Сборка 1902201737
This commit is contained in:
parent
66aca25662
commit
9e757b93d2
13
command.tc
13
command.tc
|
|
@ -243,7 +243,18 @@ string cmd_setencoder(){
|
||||||
config.EncoderCfg.encoderPort = pars[0];
|
config.EncoderCfg.encoderPort = pars[0];
|
||||||
config.EncoderCfg.encoderMode = pars[1];
|
config.EncoderCfg.encoderMode = pars[1];
|
||||||
config.EncoderCfg.encoderInterval = pars[2];
|
config.EncoderCfg.encoderInterval = pars[2];
|
||||||
config.EncoderCfg.workedPorts = pars[par_num];
|
string ports;
|
||||||
|
string port = pars[par_num];
|
||||||
|
int n = 1;
|
||||||
|
int p = instr(1,port,".",1);
|
||||||
|
while (p>0){
|
||||||
|
ports+=chr(val(mid(port,n,n-p)));
|
||||||
|
n = p+1;
|
||||||
|
p = instr(n,port,".",1);
|
||||||
|
}
|
||||||
|
ports += chr(val(mid(port,n,len(port)-n+1)));
|
||||||
|
|
||||||
|
config.EncoderCfg.workedPorts = ports;
|
||||||
config_save();
|
config_save();
|
||||||
encoder_init();
|
encoder_init();
|
||||||
return "Энкодер настроен: Порт: "+str(pars[0])+ ", Режим: "+str(pars[1])+ ", Интервал: "+str(pars[2])+ ", Рабочие порты: "+pars[par_num];
|
return "Энкодер настроен: Порт: "+str(pars[0])+ ", Режим: "+str(pars[1])+ ", Интервал: "+str(pars[2])+ ", Рабочие порты: "+pars[par_num];
|
||||||
|
|
|
||||||
13
encoder.tc
13
encoder.tc
|
|
@ -42,7 +42,8 @@ void encoder_init(){
|
||||||
inited = true;
|
inited = true;
|
||||||
#if PLATFORM_ID != SIMULATOR
|
#if PLATFORM_ID != SIMULATOR
|
||||||
io.intnum = intnum-1;
|
io.intnum = intnum-1;
|
||||||
if (config.STORE_ENCODER) io.intenabled = YES;
|
//if (config.STORE_ENCODER)
|
||||||
|
io.intenabled = YES;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,9 +90,10 @@ bool getEncEnabled(unsigned char port,bool value){
|
||||||
}else{
|
}else{
|
||||||
if (config.debug.EncoderDebug>2) d(str(port)+" не попал о окно "+str(works[portVector[port]].Count));
|
if (config.debug.EncoderDebug>2) d(str(port)+" не попал о окно "+str(works[portVector[port]].Count));
|
||||||
}
|
}
|
||||||
t("enc_end");
|
if (works[portVector[port]].State) {
|
||||||
if (works[portVector[port]].State)
|
|
||||||
send_encoder_tick(port,count);
|
send_encoder_tick(port,count);
|
||||||
|
}
|
||||||
|
t("enc_end");
|
||||||
return works[portVector[port]].State;
|
return works[portVector[port]].State;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
|
@ -108,8 +110,8 @@ bool getEncEnabled(unsigned char port,bool value){
|
||||||
void on_io_int(unsigned char linestate){
|
void on_io_int(unsigned char linestate){
|
||||||
t("enc_int_start");
|
t("enc_int_start");
|
||||||
count ++;
|
count ++;
|
||||||
string workers = vector[linestate-1];
|
//string workers = vector[linestate-1];
|
||||||
if(calibrate_mode>0){
|
if(calibrate_mode>0){ // калибровка
|
||||||
for (int i=0;i<len(config.EncoderCfg.workedPorts);i++){
|
for (int i=0;i<len(config.EncoderCfg.workedPorts);i++){
|
||||||
unsigned char port = config.EncoderCfg.workedPorts[i];
|
unsigned char port = config.EncoderCfg.workedPorts[i];
|
||||||
if (pinChange(port) && getPinStateS(port,true)==true)
|
if (pinChange(port) && getPinStateS(port,true)==true)
|
||||||
|
|
@ -119,6 +121,7 @@ void on_io_int(unsigned char linestate){
|
||||||
calibrate_buff[i][z[i]]=calibrate_count[i];
|
calibrate_buff[i][z[i]]=calibrate_count[i];
|
||||||
cmd_replay("Калибровка энкодера "+str(port)+":"+str(calibrate_count[i]));
|
cmd_replay("Калибровка энкодера "+str(port)+":"+str(calibrate_count[i]));
|
||||||
if (config.debug.EncoderDebug>0) d("Калибровка энкодера "+str(port)+":"+str(calibrate_count[i]));
|
if (config.debug.EncoderDebug>0) d("Калибровка энкодера "+str(port)+":"+str(calibrate_count[i]));
|
||||||
|
send_encoder_tick(port,count);
|
||||||
}
|
}
|
||||||
z[i]++;
|
z[i]++;
|
||||||
calibrate_count[i]=0;
|
calibrate_count[i]=0;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#message "link global not defined"
|
#message "link global not defined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define VERSION "2.0b_1902181804"
|
#define VERSION "2.0b_1902201737"
|
||||||
#define MAX_FIFO_SIZE 20
|
#define MAX_FIFO_SIZE 20
|
||||||
#define BRAKER_COUNT 3
|
#define BRAKER_COUNT 3
|
||||||
|
|
||||||
|
|
@ -126,3 +126,4 @@ extern BrakerProcess brakers[BRAKER_COUNT];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
2
main.tc
2
main.tc
|
|
@ -139,7 +139,7 @@ if (!inEncCalibrate()){
|
||||||
for (int i=1; i <= SENSORS; i++){
|
for (int i=1; i <= SENSORS; i++){
|
||||||
if (pinChange(i)){
|
if (pinChange(i)){
|
||||||
//bool state = getPinStateS(i,!config.debug.EncoderStateMode);
|
//bool state = getPinStateS(i,!config.debug.EncoderStateMode);
|
||||||
bool state = getPinStateS(i,true);
|
bool state = getPinStateS(i, !inEncCalibrate());
|
||||||
if (getEncEnabled(i,state)){
|
if (getEncEnabled(i,state)){
|
||||||
// getPinStateS(i,config.debug.EncoderStateMode);
|
// getPinStateS(i,config.debug.EncoderStateMode);
|
||||||
send_sensor(i,state);
|
send_sensor(i,state);
|
||||||
|
|
|
||||||
4
net.tc
4
net.tc
|
|
@ -125,13 +125,15 @@ void send_sensor(int number, bool state){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void send_encoder_tick(int number, unsigned long count){
|
void send_encoder_tick(int number, unsigned long count){
|
||||||
|
int n = sock.num;
|
||||||
sock.num = 0;
|
sock.num = 0;
|
||||||
if (sock.statesimple == PL_SSTS_EST){
|
if (sock.statesimple == PL_SSTS_EST){
|
||||||
if (config.debug.SensorsLook)
|
if (config.debug.SensorsLook)
|
||||||
d("Send sensor tick "+str(number)+" : "+stri(count));
|
d("Send encoder tick "+str(number)+" : "+stri(count));
|
||||||
sock.setdata("enc="+str(number)+":"+(lstri(count))+chr(13)+chr(10));
|
sock.setdata("enc="+str(number)+":"+(lstri(count))+chr(13)+chr(10));
|
||||||
sock.send();
|
sock.send();
|
||||||
}
|
}
|
||||||
|
sock.num = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue