From d14420e7f85b5fe7289aafe6bef0c053dede3657 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期五, 16 一月 2026 11:20:39 +0800
Subject: [PATCH] 1.修复以下问题: CEID 校验恒通过:ceidDefined 返回 true,PauseEvent ID 不做有效性检查。Host 若下发无效 CEID,将被接受但运行时无法触发暂停,风险难以察觉。 建议的上线前防护 / 改进(无需真机也可先改) 2.软件侧警告id上抛;
---
SourceCode/Bond/Servo/ServoDlg.cpp | 134 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 124 insertions(+), 10 deletions(-)
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index c886f66..77e626f 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -93,9 +93,11 @@
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_crBkgnd = APPDLG_BACKGROUND_COLOR;
m_hbrBkgnd = nullptr;
+ m_nLeftPanelType = 2;
m_pTerminalDisplayDlg = nullptr;
m_pObserver = nullptr;
m_pPanelMaster = nullptr;
+ m_pPanelProduction = nullptr;
m_pPanelEquipment = nullptr;
m_pPanelAttributes = nullptr;
m_pPageGraph1 = nullptr;
@@ -141,6 +143,10 @@
ON_UPDATE_COMMAND_UI(ID_MENU_TEST_MESSAGE_CLEAR, &CServoDlg::OnUpdateMenuTestMessageClear)
ON_COMMAND(ID_MENU_TOOLS_CLIENT_LIST, &CServoDlg::OnMenuToolsClientList)
ON_UPDATE_COMMAND_UI(ID_MENU_TOOLS_CLIENT_LIST, &CServoDlg::OnUpdateMenuToolsClientList)
+ ON_COMMAND(ID_MENU_WND_TEST_PANEL, &CServoDlg::OnMenuWndTestPanel)
+ ON_UPDATE_COMMAND_UI(ID_MENU_WND_TEST_PANEL, &CServoDlg::OnUpdateMenuWndTestPanel)
+ ON_COMMAND(ID_MENU_WND_PRO_PANEL, &CServoDlg::OnMenuWndProPanel)
+ ON_UPDATE_COMMAND_UI(ID_MENU_WND_PRO_PANEL, &CServoDlg::OnUpdateMenuWndProPanel)
ON_COMMAND(ID_MENU_HELP_ABOUT, &CServoDlg::OnMenuHelpAbout)
ON_WM_INITMENUPOPUP()
ON_WM_TIMER()
@@ -253,6 +259,27 @@
SetTimer(TIMER_ID_UPDATE_RUMTIME, 500, nullptr);
}
}
+ else if (RX_CODE_CONTROLJOB_CHANGED == code) {
+ auto* cj = theApp.m_model.getMaster().getControlJob();
+ CString text;
+ if (cj != nullptr) {
+ std::string st = cj->getStateText();
+ text.Format(_T("ControlJob: %S (%S)"), cj->id().c_str(), st.c_str());
+ if (cj->state() == SERVO::CJState::Paused) {
+ text += _T(" [Paused]");
+ }
+ }
+ else {
+ text = _T("ControlJob: None");
+ }
+ if (m_pMyStatusbar != nullptr) {
+ m_pMyStatusbar->setRunTimeText((LPTSTR)(LPCTSTR)text);
+ if (cj != nullptr && cj->state() == SERVO::CJState::Paused) {
+ m_pMyStatusbar->setBackgroundColor(STATUSBAR_BK_ALARM);
+ m_pMyStatusbar->setForegroundColor(RGB(0, 0, 0));
+ }
+ }
+ }
else if (RX_CODE_EQ_ROBOT_TASK == code) {
int exCode;
if (pAny->getIntValue("exCode", exCode)) {
@@ -306,18 +333,18 @@
if (STATE::NOT_CONNECTED == state) {
m_pMyStatusbar->setCimBtnText("Disconnected");
- //m_labelPassiveState.setBackground(DISCONNECTED_BACKGROUND);
- //m_labelPassiveState.setForeground(DISCONNECTED_FOREGROUND, TRUE);
+ m_pMyStatusbar->setCimBtnColors(
+ CIM_STATUS_BK_DISCONNECTED, CIM_STATUS_BK_DISCONNECTED, RGB(0, 0, 0));
}
else if (STATE::NOT_SELECTED == state) {
m_pMyStatusbar->setCimBtnText("Not Selected");
- //m_labelPassiveState.setBackground(NOT_SELECTED_BACKGROUND);
- //m_labelPassiveState.setForeground(NOT_SELECTED_FOREGROUND, TRUE);
+ m_pMyStatusbar->setCimBtnColors(
+ CIM_STATUS_BK_DISCONNECTED, CIM_STATUS_BK_DISCONNECTED, RGB(0, 0, 0));
}
else if (STATE::SELECTED == state) {
m_pMyStatusbar->setCimBtnText("Selected");
- //m_labelPassiveState.setBackground(SELECTED_BACKGROUND);
- //m_labelPassiveState.setForeground(SELECTED_FOREGROUND, TRUE);
+ m_pMyStatusbar->setCimBtnColors(
+ CIM_STATUS_BK_SELECTED, CIM_STATUS_BK_SELECTED, RGB(0, 0, 0));
}
}
pAny->release();
@@ -422,10 +449,19 @@
m_pTab->SetBkgndColor(RGB(222, 222, 222));
ShowChildPage(0);
+ // 璇诲彇闈㈡澘瀹�
+ CString strIniFile;
+ strIniFile.Format(_T("%s\\%s.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, (LPTSTR)(LPCTSTR)theApp.m_strAppFile);
+ int nPanelWidth = GetPrivateProfileInt(_T("App"), _T("MasterPanelWidth"),
+ int((double)GetSystemMetrics(SM_CXSCREEN) * 0.25), (LPTSTR)(LPCTSTR)strIniFile);
m_pPanelMaster = new CPanelMaster();
+ m_pPanelMaster->setPanelWidth(nPanelWidth);
m_pPanelMaster->Create(IDD_PANEL_MASTER, this);
- m_pPanelMaster->ShowWindow(SW_SHOW);
+ m_pPanelProduction = new CPanelProduction();
+ m_pPanelProduction->setPanelWidth(nPanelWidth);
+ m_pPanelProduction->Create(IDD_PANEL_PRODUCTION, this);
+ SetLeftPanelType(m_nLeftPanelType, false);
m_pPanelEquipment = new CPanelEquipment();
m_pPanelEquipment->Create(IDD_PANEL_EQUIPMENT, this);
m_pPanelAttributes = new CPanelAttributes();
@@ -638,6 +674,10 @@
pPage3->Create(IDD_PAGE_VARIABLE);
dlg.addPage(pPage3, "Variable");
+ CPageDataVarialbles* pPage4 = new CPageDataVarialbles();
+ pPage4->Create(IDD_PAGE_VARIABLE);
+ dlg.addPage(pPage4, "DataVariable");
+
dlg.DoModal();
}
@@ -683,6 +723,28 @@
void CServoDlg::OnUpdateMenuToolsClientList(CCmdUI* pCmdUI)
{
pCmdUI->Enable(TRUE);
+}
+
+void CServoDlg::OnMenuWndTestPanel()
+{
+ SetLeftPanelType(1);
+}
+
+void CServoDlg::OnUpdateMenuWndTestPanel(CCmdUI* pCmdUI)
+{
+ pCmdUI->Enable(TRUE);
+ pCmdUI->SetCheck(m_nLeftPanelType == 1);
+}
+
+void CServoDlg::OnMenuWndProPanel()
+{
+ SetLeftPanelType(2);
+}
+
+void CServoDlg::OnUpdateMenuWndProPanel(CCmdUI* pCmdUI)
+{
+ pCmdUI->Enable(TRUE);
+ pCmdUI->SetCheck(m_nLeftPanelType == 2);
}
void CServoDlg::OnMenuHelpAbout()
@@ -754,6 +816,12 @@
m_pPanelMaster->DestroyWindow();
delete m_pPanelMaster;
m_pPanelMaster = nullptr;
+ }
+
+ if (m_pPanelProduction != nullptr) {
+ m_pPanelProduction->DestroyWindow();
+ delete m_pPanelProduction;
+ m_pPanelProduction = nullptr;
}
if (m_pPanelEquipment != nullptr) {
@@ -856,9 +924,16 @@
int nPanelWidth = 0;
- if (m_pPanelMaster != nullptr) {
+ if (m_pPanelMaster != nullptr && ::IsWindow(m_pPanelMaster->GetSafeHwnd())
+ && m_pPanelMaster->IsWindowVisible()) {
nPanelWidth = m_pPanelMaster->getPanelWidth();
m_pPanelMaster->MoveWindow(x, y, nPanelWidth, y2 - y);
+ x += nPanelWidth;
+ }
+
+ if (m_pPanelProduction != nullptr && m_pPanelProduction->IsWindowVisible()) {
+ nPanelWidth = m_pPanelProduction->getPanelWidth();
+ m_pPanelProduction->MoveWindow(x, y, nPanelWidth, y2 - y);
x += nPanelWidth;
}
@@ -891,6 +966,32 @@
m_pMyStatusbar->MoveWindow(0, y2, rcClient.Width(), STATUSBAR_HEIGHT);
+}
+
+void CServoDlg::SetLeftPanelType(int type, bool resize)
+{
+ if (type != 1 && type != 2) {
+ type = 1;
+ }
+
+ m_nLeftPanelType = type;
+ if (m_pPanelMaster != nullptr) {
+ m_pPanelMaster->ShowWindow(SW_HIDE);
+ }
+ if (m_pPanelProduction != nullptr) {
+ m_pPanelProduction->ShowWindow(SW_HIDE);
+ }
+ if (type == 1 && m_pPanelMaster != nullptr) {
+ m_pPanelMaster->ShowWindow(SW_SHOW);
+ }
+ else if (type == 2 && m_pPanelProduction != nullptr) {
+ m_pPanelProduction->ShowWindow(SW_SHOW);
+ }
+
+ if (resize && ::IsWindow(m_hWnd)) {
+ Resize();
+ DrawMenuBar();
+ }
}
void CServoDlg::OnClose()
@@ -965,7 +1066,20 @@
LRESULT CServoDlg::OnPanelResize(WPARAM wParam, LPARAM lParam)
{
int width = (int)wParam;
- // m_pPanel->SetPanelWidth(width);
+
+ if (m_pPanelMaster != nullptr) {
+ m_pPanelMaster->setPanelWidth(width);
+ }
+ if (m_pPanelProduction != nullptr) {
+ m_pPanelProduction->setPanelWidth(width);
+ }
+
+ CString strIniFile, strValue;
+ strIniFile.Format(_T("%s\\%s.ini"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, (LPTSTR)(LPCTSTR)theApp.m_strAppFile);
+ strValue.Format(_T("%d"), width);
+ WritePrivateProfileString(_T("App"), _T("MasterPanelWidth"),
+ (LPTSTR)(LPCTSTR)strValue, (LPTSTR)(LPCTSTR)strIniFile);
+
Resize();
return 0;
@@ -1226,4 +1340,4 @@
}
return strText;
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3