添加配置相关功能

This commit is contained in:
wangxx1809 2024-06-05 23:59:04 +08:00
parent 2cf690e6e7
commit 6c05b26c5b
10 changed files with 104 additions and 15 deletions

View File

@ -529,6 +529,10 @@ void ConfigManager::CallFuncs(const ReadData& rd, const list<Item>& lst, ::strea
RedTestCfgStart(); break;
case REDTESTCFGSTOP:
RedTestCfgStop(); break;
//case FIXPOINTDAOADD:
// FixPointDaoAdd(lst); break;
//case FIXPOINTDAODEL:
// FixPointDaoDel(lst); break;
default:
break;
}
@ -536,6 +540,26 @@ void ConfigManager::CallFuncs(const ReadData& rd, const list<Item>& lst, ::strea
}
//void ConfigManager::FixPointDaoAdd(const list<Item>& lst) {
// int scannerIndex = -1;
// FixPointCfg* fpc = new FixPointCfg();
// for (auto it = lst.begin(); it != lst.end(); ++it) {
// if (it->nameKey == "index") scannerIndex = ConverType::TryToI(it->strValue);
// if (it->nameKey == "cno") fpc->m_Cno = ConverType::TryToI(it->strValue);
// if (it->nameKey == "pointX") fpc->m_PointX = ConverType::TryToF(it->strValue);
// if (it->nameKey == "pointY") fpc->m_PointY = ConverType::TryToF(it->strValue);
// if (it->nameKey == "duration") fpc->m_Duration = (unsigned int)ConverType::TryToI(it->strValue);
// }
//
// //if (GetFixPointDao()->Add(fpc)){
// // (*m_UIController.m_ScannerCtrl->GetScanners())[scannerIndex]->GetConfig()->m_FixPointWrapper.m_Cfgs->push_back(fpc);
// //}
//}
//
//void ConfigManager::FixPointDaoDel(const list<Item>& lst) {
//
//}
void ConfigManager::UpdateCfg(const ReadData& rd) {
switch (rd.dataType)

View File

@ -47,6 +47,9 @@ enum ConfigFunc{
REDTESTCFGSTART, //红光测试配置开始
REDTESTCFGSTOP, //红光测试配置结束
//FIXPOINTDAOADD, //FixPointDao add
//FIXPOINTDAODEL, //FixPointDao del
};
@ -111,7 +114,7 @@ public:
//vector<LaserCfg*> *GetMatchLaser() { return &m_pLaserCfgDao->m_MatchLaser; }
//LaserCfgDao* GetLaserCfgDao() { return m_pLaserCfgDao; }
FavoriteCfg* GetFavoriteCfg() { return &m_FavoriteCfg; } //已传
FixPointDao* GetFixPointDao() { return m_ScannerControlCfgDao->GetFixPointDao(); } //
FixPointDao* GetFixPointDao() { return m_ScannerControlCfgDao->GetFixPointDao(); } // 查看FIXPOINTDAOADD和FIXPOINTDAODEL
CameraCalibrationCfg* GetCameraCalibrationCfg() { return &m_CameraCalibrationCfg; } //已传
void SaveCameraCalibrationCfg() { //不传
SQLite::Transaction transaction(*m_pDB);

View File

@ -5,7 +5,9 @@
void DataHandle::DataCallBackProc(void* pthis, const ReadData& msg, const std::list<Item>& its) {
DataHandle* p = (DataHandle*)pthis;
p->DataCallBackHandle(msg,its);
ReadData rd = msg;
std::list<Item> lst = its;
p->DataCallBackHandle(rd, lst);
}
void DataHandle::LayersDataCallBackProc(void* pthis,const ReadData& msg, const list<Item>& lst, ::stream::ResponseAny** response) {
@ -119,9 +121,8 @@ void DataHandle::DataCallBackHandle(const ReadData& msg, const std::list<Item>&
ConfigManager::GetInstance()->UpdateCfg(msg);
break;
case REQUEST:
if (!msg.nameKey.empty() && ConverType::TryToI( msg.nameKey) == XYSCANSTATE) {
//printf("error,XYSCANSTATE 需要释放ScannerCtrl::Init()内部代码块...\n");
for (int i = 0; i < 4; ++i) { //需要先打开ScannerCtrl::Init()代码块
if (!msg.nameKey.empty() && ConverType::TryToI( msg.nameKey) == XYSCANSTATE) { //g_isDebug 设置为 true;
for (int i = 0; i < (int)m_controller->m_ScannerCtrl->GetScanners()->size(); ++i) { //需要先打开ScannerCtrl::Init()代码块
Scanner* p = (m_controller->m_ScannerCtrl->GetScanners())->at(i);
p->GetScanStateXY().SendToClients(XYSCANSTATE, "_" + to_string(i));
}
@ -131,9 +132,6 @@ void DataHandle::DataCallBackHandle(const ReadData& msg, const std::list<Item>&
}
break;
default: break;
}
}

View File

@ -67,8 +67,8 @@ Status StreamServer::AllStream(ServerContext* context, grpc::ServerReaderWriter<
paramLst.emplace_back(Item{ it.namekey(),it.strvalue() ,(DATATYPE)it.valuetype() }); //直接加到readData.its上面后续的请求无法收到不知道为啥
}
printf("客户端消息dataType:%d,nameKey:%s, strValue:%s,valueType:%d\n",
readData.dataType, readData.nameKey.c_str(), readData.strValue.c_str(), readData.valueType);
printf("客户端消息dataType:%d,nameKey:%s, strValue:%s,valueType:%d,lst:%zd\n",
readData.dataType, readData.nameKey.c_str(), readData.strValue.c_str(), readData.valueType, paramLst.size());
if (m_dataCallBack) {
m_dataCallBack(m_handlePtr,readData, paramLst);
}

View File

@ -133,10 +133,8 @@ bool ScannerCtrl::Init() {
}
Scanner* scanner = NULL;
scanner = new RTC5Scanner(cfg,index++);
if (scanner->Init())
{
ConfigManager::GetInstance()->GetMatchScannerControlCfg()->push_back(cfg);
@ -1950,14 +1948,58 @@ void ScannerCtrl::CallFunc(const ReadData& rd, const list<Item>& lst) {
}
m_scan[index]->SetXYCorrect(x,y);
}
if (SETK == func) {
else if (SETK == func) {
double k = 0.0;
for (auto item = lst.begin(); item != lst.end(); ++item) {
if (item->nameKey == "k") k = ConverType::TryToD(item->strValue);
}
m_scan[index]->SetK(k);
}
else if (FIXPOINTDAOADD == func) {
FixPointDaoAdd(lst,index);
}
else if (FIXPOINTDAODEL == func) {
FixPointDaoDel(lst,index);
}
}
void ScannerCtrl::FixPointDaoAdd(const list<Item>& lst,int index) {
FixPointCfg* fpc = new FixPointCfg();
for (auto it = lst.begin(); it != lst.end(); ++it) {
if (it->nameKey == "cno") fpc->m_Cno = ConverType::TryToI(it->strValue);
if (it->nameKey == "pointX") fpc->m_PointX = ConverType::TryToF(it->strValue);
if (it->nameKey == "pointY") fpc->m_PointY = ConverType::TryToF(it->strValue);
if (it->nameKey == "duration") fpc->m_Duration = (unsigned int)ConverType::TryToI(it->strValue);
}
if (ConfigManager::GetInstance()->GetFixPointDao()->Add(fpc)) {
m_scan[index]->GetConfig()->m_FixPointWrapper.m_Cfgs.push_back(fpc);
}
}
void ScannerCtrl::FixPointDaoDel(const list<Item>& lst, int index) {
int id = 0;
for (auto it = lst.begin(); it != lst.end(); ++it) {
if (it->nameKey == "id") id = ConverType::TryToI(it->strValue);
}
list<FixPointCfg*> fpcs = m_scan[index]->GetConfig()->m_FixPointWrapper.m_Cfgs;
for (list<FixPointCfg*>::iterator fpit = fpcs.begin(); fpit != fpcs.end();) {
FixPointCfg* fpc = (*fpit);
if (fpc->m_Id == id){
if (ConfigManager::GetInstance()->GetFixPointDao()->Del(fpc)){
fpit = fpcs.erase(fpit);
delete fpc;
fpc = NULL;
}
break;
}
else {
fpit++;
}
}
}
void ScannerCtrl::SendToClients() {

View File

@ -37,6 +37,8 @@ enum FUNCNAME {
UPDATESKYWRITING,
SETXYCORRECT,
SETK,
FIXPOINTDAOADD,
FIXPOINTDAODEL,
};
@ -120,6 +122,9 @@ private:
void DispatchTestDataBlock();
void DispatchModelDataBlock(int partId, string scanType, float power, float speed);
void FixPointDaoAdd(const list<Item>& lst, int index);
void FixPointDaoDel(const list<Item>& lst, int index);
public:
string m_PauseMsg;
string m_StopMsg;

Binary file not shown.

Binary file not shown.

View File

@ -346,7 +346,8 @@ void DataHandle::ScanCtrlTest() {
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");
@ -354,32 +355,46 @@ void DataHandle::ScanCtrlTest() {
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");
}

View File

@ -61,6 +61,8 @@ enum ScanCtrlFunc {
UPDATESKYWRITING,
SETXYCORRECT,
SETK,
FIXPOINTDAOADD,
FIXPOINTDAODEL,
END1 //结束标记
};