类析构时取消其设置的回调函数

This commit is contained in:
ranchuan
2023-11-30 10:50:05 +08:00
parent e34b8111dc
commit ae972b21aa
4 changed files with 81 additions and 11 deletions

View File

@@ -62,6 +62,11 @@ myarray moter_ctrl(myarray op)
}
// 自研批检仪检测
int selfdev_check::dolater(int cmd, myarray data)
{
@@ -70,9 +75,9 @@ int selfdev_check::dolater(int cmd, myarray data)
mycfg *cfg=syscfg();
busy=1;
connect(this, &selfdev_check::send_to_m4_signal, m4, &prot_m4::send_data_slot);
prot_m4_cb moter_down_cb=[=](myarray data)
moter_down_cb_fun=[=](myarray data)
{
m4->del_irq_fun(moter_down_cb,"moter ");
m4->del_irq_fun(moter_down_cb_fun,"moter ");
if(data=="down"){
// 这里开始检测
QList<int> addrs=cfg->calc_slave_addrs();
@@ -87,7 +92,7 @@ int selfdev_check::dolater(int cmd, myarray data)
}
}
};
m4->set_irq_fun(moter_down_cb,"moter ");
m4->set_irq_fun(moter_down_cb_fun,"moter ");
emit send_to_m4_signal(moter_ctrl("down"));
slave_acked.clear();
for(int i=0;i<cfg->slave_num;i++){
@@ -128,7 +133,6 @@ static myarray tran_slave_to_selfdev_check(myarray &data)
return r;
}
void selfdev_check::slave_end_slot(int addr,int ack, myarray data)
{
if(addr<=0||addr>slave_acked.size()){
@@ -146,13 +150,17 @@ void selfdev_check::slave_end_slot(int addr,int ack, myarray data)
}
}
static HandlePc *get_selfdev_check(){
return new selfdev_check();
}
protpc_export(0x30, get_selfdev_check);
int selfdev_moter::dolater(int cmd, myarray data)
{
prot_m4 *m4 = protM4();
@@ -170,8 +178,6 @@ void selfdev_moter::timeout(){
}
static HandlePc *get_selfdev_moter(){
return new selfdev_moter();
}
@@ -180,3 +186,34 @@ protpc_export(0x40, get_selfdev_moter);
int selfdev_slaveupdate::dolater(int cmd, myarray data)
{
prot_m4 *m4 = protM4();
connect(this, &selfdev_slaveupdate::send_to_m4_signal, m4, &prot_m4::send_data_slot);
if(data[0]==0x02){
emit send_to_m4_signal(moter_ctrl("up"));
}else if(data[0]==0x03){
emit send_to_m4_signal(moter_ctrl("down"));
}
emit send_data_signal(0x40,myarray(1,char(0)));
return 0;
}
void selfdev_slaveupdate::timeout(){
}
static HandlePc *get_selfdev_slaveupdate(){
return new selfdev_slaveupdate();
}
protpc_export(0x40, get_selfdev_slaveupdate);