protegemed, aquisição via A/D simples utilizando interrupção do timer

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed

Fork of ptgm_semDMA by Marcelo Rebonatto

Committer:
rebonatto
Date:
Tue Jan 05 11:47:35 2016 +0000
Revision:
0:fac116e94d44
Child:
1:8129536051df
Vers?o est?vel sem DMA e FFT. 128 amostras.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rebonatto 0:fac116e94d44 1 /*
rebonatto 0:fac116e94d44 2 * Settings.h
rebonatto 0:fac116e94d44 3 *
rebonatto 0:fac116e94d44 4 * Created on:
rebonatto 0:fac116e94d44 5 * Author:
rebonatto 0:fac116e94d44 6 */
rebonatto 0:fac116e94d44 7
rebonatto 0:fac116e94d44 8 #ifndef SETTINGS_H
rebonatto 0:fac116e94d44 9 #define SETTINGS_H
rebonatto 0:fac116e94d44 10
rebonatto 0:fac116e94d44 11 #include <stdio.h>
rebonatto 0:fac116e94d44 12 #include <string.h>
rebonatto 0:fac116e94d44 13 #include <ctype.h>
rebonatto 0:fac116e94d44 14
rebonatto 0:fac116e94d44 15 #include "mbed.h"
rebonatto 0:fac116e94d44 16 #include "EthernetInterface.h"
rebonatto 0:fac116e94d44 17
rebonatto 0:fac116e94d44 18 #include "Split.h"
rebonatto 0:fac116e94d44 19
rebonatto 0:fac116e94d44 20 #define FILENAME "/local/pmed.txt"
rebonatto 0:fac116e94d44 21 #define FILENAMERESET "/local/foi.txt"
rebonatto 0:fac116e94d44 22 #define FREQBASE 60U
rebonatto 0:fac116e94d44 23 #define NUMBER_OF_CHANNELS 6U
rebonatto 0:fac116e94d44 24 #define NUMBER_OF_OUTLETS 3U
rebonatto 0:fac116e94d44 25 #define NUMBER_OF_HARMONICS 12U
rebonatto 0:fac116e94d44 26 #define NUMBER_OF_SAMPLES 128U
rebonatto 0:fac116e94d44 27 #define LENGTH_MAIL_BOX 10U
rebonatto 0:fac116e94d44 28 #define MAXTRIES 10U
rebonatto 0:fac116e94d44 29
rebonatto 0:fac116e94d44 30 class Settings
rebonatto 0:fac116e94d44 31 {
rebonatto 0:fac116e94d44 32
rebonatto 0:fac116e94d44 33 //server URL
rebonatto 0:fac116e94d44 34 static char* m_serverurl;
rebonatto 0:fac116e94d44 35 //module number
rebonatto 0:fac116e94d44 36 static int m_module_number;
rebonatto 0:fac116e94d44 37 //ip address
rebonatto 0:fac116e94d44 38 static char* m_ipaddress;
rebonatto 0:fac116e94d44 39 //netmask
rebonatto 0:fac116e94d44 40 static char* m_netmask;
rebonatto 0:fac116e94d44 41 //gateway
rebonatto 0:fac116e94d44 42 static char* m_gateway;
rebonatto 0:fac116e94d44 43 //dhcp
rebonatto 0:fac116e94d44 44 static int m_dhcp;
rebonatto 0:fac116e94d44 45
rebonatto 0:fac116e94d44 46 //read RFID
rebonatto 0:fac116e94d44 47 static int m_ReadRfid;
rebonatto 0:fac116e94d44 48
rebonatto 0:fac116e94d44 49 //gain x6(float)
rebonatto 0:fac116e94d44 50 static float m_gain[NUMBER_OF_CHANNELS];
rebonatto 0:fac116e94d44 51 //offset x6(int)
rebonatto 0:fac116e94d44 52 static int m_offset[NUMBER_OF_CHANNELS];
rebonatto 0:fac116e94d44 53 //limit x6(float)
rebonatto 0:fac116e94d44 54 static float m_limit[NUMBER_OF_CHANNELS];
rebonatto 0:fac116e94d44 55 //outlet x6 (int)
rebonatto 0:fac116e94d44 56 static int m_outlet_number[NUMBER_OF_CHANNELS];
rebonatto 0:fac116e94d44 57 //purpose x6(char)
rebonatto 0:fac116e94d44 58 static char m_purpose[NUMBER_OF_CHANNELS];
rebonatto 0:fac116e94d44 59
rebonatto 0:fac116e94d44 60 //outlet x3(int)
rebonatto 0:fac116e94d44 61 static int m_outlet[NUMBER_OF_OUTLETS];
rebonatto 0:fac116e94d44 62
rebonatto 0:fac116e94d44 63 //MaxChannels
rebonatto 0:fac116e94d44 64 //static int m_MaxChannels;
rebonatto 0:fac116e94d44 65 //MaxOutlets
rebonatto 0:fac116e94d44 66 //static int m_MaxOutlets;
rebonatto 0:fac116e94d44 67 //Samples
rebonatto 0:fac116e94d44 68 //static int m_Samples;
rebonatto 0:fac116e94d44 69 //FreqBase
rebonatto 0:fac116e94d44 70 //static int m_FreqBase;
rebonatto 0:fac116e94d44 71
rebonatto 0:fac116e94d44 72 //MaxHarmonics
rebonatto 0:fac116e94d44 73 static int m_MaxHarmonics;
rebonatto 0:fac116e94d44 74
rebonatto 0:fac116e94d44 75 //EventLimit
rebonatto 0:fac116e94d44 76 static int m_EventLimit;
rebonatto 0:fac116e94d44 77
rebonatto 0:fac116e94d44 78 //MailBoxLength
rebonatto 0:fac116e94d44 79 static int m_MBoxLength;
rebonatto 0:fac116e94d44 80
rebonatto 0:fac116e94d44 81 //NumberNeighbors
rebonatto 0:fac116e94d44 82 //static int m_NumNeighbors;
rebonatto 0:fac116e94d44 83
rebonatto 0:fac116e94d44 84 //Neighbors x3(char [16])
rebonatto 0:fac116e94d44 85 //static char *m_Neighbor[NEIGHBORS];
rebonatto 0:fac116e94d44 86
rebonatto 0:fac116e94d44 87 //PortTCP
rebonatto 0:fac116e94d44 88 //static int m_PortTCP;
rebonatto 0:fac116e94d44 89
rebonatto 0:fac116e94d44 90 //Socket to receive requests
rebonatto 0:fac116e94d44 91 //static TCPSocketServer m_ServerSocket;
rebonatto 0:fac116e94d44 92
rebonatto 0:fac116e94d44 93 //Socket to send requests
rebonatto 0:fac116e94d44 94 //static TCPSocketConnection m_Socket[NEIGHBORS];
rebonatto 0:fac116e94d44 95
rebonatto 0:fac116e94d44 96 //Maximum number of try connect and send
rebonatto 0:fac116e94d44 97 //static int m_MaxTries;
rebonatto 0:fac116e94d44 98
rebonatto 0:fac116e94d44 99 //Delay time (ms) between 2 tries
rebonatto 0:fac116e94d44 100 static int m_DelayTry;
rebonatto 0:fac116e94d44 101
rebonatto 0:fac116e94d44 102 //Delay time (ms) after Send (post)
rebonatto 0:fac116e94d44 103 static int m_DelaySend;
rebonatto 0:fac116e94d44 104
rebonatto 0:fac116e94d44 105 // Control the marks behavior in log file
rebonatto 0:fac116e94d44 106 static bool m_logMarks;
rebonatto 0:fac116e94d44 107 static int m_logMarksInterval;
rebonatto 0:fac116e94d44 108
rebonatto 0:fac116e94d44 109 public:
rebonatto 0:fac116e94d44 110
rebonatto 0:fac116e94d44 111 Settings();
rebonatto 0:fac116e94d44 112
rebonatto 0:fac116e94d44 113 static char* get_ServerUrl() { return m_serverurl; }
rebonatto 0:fac116e94d44 114 static void set_ServerUrl(char *value)
rebonatto 0:fac116e94d44 115 {
rebonatto 0:fac116e94d44 116 if(m_serverurl!=NULL) delete m_serverurl;
rebonatto 0:fac116e94d44 117 int sz = strlen(value)+1;
rebonatto 0:fac116e94d44 118 m_serverurl = new char[sz];
rebonatto 0:fac116e94d44 119 strcpy(m_serverurl,value);
rebonatto 0:fac116e94d44 120 }
rebonatto 0:fac116e94d44 121 static char* get_IpAddress() { return m_ipaddress; }
rebonatto 0:fac116e94d44 122 static void set_IpAddress(char *value)
rebonatto 0:fac116e94d44 123 {
rebonatto 0:fac116e94d44 124 if(m_ipaddress!=NULL) delete m_ipaddress;
rebonatto 0:fac116e94d44 125 int sz = strlen(value)+1;
rebonatto 0:fac116e94d44 126 m_ipaddress = new char[sz];
rebonatto 0:fac116e94d44 127 strcpy(m_ipaddress,value);
rebonatto 0:fac116e94d44 128 }
rebonatto 0:fac116e94d44 129 static char* get_Netmask() { return m_netmask; }
rebonatto 0:fac116e94d44 130 static void set_Netmask(char *value)
rebonatto 0:fac116e94d44 131 {
rebonatto 0:fac116e94d44 132 if(m_netmask!=NULL) delete m_netmask;
rebonatto 0:fac116e94d44 133 int sz = strlen(value)+1;
rebonatto 0:fac116e94d44 134 m_netmask = new char[sz];
rebonatto 0:fac116e94d44 135 strcpy(m_netmask,value);
rebonatto 0:fac116e94d44 136 }
rebonatto 0:fac116e94d44 137
rebonatto 0:fac116e94d44 138 static char* get_Gateway() { return m_gateway; }
rebonatto 0:fac116e94d44 139 static void set_Gateway(char *value)
rebonatto 0:fac116e94d44 140 {
rebonatto 0:fac116e94d44 141 if(m_gateway!=NULL) delete m_gateway;
rebonatto 0:fac116e94d44 142 int sz = strlen(value)+1;
rebonatto 0:fac116e94d44 143 m_gateway = new char[sz];
rebonatto 0:fac116e94d44 144 strcpy(m_gateway,value);
rebonatto 0:fac116e94d44 145 }
rebonatto 0:fac116e94d44 146 static int get_Dhcp() { return m_dhcp; }
rebonatto 0:fac116e94d44 147 static void set_Dhcp(int value) { m_dhcp = value; }
rebonatto 0:fac116e94d44 148
rebonatto 0:fac116e94d44 149 static int get_ReadRfid() { return m_ReadRfid; }
rebonatto 0:fac116e94d44 150 static void set_ReadRfid(int value) { m_ReadRfid = value; }
rebonatto 0:fac116e94d44 151
rebonatto 0:fac116e94d44 152 static int get_ModuleNumber() { return m_module_number; }
rebonatto 0:fac116e94d44 153 static void set_ModuleNumber(int value) { m_module_number = value; }
rebonatto 0:fac116e94d44 154
rebonatto 0:fac116e94d44 155 static float get_Gain(int i) { return m_gain[i]; }
rebonatto 0:fac116e94d44 156 static void set_Gain(int i, float value) { m_gain[i] = value; }
rebonatto 0:fac116e94d44 157 static int get_Offset(int i) { return m_offset[i]; }
rebonatto 0:fac116e94d44 158 static void set_Offset(int i, int value) { m_offset[i] = value; }
rebonatto 0:fac116e94d44 159 static float get_Limit(int i) { return m_limit[i]; }
rebonatto 0:fac116e94d44 160 static void set_Limit(int i, float value) { m_limit[i] = value; }
rebonatto 0:fac116e94d44 161 static int get_OutletNumber(int i) { return m_outlet_number[i]; }
rebonatto 0:fac116e94d44 162 static void set_OutletNumber(int i, int value) { m_outlet_number[i] = value; }
rebonatto 0:fac116e94d44 163 static char get_Purpose(int i) { return m_purpose[i]; }
rebonatto 0:fac116e94d44 164 static void set_Purpose(int i, char value) { m_purpose[i] = value; }
rebonatto 0:fac116e94d44 165
rebonatto 0:fac116e94d44 166 static int get_Outlet(int i) { return m_outlet[i]; }
rebonatto 0:fac116e94d44 167 static void set_Outlet(int i, int value) { m_outlet[i] = value; }
rebonatto 0:fac116e94d44 168
rebonatto 0:fac116e94d44 169 // static int get_MaxChannels() { return m_MaxChannels; }
rebonatto 0:fac116e94d44 170 // static void set_MaxChannels(int value) { m_MaxChannels = value; }
rebonatto 0:fac116e94d44 171 // static int get_MaxOutlets() { return m_MaxOutlets; }
rebonatto 0:fac116e94d44 172 // static void set_MaxOutlets(int value) { m_MaxOutlets = value; }
rebonatto 0:fac116e94d44 173 // static int get_FreqBase() { return m_FreqBase; }
rebonatto 0:fac116e94d44 174 // static void set_FreqBase(int value) { m_FreqBase = value; }
rebonatto 0:fac116e94d44 175 // static int get_Samples() { return m_Samples; }
rebonatto 0:fac116e94d44 176 // static void set_Samples(int value) { m_Samples = value; }
rebonatto 0:fac116e94d44 177
rebonatto 0:fac116e94d44 178 static int get_MaxHarmonics() { return m_MaxHarmonics; }
rebonatto 0:fac116e94d44 179 static void set_MaxHarmonics(int value) { m_MaxHarmonics = value; }
rebonatto 0:fac116e94d44 180 static int get_EventLimit() { return m_EventLimit; }
rebonatto 0:fac116e94d44 181 static void set_EventLimit(int value) { m_EventLimit = value; }
rebonatto 0:fac116e94d44 182 static int get_MBoxLength() { return m_MBoxLength; }
rebonatto 0:fac116e94d44 183 static void set_MBoxLength(int value) { m_MBoxLength = value; }
rebonatto 0:fac116e94d44 184
rebonatto 0:fac116e94d44 185 // static int get_NumNeighbors() { return m_NumNeighbors; }
rebonatto 0:fac116e94d44 186 // static void set_NumNeighbors(int value) { m_NumNeighbors = value; }
rebonatto 0:fac116e94d44 187 // static char* get_Neighbor(int i) { return m_Neighbor[i]; }
rebonatto 0:fac116e94d44 188 // static void set_Neighbor(int i, char *value)
rebonatto 0:fac116e94d44 189 // for(...)
rebonatto 0:fac116e94d44 190 // {
rebonatto 0:fac116e94d44 191 // if(m_Neighbor[i]!=NULL) delete m_Neighbor[i];
rebonatto 0:fac116e94d44 192 // int sz = strlen(value)+1;
rebonatto 0:fac116e94d44 193 // m_Neighbor[i] = new char[sz];
rebonatto 0:fac116e94d44 194 // strcpy(m_Neighbor[i],value);
rebonatto 0:fac116e94d44 195 // }
rebonatto 0:fac116e94d44 196 // static int get_PortTCP() { return m_PortTCP; }
rebonatto 0:fac116e94d44 197 // static void set_PortTCP(int value) { m_PortTCP = value; }
rebonatto 0:fac116e94d44 198 // static TCPSocketServer& get_ServerSocket() { return m_ServerSocket; }
rebonatto 0:fac116e94d44 199 // static void set_ServerSocket(TCPSocketServer value) { m_ServerSocket = value; }
rebonatto 0:fac116e94d44 200 // static TCPSocketConnection& get_Socket(int i) { return m_Socket[i]; }
rebonatto 0:fac116e94d44 201 // static void set_Socket(int i, TCPSocketConnection value) { m_Socket[i] = value; }
rebonatto 0:fac116e94d44 202 // static int get_MaxTries() { return m_MaxTries; }
rebonatto 0:fac116e94d44 203 // static void set_MaxTries(int value) { m_MaxTries = value; }
rebonatto 0:fac116e94d44 204
rebonatto 0:fac116e94d44 205 static int get_DelayTry() { return m_DelayTry; }
rebonatto 0:fac116e94d44 206 static void set_DelayTry(int value) { m_DelayTry = value; }
rebonatto 0:fac116e94d44 207
rebonatto 0:fac116e94d44 208 static int get_DelaySend() { return m_DelaySend; }
rebonatto 0:fac116e94d44 209 static void set_DelaySend(int value) { m_DelaySend = value; }
rebonatto 0:fac116e94d44 210
rebonatto 0:fac116e94d44 211 // Control the marks behavior in log file
rebonatto 0:fac116e94d44 212 static bool get_LogMarks() { return m_logMarks; }
rebonatto 0:fac116e94d44 213 static void set_LogMarks(bool value) { m_logMarks = value; }
rebonatto 0:fac116e94d44 214 static int get_LogMarksInterval() { return m_logMarksInterval; }
rebonatto 0:fac116e94d44 215 static void set_LogMarksInterval(int value) { m_logMarksInterval = value; }
rebonatto 0:fac116e94d44 216
rebonatto 0:fac116e94d44 217 static void ReadFile(); //Read the config file and places the values in the internal variables
rebonatto 0:fac116e94d44 218 static void LoadDefaults();
rebonatto 0:fac116e94d44 219 static void WriteFile();
rebonatto 0:fac116e94d44 220 static void ShowValues();
rebonatto 0:fac116e94d44 221
rebonatto 0:fac116e94d44 222 };
rebonatto 0:fac116e94d44 223
rebonatto 0:fac116e94d44 224 #endif //#ifndef SETTINGS