teste de publish

Committer:
brunofgc
Date:
Thu Mar 30 19:53:22 2017 +0000
Revision:
1:3f9e5b86d9e4
Parent:
0:8c59a494a451
Child:
2:ca3723da6668
Antes de corrigir o vazamento de mem?ria (Aloca??o din?mica mal feita)

Who changed what in which revision?

UserRevisionLine numberNew 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 0:8c59a494a451 4 #ifndef _devices_h_
brunofgc 0:8c59a494a451 5 #define _devices_h_
brunofgc 0:8c59a494a451 6 #define maxCaractereLeLinha 40
brunofgc 0:8c59a494a451 7 #include <cstdlib>
brunofgc 0:8c59a494a451 8
brunofgc 1:3f9e5b86d9e4 9 #define enderecoControladoraVirtual 0
brunofgc 1:3f9e5b86d9e4 10
brunofgc 0:8c59a494a451 11 enum {
brunofgc 0:8c59a494a451 12 modBusType_float=1,
brunofgc 0:8c59a494a451 13 modBusType_bit,
brunofgc 0:8c59a494a451 14 modBusType_uint8_t,
brunofgc 0:8c59a494a451 15 modBusType_uint16_t,
brunofgc 0:8c59a494a451 16 modBusType_uint32_t,
brunofgc 1:3f9e5b86d9e4 17 IrCommandType,
brunofgc 1:3f9e5b86d9e4 18 PWMCommandType
brunofgc 0:8c59a494a451 19 };
brunofgc 0:8c59a494a451 20
brunofgc 0:8c59a494a451 21 typedef struct _alarm{
brunofgc 0:8c59a494a451 22 uint32_t id;
brunofgc 0:8c59a494a451 23 //Tempos de confirmação
brunofgc 0:8c59a494a451 24 uint32_t seconds;
brunofgc 0:8c59a494a451 25 //Var Read block
brunofgc 0:8c59a494a451 26 uint8_t type;
brunofgc 0:8c59a494a451 27 uint16_t addrModbusRead;
brunofgc 0:8c59a494a451 28 uint8_t funcModbusRead;
brunofgc 0:8c59a494a451 29 uint16_t regModbusRead;
brunofgc 0:8c59a494a451 30 uint8_t max; //1 Max; 0 Min
brunofgc 0:8c59a494a451 31 uint8_t value[4];
brunofgc 0:8c59a494a451 32
brunofgc 0:8c59a494a451 33 //Act block
brunofgc 0:8c59a494a451 34 uint32_t idAct;
brunofgc 0:8c59a494a451 35
brunofgc 0:8c59a494a451 36 //Maquina de estados alarme
brunofgc 0:8c59a494a451 37 uint32_t secAlarm;
brunofgc 0:8c59a494a451 38 bool alarmFound;
brunofgc 0:8c59a494a451 39 }alarm;
brunofgc 0:8c59a494a451 40
brunofgc 0:8c59a494a451 41 typedef struct _reading{
brunofgc 0:8c59a494a451 42 uint8_t type;
brunofgc 0:8c59a494a451 43 uint8_t addr;
brunofgc 0:8c59a494a451 44 uint8_t func;
brunofgc 0:8c59a494a451 45 uint16_t reg;
brunofgc 0:8c59a494a451 46 uint8_t numRegs;
brunofgc 0:8c59a494a451 47 }reading;
brunofgc 0:8c59a494a451 48
brunofgc 0:8c59a494a451 49 typedef struct _schedule{
brunofgc 0:8c59a494a451 50 uint32_t id;
brunofgc 0:8c59a494a451 51 uint8_t weekday;
brunofgc 0:8c59a494a451 52 uint16_t minute; // Minuto do dia em que será executada a ação programada
brunofgc 0:8c59a494a451 53
brunofgc 0:8c59a494a451 54 //Act block
brunofgc 0:8c59a494a451 55 uint32_t idAct;
brunofgc 0:8c59a494a451 56 //Maquina de estados alarme
brunofgc 0:8c59a494a451 57 bool actSent;
brunofgc 0:8c59a494a451 58 }schedule;
brunofgc 0:8c59a494a451 59
brunofgc 0:8c59a494a451 60 class device{
brunofgc 0:8c59a494a451 61 private:
brunofgc 1:3f9e5b86d9e4 62 uint8_t execActAlarm(uint32_t);
brunofgc 1:3f9e5b86d9e4 63 public:
brunofgc 0:8c59a494a451 64 uint8_t execAct(uint32_t);
brunofgc 0:8c59a494a451 65 uint8_t numAlarms;
brunofgc 0:8c59a494a451 66 uint8_t numSchedules;
brunofgc 0:8c59a494a451 67 uint16_t numReadings;
brunofgc 0:8c59a494a451 68 alarm *alarms;
brunofgc 0:8c59a494a451 69 reading *readings;
brunofgc 0:8c59a494a451 70 schedule *schedules;
brunofgc 0:8c59a494a451 71 //uint32_t id;
brunofgc 0:8c59a494a451 72
brunofgc 0:8c59a494a451 73 device();
brunofgc 0:8c59a494a451 74
brunofgc 0:8c59a494a451 75 void floatToBin(uint8_t,float *,uint8_t *);
brunofgc 0:8c59a494a451 76 void uint32_t_ToBin(uint8_t,uint32_t *,uint8_t *);
brunofgc 0:8c59a494a451 77 void uint16_t_ToBin(uint8_t,uint16_t *,uint8_t *);
brunofgc 0:8c59a494a451 78 void setAlarm(char *);
brunofgc 0:8c59a494a451 79 void setReading(char *);
brunofgc 0:8c59a494a451 80 void setSchedule(char *);
brunofgc 0:8c59a494a451 81 void verifyAlarms();
brunofgc 0:8c59a494a451 82 void verifySchedules();
brunofgc 0:8c59a494a451 83 void writeReadingsToSD();
brunofgc 0:8c59a494a451 84 };
brunofgc 0:8c59a494a451 85
brunofgc 0:8c59a494a451 86 int criaDevices(FILE *);
brunofgc 0:8c59a494a451 87 int configuraDevices(FILE *);
brunofgc 0:8c59a494a451 88 uint8_t resizeArray(uint32_t,uint32_t,char **,uint16_t);
brunofgc 0:8c59a494a451 89 void testaTudoDevices();
brunofgc 0:8c59a494a451 90 void writeReadingsToSD();
brunofgc 0:8c59a494a451 91 void verifyAlarms();
brunofgc 0:8c59a494a451 92 void verifySchedules();
brunofgc 0:8c59a494a451 93 #endif