371 lines
7.0 KiB
C++
371 lines
7.0 KiB
C++
#ifndef cmd_pc_h__
|
|
#define cmd_pc_h__
|
|
|
|
#include "prot/prot_pc.h"
|
|
#include "prot/prot_m4.h"
|
|
#include "prot_cmd/cmd_slave.h"
|
|
|
|
|
|
// 把小板的返回数据转化为自研批检仪上位机的格式
|
|
myarray tran_slave_to_selfdev_check(myarray &data);
|
|
|
|
// 电机控制
|
|
myarray moter_ctrl(myarray op);
|
|
|
|
// 检测 自研批检仪
|
|
class selfdev_check : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_check() : HandlePc() {
|
|
slave_acked_num=0;
|
|
moter_down_cb_fun=nullptr;
|
|
}
|
|
~selfdev_check() {
|
|
if(moter_down_cb_fun!=nullptr){
|
|
// 取消电机下降到位回调
|
|
prot_m4 *m4 = protM4();
|
|
if(m4!=nullptr) {
|
|
m4->del_irq_fun(moter_down_cb_fun,"moter ");
|
|
}
|
|
}
|
|
}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
public slots:
|
|
void slave_end_slot(int addr,int ack, myarray data);
|
|
protected:
|
|
QList<myarray> slave_acked;
|
|
int slave_acked_num;
|
|
prot_m4_cb moter_down_cb_fun;
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
};
|
|
|
|
|
|
|
|
|
|
// 检测 自研批检仪 广播形式
|
|
class selfdev_check2 : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_check2() : HandlePc() {
|
|
slave_acked_num=0;
|
|
moter_down_cb_fun=nullptr;
|
|
}
|
|
~selfdev_check2() {
|
|
if(moter_down_cb_fun!=nullptr){
|
|
// 取消电机下降到位回调
|
|
prot_m4 *m4 = protM4();
|
|
if(m4!=nullptr) {
|
|
m4->del_irq_fun(moter_down_cb_fun,"moter ");
|
|
}
|
|
}
|
|
}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
public slots:
|
|
void slave_end_slot(int addr,int ack, slave_data data);
|
|
protected:
|
|
QList<myarray> slave_acked;
|
|
int slave_acked_num;
|
|
prot_m4_cb moter_down_cb_fun;
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
};
|
|
|
|
|
|
|
|
|
|
// 检测结束 自研批检仪
|
|
class selfdev_checkend : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_checkend() : HandlePc() {}
|
|
~selfdev_checkend() {}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
};
|
|
|
|
|
|
|
|
|
|
// 电机 自研批检仪
|
|
class selfdev_moter : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_moter() : HandlePc() {}
|
|
~selfdev_moter() {}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 小板升级
|
|
class selfdev_slaveupdate : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_slaveupdate() : HandlePc() {
|
|
handle_start_time=0;
|
|
}
|
|
~selfdev_slaveupdate() {}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
public slots:
|
|
void slave_end_slot(int addr,int ack, slave_data data);
|
|
void rate_slot(int rate, mystring str);
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
protected:
|
|
qint64 handle_start_time;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 升级方案
|
|
class selfdev_update_scheme : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_update_scheme() : HandlePc() {}
|
|
~selfdev_update_scheme() {}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
public slots:
|
|
void slave_end_slot(int addr,int ack, slave_data data);
|
|
void rate_slot(int rate, mystring str);
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
protected:
|
|
qint64 handle_start_time;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 本机升级
|
|
class selfdev_hostupdate : public selfdev_slaveupdate
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_hostupdate() : selfdev_slaveupdate() {}
|
|
~selfdev_hostupdate() {}
|
|
int dolater(int cmd, myarray data);
|
|
};
|
|
|
|
|
|
|
|
// jwt升级
|
|
class selfdev_jwtupdate : public selfdev_slaveupdate
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_jwtupdate() : selfdev_slaveupdate() {}
|
|
~selfdev_jwtupdate() {}
|
|
int dolater(int cmd, myarray data);
|
|
};
|
|
|
|
|
|
|
|
|
|
// 自检
|
|
class selfdev_bootinfo : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_bootinfo() : HandlePc() {
|
|
slave_acked_num=0;
|
|
}
|
|
~selfdev_bootinfo() {
|
|
}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
public slots:
|
|
virtual void slave_end_slot(int addr,int ack, slave_data data);
|
|
protected:
|
|
QList<myarray> slave_acked;
|
|
int slave_acked_num;
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 测量电阻
|
|
class selfdev_measure_rescv : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_measure_rescv() : HandlePc() {
|
|
slave_acked_num=0;
|
|
}
|
|
~selfdev_measure_rescv() {
|
|
if(moter_down_cb_fun!=nullptr){
|
|
// 取消电机下降到位回调
|
|
prot_m4 *m4 = protM4();
|
|
if(m4!=nullptr) {
|
|
m4->del_irq_fun(moter_down_cb_fun,"moter ");
|
|
}
|
|
}
|
|
}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
public slots:
|
|
void slave_end_slot(int addr,int ack, slave_data data);
|
|
protected:
|
|
QList<myarray> slave_acked;
|
|
int slave_acked_num;
|
|
prot_m4_cb moter_down_cb_fun;
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
};
|
|
|
|
|
|
|
|
|
|
// 设置电阻校准
|
|
class selfdev_set_rescv : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_set_rescv() : HandlePc() {
|
|
slave_acked_num=0;
|
|
}
|
|
~selfdev_set_rescv() {
|
|
}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
public slots:
|
|
void slave_end_slot(int addr,int ack, slave_data data);
|
|
protected:
|
|
QList<myarray> slave_acked;
|
|
int slave_acked_num;
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 执行任务
|
|
class selfdev_runtask : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
selfdev_runtask() : HandlePc() {
|
|
slave_acked_num=0;
|
|
}
|
|
~selfdev_runtask() {
|
|
}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
// pc指令转从机
|
|
virtual myarray cmd_pc_to_slave(myarray data)=0;
|
|
// pc指令生成从机列表
|
|
virtual QList<int> cmd_pc_to_addrs(myarray data)=0;
|
|
// 从机发起命令
|
|
virtual int cmd_slave(){return 0x20;}
|
|
// pc收到回复,返回0不回复
|
|
virtual int cmd_pc_recv()=0;
|
|
// 生成接收回复到pc
|
|
virtual myarray cmd_pc_recv_to_pc()=0;
|
|
// pc回复命令,返回0不回复
|
|
virtual int cmd_pc_ret()=0;
|
|
// 从机返回转pc
|
|
virtual myarray ret_slave_to_pc(QList<myarray> data)=0;
|
|
public slots:
|
|
void slave_end_slot(int addr,int ack, slave_data data);
|
|
protected:
|
|
void slave_sort();
|
|
protected:
|
|
QList<myarray> slave_acked;
|
|
int slave_acked_num;
|
|
QList<int> addrs;
|
|
signals:
|
|
void send_to_m4_signal(myarray data);
|
|
};
|
|
|
|
|
|
/*
|
|
|
|
selfdev_runtask 重载示例
|
|
class selfdef_custom:public selfdev_runtask
|
|
{
|
|
// 重载此函数把pc的指令格式转化为从机能识别的格式
|
|
myarray cmd_pc_to_slave(myarray data);
|
|
// 重载此函数根据pc指令生成要执行命令的从机列表
|
|
QList<int> cmd_pc_to_addrs(myarray data);
|
|
// (可选)重载此函数设置从机要执行的命令,不重载则使用命令0x20
|
|
int cmd_slave();
|
|
// 重载此函数指定收到数据回复的命令字
|
|
int cmd_pc_recv();
|
|
// 重载此函数生成接收到数据回复的数据
|
|
myarray cmd_pc_recv_to_pc();
|
|
// 重载此函数指定操作结束回复的命令字
|
|
int cmd_pc_ret();
|
|
// 重载此函数把从机的数据格式转化为pc能识别的格式
|
|
myarray ret_slave_to_pc(QList<myarray> data);
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
// 赋码仪配置参数
|
|
class coder_sysparam : public HandlePc
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
coder_sysparam() : HandlePc() {
|
|
}
|
|
~coder_sysparam() {
|
|
}
|
|
int dolater(int cmd, myarray data);
|
|
void timeout();
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 赋码仪基本信息
|
|
class coder_bootinfo : public selfdev_bootinfo
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
coder_bootinfo() : selfdev_bootinfo() {
|
|
}
|
|
~coder_bootinfo() {
|
|
}
|
|
void slave_end_slot(int addr,int ack, slave_data data);
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|