添加广播方式升级
This commit is contained in:
@@ -30,8 +30,8 @@ myarray moter_ctrl(myarray op)
|
||||
moter->moter_run = 1;
|
||||
count = -moter->moter_count - 100;
|
||||
moter->moter_count = 0;
|
||||
QString s = QString("moter %1").arg(count);
|
||||
r = s.toLocal8Bit();
|
||||
mystring s = mystring("moter %1").arg(count);
|
||||
r = myarray(s.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -47,8 +47,9 @@ myarray moter_ctrl(myarray op)
|
||||
moter->moter_run = 1;
|
||||
count = cfg_->moter_count - moter->moter_count;
|
||||
moter->moter_count += count;
|
||||
QString s = QString("moter %1").arg(count);
|
||||
r = s.toLocal8Bit();
|
||||
mystring s = mystring("moter %1").arg(count);
|
||||
r = myarray(s.data());
|
||||
qDebug("moter down:%s",s.data());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -56,7 +57,8 @@ myarray moter_ctrl(myarray op)
|
||||
return r;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
qDebug("moter ctrl:%s",op.data());
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,23 +70,24 @@ 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);
|
||||
m4->set_irq_fun([=](myarray data)
|
||||
{
|
||||
m4->del_irq_fun(nullptr,"moter ");
|
||||
if(data=="down"){
|
||||
// 这里开始检测
|
||||
QList<int> addrs=cfg->calc_slave_addrs();
|
||||
HandleSlave *s=new slave_check();
|
||||
foreach(int addr, addrs){
|
||||
bool ack=slave->set_slave_handle(addr,s);
|
||||
if(ack==false){
|
||||
qWarning("addr %d handle is busy.",addr);
|
||||
}else{
|
||||
connect(s,&HandleSlave::end_signal,this,&selfdev_check::slave_end_slot);
|
||||
}
|
||||
prot_m4_cb moter_down_cb=[=](myarray data)
|
||||
{
|
||||
m4->del_irq_fun(moter_down_cb,"moter ");
|
||||
if(data=="down"){
|
||||
// 这里开始检测
|
||||
QList<int> addrs=cfg->calc_slave_addrs();
|
||||
HandleSlave *s=new slave_check();
|
||||
foreach(int addr, addrs){
|
||||
bool ack=slave->set_slave_handle(addr,s);
|
||||
if(ack==false){
|
||||
qWarning("addr %d handle is busy.",addr);
|
||||
}else{
|
||||
connect(s,&HandleSlave::end_signal,this,&selfdev_check::slave_end_slot);
|
||||
}
|
||||
}
|
||||
},"moter ");
|
||||
}
|
||||
};
|
||||
m4->set_irq_fun(moter_down_cb,"moter ");
|
||||
emit send_to_m4_signal(moter_ctrl("down"));
|
||||
slave_acked.clear();
|
||||
for(int i=0;i<cfg->slave_num;i++){
|
||||
@@ -148,8 +151,32 @@ 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);
|
||||
|
||||
protpc_export(0xff, get_selfdev_check);
|
||||
int selfdev_moter::dolater(int cmd, myarray data)
|
||||
{
|
||||
prot_m4 *m4 = protM4();
|
||||
connect(this, &selfdev_moter::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_moter::timeout(){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static HandlePc *get_selfdev_moter(){
|
||||
return new selfdev_moter();
|
||||
}
|
||||
|
||||
protpc_export(0x40, get_selfdev_moter);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user