From 80c5a369c116280921e8d5668e3fcde894668c7e Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 07 十二月 2024 17:08:24 +0800
Subject: [PATCH] 1.轴定位按钮、回原点按钮根据PLC相关位状态闪烁;

---
 SourceCode/Bond/BondEq/BlButton.h                    |    1 
 SourceCode/Bond/BondEq/View/AxisSettingsDlg.h        |   14 +++-
 SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp      |  110 ++++++++++++++++++++++++++++++++++++
 SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp |   35 ++++++-----
 SourceCode/Bond/BondEq/BlButton.cpp                  |    6 ++
 SourceCode/Bond/BondEq/Common.h                      |   14 +++-
 6 files changed, 157 insertions(+), 23 deletions(-)

diff --git a/SourceCode/Bond/BondEq/BlButton.cpp b/SourceCode/Bond/BondEq/BlButton.cpp
index 4e31082..5eb7694 100644
--- a/SourceCode/Bond/BondEq/BlButton.cpp
+++ b/SourceCode/Bond/BondEq/BlButton.cpp
@@ -151,6 +151,12 @@
 {
 	m_nFlashState = 0;
 	KillTimer(1);
+	Invalidate();
+}
+
+BOOL CBlButton::IsFlash()
+{
+	return m_nFlashState != 0;
 }
 
 void CBlButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
diff --git a/SourceCode/Bond/BondEq/BlButton.h b/SourceCode/Bond/BondEq/BlButton.h
index 5b9d5ca..7b9bcea 100644
--- a/SourceCode/Bond/BondEq/BlButton.h
+++ b/SourceCode/Bond/BondEq/BlButton.h
@@ -52,6 +52,7 @@
 	void SetIcon(HICON hIcon, HICON hIconGray, int width);
 	void Flash(int ms);
 	void StopFlash();
