From 1f5df45b8e213de70e91a7ca54d6e2219cd967ca Mon Sep 17 00:00:00 2001
From: darker <mr.darker@163.com>
Date: 星期二, 18 二月 2025 11:07:25 +0800
Subject: [PATCH] 1. 添加获取plc心跳修改状态

---
 SourceCode/Bond/Servo/ServoDlg.cpp |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 292467f..07bce45 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -144,6 +144,21 @@
 					ShowTerminalText(pszText);
 				}
 			}
+			else if (RX_CODE_EQ_ALIVE == code) {
+				// 通知设备状态
+				SERVO::CEquipment* pEquipment = nullptr;
+				if (pAny->getPtrValue("ptr", (void*&)pEquipment)) {
+					if (pEquipment != nullptr) {
+						int nID = pEquipment->getID();
+						BOOL bAlive = pEquipment->isAlive();
+						if (1 == nID) {
+							DeviceStatus status = bAlive ? DeviceStatus::ONLINE : DeviceStatus::OFFLINE;
+							UpdateDeviceStatus(INDICATE_ROBOT_ARM1, status);
+							UpdateDeviceStatus(INDICATE_ROBOT_ARM2, status);
+						}
+					}
+				}
+			}
 			pAny->release();
 		}, [&]() -> void {
 			// onComplete
@@ -660,12 +675,12 @@
 	COLORREF newFrameColor2;
 
 	switch (status) {
-	case Online:
+	case ONLINE:
 		newBackgroundColor = RGB(255, 0, 0);
 		newFrameColor1 = RGB(22, 22, 22);
 		newFrameColor2 = RGB(255, 127, 39);
 		break;
-	case Offline:
+	case OFFLINE:
 		newBackgroundColor = RGB(0, 255, 0);
 		newFrameColor1 = RGB(22, 22, 22);
 		newFrameColor2 = RGB(255, 127, 39);

--
Gitblit v1.9.3