From 2b87741f1a372c6da84d6ae3839ff2cf6297b71f Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期二, 10 二月 2026 14:27:31 +0800
Subject: [PATCH] 1.状态图格子坐标从配置文件中读取;

---
 SourceCode/Bond/Servo/CPageGraph1.cpp |  108 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 84 insertions(+), 24 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageGraph1.cpp b/SourceCode/Bond/Servo/CPageGraph1.cpp
index b2d932a..362b63f 100644
--- a/SourceCode/Bond/Servo/CPageGraph1.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph1.cpp
@@ -229,9 +229,7 @@
 		m_slotTable.SetTitleHeight(m_slotTableTitleHeight);
 		m_slotTable.SetLineColor(lineColor);
 		m_slotTable.SetHeaderBgColor(headerBgColor);
-		LOGI("[Graph1] SlotTable create ret=%d hwnd=%p err=%lu rc=(%d,%d)-(%d,%d)",
-			created, m_slotTable.GetSafeHwnd(), GetLastError(),
-			rcTable.left, rcTable.top, rcTable.right, rcTable.bottom);
+		(void)created;
 	}
 	else {
 		m_slotTable.MoveWindow(&rcTable);
@@ -241,20 +239,16 @@
 		m_slotTable.SetTitleHeight(m_slotTableTitleHeight);
 		m_slotTable.SetLineColor(lineColor);
 		m_slotTable.SetHeaderBgColor(headerBgColor);
-		LOGI("[Graph1] SlotTable moved rc=(%d,%d)-(%d,%d)", rcTable.left, rcTable.top, rcTable.right, rcTable.bottom);
 	}
 
 	// 濡傛灉瓒呭嚭鍙鍖哄煙锛屽己鍒剁Щ鍒板乏涓婅浣滀负鍏滃簳
 	CRect rcWnd;
 	m_slotTable.GetWindowRect(&rcWnd);
 	ScreenToClient(&rcWnd);
-	LOGI("[Graph1] SlotTable wnd rc=(%d,%d)-(%d,%d) client=(%d,%d)",
-		rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, rcClient.right, rcClient.bottom);
 	if (rcWnd.right <= 0 || rcWnd.bottom <= 0 ||
 		rcWnd.left >= rcClient.right || rcWnd.top >= rcClient.bottom) {
 		CRect rcFallback(10, 10, 10 + cfgW, 10 + cfgH);
 		m_slotTable.MoveWindow(&rcFallback);
-		LOGI("[Graph1] SlotTable fallback rc=(%d,%d)-(%d,%d)", rcFallback.left, rcFallback.top, rcFallback.right, rcFallback.bottom);
 	}
 	m_slotTable.SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
 
@@ -270,7 +264,6 @@
 
 	std::vector<CSlotTableCtrl::Row> rows;
 	if (pEquipment != nullptr) {
-		LOGI("[Graph1] UpdateSlotTable eq=%s(%p)", pEquipment->getName().c_str(), pEquipment);
 		for (int i = 0; i < SLOT_MAX && rows.size() < 8; ++i) {
 			SERVO::CSlot* pSlot = pEquipment->getSlot(i);
 			if (pSlot == nullptr || !pSlot->isEnable()) continue;
@@ -291,7 +284,6 @@
 			rows.push_back(row);
 		}
 	}
-	LOGI("[Graph1] SlotTable rows=%zu", rows.size());
 
 	m_slotTableRowCount = static_cast<int>(rows.size());
 	if (m_slotTableRowCount < 1) m_slotTableRowCount = 1;
@@ -359,6 +351,14 @@
 					}
 				}
 			}
