From bc7f1c4e028e69be51079b59dae4ae5c4d43f5bb Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期六, 31 一月 2026 21:54:56 +0800
Subject: [PATCH] 1.状态指示图,目前灰色表示掉线,绿色表示在线。增加Slot的小点表示有没有料,及加工状态 。 2.增加图示
---
SourceCode/Bond/Servo/CPagePortProperty.cpp | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 320 insertions(+), 15 deletions(-)
diff --git a/SourceCode/Bond/Servo/CPagePortProperty.cpp b/SourceCode/Bond/Servo/CPagePortProperty.cpp
index 88728b5..3b8f4e5 100644
--- a/SourceCode/Bond/Servo/CPagePortProperty.cpp
+++ b/SourceCode/Bond/Servo/CPagePortProperty.cpp
@@ -5,6 +5,11 @@
#include "Servo.h"
#include "CPagePortProperty.h"
#include "afxdialogex.h"
+#include "Log.h"
+#include "MsgDlg.h"
+
+
+#define DELAY_CLOSE 2000
// CPagePortProperty 瀵硅瘽妗�
@@ -32,6 +37,11 @@
ON_WM_DESTROY()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_CHECK_ENABLE, &CPagePortProperty::OnBnClickedCheckEnable)
+ ON_CBN_SELCHANGE(IDC_COMBO_PORT_TYPE, &CPagePortProperty::OnCbnSelchangeComboPortType)
+ ON_CBN_SELCHANGE(IDC_COMBO_PORT_MODE, &CPagePortProperty::OnCbnSelchangeComboPortMode)
+ ON_CBN_SELCHANGE(IDC_COMBO_PORT_CASSERT_TYPE, &CPagePortProperty::OnCbnSelchangeComboPortCassertType)
+ ON_CBN_SELCHANGE(IDC_COMBO_PORT_TRANSFER_MODE, &CPagePortProperty::OnCbnSelchangeComboPortTransferMode)
+ ON_BN_CLICKED(IDC_CHECK_AUTO_CHANGE, &CPagePortProperty::OnBnClickedCheckAutoChange)
END_MESSAGE_MAP()
@@ -50,39 +60,39 @@
CComboBox* pComboBox;
std::string strTemp;
-
+ ((CButton*)GetDlgItem(IDC_CHECK_ENABLE))->SetCheck(m_pPort->isEnable() ? BST_CHECKED : BST_UNCHECKED);
pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_TYPE);
for (int i = 1; i <= 7; i++) {
- pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortTypeDescription(i, strTemp).c_str());
+ pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortTypeDescription((SERVO::PortType)i, strTemp).c_str());
}
- int portType = m_pPort->getPortType();
+ int portType = (int)m_pPort->getPortType();
if (1 <= portType && portType <= 7) {
pComboBox->SetCurSel(portType - 1);
}
pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_MODE);
- for (int i = 1; i <= 3; i++) {
- pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortModeDescription(i, strTemp).c_str());
+ for (int i = 0; i <= 5; i++) {
+ pComboBox->InsertString(i, SERVO::CLoadPort::getPortModeDescription((SERVO::PortMode)i, strTemp).c_str());
}
- int portMode = m_pPort->getPortMode();
- if (1 <= portMode && portMode <= 3) {
- pComboBox->SetCurSel(portMode - 1);
+ int portMode = (int)m_pPort->getPortMode();
+ if (0 <= portMode && portMode <= 5) {
+ pComboBox->SetCurSel(portMode);
}
pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_CASSERT_TYPE);
for (int i = 1; i <= 3; i++) {
- pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortCassetteTypeDescription(i, strTemp).c_str());
+ pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortCassetteTypeDescription((SERVO::CassetteType)i, strTemp).c_str());
}
- int cessetteType = m_pPort->getCessetteType();
+ int cessetteType = (int)m_pPort->getCessetteType();
if (1 <= cessetteType && cessetteType <= 3) {
pComboBox->SetCurSel(cessetteType - 1);
}
pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_PORT_TRANSFER_MODE);
for (int i = 1; i <= 3; i++) {
- pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortTransferModeDescription(i, strTemp).c_str());
+ pComboBox->InsertString(i - 1, SERVO::CLoadPort::getPortTransferModeDescription((SERVO::TransferMode)i, strTemp).c_str());
}
- int transferMode = m_pPort->getTransferMode();
+ int transferMode = (int)m_pPort->getTransferMode();
if (1 <= transferMode && transferMode <= 3) {
pComboBox->SetCurSel(transferMode - 1);
}
@@ -123,17 +133,312 @@
// TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
}
+int g_nMsgDlgShow = 0;
void CPagePortProperty::OnBnClickedCheckEnable()
{
BOOL bCheck = ((CButton*)GetDlgItem(IDC_CHECK_ENABLE))->GetCheck() == BST_CHECKED;
EnableCtrls(bCheck);
+
+#ifdef _LOCAL
+ ASSERT(m_pPort != nullptr);
+ theApp.m_model.setPortEnable(m_pPort->getIndex(), bCheck);
+#else
+
+ // enable port
+ g_nMsgDlgShow = 0;
+ CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鎿嶄綔锛岃绛夊緟...");
+
+ m_pPort->eablePort(bCheck, [&](int code) -> int {
+ Sleep(100);
+ CString strMsg;
+
+ if (code == WOK) {
+ LOGI("%s Port 鎴愬姛.", bCheck ? _T("enable") : _T("disable"));
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("%s Port 鎴愬姛."), bCheck ? _T("enable") : _T("disable"));
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_SUCCEED);
+ msgDlg.SetTitle(_T("鎿嶄綔鎴愬姛"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(0);
+ }
+ }
+ else {
+ LOGI("%s Port 澶辫触锛宑ode:%d", bCheck ? _T("enable") : _T("disable"), code);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("%s Port 澶辫触锛宑ode:%d"), bCheck ? _T("enable") : _T("disable"), code);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_ERROR);
+ msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(-1);
+ }
+ // 杩樺師鎺т欢鐘舵��
+ EnableCtrls(!bCheck);
+ ((CButton*)GetDlgItem(IDC_CHECK_ENABLE))->SetCheck(!bCheck ? BST_CHECKED : BST_UNCHECKED);
+ }
+
+ return 0;
+ });
+
+ msgDlg.DoModal();
+ g_nMsgDlgShow = 1;
+#endif
+}
+
+void CPagePortProperty::OnCbnSelchangeComboPortType()
+{
+ g_nMsgDlgShow = 0;
+ CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鎿嶄綔锛岃绛夊緟...");
+ msgDlg.SetData((DWORD_PTR)this);
+
+ // 淇敼涓哄彧淇濆瓨鍦ㄦ湰鍦伴厤缃�
+ ASSERT(m_pPort != nullptr);
+ int index = ((CComboBox*)GetDlgItem(IDC_COMBO_PORT_TYPE))->GetCurSel();
+ theApp.m_model.setPortType(m_pPort->getIndex(), SERVO::PortType(index + 1));
+
+ /*
+ m_pPort->setPortType(SERVO::PortType(index + 1), [&](int code) -> int {
+ Sleep(100);
+ CString strMsg;
+
+ if (code == WOK) {
+ LOGI("璁剧疆Port Type(%d)鎴愬姛.", index + 1);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Port Type(%d)鎴愬姛"), index + 1);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_SUCCEED);
+ msgDlg.SetTitle(_T("鎿嶄綔鎴愬姛"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(0);
+ }
+ }
+ else {
+ LOGI("璁剧疆Port Type(%d)澶辫触锛宑ode:%d", index + 1, code);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Port Type(%d)澶辫触锛宑ode:%d"), index + 1, code);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_ERROR);
+ msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(-1);
+ }
+ }
+
+ return 0;
+ });
+
+ msgDlg.DoModal();
+ g_nMsgDlgShow = 1;
+ */
+}
+
+void CPagePortProperty::OnCbnSelchangeComboPortMode()
+{
+ g_nMsgDlgShow = 0;
+ CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鎿嶄綔锛岃绛夊緟...");
+ msgDlg.SetData((DWORD_PTR)this);
+
+ ASSERT(m_pPort != nullptr);
+ int index = ((CComboBox*)GetDlgItem(IDC_COMBO_PORT_MODE))->GetCurSel();
+ m_pPort->setPortMode(SERVO::PortMode(index), [&](int code) -> int {
+ Sleep(100);
+ CString strMsg;
+
+ if (code == WOK) {
+ LOGI("璁剧疆Port Mode(%d)鎴愬姛.", index);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Port Mode(%d)鎴愬姛"), index);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_SUCCEED);
+ msgDlg.SetTitle(_T("鎿嶄綔鎴愬姛"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(0);
+ }
+ }
+ else {
+ LOGI("璁剧疆Port Mode(%d)澶辫触锛宑ode:%d", index, code);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Port Mode(%d)澶辫触锛宑ode:%d"), index, code);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_ERROR);
+ msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(-1);
+ }
+ }
+
+ return 0;
+ });
+
+ msgDlg.DoModal();
+ g_nMsgDlgShow = 1;
+}
+
+void CPagePortProperty::OnCbnSelchangeComboPortCassertType()
+{
+ // 鐢卞師鏉ョ殑鏇存柊鍒癊FEM, 淇敼涓轰繚瀛樺埌鏈湴ini鏂囦欢
+ ASSERT(m_pPort != nullptr);
+ int index = ((CComboBox*)GetDlgItem(IDC_COMBO_PORT_CASSERT_TYPE))->GetCurSel();
+ theApp.m_model.setPortCassetteType(m_pPort->getIndex(), SERVO::CassetteType(index + 1));
+
+
+ g_nMsgDlgShow = 0;
+ CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鎿嶄綔锛岃绛夊緟...");
+ msgDlg.SetData((DWORD_PTR)this);
+
+ ASSERT(m_pPort != nullptr);
+ m_pPort->setCassetteType(SERVO::CassetteType(index + 1), [&](int code) -> int {
+ Sleep(100);
+ CString strMsg;
+
+ if (code == WOK) {
+ LOGI("璁剧疆Cassette type(%d)鎴愬姛.", index + 1);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Cassette type(%d)鎴愬姛"), index + 1);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_SUCCEED);
+ msgDlg.SetTitle(_T("鎿嶄綔鎴愬姛"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(0);
+ }
+ }
+ else {
+ LOGI("璁剧疆Cassette type(%d)澶辫触锛宑ode:%d", index + 1, code);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Cassette type(%d)澶辫触锛宑ode:%d"), index + 1, code);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_ERROR);
+ msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(-1);
+ }
+ }
+
+ return 0;
+ });
+
+ msgDlg.DoModal();
+ g_nMsgDlgShow = 1;
+}
+
+void CPagePortProperty::OnCbnSelchangeComboPortTransferMode()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ g_nMsgDlgShow = 0;
+ CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鎿嶄綔锛岃绛夊緟...");
+ msgDlg.SetData((DWORD_PTR)this);
+
+ ASSERT(m_pPort != nullptr);
+ int index = ((CComboBox*)GetDlgItem(IDC_COMBO_PORT_TRANSFER_MODE))->GetCurSel();
+ m_pPort->setTransferMode(SERVO::TransferMode(index + 1), [&](int code) -> int {
+ Sleep(100);
+ CString strMsg;
+
+ if (code == WOK) {
+ LOGI("璁剧疆Transfer mode(%d)鎴愬姛.", index + 1);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Transfer mode(%d)鎴愬姛"), index + 1);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_SUCCEED);
+ msgDlg.SetTitle(_T("鎿嶄綔鎴愬姛"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(0);
+ }
+ }
+ else {
+ LOGI("璁剧疆Transfer mode(%d)澶辫触锛宑ode:%d", index + 1, code);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("璁剧疆Transfer mode(%d)澶辫触锛宑ode:%d"), index + 1, code);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_ERROR);
+ msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(-1);
+ }
+ }
+
+ return 0;
+ });
+
+ msgDlg.DoModal();
+ g_nMsgDlgShow = 1;
+}
+
+void CPagePortProperty::OnBnClickedCheckAutoChange()
+{
+ BOOL bCheck = ((CButton*)GetDlgItem(IDC_CHECK_AUTO_CHANGE))->GetCheck() == BST_CHECKED;
+
+
+ // enable port
+ g_nMsgDlgShow = 0;
+ CMsgDlg msgDlg("璇风瓑寰�", "姝e湪鎿嶄綔锛岃绛夊緟...");
+
+ ASSERT(m_pPort != nullptr);
+ m_pPort->eableAutoChange(bCheck, [&](int code) -> int {
+ Sleep(100);
+ CString strMsg;
+
+ if (code == WOK) {
+ LOGI("%s Auto Change 鎴愬姛.", bCheck ? _T("enable") : _T("disable"));
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("%s Auto Change 鎴愬姛."), bCheck ? _T("enable") : _T("disable"));
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_SUCCEED);
+ msgDlg.SetTitle(_T("鎿嶄綔鎴愬姛"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(0);
+ }
+ }
+ else {
+ LOGI("%s Auto Change 澶辫触锛宑ode:%d", bCheck ? _T("enable") : _T("disable"), code);
+
+ if (g_nMsgDlgShow == 0 && ::IsWindow(msgDlg.GetSafeHwnd())) {
+ strMsg.Format(_T("%s Auto Change 澶辫触锛宑ode:%d"), bCheck ? _T("enable") : _T("disable"), code);
+ msgDlg.DelayClose(DELAY_CLOSE);
+ msgDlg.SetIcon(MSG_BOX_ERROR);
+ msgDlg.SetTitle(_T("鎿嶄綔澶辫触"));
+ msgDlg.SetMessage((LPTSTR)(LPCTSTR)strMsg);
+ msgDlg.SetMarquee(FALSE, 0);
+ msgDlg.SetCompleteCode(-1);
+ }
+
+ // 杩樺師鎺т欢鐘舵��
+ ((CButton*)GetDlgItem(IDC_CHECK_AUTO_CHANGE))->SetCheck(!bCheck ? BST_CHECKED : BST_UNCHECKED);
+ }
+
+ return 0;
+ });
+
+ msgDlg.DoModal();
+ g_nMsgDlgShow = 1;
}
void CPagePortProperty::EnableCtrls(BOOL bEnable)
{
GetDlgItem(IDC_COMBO_PORT_TYPE)->EnableWindow(bEnable);
- GetDlgItem(IDC_COMBO_PORT_MODE)->EnableWindow(bEnable);
GetDlgItem(IDC_COMBO_PORT_CASSERT_TYPE)->EnableWindow(bEnable);
- GetDlgItem(IDC_COMBO_PORT_TRANSFER_MODE)->EnableWindow(bEnable);
- GetDlgItem(IDC_CHECK_AUTO_CHANGE)->EnableWindow(bEnable);
}
+
--
Gitblit v1.9.3