Marcelo Rebonatto / Mbed 2 deprecated Protegemed_limpo

Dependencies:   EthernetInterface mbed-rtos mbed NTPClient

Committer:
mlucas82
Date:
Fri Mar 27 15:46:25 2015 +0000
Branch:
feature-logs
Revision:
21:4bfe3dc59b86
Parent:
20:54e8563fb78c
Child:
22:a06c7bb05008
Defined some entries on log: when reseted programmatically and when loaded default settings

Who changed what in which revision?

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