#include "FuncTest.h" void FuncTest::PushMsg(WRITETYPE dataType, const string& nameKey, const std::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 FuncTest::PushMsg(const WriteData& wd) { if (m_streamClient) { m_streamClient->PushMsg(wd); } } void FuncTest::AllTest() { AxisMoveTest(); ScanCtrlTest(); RegistrationTest(); CameraTest(); PurifierTest(); ConfigTest(); DirectoryTest(); } //轴运动测试 void FuncTest::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 FuncTest::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 FuncTest::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()) { 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()) { 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()) { resp.data().UnpackTo(&result); printf("CHECKREGKEY resp:%d\n", result.data()); } } void FuncTest::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()) { 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()) { 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 FuncTest::PurifierTest() { PushMsg(PURIFIERFUNC, to_string(STARTAUTODEOXYGEN)); printf("STARTAUTODEOXYGEN is called...\n"); PushMsg(PURIFIERFUNC, to_string(STOPAUTODEOXYGEN)); printf("STOPAUTODEOXYGEN is called...\n"); } void FuncTest::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()) { 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"); } void FuncTest::DirectoryTest() { ::stream::ResponseAny resp; stream::ComResponce result; WriteData wdata{ DIRCTROYFUNC ,to_string(GetLogicalDrive) }; m_streamClient->Request(wdata, &resp); if (resp.data().Is()) { resp.data().UnpackTo(&result); printf("GetLogicalDrive resp:%s\n", result.data().data()); } Sleep(100); wdata = WriteData{ DIRCTROYFUNC ,to_string(ScanDir),"C://" }; m_streamClient->Request(wdata, &resp); if (resp.data().Is()) { resp.data().UnpackTo(&result); printf("ScanDir directory:%s\n", result.directory().data()); for (auto& it : result.fileinfo()) { printf("ScanDir fileinfo type:%s,filename:%s,filepath:%s,ext:%s\n" , it.type().data(), it.filename().data(), it.filepath().data(), it.ext().data()); } printf("size:%d\n",result.fileinfo_size()); } }