添加自研批检仪检测命令
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#ifndef PROT_SLAVE_H
|
||||
#define PROT_SLAVE_H
|
||||
|
||||
|
||||
#include "QObject"
|
||||
#include "base/base.h"
|
||||
#include "QList"
|
||||
@@ -9,52 +8,80 @@
|
||||
#include "interface/interface.h"
|
||||
#include "base/mycfg.h"
|
||||
#include "QThread"
|
||||
#include "QTimer"
|
||||
|
||||
|
||||
class HandleSlave:public QObject{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HandleSlave(){busy=0;}
|
||||
virtual ~HandleSlave(){}
|
||||
virtual int start(myarray data)=0;
|
||||
virtual int dolater(int cmd,myarray data)=0;
|
||||
int busy;
|
||||
signals:
|
||||
void send_data_signal(int addr,int cmd,myarray data);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class prot_slave:public QObject
|
||||
class HandleSlave : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
prot_slave(){if_=nullptr;codec_=nullptr;busy=0;addr=0;}
|
||||
~prot_slave(){}
|
||||
void init();
|
||||
bool set_slave_handle(int addr,HandleSlave *handle);
|
||||
int busy;
|
||||
int addr;
|
||||
protected slots:
|
||||
void send_data_slot(int addr,int cmd,myarray data);
|
||||
HandleSlave() {
|
||||
busy = 0;
|
||||
addr = 0;
|
||||
cmd=0;
|
||||
timer_=nullptr;
|
||||
}
|
||||
virtual ~HandleSlave() {
|
||||
if(timer_!=nullptr){
|
||||
delete timer_;
|
||||
}
|
||||
}
|
||||
public:
|
||||
virtual int start(myarray data) = 0;
|
||||
virtual int dolater(int cmd, myarray data) = 0;
|
||||
virtual void timeout()=0;
|
||||
int busy;
|
||||
int addr;
|
||||
int cmd;
|
||||
public:
|
||||
int send_data(int cmd,myarray data){
|
||||
emit send_data_signal(addr,cmd,data);
|
||||
return 0;
|
||||
}
|
||||
int end(int ack,myarray data){
|
||||
emit end_signal(addr,ack,data);
|
||||
return 0;
|
||||
}
|
||||
protected:
|
||||
InterFace *if_;
|
||||
Codec *codec_;
|
||||
QList<HandleSlave *> slaves;
|
||||
void timeout_start(int ms){
|
||||
if(timer_==nullptr){
|
||||
timer_=new QTimer();
|
||||
connect(timer_,&QTimer::timeout,this,&HandleSlave::timeout);
|
||||
}
|
||||
timer_->start(ms);
|
||||
}
|
||||
void timeout_stop(){
|
||||
if(timer_!=nullptr){
|
||||
timer_->stop();
|
||||
}
|
||||
}
|
||||
private:
|
||||
QTimer *timer_;
|
||||
signals:
|
||||
void send_data_signal(int addr, int cmd, myarray data);
|
||||
void end_signal(int addr,int ack,myarray data);
|
||||
};
|
||||
|
||||
class prot_slave : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
prot_slave()
|
||||
{
|
||||
if_ = nullptr;
|
||||
codec_ = nullptr;
|
||||
}
|
||||
~prot_slave() {}
|
||||
void init();
|
||||
bool set_slave_handle(int addr, HandleSlave *handle);
|
||||
protected slots:
|
||||
void send_data_slot(int addr, int cmd, myarray data);
|
||||
|
||||
protected:
|
||||
InterFace *if_;
|
||||
Codec *codec_;
|
||||
QList<HandleSlave *> slaves;
|
||||
};
|
||||
|
||||
prot_slave *protSlave();
|
||||
|
||||
|
||||
|
||||
#endif // PROT_SLAVE_H
|
||||
|
Reference in New Issue
Block a user