Добавлены команды выключения вывода в отладку информации о сработках реле и включения режима работы энкодера по состоянию 1902011653

This commit is contained in:
Иван Мокротоваров 2019-02-01 16:54:37 +03:00
parent 7ab40390c6
commit 7dbf043923
6 changed files with 37 additions and 7 deletions

View File

@ -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;

View File

@ -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);

View File

@ -197,5 +197,6 @@ void config_create(){
config.EncoderCfg.workedPorts = "";
config.debug.EncoderDebug=0;
config.debug.RelayShow=true;
}

View File

@ -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];

View File

@ -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);
}
}

View File

@ -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"));
}