diff --git a/command.tc b/command.tc index 7520bcf..33d27cb 100644 --- a/command.tc +++ b/command.tc @@ -5,7 +5,18 @@ #include "net.th" #include "encoder.th" + +static string commands[]= { + "enc_set_windows", + "debug_enc_level", + "debug_relay_reply", + "debug_sensors", + "debug_showtime", + "debug_enc_state" + }; static string cmdbuffer = ""; +string cmd; +string params; string pars[10]; int par_num; void on_sock_inband() // обработка поступивших команд @@ -19,8 +30,8 @@ void on_sock_inband() // обработка поступивших команд unsigned char cmdlen = instr(1,cmdline,chr('='),1); if (cmdlen==0) cmdlen = instr(1,cmdline,chr('&'),1); - string cmd = left(cmdline,cmdlen-1); - string params = mid(cmdline,cmdlen+1,position-cmdlen-1); + cmd = left(cmdline,cmdlen-1); + params = mid(cmdline,cmdlen+1,position-cmdlen-1); // d("{cmd}: "+cmd); // d("{cmd}.params: "+params); if (cmd =="systeminfo"){ @@ -40,8 +51,12 @@ void on_sock_inband() // обработка поступивших команд cmd_replay(cmd_enc_set_windows(params)); }else if (cmd == "debug_enc_level"){ cmd_replay(cmd_debug_enc_level(params)); + }else if (cmd == "debug_enc_state"){ + cmd_replay(cmd_debug_enc_state(params)); }else if (cmd == "debug_relay_reply"){ cmd_replay(cmd_debug_relay_reply(params)); + }else if (cmd == "debug_relay_show"){ + cmd_replay(cmd_debug_relay_show(params)); }else if (cmd == "debug_sensors"){ cmd_replay(cmd_debug_sensors(params)); }else if (cmd == "debug_showtime"){ @@ -67,13 +82,21 @@ string cmd_debug_relay_reply(string params){ config.debug.RelayReply = val(pars[0])>0; return "Debug relay reply SET="+(config.debug.RelayReply? "TRUE":"FALSE"); } - +string cmd_debug_relay_show(string params){ + getParams(params); + config.debug.RelayShow = val(pars[0])>0; + return "Debug relay show SET="+(config.debug.RelayShow? "TRUE":"FALSE"); +} string cmd_debug_enc_level(string params){ getParams(params); config.debug.EncoderDebug= val(pars[0]); return "Debug encoder level SET="+str(config.debug.EncoderDebug); } - +string cmd_debug_enc_state(string params){ + getParams(params); + config.debug.EncoderStateMode= val(pars[0]); + return "Debug encoder work with state SET="+str(config.debug.EncoderStateMode); +} string cmd_debug_showtime(string params){ getParams(params); config.debug.ShowTime = val(pars[0])>0; diff --git a/command.th b/command.th index 8c613b5..3743d19 100644 --- a/command.th +++ b/command.th @@ -8,7 +8,9 @@ string cmd_setencoder(string params); string cmd_enc_calibre(string params); string cmd_enc_set_windows(string params); string cmd_debug_enc_level(string params); +string cmd_debug_enc_state(string params); string cmd_debug_sensors(string params); string cmd_debug_showtime(string params); void getParams(string params); string cmd_debug_relay_reply(string params); +string cmd_debug_relay_show(string params); diff --git a/config_work.tc b/config_work.tc index 8ad39a7..0e8bf75 100644 --- a/config_work.tc +++ b/config_work.tc @@ -197,5 +197,6 @@ void config_create(){ config.EncoderCfg.workedPorts = ""; config.debug.EncoderDebug=0; + config.debug.RelayShow=true; } \ No newline at end of file diff --git a/global.th b/global.th index e65d2c8..fd0d80f 100644 --- a/global.th +++ b/global.th @@ -9,7 +9,7 @@ #message "link global not defined" #endif -#define VERSION "2.0b_1901312239" +#define VERSION "2.0b_1902011653" #define MAX_FIFO_SIZE 20 #define BRAKER_COUNT 3 @@ -81,6 +81,8 @@ typedef struct DebugConf{ bool ShowTime; int EncoderDebug; bool RelayReply; + bool RelayShow; + bool EncoderStateMode; }; typedef struct Configuration{ @@ -118,3 +120,4 @@ extern BrakerProcess brakers[BRAKER_COUNT]; + diff --git a/main.tc b/main.tc index f2eb2b1..7687d23 100644 --- a/main.tc +++ b/main.tc @@ -101,8 +101,9 @@ if (!inEncCalibrate()){ // sensors process for (int i=1; i <= SENSORS; i++){ if (pinChange(i)){ - bool state = getPinStateS(i,true); + bool state = getPinStateS(i,!config.debug.EncoderStateMode); if (getEncEnabled(i,state)) + getPinStateS(i,config.debug.EncoderStateMode); send_sensor(i,state); } } diff --git a/relay.tc b/relay.tc index 64a68c5..e27b197 100644 --- a/relay.tc +++ b/relay.tc @@ -19,5 +19,5 @@ void relay_set(int number, bool state) #if PLATFORM_ID != SIMULATOR io.lineset(OUTPIN[number-1],!state ); #endif - d("Relay "+str(number)+" is "+ (state? "ON":"OFF")); + if (config.debug.RelayShow) d("Relay "+str(number)+" is "+ (state? "ON":"OFF")); } \ No newline at end of file