Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CRC16 FreescaleIAP FreescaleWatchdog GGSProtocol LM75B PIMA Parameters PersistentCircularQueue SerialNumberV2COM mbed-dev-watchdog_2016_03_04
Fork of smartRamalKW by
cmd/lerAlarmes.cpp@13:eed9484a89bc, 2015-07-28 (annotated)
- Committer:
- tpadovani
- Date:
- Tue Jul 28 17:56:11 2015 +0000
- Revision:
- 13:eed9484a89bc
Implementa??o de alarmes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tpadovani | 13:eed9484a89bc | 1 | #include "appCommands.h" |
tpadovani | 13:eed9484a89bc | 2 | #include "alarm.h" |
tpadovani | 13:eed9484a89bc | 3 | |
tpadovani | 13:eed9484a89bc | 4 | #define ALARMES_FALHA 1 |
tpadovani | 13:eed9484a89bc | 5 | #define ALARMES_FIM 2 |
tpadovani | 13:eed9484a89bc | 6 | |
tpadovani | 13:eed9484a89bc | 7 | extern Alarm alarm; |
tpadovani | 13:eed9484a89bc | 8 | char* respAlarm; |
tpadovani | 13:eed9484a89bc | 9 | |
tpadovani | 13:eed9484a89bc | 10 | void cmdLerAlarmes(int block){ |
tpadovani | 13:eed9484a89bc | 11 | if(block == 0){ |
tpadovani | 13:eed9484a89bc | 12 | free(respAlarm); |
tpadovani | 13:eed9484a89bc | 13 | respAlarm = alarm.getAllAlarms(); |
tpadovani | 13:eed9484a89bc | 14 | } |
tpadovani | 13:eed9484a89bc | 15 | |
tpadovani | 13:eed9484a89bc | 16 | if(respAlarm == NULL){ |
tpadovani | 13:eed9484a89bc | 17 | exec.enviaResposta(RESP_LER_ALARMES, ALARMES_FALHA); |
tpadovani | 13:eed9484a89bc | 18 | } else{ |
tpadovani | 13:eed9484a89bc | 19 | int alarmSize = APP_PARAMETERS.ALARMS_QUEUE_SIZE; |
tpadovani | 13:eed9484a89bc | 20 | if(alarmSize < 0 || alarmSize > 127){ |
tpadovani | 13:eed9484a89bc | 21 | alarmSize = 100; // Use default |
tpadovani | 13:eed9484a89bc | 22 | } |
tpadovani | 13:eed9484a89bc | 23 | int blocks = ceil(alarmSize / 25.0); |
tpadovani | 13:eed9484a89bc | 24 | if(blocks < 0 || blocks > 6){ |
tpadovani | 13:eed9484a89bc | 25 | blocks = 4; // Use default of 100 entries |
tpadovani | 13:eed9484a89bc | 26 | } |
tpadovani | 13:eed9484a89bc | 27 | if(block >= blocks){ |
tpadovani | 13:eed9484a89bc | 28 | exec.enviaResposta(RESP_LER_ALARMES, ALARMES_FIM); |
tpadovani | 13:eed9484a89bc | 29 | free(respAlarm); |
tpadovani | 13:eed9484a89bc | 30 | } else{ |
tpadovani | 13:eed9484a89bc | 31 | int size = 8*25; |
tpadovani | 13:eed9484a89bc | 32 | if(block == blocks-1){ |
tpadovani | 13:eed9484a89bc | 33 | size = 8*(APP_PARAMETERS.ALARMS_QUEUE_SIZE % 25); |
tpadovani | 13:eed9484a89bc | 34 | if(size == 0){ |
tpadovani | 13:eed9484a89bc | 35 | size = 8*25; |
tpadovani | 13:eed9484a89bc | 36 | } |
tpadovani | 13:eed9484a89bc | 37 | } |
tpadovani | 13:eed9484a89bc | 38 | exec.enviaResposta(RESP_LER_ALARMES, respAlarm+block*8*25, size); |
tpadovani | 13:eed9484a89bc | 39 | } |
tpadovani | 13:eed9484a89bc | 40 | } |
tpadovani | 13:eed9484a89bc | 41 | } |