From df4d0e875ccfe40add25100a75dedee54e566aaa Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 18 九月 2025 09:06:24 +0800
Subject: [PATCH] 1.CConrolJobManagerDlg临时数据存储。
---
SourceCode/Bond/Servo/CPageGlassList.cpp | 279 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 195 insertions(+), 84 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPageGlassList.cpp b/SourceCode/Bond/Servo/CPageGlassList.cpp
index 4405d13..4291a7e 100644
--- a/SourceCode/Bond/Servo/CPageGlassList.cpp
+++ b/SourceCode/Bond/Servo/CPageGlassList.cpp
@@ -8,12 +8,12 @@
#include "GlassJson.h"
#include "CServoUtilsTool.h"
#include "ToolUnits.h"
-
#include <optional>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <string>
+#include "CProcessDataListDlg.h"
#define PAGE_SIZE 50
#define PAGE_BACKGROUND_COLOR RGB(252, 252, 255)
@@ -340,6 +340,39 @@
}
}
+bool CopyUtf8ToClipboard(const std::string& utf8)
+{
+ // 1) UTF-8 -> UTF-16 闀垮害锛堝惈缁撳熬 '\0'锛�
+ int wlen = MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, nullptr, 0);
+ if (wlen <= 0) return false;
+
+ // 2) 涓哄壀璐存澘鍒嗛厤鍏ㄥ眬鍙Щ鍔ㄥ唴瀛橈紙蹇呴』 GMEM_MOVEABLE锛�
+ SIZE_T bytes = static_cast<SIZE_T>(wlen) * sizeof(wchar_t);
+ HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, bytes);
+ if (!hMem) return false;
+
+ // 3) 濉厖 UTF-16 鏂囨湰
+ wchar_t* wbuf = static_cast<wchar_t*>(GlobalLock(hMem));
+ if (!wbuf) { GlobalFree(hMem); return false; }
+ MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, wbuf, wlen);
+ GlobalUnlock(hMem);
+
+ // 4) 鎵撳紑鍓创鏉垮苟璁剧疆鏁版嵁锛圕F_UNICODETEXT锛�
+ if (!OpenClipboard(nullptr)) { GlobalFree(hMem); return false; }
+ if (!EmptyClipboard()) { CloseClipboard(); GlobalFree(hMem); return false; }
+
+ // 鎴愬姛鍚庯紝鍐呭瓨鎵�鏈夋潈浜ょ粰鍓创鏉匡紝涓嶈兘鍐� GlobalFree
+ if (!SetClipboardData(CF_UNICODETEXT, hMem)) {
+ CloseClipboard();
+ GlobalFree(hMem);
+ return false;
+ }
+
+ CloseClipboard();
+ return true;
+}
+
+
// CPageGlassList 瀵硅瘽妗�
IMPLEMENT_DYNAMIC(CPageGlassList, CDialogEx)
@@ -403,7 +436,7 @@
}
// ===== CPageGlassList 娑堟伅澶勭悊绋嬪簭 =====
-void CPageGlassList::InitRxWindow()
+void CPageGlassList::InitRxWindows()
{
// 璁㈤槄鏁版嵁
IRxWindows* pRxWindows = RX_GetRxWindows();
@@ -520,10 +553,10 @@
{
m_rebuilding = true;
- // 鏀惧湪浠讳綍娓呯┖/閲嶅缓鍔ㄤ綔涔嬪墠锛�
+ // 鏀惧湪浠讳綍娓呯┖/閲嶅缓鍔ㄤ綔涔嬪墠锛氳褰曞睍寮�鐨勭埗鑺傜偣 key锛圕lassID锛�
auto expandedKeys = SnapshotExpandedKeys(m_listCtrl);
- // 鈥斺�� 鍙屼繚闄╋細鍏堟竻鎺夊彲瑙侀」锛屽啀娓呮爲缁撴瀯 鈥斺��
+ // 鈥斺�� 鍙屼繚闄╋細鍏堟竻鎺夊彲瑙侀」锛屽啀娓呮爲缁撴瀯 鈥斺��
m_listCtrl.SetRedraw(FALSE);
m_listCtrl.DeleteAllItems();
m_listCtrl.SetRedraw(TRUE);
@@ -532,7 +565,7 @@
m_listCtrl.ClearTree();
const int colCount = m_listCtrl.GetHeaderCtrl() ? m_listCtrl.GetHeaderCtrl()->GetItemCount() : 0;
- if (colCount <= 0) return;
+ if (colCount <= 0) { m_rebuilding = false; return; }
// ==================== 1) WIP锛氫粎绗� 1 椤垫瀯寤猴紝涓旀斁鍦ㄦ渶椤堕儴 ====================
if (m_nCurPage == 1) {
@@ -551,9 +584,11 @@
SERVO::CGlass* b = g->getBuddy();
if (b) {
+ // 鎸変綘鐨勭害瀹氾細g 鏄埗锛宐uddy 鏄瓙
SERVO::CGlass* parent = g;
SERVO::CGlass* child = b;
+ // parent
std::vector<CString> pcols(colCount);
pcols[1] = _T("");
pcols[2] = std::to_string(parent->getCassetteSequenceNo()).c_str();
@@ -572,6 +607,7 @@
MaybeRestoreExpandByKey(nParent, expandedKeys);
m_listCtrl.SetNodeColor(nParent, kWipText, kWipParentBk); // 鐖讹細鍩虹缁�
+ // child
std::vector<CString> ccols(colCount);
ccols[1] = _T("");
ccols[2] = std::to_string(child->getCassetteSequenceNo()).c_str();
@@ -615,107 +651,168 @@
for (auto* item : tempGlasses) item->release();
}
- // ==================== 2) DB 褰撳墠椤碉紙鏃犺绗嚑椤甸兘鏋勫缓锛涙帓鍦� WIP 涔嬪悗锛� ====================
+ // ==================== 2) DB 褰撳墠椤碉紙涓ら樁娈垫瀯寤猴紝澶勭悊鍗曞悜 buddy锛� ====================
+ const int rawLimit = PAGE_SIZE + 1;
+ const int rawOffset = PAGE_SIZE * (m_nCurPage - 1);
#if USE_FAKE_DB_DEMO
- auto page = _make_page_fake(m_filters, PAGE_SIZE, PAGE_SIZE * (m_nCurPage - 1));
+ auto page = _make_page_fake(m_filters, rawLimit, rawOffset);
#else
auto& db = GlassLogDb::Instance();
- auto page = db.queryPaged(m_filters, PAGE_SIZE, PAGE_SIZE * (m_nCurPage - 1));
+ auto pageFull = db.queryPaged(m_filters, rawLimit, rawOffset);
#endif
+ // 濡傛灉澶氬嚭涓�鏉★紝鐪嬬湅瀹冩槸鍚︽槸鈥滄湰椤垫渶鍚庝竴鏉♀�濈殑 buddy
+ std::optional<decltype(pageFull.items)::value_type> lookahead; // 棰勮璁板綍锛堣嫢涓庢渶鍚庝竴鏉¢厤瀵癸級
+ auto iEquals = [](const std::string& a, const std::string& b) {
+#ifdef _WIN32
+ return _stricmp(a.c_str(), b.c_str()) == 0;
+#else
+ return strcasecmp(a.c_str(), b.c_str()) == 0;
+#endif
+ };
+
+ if (pageFull.items.size() == rawLimit) {
+ const auto& last = pageFull.items[PAGE_SIZE - 1];
+ const auto& extra = pageFull.items[PAGE_SIZE];
+
+ bool pair =
+ (!last.buddyId.empty() && iEquals(last.buddyId, extra.classId)) ||
+ (!extra.buddyId.empty() && iEquals(extra.buddyId, last.classId));
+
+ if (pair) {
+ lookahead = extra; // 鎶婇璇讳繚瀛樹笅鏉ワ紝绋嶅悗琛ユ垚瀛愯
+ }
+ // 鏃犺鏄惁閰嶅锛屽垪琛ㄩ兘缂╁洖 PAGE_SIZE 鏉★紙棰勮涓嶇畻鍏ユ湰椤垫暟鎹泦锛�
+ pageFull.items.pop_back();
+ }
+
+ // 涔嬪悗姝e父鎸� page 鏋勫缓
+ auto& page = pageFull; // 涓轰簡澶嶇敤浣犲師鏈夊彉閲忓悕
+
+ // 寤虹储寮曪細classId -> index
std::unordered_map<std::string, size_t> idxById;
idxById.reserve(page.items.size());
- for (size_t i = 0; i < page.items.size(); ++i) idxById[page.items[i].classId] = i;
+ for (size_t i = 0; i < page.items.size(); ++i) {
+ idxById[page.items[i].classId] = i;
+ }
- std::unordered_set<std::string> usedDb;
+ // 宸叉秷璐癸紙宸叉彃鍏ヤ负鐖舵垨瀛愶級
+ std::unordered_set<std::string> consumed;
int zebra = 0;
+ auto zebraBk = [&](int z) -> COLORREF {
+ return (z % 2 == 0) ? RGB(255, 255, 255) : RGB(235, 235, 235);
+ };
+ // -------- Phase 1: 鍏堝鐞嗏�滄湁 buddyId 鐨勮褰曗�濓紙鑳介厤灏遍厤锛涘崟鍚戜篃閰嶏級 ----------
for (size_t i = 0; i < page.items.size(); ++i) {
const auto& r = page.items[i];
- if (usedDb.count(r.classId)) continue;
+ // CopyUtf8ToClipboard(r.pretty);
+
+ if (consumed.count(r.classId)) continue;
+ if (r.buddyId.empty()) continue;
- COLORREF bk = (zebra % 2 == 0) ? RGB(255, 255, 255) : RGB(235, 235, 235);
- bool paired = false;
+ COLORREF bk = zebraBk(zebra);
- if (!r.buddyId.empty()) {
- auto it = idxById.find(r.buddyId);
- if (it != idxById.end()) {
- const auto& br = page.items[it->second];
- if (!usedDb.count(br.classId)) {
- bool rIsParent = (r.classId <= br.classId);
- const auto& parentRec = rIsParent ? r : br;
- const auto& childRec = rIsParent ? br : r;
+ auto it = idxById.find(r.buddyId);
+ if (it != idxById.end()) {
+ const auto& br = page.items[it->second];
+ if (!consumed.count(br.classId)) {
+ // 鈥斺�� 浠モ�滄湁 buddyId 鐨勮繖鏉� r鈥濅负鐖讹紝buddy 浣滀负瀛愶紙鍗曞悜涔熻兘閰嶏級鈥斺��
+ std::vector<CString> pcols(colCount);
+ pcols[1] = std::to_string(r.id).c_str();
+ pcols[2] = std::to_string(r.cassetteSeqNo).c_str();
+ pcols[3] = std::to_string(r.jobSeqNo).c_str();
+ pcols[4] = r.classId.c_str();
+ pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
+ pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
+ pcols[7] = r.tStart.c_str();
+ pcols[8] = r.tEnd.c_str();
+ pcols[9] = r.buddyId.c_str();
+ pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
+ pcols[11] = r.path.c_str();
+ pcols[12] = r.params.c_str();
- std::vector<CString> pcols(colCount);
- pcols[1] = std::to_string(parentRec.id).c_str(); pcols[2] = std::to_string(parentRec.cassetteSeqNo).c_str();
- pcols[3] = std::to_string(parentRec.jobSeqNo).c_str(); pcols[4] = parentRec.classId.c_str();
- pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)parentRec.materialType).c_str();
- pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)parentRec.state).c_str();
- pcols[7] = parentRec.tStart.c_str(); pcols[8] = parentRec.tEnd.c_str(); pcols[9] = parentRec.buddyId.c_str();
- pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)parentRec.aoiResult).c_str();
- pcols[11] = parentRec.path.c_str(); pcols[12] = parentRec.params.c_str();
+ auto* nParent = m_listCtrl.InsertRoot(pcols);
+ MaybeRestoreExpandByKey(nParent, expandedKeys);
+ m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
- auto* nParent = m_listCtrl.InsertRoot(pcols);
- MaybeRestoreExpandByKey(nParent, expandedKeys);
- m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
+ std::vector<CString> ccols(colCount);
+ ccols[1] = std::to_string(br.id).c_str();
+ ccols[2] = std::to_string(br.cassetteSeqNo).c_str();
+ ccols[3] = std::to_string(br.jobSeqNo).c_str();
+ ccols[4] = br.classId.c_str();
+ ccols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)br.materialType).c_str();
+ ccols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)br.state).c_str();
+ ccols[7] = br.tStart.c_str();
+ ccols[8] = br.tEnd.c_str();
+ ccols[9] = br.buddyId.c_str();
+ ccols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)br.aoiResult).c_str();
+ ccols[11] = br.path.c_str();
+ ccols[12] = br.params.c_str();
- std::vector<CString> ccols(colCount);
- ccols[1] = std::to_string(childRec.id).c_str(); ccols[2] = std::to_string(childRec.cassetteSeqNo).c_str();
- ccols[3] = std::to_string(childRec.jobSeqNo).c_str(); ccols[4] = childRec.classId.c_str();
- ccols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)childRec.materialType).c_str();
- ccols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)childRec.state).c_str();
- ccols[7] = childRec.tStart.c_str(); ccols[8] = childRec.tEnd.c_str(); ccols[9] = childRec.buddyId.c_str();
- ccols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)childRec.aoiResult).c_str();
- ccols[11] = childRec.path.c_str(); ccols[12] = childRec.params.c_str();
+ auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
+ m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
- auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
- m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
-
- usedDb.insert(parentRec.classId);
- usedDb.insert(childRec.classId);
- paired = true;
- }
+ consumed.insert(r.classId);
+ consumed.insert(br.classId);
+ ++zebra;
+ continue;
}
}
- if (!paired && !r.buddyId.empty()) {
- std::vector<CString> pcols(colCount);
- pcols[1] = std::to_string(r.id).c_str(); pcols[2] = std::to_string(r.cassetteSeqNo).c_str();
- pcols[3] = std::to_string(r.jobSeqNo).c_str(); pcols[4] = r.classId.c_str();
- pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
- pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
- pcols[7] = r.tStart.c_str(); pcols[8] = r.tEnd.c_str(); pcols[9] = r.buddyId.c_str();
- pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
- pcols[11] = r.path.c_str(); pcols[12] = r.params.c_str();
+ // 鍚岄〉娌℃壘鍒� buddy锛堟垨宸茶娑堣垂锛夆啋 鎻掑崰浣嶅瓙琛�
+ std::vector<CString> pcols(colCount);
+ pcols[1] = std::to_string(r.id).c_str();
+ pcols[2] = std::to_string(r.cassetteSeqNo).c_str();
+ pcols[3] = std::to_string(r.jobSeqNo).c_str();
+ pcols[4] = r.classId.c_str();
+ pcols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
+ pcols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
+ pcols[7] = r.tStart.c_str();
+ pcols[8] = r.tEnd.c_str();
+ pcols[9] = r.buddyId.c_str();
+ pcols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
+ pcols[11] = r.path.c_str();
+ pcols[12] = r.params.c_str();
- auto* nParent = m_listCtrl.InsertRoot(pcols);
- MaybeRestoreExpandByKey(nParent, expandedKeys);
- m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
+ auto* nParent = m_listCtrl.InsertRoot(pcols);
+ MaybeRestoreExpandByKey(nParent, expandedKeys);
+ m_listCtrl.SetNodeColor(nParent, RGB(0, 0, 0), bk);
- std::vector<CString> ccols(colCount);
- ccols[4] = r.buddyId.c_str(); // 鍗犱綅瀛愯锛氭樉绀� buddy 鐨� classId
- auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
- m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
+ std::vector<CString> ccols(colCount); // 鍗犱綅鍙啓 ClassID
+ ccols[4] = r.buddyId.c_str();
+ auto* nChild = m_listCtrl.InsertChild(nParent, ccols);
+ m_listCtrl.SetNodeColor(nChild, RGB(0, 0, 0), bk);
- usedDb.insert(r.classId);
- paired = true;
- }
+ consumed.insert(r.classId);
+ ++zebra;
+ }
- if (!paired) {
- std::vector<CString> cols(colCount);
- cols[1] = std::to_string(r.id).c_str(); cols[2] = std::to_string(r.cassetteSeqNo).c_str();
- cols[3] = std::to_string(r.jobSeqNo).c_str(); cols[4] = r.classId.c_str();
- cols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
- cols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
- cols[7] = r.tStart.c_str(); cols[8] = r.tEnd.c_str(); cols[9] = r.buddyId.c_str();
- cols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
- cols[11] = r.path.c_str(); cols[12] = r.params.c_str();
+ // -------- Phase 2: 鍓╀綑鏈秷璐圭殑锛屼綔涓衡�滃崟鏉℃牴琛屸�� ----------
+ for (size_t i = 0; i < page.items.size(); ++i) {
+ const auto& r = page.items[i];
+ if (consumed.count(r.classId)) continue;
- auto* n = m_listCtrl.InsertRoot(cols);
- m_listCtrl.SetNodeColor(n, RGB(0, 0, 0), bk);
- usedDb.insert(r.classId);
- }
+ COLORREF bk = zebraBk(zebra);
+ std::vector<CString> cols(colCount);
+ cols[1] = std::to_string(r.id).c_str();
+ cols[2] = std::to_string(r.cassetteSeqNo).c_str();
+ cols[3] = std::to_string(r.jobSeqNo).c_str();
+ cols[4] = r.classId.c_str();
+ cols[5] = SERVO::CServoUtilsTool::getMaterialsTypeText((SERVO::MaterialsType)r.materialType).c_str();
+ cols[6] = SERVO::CServoUtilsTool::getGlassStateText((SERVO::GlsState)r.state).c_str();
+ cols[7] = r.tStart.c_str();
+ cols[8] = r.tEnd.c_str();
+ cols[9] = r.buddyId.c_str();
+ cols[10] = SERVO::CServoUtilsTool::getInspResultText((SERVO::InspResult)r.aoiResult).c_str();
+ cols[11] = r.path.c_str();
+ cols[12] = r.params.c_str();
+
+ auto* n = m_listCtrl.InsertRoot(cols);
+ m_listCtrl.SetNodeColor(n, RGB(0, 0, 0), bk);
+
+ consumed.insert(r.classId);
++zebra;
}
@@ -727,6 +824,7 @@
m_rebuilding = false;
}
+
void CPageGlassList::UpdatePageControls()
{
@@ -768,8 +866,8 @@
CString headers[] = {
_T(""),
_T("id"),
- _T("Cassette Sequence No"),
- _T("Job Sequence No"),
+ _T("Cassette SN"),
+ _T("Job SN"),
_T("Class ID"),
_T("鐗╂枡绫诲瀷"),
_T("鐘舵��"),
@@ -848,7 +946,7 @@
{
if (nIDEvent == 1) {
KillTimer(1);
- InitRxWindow();
+ InitRxWindows();
}
else if (nIDEvent == 2) {
UpdateWipData(); // 鍙仛澧為噺锛屼笉閲嶅缓
@@ -966,8 +1064,12 @@
void CPageGlassList::OnShowFullText(NMHDR* pNMHDR, LRESULT* pResult)
{
auto* p = reinterpret_cast<NMC_ELC_SHOWFULLTEXT*>(pNMHDR);
- // 杩欓噷鏆傛椂鐢ㄦ秷鎭鏄剧ず锛涘悗缁彲鎹㈡垚浣犵殑璇︽儏椤�
- MessageBox(p->text, _T("璇︾粏淇℃伅"), MB_OK | MB_ICONINFORMATION);
+
+ // 瀵硅瘽妗嗘樉绀哄伐鑹哄弬鏁�
+ CProcessDataListDlg dlg;
+ dlg.setRawText(p->text);
+ dlg.DoModal();
+
*pResult = 0;
}
@@ -1294,3 +1396,12 @@
return true;
}
+
+BOOL CPageGlassList::PreTranslateMessage(MSG* pMsg)
+{
+ if (pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE) {
+ return TRUE;
+ }
+
+ return CDialogEx::PreTranslateMessage(pMsg);
+}
--
Gitblit v1.9.3