EZR
Dependencies: CRC16 FreescaleIAP FreescaleWatchdog GGSProtocol LM75B PIMA Parameters PersistentCircularQueue SerialNumberV2COM mbed-dev-watchdog_2016_03_04
Fork of smartRamalKW by
alarm.cpp@35:78614a27b9e6, 2016-06-16 (annotated)
- Committer:
- fprado
- Date:
- Thu Jun 16 18:55:57 2016 +0000
- Revision:
- 35:78614a27b9e6
- Parent:
- 22:b66e36356dd4
temporary snapshot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tpadovani | 13:eed9484a89bc | 1 | #include "alarm.h" |
tpadovani | 13:eed9484a89bc | 2 | |
tpadovani | 13:eed9484a89bc | 3 | void Alarm::loadQueue(int size, int sector){ |
tpadovani | 13:eed9484a89bc | 4 | alarmQueue.init(size, sector); |
tpadovani | 15:12db9ae94161 | 5 | alarmQueue.dropQueue(); |
tpadovani | 22:b66e36356dd4 | 6 | DEBUG(printf("[Alarm] Alarm queue loaded (Max %d records)\r\n", size)); |
tpadovani | 13:eed9484a89bc | 7 | } |
tpadovani | 13:eed9484a89bc | 8 | |
tpadovani | 13:eed9484a89bc | 9 | void Alarm::writeAlarm(int code, bool state, bool previousState){ |
tpadovani | 13:eed9484a89bc | 10 | if(state == previousState){ |
tpadovani | 13:eed9484a89bc | 11 | return; |
tpadovani | 13:eed9484a89bc | 12 | } |
tpadovani | 13:eed9484a89bc | 13 | AlarmEntry entry; |
tpadovani | 13:eed9484a89bc | 14 | entry.time = time(NULL); |
tpadovani | 13:eed9484a89bc | 15 | entry.code = code; |
tpadovani | 13:eed9484a89bc | 16 | entry.state = state ? 1 : 0; |
tpadovani | 13:eed9484a89bc | 17 | |
tpadovani | 13:eed9484a89bc | 18 | alarmQueue.add((char*)&entry); |
tpadovani | 22:b66e36356dd4 | 19 | DEBUG(printf("[Alarm] New record stored: Time=%d, Code=%d, State=%d\r\n", entry.time, entry.code, entry.state)); |
tpadovani | 13:eed9484a89bc | 20 | setAlarmState(code, state); |
tpadovani | 13:eed9484a89bc | 21 | } |
tpadovani | 13:eed9484a89bc | 22 | |
tpadovani | 13:eed9484a89bc | 23 | char* Alarm::getAllAlarms(){ |
tpadovani | 13:eed9484a89bc | 24 | return alarmQueue.getAll(); |
tpadovani | 13:eed9484a89bc | 25 | } |