Versão do protegemed que calcula o tempo em ms da fuga, calcula o numero de onverflow (valores muito baixo) e underflow (valores muito altos). Além disso, calcula um valor médio a partir dos valores capturados e não apenas pela fft.
Dependencies: EthernetInterface mbed-rtos mbed
Headers/Settings.h@2:86c3cb25577b, 2014-07-21 (annotated)
- Committer:
- rebonatto
- Date:
- Mon Jul 21 00:58:34 2014 +0000
- Revision:
- 2:86c3cb25577b
- Parent:
- 0:c64e1194230b
Problemas com objeto para aquisi??o da rfid (serial)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rebonatto | 0:c64e1194230b | 1 | /* |
rebonatto | 0:c64e1194230b | 2 | * Settings.h |
rebonatto | 0:c64e1194230b | 3 | * |
rebonatto | 0:c64e1194230b | 4 | * Created on: |
rebonatto | 0:c64e1194230b | 5 | * Author: |
rebonatto | 0:c64e1194230b | 6 | */ |
rebonatto | 0:c64e1194230b | 7 | |
rebonatto | 0:c64e1194230b | 8 | #ifndef SETTINGS_H |
rebonatto | 0:c64e1194230b | 9 | #define SETTINGS_H |
rebonatto | 0:c64e1194230b | 10 | |
rebonatto | 0:c64e1194230b | 11 | #include <stdio.h> |
rebonatto | 0:c64e1194230b | 12 | #include <string.h> |
rebonatto | 0:c64e1194230b | 13 | #include <ctype.h> |
rebonatto | 0:c64e1194230b | 14 | |
rebonatto | 0:c64e1194230b | 15 | #include "mbed.h" |
rebonatto | 0:c64e1194230b | 16 | #include "EthernetInterface.h" |
rebonatto | 0:c64e1194230b | 17 | |
rebonatto | 0:c64e1194230b | 18 | #include "Split.h" |
rebonatto | 0:c64e1194230b | 19 | |
rebonatto | 0:c64e1194230b | 20 | #define FILENAME "/local/pmed.txt" |
rebonatto | 0:c64e1194230b | 21 | #define FILENAMERESET "/local/foi.txt" |
rebonatto | 0:c64e1194230b | 22 | #define NUMBER_OF_CHANNELS 6U |
rebonatto | 0:c64e1194230b | 23 | #define NUMBER_OF_OUTLETS 3U |
rebonatto | 0:c64e1194230b | 24 | #define NUMBER_OF_HARMONICS 12U |
rebonatto | 0:c64e1194230b | 25 | #define NUMBER_OF_SAMPLES 256U |
rebonatto | 0:c64e1194230b | 26 | #define LENGTH_MAIL_BOX 50U |
rebonatto | 0:c64e1194230b | 27 | #define NEIGHBORS 3U |
rebonatto | 0:c64e1194230b | 28 | |
rebonatto | 0:c64e1194230b | 29 | class Settings |
rebonatto | 0:c64e1194230b | 30 | { |
rebonatto | 0:c64e1194230b | 31 | |
rebonatto | 0:c64e1194230b | 32 | //server URL |
rebonatto | 0:c64e1194230b | 33 | static char* m_serverurl; |
rebonatto | 0:c64e1194230b | 34 | //module number |
rebonatto | 0:c64e1194230b | 35 | static int m_module_number; |
rebonatto | 0:c64e1194230b | 36 | //ip address |
rebonatto | 0:c64e1194230b | 37 | static char* m_ipaddress; |
rebonatto | 0:c64e1194230b | 38 | //netmask |
rebonatto | 0:c64e1194230b | 39 | static char* m_netmask; |
rebonatto | 0:c64e1194230b | 40 | //gateway |
rebonatto | 0:c64e1194230b | 41 | static char* m_gateway; |
rebonatto | 0:c64e1194230b | 42 | //dhcp |
rebonatto | 0:c64e1194230b | 43 | static int m_dhcp; |
rebonatto | 0:c64e1194230b | 44 | |
rebonatto | 0:c64e1194230b | 45 | //gain x6(float) |
rebonatto | 0:c64e1194230b | 46 | static float m_gain[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 47 | //offset x6(int) |
rebonatto | 0:c64e1194230b | 48 | static int m_offset[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 49 | //limit x6(float) |
rebonatto | 0:c64e1194230b | 50 | static float m_limit[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 51 | //outlet x6 (int) |
rebonatto | 0:c64e1194230b | 52 | static int m_outlet_number[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 53 | //purpose x6(char) |
rebonatto | 0:c64e1194230b | 54 | static char m_purpose[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 55 | |
rebonatto | 0:c64e1194230b | 56 | //outlet x3(int) |
rebonatto | 0:c64e1194230b | 57 | static int m_outlet[NUMBER_OF_OUTLETS]; |
rebonatto | 0:c64e1194230b | 58 | |
rebonatto | 0:c64e1194230b | 59 | //MaxChannels |
rebonatto | 0:c64e1194230b | 60 | static int m_MaxChannels; |
rebonatto | 0:c64e1194230b | 61 | //MaxOutlets |
rebonatto | 0:c64e1194230b | 62 | static int m_MaxOutlets; |
rebonatto | 0:c64e1194230b | 63 | //Samples |
rebonatto | 0:c64e1194230b | 64 | static int m_Samples; |
rebonatto | 0:c64e1194230b | 65 | |
rebonatto | 0:c64e1194230b | 66 | //FreqBase |
rebonatto | 0:c64e1194230b | 67 | static int m_FreqBase; |
rebonatto | 0:c64e1194230b | 68 | |
rebonatto | 0:c64e1194230b | 69 | //MaxHarmonics |
rebonatto | 0:c64e1194230b | 70 | static int m_MaxHarmonics; |
rebonatto | 0:c64e1194230b | 71 | |
rebonatto | 0:c64e1194230b | 72 | //EventLimit |
rebonatto | 0:c64e1194230b | 73 | static int m_EventLimit; |
rebonatto | 0:c64e1194230b | 74 | |
rebonatto | 0:c64e1194230b | 75 | //MailBoxLength |
rebonatto | 0:c64e1194230b | 76 | static int m_MBoxLength; |
rebonatto | 0:c64e1194230b | 77 | |
rebonatto | 0:c64e1194230b | 78 | //NumberNeighbors |
rebonatto | 0:c64e1194230b | 79 | static int m_NumNeighbors; |
rebonatto | 0:c64e1194230b | 80 | |
rebonatto | 0:c64e1194230b | 81 | //Neighbors x3(char [16]) |
rebonatto | 0:c64e1194230b | 82 | static char *m_Neighbor[NEIGHBORS]; |
rebonatto | 0:c64e1194230b | 83 | |
rebonatto | 0:c64e1194230b | 84 | //PortTCP |
rebonatto | 0:c64e1194230b | 85 | static int m_PortTCP; |
rebonatto | 0:c64e1194230b | 86 | |
rebonatto | 0:c64e1194230b | 87 | //Socket to receive requests |
rebonatto | 0:c64e1194230b | 88 | static TCPSocketServer m_ServerSocket; |
rebonatto | 0:c64e1194230b | 89 | |
rebonatto | 0:c64e1194230b | 90 | //Socket to send requests |
rebonatto | 0:c64e1194230b | 91 | static TCPSocketConnection m_Socket[NEIGHBORS]; |
rebonatto | 0:c64e1194230b | 92 | |
rebonatto | 0:c64e1194230b | 93 | //Maximum number of try connect and send |
rebonatto | 0:c64e1194230b | 94 | static int m_MaxTries; |
rebonatto | 0:c64e1194230b | 95 | |
rebonatto | 0:c64e1194230b | 96 | //Delay time (ms) between 2 tries |
rebonatto | 0:c64e1194230b | 97 | static int m_DelayTry; |
rebonatto | 0:c64e1194230b | 98 | |
rebonatto | 0:c64e1194230b | 99 | //Delay time (ms) after Send (post) |
rebonatto | 0:c64e1194230b | 100 | static int m_DelaySend; |
rebonatto | 0:c64e1194230b | 101 | |
rebonatto | 0:c64e1194230b | 102 | |
rebonatto | 0:c64e1194230b | 103 | public: |
rebonatto | 0:c64e1194230b | 104 | |
rebonatto | 0:c64e1194230b | 105 | Settings(); |
rebonatto | 0:c64e1194230b | 106 | |
rebonatto | 0:c64e1194230b | 107 | static char* get_ServerUrl() { return m_serverurl; } |
rebonatto | 0:c64e1194230b | 108 | static void set_ServerUrl(char *value) |
rebonatto | 0:c64e1194230b | 109 | { |
rebonatto | 0:c64e1194230b | 110 | if(m_serverurl!=NULL) delete m_serverurl; |
rebonatto | 0:c64e1194230b | 111 | int sz = strlen(value)+1; |
rebonatto | 0:c64e1194230b | 112 | m_serverurl = new char[sz]; |
rebonatto | 0:c64e1194230b | 113 | strcpy(m_serverurl,value); |
rebonatto | 0:c64e1194230b | 114 | } |
rebonatto | 0:c64e1194230b | 115 | static char* get_IpAddress() { return m_ipaddress; } |
rebonatto | 0:c64e1194230b | 116 | static void set_IpAddress(char *value) |
rebonatto | 0:c64e1194230b | 117 | { |
rebonatto | 0:c64e1194230b | 118 | if(m_ipaddress!=NULL) delete m_ipaddress; |
rebonatto | 0:c64e1194230b | 119 | int sz = strlen(value)+1; |
rebonatto | 0:c64e1194230b | 120 | m_ipaddress = new char[sz]; |
rebonatto | 0:c64e1194230b | 121 | strcpy(m_ipaddress,value); |
rebonatto | 0:c64e1194230b | 122 | } |
rebonatto | 0:c64e1194230b | 123 | static char* get_Netmask() { return m_netmask; } |
rebonatto | 0:c64e1194230b | 124 | static void set_Netmask(char *value) |
rebonatto | 0:c64e1194230b | 125 | { |
rebonatto | 0:c64e1194230b | 126 | if(m_netmask!=NULL) delete m_netmask; |
rebonatto | 0:c64e1194230b | 127 | int sz = strlen(value)+1; |
rebonatto | 0:c64e1194230b | 128 | m_netmask = new char[sz]; |
rebonatto | 0:c64e1194230b | 129 | strcpy(m_netmask,value); |
rebonatto | 0:c64e1194230b | 130 | } |
rebonatto | 0:c64e1194230b | 131 | |
rebonatto | 0:c64e1194230b | 132 | static char* get_Gateway() { return m_gateway; } |
rebonatto | 0:c64e1194230b | 133 | static void set_Gateway(char *value) |
rebonatto | 0:c64e1194230b | 134 | { |
rebonatto | 0:c64e1194230b | 135 | if(m_gateway!=NULL) delete m_gateway; |
rebonatto | 0:c64e1194230b | 136 | int sz = strlen(value)+1; |
rebonatto | 0:c64e1194230b | 137 | m_gateway = new char[sz]; |
rebonatto | 0:c64e1194230b | 138 | strcpy(m_gateway,value); |
rebonatto | 0:c64e1194230b | 139 | } |
rebonatto | 0:c64e1194230b | 140 | static int get_Dhcp() { return m_dhcp; } |
rebonatto | 0:c64e1194230b | 141 | static void set_Dhcp(int value) { m_dhcp = value; } |
rebonatto | 0:c64e1194230b | 142 | static int get_ModuleNumber() { return m_module_number; } |
rebonatto | 0:c64e1194230b | 143 | static void set_ModuleNumber(int value) { m_module_number = value; } |
rebonatto | 0:c64e1194230b | 144 | |
rebonatto | 0:c64e1194230b | 145 | static float get_Gain(int i) { return m_gain[i]; } |
rebonatto | 0:c64e1194230b | 146 | static void set_Gain(int i, float value) { m_gain[i] = value; } |
rebonatto | 0:c64e1194230b | 147 | static int get_Offset(int i) { return m_offset[i]; } |
rebonatto | 0:c64e1194230b | 148 | static void set_Offset(int i, int value) { m_offset[i] = value; } |
rebonatto | 0:c64e1194230b | 149 | static float get_Limit(int i) { return m_limit[i]; } |
rebonatto | 0:c64e1194230b | 150 | static void set_Limit(int i, float value) { m_limit[i] = value; } |
rebonatto | 0:c64e1194230b | 151 | static int get_OutletNumber(int i) { return m_outlet_number[i]; } |
rebonatto | 0:c64e1194230b | 152 | static void set_OutletNumber(int i, int value) { m_outlet_number[i] = value; } |
rebonatto | 0:c64e1194230b | 153 | static char get_Purpose(int i) { return m_purpose[i]; } |
rebonatto | 0:c64e1194230b | 154 | static void set_Purpose(int i, char value) { m_purpose[i] = value; } |
rebonatto | 0:c64e1194230b | 155 | |
rebonatto | 0:c64e1194230b | 156 | static int get_Outlet(int i) { return m_outlet[i]; } |
rebonatto | 0:c64e1194230b | 157 | static void set_Outlet(int i, int value) { m_outlet[i] = value; } |
rebonatto | 0:c64e1194230b | 158 | |
rebonatto | 0:c64e1194230b | 159 | static int get_MaxChannels() { return m_MaxChannels; } |
rebonatto | 0:c64e1194230b | 160 | static void set_MaxChannels(int value) { m_MaxChannels = value; } |
rebonatto | 0:c64e1194230b | 161 | static int get_MaxOutlets() { return m_MaxOutlets; } |
rebonatto | 0:c64e1194230b | 162 | static void set_MaxOutlets(int value) { m_MaxOutlets = value; } |
rebonatto | 0:c64e1194230b | 163 | static int get_FreqBase() { return m_FreqBase; } |
rebonatto | 0:c64e1194230b | 164 | static void set_FreqBase(int value) { m_FreqBase = value; } |
rebonatto | 0:c64e1194230b | 165 | static int get_MaxHarmonics() { return m_MaxHarmonics; } |
rebonatto | 0:c64e1194230b | 166 | static void set_MaxHarmonics(int value) { m_MaxHarmonics = value; } |
rebonatto | 0:c64e1194230b | 167 | static int get_Samples() { return m_Samples; } |
rebonatto | 0:c64e1194230b | 168 | static void set_Samples(int value) { m_Samples = value; } |
rebonatto | 0:c64e1194230b | 169 | static int get_EventLimit() { return m_EventLimit; } |
rebonatto | 0:c64e1194230b | 170 | static void set_EventLimit(int value) { m_EventLimit = value; } |
rebonatto | 0:c64e1194230b | 171 | static int get_MBoxLength() { return m_MBoxLength; } |
rebonatto | 0:c64e1194230b | 172 | static void set_MBoxLength(int value) { m_MBoxLength = value; } |
rebonatto | 0:c64e1194230b | 173 | |
rebonatto | 0:c64e1194230b | 174 | static int get_NumNeighbors() { return m_NumNeighbors; } |
rebonatto | 0:c64e1194230b | 175 | static void set_NumNeighbors(int value) { m_NumNeighbors = value; } |
rebonatto | 0:c64e1194230b | 176 | |
rebonatto | 0:c64e1194230b | 177 | static char* get_Neighbor(int i) { return m_Neighbor[i]; } |
rebonatto | 0:c64e1194230b | 178 | static void set_Neighbor(int i, char *value) |
rebonatto | 0:c64e1194230b | 179 | { |
rebonatto | 0:c64e1194230b | 180 | if(m_Neighbor[i]!=NULL) delete m_Neighbor[i]; |
rebonatto | 0:c64e1194230b | 181 | int sz = strlen(value)+1; |
rebonatto | 0:c64e1194230b | 182 | m_Neighbor[i] = new char[sz]; |
rebonatto | 0:c64e1194230b | 183 | strcpy(m_Neighbor[i],value); |
rebonatto | 0:c64e1194230b | 184 | } |
rebonatto | 0:c64e1194230b | 185 | |
rebonatto | 0:c64e1194230b | 186 | static int get_PortTCP() { return m_PortTCP; } |
rebonatto | 0:c64e1194230b | 187 | static void set_PortTCP(int value) { m_PortTCP = value; } |
rebonatto | 0:c64e1194230b | 188 | |
rebonatto | 0:c64e1194230b | 189 | static TCPSocketServer& get_ServerSocket() { return m_ServerSocket; } |
rebonatto | 0:c64e1194230b | 190 | static void set_ServerSocket(TCPSocketServer value) { m_ServerSocket = value; } |
rebonatto | 0:c64e1194230b | 191 | |
rebonatto | 0:c64e1194230b | 192 | static TCPSocketConnection& get_Socket(int i) { return m_Socket[i]; } |
rebonatto | 0:c64e1194230b | 193 | static void set_Socket(int i, TCPSocketConnection value) { m_Socket[i] = value; } |
rebonatto | 0:c64e1194230b | 194 | |
rebonatto | 0:c64e1194230b | 195 | static int get_MaxTries() { return m_MaxTries; } |
rebonatto | 0:c64e1194230b | 196 | static void set_MaxTries(int value) { m_MaxTries = value; } |
rebonatto | 0:c64e1194230b | 197 | |
rebonatto | 0:c64e1194230b | 198 | static int get_DelayTry() { return m_DelayTry; } |
rebonatto | 0:c64e1194230b | 199 | static void set_DelayTry(int value) { m_DelayTry = value; } |
rebonatto | 0:c64e1194230b | 200 | |
rebonatto | 0:c64e1194230b | 201 | static int get_DelaySend() { return m_DelaySend; } |
rebonatto | 0:c64e1194230b | 202 | static void set_DelaySend(int value) { m_DelaySend = value; } |
rebonatto | 0:c64e1194230b | 203 | |
rebonatto | 0:c64e1194230b | 204 | static void ReadFile(); //Read the config file and places the values in the internal variables |
rebonatto | 0:c64e1194230b | 205 | static void LoadDefaults(); |
rebonatto | 0:c64e1194230b | 206 | static void WriteFile(); |
rebonatto | 0:c64e1194230b | 207 | static void ShowValues(); |
rebonatto | 0:c64e1194230b | 208 | |
rebonatto | 0:c64e1194230b | 209 | }; |
rebonatto | 0:c64e1194230b | 210 | |
rebonatto | 0:c64e1194230b | 211 | #endif //#ifndef SETTINGS |