+			else if (RX_CODE_EQ_DATA_CHANGED == code
+				|| RX_CODE_LOADPORT_STATUS_CHANGED == code) {
+				// 璁惧鏁版嵁鍙樺寲鏃讹紝鍙婃椂鍒锋柊鏍煎瓙涓庡彸渚lot琛紝閬垮厤鍙湪鐐瑰嚮鏃舵洿鏂颁竴娆�
+				UpdateSlotBars();
+				if (m_pSelectedEquipment != nullptr) {
+					UpdateSlotTable(m_pSelectedEquipment);
+				}
+			}
 
 			pAny->release();
 			}, [&]() -> void {
@@ -386,8 +386,39 @@
 	if (auto* pGraphWnd = GetDlgItem(IDC_SERVO_GRAPH1)) {
 		pGraphWnd->ModifyStyle(0, WS_CLIPSIBLINGS);
 	}
+	std::string iniPath = GetConfigPath();
 	CString strPath;
-	strPath.Format(_T("%s\\res\\Servo001.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	auto resolveGraphImagePath = [&](const char* iniKey, const char* defaultName) -> CString {
+		char value[MAX_PATH] = { 0 };
+		GetPrivateProfileStringA("Graph1", iniKey, defaultName, value, (DWORD)sizeof(value), iniPath.c_str());
+		std::string file = value;
+		auto trim = [](std::string& s) {
+			while (!s.empty() && (s.front() == ' ' || s.front() == '\t' || s.front() == '\r' || s.front() == '\n')) s.erase(s.begin());
+			while (!s.empty() && (s.back() == ' ' || s.back() == '\t' || s.back() == '\r' || s.back() == '\n')) s.pop_back();
+		};
+		trim(file);
+		if (file.empty()) file = defaultName;
+
+		CString path;
+		const bool isAbs = (file.size() > 1 && file[1] == ':') || (!file.empty() && (file[0] == '\\' || file[0] == '/'));
+		if (isAbs) {
+			path = file.c_str();
+		}
+		else if (file.rfind("res\\", 0) == 0 || file.rfind("res/", 0) == 0) {
+			path.Format(_T("%s\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(file.c_str()));
+		}
+		else {
+			path.Format(_T("%s\\res\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(file.c_str()));
+		}
+
+		DWORD attr = GetFileAttributes(path);
+		if (attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY)) {
+			path.Format(_T("%s\\res\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(defaultName));
+		}
+		return path;
+	};
+
+	strPath = resolveGraphImagePath("BackgroundBmp", "Servo001.bmp");
 	m_pGraph->AddImage(1, (LPTSTR)(LPCTSTR)strPath, 0, 0);
 
 	strPath.Format(_T("%s\\res\\Robot001.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
@@ -403,7 +434,6 @@
 	// 娣诲姞鎸囩ず鍣�
 	// Bonder
 	// size config
-	std::string iniPath = GetConfigPath();
 	int boxSize = GetPrivateProfileIntA("Graph1", "BoxSize", 56, iniPath.c_str());
 	if (boxSize < 40) boxSize = 40;
 	if (boxSize > 80) boxSize = 80;
@@ -446,73 +476,96 @@
 		arm2X = baseMid + half;
 	}
 
-	m_pGraph->AddIndicateBox(INDICATE_BONDER1, 220, 172, boxSize, RGB(22, 22, 22),
+	auto readGraphPoint = [&](const char* keyPrefix, int defaultX, int defaultY) -> POINT {
+		std::string keyX = std::string(keyPrefix) + "_X";
+		std::string keyY = std::string(keyPrefix) + "_Y";
+		POINT pt = { 0 };
+		pt.x = GetPrivateProfileIntA("Graph1", keyX.c_str(), defaultX, iniPath.c_str());
+		pt.y = GetPrivateProfileIntA("Graph1", keyY.c_str(), defaultY, iniPath.c_str());
+		return pt;
+	};
+
+	const POINT ptBonder1 = readGraphPoint("Bonder1", 220, 172);
+	const POINT ptBonder2 = readGraphPoint("Bonder2", 220, 516);
+	const POINT ptFliper = readGraphPoint("Fliper", 338, 172);
+	const POINT ptAligner = readGraphPoint("Aligner", 428, 172);
+	const POINT ptLoadPort4 = readGraphPoint("LoadPort4", 518, 172);
+	const POINT ptLoadPort3 = readGraphPoint("LoadPort3", 606, 172);
+	const POINT ptLoadPort2 = readGraphPoint("LoadPort2", 690, 172);
+	const POINT ptLoadPort1 = readGraphPoint("LoadPort1", 774, 172);
+	const POINT ptRobotArm1 = readGraphPoint("RobotArm1", arm1X, armY);
+	const POINT ptRobotArm2 = readGraphPoint("RobotArm2", arm2X, armY);
+	const POINT ptVacuumBake = readGraphPoint("VacuumBake", 396, 516);
+	const POINT ptBakeCooling = readGraphPoint("BakeCooling", 566, 516);
+	const POINT ptMeasurement = readGraphPoint("Measurement", 737, 516);
+
+	m_pGraph->AddIndicateBox(INDICATE_BONDER1, ptBonder1.x, ptBonder1.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_BONDER1, "", "Bonder 1");
-	m_pGraph->AddIndicateBox(INDICATE_BONDER2, 220, 516, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_BONDER2, ptBonder2.x, ptBonder2.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_BONDER2, "", "Bonder 2");
 
 
 	// 缈昏浆
-	m_pGraph->AddIndicateBox(INDICATE_FLIPER, 338, 172, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_FLIPER, ptFliper.x, ptFliper.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_FLIPER, "", "Fliper");
 
 
 	// 瀵逛綅
-	m_pGraph->AddIndicateBox(INDICATE_ALIGNER, 428, 172, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_ALIGNER, ptAligner.x, ptAligner.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_ALIGNER, "", "Aligner");
 
 
 	// Load port 4
-	m_pGraph->AddIndicateBox(INDICATE_LPORT4, 518, 172, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_LPORT4, ptLoadPort4.x, ptLoadPort4.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_LPORT4, "", "LPort4");
 
 
 	// Load port 3
-	m_pGraph->AddIndicateBox(INDICATE_LPORT3, 606, 172, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_LPORT3, ptLoadPort3.x, ptLoadPort3.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_LPORT3, "", "LPort3");
 
 
 	// Load port 2
-	m_pGraph->AddIndicateBox(INDICATE_LPORT2, 690, 172, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_LPORT2, ptLoadPort2.x, ptLoadPort2.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_LPORT2, "", "LPort2");
 
 
 	// Load port 1
-	m_pGraph->AddIndicateBox(INDICATE_LPORT1, 774, 172, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_LPORT1, ptLoadPort1.x, ptLoadPort1.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_LPORT1, "", "LPort1");
 
 
 	// Robot
-	m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM1, arm1X, armY, armBoxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM1, ptRobotArm1.x, ptRobotArm1.y, armBoxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_ROBOT_ARM1, "", "Robot");
-	m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM2, arm2X, armY, armBoxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_ROBOT_ARM2, ptRobotArm2.x, ptRobotArm2.y, armBoxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_ROBOT_ARM2, "", "Robot");
 
 
 	// Vacuum bake
-	m_pGraph->AddIndicateBox(INDICATE_VACUUM_BAKE, 396, 516, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_VACUUM_BAKE, ptVacuumBake.x, ptVacuumBake.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_VACUUM_BAKE, "", "Vacuum bake");
 
 
 	// Bake cooling
-	m_pGraph->AddIndicateBox(INDICATE_BAKE_COOLING, 566, 516, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_BAKE_COOLING, ptBakeCooling.x, ptBakeCooling.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_BAKE_COOLING, "", "Bake cooling");
 
 
 	// 绮惧害妫�
-	m_pGraph->AddIndicateBox(INDICATE_MEASUREMENT, 737, 516, boxSize, RGB(22, 22, 22),
+	m_pGraph->AddIndicateBox(INDICATE_MEASUREMENT, ptMeasurement.x, ptMeasurement.y, boxSize, RGB(22, 22, 22),
 		RGB(255, 127, 39), EQ_BOX_OFFLINE);
 	m_pGraph->SetBoxText(INDICATE_MEASUREMENT, "", "Measurement");
 
@@ -1020,6 +1073,9 @@
 		SERVO::CEFEM* pEFEM = (SERVO::CEFEM*)theApp.m_model.m_master.getEquipment(EQ_ID_EFEM);
 		if (!pEFEM || !pEFEM->isAlive()) {
 			UpdateSlotBars();
+			if (m_pSelectedEquipment != nullptr) {
+				UpdateSlotTable(m_pSelectedEquipment);
+			}
 			return;
 		}
 
@@ -1045,6 +1101,10 @@
 		}
 
 		UpdateSlotBars();
+		if (m_pSelectedEquipment != nullptr) {
+			// 瀹氭椂鍏滃簳锛氬嵆浣挎紡鎺変簨浠堕�氱煡锛屼篃纭繚鍙充晶Slot琛ㄦ寔缁埛鏂�
+			UpdateSlotTable(m_pSelectedEquipment);
+		}
 	}
 	else if (nIDEvent == TIMER_ID_ROBOT_ANIMATION) {
 		if (!m_bIsRobotMoving) {

--
Gitblit v1.9.3