╤сюЁър 1901301532

This commit is contained in:
Иван Мокротоваров 2019-01-30 15:32:35 +03:00
parent 126ea01dd6
commit 39d899aca1
6 changed files with 65 additions and 16 deletions

View File

@ -1,13 +1,13 @@
[project]
watch=works[i].Count, portVector, works[i].WorkPort, len(port), pinState, z, works[i], EncoderCfg.reinitInterval, works
[file1]
line=85
cursor=2097
opened=yes
line=0
cursor=263
opened=active
breakpoints=
[file2]
line=44
cursor=1179
line=62
cursor=1455
opened=yes
breakpoints=
[file3]
@ -26,14 +26,14 @@ cursor=161
opened=no
breakpoints=
[file6]
line=5
cursor=1461
line=0
cursor=190
opened=yes
breakpoints=
[file7]
line=18
cursor=916
opened=no
line=100
cursor=2644
opened=yes
breakpoints=
[file8]
line=0
@ -45,7 +45,7 @@ line=0
cursor=0
opened=no
[file10]
line=76
line=22
cursor=5043
opened=yes
breakpoints=
@ -86,7 +86,7 @@ opened=no
breakpoints=
[file18]
line=0
cursor=55
cursor=334
opened=yes
breakpoints=
[file19]
@ -95,9 +95,9 @@ cursor=93
opened=yes
breakpoints=
[file20]
line=156
cursor=3777
opened=active
line=0
cursor=2782
opened=yes
breakpoints=
[file21]
line=0
@ -105,7 +105,7 @@ cursor=0
opened=yes
breakpoints=
[file22]
line=18
line=0
cursor=0
opened=yes
breakpoints=

View File

@ -6,6 +6,8 @@
#include "encoder.th"
static string cmdbuffer = "";
string pars[10];
int par_num;
void on_sock_inband() // обработка поступивших команд
{
cmdbuffer += sock.getinband();
@ -36,6 +38,10 @@ void on_sock_inband() // обработка поступивших команд
cmd_replay(cmd_setencoder(params));
}else if (cmd == "enc_calibrate_start"){
cmd_replay(cmd_enc_calibre(params));
}else if (cmd == "debug_sensors"){
cmd_replay(cmd_debug_sensors(params));
}else if (cmd == "debug_showtime"){
cmd_replay(cmd_debug_showtime(params));
}else if (cmd == "enc_calibrate_end"){
cmd_replay(cmd_enc_calibre("0"));
}else {
@ -46,6 +52,17 @@ void on_sock_inband() // обработка поступивших команд
}
}
string cmd_debug_sensors(string params){
getParams(params);
config.debug.SensorsLook = val(pars[0])>0;
return "Debug sensors SET="+config.debug.SensorsLook? "TRUE":"FALSE";
}
string cmd_debug_showtime(string params){
getParams(params);
config.debug.ShowTime = val(pars[0])>0;
return "Debug show time SET="+config.debug.ShowTime? "TRUE":"FALSE";
}
void cmd_replay(string message){
sock.setsendinband(chr(sock.escchar)+" "+message+chr(sock.endchar)+chr(13)+chr(10));
}
@ -169,3 +186,21 @@ string cmd_setbraker(string params)
return message;
}
void getParams(string params){
//d("params: "+params);
unsigned char n, p, num ;
unsigned long t;
string vals = "";
par_num = 0;
n = 1;
p = instr(1,params,",",1);
while (p>0){
pars[par_num] = mid(params,n,n-p);
n = p+1;
par_num++;
p = instr(n,params,",",1);
}
pars[par_num] = mid(params,n,len(params)-n+1);
}

View File

@ -6,3 +6,6 @@ string cmd_ip(string params);
string cmd_setbraker(string params);
string cmd_setencoder(string params);
string cmd_enc_calibre(string params);
string cmd_debug_sensors(string params);
string cmd_debug_showtime(string params);
void getParams(string params);

View File

@ -75,6 +75,12 @@ typedef struct EncoderProcess{
unsigned long Point;
unsigned char WorkPort;
};
typedef struct DebugConf{
bool SensorsLook;
bool ShowTime;
};
typedef struct Configuration{
string IP;
STORELOCATION STORE_LOCATON;
@ -84,6 +90,7 @@ typedef struct Configuration{
BrakerConfig BRAKERS[BRAKER_COUNT];
BounceConfig BOUNCE[SENSORS];
EncoderConfig EncoderCfg;
DebugConf debug;
};
//#include "config_work.th"

View File

@ -6,6 +6,8 @@
//====================================================================
void d(string mess){
if (config.debug.ShowTime)
mess = lstr(sys.timercountms)+":\t"+mess;
sys.debugprint(mess+chr(13));
int c = sock.num;
sock.num = 2;

2
net.tc
View File

@ -117,6 +117,8 @@ void net_sensor_handle(string message){
void send_sensor(int number, bool state){
sock.num = 0;
if (sock.statesimple == PL_SSTS_EST){
if (config.debug.SensorsLook)
d("Send sensor "+str(number)+" : "+(state?"1":"0"));
sock.setdata(str(number)+(state?"1":"0")+chr(13)+chr(10));
sock.send();
}