teste de publish

Committer:
brunofgc
Date:
Wed Jun 07 19:38:14 2017 +0000
Revision:
4:3f92979d1ffb
Parent:
2:ca3723da6668
Child:
5:8efd609dea7d
Ultima vers?o com erro no envio IR

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 4:3f92979d1ffb 41
brunofgc 4:3f92979d1ffb 42
brunofgc 0:8c59a494a451 43 typedef struct _reading{
brunofgc 0:8c59a494a451 44 uint8_t type;
brunofgc 0:8c59a494a451 45 uint8_t addr;
brunofgc 0:8c59a494a451 46 uint8_t func;
brunofgc 0:8c59a494a451 47 uint16_t reg;
brunofgc 0:8c59a494a451 48 uint8_t numRegs;
brunofgc 0:8c59a494a451 49 }reading;
brunofgc 0:8c59a494a451 50
brunofgc 4:3f92979d1ffb 51 typedef struct _scheduleException{
brunofgc 4:3f92979d1ffb 52 uint32_t id_schedule;
brunofgc 4:3f92979d1ffb 53 uint32_t timestamp;
brunofgc 4:3f92979d1ffb 54 }scheduleException;
brunofgc 4:3f92979d1ffb 55
brunofgc 0:8c59a494a451 56 typedef struct _schedule{
brunofgc 0:8c59a494a451 57 uint32_t id;
brunofgc 0:8c59a494a451 58 uint8_t weekday;
brunofgc 0:8c59a494a451 59 uint16_t minute; // Minuto do dia em que será executada a ação programada
brunofgc 0:8c59a494a451 60
brunofgc 0:8c59a494a451 61 //Act block
brunofgc 0:8c59a494a451 62 uint32_t idAct;
brunofgc 0:8c59a494a451 63 //Maquina de estados alarme
brunofgc 0:8c59a494a451 64 bool actSent;
brunofgc 0:8c59a494a451 65 }schedule;
brunofgc 0:8c59a494a451 66
brunofgc 0:8c59a494a451 67 class device{
brunofgc 0:8c59a494a451 68 private:
brunofgc 1:3f9e5b86d9e4 69 uint8_t execActAlarm(uint32_t);
brunofgc 1:3f9e5b86d9e4 70 public:
brunofgc 0:8c59a494a451 71 uint8_t execAct(uint32_t);
brunofgc 0:8c59a494a451 72 uint8_t numAlarms;
brunofgc 0:8c59a494a451 73 uint8_t numSchedules;
brunofgc 4:3f92979d1ffb 74 uint8_t numScheduleExceptions;
brunofgc 0:8c59a494a451 75 uint16_t numReadings;
brunofgc 0:8c59a494a451 76 alarm *alarms;
brunofgc 0:8c59a494a451 77 reading *readings;
brunofgc 0:8c59a494a451 78 schedule *schedules;
brunofgc 4:3f92979d1ffb 79 scheduleException *scheduleExceptions;
brunofgc 0:8c59a494a451 80 //uint32_t id;
brunofgc 0:8c59a494a451 81
brunofgc 0:8c59a494a451 82 device();
brunofgc 0:8c59a494a451 83
brunofgc 0:8c59a494a451 84 void floatToBin(uint8_t,float *,uint8_t *);
brunofgc 0:8c59a494a451 85 void uint32_t_ToBin(uint8_t,uint32_t *,uint8_t *);
brunofgc 0:8c59a494a451 86 void uint16_t_ToBin(uint8_t,uint16_t *,uint8_t *);
brunofgc 0:8c59a494a451 87 void setAlarm(char *);
brunofgc 0:8c59a494a451 88 void setReading(char *);
brunofgc 4:3f92979d1ffb 89 void setSchedule(char *);
brunofgc 4:3f92979d1ffb 90 void setScheduleException(char *);
brunofgc 0:8c59a494a451 91 void verifyAlarms();
brunofgc 0:8c59a494a451 92 void verifySchedules();
brunofgc 0:8c59a494a451 93 void writeReadingsToSD();
brunofgc 0:8c59a494a451 94 };
brunofgc 0:8c59a494a451 95
brunofgc 0:8c59a494a451 96 int criaDevices(FILE *);
brunofgc 0:8c59a494a451 97 int configuraDevices(FILE *);
brunofgc 2:ca3723da6668 98 //uint8_t resizeArray(uint32_t,uint32_t,char **,uint16_t);
brunofgc 0:8c59a494a451 99 void testaTudoDevices();
brunofgc 0:8c59a494a451 100 void writeReadingsToSD();
brunofgc 0:8c59a494a451 101 void verifyAlarms();
brunofgc 0:8c59a494a451 102 void verifySchedules();
brunofgc 0:8c59a494a451 103 #endif