![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
Codes/Settings.cpp@0:c64e1194230b, 2014-07-09 (annotated)
- Committer:
- rebonatto
- Date:
- Wed Jul 09 21:16:23 2014 +0000
- Revision:
- 0:c64e1194230b
Vers?o do Protegemed com calculo de tempo de fuga, overflow, underflow e novo valor m?dio (manual).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rebonatto | 0:c64e1194230b | 1 | /* |
rebonatto | 0:c64e1194230b | 2 | * Settings.cpp |
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 | #include "Settings.h" |
rebonatto | 0:c64e1194230b | 9 | |
rebonatto | 0:c64e1194230b | 10 | LocalFileSystem local("local"); |
rebonatto | 0:c64e1194230b | 11 | |
rebonatto | 0:c64e1194230b | 12 | char* Settings::m_ipaddress = NULL; |
rebonatto | 0:c64e1194230b | 13 | char* Settings::m_netmask = NULL; |
rebonatto | 0:c64e1194230b | 14 | char* Settings::m_gateway = NULL; |
rebonatto | 0:c64e1194230b | 15 | char* Settings::m_serverurl = NULL; |
rebonatto | 0:c64e1194230b | 16 | int Settings::m_dhcp = 0; |
rebonatto | 0:c64e1194230b | 17 | int Settings::m_module_number = 0; |
rebonatto | 0:c64e1194230b | 18 | int Settings::m_MaxChannels = 0; |
rebonatto | 0:c64e1194230b | 19 | int Settings::m_MaxOutlets = 0; |
rebonatto | 0:c64e1194230b | 20 | int Settings::m_FreqBase = 0; |
rebonatto | 0:c64e1194230b | 21 | int Settings::m_MaxHarmonics = 0; |
rebonatto | 0:c64e1194230b | 22 | int Settings::m_Samples = 0; |
rebonatto | 0:c64e1194230b | 23 | int Settings::m_EventLimit = 0; |
rebonatto | 0:c64e1194230b | 24 | int Settings::m_MBoxLength = 0; |
rebonatto | 0:c64e1194230b | 25 | int Settings::m_NumNeighbors = 0; |
rebonatto | 0:c64e1194230b | 26 | int Settings::m_PortTCP = 0; |
rebonatto | 0:c64e1194230b | 27 | int Settings::m_MaxTries = 0; |
rebonatto | 0:c64e1194230b | 28 | int Settings::m_DelayTry = 0; |
rebonatto | 0:c64e1194230b | 29 | int Settings::m_DelaySend = 0; |
rebonatto | 0:c64e1194230b | 30 | |
rebonatto | 0:c64e1194230b | 31 | |
rebonatto | 0:c64e1194230b | 32 | TCPSocketServer Settings::m_ServerSocket; |
rebonatto | 0:c64e1194230b | 33 | TCPSocketConnection Settings::m_Socket[NEIGHBORS]; |
rebonatto | 0:c64e1194230b | 34 | |
rebonatto | 0:c64e1194230b | 35 | float Settings::m_gain[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 36 | int Settings::m_offset[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 37 | float Settings::m_limit[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 38 | int Settings::m_outlet_number[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 39 | char Settings::m_purpose[NUMBER_OF_CHANNELS]; |
rebonatto | 0:c64e1194230b | 40 | int Settings::m_outlet[NUMBER_OF_OUTLETS]; |
rebonatto | 0:c64e1194230b | 41 | char *Settings::m_Neighbor[NEIGHBORS]; |
rebonatto | 0:c64e1194230b | 42 | |
rebonatto | 0:c64e1194230b | 43 | void Settings::LoadDefaults() |
rebonatto | 0:c64e1194230b | 44 | { |
rebonatto | 0:c64e1194230b | 45 | set_ServerUrl("192.168.1.26"); |
rebonatto | 0:c64e1194230b | 46 | |
rebonatto | 0:c64e1194230b | 47 | set_IpAddress("192.168.1.100"); |
rebonatto | 0:c64e1194230b | 48 | |
rebonatto | 0:c64e1194230b | 49 | set_Netmask("255.255.255.0"); |
rebonatto | 0:c64e1194230b | 50 | set_Gateway("192.168.1.5"); |
rebonatto | 0:c64e1194230b | 51 | |
rebonatto | 0:c64e1194230b | 52 | set_Dhcp(1); |
rebonatto | 0:c64e1194230b | 53 | |
rebonatto | 0:c64e1194230b | 54 | set_ModuleNumber(1); |
rebonatto | 0:c64e1194230b | 55 | set_MaxChannels(NUMBER_OF_CHANNELS); |
rebonatto | 0:c64e1194230b | 56 | set_MaxOutlets(NUMBER_OF_OUTLETS); |
rebonatto | 0:c64e1194230b | 57 | set_FreqBase(60); |
rebonatto | 0:c64e1194230b | 58 | set_MaxHarmonics(12); |
rebonatto | 0:c64e1194230b | 59 | set_Samples(256); |
rebonatto | 0:c64e1194230b | 60 | set_EventLimit(3); |
rebonatto | 0:c64e1194230b | 61 | set_MBoxLength(10); |
rebonatto | 0:c64e1194230b | 62 | set_NumNeighbors(3); |
rebonatto | 0:c64e1194230b | 63 | set_PortTCP(7890); |
rebonatto | 0:c64e1194230b | 64 | set_MaxTries(10); |
rebonatto | 0:c64e1194230b | 65 | set_DelayTry(500); |
rebonatto | 0:c64e1194230b | 66 | set_DelaySend(50); |
rebonatto | 0:c64e1194230b | 67 | |
rebonatto | 0:c64e1194230b | 68 | int i; |
rebonatto | 0:c64e1194230b | 69 | |
rebonatto | 0:c64e1194230b | 70 | for(i=0;i<get_MaxChannels();i++) |
rebonatto | 0:c64e1194230b | 71 | { |
rebonatto | 0:c64e1194230b | 72 | set_Gain(i,1); |
rebonatto | 0:c64e1194230b | 73 | set_Offset(i,2048); |
rebonatto | 0:c64e1194230b | 74 | set_Limit(i,2048); |
rebonatto | 0:c64e1194230b | 75 | set_OutletNumber(i,i/2); |
rebonatto | 0:c64e1194230b | 76 | set_Purpose(i,(i%2)?'d':'p'); |
rebonatto | 0:c64e1194230b | 77 | } |
rebonatto | 0:c64e1194230b | 78 | for(i=0;i<get_MaxOutlets();i++) |
rebonatto | 0:c64e1194230b | 79 | { |
rebonatto | 0:c64e1194230b | 80 | set_Outlet(i,i+1); |
rebonatto | 0:c64e1194230b | 81 | } |
rebonatto | 0:c64e1194230b | 82 | |
rebonatto | 0:c64e1194230b | 83 | set_Neighbor(0, "192.168.1.6"); |
rebonatto | 0:c64e1194230b | 84 | set_Neighbor(1, "192.168.1.7"); |
rebonatto | 0:c64e1194230b | 85 | set_Neighbor(2, "192.168.1.8"); |
rebonatto | 0:c64e1194230b | 86 | |
rebonatto | 0:c64e1194230b | 87 | /* |
rebonatto | 0:c64e1194230b | 88 | m_ServerSocket.bind(get_PortTCP()); // liga o serversocket a porta |
rebonatto | 0:c64e1194230b | 89 | printf("Settings Default: fez bind na porta %d\n", get_PortTCP()); |
rebonatto | 0:c64e1194230b | 90 | |
rebonatto | 0:c64e1194230b | 91 | for(i=0;i<get_NumNeighbors();i++){ |
rebonatto | 0:c64e1194230b | 92 | m_Socket[i].connect(get_Neighbor(i), get_PortTCP()); // conecta os sockets de envio aos IPs dos vizinhos |
rebonatto | 0:c64e1194230b | 93 | printf("Settings Default: conectou socket com %s:%d\n", get_Neighbor(i), get_PortTCP()); |
rebonatto | 0:c64e1194230b | 94 | } |
rebonatto | 0:c64e1194230b | 95 | */ |
rebonatto | 0:c64e1194230b | 96 | |
rebonatto | 0:c64e1194230b | 97 | } |
rebonatto | 0:c64e1194230b | 98 | |
rebonatto | 0:c64e1194230b | 99 | void Settings::ReadFile() |
rebonatto | 0:c64e1194230b | 100 | { |
rebonatto | 0:c64e1194230b | 101 | int i; |
rebonatto | 0:c64e1194230b | 102 | FILE *f = fopen(FILENAME,"r"); |
rebonatto | 0:c64e1194230b | 103 | |
rebonatto | 0:c64e1194230b | 104 | if(f == NULL) |
rebonatto | 0:c64e1194230b | 105 | { |
rebonatto | 0:c64e1194230b | 106 | LoadDefaults(); |
rebonatto | 0:c64e1194230b | 107 | WriteFile(); |
rebonatto | 0:c64e1194230b | 108 | return; |
rebonatto | 0:c64e1194230b | 109 | } |
rebonatto | 0:c64e1194230b | 110 | char buf[50]; |
rebonatto | 0:c64e1194230b | 111 | while(fgets(buf,50,f)!= NULL) |
rebonatto | 0:c64e1194230b | 112 | { |
rebonatto | 0:c64e1194230b | 113 | char* p = strchr(buf,'\n'); |
rebonatto | 0:c64e1194230b | 114 | if(p) |
rebonatto | 0:c64e1194230b | 115 | { |
rebonatto | 0:c64e1194230b | 116 | if(isprint(*(p-1)) == 0) *(p-1) = '\0'; |
rebonatto | 0:c64e1194230b | 117 | *p = '\0'; |
rebonatto | 0:c64e1194230b | 118 | } |
rebonatto | 0:c64e1194230b | 119 | char **line; |
rebonatto | 0:c64e1194230b | 120 | int l = split(buf,"=",&line); |
rebonatto | 0:c64e1194230b | 121 | if(l!=2)continue; |
rebonatto | 0:c64e1194230b | 122 | if(!strcmp(line[0],"server")) |
rebonatto | 0:c64e1194230b | 123 | { |
rebonatto | 0:c64e1194230b | 124 | set_ServerUrl(line[1]); |
rebonatto | 0:c64e1194230b | 125 | } |
rebonatto | 0:c64e1194230b | 126 | if(!strcmp(line[0],"address")) |
rebonatto | 0:c64e1194230b | 127 | { |
rebonatto | 0:c64e1194230b | 128 | set_IpAddress(line[1]); |
rebonatto | 0:c64e1194230b | 129 | } |
rebonatto | 0:c64e1194230b | 130 | if(!strcmp(line[0],"netmask")) |
rebonatto | 0:c64e1194230b | 131 | { |
rebonatto | 0:c64e1194230b | 132 | set_Netmask(line[1]); |
rebonatto | 0:c64e1194230b | 133 | } |
rebonatto | 0:c64e1194230b | 134 | if(!strcmp(line[0],"gateway")) |
rebonatto | 0:c64e1194230b | 135 | { |
rebonatto | 0:c64e1194230b | 136 | set_Gateway(line[1]); |
rebonatto | 0:c64e1194230b | 137 | } |
rebonatto | 0:c64e1194230b | 138 | if(!strcmp(line[0],"dhcp")) |
rebonatto | 0:c64e1194230b | 139 | { |
rebonatto | 0:c64e1194230b | 140 | if(!strcmp(line[1],"false")) |
rebonatto | 0:c64e1194230b | 141 | set_Dhcp(0); |
rebonatto | 0:c64e1194230b | 142 | else |
rebonatto | 0:c64e1194230b | 143 | set_Dhcp(1); |
rebonatto | 0:c64e1194230b | 144 | } |
rebonatto | 0:c64e1194230b | 145 | if(!strcmp(line[0],"module")) |
rebonatto | 0:c64e1194230b | 146 | { |
rebonatto | 0:c64e1194230b | 147 | set_ModuleNumber(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 148 | } |
rebonatto | 0:c64e1194230b | 149 | |
rebonatto | 0:c64e1194230b | 150 | if(!strcmp(line[0],"FreqBase")) |
rebonatto | 0:c64e1194230b | 151 | { |
rebonatto | 0:c64e1194230b | 152 | set_FreqBase(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 153 | } |
rebonatto | 0:c64e1194230b | 154 | if(!strcmp(line[0],"MaxChannels")) |
rebonatto | 0:c64e1194230b | 155 | { |
rebonatto | 0:c64e1194230b | 156 | set_MaxChannels(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 157 | } |
rebonatto | 0:c64e1194230b | 158 | if(!strcmp(line[0],"MaxOutlets")) |
rebonatto | 0:c64e1194230b | 159 | { |
rebonatto | 0:c64e1194230b | 160 | set_MaxOutlets(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 161 | } |
rebonatto | 0:c64e1194230b | 162 | if(!strcmp(line[0],"Samples")) |
rebonatto | 0:c64e1194230b | 163 | { |
rebonatto | 0:c64e1194230b | 164 | set_Samples(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 165 | } |
rebonatto | 0:c64e1194230b | 166 | if(!strcmp(line[0],"EventLimit")) |
rebonatto | 0:c64e1194230b | 167 | { |
rebonatto | 0:c64e1194230b | 168 | set_EventLimit(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 169 | } |
rebonatto | 0:c64e1194230b | 170 | if(!strcmp(line[0],"MBoxLength")) |
rebonatto | 0:c64e1194230b | 171 | { |
rebonatto | 0:c64e1194230b | 172 | set_MBoxLength(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 173 | } |
rebonatto | 0:c64e1194230b | 174 | |
rebonatto | 0:c64e1194230b | 175 | for(i=0;i<get_MaxChannels();i++) |
rebonatto | 0:c64e1194230b | 176 | { |
rebonatto | 0:c64e1194230b | 177 | char x[10]; |
rebonatto | 0:c64e1194230b | 178 | sprintf(x,"gain%d",i); |
rebonatto | 0:c64e1194230b | 179 | if(!strcmp(line[0],x)) |
rebonatto | 0:c64e1194230b | 180 | { |
rebonatto | 0:c64e1194230b | 181 | set_Gain(i,atof(line[1])); |
rebonatto | 0:c64e1194230b | 182 | } |
rebonatto | 0:c64e1194230b | 183 | sprintf(x,"offset%d",i); |
rebonatto | 0:c64e1194230b | 184 | if(!strcmp(line[0],x)) |
rebonatto | 0:c64e1194230b | 185 | { |
rebonatto | 0:c64e1194230b | 186 | set_Offset(i,atoi(line[1])); |
rebonatto | 0:c64e1194230b | 187 | } |
rebonatto | 0:c64e1194230b | 188 | sprintf(x,"limit%d",i); |
rebonatto | 0:c64e1194230b | 189 | if(!strcmp(line[0],x)) |
rebonatto | 0:c64e1194230b | 190 | { |
rebonatto | 0:c64e1194230b | 191 | set_Limit(i,atof(line[1])); |
rebonatto | 0:c64e1194230b | 192 | } |
rebonatto | 0:c64e1194230b | 193 | sprintf(x,"type%d",i); |
rebonatto | 0:c64e1194230b | 194 | if(!strcmp(line[0],x)) |
rebonatto | 0:c64e1194230b | 195 | { |
rebonatto | 0:c64e1194230b | 196 | set_Purpose(i,line[1][0]); |
rebonatto | 0:c64e1194230b | 197 | set_OutletNumber(i,line[1][1]-'0'); |
rebonatto | 0:c64e1194230b | 198 | } |
rebonatto | 0:c64e1194230b | 199 | } |
rebonatto | 0:c64e1194230b | 200 | |
rebonatto | 0:c64e1194230b | 201 | for(i=0;i<get_MaxOutlets();i++) |
rebonatto | 0:c64e1194230b | 202 | { |
rebonatto | 0:c64e1194230b | 203 | char x[10]; |
rebonatto | 0:c64e1194230b | 204 | sprintf(x,"outlet%d",i); |
rebonatto | 0:c64e1194230b | 205 | if(!strcmp(line[0],x)) |
rebonatto | 0:c64e1194230b | 206 | { |
rebonatto | 0:c64e1194230b | 207 | set_Outlet(i,atoi(line[1])); |
rebonatto | 0:c64e1194230b | 208 | } |
rebonatto | 0:c64e1194230b | 209 | } |
rebonatto | 0:c64e1194230b | 210 | if(!strcmp(line[0],"MaxHarmonics")) |
rebonatto | 0:c64e1194230b | 211 | { |
rebonatto | 0:c64e1194230b | 212 | set_MaxHarmonics(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 213 | } |
rebonatto | 0:c64e1194230b | 214 | |
rebonatto | 0:c64e1194230b | 215 | if(!strcmp(line[0],"NumNeighbors")) |
rebonatto | 0:c64e1194230b | 216 | { |
rebonatto | 0:c64e1194230b | 217 | set_NumNeighbors(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 218 | } |
rebonatto | 0:c64e1194230b | 219 | |
rebonatto | 0:c64e1194230b | 220 | if(!strcmp(line[0],"TcpPort")) |
rebonatto | 0:c64e1194230b | 221 | { |
rebonatto | 0:c64e1194230b | 222 | set_PortTCP(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 223 | //m_ServerSocket.bind(get_PortTCP()); // liga o serversocket a porta |
rebonatto | 0:c64e1194230b | 224 | } |
rebonatto | 0:c64e1194230b | 225 | |
rebonatto | 0:c64e1194230b | 226 | for(i=0;i<get_NumNeighbors();i++) |
rebonatto | 0:c64e1194230b | 227 | { |
rebonatto | 0:c64e1194230b | 228 | char x[15]; |
rebonatto | 0:c64e1194230b | 229 | sprintf(x,"Neighbor%d",i); |
rebonatto | 0:c64e1194230b | 230 | //printf("Vai buscar %d -> %s\n", i, x); |
rebonatto | 0:c64e1194230b | 231 | if(!strcmp(line[0],x)) |
rebonatto | 0:c64e1194230b | 232 | { |
rebonatto | 0:c64e1194230b | 233 | // printf("Vai usar %d -> %s\n", i, line[1]); |
rebonatto | 0:c64e1194230b | 234 | set_Neighbor(i, line[1]) ; |
rebonatto | 0:c64e1194230b | 235 | //m_Socket[i].connect(get_Neighbor(i), get_PortTCP()); // conecta os sockets de envio aos IPs dos vizinhos |
rebonatto | 0:c64e1194230b | 236 | } |
rebonatto | 0:c64e1194230b | 237 | } |
rebonatto | 0:c64e1194230b | 238 | |
rebonatto | 0:c64e1194230b | 239 | if(!strcmp(line[0],"MaxTries")) |
rebonatto | 0:c64e1194230b | 240 | { |
rebonatto | 0:c64e1194230b | 241 | set_MaxTries(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 242 | //m_ServerSocket.bind(get_PortTCP()); // liga o serversocket a porta |
rebonatto | 0:c64e1194230b | 243 | } |
rebonatto | 0:c64e1194230b | 244 | |
rebonatto | 0:c64e1194230b | 245 | if(!strcmp(line[0],"DelayTry")) |
rebonatto | 0:c64e1194230b | 246 | { |
rebonatto | 0:c64e1194230b | 247 | set_DelayTry(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 248 | //m_ServerSocket.bind(get_PortTCP()); // liga o serversocket a porta |
rebonatto | 0:c64e1194230b | 249 | } |
rebonatto | 0:c64e1194230b | 250 | |
rebonatto | 0:c64e1194230b | 251 | if(!strcmp(line[0],"DelaySend")) |
rebonatto | 0:c64e1194230b | 252 | { |
rebonatto | 0:c64e1194230b | 253 | set_DelaySend(atoi(line[1])); |
rebonatto | 0:c64e1194230b | 254 | //m_ServerSocket.bind(get_PortTCP()); // liga o serversocket a porta |
rebonatto | 0:c64e1194230b | 255 | } |
rebonatto | 0:c64e1194230b | 256 | |
rebonatto | 0:c64e1194230b | 257 | //printf("Param=%s Value=%s\r\n",line[0],line[1]); |
rebonatto | 0:c64e1194230b | 258 | } |
rebonatto | 0:c64e1194230b | 259 | |
rebonatto | 0:c64e1194230b | 260 | /* |
rebonatto | 0:c64e1194230b | 261 | m_ServerSocket.bind(get_PortTCP()); // liga o serversocket a porta |
rebonatto | 0:c64e1194230b | 262 | printf("Settings LoadFile: fez bind na porta %d\n", get_PortTCP()); |
rebonatto | 0:c64e1194230b | 263 | |
rebonatto | 0:c64e1194230b | 264 | for(i=0;i<get_NumNeighbors();i++){ |
rebonatto | 0:c64e1194230b | 265 | m_Socket[i].connect(get_Neighbor(i), get_PortTCP()); // conecta os sockets de envio aos IPs dos vizinhos |
rebonatto | 0:c64e1194230b | 266 | printf("Settings LoadFile: conectou socket com %s:%d\n", get_Neighbor(i), get_PortTCP()); |
rebonatto | 0:c64e1194230b | 267 | } |
rebonatto | 0:c64e1194230b | 268 | */ |
rebonatto | 0:c64e1194230b | 269 | |
rebonatto | 0:c64e1194230b | 270 | fclose(f); |
rebonatto | 0:c64e1194230b | 271 | } |
rebonatto | 0:c64e1194230b | 272 | |
rebonatto | 0:c64e1194230b | 273 | |
rebonatto | 0:c64e1194230b | 274 | void Settings::WriteFile() |
rebonatto | 0:c64e1194230b | 275 | { |
rebonatto | 0:c64e1194230b | 276 | FILE *f = fopen(FILENAME,"w"); |
rebonatto | 0:c64e1194230b | 277 | int i; |
rebonatto | 0:c64e1194230b | 278 | |
rebonatto | 0:c64e1194230b | 279 | if(f == NULL) |
rebonatto | 0:c64e1194230b | 280 | { |
rebonatto | 0:c64e1194230b | 281 | printf("Error creating settings file\r\n"); |
rebonatto | 0:c64e1194230b | 282 | return; |
rebonatto | 0:c64e1194230b | 283 | } |
rebonatto | 0:c64e1194230b | 284 | |
rebonatto | 0:c64e1194230b | 285 | fprintf(f,"server=%s\r\n",get_ServerUrl()); |
rebonatto | 0:c64e1194230b | 286 | fprintf(f,"address=%s\r\n",get_IpAddress()); |
rebonatto | 0:c64e1194230b | 287 | fprintf(f,"netmask=%s\r\n",get_Netmask()); |
rebonatto | 0:c64e1194230b | 288 | fprintf(f,"gateway=%s\r\n",get_Gateway()); |
rebonatto | 0:c64e1194230b | 289 | |
rebonatto | 0:c64e1194230b | 290 | if(get_Dhcp()) |
rebonatto | 0:c64e1194230b | 291 | fprintf(f,"dhcp=true\r\n"); |
rebonatto | 0:c64e1194230b | 292 | else |
rebonatto | 0:c64e1194230b | 293 | fprintf(f,"dhcp=false\r\n"); |
rebonatto | 0:c64e1194230b | 294 | |
rebonatto | 0:c64e1194230b | 295 | fprintf(f,"module=%d\r\n",get_ModuleNumber()); |
rebonatto | 0:c64e1194230b | 296 | fprintf(f,"MaxChannels=%d\r\n",get_MaxChannels()); |
rebonatto | 0:c64e1194230b | 297 | fprintf(f,"MaxOutlets=%d\r\n",get_MaxOutlets()); |
rebonatto | 0:c64e1194230b | 298 | fprintf(f,"FreqBase=%d\r\n",get_FreqBase()); |
rebonatto | 0:c64e1194230b | 299 | fprintf(f,"Samples=%d\r\n",get_Samples()); |
rebonatto | 0:c64e1194230b | 300 | fprintf(f,"EventLimit=%d\r\n",get_EventLimit()); |
rebonatto | 0:c64e1194230b | 301 | fprintf(f,"MBoxLength=%d\r\n",get_MBoxLength()); |
rebonatto | 0:c64e1194230b | 302 | |
rebonatto | 0:c64e1194230b | 303 | for(i=0;i<get_MaxChannels();i++) |
rebonatto | 0:c64e1194230b | 304 | { |
rebonatto | 0:c64e1194230b | 305 | fprintf(f,"gain%d=%0.4f\r\n",i,get_Gain(i)); |
rebonatto | 0:c64e1194230b | 306 | fprintf(f,"offset%d=%d\r\n",i,get_Offset(i)); |
rebonatto | 0:c64e1194230b | 307 | fprintf(f,"limit%d=%0.4f\r\n",i,get_Limit(i)); |
rebonatto | 0:c64e1194230b | 308 | fprintf(f,"type%d=%c%d\r\n",i,get_Purpose(i),get_OutletNumber(i)); |
rebonatto | 0:c64e1194230b | 309 | } |
rebonatto | 0:c64e1194230b | 310 | |
rebonatto | 0:c64e1194230b | 311 | for(i=0;i<get_MaxOutlets();i++) |
rebonatto | 0:c64e1194230b | 312 | { |
rebonatto | 0:c64e1194230b | 313 | fprintf(f,"outlet%d=%d\r\n",i,get_Outlet(i)); |
rebonatto | 0:c64e1194230b | 314 | } |
rebonatto | 0:c64e1194230b | 315 | fprintf(f,"MaxHarmonics=%d\r\n",get_MaxHarmonics()); |
rebonatto | 0:c64e1194230b | 316 | |
rebonatto | 0:c64e1194230b | 317 | fprintf(f,"NumNeighbors=%d\r\n",get_NumNeighbors()); |
rebonatto | 0:c64e1194230b | 318 | fprintf(f,"TcpPort=%d\r\n",get_PortTCP()); |
rebonatto | 0:c64e1194230b | 319 | for(i=0;i<get_NumNeighbors();i++) |
rebonatto | 0:c64e1194230b | 320 | { |
rebonatto | 0:c64e1194230b | 321 | fprintf(f,"Neighbor%d=%s\r\n",i,get_Neighbor(i)); |
rebonatto | 0:c64e1194230b | 322 | } |
rebonatto | 0:c64e1194230b | 323 | fprintf(f,"MaxTries=%d\r\n",get_MaxTries()); |
rebonatto | 0:c64e1194230b | 324 | fprintf(f,"DelayTry=%d\r\n",get_DelayTry()); |
rebonatto | 0:c64e1194230b | 325 | fprintf(f,"DelaySend=%d\r\n",get_DelaySend()); |
rebonatto | 0:c64e1194230b | 326 | |
rebonatto | 0:c64e1194230b | 327 | fclose(f); |
rebonatto | 0:c64e1194230b | 328 | } |
rebonatto | 0:c64e1194230b | 329 | |
rebonatto | 0:c64e1194230b | 330 | void Settings::ShowValues() |
rebonatto | 0:c64e1194230b | 331 | { |
rebonatto | 0:c64e1194230b | 332 | printf("ServerUrl: %s\n", get_ServerUrl()); |
rebonatto | 0:c64e1194230b | 333 | printf("IpAddress: %s\n", get_IpAddress()); |
rebonatto | 0:c64e1194230b | 334 | printf("NetMask: %s\n", get_Netmask()); |
rebonatto | 0:c64e1194230b | 335 | printf("Gateway: %s\n", get_Gateway()); |
rebonatto | 0:c64e1194230b | 336 | printf("Dhcp: %d\n", get_Dhcp()); |
rebonatto | 0:c64e1194230b | 337 | printf("ModuleNumber: %d\n", get_ModuleNumber() ); |
rebonatto | 0:c64e1194230b | 338 | printf("FreqBase : %d\n", get_FreqBase() ); |
rebonatto | 0:c64e1194230b | 339 | printf("Samples : %d\n" , get_Samples() ); |
rebonatto | 0:c64e1194230b | 340 | printf("EventLimit : %d\n" , get_EventLimit() ); |
rebonatto | 0:c64e1194230b | 341 | printf("MBoxLength : %d\n" , get_MBoxLength() ); |
rebonatto | 0:c64e1194230b | 342 | printf("MaxChannels : %d\n", get_MaxChannels() ); |
rebonatto | 0:c64e1194230b | 343 | printf("MaxOutlets : %d\n", get_MaxOutlets() ); |
rebonatto | 0:c64e1194230b | 344 | printf("Per Channel\n"); |
rebonatto | 0:c64e1194230b | 345 | int i; |
rebonatto | 0:c64e1194230b | 346 | for(i=0;i<get_MaxChannels();i++) |
rebonatto | 0:c64e1194230b | 347 | { |
rebonatto | 0:c64e1194230b | 348 | printf("Channel %d Gain %f Offset %d Limmit %f Outlet %d Purpose %c\n ", i, get_Gain(i), get_Offset(i), get_Limit(i), get_OutletNumber(i), get_Purpose(i)); |
rebonatto | 0:c64e1194230b | 349 | } |
rebonatto | 0:c64e1194230b | 350 | printf("Per Outlet \n"); |
rebonatto | 0:c64e1194230b | 351 | for(i=0;i<get_MaxOutlets();i++) |
rebonatto | 0:c64e1194230b | 352 | { |
rebonatto | 0:c64e1194230b | 353 | printf("Outlet %d Number %d \n ", i, get_Outlet(i)); |
rebonatto | 0:c64e1194230b | 354 | } |
rebonatto | 0:c64e1194230b | 355 | printf("MaxHarmonics : %d\n", get_MaxHarmonics() ); |
rebonatto | 0:c64e1194230b | 356 | |
rebonatto | 0:c64e1194230b | 357 | printf("NumNeighbors : %d\n", get_NumNeighbors() ); |
rebonatto | 0:c64e1194230b | 358 | for(i=0;i<get_NumNeighbors();i++) |
rebonatto | 0:c64e1194230b | 359 | { |
rebonatto | 0:c64e1194230b | 360 | printf("Neighbor %d Value %s \n ", i, get_Neighbor(i)); |
rebonatto | 0:c64e1194230b | 361 | } |
rebonatto | 0:c64e1194230b | 362 | printf("TcpPort : %d\n", get_PortTCP() ); |
rebonatto | 0:c64e1194230b | 363 | printf("MaxTries : %d\n", get_MaxTries() ); |
rebonatto | 0:c64e1194230b | 364 | printf("DelayTry : %d\n", get_DelayTry() ); |
rebonatto | 0:c64e1194230b | 365 | printf("DelaySend : %d\n", get_DelaySend() ); |
rebonatto | 0:c64e1194230b | 366 | } |