teste de publish

Committer:
brunofgc
Date:
Fri Mar 24 15:54:14 2017 +0000
Revision:
0:8c59a494a451
Child:
1:3f9e5b86d9e4
Novas funcionalidades. Saidas Digitais com pwm, entradas analogicas.

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