添加自研批检仪检测命令

This commit is contained in:
ranchuan
2023-11-27 14:31:00 +08:00
parent b3a0d7b57c
commit a0b0f41c39
45 changed files with 3778 additions and 2628 deletions

View File

@@ -3,19 +3,18 @@
#include "prot_pc.h"
#include "QDebug"
HandlePc *handlePcFind(int cmd)
{
extern const int __start_protpc;
extern const int __stop_protpc;
handlepc_def *start=(handlepc_def *)&__start_protpc;
handlepc_def *end=(handlepc_def *)&__stop_protpc;
extern const int __start_protpc;
extern const int __stop_protpc;
handlepc_def *start = (handlepc_def *)&__start_protpc;
handlepc_def *end = (handlepc_def *)&__stop_protpc;
handlepc_def *item = 0;
for (item=start;item<end;item++)
for (item = start; item < end; item++)
{
if (item != nullptr)
{
if (item->cmd==cmd)
if (item->cmd == cmd)
return item->handle_get_fun();
}
}
@@ -23,57 +22,53 @@ HandlePc *handlePcFind(int cmd)
return nullptr;
}
protpc_export(0xff,nullptr);
void ProtPc::init()
{
if_=interFaceFind("tcp");
codec_=codecFind("codec_ym");
if_ = interFaceFind("tcp");
codec_ = codecFind("codec_ym");
if_->set_irq([=](myarray recv){
recv_data+=recv;
if(codec_->packCheck(recv_data)==true){
int cmd,src,dst;
myarray data=codec_->decode(src,dst,cmd,recv_data);
if(handle_!=nullptr){
if(handle_->busy==0){
disconnect(handle_,&HandlePc::send_data_signal,this,send_data_slot);
delete handle_;
}else{
qWarning("prot_pc is busy.");
return;
}
}
handle_=handlePcFind(cmd);
if(handle_!=nullptr){
connect(handle_,&HandlePc::send_data_signal,this,send_data_slot);
handle_->dolater(cmd,data);
}
recv_data.clear();
}
if_->set_irq([=](myarray recv)
{
recv_data+=recv;
if(codec_->packCheck(recv_data)==true){
int cmd,src,dst;
myarray data=codec_->decode(src,dst,cmd,recv_data);
if(handle_!=nullptr){
if(handle_->busy==0){
disconnect(handle_,&HandlePc::send_data_signal,this,&ProtPc::send_data_slot);
delete handle_;
}else{
qWarning("prot_pc is busy.");
return;
}
}
handle_=handlePcFind(cmd);
if(handle_!=nullptr){
connect(handle_,&HandlePc::send_data_signal,this,&ProtPc::send_data_slot);
handle_->dolater(cmd,data);
}
recv_data.clear();
}
});
}
void ProtPc::send_data_slot(int cmd,myarray data)
void ProtPc::send_data_slot(int cmd, myarray data)
{
if((if_!=nullptr)&&(codec_!=nullptr)){
myarray send=codec_->encode(0,0,cmd,data);
if_->write(send);
}
if ((if_ != nullptr) && (codec_ != nullptr))
{
myarray send = codec_->encode(0, 0, cmd, data);
if_->write(send);
}
}
static ProtPc *g_protpc;
ProtPc *protPc(){
if(g_protpc==nullptr){
g_protpc=new ProtPc();
g_protpc->init();
}
return g_protpc;
ProtPc *protPc()
{
if (g_protpc == nullptr)
{
g_protpc = new ProtPc();
g_protpc->init();
}
return g_protpc;
}