teste de publish
devices.h@17:c046e4b07ded, 2018-05-01 (annotated)
- Committer:
- brunofgc
- Date:
- Tue May 01 03:27:47 2018 +0000
- Revision:
- 17:c046e4b07ded
- Parent:
- 5:8efd609dea7d
- Child:
- 19:d52176ff683d
Nova vers?o em teste. (Inclu?ndo a capacidade de ler int16 e 32 com sinal)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brunofgc | 0:8c59a494a451 | 1 | #include "mbed.h" |
brunofgc | 0:8c59a494a451 | 2 | #include "funcoesSDCard.h" |
brunofgc | 0:8c59a494a451 | 3 | #include "modbusMaster1.h" |
brunofgc | 5:8efd609dea7d | 4 | #include "SDFileSystem.h" |
brunofgc | 0:8c59a494a451 | 5 | #ifndef _devices_h_ |
brunofgc | 0:8c59a494a451 | 6 | #define _devices_h_ |
brunofgc | 0:8c59a494a451 | 7 | #define maxCaractereLeLinha 40 |
brunofgc | 0:8c59a494a451 | 8 | #include <cstdlib> |
brunofgc | 0:8c59a494a451 | 9 | |
brunofgc | 1:3f9e5b86d9e4 | 10 | #define enderecoControladoraVirtual 0 |
brunofgc | 1:3f9e5b86d9e4 | 11 | |
brunofgc | 0:8c59a494a451 | 12 | enum { |
brunofgc | 0:8c59a494a451 | 13 | modBusType_float=1, |
brunofgc | 0:8c59a494a451 | 14 | modBusType_bit, |
brunofgc | 0:8c59a494a451 | 15 | modBusType_uint8_t, |
brunofgc | 0:8c59a494a451 | 16 | modBusType_uint16_t, |
brunofgc | 0:8c59a494a451 | 17 | modBusType_uint32_t, |
brunofgc | 17:c046e4b07ded | 18 | modBusType_int16_t, |
brunofgc | 17:c046e4b07ded | 19 | modBusType_int32_t, |
brunofgc | 1:3f9e5b86d9e4 | 20 | IrCommandType, |
brunofgc | 1:3f9e5b86d9e4 | 21 | PWMCommandType |
brunofgc | 0:8c59a494a451 | 22 | }; |
brunofgc | 0:8c59a494a451 | 23 | |
brunofgc | 0:8c59a494a451 | 24 | typedef struct _alarm{ |
brunofgc | 0:8c59a494a451 | 25 | uint32_t id; |
brunofgc | 0:8c59a494a451 | 26 | //Tempos de confirmação |
brunofgc | 0:8c59a494a451 | 27 | uint32_t seconds; |
brunofgc | 0:8c59a494a451 | 28 | //Var Read block |
brunofgc | 0:8c59a494a451 | 29 | uint8_t type; |
brunofgc | 0:8c59a494a451 | 30 | uint16_t addrModbusRead; |
brunofgc | 0:8c59a494a451 | 31 | uint8_t funcModbusRead; |
brunofgc | 0:8c59a494a451 | 32 | uint16_t regModbusRead; |
brunofgc | 0:8c59a494a451 | 33 | uint8_t max; //1 Max; 0 Min |
brunofgc | 0:8c59a494a451 | 34 | uint8_t value[4]; |
brunofgc | 0:8c59a494a451 | 35 | |
brunofgc | 0:8c59a494a451 | 36 | //Act block |
brunofgc | 0:8c59a494a451 | 37 | uint32_t idAct; |
brunofgc | 0:8c59a494a451 | 38 | |
brunofgc | 0:8c59a494a451 | 39 | //Maquina de estados alarme |
brunofgc | 0:8c59a494a451 | 40 | uint32_t secAlarm; |
brunofgc | 0:8c59a494a451 | 41 | bool alarmFound; |
brunofgc | 5:8efd609dea7d | 42 | bool on; |
brunofgc | 0:8c59a494a451 | 43 | }alarm; |
brunofgc | 0:8c59a494a451 | 44 | |
brunofgc | 4:3f92979d1ffb | 45 | |
brunofgc | 4:3f92979d1ffb | 46 | |
brunofgc | 0:8c59a494a451 | 47 | typedef struct _reading{ |
brunofgc | 0:8c59a494a451 | 48 | uint8_t type; |
brunofgc | 0:8c59a494a451 | 49 | uint8_t addr; |
brunofgc | 0:8c59a494a451 | 50 | uint8_t func; |
brunofgc | 0:8c59a494a451 | 51 | uint16_t reg; |
brunofgc | 0:8c59a494a451 | 52 | uint8_t numRegs; |
brunofgc | 0:8c59a494a451 | 53 | }reading; |
brunofgc | 0:8c59a494a451 | 54 | |
brunofgc | 4:3f92979d1ffb | 55 | typedef struct _scheduleException{ |
brunofgc | 4:3f92979d1ffb | 56 | uint32_t id_schedule; |
brunofgc | 4:3f92979d1ffb | 57 | uint32_t timestamp; |
brunofgc | 4:3f92979d1ffb | 58 | }scheduleException; |
brunofgc | 4:3f92979d1ffb | 59 | |
brunofgc | 0:8c59a494a451 | 60 | typedef struct _schedule{ |
brunofgc | 0:8c59a494a451 | 61 | uint32_t id; |
brunofgc | 0:8c59a494a451 | 62 | uint8_t weekday; |
brunofgc | 0:8c59a494a451 | 63 | uint16_t minute; // Minuto do dia em que será executada a ação programada |
brunofgc | 0:8c59a494a451 | 64 | |
brunofgc | 0:8c59a494a451 | 65 | //Act block |
brunofgc | 0:8c59a494a451 | 66 | uint32_t idAct; |
brunofgc | 0:8c59a494a451 | 67 | //Maquina de estados alarme |
brunofgc | 0:8c59a494a451 | 68 | bool actSent; |
brunofgc | 0:8c59a494a451 | 69 | }schedule; |
brunofgc | 0:8c59a494a451 | 70 | |
brunofgc | 0:8c59a494a451 | 71 | class device{ |
brunofgc | 0:8c59a494a451 | 72 | private: |
brunofgc | 1:3f9e5b86d9e4 | 73 | public: |
brunofgc | 5:8efd609dea7d | 74 | uint8_t execAct(uint32_t); |
brunofgc | 0:8c59a494a451 | 75 | uint8_t numAlarms; |
brunofgc | 0:8c59a494a451 | 76 | uint8_t numSchedules; |
brunofgc | 4:3f92979d1ffb | 77 | uint8_t numScheduleExceptions; |
brunofgc | 0:8c59a494a451 | 78 | uint16_t numReadings; |
brunofgc | 0:8c59a494a451 | 79 | alarm *alarms; |
brunofgc | 0:8c59a494a451 | 80 | reading *readings; |
brunofgc | 0:8c59a494a451 | 81 | schedule *schedules; |
brunofgc | 4:3f92979d1ffb | 82 | scheduleException *scheduleExceptions; |
brunofgc | 0:8c59a494a451 | 83 | //uint32_t id; |
brunofgc | 0:8c59a494a451 | 84 | |
brunofgc | 0:8c59a494a451 | 85 | device(); |
brunofgc | 0:8c59a494a451 | 86 | |
brunofgc | 0:8c59a494a451 | 87 | void floatToBin(uint8_t,float *,uint8_t *); |
brunofgc | 0:8c59a494a451 | 88 | void uint32_t_ToBin(uint8_t,uint32_t *,uint8_t *); |
brunofgc | 0:8c59a494a451 | 89 | void uint16_t_ToBin(uint8_t,uint16_t *,uint8_t *); |
brunofgc | 0:8c59a494a451 | 90 | void setAlarm(char *); |
brunofgc | 0:8c59a494a451 | 91 | void setReading(char *); |
brunofgc | 4:3f92979d1ffb | 92 | void setSchedule(char *); |
brunofgc | 4:3f92979d1ffb | 93 | void setScheduleException(char *); |
brunofgc | 0:8c59a494a451 | 94 | void verifyAlarms(); |
brunofgc | 0:8c59a494a451 | 95 | void verifySchedules(); |
brunofgc | 5:8efd609dea7d | 96 | void writeReadingsToSD(); |
brunofgc | 5:8efd609dea7d | 97 | void alarmOnOff(uint32_t,bool); |
brunofgc | 0:8c59a494a451 | 98 | }; |
brunofgc | 0:8c59a494a451 | 99 | |
brunofgc | 0:8c59a494a451 | 100 | int criaDevices(FILE *); |
brunofgc | 0:8c59a494a451 | 101 | int configuraDevices(FILE *); |
brunofgc | 2:ca3723da6668 | 102 | //uint8_t resizeArray(uint32_t,uint32_t,char **,uint16_t); |
brunofgc | 0:8c59a494a451 | 103 | void testaTudoDevices(); |
brunofgc | 0:8c59a494a451 | 104 | void writeReadingsToSD(); |
brunofgc | 0:8c59a494a451 | 105 | void verifyAlarms(); |
brunofgc | 0:8c59a494a451 | 106 | void verifySchedules(); |
brunofgc | 0:8c59a494a451 | 107 | #endif |