+	BOOL IsFlash();
 
 private:
 	BOOL CustomBitBlt(HDC hDC, LPRECT lprc, CString& strBkgndBmp, int nFrame, int nAllFrame,
diff --git a/SourceCode/Bond/BondEq/Common.h b/SourceCode/Bond/BondEq/Common.h
index 5560bbf..8c949bd 100644
--- a/SourceCode/Bond/BondEq/Common.h
+++ b/SourceCode/Bond/BondEq/Common.h
@@ -93,10 +93,10 @@
 /* 轴设定页面颜色定义 */
 
 /* 5个按钮页, 按钮背景色,正常状态*/
-#define BTN_PAGE_FACE_NORMAL_COLOR		RGB(240, 240, 240)
-#define BTN_PAGE_FACE_SELECT_COLOR		RGB(0, 122, 204)
+#define BTN_PAGE_FACE_NORMAL_COLOR		RGB(0, 168, 0)
+#define BTN_PAGE_FACE_SELECT_COLOR		RGB(0, 232, 0)
 #define BTN_PAGE_TEXT_NORMAL_COLOR		RGB(22, 22, 22)
-#define BTN_PAGE_TEXT_SELECT_COLOR		RGB(222, 222, 222)
+#define BTN_PAGE_TEXT_SELECT_COLOR		RGB(22, 22, 22)
 
 /* JOG+, JOG-*/
 #define BTN_JOG_FRAME_NORMAL			RGB(88, 88, 88)
@@ -130,6 +130,14 @@
 #define BTN_OPR_BKGND_HOVER				RGB(208, 208, 222)
 #define BTN_OPR_BKGND_PRESS				RGB(0, 232, 0)
 
+/* 定位按钮 */
+#define BTN_POINT_FRAME_NORMAL			RGB(88, 88, 88)
+#define BTN_POINT_FRAME_HOVER			RGB(88, 88, 88)
+#define BTN_POINT_FRAME_PRESS			RGB(88, 88, 88)
+#define BTN_POINT_BKGND_NORMAL			RGB(222, 222, 222)
+#define BTN_POINT_BKGND_HOVER			RGB(208, 208, 222)
+#define BTN_POINT_BKGND_PRESS			RGB(0, 232, 0)
+
 
 /* 按钮id */
 #define VIEW_TOOL_BTN_CLOSE				0x1016
diff --git a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
index 43105ef..004463c 100644
--- a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
+++ b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
@@ -113,25 +113,30 @@
         axisNode.append_attribute("start_address") = axisInfo.startAddress.c_str();
 
         // 保存 ValueRange 值
-        axisNode.append_child("jog_distance").append_attribute("min") = axisInfo.jogDistance.minValue;
-        axisNode.append_child("jog_distance").append_attribute("max") = axisInfo.jogDistance.maxValue;
-        axisNode.append_child("jog_distance").append_attribute("current") = axisInfo.jogDistance.currentValue;
+        auto jog_distance = axisNode.append_child("jog_distance");
+        jog_distance.append_attribute("min") = axisInfo.jogDistance.minValue;
+        jog_distance.append_attribute("max") = axisInfo.jogDistance.maxValue;
+        jog_distance.append_attribute("current") = axisInfo.jogDistance.currentValue;
 
-        axisNode.append_child("manual_speed").append_attribute("min") = axisInfo.manualSpeed.minValue;
-        axisNode.append_child("manual_speed").append_attribute("max") = axisInfo.manualSpeed.maxValue;
-        axisNode.append_child("manual_speed").append_attribute("current") = axisInfo.manualSpeed.currentValue;
+        auto manual_speed = axisNode.append_child("manual_speed");
+        manual_speed.append_attribute("min") = axisInfo.manualSpeed.minValue;
+        manual_speed.append_attribute("max") = axisInfo.manualSpeed.maxValue;
+        manual_speed.append_attribute("current") = axisInfo.manualSpeed.currentValue;
 
-        axisNode.append_child("auto_speed").append_attribute("min") = axisInfo.autoSpeed.minValue;
-        axisNode.append_child("auto_speed").append_attribute("max") = axisInfo.autoSpeed.maxValue;
-        axisNode.append_child("auto_speed").append_attribute("current") = axisInfo.autoSpeed.currentValue;
+        auto auto_speed = axisNode.append_child("auto_speed");
+        auto_speed.append_attribute("min") = axisInfo.autoSpeed.minValue;
+        auto_speed.append_attribute("max") = axisInfo.autoSpeed.maxValue;
+        auto_speed.append_attribute("current") = axisInfo.autoSpeed.currentValue;
 
-        axisNode.append_child("acceleration_time").append_attribute("min") = axisInfo.accelerationTime.minValue;
-        axisNode.append_child("acceleration_time").append_attribute("max") = axisInfo.accelerationTime.maxValue;
-        axisNode.append_child("acceleration_time").append_attribute("current") = axisInfo.accelerationTime.currentValue;
+        auto acceleration_time = axisNode.append_child("acceleration_time");
+        acceleration_time.append_attribute("min") = axisInfo.accelerationTime.minValue;
+        acceleration_time.append_attribute("max") = axisInfo.accelerationTime.maxValue;
+        acceleration_time.append_attribute("current") = axisInfo.accelerationTime.currentValue;
 
-        axisNode.append_child("deceleration_time").append_attribute("min") = axisInfo.decelerationTime.minValue;
-        axisNode.append_child("deceleration_time").append_attribute("max") = axisInfo.decelerationTime.maxValue;
-        axisNode.append_child("deceleration_time").append_attribute("current") = axisInfo.decelerationTime.currentValue;
+        auto deceleration_time = axisNode.append_child("deceleration_time");
+        deceleration_time.append_attribute("min") = axisInfo.decelerationTime.minValue;
+        deceleration_time.append_attribute("max") = axisInfo.decelerationTime.maxValue;
+        deceleration_time.append_attribute("current") = axisInfo.decelerationTime.currentValue;
 
         // 保存 PositionRange 值
         auto positionsNode = axisNode.append_child("Positions");
diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
index b54b4b1..76c93ac 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
@@ -45,6 +45,8 @@
 	for (int i = 0; i < 6; i++) {
 		m_pBlLabels[i] = new CBLLabel();
 	}
+	m_nBtnsFlashState6 = 0;
+	m_nBtnsFlashState8 = 0;
 }
 
 CAxisSettingsDlg::~CAxisSettingsDlg()
@@ -735,6 +737,19 @@
 			m_bBusy = CToolUnits::getBit(pData[10 * 2 + 1], 0xB - 8);
 			m_bErr = CToolUnits::getBit(pData[10 * 2 + 1], 0xF - 8);
 
