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