![](/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/TelnetCommands/telnet_setparam.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 | #include "TelnetServer.h" |
rebonatto | 0:c64e1194230b | 2 | |
rebonatto | 0:c64e1194230b | 3 | #include "Settings.h" |
rebonatto | 0:c64e1194230b | 4 | |
rebonatto | 0:c64e1194230b | 5 | char *wrong_args_msg_set = "Wrong number of arguments.\r\n\r\nUsage: setparam <parameter name> <parameter value>\r\n"; |
rebonatto | 0:c64e1194230b | 6 | char *param_not_found_msg_set = "Parameter not found.\r\n\r\n"; |
rebonatto | 0:c64e1194230b | 7 | char *bad_argument_set = "The parameter supplied does not have a valid format.\r\n\r\n"; |
rebonatto | 0:c64e1194230b | 8 | |
rebonatto | 0:c64e1194230b | 9 | int TelnetServer::SetParamCommand(TCPSocketConnection *conn,char** argv,int argc) |
rebonatto | 0:c64e1194230b | 10 | { |
rebonatto | 0:c64e1194230b | 11 | |
rebonatto | 0:c64e1194230b | 12 | if(argc != 3) |
rebonatto | 0:c64e1194230b | 13 | { |
rebonatto | 0:c64e1194230b | 14 | conn->send(wrong_args_msg_set,strlen(wrong_args_msg_set)); |
rebonatto | 0:c64e1194230b | 15 | return 0; |
rebonatto | 0:c64e1194230b | 16 | } |
rebonatto | 0:c64e1194230b | 17 | |
rebonatto | 0:c64e1194230b | 18 | |
rebonatto | 0:c64e1194230b | 19 | if(!strcmp(argv[1],"ipserver")) |
rebonatto | 0:c64e1194230b | 20 | { |
rebonatto | 0:c64e1194230b | 21 | ip_addr_t addr; |
rebonatto | 0:c64e1194230b | 22 | if(ipaddr_aton(argv[2],&addr) != ERR_OK) |
rebonatto | 0:c64e1194230b | 23 | { |
rebonatto | 0:c64e1194230b | 24 | conn->send(bad_argument_set,strlen(bad_argument_set)); |
rebonatto | 0:c64e1194230b | 25 | } |
rebonatto | 0:c64e1194230b | 26 | else |
rebonatto | 0:c64e1194230b | 27 | { |
rebonatto | 0:c64e1194230b | 28 | Settings::set_IpAddress(argv[2]); |
rebonatto | 0:c64e1194230b | 29 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 30 | } |
rebonatto | 0:c64e1194230b | 31 | return 0; |
rebonatto | 0:c64e1194230b | 32 | } |
rebonatto | 0:c64e1194230b | 33 | |
rebonatto | 0:c64e1194230b | 34 | if(!strcmp(argv[1],"module")) |
rebonatto | 0:c64e1194230b | 35 | { |
rebonatto | 0:c64e1194230b | 36 | Settings::set_ModuleNumber(atoi(argv[2])); |
rebonatto | 0:c64e1194230b | 37 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 38 | return 0; |
rebonatto | 0:c64e1194230b | 39 | } |
rebonatto | 0:c64e1194230b | 40 | |
rebonatto | 0:c64e1194230b | 41 | int i; |
rebonatto | 0:c64e1194230b | 42 | for(i=0;i<3;i++) |
rebonatto | 0:c64e1194230b | 43 | { |
rebonatto | 0:c64e1194230b | 44 | char b[12]; |
rebonatto | 0:c64e1194230b | 45 | sprintf(b,"outlet%d",i); |
rebonatto | 0:c64e1194230b | 46 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 47 | { |
rebonatto | 0:c64e1194230b | 48 | Settings::set_Outlet(i,atoi(argv[2])); |
rebonatto | 0:c64e1194230b | 49 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 50 | return 0; |
rebonatto | 0:c64e1194230b | 51 | } |
rebonatto | 0:c64e1194230b | 52 | } |
rebonatto | 0:c64e1194230b | 53 | for(i=0;i<6;i++) |
rebonatto | 0:c64e1194230b | 54 | { |
rebonatto | 0:c64e1194230b | 55 | char b[12]; |
rebonatto | 0:c64e1194230b | 56 | sprintf(b,"gain%d",i); |
rebonatto | 0:c64e1194230b | 57 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 58 | { |
rebonatto | 0:c64e1194230b | 59 | Settings::set_Gain(i,atof(argv[2])); |
rebonatto | 0:c64e1194230b | 60 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 61 | return 0; |
rebonatto | 0:c64e1194230b | 62 | } |
rebonatto | 0:c64e1194230b | 63 | |
rebonatto | 0:c64e1194230b | 64 | sprintf(b,"offset%d",i); |
rebonatto | 0:c64e1194230b | 65 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 66 | { |
rebonatto | 0:c64e1194230b | 67 | Settings::set_Offset(i,atoi(argv[2])); |
rebonatto | 0:c64e1194230b | 68 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 69 | return 0; |
rebonatto | 0:c64e1194230b | 70 | } |
rebonatto | 0:c64e1194230b | 71 | |
rebonatto | 0:c64e1194230b | 72 | sprintf(b,"limit%d",i); |
rebonatto | 0:c64e1194230b | 73 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 74 | { |
rebonatto | 0:c64e1194230b | 75 | Settings::set_Limit(i,atof(argv[2])); |
rebonatto | 0:c64e1194230b | 76 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 77 | return 0; |
rebonatto | 0:c64e1194230b | 78 | } |
rebonatto | 0:c64e1194230b | 79 | |
rebonatto | 0:c64e1194230b | 80 | sprintf(b,"outlet_number%d",i); |
rebonatto | 0:c64e1194230b | 81 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 82 | { |
rebonatto | 0:c64e1194230b | 83 | Settings::set_OutletNumber(i,atoi(argv[2])); |
rebonatto | 0:c64e1194230b | 84 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 85 | return 0; |
rebonatto | 0:c64e1194230b | 86 | } |
rebonatto | 0:c64e1194230b | 87 | |
rebonatto | 0:c64e1194230b | 88 | sprintf(b,"purpose%d",i); |
rebonatto | 0:c64e1194230b | 89 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 90 | { |
rebonatto | 0:c64e1194230b | 91 | Settings::set_Purpose(i,argv[2][0]); |
rebonatto | 0:c64e1194230b | 92 | Settings::WriteFile(); |
rebonatto | 0:c64e1194230b | 93 | return 0; |
rebonatto | 0:c64e1194230b | 94 | } |
rebonatto | 0:c64e1194230b | 95 | } |
rebonatto | 0:c64e1194230b | 96 | |
rebonatto | 0:c64e1194230b | 97 | conn->send(param_not_found_msg_set,strlen(param_not_found_msg_set)); |
rebonatto | 0:c64e1194230b | 98 | return 0; |
rebonatto | 0:c64e1194230b | 99 | |
rebonatto | 0:c64e1194230b | 100 | } |