+			// 璁板綍鎸夐挳鍒锋柊鐘舵��
+			// 6,7,8,9涓哄師鐐瑰拰25涓偣浣嶇姸鎬佸拰瀹屾垚鐘舵��
+			// ZR 06.0 鍜� 08.0
+			// 鍥炲師鐐硅繍鍔ㄤ腑锛孼R06.0鍦�0鍜�1涓垏鎹紝鍥炲師鐐瑰畬鎴愶紝 08.0涓�1
+			// 瀹氫綅1
+			// ZR 06.1 鍜� 08.1
+			// ...
+			int b = 6 * 2;
+			m_nBtnsFlashState6 = ((BYTE)pData[b] | (BYTE)pData[b + 1] << 8);
+			m_nBtnsFlashState6 |= ((BYTE)pData[b + 2] << 16 | (BYTE)pData[b + 3] << 24);
+			m_nBtnsFlashState8 = ((BYTE)pData[b + 4] | (BYTE)pData[b + 5] << 8);
+			m_nBtnsFlashState8 |= ((BYTE)pData[b + 6] << 16 | (BYTE)pData[b + 7] << 24);
+
 			PostMessage(ID_MSG_UPDATA_DATA_TO_UI);
 		}
 	};
@@ -854,6 +869,18 @@
 	m_pBlBtns[BTN_JOG_OPR]->SetBkgndColor(BS_NORMAL, BTN_OPR_BKGND_NORMAL);
 	m_pBlBtns[BTN_JOG_OPR]->SetBkgndColor(BS_HOVER, BTN_OPR_BKGND_HOVER);
 	m_pBlBtns[BTN_JOG_OPR]->SetBkgndColor(BS_PRESS, BTN_OPR_BKGND_PRESS);
+	static UINT btnPointIds[] = { IDC_BUTTON_AXIS_ANCHOR_POINT1, IDC_BUTTON_AXIS_ANCHOR_POINT2,
+		IDC_BUTTON_AXIS_ANCHOR_POINT3, IDC_BUTTON_AXIS_ANCHOR_POINT4, IDC_BUTTON_AXIS_ANCHOR_POINT5};
+	for (int i = 0; i < 5; i++) {
+		m_pBlBtns[BTN_POINT1 + i]->SubclassDlgItem(btnPointIds[i], this);
+		m_pBlBtns[BTN_POINT1 + i]->SetFrameColor(BS_NORMAL, BTN_POINT_FRAME_NORMAL);
+		m_pBlBtns[BTN_POINT1 + i]->SetFrameColor(BS_HOVER, BTN_POINT_FRAME_HOVER);
+		m_pBlBtns[BTN_POINT1 + i]->SetFrameColor(BS_PRESS, BTN_POINT_FRAME_PRESS);
+		m_pBlBtns[BTN_POINT1 + i]->SetBkgndColor(BS_NORMAL, BTN_POINT_BKGND_NORMAL);
+		m_pBlBtns[BTN_POINT1 + i]->SetBkgndColor(BS_HOVER, BTN_POINT_BKGND_HOVER);
+		m_pBlBtns[BTN_POINT1 + i]->SetBkgndColor(BS_PRESS, BTN_POINT_BKGND_PRESS);
+	}
+
 
 	// 鍒濆鍖栧綋鍓嶉〉闈负绗竴椤�
 	m_currentPage = 1;
@@ -1143,6 +1170,7 @@
 	handleAxisOperation(AxisOperationType::POSITION_1, true);
 	Sleep(200);
 	handleAxisOperation(AxisOperationType::POSITION_1, false);
+	m_pBlBtns[BTN_POINT1]->Flash(1000);
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint2()
@@ -1183,7 +1211,6 @@
 	handleAxisOperation(AxisOperationType::OPR, true);
 	Sleep(200);
 	handleAxisOperation(AxisOperationType::OPR, false);
-	m_pBlBtns[BTN_JOG_OPR]->Flash(1000);
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisTestStop()
@@ -1193,6 +1220,11 @@
 	Sleep(200);
 	handleAxisOperation(AxisOperationType::STOP, false);
 	m_pBlBtns[BTN_JOG_OPR]->StopFlash();
+	m_pBlBtns[BTN_POINT1]->StopFlash();
+	m_pBlBtns[BTN_POINT2]->StopFlash();
+	m_pBlBtns[BTN_POINT3]->StopFlash();
+	m_pBlBtns[BTN_POINT3]->StopFlash();
+	m_pBlBtns[BTN_POINT4]->StopFlash();
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisSev()
@@ -1298,6 +1330,82 @@
 		SetLabelColor(*m_pBlLabels[5], RGB(0, 180, 0));
 	}
 
