自研批检仪检测命令测试成功
广播方式升级从机发现卡死现象
This commit is contained in:
@@ -77,23 +77,32 @@ int selfdev_check::dolater(int cmd, myarray data)
|
||||
connect(this, &selfdev_check::send_to_m4_signal, m4, &prot_m4::send_data_slot);
|
||||
moter_down_cb_fun=[=](myarray data)
|
||||
{
|
||||
m4->del_irq_fun(moter_down_cb_fun,"moter ");
|
||||
if(data=="down"){
|
||||
m4->del_irq_fun(moter_down_cb_fun,"moter down");
|
||||
{
|
||||
// 这里开始检测
|
||||
qDebug("start check.");
|
||||
emit send_data_signal(cmd,myarray(1,0));
|
||||
QList<int> addrs=cfg->calc_slave_addrs();
|
||||
HandleSlave *s=new slave_check();
|
||||
foreach(int addr, addrs){
|
||||
HandleSlave *s=new slave_check();
|
||||
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);
|
||||
s->start(myarray());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
m4->set_irq_fun(moter_down_cb_fun,"moter ");
|
||||
emit send_to_m4_signal(moter_ctrl("down"));
|
||||
myarray moter_cmd=moter_ctrl("down");
|
||||
if(moter_cmd.size()==0){
|
||||
busy=0;
|
||||
qWarning("moter failed.");
|
||||
}else{
|
||||
m4->set_irq_fun(moter_down_cb_fun,"moter down");
|
||||
emit send_to_m4_signal(moter_cmd);
|
||||
}
|
||||
slave_acked.clear();
|
||||
for(int i=0;i<cfg->slave_num;i++){
|
||||
slave_acked.append(myarray());
|
||||
@@ -104,7 +113,7 @@ int selfdev_check::dolater(int cmd, myarray data)
|
||||
|
||||
void selfdev_check::timeout()
|
||||
{
|
||||
|
||||
busy=0;
|
||||
}
|
||||
|
||||
// 把小板的返回数据转化为自研批检仪上位机的格式
|
||||
@@ -136,8 +145,10 @@ static myarray tran_slave_to_selfdev_check(myarray &data)
|
||||
void selfdev_check::slave_end_slot(int addr,int ack, myarray data)
|
||||
{
|
||||
if(addr<=0||addr>slave_acked.size()){
|
||||
slave_acked.replace(addr-1,data);
|
||||
qWarning("slave addr err:%d",addr);
|
||||
return;
|
||||
}
|
||||
slave_acked.replace(addr-1,data);
|
||||
slave_acked_num++;
|
||||
if(slave_acked_num>=slave_acked.size()){
|
||||
myarray r;
|
||||
@@ -160,7 +171,33 @@ protpc_export(0x30, get_selfdev_check);
|
||||
|
||||
|
||||
|
||||
// 检测结束 电机上升
|
||||
int selfdev_checkend::dolater(int cmd, myarray data)
|
||||
{
|
||||
prot_m4 *m4 = protM4();
|
||||
connect(this, &selfdev_checkend::send_to_m4_signal, m4, &prot_m4::send_data_slot);
|
||||
emit send_to_m4_signal(moter_ctrl("up"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void selfdev_checkend::timeout(){
|
||||
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_checkend(){
|
||||
return new selfdev_checkend();
|
||||
}
|
||||
|
||||
protpc_export(0x31, get_selfdev_checkend);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 电机控制
|
||||
int selfdev_moter::dolater(int cmd, myarray data)
|
||||
{
|
||||
prot_m4 *m4 = protM4();
|
||||
@@ -189,17 +226,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"));
|
||||
myarray r;
|
||||
int len_filename=data[0];
|
||||
mystring name=data.mid(1,len_filename);
|
||||
prot_slave *slave=protSlave();
|
||||
mycfg *cfg_=syscfg();
|
||||
qInfo()<<"slave_app name:"<<name<<endl;
|
||||
data.remove(0,len_filename+1);
|
||||
|
||||
// TODO 校验小板程序
|
||||
|
||||
r.append(uint8_t(0));
|
||||
cfg_->save_file(name,data);
|
||||
emit send_data_signal(0xfe,myarray(1,char(0)));
|
||||
|
||||
// 自动给小板升级
|
||||
// start_updata_mcu(cfg_->config_path+name,slave_addrs);
|
||||
HandleBoardCast *b=new boardcast_updata();
|
||||
bool ack=slave->set_boardcast_handle(cfg_->calc_slave_addrs(),b);
|
||||
if(ack==false){
|
||||
qWarning("handle is busy.");
|
||||
}else{
|
||||
connect(b,&HandleBoardCast::end_signal,this,&selfdev_slaveupdate::slave_end_slot);
|
||||
b->start(data);
|
||||
}
|
||||
emit send_data_signal(0x40,myarray(1,char(0)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -207,11 +261,16 @@ void selfdev_slaveupdate::timeout(){
|
||||
|
||||
}
|
||||
|
||||
void selfdev_slaveupdate::slave_end_slot(int addr,int ack, myarray data)
|
||||
{
|
||||
qDebug("slave update end,ack=%d",ack);
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_slaveupdate(){
|
||||
return new selfdev_slaveupdate();
|
||||
}
|
||||
|
||||
protpc_export(0x41, get_selfdev_slaveupdate);
|
||||
protpc_export(0xfe, get_selfdev_slaveupdate);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user