Frederico Prado / smartRamalEZR

Dependencies:   CRC16 FreescaleIAP FreescaleWatchdog GGSProtocol LM75B PIMA Parameters PersistentCircularQueue SerialNumberV2COM mbed-dev-watchdog_2016_03_04

Fork of smartRamalKW by Equipe Firmware V2COM

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers alarm.cpp Source File

alarm.cpp

00001 #include "alarm.h"
00002 
00003 void Alarm::loadQueue(int size, int sector){
00004     alarmQueue.init(size, sector);
00005     alarmQueue.dropQueue();
00006     DEBUG(printf("[Alarm] Alarm queue loaded (Max %d records)\r\n", size));
00007 }
00008 
00009 void Alarm::writeAlarm(int code, bool state, bool previousState){
00010     if(state == previousState){
00011         return;
00012     }
00013     AlarmEntry entry;
00014     entry.time = time(NULL);
00015     entry.code = code;
00016     entry.state = state ? 1 : 0;
00017     
00018     alarmQueue.add((char*)&entry);
00019     DEBUG(printf("[Alarm] New record stored: Time=%d, Code=%d, State=%d\r\n", entry.time, entry.code, entry.state));
00020     setAlarmState(code, state);
00021 }
00022 
00023 char* Alarm::getAllAlarms(){
00024     return alarmQueue.getAll();
00025 }