+
+	// OPR鎸夐挳鏄惁瑕侀棯鐑佹垨鍋滄闂儊
+	// 06.0鍜�08.0
+	TRACE("m_nBtnsFlashState6  %x %x\n", m_nBtnsFlashState6, m_nBtnsFlashState8);
+	if (m_nBtnsFlashState6 & 0x01) {
+		// 06.0
+		if (!m_pBlBtns[BTN_JOG_OPR]->IsFlash()) {
+			m_pBlBtns[BTN_JOG_OPR]->Flash(1000);
+		}
+	}
+	else if (m_nBtnsFlashState8 & 0x01) {
+		if (m_pBlBtns[BTN_JOG_OPR]->IsFlash()) {
+			m_pBlBtns[BTN_JOG_OPR]->StopFlash();
+		}
+	}
+
+	int v = 0x02;
+	if (m_currentPage > 1) {
+		v = v << (5 * (m_currentPage - 1));
+	}
+
+	if (m_nBtnsFlashState6 & v) {
+		if (!m_pBlBtns[BTN_POINT1]->IsFlash()) {
+			m_pBlBtns[BTN_POINT1]->Flash(1000);
+		}
+	}
+	else if (m_nBtnsFlashState8 & v) {
+		if (m_pBlBtns[BTN_POINT1]->IsFlash()) {
+			m_pBlBtns[BTN_POINT1]->StopFlash();
+		}
+	}
+
+	if (m_nBtnsFlashState6 & (v << 1)) {
+		if (!m_pBlBtns[BTN_POINT2]->IsFlash()) {
+			m_pBlBtns[BTN_POINT2]->Flash(1000);
+		}
+	}
+	else if (m_nBtnsFlashState8 & (v << 1)) {
+		if (m_pBlBtns[BTN_POINT2]->IsFlash()) {
+			m_pBlBtns[BTN_POINT2]->StopFlash();
+		}
+	}
+
+	if (m_nBtnsFlashState6 & (v << 2)) {
+		if (!m_pBlBtns[BTN_POINT3]->IsFlash()) {
+			m_pBlBtns[BTN_POINT3]->Flash(1000);
+		}
+	}
+	else if (m_nBtnsFlashState8 & (v << 2)) {
+		if (m_pBlBtns[BTN_POINT3]->IsFlash()) {
+			m_pBlBtns[BTN_POINT3]->StopFlash();
+		}
+	}
+
+	if (m_nBtnsFlashState6 & (v << 3)) {
+		if (!m_pBlBtns[BTN_POINT4]->IsFlash()) {
+			m_pBlBtns[BTN_POINT4]->Flash(1000);
+		}
+	}
+	else if (m_nBtnsFlashState8 & (v << 3)) {
+		if (m_pBlBtns[BTN_POINT4]->IsFlash()) {
+			m_pBlBtns[BTN_POINT4]->StopFlash();
+		}
+	}
+
+	if (m_nBtnsFlashState6 & (v << 4)) {
+		if (!m_pBlBtns[BTN_POINT5]->IsFlash()) {
+			m_pBlBtns[BTN_POINT5]->Flash(1000);
+		}
+	}
+	else if (m_nBtnsFlashState8 & (v << 4)) {
+		if (m_pBlBtns[BTN_POINT5]->IsFlash()) {
+			m_pBlBtns[BTN_POINT5]->StopFlash();
+		}
+	}
+
 	return 0;
 }
 
diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
index 012a8ac..b05a8f7 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
@@ -5,7 +5,7 @@
 #include "CPLC.h"
 
 
-#define BTN_MAX			10
+#define BTN_MAX			15
 #define BTN_PAGE1		0
 #define BTN_PAGE2		1
 #define BTN_PAGE3		2
@@ -14,9 +14,13 @@
 #define BTN_JOG_ADD		5
 #define BTN_JOG_SUB		6
 #define BTN_JOG_SEV		7
-#define BTN_JOG_STOP	8
-#define BTN_JOG_OPR		9
-
+#define BTN_JOG_OPR		8
+#define BTN_JOG_STOP	9
+#define BTN_POINT1		10
+#define BTN_POINT2		11
+#define BTN_POINT3		12
+#define BTN_POINT4		13
+#define BTN_POINT5		14
 
 // CAxisSettingsDlg 瀵硅瘽妗�
 
@@ -109,6 +113,8 @@
 	BOOL m_bReady;
 	BOOL m_bBusy;
 	BOOL m_bErr;
+	DWORD m_nBtnsFlashState6;
+	DWORD m_nBtnsFlashState8;
 
 protected:
 	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 鏀寔

--
Gitblit v1.9.3