-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotification.cpp
More file actions
150 lines (115 loc) · 3.98 KB
/
Copy pathNotification.cpp
File metadata and controls
150 lines (115 loc) · 3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include "Notification.h"
#include <libutils/Logger.h>
#include <iostream>
#include "SysInfo.h"
using namespace std;
using namespace Utils;
namespace OPI
{
Notification notification;
Notification::Notification() = default;
void Notification::Notify(Notification::Notice notice, const string &info)
{
switch (sysinfo.Type()) {
case SysInfo::TypePC:
{
switch ( notice ) {
case Notification::Completed:
logg << Logger::Notice << "Completed: [" << info << "]" << lend;
break;
case Notification::Waiting:
logg << Logger::Notice << "Waiting: [" << info << "]" << lend;
break;
case Notification::Error:
logg << Logger::Error << "Error: [" << info << "]" << lend;
break;
default:
break;
}
}
break;
case SysInfo::TypeOpi:
{
switch ( notice ) {
case Notification::Completed:
// all green leds on
this->leds.SetTrigger("usr0", "none");
this->leds.Brightness("usr0", true);
this->leds.SetTrigger("usr1", "none");
this->leds.Brightness("usr1", true);
this->leds.SetTrigger("usr2", "none");
this->leds.Brightness("usr2", true);
// red led off
this->leds.SetTrigger("usr3", "none");
this->leds.Brightness("usr3", false);
break;
case Notification::Waiting:
// first and second green leds on
this->leds.SetTrigger("usr0", "none");
this->leds.Brightness("usr0", true);
this->leds.SetTrigger("usr1", "none");
this->leds.Brightness("usr1", true);
// heartbeat on third led
this->leds.SetTrigger("usr2", "heartbeat");
this->leds.Brightness("usr2", true);
// red led off
this->leds.SetTrigger("usr3", "none");
this->leds.Brightness("usr3", false);
break;
case Notification::Error:
// first and second green leds on
this->leds.SetTrigger("usr0", "none");
this->leds.Brightness("usr0", true);
this->leds.SetTrigger("usr1", "none");
this->leds.Brightness("usr1", true);
// third led off
this->leds.SetTrigger("usr2", "none");
this->leds.Brightness("usr2", false);
// red led heartbeat
this->leds.SetTrigger("usr3", "heartbeat");
break;
default:
break;
}
}
break;
case SysInfo::TypeArmada:
{
switch ( notice ) {
// "heartbeat" trigger can have LED in either state, when changing to "none"
// make sure to set the value also.
case Notification::Completed:
this->leds.SetTrigger("blue","none");
this->leds.Brightness("blue", false); // make sure led is turned off.
this->leds.SetTrigger("red","none");
this->leds.Brightness("red", false); // make sure led is turned off.
this->leds.SetTrigger("green","none");
this->leds.Brightness("green", true); // make sure led is turned on.
break;
case Notification::Waiting:
this->leds.SetTrigger("blue","none");
this->leds.Brightness("blue", false); // make sure led is turned off.
this->leds.SetTrigger("red","none");
this->leds.Brightness("red", false); // make sure led is turned off.
this->leds.SetTrigger("green","heartbeat");
break;
case Notification::Error:
this->leds.SetTrigger("blue","none");
this->leds.Brightness("blue", false); // make sure led is turned off.
this->leds.SetTrigger("red","none");
this->leds.Brightness("red", true); // make sure led is turned on.
this->leds.SetTrigger("green","none");
this->leds.Brightness("green", false); // make sure led is turned off.
break;
default:
break;
}
}
break;
default:
logg << Logger::Notice << "Unimplemented system type in Notification subsytem" << lend;
break;
}
}
Notification::~Notification() = default;
}