620 lines
22 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "DataHandle.h"
#include "FunC.h"
#include "../utils/ConverType.h"
#include "../utils/StringHelper.h"
#define DELP(p) if(p){delete p; p = nullptr;}
#define COLOR_RESET "\033[0m" // 假设你的系统支持ANSI颜色代码
#define COLOR_GREEN "\033[32m"
#define COLOR_YELLOW "\033[33m"
void DataHandle::DataCallBackProc(void* pthis, const ReadData& msg) {
DataHandle* p = (DataHandle*)pthis;
ReadData readData = msg;
p->DataCallBackHandle(readData);
}
DataHandle::DataHandle()
: m_dataCallBack(nullptr)
, m_streamClient(nullptr)
, m_printIndex(-1){
m_dataTypeMp[iBOOL] = "iBOOL";
m_dataTypeMp[iSHORT] = "iSHORT";
m_dataTypeMp[iUSHORT] = "iUSHORT";
m_dataTypeMp[iINT] = "iINT";
m_dataTypeMp[iUINT] = "iUINT";
m_dataTypeMp[iFLOAT] = "iFLOAT";
m_dataTypeMp[iSTRING] = "iSTRING";
m_dataTypeMp[iCHAR] = "iCHAR";
m_dataTypeMp[iUCHAR] = "iUCHAR";
m_dataTypeMp[iWORD] = "iWORD";
m_dataTypeMp[iDOUBLE] = "iDOUBLE";
m_dataTypeMp[iTIMET] = "iTIMET";
m_dataTypeMp[UNKNOW] = "UNKNOW";
}
DataHandle::~DataHandle() {
DELP(m_streamClient);
}
void DataHandle::Init() {
m_streamClient = new StreamClient();
m_streamClient->SetCallBackFunc(this,&DataHandle::DataCallBackProc);
m_streamClient->Init();
//stream::ResponseInfo* response = new stream::ResponseInfo(); //获取一层图层的数据
//m_streamClient->GetLayerByIndex(1, response);
}
void DataHandle::Stop() {
m_streamClient->Stop();
DELP(m_streamClient);
}
void DataHandle::PushMsg(WRITETYPE dataType, const string& nameKey, const string& strValue, DATATYPE valueType, DATAHANDLE handleType) {
if (m_streamClient) {
WriteData msg;
msg.dataType = dataType;
msg.nameKey = nameKey;
msg.strValue = strValue;
msg.valueType = valueType;
msg.handleType = handleType;
m_streamClient->PushMsg(msg);
}
}
void DataHandle::PushMsg(const WriteData& wd) {
if (m_streamClient) {
m_streamClient->PushMsg(wd);
}
}
void DataHandle::PrintValue(const ReadData& msg){
if (m_printIndex != msg.dataType) return;
auto it = msg.its.begin();
while (it != msg.its.end()) {
it->nameKey;
string valueType = m_dataTypeMp[(*it).valueType];
if (msg.dataType >= STOPALARMCFGPARAM && msg.dataType <= WARNALARMCFGPARAM) {
printf("接收:dataType:%d,nameKey:%*s, content:%s,isEnable:%d,isAlarm:%d,isShow:%d\n",
msg.dataType, 33, it->nameKey.data(), it->content.c_str(), it->isEnable, it->isAlarm, it->isShow);
}
else if (msg.dataType == POWDERSETPARAM) {
printf("接收:dataType:%d,startLayer:%d,endLayer:%d,powder:%.2f\n",
msg.dataType,it->start_layer, it->end_layer, it->powder);
}
else {
printf("接收:dataType:%d,nameKey:%*s, strvalue:%*s, valueType:%s\n",
msg.dataType, 33, it->nameKey.data(), 13, it->strValue.data(), valueType.data());
}
++it;
}
printf("共有参数%zd个...\n", msg.its.size());
if(m_printIndex == LASERPARAM || m_printIndex == XYSCANSTATE){
static int count = 0;
++count;
if (count == 4) { count = 0; m_printIndex = -1; } //激光参数默认4个
}
else if (m_printIndex == COMMUNICATIONCFGPARAM) {
static int count = 0;
++count;
if (count == 23) { count = 0; m_printIndex = -1; } //激光参数默认4个
}
else {
m_printIndex = -1;
}
}
void DataHandle::DataCallBackHandle(const ReadData& msg) {
if (msg.dataType == VERSIONRSP) {
if (m_printIndex != VERSIONRSP) return;
m_version = msg.its.front().strValue;
printf("版本:%s\n", m_version.data());
m_printIndex = -1;
}
else {
PrintValue(msg);
}
}
void DataHandle::Usage() {
printf(COLOR_GREEN "print TestClient usage:\n" COLOR_RESET);
printf(" 0: " COLOR_YELLOW "print help information...\n" COLOR_RESET);
printf(" 1: " COLOR_YELLOW "exit program...\n" COLOR_RESET);
printf(" 2: " COLOR_YELLOW "test all...\n" COLOR_RESET);
printf(" 3: " COLOR_YELLOW "test axis move interface...\n" COLOR_RESET);
printf(" 4: " COLOR_YELLOW "test scan control interface...\n" COLOR_RESET);
printf(" 5: " COLOR_YELLOW "test registration interface...\n" COLOR_RESET);
printf(" 6: " COLOR_YELLOW "test camera interface...\n" COLOR_RESET);
printf(" 7: " COLOR_YELLOW "test purifier interface...\n" COLOR_RESET);
printf(" 8: " COLOR_YELLOW "test config interface...\n" COLOR_RESET);
printf(" 100: " COLOR_YELLOW "start test recv param interface...\n" COLOR_RESET);
}
void DataHandle::ParamReadUsage() {
printf(COLOR_GREEN "print param usage:\n" COLOR_RESET);
printf(" h: " COLOR_YELLOW "print this information...\n" COLOR_RESET);
printf(" q: " COLOR_YELLOW "return to the previous level...\n" COLOR_RESET);
printf(" 0: " COLOR_YELLOW "print alarm param...\n" COLOR_RESET);
printf(" 1: " COLOR_YELLOW "print version rsp...\n" COLOR_RESET);
printf(" 2: " COLOR_YELLOW "print io signal rsp...\n" COLOR_RESET);
printf(" 3: " COLOR_YELLOW "print system param data...\n" COLOR_RESET);
printf(" 4: " COLOR_YELLOW "print laserchiller data...\n" COLOR_RESET);
printf(" 5: " COLOR_YELLOW "print ups param data...\n" COLOR_RESET);
printf(" 6: " COLOR_YELLOW "print temp ctrl param data...\n" COLOR_RESET);
printf(" 7: " COLOR_YELLOW "print oxygenparam data...\n" COLOR_RESET);
printf(" 8: " COLOR_YELLOW "print laser param data...\n" COLOR_RESET);
printf(" 9: " COLOR_YELLOW "print simplesupplyparam_v10 data...\n" COLOR_RESET);
printf(" 10: " COLOR_YELLOW "print SIMPLESUPPLYPARAM_V21 data...\n" COLOR_RESET);
printf(" 11: " COLOR_YELLOW "print SIMPLESUPPLYPARAM_V22 data...\n" COLOR_RESET);
printf(" 12: " COLOR_YELLOW "print purifier param data...\n" COLOR_RESET);
printf(" 13: " COLOR_YELLOW "print power meter param data...\n" COLOR_RESET);
printf(" 14: " COLOR_YELLOW "print powder supply simple param data...\n" COLOR_RESET);
printf(" 15: " COLOR_YELLOW "print scanner power param data...\n" COLOR_RESET);
printf(" 16: " COLOR_YELLOW "print axismold data...\n" COLOR_RESET);
printf(" 17: " COLOR_YELLOW "print axismold slave data...\n" COLOR_RESET);
printf(" 18: " COLOR_YELLOW "print axisclean data...\n" COLOR_RESET);
printf(" 19: " COLOR_YELLOW "print axisclean slave data...\n" COLOR_RESET);
printf(" 20: " COLOR_YELLOW "print axisload data...\n" COLOR_RESET);
printf(" 21: " COLOR_YELLOW "print axismarm data...\n" COLOR_RESET);
printf(" 22: " COLOR_YELLOW "print axismsupply data...\n" COLOR_RESET);
printf(" 23: " COLOR_YELLOW "print axisele data...\n" COLOR_RESET);
printf(" 24: " COLOR_YELLOW "print axisele slave data...\n" COLOR_RESET);
printf(" 25: " COLOR_YELLOW "print paramlimitcfg param data...\n" COLOR_RESET);
printf(" 26: " COLOR_YELLOW "print extcfg param data...\n" COLOR_RESET);
printf(" 27: " COLOR_YELLOW "print runcfg param data...\n" COLOR_RESET);
printf(" 28: " COLOR_YELLOW "print infraredtemp cfg param data...\n" COLOR_RESET);
printf(" 29: " COLOR_YELLOW "print machine cfg param data...\n" COLOR_RESET);
printf(" 30: " COLOR_YELLOW "print favorite cfg param data...\n" COLOR_RESET);
printf(" 31: " COLOR_YELLOW "print cameracalibration cfg param data...\n" COLOR_RESET);
printf(" 32: " COLOR_YELLOW "print uishow cfg param data...\n" COLOR_RESET);
printf(" 33: " COLOR_YELLOW "print recoatcheck cfg param data...\n" COLOR_RESET);
printf(" 34: " COLOR_YELLOW "print powderestimate cfg param data...\n" COLOR_RESET);
printf(" 35: " COLOR_YELLOW "print communication cfg param data...\n" COLOR_RESET);
printf(" 36: " COLOR_YELLOW "print stopalarm cfg param data...\n" COLOR_RESET);
printf(" 37: " COLOR_YELLOW "print pausealarm cfg param data...\n" COLOR_RESET);
printf(" 38: " COLOR_YELLOW "print warnalarm cfg param data...\n" COLOR_RESET);
printf(" 39: " COLOR_YELLOW "print powder cfg param data...\n" COLOR_RESET);
printf(" 40: " COLOR_YELLOW "print powder cfg param data...\n" COLOR_RESET);
printf(" 41: " COLOR_YELLOW "print scaner ctrl cfg param data...\n" COLOR_RESET);
printf(" 42: " COLOR_YELLOW "print moldcfg param data...\n" COLOR_RESET);
printf(" 43: " COLOR_YELLOW "print loadcfg param data...\n" COLOR_RESET);
printf(" 44: " COLOR_YELLOW "print armcfgparam data...\n" COLOR_RESET);
printf(" 45: " COLOR_YELLOW "print supplycfgparam data...\n" COLOR_RESET);
printf(" 46: " COLOR_YELLOW "print cleancfgparam data...\n" COLOR_RESET);
printf(" 47: " COLOR_YELLOW "print elecfgparam data...\n" COLOR_RESET);
printf(" 48: " COLOR_YELLOW "print loadparamrsp data...\n" COLOR_RESET);
printf(" 49: " COLOR_YELLOW "print scan ctrl state data...\n" COLOR_RESET);
printf(" 50: " COLOR_YELLOW "print scan ctrl Param data...\n" COLOR_RESET);
printf(" 51: " COLOR_YELLOW "print xy scan state data...\n" COLOR_RESET);
printf(" 52: " COLOR_YELLOW "print camera param data...\n" COLOR_RESET);
}
int DataHandle::Request(int index) {
int result = 0;
string userInput;
switch (index) {
case 0:
Usage(); break;
case 1:
Stop(); break;
case 2:
AllTest(); break;
case 3:
AxisMoveTest(); break;
case 4:
ScanCtrlTest(); break;
case 5:
RegistrationTest(); break;
case 6:
CameraTest(); break;
case 7:
PurifierTest(); break;
case 8:
ConfigTest(); break;
case 100:
ParamReadUsage();
while (printf("*请输入命令:") && std::getline(std::cin, userInput)) {
if (userInput == "q") {
printf("返回上一级...\n"); break;
}
else if (userInput.empty()) {
continue;
}
else if (userInput == "h") { //打印用法
ParamReadUsage();
}
else if (userInput.find("push") != string::npos) { //更新数据到服务器
UpdateParamToService(userInput);
}
else { //接收指定的参数
ReceiveParam(ConverType::TryToI(userInput));
}
}
break;
default:
result = -1;
break;
}
return result;
}
void DataHandle::AllTest() {
AxisMoveTest();
ScanCtrlTest();
RegistrationTest();
CameraTest();
PurifierTest();
ConfigTest();
}
void DataHandle::ReceiveParam(int index) {
if (index == VERSIONRSP) {
PushMsg(VERSIONREQ); //获取版本信息
}
if (index == SCANERCTRLCFGPARAM) {
::stream::ResponseAny resp;
stream::ScannerCrtlCfgResp result;
WriteData wdata{ SCANERCTRLCFG };
m_streamClient->Request(wdata, &resp);
if (resp.data().Is<stream::ScannerCrtlCfgResp>()) {
resp.data().UnpackTo(&result);
PrintScanerCfg(result);
}
index = -1;
}
else if (index >= PARAMLIMITCFGPARAM && index <= ELECFGPARAM) {
PushMsg(REQUEST);
}
else if(index == LOADPARAMRSP){
PushMsg(LOADPARAM);
}
else if (index == XYSCANSTATE) {
PushMsg(REQUEST,to_string(index));
}
m_printIndex = index;
while (m_printIndex >= 0) {
Sleep(20);
static int count = 0;
++count;
if (count == 50 && m_printIndex >= 0) { //等待1s没用收到消息判断为服务器没用发送
count = 0;
printf("服务器没有发送此参数...\n");
break;
}
}
}
void DataHandle::PrintScanerCfg(const stream::ScannerCrtlCfgResp& result) {
result.scannercfg().size();
for (auto& rsp : result.scannercfg()) {
printf("seqNo:%d\n",rsp.seqno());
printf("controlno:%d,serialno:%d,controlType:%d,cardname:%s,cardip:%s,isenable:%d,hadassign:%d,hadmatch:%d\n",
rsp.controlno(), rsp.serialno(), rsp.controltype(), rsp.cardname().data(), rsp.cardip().data(), rsp.isenable(), rsp.hadassign(), rsp.hadmatch());
for (auto& fp : rsp.fixpointdata()) {
printf("(pixpoint)id:%d,cno:%d,pointx:%f,pointy:%f,duration:%d\n"
, fp.id(), fp.cno(), fp.pointx(), fp.pointy(), fp.duration());
}
//打印部分内容
auto& spc = rsp.scanparamcfg();
printf("(scanparamcfg)edgelevel:%d,edgelevelmin:%d,edgelevelmax:%d,jumpDelay:%u\n",
spc.edgelevel(), spc.edgelevelmin(), spc.edgelevelmax(), spc.jumpdelay());
auto& hp = rsp.hatchingparams();
printf("(hatchingparams)edgelevel:%d,edgelevelmin:%d,edgelevelmax:%d,jumpDelay:%u\n",
hp.edgelevel(), hp.edgelevelmin(), hp.edgelevelmax(), hp.jumpdelay());
auto& bp = rsp.borderparams();
printf("(borderParams)edgelevel:%d,edgelevelmin:%d,edgelevelmax:%d,jumpDelay:%u\n",
hp.edgelevel(), hp.edgelevelmin(), hp.edgelevelmax(), hp.jumpdelay());
auto& sp = rsp.supportparams();
printf("(supportparams)edgelevel:%d,edgelevelmin:%d,edgelevelmax:%d,jumpDelay:%u\n",
sp.edgelevel(), sp.edgelevelmin(), sp.edgelevelmax(), sp.jumpdelay());
auto& cpc = rsp.correctparamcfg();
printf("(correctparamcfg)xmeasuremin:%.3f,xmeasuremax:%.3f,ymeasuremin:%.3f,ymeasuremax:%.3f\n",
cpc.xmeasuremin(), cpc.xmeasuremax(), cpc.ymeasuremin(), cpc.ymeasuremax());
auto& stc = rsp.scantestcfg();
printf("(scantestcfg)debugshape:%d,shapesize:%d,shapesizemin:%d,shape_size_max:%d\n",
stc.debugshape(), stc.shapesize(), stc.shapesizemin(), stc.shape_size_max());
auto& swc = rsp.skywritingcfg();
printf("(skywritingcfg)debugshape:%d,shapesize:%.3f,shapesizemin:%.3f,shape_size_max:%.3f\n",
swc.isenable(), swc.timelag(), swc.timelagmin(), swc.timelagmax());
for (auto& pc : rsp.powercompensate()) {
printf("(powercompensate)cno:%d,percent:%d,value:%.3f,value_min:%.3f,value_max:%.3f\n",
pc.cno(), pc.percent(), pc.value(), pc.value_min(),pc.value_max());
}
for (auto& tpc : rsp.tpowercompensate()) {
printf("(tpowercompensate)cno:%d,id:%d,value:%u,value_min:%u,value_max:%.3f\n",
tpc.cno(), tpc.id(), tpc.startminute(), tpc.endminute(), tpc.compensate());
}
}
}
//选择一个参数更新到服务
void DataHandle::UpdateParamToService(const string& input) {
WriteData writeData;
int index = ConverType::TryToI(input.substr(5));
switch (index) {
case PARAMLIMITCFGPARAM:
break;
case EXTCFGPARAM: break;
case RUNCFGPARAM:
PushMsg(RUNCFG, "FanFreqLowLimit", to_string(11), iFLOAT);//runcfg test
break;
case INFRAREDTEMPCFGPARAM:
PushMsg(INFRAREDTEMPCFG, "ReflectTempAssist", to_string(11), iFLOAT); //infraredtempcfg test
break;
case MACHINECFGPARAM:
PushMsg(MACHINECFG, "lastStartTime", to_string(time(nullptr)), iTIMET); //machinecfg test
break;
case FAVORITECFGPARAM:
PushMsg(FAVORITECFG, "lastStartTime", to_string(time(nullptr)), iSTRING,ADD); //FavoriteCfg test
break;
case CAMERACALIBRATIONCFGPARAM:
PushMsg(CAMERACALIBRATIONCFG, "ShowCorners", to_string(true), iBOOL); //CameracalibrationCfg test
break;
case UISHOWCFGPARAM:
PushMsg(UISHOWCFG, "ItemInnerSpacingHeight", to_string(125.0f), iFLOAT); //UIshowCfg test
break;
case RECOATCHECKCFGPARAM:
PushMsg(RECOATCHECKCFG, "UncoverPercentage", to_string(125.0f), iFLOAT); //RecoatcheckCfg test
break;
case POWDERESTIMATECFGPARAM:
PushMsg(POWDERESTIMATECFG, "TotalGrids", to_string(4201), iUINT); //PowderestimateCfg test
break;
case COMMUNICATIONCFGPARAM:
PushMsg(COMMUNICATIONCFG, "Type_XT_PURIFIER", to_string(4), iINT); //CommunicationCfg test
break;
case STOPALARMCFGPARAM: //AlarmCfgWrapper stop参数
PushMsg(ALARMCFG, "WindOverLimitAlarm", to_string(0), iINT);
break;
case PAUSEALARMCFGPARAM: //AlarmCfgWrapper pause参数
PushMsg(ALARMCFG, "HeatingDisconnectAlarm", to_string(0), iINT);
break;
case WARNALARMCFGPARAM: //AlarmCfgWrapper warn参数
PushMsg(ALARMCFG, "SupplyPipeBlockWarn", to_string(0), iINT);
break;
case POWDERSETPARAM: //PowderSet参数
writeData = WriteData{ POWDERSET, "", "", UNKNOW,TOTAL };
writeData.items.emplace_back(Item{"","",UNKNOW,"",0,0,0,1,100,2});
PushMsg(writeData);
break;
case SCANERCTRLCFGPARAM:
writeData = WriteData{ SCANERCTRLCFG, "1", to_string(SCCFGP::CTRLCFG), UNKNOW,UPDATE };
writeData.items.emplace_back(Item{ "CardIP","127.0.0.1",iSTRING});
PushMsg(writeData);
writeData = WriteData{ SCANERCTRLCFG, "1",to_string(SCCFGP::POWERCOMPENSATECFG), UNKNOW,UPDATE };
writeData.items.emplace_back(Item{ "10","1.323",iFLOAT });
PushMsg(writeData);
break;
case ELECFGPARAM:
break;
case LOADPARAMRSP:
break;
case XYSCANSTATE:
break;
default:
break;
}
}
//轴运动测试
void DataHandle::AxisMoveTest() {
int count =(int)MACHINEFUNC::END0;
for (int i = 0; i < count; ++i) {
PushMsg(WRITETYPE::AXISMOVEFUNC,to_string(i));
printf("发送请求%d成功...\n", i);
Sleep(100);
}
}
//扫描控制测试
void DataHandle::ScanCtrlTest() {
PushMsg(SCANCTRLFUNC, to_string(BEGINWORK)); printf("call BEGINWORK function...\n");
PushMsg(SCANCTRLFUNC, to_string(PAUSEWORK)); printf("call PAUSEWORK function...\n");
PushMsg(SCANCTRLFUNC, to_string(PAUSEAUTO)); printf("call PAUSEAUTO function...\n");
PushMsg(SCANCTRLFUNC, to_string(STOPWORK)); printf("call STOPWORK function...\n");
PushMsg(SCANCTRLFUNC, to_string(STOPREDTEST)); printf("call STOPREDTEST function...\n");
PushMsg(SCANCTRLFUNC, to_string(TESTLAYER)); printf("call TESTLAYER function...\n");
PushMsg(SCANCTRLFUNC, to_string(REMOVESCANNER), to_string(1), iINT); printf("call REMOVESCANNER function...\n");
PushMsg(SCANCTRLFUNC, to_string(STARTHEATINGMOTION)); printf("call STARTHEATINGMOTION function...\n");
PushMsg(SCANCTRLFUNC, to_string(STOPHEATINGMOTION), to_string(0), iBOOL); printf("call STOPHEATINGMOTION function...\n");
PushMsg(SCANCTRLFUNC, to_string(STARTDEBUGTEST), "1", iINT); printf("call STARTDEBUGTEST function...\n");
PushMsg(SCANCTRLFUNC, to_string(STOPDEBUGTEST), "1", iINT); printf("call STOPDEBUGTEST function...\n");
PushMsg(SCANCTRLFUNC, to_string(STARTHEATINGSCANNERTEST), "1", iINT); printf("call STARTHEATINGSCANNERTEST function...\n");
PushMsg(SCANCTRLFUNC, to_string(STOPHEATINGSCANNERTEST), "1", iINT); printf("call STOPHEATINGSCANNERTEST function...\n");
PushMsg(SCANCTRLFUNC, to_string(STARTGETSCANINFO), "1", iINT); printf("call STARTGETSCANINFO function...\n");
PushMsg(SCANCTRLFUNC, to_string(STOPGETSCANINFO), "1", iINT); printf("call STOPGETSCANINFO function...\n");
WriteData wd{ SCANCTRLFUNC,to_string(SETXYOFFSET) ,"1", iINT };
wd.items.emplace_back(Item{"x", to_string(1.23f),iFLOAT});
wd.items.emplace_back(Item{"y", to_string(2.23f),iFLOAT});
PushMsg(wd); printf("call SETXYOFFSET function...\n");
wd.items.clear();
wd.nameKey = to_string(SETANGLE);
wd.items.emplace_back(Item{ "angle", to_string(1.2),iDOUBLE });
PushMsg(wd); printf("call SETANGLE function...\n");
PushMsg(SCANCTRLFUNC, to_string(UPDATESETTING), "1", iINT); printf("call UPDATESETTING function...\n");
wd.items.clear();
wd.nameKey = to_string(UPDATESKYWRITING);
wd.items.emplace_back(Item{ "isList", to_string(true),iBOOL });
PushMsg(wd); printf("call UPDATESKYWRITING function...\n");
wd.items.clear();
wd.nameKey = to_string(SETXYCORRECT);
wd.items.emplace_back(Item{ "x", to_string(2.3),iDOUBLE });
wd.items.emplace_back(Item{ "y", to_string(3.4),iDOUBLE });
PushMsg(wd); printf("call SETXYCORRECT function...\n");
wd.items.clear();
wd.nameKey = to_string(SETK);
wd.items.emplace_back(Item{ "k", to_string(2.1),iDOUBLE });
PushMsg(wd); printf("call SETK function...\n");
wd.items.clear();
wd.nameKey = to_string(FIXPOINTDAOADD);
wd.items.emplace_back(Item{ "cno", to_string(2),iINT });
wd.items.emplace_back(Item{ "pointX", to_string(2.1),iFLOAT });
wd.items.emplace_back(Item{ "pointY", to_string(2.1),iFLOAT });
wd.items.emplace_back(Item{ "duration", to_string(5),iUINT });
PushMsg(wd); printf("call FIXPOINTDAOADD function...\n");
wd.items.clear();
wd.nameKey = to_string(FIXPOINTDAODEL);
wd.items.emplace_back(Item{ "id", to_string(2),iINT });
PushMsg(wd); printf("call FIXPOINTDAODEL function...\n");
}
void DataHandle::RegistrationTest(){
::stream::ResponseAny resp;
stream::RegResponce result;
WriteData wdata{ REGISTFUNC ,to_string(CHECKREG),to_string(time(nullptr)) ,iSTRING };
m_streamClient->Request(wdata,&resp);
if (resp.data().Is<stream::RegResponce>()) {
resp.data().UnpackTo(&result);
printf("CHECKREG resp:%d\n", result.data());
}
Sleep(100);
wdata.strValue = "123456789";
wdata.nameKey = to_string(GETSN);
m_streamClient->Request(wdata, &resp);
if (resp.data().Is<stream::RegResponce>()) {
resp.data().UnpackTo(&result);
printf("GETSN resp:%u\n", (unsigned int)result.data());
}
Sleep(100);
wdata.strValue = "regconfig";
wdata.nameKey = to_string(CHECKREGKEY);
m_streamClient->Request(wdata, &resp);
if (resp.data().Is<stream::RegResponce>()) {
resp.data().UnpackTo(&result);
printf("CHECKREGKEY resp:%d\n", result.data());
}
}
void DataHandle::CameraTest() {
int count = (int)CAMERAFUNC::END2;
for (int i = 0; i < count; ++i) {
if (i == GETSHOWIMAGE || i == GETSHOWIMAGES) continue;
if(i == SETDEMANDCATPURE) PushMsg(CAMERAFUNC, to_string(i),to_string(1),iBOOL);
else PushMsg(CAMERAFUNC, to_string(i));
printf("发送请求%d成功...\n", i);
Sleep(100);
}
::stream::ResponseAny resp;
stream::ImgInfoResponce result;
WriteData wdata{ CAMERAFUNC ,to_string(GETSHOWIMAGE)};
m_streamClient->Request(wdata, &resp);
if (resp.data().Is<stream::ImgInfoResponce>()) {
resp.data().UnpackTo(&result);
printf("GETSHOWIMAGE resp:%u\n", result.levelimage());
}
Sleep(100);
resp.Clear();
wdata.nameKey = to_string(GETSHOWIMAGES);
wdata.strValue = to_string(5); //测试值
wdata.valueType = iINT; //测试值
m_streamClient->Request(wdata, &resp);
if (resp.data().Is<stream::ImgInfoResponce>()) {
resp.data().UnpackTo(&result);
printf("GETSHOWIMAGES resp levelimg:%u,height:%d,width:%d\n", result.levelimage(),result.width(),result.height());
}
Sleep(100);
//修改参数
PushMsg(CAMERAPARAMUPDATE,"LastMouRefImgPosX", to_string(10),iINT);
PushMsg(CAMERAPARAMUPDATE,"LastMouRefImgPosY", to_string(100),iINT);
PushMsg(CAMERAPARAMUPDATE,"ShowFlag", to_string(1),iBOOL);
printf("CAMERAPARAMUPDATE update finish\n");
}
void DataHandle::PurifierTest() {
PushMsg(PURIFIERFUNC, to_string(STARTAUTODEOXYGEN));
printf("STARTAUTODEOXYGEN is called...\n");
PushMsg(PURIFIERFUNC, to_string(STOPAUTODEOXYGEN));
printf("STOPAUTODEOXYGEN is called...\n");
}
void DataHandle::ConfigTest() {
PushMsg(CONFIGFUNC, to_string(SAVECONFIG));
printf("saveconfig is called...\n");
PushMsg(CONFIGFUNC, to_string(SAVEMACHINECONFIG));
printf("savemachineconfig is called...\n");
PushMsg(CONFIGFUNC, to_string(DELETEMACHINEIO));
printf("deletemachineio is called...\n");
WriteData wd{ CONFIGFUNC, to_string(CONTROLRUN) };
wd.items.emplace_back(Item{ "enable", to_string(true) ,iBOOL });
wd.items.emplace_back(Item{ "code", "usp" ,iSTRING });
PushMsg(wd);
printf("controlrun is called...\n");
::stream::ResponseAny resp;
stream::ComResponce result;
WriteData wdata{ CONFIGFUNC ,to_string(IOVERSIONSTR) };
wdata.items.emplace_back(Item{"index","1",iINT});
m_streamClient->Request(wdata, &resp);
if (resp.data().Is<stream::ComResponce>()) {
resp.data().UnpackTo(&result);
printf("IOVERSIONSTR resp:%s\n", result.data().data());
}
PushMsg(CONFIGFUNC, to_string(REDTESTCFGSTART));
printf("redtestcfgstart is called...\n");
PushMsg(CONFIGFUNC, to_string(REDTESTCFGSTOP));
printf("redtestcfgstop is called...\n");
}