S9T9可能遇到 A模块. B模块 .C模块

来源:S9T9可能遇到 A模块. B模块 .C模块

在开发一个OA系统是,S9T9可能遇到 A模块. B模块 .C模块,这也模块组成一个完整的系统,买给客服。
现在又有一个客服要我们做一个OA系统,唉我们发现,S9T9跟上一个OA系统差不多,但没有C模块。怎么办?
修改源码,系统简单还好,但是一系统复杂到一定程度,修改源码改这改这就像重写了!
怎么办,MVC插件式开发帮你解决问题,先看演示,再看代码。

072005528656037.png

1 分钟前 上传
下载附件 (2.79 KB)



CCAV.WebSite 是主站,引用 CCAV.Modules.Category
CCAV.Modules.Category 就像当于一个模块,具体看演示。



072012202875496.png

1 分钟前 上传
下载附件 (58.21 KB)



通过主站可以访问到CCAV.Modules.Category 的控制器,如果 主站移除 对 CCAV.Modules.Category引用 将访问不到  CCAV.Modules.Category 你的控制器。
这样刚才的问题就解决了!



#include "pch.h" #include "LCMESClass.h" #include <QDateTime> #include <mmsystem.h> extern CGlobalFunction m_GFunction; // 全局函数 extern Loger m_Loger; // 全局Log类 extern CGlobalVariant m_GVariant; // 全局变量 extern CDlgDevError m_dlgError; // 错误信息对话框 extern CActionFlow m_GActionFlow; // 主动作流程 #pragma comment(lib, "winmm.lib") LCMESClass* LCMESClass::m_pInstance = nullptr; LCMESClass* LCMESClass::GetInstance() { static CCriticalSection cs; CriticalSectionLock lock(cs); // 使用我们之前定义的 RAII 锁 if (m_pInstance == nullptr) // 错误:m_pInstance 未声明 { m_pInstance = new LCMESClass(); } return m_pInstance; } LCMESClass::LCMESClass() { StartWorkerThread(); } LCMESClass::~LCMESClass() { StopWorkerThread(); StopTimer(); } void LCMESClass::StartWorkerThread() { if (m_pWorkerThread == nullptr) { m_pWorkerThread = AfxBeginThread(WorkerThreadProc, this); } } void LCMESClass::StopWorkerThread() { if (m_pWorkerThread != nullptr) { m_bStopThread = true; m_taskEvent.SetEvent(); // 唤醒线程退出 WaitForSingleObject(m_pWorkerThread->m_hThread, INFINITE); m_pWorkerThread = nullptr; } } void LCMESClass::PostTask(TaskType type, const CString& param) { TaskItem* pItem = new TaskItem(); pItem->type = type; pItem->param = param; { CriticalSectionLock lock(m_cs); // 使用自定义锁 m_taskList.AddTail(pItem); } m_taskEvent.SetEvent(); // 触发事件 } UINT LCMESClass::WorkerThreadProc(LPVOID pParam) { LCMESClass* pThis = (LCMESClass*)pParam; while (!pThis->m_bStopThread) { DWORD dwWait = WaitForSingleObject(pThis->m_taskEvent.m_hObject, INFINITE); if (dwWait != WAIT_OBJECT_0) continue; if (pThis->m_bStopThread) break; TaskItem* pItem = nullptr; { CriticalSectionLock lock(pThis->m_cs); // 使用自定义锁 if (!pThis->m_taskList.IsEmpty()) { pItem = pThis->m_taskList.RemoveHead(); } } if (pItem) { pThis->ProcessTask(pItem); delete pItem; } } return 0; } void LCMESClass::ProcessTask(TaskItem* pItem) { switch (pItem->type) { case TASK_PULLMES: ExecutePullMes(); break; case TASK_EVENT_PRODUCT_MOVED: ExecuteProductMoved(pItem->param); break; case TASK_EVENT_DEVICE_STATE_CHANGED: ExecuteDeviceStateChanged(_ttoi(pItem->param)); break; case TASK_EVENT_TEST_END: ExecuteTestEnd(); break; case TASK_UPLOAD_STATS: ExecuteUploadStats(); case TASK_ALARM_CLEAR: ExecuteAlarmClear(); break; } } void LCMESClass::ExecutePullMes() { CriticalSectionLock lock(m_cs); // 线程安全调用 this->PullMes(); } void LCMESClass::ExecuteProductMoved(const CString & position) { CriticalSectionLock lock(m_cs); // 线程安全调用 this->ProductMoved(m_GFunction.CString2String(position)); } void LCMESClass::ExecuteDeviceStateChanged(int state) { CriticalSectionLock lock(m_cs); // 线程安全调用 DeviceState deviceState = static_cast<DeviceState>(state); this->DeviceStateChanged(deviceState); } void LCMESClass::ExecuteTestEnd() { CriticalSectionLock lock(m_cs); // 线程安全调用 this->TestEnd(); } void LCMESClass::ExecuteUploadStats() { CriticalSectionLock lock(m_cs); // 发送统计数量总计和OK品数量 int okCount = m_GActionFlow.m_Statistics.m_lBest + m_GActionFlow.m_Statistics.m_lMed + m_GActionFlow.m_Statistics.m_lPass; this->SendCount(m_GActionFlow.m_Statistics.m_lTotal, okCount); } void LCMESClass::ExecuteAlarmClear() { CriticalSectionLock lock(m_cs); this->DeviceAlarmCleared(); } // 定时五分钟发送统计数量总计和OK品数量 void LCMESClass::StartTimer(UINT interval) { if (m_timerID == 0) { m_timerID = timeSetEvent( interval, 10, TimerProc, (DWORD_PTR)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); } } void LCMESClass::StopTimer() { // 停止定时器(需保存 timer ID) if (m_timerID != 0) { timeKillEvent(m_timerID); m_timerID = 0; } } void CALLBACK LCMESClass::TimerProc(UINT uID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) { LCMESClass* pThis = (LCMESClass*)dwUser; if (pThis) { pThis->PostTask(TASK_UPLOAD_STATS); } } // 产品check Response LCMESClass::EquipmentTextData_Check(string info) { std::lock_guard<std::mutex> lock(m_mutex); // 加锁,函数退出时自动解锁 // 原始配置 string hostname = m_GVariant.m_MesConfig->Host; int port = m_GVariant.m_MesConfig->Port; string api = m_GVariant.m_MesConfig->Check; Response resp = Send(info, hostname, port, api); if (SUCCESS == resp.Code) { return ParseRcv(resp.Msg); } return resp; } // 产品过站 Response LCMESClass::EquipmentTextData_Save(string info) { std::lock_guard<std::mutex> lock(m_mutex); // 加锁,函数退出时自动解锁 // 原始配置 string hostname = m_GVariant.m_MesConfig->Host; int port = m_GVariant.m_MesConfig->Port; string api = m_GVariant.m_MesConfig->Check; Response resp = Send(info, hostname, port, api); if (SUCCESS == resp.Code) { return ParseRcv(resp.Msg); } return resp; } // 产品生产过程事件、配方比对 Response LCMESClass::deviceInfoCollerct(string info) { std::lock_guard<std::mutex> lock(m_mutex); // 加锁,函数退出时自动解锁 // 原始配置 string hostname = m_GVariant.m_MesConfig->Host; int port = m_GVariant.m_MesConfig->Port; string api = m_GVariant.m_MesConfig->Check; Response resp = Send(info, hostname, port, api); if (SUCCESS == resp.Code) { return ParseRcv(resp.Msg); } return resp; } void LCMESClass::Connect() { std::lock_guard<std::mutex> lock(m_mutex); std::string hostname = m_GVariant.m_MesConfig->Host; int port = m_GVariant.m_MesConfig->Port; // 如果已有连接且目标主机和端口一致,直接复用 if (m_pConnection) { if (m_cachedHost == hostname && m_cachedPort == port) { return; // 已连接到目标主机,无需重复连接 } else { // 不同主机或端口,释放旧连接 delete m_pConnection; m_pConnection = nullptr; } } // 设置全局超时参数 HINTERNET hSession = (HINTERNET)m_Session; // ✅ 正确获取 HINTERNET 句柄 if (hSession) { DWORD connectTimeout = 5000; // 5 秒 DWORD sendTimeout = m_GVariant.m_MesConfig->SendTimeout; DWORD recvTimeout = m_GVariant.m_MesConfig->RecvTimeout; InternetSetOption(hSession, INTERNET_OPTION_CONNECT_TIMEOUT, &connectTimeout, sizeof(connectTimeout)); InternetSetOption(hSession, INTERNET_OPTION_SEND_TIMEOUT, &sendTimeout, sizeof(sendTimeout)); InternetSetOption(hSession, INTERNET_OPTION_RECEIVE_TIMEOUT, &recvTimeout, sizeof(recvTimeout)); } // 创建新连接 m_cachedHost = hostname; m_cachedPort = port; m_pConnection = m_Session.GetHttpConnection( m_GFunction.String2CString(hostname), port, _T(""), // username _T("") // password ); if (!m_pConnection) { // 连接失败,记录错误 CString logMessage; logMessage.Format(_T("连接到 %s:%d 失败,无法创建 HTTP 连接\n"), m_GFunction.String2CString(hostname), port); addInfo(m_GFunction.CString2String(logMessage)); } } Response LCMESClass::Send(const string & info, const string & hostname, const int & port, const string & apiPath) { Response resp; if (!m_pConnection) { resp.Code = NETWORK_ERROR; resp.Msg = "Not connected to server. Call Connect() first."; return resp; } try { auto deleter = [](CHttpFile* p) { if (p) delete p; }; std::unique_ptr<CHttpFile, decltype(deleter)> pFile( m_pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST, m_GFunction.String2CString(apiPath)), deleter); CString strHeaders = _T("Content-Type: application/json"); CString strData = m_GFunction.String2CString(info); pFile->SendRequest ( strHeaders, (DWORD)strHeaders.GetLength(), (LPVOID)(LPCTSTR)strData, (DWORD)strData.GetLength() ); DWORD dwStatusCode; pFile->QueryInfoStatusCode(dwStatusCode); CString strResponse; if (dwStatusCode == HTTP_STATUS_OK) { TCHAR szBuffer[1024]; while (pFile->Read(szBuffer, 1023) > 0) { strResponse += szBuffer; } } if (dwStatusCode != HTTP_STATUS_OK) { resp.Code = HTTP_ERROR; resp.Msg = std::to_string(dwStatusCode); return resp; } resp.Msg = m_GFunction.CString2String(strResponse); pFile->Close(); } catch (CInternetException* pEx) { TCHAR szError[1024]; pEx->GetErrorMessage(szError, 1024); resp.Msg = m_GFunction.CString2String(szError);// 异常信息写入resultMSG pEx->Delete(); resp.Code = NETWORK_ERROR; return resp; } resp.Code = SUCCESS; return resp; } Response LCMESClass::ParseRcv(string& msg) { json j = json::parse(msg); return Response::from_json(j); } int LCMESClass::FL_PullMes() { int iRtn = 0; switch (sSC_PullMes.nStep) { case 0: sSC_PullMes.nStep = 2; addInfo(sSC_PullMes, 2, "开始巡检MES目录", true); return 0; case 2: iRtn = checkFolder(); if (-1 == iRtn) { addInfo(sSC_PullMes, ST_ERR, "巡检MES目录失败"); } if (1 == iRtn) { sSC_PullMes.nStep = 5; //addInfo(sSC_PullMes, 5, "巡检MES目录缓存添加完成"); } else { sSC_PullMes.SetDelay(5, 1000); } return 0; case 5: if (m_File.checkFileExist(m_destinationFolder, m_currentFileNames)) { sSC_PullMes.nStep = 10; //addInfo(sSC_PullMes, 10, "检查所有文件都剪切完成;准备解析文件"); } else { sSC_PullMes.nStep = ST_ERR; } return 0; case 10: if (m_bufferFileNames.size() == 0) { sSC_PullMes.nStep = ST_END; //addInfo(sSC_PullMes, ST_END, "本次缓存已上传完毕"); } else { sSC_PullMes.nStep = 15; } return 0; case 15: if (m_iItemIndex <= m_bufferFileNames.size() - 1) { m_qstrRemoveFile = m_bufferFileNames[m_iItemIndex]; QString tempFile = m_destinationFolder + "\\" + m_qstrRemoveFile; if (deserializeFromJsonFile(tempFile, m_MesInfo)) { if (m_MesInfo.Barcode == "" || m_MesInfo.Barcode.length() < 5) { m_iItemIndex = 0;//将索引归零 addInfo(sSC_PullMes, 10, "条码长度小于5:条码为" + (string)m_MesInfo.Barcode.toLocal8Bit()); m_bufferFileNames.removeOne(m_bufferFileNames[m_iItemIndex]); } else { m_iItemIndex++; m_qqmesInfos.append(m_MesInfo); if (1 == m_GVariant.m_MesConfig->TestAngleCount) { addInfo(sSC_PullMes, 20, "准备上传单角度数据"); } else { if (m_qqmesInfos.size() == 1) { m_AllRemoveFileNames.append(m_bufferFileNames[m_iItemIndex]); m_bufferFileNames.removeOne(m_bufferFileNames[m_iItemIndex]); m_iItemIndex = 0; addInfo(sSC_PullMes, 10, "上传双角度,但是只有角度1数据,继续寻找角度2数据文件"); } else if (m_qqmesInfos.size() == 2) { addInfo(sSC_PullMes, 25, "准备上传双角度数据"); } } } } else { addInfo(sSC_PullMes, ST_ERR, "文件" + (string)tempFile.toLocal8Bit() + "json序列化失败"); } } else { addInfo(sSC_PullMes, ST_END, "缓存文件已上传完毕"); } return 0; case 20: iRtn = updataMes(m_MesInfo,m_GVariant.m_MesConfig->m_MesInfo); if (1 == iRtn) { //清空列表中的 //清空队列中的 m_bufferFileNames.removeOne(m_qstrRemoveFile); m_qqmesInfos.clear(); m_iItemIndex = 0;//将索引归零 addInfo(sSC_PullMes, 10, "单角度上传生成,开始缓存新MES数据"); } else if (-1 == iRtn) { sSC_PullMes.nStep = ST_ERR; } return 0; case 25: if (m_qqmesInfos[0].Barcode == m_qqmesInfos[1].Barcode) { m_AllRemoveFileNames.append(m_qstrRemoveFile); iCount = 0; addInfo(sSC_PullMes, 30, "比对2次条码一致,准备合并上传"); } else { m_qqmesInfos.removeAt(1); iCount++; addInfo(sSC_PullMes, 10, "比对2次条码不一致,继续寻找相同条码文件"); if (iCount >= 2) { iCount = 0; m_AllRemoveFileNames.clear(); m_qqmesInfos.clear(); m_iItemIndex = 0;//将索引归零 } } return 0; case 30: iRtn = updataMes(m_qqmesInfos, m_GVariant.m_MesConfig->m_MesInfo); if (-1 == iRtn) { sSC_PullMes.nStep = ST_ERR; } if (1 == iRtn) { addInfo(sSC_PullMes, 35, "双角度合并上传完成"); } return 0; case 35: m_bufferFileNames.removeOne(m_AllRemoveFileNames[0]); m_bufferFileNames.removeOne(m_AllRemoveFileNames[1]); m_qqmesInfos.clear(); m_AllRemoveFileNames.clear(); m_iItemIndex = 0; sSC_PullMes.nStep = 10; return 0; case ST_DELAY: if (GetTickCount() - sSC_PullMes.dwStart >= sSC_PullMes.dwDelay) { sSC_PullMes.nStep = sSC_PullMes.nStepNext; } return 0; case ST_ERR: return -1; case ST_END: sSC_PullMes.ulCountEnd = m_GFunction.GetCPUPerformanceCounter(); sSC_PullMes.dCycleTime = (sSC_PullMes.ulCountEnd - sSC_PullMes.ulCountStart) / 1000.0; sSC_PullMes.AddCTRecordEnd(m_Loger.m_iRecordCycleTime, "Handler流程初始化执行结束", sSC_PullMes.dCycleTime); if (1 == m_Loger.m_iRecordCycleTime) m_Loger.RecordLogOperation(sSC_PullMes.strRecord);// 添加到缓存变量 sSC_PullMes.Init(); return 1; default: sSC_PullMes.Init(); break; } return 0; } int LCMESClass::checkFolder() { m_currentFileNames.clear(); QString m_sourceFolder = QString::fromLocal8Bit(m_GVariant.m_MesConfig->Path_SourceTestFile.c_str()) + "\\MES" + QDateTime::currentDateTime().addDays(-1).toString("yyyyMMdd"); m_destinationFolder = QString::fromLocal8Bit(m_GVariant.m_MesConfig->Path_DestTestFile.c_str()) + "\\" + QDateTime::currentDateTime().addDays(-1).toString("yyyyMMdd"); bool result1 = m_File.moveAllFiles(m_sourceFolder, m_destinationFolder, m_currentFileNames); m_sourceFolder = QString::fromLocal8Bit(m_GVariant.m_MesConfig->Path_SourceTestFile.c_str()) + "\\MES" + QDateTime::currentDateTime().toString("yyyyMMdd"); m_destinationFolder = QString::fromLocal8Bit(m_GVariant.m_MesConfig->Path_DestTestFile.c_str()) + "\\" + QDateTime::currentDateTime().toString("yyyyMMdd"); bool result2 = m_File.moveAllFiles(m_sourceFolder, m_destinationFolder, m_currentFileNames); if (result1 || result2) { if (m_currentFileNames.size() > 0) { for (auto item : m_currentFileNames) { m_bufferFileNames.append(item); } return 1; } } else { return -1; } return 0; } int LCMESClass::updataMes(TestData testData, MesInfo mesInfo) { mesInfo.SN = testData.Barcode; mesInfo.LastResult = testData.Result.Aggregate; mesInfo.TestDate = testData.Basic.Time; // 重新排序处理 QString tempString = ShortLCMesInfo(testData); QJsonObject jsonObj2; serializeToJsonFile(mesInfo, jsonObj2); QJsonDocument doc(jsonObj2); QString jsonString = doc.toJson(QJsonDocument::Compact); QStringList list = jsonString.split(","); list.insert(5, tempString); QString jsonMesInfo = list.join(",");; jsonMesInfo = jsonMesInfo.replace("/", "//"); jsonMesInfo = jsonMesInfo.replace("\"", "\\\""); jsonMesInfo = "{\"jsonData\":\"" + jsonMesInfo + "\"}"; string info = jsonMesInfo.toLocal8Bit(); Response res = EquipmentTextData_Save(info); if (res.Code == 0 || res.Result == "OK") { return 1; } else { addInfo(res.Msg); return -1; } return 0; } int LCMESClass::updataMes(QQueue<TestData> testData, MesInfo mesInfo) { QString tempString = ShortLCMesInfo(testData[0]); tempString.chop(1); mesInfo.SN = testData[0].Barcode; QString firstResult = testData[0].Result.Final; QString secoundResult = testData[1].Result.Final; if (firstResult == "FAIL" || secoundResult == "FAIL") { mesInfo.LastResult = "FAIL"; } else { mesInfo.LastResult = "PASS"; } mesInfo.TestDate = testData[0].Basic.Time; QString tempString2 = ShortLCMesInfo(testData[1]); tempString2.replace("\"TestData\":{", ""); tempString = tempString + "," + tempString2; QJsonObject jsonObject3; serializeToJsonFile(mesInfo, jsonObject3); QJsonDocument doc(jsonObject3); QString jsonString2 = doc.toJson(QJsonDocument::Compact); QStringList list = jsonString2.split(","); list.insert(5, tempString); QString jsonMesInfo = list.join(","); jsonMesInfo = jsonMesInfo.replace("/", "//"); jsonMesInfo = jsonMesInfo.replace("\"", "\\\""); jsonMesInfo = "{\"jsonData\":\"" + jsonMesInfo + "\"}"; string info = jsonMesInfo.toLocal8Bit(); Response res = EquipmentTextData_Save(info); if (res.Code == 0 || res.Result == "OK") { return 1; } else { addInfo(res.Msg); return -1; } return 0; } QString LCMESClass::ShortLCMesInfo(TestData testData) { QString key = ""; QString value = ""; QString tempString = "\"TestData\":{\""; SplicingEFL(testData, tempString); SplicingFFL(testData, tempString); key = "FinalMTFResult"; value = testData.Result.Aggregate; tempString += (key + "\":\"" + value + "\",\""); SplicingMTF(testData, tempString); key = "Angle"; value = testData.Normal.Tilt.Angle; tempString += (key + "\":\"" + value + "\",\""); SplicingFocalShfit(testData, tempString); SplicingPeak(testData, tempString); SplicingFOV(testData, tempString); SplicingDOF(testData, tempString); SplicingMultiFrqMTF(testData, tempString); key = "SymmetricalGroupAverageCAM2_5TAN"; try { value = testData.Normal.SymmetricalFieldMTF.at(1); } catch (const std::exception&) { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "AstigmatismCameras1"; try { value = testData.Normal.Astigmatism.first(); } catch (const std::exception&) { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "Symmetrical_Group_Ml_(Max-in)_CAM10..13TAN"; if (testData.Normal.SymmetricalGroupMTF.size() > 2) { value = testData.Normal.SymmetricalGroupMTF.at(2).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\"}"); return tempString; } void LCMESClass::PullMes() { sSC_PullMes.Init(); while (true) { int iRtn = FL_PullMes(); if (-1 == iRtn) { break; } Sleep(0); } } int LCMESClass::Check(string sn) { Check_MesInfo checkInof; checkInof.EquipmentEncode = m_GVariant.m_MesConfig->m_MesInfo.EquipmentEncode; checkInof.SpecificationName = m_GVariant.m_MesConfig->m_MesInfo.SpecificationName; checkInof.UserName = m_GVariant.m_MesConfig->m_MesInfo.UserName; checkInof.SN = QString::fromLocal8Bit(sn.c_str()); QJsonObject jsonObj; serializeToJsonFile(checkInof, jsonObj); QJsonDocument doc(jsonObj); QString jsonMesInfo = doc.toJson(QJsonDocument::Compact); jsonMesInfo = jsonMesInfo.replace("/", "//"); jsonMesInfo = jsonMesInfo.replace("\"", "\\\""); jsonMesInfo = "{\"jsonData\":\"" + jsonMesInfo + "\"}"; jsonMesInfo = jsonMesInfo.replace("\r", ""); string info = jsonMesInfo.toLocal8Bit(); Response res = EquipmentTextData_Check(info); if (res.Code == 0 || res.Result == "OK") { return 1; } else { addErrInfo(res.Msg); return -1; } } int LCMESClass::getDeviceInfoCollerctResult(string eventName, string deviceStatus) { Device_MesInfo mes; mes.eventName = QString::fromLocal8Bit(eventName.c_str()); mes.deviceStatus = QString::fromLocal8Bit(deviceStatus.c_str()); mes.EquipmentEncode = m_GVariant.m_MesConfig->m_MesInfo.EquipmentEncode; mes.type = QString::number(1); mes.SpecificationName = m_GVariant.m_MesConfig->m_MesInfo.SpecificationName; mes.UserName = m_GVariant.m_MesConfig->m_MesInfo.UserName; QJsonObject jsonObj; serializeToJsonFile(mes, jsonObj); QJsonDocument doc(jsonObj); QString jsonMesInfo = doc.toJson(QJsonDocument::Compact); jsonMesInfo = jsonMesInfo.replace("/", "//"); jsonMesInfo = jsonMesInfo.replace("\"", "\\\""); jsonMesInfo = "{\"jsonData\":\"" + jsonMesInfo + "\"}"; jsonMesInfo = jsonMesInfo.replace("\r", ""); string info = jsonMesInfo.toLocal8Bit(); Response res = deviceInfoCollerct(info); if (res.Code == 0 || res.Result == "OK") { return 1; } else { addErrInfo(res.Msg); return -1; } return 0; } int LCMESClass::DeviceStateChanged(DeviceState state) { string deviceStatus = ""; switch (state) { case Waiting: deviceStatus = "待机"; break; case Wroking: deviceStatus = "作业"; break; case Faulted: deviceStatus = "故障"; break; case Stopped: deviceStatus = "停机"; break; default: break; } return getDeviceInfoCollerctResult("设备状态改变事件", deviceStatus); } // 设备状态解除事件 int LCMESClass::DeviceAlarmCleared() { return getDeviceInfoCollerctResult("设备故障解除事件", "故障解除"); } // 产品移动事件 int LCMESClass::ProductMoved(string ProductPosition) { return getDeviceInfoCollerctResult("产品移动事件", ProductPosition.c_str()); } // 测试完成发送完工报告事件 int LCMESClass::TestEnd() { return getDeviceInfoCollerctResult("测试完工报告", "测试完成"); } int LCMESClass::SendCount(int total, int okCount) { return 0; } QString LCMESClass::SplicingEFL(TestData testData, QString & tempString) { QString key = "EFL"; QString value = testData.Normal.EFL; tempString += (key + "\":\"" + value + "\",\""); return tempString; } QString LCMESClass::SplicingFFL(TestData testData, QString & tempString) { QString key = "FFL"; QString value = testData.Normal.FFL; tempString += (key + "\":\"" + value + "\",\""); return tempString; } QString LCMESClass::SplicingMTF(TestData testData, QString & tempString) { QString key = ""; QString value = ""; key = "Result"; value = testData.Result.MTF; tempString += (key + "\":\"" + value + "\",\""); for (int i = 0; i < testData.Normal.MTF.size(); i++) { key = "S" + QString::number(i + 1); value = testData.Normal.MTF.at(i).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T" + QString::number(i + 1); value = testData.Normal.MTF.at(i).Tan; tempString += (key + "\":\"" + value + "\",\""); } return tempString; } QString LCMESClass::SplicingFocalShfit(TestData testData, QString & tempString) { QString key = "FocalShift_S2"; QString value = testData.Normal.FocalShift.Cameras.at(1).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T2"; value = testData.Normal.FocalShift.Cameras.at(1).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S3"; value = testData.Normal.FocalShift.Cameras.at(2).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T3"; value = testData.Normal.FocalShift.Cameras.at(2).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S4"; value = testData.Normal.FocalShift.Cameras.at(3).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T4"; value = testData.Normal.FocalShift.Cameras.at(3).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S5"; value = testData.Normal.FocalShift.Cameras.at(4).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T5"; value = testData.Normal.FocalShift.Cameras.at(4).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S6"; value = testData.Normal.FocalShift.Cameras.at(5).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T6"; value = testData.Normal.FocalShift.Cameras.at(5).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S7"; value = testData.Normal.FocalShift.Cameras.at(6).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T7"; value = testData.Normal.FocalShift.Cameras.at(6).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S8"; value = testData.Normal.FocalShift.Cameras.at(7).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T8"; value = testData.Normal.FocalShift.Cameras.at(7).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S9"; value = testData.Normal.FocalShift.Cameras.at(8).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T9"; value = testData.Normal.FocalShift.Cameras.at(8).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S10"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(9).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T10"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(9).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S11"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(10).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T11"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(10).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S12"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(11).Sag; } tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T12"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(11).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_S13"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(12).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FocalShift_T13"; if (testData.Normal.FocalShift.Cameras.size() > 9) { value = testData.Normal.FocalShift.Cameras.at(12).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "Focal_Shift_Group_CAM_2..5_SAG"; if (testData.Normal.FocalShiftGroup.size() != 0) { value = testData.Normal.FocalShiftGroup.at(0).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "Focal_Shift_Group_CAM_2..5_TAN"; if (testData.Normal.FocalShiftGroup.size() != 0) { value = testData.Normal.FocalShiftGroup.at(0).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "Focal_Shift_Group_CAM_6..9_SAG"; if (testData.Normal.FocalShiftGroup.size() > 1) { value = testData.Normal.FocalShiftGroup.at(1).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "Focal_Shift_Group_CAM_6..9_TAN"; if (testData.Normal.FocalShiftGroup.size() > 1) { value = testData.Normal.FocalShiftGroup.at(1).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "Focal_Shift_Group_CAM_10..13_SAG"; if (testData.Normal.FocalShiftGroup.size() > 2) { value = testData.Normal.FocalShiftGroup.at(2).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "Focal_Shift_Group_CAM_10..13_TAN"; if (testData.Normal.FocalShiftGroup.size() > 2) { value = testData.Normal.FocalShiftGroup.at(2).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); return tempString; } QString LCMESClass::SplicingPeak(TestData testData, QString & tempString) { QString key = "S1PEAK"; QString value = testData.Normal.MTFPeaks.at(0).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T1PEAK"; value = testData.Normal.MTFPeaks.at(0).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S2PEAK"; value = testData.Normal.MTFPeaks.at(1).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T2PEAK"; value = testData.Normal.MTFPeaks.at(1).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S3PEAK"; value = testData.Normal.MTFPeaks.at(2).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T3PEAK"; value = testData.Normal.MTFPeaks.at(2).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S4PEAK"; value = testData.Normal.MTFPeaks.at(3).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T4PEAK"; value = testData.Normal.MTFPeaks.at(3).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S5PEAK"; value = testData.Normal.MTFPeaks.at(4).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T5PEAK"; value = testData.Normal.MTFPeaks.at(4).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S6PEAK"; value = testData.Normal.MTFPeaks.at(5).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T6PEAK"; value = testData.Normal.MTFPeaks.at(5).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S7PEAK"; value = testData.Normal.MTFPeaks.at(6).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T7PEAK"; value = testData.Normal.MTFPeaks.at(6).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S8PEAK"; value = testData.Normal.MTFPeaks.at(7).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T8PEAK"; value = testData.Normal.MTFPeaks.at(7).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S9PEAK"; value = testData.Normal.MTFPeaks.at(8).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T9PEAK"; value = testData.Normal.MTFPeaks.at(8).Tan; tempString += (key + "\":\"" + value + "\",\""); key = "S10PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(9).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "T10PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(9).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "S11PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(10).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "T11PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(10).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "S12PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(11).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "T12PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(11).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "S13PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(12).Sag; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "T13PEAK"; if (testData.Normal.MTFPeaks.size() > 9) { value = testData.Normal.MTFPeaks.at(12).Tan; } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); return tempString; } QString LCMESClass::SplicingFOV(TestData testData, QString & tempString) { QString key = "FullFOV2_4"; QString value = ""; if (testData.Normal.FullFOV.size() != 0) { value = testData.Normal.FullFOV.at(0); } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FullFOV3_5"; if (testData.Normal.FullFOV.size() > 1) { value = testData.Normal.FullFOV.at(1); } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FullFOV6_8"; if (testData.Normal.FullFOV.size() > 2) { value = testData.Normal.FullFOV.at(2); } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FullFOV7_9"; if (testData.Normal.FullFOV.size() > 3) { value = testData.Normal.FullFOV.at(3); } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FullFOV10_12"; if (testData.Normal.FullFOV.size() > 4) { value = testData.Normal.FullFOV.at(4); } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "FullFOV11_13"; if (testData.Normal.FullFOV.size() > 5) { value = testData.Normal.FullFOV.at(5); } else { value = ""; } tempString += (key + "\":\"" + value + "\",\""); return tempString; } QString LCMESClass::SplicingDOF(TestData testData, QString & tempString) { QString key = "DOF"; QString value = testData.Normal.DOF.DOF; tempString += (key + "\":\"" + value + "\",\""); key = "A2DOF"; value = testData.Normal.A2DOF.A2DOF; tempString += (key + "\":\"" + value + "\",\""); key = "A2_DOFMinus"; try { value = testData.Normal.A2DOF.Minus; } catch (const std::exception&) { value = ""; } tempString += (key + "\":\"" + value + "\",\""); key = "A2_DOFPlus"; try { value = testData.Normal.A2DOF.Plus; } catch (const std::exception&) { value = ""; } tempString += (key + "\":\"" + value + "\",\""); if (testData.m_bDefocus || testData.Defocus.MTF.size() > 0) { // 如果有defocus数据,应该在这里就要拼接好 for (int i = 0; i < testData.Defocus.MTF.size(); i++) { key = "Defocus"; QStringList list = testData.Result.Defocus.split(" "); value = list.at(i); tempString += (key + "\":\"" + value + "\",\""); QVector<MTFData> q_verMtfData = testData.Defocus.MTF.at(i); for (int j = 0; j < q_verMtfData.size(); j++) { MTFData data = q_verMtfData.at(j); key = "S" + QString::number(j + 1); value = data.Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T" + QString::number(j + 1); value = data.Tan; tempString += (key + "\":\"" + value + "\",\""); } } } return tempString; } QString LCMESClass::SplicingMultiFrqMTF(TestData testData, QString & tempString) { if (testData.Normal.m_bMultiFrqMTF || testData.Normal.MultiFrqMTF.size() > 0) { QString key = ""; QString value = ""; for (int i = 0; i < testData.Normal.MultiFrqMTF.size(); i++) { MultiFrqMTFData data = testData.Normal.MultiFrqMTF.at(i); key = "LstFrq"; value = data.LstFrq; tempString += (key + "\":\"" + value + "\",\""); key = "Result"; QStringList list = testData.Result.MultiFrqMTF.split(" "); value = list.at(i + 1); tempString += (key + "\":\"" + value + "\",\""); for (int j = 0; j < data.MTF.size(); j++) { key = "S" + QString::number(j + 1);; value = data.MTF.at(j).Sag; tempString += (key + "\":\"" + value + "\",\""); key = "T" + QString::number(j + 1); value = data.MTF.at(j).Tan; tempString += (key + "\":\"" + value + "\",\""); } } } return tempString; } QVariantList LCMESClass::jsonArrayToVariantList(const QJsonArray & array) { QVariantList list; for (const QJsonValue& v : array) { list.append(v.toVariant()); } return list; } QJsonArray LCMESClass::variantListToJsonArray(const QVariantList & list) { QJsonArray array; for (const QVariant& v : list) { array.append(QJsonValue::fromVariant(v)); } return array; } int LCMESClass::addInfo(string& info) { if (m_logInfo == info) { return 1; } m_logInfo = info; m_Loger.RecordLogMes(m_logInfo); // 发送消息,传递快照指针 if (NULL != m_GActionFlow.m_hwdMainView) { // 使用PostMessage CString* pMsg = new CString(CA2CT(info.c_str())); ::SendMessage(m_GActionFlow.m_hwdMainView, WM_MESINFO, (WPARAM)pMsg, 0); } return 0; } int LCMESClass::addInfo(StepCtrl & crtl, int next, string info, bool blag) { addInfo(info); crtl.nStep = next; if (blag) { crtl.ulCountStart = m_GFunction.GetCPUPerformanceCounter(); crtl.InitRecordString(); } if (next == ST_ERR) { addErrInfo(info); } return 0; } int LCMESClass::addInfo(StepCtrl & crtl, int next, string info, int delay) { crtl.SetDelay(next, delay); addInfo(info); return 0; } int LCMESClass::addErrInfo(string info) { m_GActionFlow.LightOpenRed(); m_dlgError.SetError(info); m_Loger.RecordLogError(info); //m_gMes.DeviceStateChanged(DeviceState::Faulted); 不能用,MES服务端出现问题后不能再调用,会导致死循环 if (MB_OKCANCEL == AfxMessageBox(m_GFunction.String2CString(info), MB_OKCANCEL | MB_DEFBUTTON1)) { m_GActionFlow.LightOpenGreen(); } return 0; } 统一用的锁
最新发布
09-13
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值