Nix (Dev) 3.5.10
dev - 3.5.10 - 1af9301
Loading...
Searching...
No Matches
enums.hpp
Go to the documentation of this file.
1#ifndef IV_SRC_ALARMS_ENUMS_HPP_
2#define IV_SRC_ALARMS_ENUMS_HPP_
3
4#include "core/color.hpp"
5#include "model/enums.hpp"
6
7#include <cstdint>
8
9namespace iv::alarms
10{
11
13{
14 Alarm = 0x01, // Antiguamente 0x02
15 Critical = 0x00,// Antiguamente 0x03
16 Warning = 0x02 // Antiguamente 0x01
17};
18
19enum class eAlarmState
20{
21 Inactive = 0x00, // No alarm, normal state
22 Acknowledged = 0x01, // Ack
23 Active = 0x02, // Alarm
24 Unacknowledged = 0x03,// Return no ack
25 Undefined = 0x04, // No value
26};
27
28inline uint64_t getAlarmCodeForSlim(const iv::alarms::eAlarmState state)
29{
30 uint64_t code {0};
31
32 switch (state)
33 {
36 code = 0;
37 break;
38
40 code = 1;
41 break;
42
44 code = 2;
45 break;
46
48 code = 3;
49 break;
50 }
51
52 return code;
53}
54
55enum class eAlarmType
56{
57 Normal = 0x00,
58 AlarmOpen = 0x01,
59 AlarmClose = 0x02,
60 AlarmIfh = 0x03,
61 AlarmHh = 0x04,
62 AlarmH = 0x05,
63 AlarmL = 0x06,
64 AlarmLl = 0x07,
65 AlarmIfl = 0x08,
66 AlarmOffScan = 0x09,
67 AlarmFail = 0x0A,
68 AlarmInh = 0x0B,
69 AlarmUnk = 0x0C,
70};
71
72enum class eIsNodeOnDuty : uint8_t
73{
74 NoOnDuty = 0x00,
75 OnDuty = 0x01
76};
77
79{
80 CallAllOff = 0x00,
81 CallFromEcr = 0x01,
82 CallFromBridge = 0x02,
86 CallAllUndefined = 0xFF
87};
88
89enum class eWatchState : uint8_t
90{
91 EcrOnWatch = 0x01,
93 EcrRequestingBgrOnWatch = 0x12 /*ECR requesting BRGOnWatch*/,
94 BgrRequestingEcrOnWatch = 0x28 /*BRG requesting ECROnWatch*/,
95 BgrRequestingBgrOnWatch = 0x22 /*BRG requesting BRGOnWatch*/,
96 BgrOnWatch = 0x04 /*BRGOnWatch*/,
97 Undefined = 0x30
98};
99
100enum class eWatchCmd : uint8_t
101{
102 EcrButtonPressed = 0x0,
103 BrgButtonPressed = 0x1
104};
105
107{
108 NoAlarmRepeat = 0x00,
109 OnlyDutyAlarmRepeat = 0x01,
111 AllAlarmRepeat = 0x03
112};
113
115{
116 WatchcallNT = 0x00,
117 WatchcallCan = 0x01
118};
119
124
165
166inline std::string getAlarmIcon(const iv::alarms::eAlarmState state, const iv::alarms::eAlarmType type,
167 const iv::alarms::eAlarmPriority priority)
168{
169 static constexpr std::string resourceRoute {"diamar/"};
170 switch (type)
171 {
173 return resourceRoute + "Icon-Offscan";
174
176 return resourceRoute + "Icon-Inhibited";
177
178 default:
179 break;
180 }
181
182 auto iconPath = resourceRoute + "Icon-Offline";
183
184 switch (state)
185 {
188 iconPath = resourceRoute + "Icon-Transparent";//"Icon-Normal";
189 break;
190
193 {
194 iconPath = resourceRoute + "Icon-WarningACK";
195 }
196 else
197 {
198 iconPath = resourceRoute + "Icon-AlarmACK";
199 }
200 break;
201
204 {
205 iconPath = resourceRoute + "Icon-Warning";
206 }
207 else
208 {
209 iconPath = resourceRoute + "Icon-Alarm";
210 }
211 break;
212
214 iconPath = resourceRoute + "Icon-ReturnNoACK";
215 break;
216 }
217
218 return iconPath;
219}
220
221inline std::string toString(const eAlarmType type)
222{
223 switch (type)
224 {
226 return "Normal";
228 return "OP";
230 return "CL";
232 return "IFH";
234 return "HHAL";
236 return "HAL";
238 return "LAL";
240 return "LLAL";
242 return "IFL";
244 return "OffScan";
246 return "Fail";
248 return "INH";
250 default:
251 return "Unknown";
252 }
253}
254
255inline std::pair<iv::alarms::eAlarmState, iv::alarms::eAlarmPriority>
258{
259 iv::alarms::eAlarmState resultState {previousState};
260 iv::alarms::eAlarmPriority resultPriority {previousPriority};
261
262 if (previousState == newState)
263 {
264 if (newPriority < previousPriority)
265 {
266 resultPriority = newPriority;
267 }
268 }
269 else
270 {
271 switch (newState)
272 {
274 resultState = newState;
275 resultPriority = newPriority;
276 break;
277
279 switch (previousState)
280 {
282 break;
283
284 default:
285 resultState = newState;
286 resultPriority = newPriority;
287 }
288 break;
289
291 switch (previousState)
292 {
295 resultState = newState;
296 resultPriority = newPriority;
297 break;
298
299 default:
300 break;
301 }
302 break;
303
306 break;
307 }
308 }
309
310 return {resultState, resultPriority};
311}
312
313inline std::string callAllStatusToString(iv::alarms::eCallAllStatus callAllStatus)
314{
315 switch (callAllStatus)
316 {
319 return _("Call All");
321 return _("Call All from ECR");
323 return _("Call All From BRG");
324 default:
325 return "Unknown";
326 }
327}
328
330 iv::alarms::eWatchCmd watchCmd)
331{
332 switch (shipArea)
333 {
335 switch (watchState)
336 {
338 switch (watchCmd)
339 {
341 return _("Request ECR");
343 return _("BRG");
344 }
345 break;
346
348 switch (watchCmd)
349 {
351 return _("ECR");
353 return _("Request BRG");
354 }
355 break;
356
358 switch (watchCmd)
359 {
361 return _("ECR");
363 return _("Accept BRG");
364 }
365 break;
366
368 switch (watchCmd)
369 {
371 return _("Accept ECR");
373 return _("BRG");
374 }
375 break;
376
378 switch (watchCmd)
379 {
381 return _("ECR");
383 return _("Requesting BRG");
384 }
385 break;
386
388 switch (watchCmd)
389 {
391 return _("Requesting ECR");
393 return _("BRG");
394 }
395 break;
396
398 default:
399 break;
400 }
401 break;
402
404 switch (watchState)
405 {
407 switch (watchCmd)
408 {
410 return _("Request ECR");
412 return _("BRG");
413 }
414 break;
415
417 switch (watchCmd)
418 {
420 return _("ECR");
422 return _("Request BRG");
423 }
424 break;
425
427 switch (watchCmd)
428 {
430 return _("ECR");
432 return _("Requesting BRG");
433 }
434 break;
435
437 switch (watchCmd)
438 {
440 return _("Requesting ECR");
442 return _("BRG");
443 }
444 break;
445
447 switch (watchCmd)
448 {
450 return _("ECR");
452 return _("Accept BRG");
453 }
454 break;
455
457 switch (watchCmd)
458 {
460 return _("Accept ECR");
462 return _("BRG");
463 }
464 break;
465
467 default:
468 break;
469 }
470 break;
471
473 default:
474 switch (watchCmd)
475 {
477 return _("ECR");
479 return _("BRG");
480 }
481 break;
482 }
483
484 return _("undefined");
485}
486
487}// namespace iv::alarms
488
489#endif//IV_SRC_ALARMS_ENUMS_HPP_
#define _(string)
Definition defines.hpp:169
Definition AlarmsManager.cpp:18
eCallAllStatus
Definition enums.hpp:79
std::string watchBrgEcrButtonStatusText(iv::model::eShipArea shipArea, iv::alarms::eWatchState watchState, iv::alarms::eWatchCmd watchCmd)
Definition enums.hpp:329
eWatchCmd
Definition enums.hpp:101
iv::types::color getAlarmColor(iv::alarms::eAlarmState state, iv::alarms::eAlarmType type, iv::alarms::eAlarmPriority priority)
Definition enums.hpp:125
eWatchcallTechnology
Definition enums.hpp:115
std::string getAlarmIcon(const iv::alarms::eAlarmState state, const iv::alarms::eAlarmType type, const iv::alarms::eAlarmPriority priority)
Definition enums.hpp:166
std::pair< iv::alarms::eAlarmState, iv::alarms::eAlarmPriority > getHigherPreference(iv::alarms::eAlarmState previousState, iv::alarms::eAlarmPriority previousPriority, iv::alarms::eAlarmState newState, iv::alarms::eAlarmPriority newPriority)
Definition enums.hpp:256
eAlarmPriority
Definition enums.hpp:13
std::string callAllStatusToString(iv::alarms::eCallAllStatus callAllStatus)
Definition enums.hpp:313
eAlarmRepeatType
Definition enums.hpp:107
uint64_t getAlarmCodeForSlim(const iv::alarms::eAlarmState state)
Definition enums.hpp:28
eWatchState
Definition enums.hpp:90
eAlarmType
Definition enums.hpp:56
bool isStateAlarmWithPermission(const iv::alarms::eAlarmState state)
Definition enums.hpp:120
std::string toString(const eAlarmType type)
Definition enums.hpp:221
eIsNodeOnDuty
Definition enums.hpp:73
eAlarmState
Definition enums.hpp:20
constexpr iv::types::color SedniWarning
Definition color.hpp:323
constexpr iv::types::color Silver
Definition color.hpp:201
constexpr iv::types::color SedniInhibition
Definition color.hpp:334
constexpr iv::types::color SedniNoConnection
Definition color.hpp:335
constexpr iv::types::color SedniNoAlarm
Definition color.hpp:332
constexpr iv::types::color SedniAlarm
Definition color.hpp:322
constexpr iv::types::color SedniUnacknowledgedAlarm
Definition color.hpp:327
eShipArea
Definition enums.hpp:11
uint32_t color
Definition types.hpp:12
Definition structs.hpp:16