From 415ad67bb66ca2d99fb21a8eeb32f942ad2cd7b0 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期一, 09 二月 2026 13:32:42 +0800
Subject: [PATCH] 1.修改为tab页的展示形式
---
SourceCode/Bond/Servo/CPageGlassList.cpp | 474 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 431 insertions(+), 43 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPageGlassList.cpp b/SourceCode/Bond/Servo/CPageGlassList.cpp
index 0d12d82..3fbf607 100644
--- a/SourceCode/Bond/Servo/CPageGlassList.cpp
+++ b/SourceCode/Bond/Servo/CPageGlassList.cpp
@@ -13,6 +13,7 @@
#include <unordered_map>
#include <vector>
#include <string>
+#include <algorithm>
#include "CProcessDataListDlg.h"
#define PAGE_SIZE 50
@@ -22,6 +23,86 @@
static const COLORREF kWipText = RGB(0, 0, 0);
static const COLORREF kWipParentBk = RGB(201, 228, 180); // 鍩虹缁�
static const COLORREF kWipChildBk = RGB(221, 241, 208); // 鏇存祬涓�鐐�
+
+namespace {
+ CString FormatPathTime(ULONGLONG ts)
+ {
+ if (ts == 0) return _T("");
+ return CString(CToolUnits::timeToString2(ts).c_str());
+ }
+
+ void BuildPathRowsFromGlass(SERVO::CGlass& glass, std::vector<CProcessDataListDlg::PathRow>& rows)
+ {
+ rows.clear();
+ SERVO::CPath* pHead = glass.getPath();
+ if (pHead == nullptr) return;
+
+ SERVO::CPath* p = pHead->getHeadPath();
+ int step = 1;
+ while (p != nullptr) {
+ CProcessDataListDlg::PathRow r;
+ r.step.Format(_T("%d"), step++);
+ std::string eqName = SERVO::CServoUtilsTool::getEqUnitName(
+ (int)p->getEqID(), (int)p->getUnit(), (int)p->getSlot());
+ if (eqName.empty()) {
+ CString tmp;
+ tmp.Format(_T("Eq:%u Unit:%u Slot:%u"), p->getEqID(), p->getUnit(), p->getSlot());
+ r.chamber = tmp;
+ }
+ else {
+ r.chamber = eqName.c_str();
+ }
+ r.enterTime = FormatPathTime(p->getInTime());
+ r.leaveTime = FormatPathTime(p->getOutTime());
+ r.isArmStep = (p->getEqID() == EQ_ID_ARM
+ || p->getEqID() == EQ_ID_ARM_TRAY1
+ || p->getEqID() == EQ_ID_ARM_TRAY2);
+ rows.push_back(r);
+ p = p->getNext();
+ }
+ }
+
+ void ParseNameValuePairs(const CString& text, std::vector<std::pair<CString, CString>>& outRows)
+ {
+ outRows.clear();
+ int idx = 0;
+ CString token;
+ while (AfxExtractSubString(token, text, idx, ',')) {
+ ++idx;
+ const int pos = token.Find(_T(':'));
+ if (pos < 0) continue;
+ CString name = token.Left(pos);
+ CString value = token.Mid(pos + 1);
+ name.Trim();
+ value.Trim();
+ if (!name.IsEmpty()) {
+ outRows.emplace_back(name, value);
+ }
+ }
+ }
+
+ void BuildBasicRowsFromList(CListCtrl& list, int row, std::vector<std::pair<CString, CString>>& rows)
+ {
+ rows.clear();
+ CHeaderCtrl* pHdr = list.GetHeaderCtrl();
+ const int colCount = pHdr ? pHdr->GetItemCount() : 0;
+ for (int col = 1; col < colCount; ++col) {
+ if (col == 11 || col == 12) continue; // 杩欎袱鍒楀崟鐙綔涓哄叾浠栭〉
+ TCHAR buf[256] = { 0 };
+ LVCOLUMN lvc = {};
+ lvc.mask = LVCF_TEXT;
+ lvc.pszText = buf;
+ lvc.cchTextMax = _countof(buf);
+ CString header;
+ if (list.GetColumn(col, &lvc)) header = lvc.pszText;
+ header.Trim();
+ if (header.IsEmpty()) continue;
+
+ CString val = list.GetItemText(row, col);
+ rows.emplace_back(header, val);
+ }
+ }
+}
// ===== 鏀惧湪 CPageGlassList.cpp 椤堕儴鐨勫尶鍚嶅伐鍏凤紙鏂囦欢鍐呴潤鎬侊級 =====
// 鎶婂綋鍓嶁�滃凡灞曞紑鈥濈殑鐖惰锛岀敤瀹冧滑鐨� classId锛堢4鍒楁枃鏈級鍋� key 璁板綍涓嬫潵
@@ -99,6 +180,9 @@
// ====== 寮�鍏筹細1=鍚敤鍋囨暟鎹紙鍙浛鎹� DB 鏌ヨ锛夛紱0=鐢ㄧ湡瀹� DB ======
#define USE_FAKE_DB_DEMO 0
+
+// ====== 寮�鍏筹細1=鍚敤妯℃嫙浼犳劅鍣ㄦ暟鎹敓鎴愶紱0=浣跨敤鐪熷疄鏁版嵁 ======
+#define USE_MOCK_SENSOR_DATA 0
#if USE_FAKE_DB_DEMO
#include <ctime>
@@ -475,6 +559,7 @@
ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CPageGlassList::OnBnClickedButtonPrevPage)
ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CPageGlassList::OnBnClickedButtonNextPage)
ON_NOTIFY(ELCN_SHOWFULLTEXT, IDC_LIST_ALARM, &CPageGlassList::OnShowFullText)
+ ON_NOTIFY(NM_DBLCLK, IDC_LIST_ALARM, &CPageGlassList::OnNMDblclkListAlarm)
ON_BN_CLICKED(IDC_BUTTON_EXPORT_ROW, &CPageGlassList::OnBnClickedButtonExportRow)
END_MESSAGE_MAP()
@@ -1084,9 +1169,10 @@
{
CDialogEx::OnInitDialog();
- // 瀹氭椂鍣細1=鍒濆鍖栬闃咃紝2=鍛ㄦ湡鍒锋柊锛堝彧澧為噺锛�
+ // 瀹氭椂鍣細1=鍒濆鍖栬闃咃紝2=鍛ㄦ湡鍒锋柊锛堝彧澧為噺锛夛紝3=寤惰繜鍔犺浇棣栧睆鏁版嵁
SetTimer(1, 3000, nullptr);
SetTimer(2, 2000, nullptr);
+ SetTimer(3, 10, nullptr);
// 涓嬫媺妗嗘帶浠�
InitStatusCombo();
@@ -1136,7 +1222,6 @@
m_listCtrl.SetPopupFullTextColumns({ 11, 12 });
Resize();
- OnBnClickedButtonSearch(); // 瑙﹀彂涓�娆℃煡璇笌棣栧睆濉厖
return TRUE; // return TRUE unless you set the focus to a control
}
@@ -1196,6 +1281,10 @@
else if (nIDEvent == 2) {
UpdateWipData(); // 鍙仛澧為噺锛屼笉閲嶅缓
}
+ else if (nIDEvent == 3) {
+ KillTimer(3);
+ OnBnClickedButtonSearch(); // 寤惰繜棣栧睆鏌ヨ锛岄伩鍏嶅崱浣� OnInitDialog
+ }
CDialogEx::OnTimer(nIDEvent);
}
@@ -1225,6 +1314,8 @@
void CPageGlassList::OnBnClickedButtonSearch()
{
+ CWaitCursor wait; // 鏄剧ず绛夊緟鍏夋爣锛屾彁绀烘鍦ㄥ姞杞�
+
// 鑾峰彇鍏抽敭瀛楄緭鍏ユ鍐呭
CString strKeyword;
GetDlgItemText(IDC_EDIT_KEYWORD, strKeyword);
@@ -1334,12 +1425,12 @@
strSanitizedGlassId.Remove('>');
strSanitizedGlassId.Remove('|');
- strDefaultFileName.Format(_T("Glass_%s.json"), strSanitizedGlassId);
+ strDefaultFileName.Format(_T("Glass_%s.csv"), strSanitizedGlassId);
// 鏂囦欢淇濆瓨瀵硅瘽妗嗭紝璁剧疆榛樿鏂囦欢鍚�
- CFileDialog fileDialog(FALSE, _T("json"), strDefaultFileName,
+ CFileDialog fileDialog(FALSE, _T("csv"), strDefaultFileName,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
- _T("JSON Files (*.json)|*.json|CSV Files (*.csv)|*.csv||"));
+ _T("CSV Files (*.csv)|*.csv|JSON Files (*.json)|*.json||"));
if (fileDialog.DoModal() != IDOK) return;
@@ -1360,7 +1451,7 @@
if (!row.pretty.empty()) {
CFile file;
if (file.Open(filePath, CFile::modeCreate | CFile::modeWrite)) {
- file.Write(row.pretty.c_str(), row.pretty.length());
+ file.Write(row.pretty.c_str(), (UINT)row.pretty.length());
file.Close();
CString strSuccess;
@@ -1471,72 +1562,66 @@
if (!row.pretty.empty()) {
SERVO::CGlass tempGlass;
if (GlassJson::FromString(row.pretty, tempGlass)) {
+#if USE_MOCK_SENSOR_DATA
+ // 鐢熸垚妯℃嫙鐨凷VData鐢ㄤ簬娴嬭瘯
+ GenerateMockSVData(tempGlass);
+#endif
// 瀵规瘡涓満鍣ㄧ敓鎴愯〃鏍�
for (const auto& machinePair : tempGlass.getAllSVData()) {
int machineId = machinePair.first;
+ const auto& dataByType = machinePair.second;
CString machineName = CString(SERVO::CServoUtilsTool::getEqName(machineId).c_str());
csvContent += _T("\n[") + machineName + _T("]\n");
- // 鑾峰彇璇ユ満鍣ㄧ殑棰勫畾涔夊垪椤哄簭
- auto columnOrder = getMachineColumnOrder(machineId);
-
- if (columnOrder.empty()) {
- csvContent += _T("鏃犻瀹氫箟鍒楅厤缃甛n");
+ if (dataByType.empty()) {
+ csvContent += _T("No sensor data\n");
continue;
}
- // 鏋勫缓琛ㄥご - 鐩存帴浣跨敤涓枃鍒楀悕
- CString header = _T("鏃堕棿鎴�(ms),鏈湴鏃堕棿");
+ auto columnOrder = getMachineColumnOrder(machineId, &dataByType);
+ if (columnOrder.empty()) {
+ csvContent += _T("No exportable columns\n");
+ continue;
+ }
+
+ CString header = _T("Timestamp(ms),LocalTime");
for (const auto& dataType : columnOrder) {
header += _T(",");
- header += CString(dataType.c_str()); // 鐩存帴浣跨敤涓枃鍒楀悕
+ header += CString(dataType.c_str());
}
header += _T("\n");
csvContent += header;
- // 妫�鏌ユ槸鍚︽湁鏁版嵁
- if (machinePair.second.empty()) {
- csvContent += _T("鏃犱紶鎰熷櫒鏁版嵁\n");
+ auto baselineIt = std::find_if(columnOrder.begin(), columnOrder.end(),
+ [&](const std::string& type) {
+ auto dataIt = dataByType.find(type);
+ return dataIt != dataByType.end() && !dataIt->second.empty();
+ });
+ if (baselineIt == columnOrder.end()) {
+ csvContent += _T("No usable time series\n");
continue;
}
- // 浣跨敤绗竴涓暟鎹被鍨嬬殑鏃堕棿搴忓垪浣滀负鍩哄噯
- const std::string& firstDataType = columnOrder[0];
- auto firstDataTypeIt = machinePair.second.find(firstDataType);
- if (firstDataTypeIt == machinePair.second.end() || firstDataTypeIt->second.empty()) {
- csvContent += _T("鏃犲熀鍑嗘暟鎹被鍨嬫暟鎹甛n");
- continue;
- }
-
- const auto& timeSeries = firstDataTypeIt->second;
-
- // 瀵逛簬姣忎釜鏃堕棿鐐癸紝杈撳嚭涓�琛屾暟鎹�
- for (size_t i = 0; i < timeSeries.size(); i++) {
+ const auto& timeSeries = dataByType.at(*baselineIt);
+ for (size_t i = 0; i < timeSeries.size(); ++i) {
auto timestamp = timeSeries[i].timestamp;
-
- // 鏃堕棿鎴筹紙姣锛�
auto ms = timePointToMs(timestamp);
CString row;
row.Format(_T("%lld,"), ms);
- // 鏈湴鏃堕棿瀛楃涓�
CString localTime = CString(timePointToString(timestamp).c_str());
row += localTime;
- // 鎸夌収棰勫畾涔夌殑鍒楅『搴忚緭鍑烘暟鎹�
for (const auto& dataType : columnOrder) {
row += _T(",");
-
- auto dataTypeIt = machinePair.second.find(dataType);
- if (dataTypeIt != machinePair.second.end() && i < dataTypeIt->second.size()) {
- // 鐩存帴鎸夌储寮曡幏鍙栨暟鎹�
+ auto dataTypeIt = dataByType.find(dataType);
+ if (dataTypeIt != dataByType.end() && i < dataTypeIt->second.size()) {
CString valueStr;
valueStr.Format(_T("%.3f"), dataTypeIt->second[i].value);
row += valueStr;
}
else {
- // 鐞嗚涓婁笉搴旇鍙戠敓锛屽洜涓烘偍璇存病鏈夌┖鍊�
row += _T("N/A");
}
}
@@ -1574,9 +1659,190 @@
{
auto* p = reinterpret_cast<NMC_ELC_SHOWFULLTEXT*>(pNMHDR);
- // 瀵硅瘽妗嗘樉绀哄伐鑹哄弬鏁�
+ if (p->iSubItem != 11 && p->iSubItem != 12) {
+ AfxMessageBox(p->text);
+ *pResult = 0;
+ return;
+ }
+
+ const int row = p->iItem;
+ std::vector<std::pair<CString, CString>> basicRows;
+ std::vector<std::pair<CString, CString>> processRows;
+ std::vector<CProcessDataListDlg::PathRow> pathRows;
+ bool pathOk = false;
+
+ BuildBasicRowsFromList(m_listCtrl, row, basicRows);
+
+ CString paramsText = m_listCtrl.GetItemText(row, 12);
+ ParseNameValuePairs(paramsText, processRows);
+
+ CString strId = m_listCtrl.GetItemText(row, 1); // DB id锛學IP涓虹┖
+ if (!strId.IsEmpty()) {
+ try {
+ auto rec = GlassLogDb::Instance().queryById(_ttoi64(strId));
+ if (rec.has_value() && !rec->pretty.empty()) {
+ SERVO::CGlass tempGlass;
+ if (GlassJson::FromString(rec->pretty, tempGlass)) {
+ BuildPathRowsFromGlass(tempGlass, pathRows);
+ pathOk = !pathRows.empty();
+ }
+ }
+ }
+ catch (...) {
+ pathOk = false;
+ }
+ }
+
+ if (!pathOk) {
+ CString cls = m_listCtrl.GetItemText(row, 4); // Class ID
+#ifdef _UNICODE
+ std::string classId = CT2A(cls);
+#else
+ std::string classId = cls.GetString();
+#endif
+ if (!classId.empty()) {
+ std::vector<SERVO::CGlass*> wipGlasses;
+ theApp.m_model.m_master.getWipGlasses(wipGlasses);
+ std::vector<SERVO::CGlass*> tempRetain = wipGlasses;
+ SERVO::CGlass* found = nullptr;
+ for (auto* g : wipGlasses) {
+ if (g == nullptr) continue;
+ if (g->getID() == classId) { found = g; break; }
+ SERVO::CGlass* b = g->getBuddy();
+ if (b != nullptr && b->getID() == classId) { found = b; break; }
+ }
+ if (found != nullptr) {
+ BuildPathRowsFromGlass(*found, pathRows);
+ pathOk = !pathRows.empty();
+ }
+ for (auto* item : tempRetain) {
+ if (item != nullptr) item->release();
+ }
+ }
+ }
+
+ if (!pathOk) {
+ CString pathText = m_listCtrl.GetItemText(row, 11);
+ if (!pathText.IsEmpty()) {
+ int cur = 0;
+ CString token = pathText.Tokenize(_T("->"), cur);
+ int step = 1;
+ while (!token.IsEmpty()) {
+ token.Trim();
+ if (!token.IsEmpty()) {
+ CProcessDataListDlg::PathRow r;
+ r.step.Format(_T("%d"), step++);
+ r.chamber = token;
+ r.enterTime = _T("");
+ r.leaveTime = _T("");
+ CString upper = token;
+ upper.MakeUpper();
+ r.isArmStep = (upper.Find(_T("ARM")) >= 0 || upper.Find(_T("TRAY")) >= 0);
+ pathRows.push_back(r);
+ }
+ token = pathText.Tokenize(_T("->"), cur);
+ }
+ }
+ }
+
CProcessDataListDlg dlg;
- dlg.setRawText(p->text);
+ dlg.setUnifiedData(basicRows, pathRows, processRows);
+ dlg.setInitialTab((p->iSubItem == 11) ? 1 : 2);
+ dlg.DoModal();
+
+ *pResult = 0;
+}
+
+void CPageGlassList::OnNMDblclkListAlarm(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ LPNMITEMACTIVATE pItem = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
+ if (pItem == nullptr || pItem->iItem < 0) {
+ *pResult = 0;
+ return;
+ }
+
+ const int row = pItem->iItem;
+ std::vector<std::pair<CString, CString>> basicRows;
+ std::vector<std::pair<CString, CString>> processRows;
+ std::vector<CProcessDataListDlg::PathRow> pathRows;
+ bool pathOk = false;
+
+ BuildBasicRowsFromList(m_listCtrl, row, basicRows);
+
+ CString paramsText = m_listCtrl.GetItemText(row, 12);
+ ParseNameValuePairs(paramsText, processRows);
+
+ CString strId = m_listCtrl.GetItemText(row, 1); // DB id锛學IP涓虹┖
+ if (!strId.IsEmpty()) {
+ try {
+ auto rec = GlassLogDb::Instance().queryById(_ttoi64(strId));
+ if (rec.has_value() && !rec->pretty.empty()) {
+ SERVO::CGlass tempGlass;
+ if (GlassJson::FromString(rec->pretty, tempGlass)) {
+ BuildPathRowsFromGlass(tempGlass, pathRows);
+ pathOk = !pathRows.empty();
+ }
+ }
+ }
+ catch (...) {
+ pathOk = false;
+ }
+ }
+
+ if (!pathOk) {
+ CString cls = m_listCtrl.GetItemText(row, 4); // Class ID
+#ifdef _UNICODE
+ std::string classId = CT2A(cls);
+#else
+ std::string classId = cls.GetString();
+#endif
+ if (!classId.empty()) {
+ std::vector<SERVO::CGlass*> wipGlasses;
+ theApp.m_model.m_master.getWipGlasses(wipGlasses);
+ std::vector<SERVO::CGlass*> tempRetain = wipGlasses;
+ SERVO::CGlass* found = nullptr;
+ for (auto* g : wipGlasses) {
+ if (g == nullptr) continue;
+ if (g->getID() == classId) { found = g; break; }
+ SERVO::CGlass* b = g->getBuddy();
+ if (b != nullptr && b->getID() == classId) { found = b; break; }
+ }
+ if (found != nullptr) {
+ BuildPathRowsFromGlass(*found, pathRows);
+ pathOk = !pathRows.empty();
+ }
+ for (auto* item : tempRetain) {
+ if (item != nullptr) item->release();
+ }
+ }
+ }
+
+ if (!pathOk) {
+ CString pathText = m_listCtrl.GetItemText(row, 11);
+ if (!pathText.IsEmpty()) {
+ int cur = 0;
+ CString token = pathText.Tokenize(_T("->"), cur);
+ int step = 1;
+ while (!token.IsEmpty()) {
+ token.Trim();
+ if (!token.IsEmpty()) {
+ CProcessDataListDlg::PathRow r;
+ r.step.Format(_T("%d"), step++);
+ r.chamber = token;
+ r.enterTime = _T("");
+ r.leaveTime = _T("");
+ CString upper = token;
+ upper.MakeUpper();
+ r.isArmStep = (upper.Find(_T("ARM")) >= 0 || upper.Find(_T("TRAY")) >= 0);
+ pathRows.push_back(r);
+ }
+ token = pathText.Tokenize(_T("->"), cur);
+ }
+ }
+ }
+
+ CProcessDataListDlg dlg;
+ dlg.setUnifiedData(basicRows, pathRows, processRows);
dlg.DoModal();
*pResult = 0;
@@ -1912,11 +2178,33 @@
}
// 鑾峰彇鏈哄櫒棰勫畾涔夌殑鍒楅『搴�
-std::vector<std::string> CPageGlassList::getMachineColumnOrder(int machineId)
+std::vector<std::string> CPageGlassList::getMachineColumnOrder(int machineId,
+ const std::unordered_map<std::string, std::vector<SERVO::SVDataItem>>* actualData)
{
+ std::vector<std::string> columnOrder;
auto dataTypes = SERVO::CServoUtilsTool::getEqDataTypes();
auto it = dataTypes.find(machineId);
- return it != dataTypes.end() ? it->second : std::vector<std::string>();
+
+ if (actualData != nullptr) {
+ if (it != dataTypes.end()) {
+ for (const auto& name : it->second) {
+ if (actualData->find(name) != actualData->end()) {
+ columnOrder.push_back(name);
+ }
+ }
+ }
+ for (const auto& kv : *actualData) {
+ if (std::find(columnOrder.begin(), columnOrder.end(), kv.first) == columnOrder.end()) {
+ columnOrder.push_back(kv.first);
+ }
+ }
+ return columnOrder;
+ }
+
+ if (it != dataTypes.end()) {
+ columnOrder = it->second;
+ }
+ return columnOrder;
}
// 鏃堕棿鎴宠浆鎹负瀛楃涓�
@@ -1934,4 +2222,104 @@
int64_t CPageGlassList::timePointToMs(const std::chrono::system_clock::time_point& tp)
{
return std::chrono::duration_cast<std::chrono::milliseconds>(tp.time_since_epoch()).count();
-}
\ No newline at end of file
+}
+
+// 鐢熸垚妯℃嫙鐨凷VData鐢ㄤ簬娴嬭瘯
+void CPageGlassList::GenerateMockSVData(SERVO::CGlass& glass)
+{
+ // 鑾峰彇璁惧鏁版嵁绫诲瀷閰嶇疆
+ auto& dataTypes = SERVO::CServoUtilsTool::getEqDataTypes();
+
+ // 涓烘瘡涓澶囩敓鎴愭ā鎷熸暟鎹�
+ for (const auto& machinePair : dataTypes) {
+ int machineId = machinePair.first;
+ const auto& dataTypeList = machinePair.second;
+ std::vector<std::string> filteredTypes;
+
+ if (machineId == EQ_ID_VACUUMBAKE || machineId == EQ_ID_BAKE_COOLING) {
+ const char activePrefix = 'A';
+ for (const auto& dataType : dataTypeList) {
+ if (!dataType.empty() && dataType[0] == activePrefix) {
+ filteredTypes.push_back(dataType);
+ }
+ }
+ }
+
+ const auto& typeList = filteredTypes.empty() ? dataTypeList : filteredTypes;
+
+ // 鐢熸垚鏃堕棿搴忓垪锛氫粠褰撳墠鏃堕棿寰�鍓嶆帹10鍒嗛挓锛屾瘡1绉掍竴涓暟鎹偣
+ auto now = std::chrono::system_clock::now();
+ auto startTime = now - std::chrono::minutes(10);
+
+ // 涓烘瘡涓暟鎹被鍨嬬敓鎴愭ā鎷熸暟鎹�
+ for (const auto& dataType : typeList) {
+ std::vector<SERVO::SVDataItem> mockData;
+
+ // 鐢熸垚600涓暟鎹偣锛�10鍒嗛挓 * 60涓偣/鍒嗛挓锛�
+ for (int i = 0; i < 600; ++i) {
+ auto timestamp = startTime + std::chrono::seconds(i * 1);
+
+ // 鏍规嵁璁惧绫诲瀷鍜屾暟鎹被鍨嬬敓鎴愪笉鍚岀殑妯℃嫙鍊�
+ double value = GenerateMockValue(machineId, dataType, i);
+
+ mockData.emplace_back(timestamp, value);
+ }
+
+ // 灏嗘ā鎷熸暟鎹坊鍔犲埌glass瀵硅薄涓�
+ glass.addSVData(machineId, dataType, mockData);
+ }
+ }
+}
+
+// 鏍规嵁璁惧绫诲瀷鍜屾暟鎹被鍨嬬敓鎴愭ā鎷熸暟鍊�
+double CPageGlassList::GenerateMockValue(int machineId, const std::string& dataType, int index)
+{
+ // 鍩虹鍊艰寖鍥�
+ double baseValue = 0.0;
+ double variation = 0.0;
+
+ // 鏍规嵁璁惧绫诲瀷璁剧疆鍩虹鍊�
+ switch (machineId) {
+ case EQ_ID_Bonder1:
+ case EQ_ID_Bonder2:
+ if (dataType.find("鍘嬪姏") != std::string::npos) {
+ baseValue = 50.0; // 鍘嬪姏鍩虹鍊�
+ variation = 10.0; // 鍘嬪姏鍙樺寲鑼冨洿
+ } else if (dataType.find("娓╁害") != std::string::npos) {
+ baseValue = 180.0; // 娓╁害鍩虹鍊�
+ variation = 5.0; // 娓╁害鍙樺寲鑼冨洿
+ } else if (dataType.find("鎵╁睍鍊�") != std::string::npos) {
+ baseValue = 100.0; // 鎵╁睍鍊煎熀纭�鍊�
+ variation = 15.0; // 鎵╁睍鍊煎彉鍖栬寖鍥�
+ }
+ break;
+
+ case EQ_ID_VACUUMBAKE:
+ if (dataType.find("鎵╁睍鍊�") != std::string::npos) {
+ baseValue = 80.0;
+ variation = 12.0;
+ } else if (dataType.find("娓╁害") != std::string::npos) {
+ baseValue = 200.0;
+ variation = 8.0;
+ }
+ break;
+
+ case EQ_ID_BAKE_COOLING:
+ if (dataType.find("娓╁害") != std::string::npos) {
+ baseValue = 25.0; // 鍐峰嵈娓╁害
+ variation = 3.0;
+ }
+ break;
+
+ default:
+ baseValue = 50.0;
+ variation = 5.0;
+ break;
+ }
+
+ // 娣诲姞鏃堕棿鐩稿叧鐨勮秼鍔垮拰闅忔満鍙樺寲
+ double timeTrend = sin(index * 0.1) * 2.0; // 姝e鸡娉㈣秼鍔�
+ double randomNoise = (rand() % 100 - 50) / 100.0 * variation * 0.3; // 闅忔満鍣0
+
+ return baseValue + timeTrend + randomNoise;
+}
--
Gitblit v1.9.3