From 016703bb359382dc1de4ac204da47b6f29c55c81 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 12 十二月 2024 11:09:10 +0800
Subject: [PATCH] Merge branch 'liuyang' into clh
---
SourceCode/Bond/BondEq/Resource.h | 0
SourceCode/Bond/BondEq/BondEq.rc | 0
SourceCode/Bond/BondEq/BondEq.vcxproj | 4
SourceCode/Bond/BondEq/FileManager/RecipeManager.h | 8
/dev/null | 130 ------
SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp | 419 ++++++++++++++++++++
SourceCode/Bond/BondEq/View/AxisSettingsDlg.h | 22 +
SourceCode/Bond/BondEq/RegexEdit.cpp | 143 +++++++
SourceCode/Bond/BondEq/RegexEdit.h | 74 +++
SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp | 200 +++++++--
SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp | 6
SourceCode/Bond/BLControlsSDK/include/BLLabel.h | 91 ++-
SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h | 50 ++
SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp | 23
14 files changed, 945 insertions(+), 225 deletions(-)
diff --git a/SourceCode/Bond/BLControlsSDK/include/BLLabel.h b/SourceCode/Bond/BLControlsSDK/include/BLLabel.h
index e8f35f8..88ff5d0 100644
--- a/SourceCode/Bond/BLControlsSDK/include/BLLabel.h
+++ b/SourceCode/Bond/BLControlsSDK/include/BLLabel.h
@@ -24,50 +24,77 @@
void SetClickCallback(std::function<void()> callback); // 璁剧疆鐐瑰嚮浜嬩欢鐨勫洖璋冨嚱鏁�
// 灞炴�ц缃帴鍙�
- CBLLabel& SetBkColor(COLORREF crBkgnd); // 璁剧疆鑳屾櫙棰滆壊
- CBLLabel& SetTextColor(COLORREF crText); // 璁剧疆鏂囨湰棰滆壊
- CBLLabel& SetText(const CString& strText); // 璁剧疆鏂囨湰鍐呭
- CBLLabel& SetFontBold(BOOL bBold); // 璁剧疆瀛椾綋鍔犵矖
- CBLLabel& SetFontName(const CString& strFont); // 璁剧疆瀛椾綋鍚嶇О
- CBLLabel& SetFontUnderline(BOOL bSet); // 璁剧疆涓嬪垝绾�
- CBLLabel& SetFontItalic(BOOL bSet); // 璁剧疆鏂滀綋
- CBLLabel& SetFontSize(int nSize); // 璁剧疆瀛椾綋澶у皬
- CBLLabel& SetAlignment(TextAlign alignment); // 璁剧疆鏂囨湰瀵归綈鏂瑰紡
- CBLLabel& SetDynamicFont(BOOL bDynamic); // 璁剧疆鏄惁鍔ㄦ�佽皟鏁村瓧浣�
- CBLLabel& FlashText(BOOL bActivate); // 闂儊鏂囨湰
- CBLLabel& FlashBackground(BOOL bActivate); // 闂儊鑳屾櫙
- CBLLabel& SetLink(BOOL bLink); // 璁剧疆鏄惁鍚敤瓒呴摼鎺�
- CBLLabel& SetLinkCursor(HCURSOR hCursor); // 璁剧疆瓒呴摼鎺ュ厜鏍�
+ CBLLabel& SetBkColor(COLORREF crBkgnd); // 璁剧疆鑳屾櫙棰滆壊
+ CBLLabel& SetTextColor(COLORREF crText); // 璁剧疆鏂囨湰棰滆壊
+ CBLLabel& SetText(const CString& strText); // 璁剧疆鏂囨湰鍐呭
+ CBLLabel& SetFontBold(BOOL bBold); // 璁剧疆瀛椾綋鍔犵矖
+ CBLLabel& SetFontName(const CString& strFont); // 璁剧疆瀛椾綋鍚嶇О
+ CBLLabel& SetFontUnderline(BOOL bSet); // 璁剧疆涓嬪垝绾�
+ CBLLabel& SetFontItalic(BOOL bSet); // 璁剧疆鏂滀綋
+ CBLLabel& SetFontSize(int nSize); // 璁剧疆瀛椾綋澶у皬
+ CBLLabel& SetAlignment(TextAlign alignment); // 璁剧疆鏂囨湰瀵归綈鏂瑰紡
+ CBLLabel& SetDynamicFont(BOOL bDynamic); // 璁剧疆鏄惁鍔ㄦ�佽皟鏁村瓧浣�
+ CBLLabel& FlashText(BOOL bActivate); // 闂儊鏂囨湰
+ CBLLabel& FlashBackground(BOOL bActivate); // 闂儊鑳屾櫙
+ CBLLabel& SetLink(BOOL bLink); // 璁剧疆鏄惁鍚敤瓒呴摼鎺�
+ CBLLabel& SetLinkCursor(HCURSOR hCursor); // 璁剧疆瓒呴摼鎺ュ厜鏍�
+ CBLLabel& DisableBorder(); // 绂佺敤杈规
+ CBLLabel& SetBorderColor(COLORREF crBorder); // 璁剧疆杈规棰滆壊
+ CBLLabel& SetBorderWidth(int nWidth); // 璁剧疆杈规瀹藉害
+ CBLLabel& SetBorderStyle(int nStyle); // 璁剧疆杈规鏍峰紡
+ CBLLabel& SetDefaultCursor(HCURSOR hCursor); // 璁剧疆榛樿鍏夋爣
+ CBLLabel& SetHandCursor(HCURSOR hCursor); // 璁剧疆鎵嬪瀷鍏夋爣
+ CBLLabel& SetRoundedCorners(BOOL bEnable, int nRadius); // 璁剧疆鍦嗚鍙婂崐寰�
+ CBLLabel& SetCornerRadius(int nTopLeft, int nTopRight, int nBottomRight, int nBottomLeft); // 璁剧疆鍚勮鍦嗚鍗婂緞
protected:
// 宸ュ叿鍑芥暟
- void ReconstructFont(); // 閲嶆柊鏋勯�犲瓧浣�
- void UpdateFontSize(); // 鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
- virtual void OnPaint(); // 鑷畾涔夌粯鍒舵枃鏈�
+ void ReconstructFont(); // 閲嶆柊鏋勯�犲瓧浣�
+ void UpdateFontSize(); // 鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
+ void CreateRoundedRegion(CRgn& rgn, const CRect& rect); // 鍒涘缓鍦嗚鍖哄煙
+ virtual void OnPaint(); // 鑷畾涔夌粯鍒舵枃鏈�
// 灞炴��
- COLORREF m_crText; // 鏂囨湰棰滆壊
- COLORREF m_crBkColor; // 鑳屾櫙棰滆壊
- HBRUSH m_hBrush; // 鑳屾櫙鐢诲埛
- LOGFONT m_lf; // 瀛椾綋淇℃伅
- CFont m_font; // 瀛椾綋瀵硅薄
- CString m_strText; // 鏂囨湰鍐呭
- BOOL m_bState; // 鐘舵�侊紝鐢ㄤ簬闂儊
- BOOL m_bTimer; // 瀹氭椂鍣ㄧ姸鎬�
- BOOL m_bLink; // 鏄惁涓鸿秴閾炬帴
- BOOL m_bDynamicFont; // 鏄惁鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
+ COLORREF m_crText; // 鏂囨湰棰滆壊
+ COLORREF m_crBkColor; // 鑳屾櫙棰滆壊
+ HBRUSH m_hBrush; // 鑳屾櫙鐢诲埛
+ LOGFONT m_lf; // 瀛椾綋淇℃伅
+ CFont m_font; // 瀛椾綋瀵硅薄
+ CString m_strText; // 鏂囨湰鍐呭
+ BOOL m_bState; // 鐘舵�侊紝鐢ㄤ簬闂儊
+ BOOL m_bTimer; // 瀹氭椂鍣ㄧ姸鎬�
+ BOOL m_bLink; // 鏄惁涓鸿秴閾炬帴
+ BOOL m_bDynamicFont; // 鏄惁鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
TextAlign m_alignment; // 鏂囨湰瀵归綈鏂瑰紡
FlashType m_Type; // 闂儊绫诲瀷
- HCURSOR m_hCursor; // 瓒呴摼鎺ュ厜鏍�
+ HCURSOR m_hCursor; // 瓒呴摼鎺ュ厜鏍�
+
+ // 杈规灞炴��
+ COLORREF m_crBorderColor; // 杈规棰滆壊
+ int m_nBorderWidth; // 杈规瀹藉害
+ int m_nBorderStyle; // 杈规鏍峰紡锛堜娇鐢� GDI 鏍峰紡锛歅S_SOLID, PS_DASH 绛夛級
+
+ // 鍦嗚鐩稿叧灞炴��
+ BOOL m_bRoundedCorners; // 鏄惁鍚敤鍦嗚
+ int m_nTopLeftRadius; // 宸︿笂瑙掑渾瑙掑崐寰�
+ int m_nTopRightRadius; // 鍙充笂瑙掑渾瑙掑崐寰�
+ int m_nBottomRightRadius; // 鍙充笅瑙掑渾瑙掑崐寰�
+ int m_nBottomLeftRadius; // 宸︿笅瑙掑渾瑙掑崐寰�
+
+ // 榧犳爣浜嬩欢鐩稿叧灞炴��
+ BOOL m_bMouseIn; // 榧犳爣鏄惁鍦ㄦ帶浠朵笂
+ HCURSOR m_hHandCursor; // 鎵嬪瀷鍏夋爣
+ HCURSOR m_hDefaultCursor; // 榛樿鍏夋爣
std::function<void()> m_clickCallback; // 鐐瑰嚮浜嬩欢鐨勫洖璋冨嚱鏁�
protected:
// MFC 娑堟伅鏄犲皠
- virtual HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); // 鑳屾櫙鍜屾枃鏈鑹茶缃�
- afx_msg void OnTimer(UINT_PTR nIDEvent); // 瀹氭椂鍣ㄤ簨浠�
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point); // 榧犳爣鐐瑰嚮浜嬩欢
+ virtual HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); // 鑳屾櫙鍜屾枃鏈鑹茶缃�
+ afx_msg void OnTimer(UINT_PTR nIDEvent); // 瀹氭椂鍣ㄤ簨浠�
+ afx_msg void OnLButtonDown(UINT nFlags, CPoint point); // 榧犳爣鐐瑰嚮浜嬩欢
+ afx_msg void OnMouseMove(UINT nFlags, CPoint point); // 榧犳爣绉诲姩浜嬩欢
+ afx_msg void OnMouseLeave(); // 榧犳爣绂诲紑浜嬩欢
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); // 璁剧疆鍏夋爣浜嬩欢
-
DECLARE_MESSAGE_MAP()
};
diff --git a/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp
deleted file mode 100644
index 36e7b07..0000000
--- a/SourceCode/Bond/BondEq/AxisSettingsDlg.cpp
+++ /dev/null
@@ -1,1116 +0,0 @@
-锘�// AxisSettingsDlg.cpp: 瀹炵幇鏂囦欢
-//
-
-#include "stdafx.h"
-#include "BondEq.h"
-#include "afxdialogex.h"
-#include "AxisSettingsDlg.h"
-#include "ToolUnits.h"
-#include <cctype>
-#include <algorithm>
-
-#define TIMER_INIT 1
-#define TIMER_READ_PLC_DATA 2
-#define TIMER_JOG_ADD 3
-#define TIMER_JOG_SUB 4
-
-// OnUpdateDataToUI
-#define ID_MSG_UPDATA_DATA_TO_UI WM_USER + 101
-
-// CAxisSettingsDlg 瀵硅瘽妗�
-
-IMPLEMENT_DYNAMIC(CAxisSettingsDlg, CDialogEx)
-
-CAxisSettingsDlg::CAxisSettingsDlg(CWnd* pParent /*=nullptr*/)
- : CDialogEx(IDD_DIALOG_AXIS_SETTINGS, pParent)
-{
- m_nInitialWidth = 0;
- m_nInitialHeight = 0;
- m_pPLC = nullptr;
-
- m_bSEV = FALSE;
- m_fCurPos = 0.0;
- m_fManualSpeed = 0.0;
- m_fAutoSpeed = 0.0;
- m_fPrm = 0.0;
- m_nLoad = 0;
- m_nErrCode = 0;
- m_nAlarmCode = 0;
- m_bFLS = FALSE;
- m_bDOG = FALSE;
- m_bRLS = FALSE;
- m_bReady = FALSE;
- m_bBusy = FALSE;
- m_bErr = FALSE;
-}
-
-CAxisSettingsDlg::~CAxisSettingsDlg()
-{
- for (auto& pair : m_mapFonts) {
- if (pair.second) {
- pair.second->DeleteObject();
- delete pair.second;
- }
- }
- m_mapFonts.clear();
-}
-
-void CAxisSettingsDlg::SetPLC(CPLC* pPLC)
-{
- ASSERT(pPLC);
- m_pPLC = pPLC;
-}
-
-void CAxisSettingsDlg::SetRecipeName(const CString& strRecipeName)
-{
- m_strRecipeName = strRecipeName;
-}
-
-void CAxisSettingsDlg::DoDataExchange(CDataExchange* pDX)
-{
- CDialogEx::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_STATIC_AXIS_TEST_FLS, m_staticFLS);
- DDX_Control(pDX, IDC_STATIC_AXIS_TEST_DOG, m_staticDOG);
- DDX_Control(pDX, IDC_STATIC_AXIS_TEST_RLS, m_staticRLS);
- DDX_Control(pDX, IDC_STATIC_AXIS_TEST_READY, m_staticReady);
- DDX_Control(pDX, IDC_STATIC_AXIS_TEST_BUSY, m_staticBusy);
- DDX_Control(pDX, IDC_STATIC_AXIS_TEST_ERR, m_staticErr);
- DDX_Control(pDX, IDC_COMBO_AXIS_NAME, m_comboAxisNO);
- DDX_Control(pDX, IDC_STATIC_AXIS_NUMBER, m_staticAxisNO);
- DDX_Control(pDX, IDC_STATIC_AXIS_DESCRIP, m_staticAxisDescription);
- DDX_Control(pDX, IDC_STATIC_START_ADDRESS, m_staticStartAddress);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_POS, m_editManualSpeed);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_AUTO_SPEED, m_editAutoSpeed);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_ACCE_TIME, m_editAccelerationTime);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_DECE_TIME, m_editDecelerationTime);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_MICROMENTUM, m_editJogDistance);
- DDX_Control(pDX, IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP1, m_pageButtons[0]);
- DDX_Control(pDX, IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP2, m_pageButtons[1]);
- DDX_Control(pDX, IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP3, m_pageButtons[2]);
- DDX_Control(pDX, IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP4, m_pageButtons[3]);
- DDX_Control(pDX, IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP5, m_pageButtons[4]);
-}
-
-UINT CAxisSettingsDlg::FindIDByName(const CString& strControlID)
-{
- // 灏嗚祫婧愭枃浠朵腑瀹氫箟鐨勬帶浠跺悕绉板拰 ID 鍔犺浇鍒颁竴涓槧灏勪腑
- static const std::map<CString, UINT> controlIdMap = {
- {"IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP1", IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP1},
- {"IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP2", IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP2},
- {"IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP3", IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP3},
- {"IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP4", IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP4},
- {"IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP5", IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP5},
- {"IDC_EDIT_AXIS_ANCHOR_POINT1", IDC_EDIT_AXIS_ANCHOR_POINT1},
- {"IDC_EDIT_AXIS_ANCHOR_POINT2", IDC_EDIT_AXIS_ANCHOR_POINT2},
- {"IDC_EDIT_AXIS_ANCHOR_POINT3", IDC_EDIT_AXIS_ANCHOR_POINT3},
- {"IDC_EDIT_AXIS_ANCHOR_POINT4", IDC_EDIT_AXIS_ANCHOR_POINT4},
- {"IDC_EDIT_AXIS_ANCHOR_POINT5", IDC_EDIT_AXIS_ANCHOR_POINT5}
- // 鍙互缁х画娣诲姞鍏朵粬鎺т欢鍚嶇О鍜� ID
- };
-
- // 鏌ユ壘鎺т欢鍚嶇О鏄惁鍦ㄦ槧灏勪腑
- auto it = controlIdMap.find(strControlID);
- if (it != controlIdMap.end()) {
- return it->second;
- }
-
- return 0;
-}
-
-CFont* CAxisSettingsDlg::GetOrCreateFont(int nFontSize)
-{
- auto it = m_mapFonts.find(nFontSize);
- if (it != m_mapFonts.end()) {
- return it->second;
- }
-
- CFont* font = new CFont();
- LOGFONT logFont = { 0 };
- _tcscpy_s(logFont.lfFaceName, _T("Segoe UI"));
- logFont.lfHeight = -nFontSize;
- logFont.lfQuality = CLEARTYPE_QUALITY;
- font->CreateFontIndirect(&logFont);
- m_mapFonts[nFontSize] = font;
-
- return font;
-}
-
-void CAxisSettingsDlg::SetDefaultFont()
-{
- CFont* defaultFont = GetOrCreateFont(12);
-
- // 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
- CWnd* pWnd = GetWindow(GW_CHILD);
- while (pWnd) {
- pWnd->SetFont(defaultFont, TRUE);
- pWnd = pWnd->GetNextWindow();
- }
-}
-
-void CAxisSettingsDlg::AdjustControls(float dScaleX, float dScaleY)
-{
- CWnd* pWnd = GetWindow(GW_CHILD);
- while (pWnd) {
- int nCtrlID = pWnd->GetDlgCtrlID();
- if (nCtrlID != -1 && m_mapCtrlLayouts.find(nCtrlID) != m_mapCtrlLayouts.end())
- {
- CRect originalRect = m_mapCtrlLayouts[nCtrlID];
- CRect newRect(
- static_cast<int>(originalRect.left * dScaleX),
- static_cast<int>(originalRect.top * dScaleY),
- static_cast<int>(originalRect.right * dScaleX),
- static_cast<int>(originalRect.bottom * dScaleY));
-
- TCHAR szClassName[256];
- GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
-
- if (_tcsicmp(szClassName, _T("ComboBox")) == 0) {
- CComboBox* pComboBox = (CComboBox*)pWnd;
- pComboBox->SetItemHeight(-1, newRect.Height()); // -1 琛ㄧず鎵�鏈夐」鐨勯珮搴�
- }
-
- pWnd->MoveWindow(&newRect);
- AdjustControlFont(pWnd, newRect.Width(), newRect.Height());
- }
- pWnd = pWnd->GetNextWindow();
- }
-}
-
-void CAxisSettingsDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight)
-{
- // 鏍规嵁鎺т欢楂樺害鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
- int fontSize = nHeight / 2;
- if (fontSize < 8) fontSize = 8;
- if (fontSize > 24) fontSize = 24; // 鏈�澶у瓧浣撳ぇ灏�
-
- // 鑾峰彇鎴栧垱寤哄瓧浣�
- CFont* pFont = GetOrCreateFont(fontSize);
-
- pWnd->SetFont(pFont);
- pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
-}
-
-void CAxisSettingsDlg::AdjustLabelFont(CBLLabel& label)
-{
- // 鑾峰彇鎺т欢鐨勭煩褰㈠尯鍩�
- CRect rect;
- label.GetClientRect(&rect);
-
- // 鍔ㄦ�佽绠楀瓧浣撳ぇ灏忥紝鍩轰簬鎺т欢鐨勯珮搴�
- int fontSize = rect.Height() / 2; // 鎺т欢楂樺害鐨勪竴鍗婁綔涓哄瓧浣撳ぇ灏�
- if (fontSize < 8) fontSize = 8; // 鏈�灏忓瓧浣撳ぇ灏�
- if (fontSize > 30) fontSize = 30; // 鏈�澶у瓧浣撳ぇ灏�
-
- // 璁剧疆瀛椾綋澶у皬
- label.SetFontSize(fontSize);
-
- // 鍒锋柊鎺т欢鏄剧ず
- label.Invalidate();
- label.UpdateWindow();
-}
-
-void CAxisSettingsDlg::SetLabelColor(CBLLabel& label, COLORREF color)
-{
- label.SetBkColor(color);
- label.Invalidate(); // 鏍囪鍖哄煙鏃犳晥
- label.UpdateWindow(); // 绔嬪嵆鍒锋柊
-}
-
-void CAxisSettingsDlg::updatePageButtonStates()
-{
- for (int i = 0; i < 5; ++i) {
- if (i + 1 == m_currentPage) {
- m_pageButtons[i].SetFaceColor(RGB(0, 122, 204)); // 閫変腑鑳屾櫙鑹诧紙钃濊壊锛�
- }
- else {
- m_pageButtons[i].SetFaceColor(RGB(240, 240, 240)); // 榛樿鑳屾櫙鑹�
- }
-
- m_pageButtons[i].Invalidate();
- }
-}
-
-int CAxisSettingsDlg::getCurrentSelectedAxisID()
-{
- int currentIndex = m_comboAxisNO.GetCurSel();
- if (currentIndex == CB_ERR) {
- return -1;
- }
-
- CString strAxisIDStr;
- m_comboAxisNO.GetLBText(currentIndex, strAxisIDStr);
- return _ttoi(strAxisIDStr);
-}
-
-void CAxisSettingsDlg::initializeAxisIDCombo()
-{
- // 妫�鏌ラ厤鏂规槸鍚﹀姞杞芥垚鍔�
- RecipeManager& recipeManager = RecipeManager::getInstance();
- if (m_strRecipeName.IsEmpty() || !recipeManager.loadRecipe(std::string(CT2A(m_strRecipeName)))) {
- AfxMessageBox(_T("鍔犺浇閰嶆柟澶辫触锛�"));
- return;
- }
-
- // 鑾峰彇鎵�鏈夎酱鐨勭紪鍙�
- auto axisNumbers = recipeManager.getAllAxisID();
-
- // 娓呯┖涓嬫媺妗�
- m_comboAxisNO.ResetContent();
-
- // 濉厖鏁版嵁鍒颁笅鎷夋
- for (const auto& axisID : axisNumbers) {
- CString axisCString;
- axisCString.Format(_T("%d"), axisID);
- m_comboAxisNO.AddString(axisCString);
- }
-
- // 榛樿閫夋嫨绗竴椤�
- if (m_comboAxisNO.GetCount() > 0) {
- m_comboAxisNO.SetCurSel(0);
- }
-}
-
-void CAxisSettingsDlg::refreshAxisDetails(int nAxisId)
-{
- // 鑾峰彇杞存暟鎹�
- RecipeManager& recipeManager = RecipeManager::getInstance();
- auto axisDetails = recipeManager.getAxis(nAxisId);
-
- auto formatDouble = [](double value) -> CString {
- CString str;
- str.Format(_T("%.3f"), value);
- return str;
- };
-
- // 鏇存柊鎺т欢鏄剧ず
- m_staticAxisNO.SetWindowText(CString(axisDetails.number.c_str())); // 杞寸紪鍙�
- m_staticAxisDescription.SetWindowText(CString(axisDetails.description.c_str())); // 杞存弿杩�
- m_staticStartAddress.SetWindowText(CString(axisDetails.startAddress.c_str())); // 璧峰鍦板潃
- m_editJogDistance.SetWindowText(formatDouble(axisDetails.jogDistance)); // 寰姩閲�
- m_editManualSpeed.SetWindowText(formatDouble(axisDetails.manualSpeed)); // 鎵嬪姩閫熷害
- m_editAutoSpeed.SetWindowText(formatDouble(axisDetails.autoSpeed)); // 鑷姩閫熷害
- m_editAccelerationTime.SetWindowText(formatDouble(axisDetails.accelerationTime)); // 鍔犻�熸椂闂�
- m_editDecelerationTime.SetWindowText(formatDouble(axisDetails.decelerationTime)); // 鍑忛�熸椂闂�
-}
-
-void CAxisSettingsDlg::refreshPositionDetails(int nAxisId, int pageNumber)
-{
- RecipeManager& recipeManager = RecipeManager::getInstance();
- // 姣忛〉鏄剧ず鐨勫畾浣嶇偣鏁伴噺
- const int pageSize = 5;
-
- // 鑾峰彇瀹氫綅鐐规暟鎹�
- auto positions = recipeManager.getPositions(nAxisId, pageNumber, pageSize);
-
- // 鍒锋柊 UI
- for (int i = 0; i < pageSize; ++i) {
- CString descriptionCtrlName, positionCtrlName;
- descriptionCtrlName.Format(_T("IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP%d"), i + 1);
- positionCtrlName.Format(_T("IDC_EDIT_AXIS_ANCHOR_POINT%d"), i + 1);
-
- UINT descriptionCtrlId = FindIDByName(descriptionCtrlName);
- UINT positionCtrlId = FindIDByName(positionCtrlName);
-
- CWnd* pDescriptionCtrl = GetDlgItem(descriptionCtrlId);
- CWnd* pPositionCtrl = GetDlgItem(positionCtrlId);
-
- if (i < positions.size()) {
- CString description = CString(positions[i].first.c_str());
- CString value;
- value.Format(_T("%.3f"), positions[i].second);
-
- if (pDescriptionCtrl) pDescriptionCtrl->SetWindowText(description);
- if (pPositionCtrl) pPositionCtrl->SetWindowText(value);
- }
- else {
- if (pDescriptionCtrl) pDescriptionCtrl->SetWindowText(_T(""));
- if (pPositionCtrl) pPositionCtrl->SetWindowText(_T(""));
- }
- }
-}
-
-void CAxisSettingsDlg::updateAxisSelection(int offset)
-{
- int currentIndex = m_comboAxisNO.GetCurSel();
- if (currentIndex == CB_ERR) {
- AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
- return;
- }
-
- int newIndex = currentIndex + offset;
- if (newIndex < 0 || newIndex >= m_comboAxisNO.GetCount()) {
- CString error;
- error.Format(_T("宸茬粡鍒拌揪%s涓�涓酱锛�"), offset < 0 ? _T("涓�") : _T("涓�"));
- AfxMessageBox(error);
- return;
- }
-
- m_comboAxisNO.SetCurSel(newIndex);
- refreshAxisDetails(newIndex + 1);
- refreshPositionDetails(newIndex + 1, m_currentPage);
- updatePageButtonStates();
-}
-
-void CAxisSettingsDlg::updateDataFromUI(int nAxisId)
-{
- const int pageSize = 5; // 姣忛〉鏄剧ず 5 涓畾浣嶇偣
-
- RecipeManager& recipeManager = RecipeManager::getInstance();
- auto axisData = recipeManager.getAxis(nAxisId);
-
- // 鑾峰彇鐣岄潰涓婄殑淇敼鍙傛暟
- CString text;
- m_editManualSpeed.GetWindowText(text);
- axisData.manualSpeed = _ttof(text);
-
- m_editAutoSpeed.GetWindowText(text);
- axisData.autoSpeed = _ttof(text);
-
- m_editAccelerationTime.GetWindowText(text);
- axisData.accelerationTime = _ttof(text);
-
- m_editDecelerationTime.GetWindowText(text);
- axisData.decelerationTime = _ttof(text);
-
- m_editJogDistance.GetWindowText(text);
- axisData.jogDistance = _ttof(text);
-
- // 鏇存柊瀹氫綅鐐规暟鎹�
- for (int i = 0; i < pageSize; ++i) {
- int index = (m_currentPage - 1) * pageSize + i;
-
- if (index < axisData.positions.size()) {
- CString descriptionName, positionName;
- descriptionName.Format(_T("IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP%d"), i + 1);
- positionName.Format(_T("IDC_EDIT_AXIS_ANCHOR_POINT%d"), i + 1);
-
- CEdit* pDescriptionEdit = (CEdit*)GetDlgItem(FindIDByName(descriptionName));
- CEdit* pPositionEdit = (CEdit*)GetDlgItem(FindIDByName(positionName));
-
- if (pDescriptionEdit && pPositionEdit) {
- CString description, positionValue;
- pDescriptionEdit->GetWindowText(description);
- pPositionEdit->GetWindowText(positionValue);
-
- // 鏇存柊 RecipeManager 涓殑鏁版嵁
- axisData.positions[index].first = CT2A(description);
- axisData.positions[index].second = _ttof(positionValue);
- }
- }
- }
-
- // 淇濆瓨鍥� RecipeManager
- recipeManager.updateAxis(axisData);
-}
-
-void CAxisSettingsDlg::switchToPage(int targetPage)
-{
- try {
- // 濡傛灉褰撳墠椤甸潰宸茬粡鏄洰鏍囬〉闈紝鐩存帴杩斿洖
- if (m_currentPage == targetPage) {
- return;
- }
-
- // 鑾峰彇褰撳墠閫変腑鐨勮酱 ID
- int axisId = getCurrentSelectedAxisID();
- if (axisId == -1) {
- AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
- return;
- }
-
- // 鏇存柊 UI 鏁版嵁鍒板唴瀛�
- updateDataFromUI(axisId);
-
- // 鍒囨崲椤甸潰
- m_currentPage = targetPage;
- refreshPositionDetails(axisId, targetPage);
- updatePageButtonStates();
- }
- catch (const std::exception& ex) {
- CString errorMsg;
- errorMsg.Format(_T("鍒锋柊瀹氫綅缁�%d澶辫触锛�%s"), targetPage, CString(ex.what()));
- AfxMessageBox(errorMsg, MB_ICONERROR);
- }
-}
-
-bool CAxisSettingsDlg::ParsePLCAddress(const CString& address, MC::SOFT_COMPONENT& component, int& addr)
-{
- if (address.GetLength() < 2) {
- return false;
- }
-
- // 鎻愬彇缁勪欢绫诲瀷锛堢涓�涓瓧绗︼級
- TCHAR componentChar = address[0];
- if (address.Left(2) == _T("ZR")) {
- component = MC::SOFT_COMPONENT::ZR;
- // 鎻愬彇鏁板瓧閮ㄥ垎锛堝幓闄R鍓嶇紑锛�
- CString numericAddress = address.Mid(2);
- addr = _ttoi(numericAddress);
- return addr != 0 || numericAddress.CompareNoCase(_T("0")) == 0; // 濡傛灉鏄� "0"锛屼篃璁や负鏈夋晥
- }
-
- // 瀵逛簬鍏朵粬缁勪欢锛屾寜鐓у父瑙勮鍒欏鐞�
- CString hexAddress = address.Mid(1);
- switch (componentChar) {
- case 'D':
- component = MC::SOFT_COMPONENT::D;
- addr = _ttoi(hexAddress);
- break;
- case 'M':
- component = MC::SOFT_COMPONENT::M;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- case 'X':
- component = MC::SOFT_COMPONENT::X;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- case 'Y':
- component = MC::SOFT_COMPONENT::Y;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- case 'W':
- component = MC::SOFT_COMPONENT::W;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- case 'L':
- component = MC::SOFT_COMPONENT::L;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- case 'S':
- component = MC::SOFT_COMPONENT::S;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- case 'B':
- component = MC::SOFT_COMPONENT::B;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- case 'F':
- component = MC::SOFT_COMPONENT::F;
- addr = _tcstoul(hexAddress, nullptr, 16);
- break;
- default:
- return false;
- }
-
- // 妫�鏌ュ湴鍧�鏄惁鏈夋晥
- if (addr == 0 && hexAddress.CompareNoCase(_T("0")) != 0) {
- return false;
- }
-
- return true;
-}
-
-void CAxisSettingsDlg::writeAxisDataToPLC(int nAxisId)
-{
- // 浠� RecipeManager 鑾峰彇杞存暟鎹�
- RecipeManager& recipeManager = RecipeManager::getInstance();
- auto axisData = recipeManager.getAxis(nAxisId);
-
- int startAddress;
- MC::SOFT_COMPONENT component;
- if (!ParsePLCAddress(CString(axisData.startAddress.c_str()), component, startAddress)) {
- AfxMessageBox(_T("鏃犳晥鐨勮捣濮嬪湴鍧�锛�"));
- }
-
- // 鍐欏叆鎵嬪姩閫熷害
- m_pPLC->writeDWord(component, startAddress + 82, (int)axisData.manualSpeed * 1000, [](IMcChannel* pChannel, int addr, DWORD value, int flag) {
- if (flag == 0) {
- TRACE("\n鍐欏叆鎴愬姛: 鎵嬪姩閫熷害, 鍦板潃: %d, 鍊�: %lu\n", addr, value);
- }
- else {
- TRACE("\n鍐欏叆澶辫触: 鎵嬪姩閫熷害, 鍦板潃: %d, 閿欒鐮�: %d\n", addr, flag);
- }
- });
-
- // 鍐欏叆鑷姩閫熷害
- m_pPLC->writeDWord(component, startAddress + 84, (int)(axisData.autoSpeed * 1000.0), [](IMcChannel* pChannel, int addr, DWORD value, int flag) {
- if (flag == 0) {
- TRACE("\n鍐欏叆鎴愬姛: 鑷姩閫熷害, 鍦板潃: %d, 鍊�: %lu\n", addr, value);
- }
- else {
- TRACE("\n鍐欏叆澶辫触: 鑷姩閫熷害, 鍦板潃: %d, 閿欒鐮�: %d\n", addr, flag);
- }
- });
-
- // 鍐欏叆鍔犻�熸椂闂�, 杞崲涓烘绉�
- m_pPLC->writeDWord(component, startAddress + 62, (int)(axisData.accelerationTime * 1000.0), [](IMcChannel* pChannel, int addr, DWORD value, int flag) {
- if (flag == 0) {
- TRACE("\n鍐欏叆鎴愬姛: 鍔犻�熸椂闂�, 鍦板潃: %d, 鍊�: %lu\n", addr, value);
- }
- else {
- TRACE("\n鍐欏叆澶辫触: 鍔犻�熸椂闂�, 鍦板潃: %d, 閿欒鐮�: %d\n", addr, flag);
- }
- });
-
- // 鍐欏叆鍑忛�熸椂闂�, 杞崲涓烘绉�
- m_pPLC->writeDWord(component, startAddress + 64, (int)(axisData.decelerationTime * 1000.0), [](IMcChannel* pChannel, int addr, DWORD value, int flag) {
- if (flag == 0) {
- TRACE("\n鍐欏叆鎴愬姛: 鍑忛�熸椂闂�, 鍦板潃: %d, 鍊�: %lu\n", addr, value);
- }
- else {
- TRACE("\n鍐欏叆澶辫触: 鍑忛�熸椂闂�, 鍦板潃: %d, 閿欒鐮�: %d\n", addr, flag);
- }
- });
-
- // 鍐欏叆寰姩閲�
- m_pPLC->writeWord(component, startAddress + 81, (int)(axisData.jogDistance * 1000.0), [](IMcChannel* pChannel, int addr, DWORD value, int flag) {
- if (flag == 0) {
- TRACE("\n鍐欏叆鎴愬姛: 寰姩閲�, 鍦板潃: %d, 鍊�: %lu\n", addr, value);
- }
- else {
- TRACE("\n鍐欏叆澶辫触: 寰姩閲�, 鍦板潃: %d, 閿欒鐮�: %d\n", addr, flag);
- }
- });
-
- // 鍐欏叆瀹氫綅鐐规暟鎹�
- int positionStartAddress = startAddress + 100;
- for (size_t i = 0; i < axisData.positions.size(); ++i) {
- const auto& position = axisData.positions[i];
- unsigned int positionAddress = positionStartAddress + (i * 2);
-
- m_pPLC->writeDWord(component, positionAddress, (int)(position.second * 1000), [i, positionAddress](IMcChannel* pChannel, int addr, DWORD value, int flag) {
- if (flag == 0) {
- TRACE("\n鍐欏叆鎴愬姛: 瀹氫綅鐐� %d, 鍦板潃: %d, 鍊�: %lu\n", i + 1, positionAddress, value);
- }
- else {
- TRACE("\n鍐欏叆澶辫触: 瀹氫綅鐐� %d, 鍦板潃: %d, 閿欒鐮�: %d\n", i + 1, positionAddress, flag);
- }
- });
- }
-
-}
-
-void CAxisSettingsDlg::handleAxisOperation(AxisOperationType eOpType, bool bPressed)
-{
- int nAxisId = getCurrentSelectedAxisID();
- if (nAxisId == -1) {
- AfxMessageBox(_T("鏈�夋嫨鏈夋晥鐨勮酱缂栧彿锛�"));
- return;
- }
-
- // 鑾峰彇杞存暟鎹�
- RecipeManager& recipeManager = RecipeManager::getInstance();
- auto axisData = recipeManager.getAxis(nAxisId);
-
- int startAddress;
- MC::SOFT_COMPONENT component;
- if (!ParsePLCAddress(CString(axisData.startAddress.c_str()), component, startAddress)) {
- AfxMessageBox(_T("鏃犳晥鐨勮捣濮嬪湴鍧�锛�"));
- }
-
- // 鏍规嵁鎿嶄綔绫诲瀷璁$畻鐩爣鍦板潃
- int bitIndex = 0;
- char szWrite[4] = { 0x0, 0x0, 0x0, 0x0 };
- switch (eOpType) {
- case AxisOperationType::OPR:
- startAddress += 0; // OPR 淇″彿鍦板潃 0,闂姩淇℃伅06.0
- szWrite[0] = bPressed ? 0x1 : 0;
- break;
- case AxisOperationType::JOG_ADD:
- startAddress += 01; // JOG+ 淇″彿鍦板潃 c
- szWrite[1] = bPressed ? 0x10 : 0;
- break;
- case AxisOperationType::JOG_SUB:
- startAddress += 01; // JOG- 淇″彿鍦板潃 d
- szWrite[1] = bPressed ? 0x20 : 0;
- break;
- case AxisOperationType::STOP:
- startAddress += 05; // STOP 淇″彿鍦板潃 5.e
- szWrite[1] = bPressed ? 0x40 : 0;
- break;
- case AxisOperationType::SEV_ON:
- startAddress += 01; // SEV_ON 淇″彿鍦板潃 1.a
- szWrite[1] = bPressed ? 0x04 : 0;
- break;
- case AxisOperationType::POSITION_1:
- case AxisOperationType::POSITION_2:
- case AxisOperationType::POSITION_3:
- case AxisOperationType::POSITION_4:
- case AxisOperationType::POSITION_5:
- startAddress += ((m_currentPage - 1) * 5 + ((int)eOpType - (int)AxisOperationType::POSITION_1 + 1)) / 16;
- bitIndex = ((m_currentPage-1) * 5 + ((int)eOpType - (int)AxisOperationType::POSITION_1 + 1)) % 16;
- if(bPressed) CToolUnits::setBit(szWrite, bitIndex);
- break;
- default:
- AfxMessageBox(_T("鏈煡鎿嶄綔绫诲瀷锛�"));
- return;
- }
-
- // 鍚� PLC 鍐欏叆淇″彿
- m_pPLC->writeData(component, startAddress, szWrite, 2, [eOpType, startAddress, bPressed](IMcChannel* pChannel, int nAddr, DWORD nValue, int nFlag) {
- if (nFlag == 0) {
- TRACE("鎿嶄綔鎴愬姛锛氱被鍨�=%d锛屽湴鍧�=%d锛屽��=%d\n", static_cast<int>(eOpType), nAddr, bPressed);
- }
- else {
- TRACE("鎿嶄綔澶辫触锛氱被鍨�=%d锛屽湴鍧�=%d锛岄敊璇爜=%d\n", static_cast<int>(eOpType), nAddr, nFlag);
- }
- });
-}
-
-void CAxisSettingsDlg::readPLCDataToUI(int nAxisId)
-{
- // 浠� RecipeManager 鑾峰彇杞存暟鎹�
- RecipeManager& recipeManager = RecipeManager::getInstance();
- auto axisData = recipeManager.getAxis(nAxisId);
-
- MC::SOFT_COMPONENT component;
- int startAddress, endAddress, readSize;
- if (!ParsePLCAddress(CString(axisData.startAddress.c_str()), component, startAddress)) {
- AfxMessageBox(_T("鏃犳晥鐨勮捣濮嬪湴鍧�锛�"));
- }
- endAddress = startAddress + 300;
- readSize = (endAddress - startAddress + 1) * 2;
-
- auto funOnReadData = [&, startAddress, readSize](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) -> void {
- if (nDataSize == readSize && flag == 0 && ::IsWindow(m_hWnd)) {
- m_fCurPos = CToolUnits::toInt32(&pData[20 * 2]) * 0.001;
- m_fManualSpeed = CToolUnits::toInt32(&pData[82 * 2]) * 0.001;
- m_fAutoSpeed = CToolUnits::toInt32(&pData[84 * 2]) * 0.001;
- m_fPrm = CToolUnits::toInt32(&pData[50 * 2]) * 0.1;
- m_nLoad = CToolUnits::toInt16(&pData[54 * 2]);
- m_nErrCode = CToolUnits::toInt16(&pData[26 * 2]);
- m_nAlarmCode = CToolUnits::toInt16(&pData[27 * 2]);
-
- m_bSEV = CToolUnits::getBit(pData[1 * 2 + 1], 0xa - 8);
- m_bFLS = CToolUnits::getBit(pData[10 * 2], 1);
- m_bDOG = CToolUnits::getBit(pData[10 * 2], 6);
- m_bRLS = CToolUnits::getBit(pData[10 * 2], 0);
- m_bReady = CToolUnits::getBit(pData[10 * 2 + 1], 0xA - 8);
- m_bBusy = CToolUnits::getBit(pData[10 * 2 + 1], 0xB - 8);
- m_bErr = CToolUnits::getBit(pData[10 * 2 + 1], 0xF - 8);
-
- PostMessage(ID_MSG_UPDATA_DATA_TO_UI);
- }
- };
- m_pPLC->readData(component, startAddress, readSize, funOnReadData);
-}
-
-
-BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CDialogEx)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_LAST, &CAxisSettingsDlg::OnBnClickedButtonAxisLast)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_NEXT, &CAxisSettingsDlg::OnBnClickedButtonAxisNext)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP1, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup1)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP2, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup2)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP3, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup3)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP4, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup4)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP5, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup5)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT1, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint1)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT2, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint2)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT3, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint3)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT4, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint4)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT5, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint5)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_TEST_OPR, &CAxisSettingsDlg::OnBnClickedButtonAxisTestOpr)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_TEST_STOP, &CAxisSettingsDlg::OnBnClickedButtonAxisTestStop)
- ON_CBN_SELCHANGE(IDC_COMBO_AXIS_NAME, &CAxisSettingsDlg::OnSelchangeComboAxisName)
- ON_BN_CLICKED(IDC_BUTTON_AXIS_SAVE, &CAxisSettingsDlg::OnBnClickedButtonAxisSave)
- ON_MESSAGE(ID_MSG_UPDATA_DATA_TO_UI, &CAxisSettingsDlg::OnUpdateDataToUI)
- ON_WM_SIZE()
- ON_WM_CTLCOLOR()
- ON_WM_SIZING()
- ON_WM_TIMER()
- ON_WM_CLOSE()
- ON_BN_CLICKED(IDC_BUTTON_AXIS_SEV, &CAxisSettingsDlg::OnBnClickedButtonAxisSev)
-END_MESSAGE_MAP()
-
-
-// CAxisSettingsDlg 娑堟伅澶勭悊绋嬪簭
-
-
-BOOL CAxisSettingsDlg::OnInitDialog()
-{
- CDialogEx::OnInitDialog();
-
- // TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
- CString strTitle;
- strTitle.Format(_T("Axis璁惧畾(閰嶆柟: %s)"), m_strRecipeName);
- SetWindowText(strTitle);
-
- // 璁剧疆娴嬭瘯鐘舵��
- CBLLabel* pLabels[] = { &m_staticFLS, &m_staticDOG, &m_staticRLS, &m_staticReady, &m_staticBusy, &m_staticErr };
- for (auto pLabel : pLabels) {
- pLabel->SetBkColor(RGB(0, 180, 0));
- pLabel->ModifyStyle(0, SS_NOTIFY);
- pLabel->SetTextColor(RGB(255, 255, 255));
- pLabel->SetAlignment(AlignCenter);
- pLabel->SetDynamicFont(TRUE);
- }
-
- // 鍒濆鍖栧綋鍓嶉〉闈负绗竴椤�
- m_currentPage = 1;
- updatePageButtonStates();
-
- initializeAxisIDCombo();
- refreshAxisDetails(1);
- refreshPositionDetails(1, m_currentPage);
-
- CRect screenRect, dlgRect, clientRect;
- GetClientRect(&clientRect);
- m_nInitialWidth = clientRect.Width();
- m_nInitialHeight = clientRect.Height();
-
- // 鍒濆鍖栭粯璁ゅ瓧浣�
- CFont* pDefaultFont = GetOrCreateFont(12);
-
- // 閬嶅巻鎵�鏈夊瓙鎺т欢锛岃褰曞垵濮嬩綅缃苟璁剧疆榛樿瀛椾綋
- CWnd* pWnd = GetWindow(GW_CHILD);
- while (pWnd) {
- int nCtrlID = pWnd->GetDlgCtrlID();
- if (nCtrlID != -1) {
- // 璁板綍鎺т欢鍒濆甯冨眬
- CRect ctrlRect;
- pWnd->GetWindowRect(&ctrlRect);
- ScreenToClient(&ctrlRect);
- m_mapCtrlLayouts[nCtrlID] = ctrlRect;
-
- // 璁剧疆榛樿瀛椾綋
- pWnd->SetFont(pDefaultFont);
- }
- pWnd = pWnd->GetNextWindow();
- }
-
- GetWindowRect(&dlgRect);
- int dlgWidth = dlgRect.Width() * 2;
- int dlgHeight = dlgRect.Height() * 2;
-
- SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
- if (dlgWidth > screenRect.Width()) {
- dlgWidth = screenRect.Width();
- }
- if (dlgHeight > screenRect.Height()) {
- dlgHeight = screenRect.Height();
- }
-
- int centerX = screenRect.left + (screenRect.Width() - dlgWidth) / 2;
- int centerY = screenRect.top + (screenRect.Height() - dlgHeight) / 2;
- MoveWindow(centerX, centerY, dlgWidth, dlgHeight);
-
- SetTimer(TIMER_READ_PLC_DATA, 500, nullptr);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
-}
-
-BOOL CAxisSettingsDlg::PreTranslateMessage(MSG* pMsg)
-{
- // TODO: 鍦ㄦ娣诲姞涓撶敤浠g爜鍜�/鎴栬皟鐢ㄥ熀绫�
-
- if (pMsg->message == WM_LBUTTONDOWN) {
- if (pMsg->hwnd == GetDlgItem(IDC_BUTTON_AXIS_TEST_JOG_ADD)->m_hWnd) {
- TRACE("JOG+ 鎸夐挳鎸変笅\n");
- handleAxisOperation(AxisOperationType::JOG_ADD, true);
- }
- else if (pMsg->hwnd == GetDlgItem(IDC_BUTTON_AXIS_TEST_JOG_SUB)->m_hWnd) {
- TRACE("JOG- 鎸夐挳鎸変笅\n");
- // 鍚姩瀹氭椂鍣ㄨ繛缁彂閫佷俊鍙�
- handleAxisOperation(AxisOperationType::JOG_SUB, true);
- }
- }
- else if (pMsg->message == WM_LBUTTONUP) {
- if (pMsg->hwnd == GetDlgItem(IDC_BUTTON_AXIS_TEST_JOG_ADD)->m_hWnd) {
- TRACE("JOG+ 鎸夐挳鏉惧紑\n");
- handleAxisOperation(AxisOperationType::JOG_ADD, false);
- }
- else if (pMsg->hwnd == GetDlgItem(IDC_BUTTON_AXIS_TEST_JOG_SUB)->m_hWnd) {
- TRACE("JOG- 鎸夐挳鏉惧紑\n");
- handleAxisOperation(AxisOperationType::JOG_SUB, false);
- }
- }
-
- return CDialogEx::PreTranslateMessage(pMsg);
-}
-
-void CAxisSettingsDlg::OnSize(UINT nType, int cx, int cy)
-{
- CDialogEx::OnSize(nType, cx, cy);
-
- // TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
- if (nType == SIZE_MINIMIZED || m_mapCtrlLayouts.empty()) {
- return;
- }
-
- float dScaleX = static_cast<float>(cx) / m_nInitialWidth;
- float dScaleY = static_cast<float>(cy) / m_nInitialHeight;
-
- // 閬嶅巻瀵硅瘽妗嗕腑鐨勬墍鏈夋帶浠�
- AdjustControls(dScaleX, dScaleY);
-
- // 鍔ㄦ�佽皟鏁村悇涓� CBLLabel 鐨勫瓧浣撳ぇ灏�
- CBLLabel* pLabels[] = { &m_staticFLS, &m_staticDOG, &m_staticRLS, &m_staticReady, &m_staticBusy, &m_staticErr };
- for (auto pLabel : pLabels) {
- AdjustLabelFont(*pLabel);
- }
-
- // 璋冩暣涓嬫媺妗嗛珮搴�
- CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_AXIS_NAME);
- CButton* pButtonLeft = (CButton*)GetDlgItem(IDC_BUTTON_AXIS_LAST);
- CButton* pButtonRight = (CButton*)GetDlgItem(IDC_BUTTON_AXIS_NEXT);
-
- if (pComboBox && pButtonLeft && pButtonRight) {
- CRect rectButton;
- pButtonLeft->GetWindowRect(&rectButton); // 鑾峰彇鎸夐挳灏哄
- ScreenToClient(&rectButton); // 杞崲涓哄鎴风鍧愭爣
-
- CRect rectComboBox;
- pComboBox->GetWindowRect(&rectComboBox);
- ScreenToClient(&rectComboBox);
-
- // 璋冩暣涓嬫媺妗嗛珮搴�
- int heightAdjustment = 2;
- rectComboBox.top = rectButton.top;
- rectComboBox.bottom = rectButton.bottom + heightAdjustment;
- pComboBox->MoveWindow(&rectComboBox);
- pComboBox->SetItemHeight(-1, rectButton.Height() - 6);
- }
-}
-
-void CAxisSettingsDlg::OnSizing(UINT fwSide, LPRECT pRect)
-{
- if (fwSide == WMSZ_BOTTOMRIGHT) {
- if (pRect->right - pRect->left < 200) {
- pRect->right = pRect->left + 200;
- }
- if (pRect->bottom - pRect->top < 150) {
- pRect->bottom = pRect->top + 150;
- }
- }
-
- CDialogEx::OnSizing(fwSide, pRect);
-}
-
-HBRUSH CAxisSettingsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
-{
- HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
-
- // TODO: 鍦ㄦ鏇存敼 DC 鐨勪换浣曠壒鎬�
-
- // TODO: 濡傛灉榛樿鐨勪笉鏄墍闇�鐢荤瑪锛屽垯杩斿洖鍙︿竴涓敾绗�
- return hbr;
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisLast()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- updateAxisSelection(-1);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisNext()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- updateAxisSelection(1);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup1()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- switchToPage(1);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup2()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- switchToPage(2);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup3()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- switchToPage(3);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup4()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- switchToPage(4);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup5()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- switchToPage(5);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint1()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::POSITION_1, true);
- Sleep(200);
- handleAxisOperation(AxisOperationType::POSITION_1, false);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint2()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::POSITION_2, true);
- Sleep(200);
- handleAxisOperation(AxisOperationType::POSITION_2, false);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint3()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::POSITION_3, true);
- Sleep(200);
- handleAxisOperation(AxisOperationType::POSITION_3, false);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint4()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::POSITION_4, true);
- Sleep(200);
- handleAxisOperation(AxisOperationType::POSITION_4, false);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint5()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::POSITION_5, true);
- Sleep(200);
- handleAxisOperation(AxisOperationType::POSITION_5, false);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisTestOpr()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::OPR, true);
- Sleep(200);
- handleAxisOperation(AxisOperationType::OPR, false);
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisTestStop()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::STOP, true);
- Sleep(200);
- handleAxisOperation(AxisOperationType::STOP, false);
-}
-
-void CAxisSettingsDlg::OnSelchangeComboAxisName()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- int axisId = getCurrentSelectedAxisID();
- if (axisId == -1) {
- AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
- return;
- }
-
- refreshAxisDetails(axisId);
- refreshPositionDetails(axisId, m_currentPage);
- updatePageButtonStates();
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisSave()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- int axisId = getCurrentSelectedAxisID();
- if (axisId == -1) {
- AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
- return;
- }
-
- CString cstrMessage;
- cstrMessage.Format(_T("鏄惁淇濆瓨杞� [%d] 鍙傛暟锛�"), axisId);
- int ret = AfxMessageBox(_T(cstrMessage), MB_OKCANCEL | MB_ICONEXCLAMATION);
- if (ret != IDOK) {
- return;
- }
-
- updateDataFromUI(axisId);
- if (RecipeManager::getInstance().saveRecipe(std::string(CT2A(m_strRecipeName)))) {
- writeAxisDataToPLC(axisId);
- cstrMessage.Format(_T("淇濆瓨杞� [%d] 鍙傛暟鎴愬姛锛�"), axisId);
- SystemLogManager::getInstance().log(SystemLogManager::LogType::Operation, std::string(CT2A(cstrMessage)));
- }
- else {
- cstrMessage.Format(_T("淇濆瓨杞� [%d] 鍙傛暟澶辫触锛�"), axisId);
- SystemLogManager::getInstance().log(SystemLogManager::LogType::Error, std::string(CT2A(cstrMessage)));
- }
-
- AfxMessageBox(cstrMessage);
-}
-
-LRESULT CAxisSettingsDlg::OnUpdateDataToUI(WPARAM wParam, LPARAM lParam)
-{
- CToolUnits::setDlgItemDouble(this, IDC_EDIT_AXIS_CURR_POS, m_fCurPos);
- CToolUnits::setDlgItemDouble(this, IDC_EDIT_AXIS_CURR_MANUAL_SPEED, m_fManualSpeed);
- CToolUnits::setDlgItemDouble(this, IDC_EDIT_AXIS_CURR_AUTO_SPEED, m_fAutoSpeed);
- CToolUnits::setDlgItemDouble(this, IDC_EDIT_AXIS_CURR_ROTA_SPEED, m_fPrm);
- SetDlgItemInt(IDC_EDIT_AXIS_CURR_LOAD, m_nLoad);
- SetDlgItemInt(IDC_EDIT_AXIS_CURR_ERROR_NUMBER, m_nErrCode);
- SetDlgItemInt(IDC_EDIT_AXIS_CURR_ALARM_NUMBER, m_nAlarmCode);
-
- //OPR 淇″彿
- if (m_bFLS) {
- SetLabelColor(m_staticFLS, RGB(0, 255, 0));
- }
- else {
- SetLabelColor(m_staticFLS, RGB(0, 180, 0));
- }
-
- if (m_bDOG) {
- SetLabelColor(m_staticDOG, RGB(0, 255, 0));
- }
- else {
- SetLabelColor(m_staticDOG, RGB(0, 180, 0));
- }
-
- if (m_bRLS) {
- SetLabelColor(m_staticRLS, RGB(0, 255, 0));
- }
- else {
- SetLabelColor(m_staticRLS, RGB(0, 180, 0));
- }
-
- if (m_bReady) {
- SetLabelColor(m_staticReady, RGB(0, 255, 0));
- }
- else {
- SetLabelColor(m_staticReady, RGB(0, 180, 0));
- }
-
- if (m_bBusy) {
- SetLabelColor(m_staticBusy, RGB(0, 255, 0));
- }
- else {
- SetLabelColor(m_staticBusy, RGB(0, 180, 0));
- }
-
- if (m_bErr) {
- SetLabelColor(m_staticErr, RGB(255, 0, 0));
- }
- else {
- SetLabelColor(m_staticErr, RGB(0, 180, 0));
- }
-
- return 0;
-}
-
-void CAxisSettingsDlg::OnTimer(UINT_PTR nIDEvent)
-{
- if (TIMER_READ_PLC_DATA == nIDEvent) {
- ASSERT(m_pPLC);
-
- int nAxisId = getCurrentSelectedAxisID();
- if (nAxisId == -1) {
- return;
- }
-
- readPLCDataToUI(nAxisId);
- }
-
- CDialogEx::OnTimer(nIDEvent);
-}
-
-void CAxisSettingsDlg::OnClose()
-{
- // TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
- KillTimer(TIMER_READ_PLC_DATA);
-
- CDialogEx::OnClose();
-}
-
-void CAxisSettingsDlg::OnBnClickedButtonAxisSev()
-{
- // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
- handleAxisOperation(AxisOperationType::SEV_ON, !m_bSEV);
-}
diff --git a/SourceCode/Bond/BondEq/AxisSettingsDlg.h b/SourceCode/Bond/BondEq/AxisSettingsDlg.h
deleted file mode 100644
index 688f61b..0000000
--- a/SourceCode/Bond/BondEq/AxisSettingsDlg.h
+++ /dev/null
@@ -1,130 +0,0 @@
-锘�#pragma once
-#include "afxdialogex.h"
-#include "BlButton.h"
-#include "BLLabel.h"
-#include "CPLC.h"
-
-// CAxisSettingsDlg 瀵硅瘽妗�
-
-enum class AxisOperationType {
- OPR = 0, // 鍥炲師鐐�
- JOG_ADD, // 姝e悜鐐瑰姩
- JOG_SUB, // 鍙嶅悜鐐瑰姩
- STOP, // 鍋滄鎿嶄綔
- SEV_ON, // 浣胯兘
- POSITION_1, // 瀹氫綅鐐�1
- POSITION_2, // 瀹氫綅鐐�2
- POSITION_3, // 瀹氫綅鐐�3
- POSITION_4, // 瀹氫綅鐐�4
- POSITION_5 // 瀹氫綅鐐�5
-};
-
-class CAxisSettingsDlg : public CDialogEx
-{
- DECLARE_DYNAMIC(CAxisSettingsDlg)
-
-public:
- CAxisSettingsDlg(CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
- virtual ~CAxisSettingsDlg();
-
-public:
- void SetPLC(CPLC* pPLC);
- void SetRecipeName(const CString& strRecipeName);
-
-// 瀵硅瘽妗嗘暟鎹�
-#ifdef AFX_DESIGN_TIME
- enum { IDD = IDD_DIALOG_AXIS_SETTINGS };
-#endif
-
-private:
- UINT FindIDByName(const CString& strControlID);
- CFont* GetOrCreateFont(int nFontSize);
- void SetDefaultFont();
- void AdjustControls(float dScaleX, float dScaleY);
- void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
- void AdjustLabelFont(CBLLabel& label);
- void SetLabelColor(CBLLabel& label, COLORREF color);
- void updatePageButtonStates();
- int getCurrentSelectedAxisID();
- void initializeAxisIDCombo();
- void refreshAxisDetails(int nAxisId);
- void refreshPositionDetails(int nAxisId, int pageNumber);
- void updateAxisSelection(int offset);
- void updateDataFromUI(int nAxisId);
- void switchToPage(int targetPage);
- bool ParsePLCAddress(const CString& address, MC::SOFT_COMPONENT& component, int& addr);
- void writeAxisDataToPLC(int nAxisId);
- void handleAxisOperation(AxisOperationType eOpType, bool bPressed);
- void readPLCDataToUI(int nAxisId);
-
-private:
- CPLC* m_pPLC;
- int m_nInitialWidth;
- int m_nInitialHeight;
-
- // 褰撳墠閫変腑鐨勫畾浣嶉〉闈㈢储寮�
- int m_currentPage;
-
- // 閰嶆柟鍚嶇О
- CString m_strRecipeName;
-
- // 鎸変笅鏍囪瘑
- BOOL m_bJogAddPressed;
- BOOL m_bJogSubPressed;
-
- // 鎺т欢
- CBLLabel m_staticFLS, m_staticDOG, m_staticRLS, m_staticReady, m_staticBusy, m_staticErr;
- CComboBox m_comboAxisNO;
- CStatic m_staticAxisNO, m_staticAxisDescription, m_staticStartAddress;
- CEdit m_editManualSpeed, m_editAutoSpeed, m_editAccelerationTime, m_editDecelerationTime, m_editJogDistance;
- CBlButton m_pageButtons[5];
-
- std::map<int, CRect> m_mapCtrlLayouts;
- std::map<int, CFont*> m_mapFonts;
-
- // 璇诲埌鐨勬暟鎹�
- BOOL m_bSEV;
- double m_fCurPos;
- double m_fManualSpeed;
- double m_fAutoSpeed;
- double m_fPrm;
- int m_nLoad;
- int m_nErrCode;
- int m_nAlarmCode;
- BOOL m_bFLS;
- BOOL m_bDOG;
- BOOL m_bRLS;
- BOOL m_bReady;
- BOOL m_bBusy;
- BOOL m_bErr;
-
-protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 鏀寔
- virtual BOOL OnInitDialog();
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
- afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
- afx_msg void OnBnClickedButtonAxisLast();
- afx_msg void OnBnClickedButtonAxisNext();
- afx_msg void OnBnClickedButtonAxisAnchorPointGroup1();
- afx_msg void OnBnClickedButtonAxisAnchorPointGroup2();
- afx_msg void OnBnClickedButtonAxisAnchorPointGroup3();
- afx_msg void OnBnClickedButtonAxisAnchorPointGroup4();
- afx_msg void OnBnClickedButtonAxisAnchorPointGroup5();
- afx_msg void OnBnClickedButtonAxisAnchorPoint1();
- afx_msg void OnBnClickedButtonAxisAnchorPoint2();
- afx_msg void OnBnClickedButtonAxisAnchorPoint3();
- afx_msg void OnBnClickedButtonAxisAnchorPoint4();
- afx_msg void OnBnClickedButtonAxisAnchorPoint5();
- afx_msg void OnBnClickedButtonAxisTestOpr();
- afx_msg void OnBnClickedButtonAxisTestStop();
- afx_msg void OnSelchangeComboAxisName();
- afx_msg void OnBnClickedButtonAxisSave();
- afx_msg LRESULT OnUpdateDataToUI(WPARAM wParam, LPARAM lParam);
- afx_msg void OnTimer(UINT_PTR nIDEvent);
- afx_msg void OnClose();
- DECLARE_MESSAGE_MAP()
-public:
- afx_msg void OnBnClickedButtonAxisSev();
-};
diff --git a/SourceCode/Bond/BondEq/BondEq.rc b/SourceCode/Bond/BondEq/BondEq.rc
index f3596f0..b81e838 100644
--- a/SourceCode/Bond/BondEq/BondEq.rc
+++ b/SourceCode/Bond/BondEq/BondEq.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/BondEq.vcxproj b/SourceCode/Bond/BondEq/BondEq.vcxproj
index 73727f0..c76af03 100644
--- a/SourceCode/Bond/BondEq/BondEq.vcxproj
+++ b/SourceCode/Bond/BondEq/BondEq.vcxproj
@@ -245,6 +245,7 @@
<ClInclude Include="Model.h" />
<ClInclude Include="CPageAlarm.h" />
<ClInclude Include="Recipe.h" />
+ <ClInclude Include="RegexEdit.h" />
<ClInclude Include="Resource.h" />
<ClInclude Include="SetPage1.h" />
<ClInclude Include="SetPage2.h" />
@@ -256,6 +257,7 @@
<ClInclude Include="ToolUnits.h" />
<ClInclude Include="TopToolbar.h" />
<ClInclude Include="VerticalLine.h" />
+ <ClInclude Include="View\AxisDetailSettingsDlg.h" />
<ClInclude Include="View\AxisSettingsDlg.h" />
<ClInclude Include="View\ChangePasswordDlg.h" />
<ClInclude Include="View\IOMonitoringDlg.h" />
@@ -318,6 +320,7 @@
<ClCompile Include="Model.cpp" />
<ClCompile Include="CPageAlarm.cpp" />
<ClCompile Include="Recipe.cpp" />
+ <ClCompile Include="RegexEdit.cpp" />
<ClCompile Include="SetPage1.cpp" />
<ClCompile Include="SetPage2.cpp" />
<ClCompile Include="SettingsDlg.cpp" />
@@ -333,6 +336,7 @@
<ClCompile Include="ToolUnits.cpp" />
<ClCompile Include="TopToolbar.cpp" />
<ClCompile Include="VerticalLine.cpp" />
+ <ClCompile Include="View\AxisDetailSettingsDlg.cpp" />
<ClCompile Include="View\AxisSettingsDlg.cpp" />
<ClCompile Include="View\ChangePasswordDlg.cpp" />
<ClCompile Include="View\IOMonitoringDlg.cpp" />
diff --git a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
index 004463c..86c978d 100644
--- a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
+++ b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
@@ -37,6 +37,8 @@
axisInfo.number = axisNode.attribute("number").value();
axisInfo.description = axisNode.attribute("description").value();
axisInfo.startAddress = axisNode.attribute("start_address").value();
+ //axisInfo.maxPositioningSpeed = axisNode.attribute("maxPositioningSpeed").as_double();
+ //axisInfo.maxManualSpeed = axisNode.attribute("maxManualSpeed").as_double();
// 加载 ValueRange 值
axisInfo.jogDistance = ValueRange(
@@ -66,7 +68,9 @@
);
// 加载 PositionRange 值
+ axisInfo.positioningPointCount = axisNode.child("Positions").attribute("positioningPointCount").as_int();
for (auto positionNode : axisNode.child("Positions").children("Position")) {
+ bool isEnable = positionNode.attribute("isEnable").as_bool();
std::string description = positionNode.attribute("description").value();
ValueRange positionRange(
positionNode.attribute("min").as_double(),
@@ -74,7 +78,7 @@
positionNode.attribute("current").as_double()
);
- axisInfo.positions.emplace_back(PositionRange(description, positionRange));
+ axisInfo.positions.emplace_back(PositionRange(isEnable, description, positionRange));
}
m_axes[axisInfo.id] = axisInfo;
@@ -111,6 +115,8 @@
axisNode.append_attribute("number") = axisInfo.number.c_str();
axisNode.append_attribute("description") = axisInfo.description.c_str();
axisNode.append_attribute("start_address") = axisInfo.startAddress.c_str();
+ //axisNode.append_attribute("maxPositioningSpeed") = axisInfo.maxPositioningSpeed;
+ //axisNode.append_attribute("maxManualSpeed") = axisInfo.maxManualSpeed;
// 保存 ValueRange 值
auto jog_distance = axisNode.append_child("jog_distance");
@@ -140,8 +146,10 @@
// 保存 PositionRange 值
auto positionsNode = axisNode.append_child("Positions");
+ positionsNode.append_attribute("positioningPointCount") = axisInfo.positioningPointCount;
for (const auto& position : axisInfo.positions) {
auto positionNode = positionsNode.append_child("Position");
+ positionNode.append_attribute("isEnable") = position.isEnable;
positionNode.append_attribute("description") = position.description.c_str();
positionNode.append_attribute("min") = position.range.minValue;
positionNode.append_attribute("max") = position.range.maxValue;
@@ -160,6 +168,9 @@
for (int axisId = 1; axisId <= 12; ++axisId) {
AxisInfo axisInfo;
axisInfo.id = axisId;
+ axisInfo.positioningPointCount = 25;
+ //axisInfo.maxPositioningSpeed = 100.0;
+ //axisInfo.maxManualSpeed = 100.0;
axisInfo.number = "M100-M" + std::to_string(axisId);
axisInfo.description = "Default_Axis" + std::to_string(axisId);
axisInfo.startAddress = "ZR" + std::to_string(10000 + (axisId - 1) * 300);
@@ -172,10 +183,10 @@
axisInfo.decelerationTime = ValueRange(1.0, 10.0, 1.0);
// 添加定位点并设置默认的最小值和最大值
- for (int posId = 1; posId <= 25; ++posId) {
- double minPos = posId * 5.0;
- double maxPos = posId * 20.0;
- axisInfo.positions.emplace_back(PositionRange("Position " + std::to_string(posId), ValueRange(minPos, maxPos, posId * 10.0)));
+ for (int posId = 0; posId < axisInfo.positioningPointCount; ++posId) {
+ double minPos = (posId + 1) * 5.0;
+ double maxPos = (posId + 1) * 20.0;
+ axisInfo.positions.emplace_back(PositionRange(TRUE, "Position " + std::to_string(posId + 1), ValueRange(minPos, maxPos, (posId + 1) * 10.0)));
}
m_axes[axisId] = axisInfo;
@@ -195,7 +206,7 @@
}
// 如果没有找到该轴,返回一个默认的无效 AxisInfo
- return AxisInfo{ -1, "", "", "", ValueRange(), ValueRange(), ValueRange(), ValueRange(), ValueRange(), {} };
+ return AxisInfo{ -1, 0, /*0.0, 0.0,*/ "", "", "", ValueRange(), ValueRange(), ValueRange(), ValueRange(), ValueRange(), {} };
}
// 更新轴信息
diff --git a/SourceCode/Bond/BondEq/FileManager/RecipeManager.h b/SourceCode/Bond/BondEq/FileManager/RecipeManager.h
index aabc1b5..f0c873c 100644
--- a/SourceCode/Bond/BondEq/FileManager/RecipeManager.h
+++ b/SourceCode/Bond/BondEq/FileManager/RecipeManager.h
@@ -17,17 +17,21 @@
};
struct PositionRange {
+ BOOL isEnable; // 是否启用
std::string description; // 定位点描述
ValueRange range; // 位置的最小值、最大值和当前值
// 构造函数初始化
- PositionRange(const std::string& desc = "", const ValueRange& r = ValueRange())
- : description(desc), range(r) {}
+ PositionRange(BOOL b = TRUE, const std::string& desc = "", const ValueRange& r = ValueRange())
+ :isEnable(b), description(desc), range(r) {}
};
// 轴信息结构体
struct AxisInfo {
int id; // 轴ID
+ int positioningPointCount; // 定位点数
+ //double maxPositioningSpeed; // 定位速度上限
+ //double maxManualSpeed; // 手动速度上限
std::string number; // 轴编号
std::string description; // 轴描述
std::string startAddress; // 起始地址
diff --git a/SourceCode/Bond/BondEq/RegexEdit.cpp b/SourceCode/Bond/BondEq/RegexEdit.cpp
new file mode 100644
index 0000000..eaf8879
--- /dev/null
+++ b/SourceCode/Bond/BondEq/RegexEdit.cpp
@@ -0,0 +1,143 @@
+#include "stdafx.h"
+#include "RegexEdit.h"
+#include <stdexcept>
+
+IMPLEMENT_DYNAMIC(CRegexEdit, CEdit)
+
+CRegexEdit::CRegexEdit()
+{
+ m_enRegexType = RegexType::Alphanumeric;
+ m_dMinValue = LDBL_MIN;
+ m_dMaxValue = LDBL_MAX;
+}
+
+CRegexEdit::~CRegexEdit()
+{
+}
+
+void CRegexEdit::SetRegexType(RegexType enType)
+{
+ m_enRegexType = enType;
+}
+
+void CRegexEdit::SetCustomRegex(const std::string& strCustomRegex)
+{
+ m_strCustomRegex = strCustomRegex;
+}
+
+void CRegexEdit::SetValueRange(long double dMinValue, long double dMaxValue)
+{
+ m_dMinValue = dMinValue;
+ m_dMaxValue = dMaxValue;
+}
+
+void CRegexEdit::SetCustomComparator(std::function<bool(const std::string&)> comparator)
+{
+ m_customComparator = comparator;
+}
+
+void CRegexEdit::SetInvalidInputCallback(std::function<void()> callback)
+{
+ m_invalidInputCallback = callback;
+}
+
+bool CRegexEdit::FindMatch(const std::string& pattern, std::string& foundText)
+{
+ CString currentText;
+ GetWindowText(currentText);
+
+ std::string text(CT2A(currentText.GetString()));
+ std::regex regexPattern(pattern);
+ std::smatch match;
+
+ if (std::regex_search(text, match, regexPattern)) {
+ foundText = match.str();
+ return true;
+ }
+ return false;
+}
+
+void CRegexEdit::ReplaceMatch(const std::string& pattern, const std::string& replacement)
+{
+ CString currentText;
+ GetWindowText(currentText);
+
+ std::string text(CT2A(currentText.GetString()));
+ std::regex regexPattern(pattern);
+ std::string result = std::regex_replace(text, regexPattern, replacement);
+
+ SetWindowText(CString(result.c_str()));
+}
+
+std::regex CRegexEdit::GetCurrentRegex() const
+{
+ switch (m_enRegexType)
+ {
+ case RegexType::Alphanumeric:
+ return std::regex("^[a-zA-Z0-9]*$"); // 字母和数字
+ case RegexType::Letters:
+ return std::regex("^[a-zA-Z]*$"); // 只允许字母
+ case RegexType::Digits:
+ return std::regex("^\\d*$"); // 只允许数字
+ case RegexType::Decimal:
+ return std::regex("^[-+]?\\d+(\\.\\d+)?$"); // 允许小数和整数
+ case RegexType::Custom:
+ return std::regex(m_strCustomRegex); // 自定义正则
+ default:
+ return std::regex(".*"); // 默认允许输入任何内容
+ }
+}
+
+bool CRegexEdit::IsValueInRange(const std::string& strText)
+{
+ try {
+ if (m_enRegexType == RegexType::Digits || m_enRegexType == RegexType::Decimal) {
+ if (strText.find('.') == std::string::npos) {
+ int nValue = std::stoi(strText);
+ return nValue >= static_cast<int>(m_dMinValue) && nValue <= static_cast<int>(m_dMaxValue);
+ }
+ else {
+ double dValue = std::stod(strText);
+ return dValue >= m_dMinValue && dValue <= m_dMaxValue;
+ }
+ }
+ }
+ catch (const std::invalid_argument&) {
+ return false;
+ }
+
+ return true;
+}
+
+BEGIN_MESSAGE_MAP(CRegexEdit, CEdit)
+ ON_WM_CHAR()
+END_MESSAGE_MAP()
+
+void CRegexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
+{
+ // 处理删除键和退格键
+ if (nChar == VK_BACK || nChar == VK_DELETE) {
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
+ return;
+ }
+
+ CString strCurrent;
+ GetWindowText(strCurrent);
+
+ // 获取光标当前位置
+ int nStartChar, nEndChar;
+ GetSel(nStartChar, nEndChar); // 获取当前选区的起始和结束位置
+
+ std::string strText(CT2A(strCurrent.GetBuffer()));
+ strText.insert(strText.begin() + nStartChar, (char)nChar);
+
+ bool bValid = m_customComparator ? m_customComparator(strText) : IsValueInRange(strText);
+ if (std::regex_match(strText, GetCurrentRegex()) && bValid) {
+ CEdit::OnChar(nChar, nRepCnt, nFlags);
+ }
+ else {
+ if (m_invalidInputCallback) {
+ m_invalidInputCallback();
+ }
+ }
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/RegexEdit.h b/SourceCode/Bond/BondEq/RegexEdit.h
new file mode 100644
index 0000000..0632d00
--- /dev/null
+++ b/SourceCode/Bond/BondEq/RegexEdit.h
@@ -0,0 +1,74 @@
+#if !defined(AFX_REGEXEDIT_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)
+#define AFX_REGEXEDIT_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif // _MSC_VER >= 1000
+
+#include <afxwin.h>
+#include <regex>
+#include <functional>
+#include <limits>
+
+// 枚举类型:正则表达式类型
+enum class RegexType
+{
+ Alphanumeric, // 允许字母和数字
+ Letters, // 只允许字母
+ Digits, // 只允许数字
+ Decimal, // 允许小数和整数
+ Custom // 自定义正则
+};
+
+class CRegexEdit : public CEdit
+{
+ DECLARE_DYNAMIC(CRegexEdit)
+
+public:
+ // 构造与析构
+ CRegexEdit();
+ virtual ~CRegexEdit();
+
+ // 设置正则类型
+ void SetRegexType(RegexType enType);
+
+ // 设置自定义正则表达式
+ void SetCustomRegex(const std::string& strCustomRegex);
+
+ // 设置数值范围(整数或浮点)
+ void SetValueRange(long double dMinValue, long double dMaxValue);
+
+ // 设置自定义比较函数
+ void SetCustomComparator(std::function<bool(const std::string&)> comparator);
+
+ // 设置输入不合法函数
+ void SetInvalidInputCallback(std::function<void()> callback);
+
+ // 查找匹配内容
+ bool FindMatch(const std::string& pattern, std::string& foundText);
+
+ // 替换匹配内容
+ void ReplaceMatch(const std::string& pattern, const std::string& replacement);
+
+protected:
+ // 根据枚举值返回对应的正则表达式
+ std::regex GetCurrentRegex() const;
+
+ // 校验输入是否在指定范围内
+ bool IsValueInRange(const std::string& strText);
+
+protected:
+ RegexType m_enRegexType; // 当前选中的正则类型
+ std::string m_strCustomRegex; // 自定义正则表达式
+ long double m_dMinValue; // 最小值
+ long double m_dMaxValue; // 最大值
+
+ std::function<bool(const std::string&)> m_customComparator; // 自定义比较函数
+ std::function<void()> m_invalidInputCallback; // 不合法输入的回调函数
+
+protected:
+ void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
+ DECLARE_MESSAGE_MAP()
+};
+
+#endif // !defined(AFX_REGEXEDIT_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/Resource.h b/SourceCode/Bond/BondEq/Resource.h
index 0e92991..bbb9b9c 100644
--- a/SourceCode/Bond/BondEq/Resource.h
+++ b/SourceCode/Bond/BondEq/Resource.h
Binary files differ
diff --git a/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp
new file mode 100644
index 0000000..e010f8b
--- /dev/null
+++ b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp
@@ -0,0 +1,419 @@
+锘�// AxisDetailSettingsDlg.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "BondEq.h"
+#include "afxdialogex.h"
+#include "AxisDetailSettingsDlg.h"
+#include "NewCellTypes/GridCellCheck.h"
+#include "NewCellTypes/GridCellNumeric.h"
+
+
+// CAxisDetailSettingsDlg 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CAxisDetailSettingsDlg, CDialogEx)
+
+CAxisDetailSettingsDlg::CAxisDetailSettingsDlg(const CString& strRecipeName, int nAxisNO, CWnd* pParent /*=nullptr*/)
+ : CDialogEx(IDD_DIALOG_AXIS_DETAIL_SETTINGS, pParent)
+{
+ m_strRecipeName = strRecipeName;
+ m_nAxisNO = nAxisNO;
+
+ m_pPLC = nullptr;
+ m_nInitialWidth = 0;
+ m_nInitialHeight = 0;
+}
+
+CAxisDetailSettingsDlg::~CAxisDetailSettingsDlg()
+{
+}
+
+void CAxisDetailSettingsDlg::SetPLC(CPLC* pPLC)
+{
+ ASSERT(pPLC);
+ m_pPLC = pPLC;
+}
+
+void CAxisDetailSettingsDlg::InitAnchorPontManager()
+{
+ if (m_grid.GetSafeHwnd() == NULL)
+ return;
+
+ int nRows = 1;
+ int nCols = 6;
+
+ int nFixRows = 1;
+ int nFixCols = 0;
+ int nRowIdx = 0;
+ int nColIdx = 0;
+
+ m_grid.DeleteAllItems();
+ m_grid.SetVirtualMode(FALSE);
+ m_grid.GetDefaultCell(TRUE, FALSE)->SetBackClr(g_nGridFixCellColor); // 璁剧疆鍥哄畾琛岃儗鏅壊
+ m_grid.GetDefaultCell(FALSE, TRUE)->SetBackClr(g_nGridFixCellColor); // 璁剧疆鍥哄畾鍒楄儗鏅壊
+ m_grid.GetDefaultCell(FALSE, FALSE)->SetBackClr(g_nGridCellColor); // 璁剧疆鍗曞厓鏍艰儗鏅壊
+ m_grid.SetFixedTextColor(g_nGridFixFontColor); // 璁剧疆鍥哄畾琛屽垪瀛椾綋棰滆壊
+
+ m_grid.SetRowCount(nRows);
+ m_grid.SetColumnCount(nCols);
+ m_grid.SetFixedRowCount(nFixRows);
+ m_grid.SetFixedColumnCount(nFixCols);
+
+ // Col
+ m_grid.SetColumnWidth(nColIdx, 10);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("No."));
+ m_grid.SetColumnWidth(nColIdx, 10);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("婵�娲�"));
+ m_grid.SetColumnWidth(nColIdx, 50);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("鏈�灏忓��"));
+ m_grid.SetColumnWidth(nColIdx, 50);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("褰撳墠鍊�"));
+ m_grid.SetColumnWidth(nColIdx, 50);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("鏈�澶у��"));
+ m_grid.SetColumnWidth(nColIdx, 120);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("鎻忚堪"));
+
+ m_grid.SetFixedRowSelection(FALSE);
+ m_grid.SetFixedColumnSelection(FALSE);
+ m_grid.SetEditable(TRUE);
+ m_grid.SetRowResize(FALSE);
+ m_grid.SetColumnResize(TRUE);
+ m_grid.ExpandColumnsToFit(TRUE);
+ m_grid.SetListMode(TRUE); // 鍚敤鍒楄〃妯″紡
+ m_grid.EnableSelection(TRUE); // 鍚敤閫夋嫨
+ m_grid.SetSingleRowSelection(TRUE); // 鑷姩鏁磋楂樹寒锛堥檺鍒朵负鍗曡閫夋嫨锛�
+ m_grid.ExpandLastColumn(); // 鏈�鍚庝竴鍒楀~鍏呯綉鏍�
+
+ FillAnchorPontManager();
+}
+
+void CAxisDetailSettingsDlg::FillAnchorPontManager()
+{
+ RecipeManager& g_recipeManager = RecipeManager::getInstance();
+ auto axisDetails = g_recipeManager.getAxis(m_nAxisNO);
+
+ int nRowIndex = 1;
+ int nPositionsSize = (int)axisDetails.positions.size();
+
+ // 娓呴櫎鏁版嵁琛岋紝淇濈暀琛ㄥご
+ for (int i = 1; i < m_grid.GetRowCount(); i++) {
+ m_grid.DeleteRow(i);
+ }
+
+ // 璁剧疆琛ㄦ牸琛屾暟
+ m_grid.SetRowCount(axisDetails.positioningPointCount + 1);
+ auto SetCellText = [this](int nRow, int nCol, const CString& strText, UINT nState = GVIS_READONLY) {
+ m_grid.SetItemText(nRow, nCol, strText);
+ m_grid.SetItemState(nRow, nCol, nState);
+ };
+
+ auto FormatFloatToString = [](double dValue) -> CString {
+ CString strText;
+ strText.Format(_T("%.3f"), dValue);
+ return strText;
+ };
+
+ for (int nIndex = 0; nIndex < axisDetails.positioningPointCount; nIndex++) {
+ m_grid.SetItemState(nIndex, 0, GVIS_READONLY); // 搴忓彿鍒楄缃彧璇�
+ SetCellText(nRowIndex, 0, CString(std::to_string(nRowIndex).c_str()));
+
+ if (nIndex >= nPositionsSize) {
+ // 娣诲姞鏂拌鐨勯粯璁ゅ��
+ if (m_grid.SetCellType(nRowIndex, 1, RUNTIME_CLASS(CGridCellCheck))) {
+ auto* pCell = static_cast<CGridCellCheck*>(m_grid.GetCell(nRowIndex, 1));
+ pCell->SetCheck(TRUE);
+ }
+
+ SetCellText(nRowIndex, 2, FormatFloatToString(0.0), GVIS_MODIFIED);
+ SetCellText(nRowIndex, 3, FormatFloatToString(1.0), GVIS_MODIFIED);
+ SetCellText(nRowIndex, 4, FormatFloatToString(10.0), GVIS_MODIFIED);
+ SetCellText(nRowIndex, 5, CString(_T("Position ")) + CString(std::to_string(nIndex + 1).c_str()), GVIS_MODIFIED);
+ }
+ else {
+ const auto& enPosition = axisDetails.positions[nIndex];
+
+ if (m_grid.SetCellType(nRowIndex, 1, RUNTIME_CLASS(CGridCellCheck))) {
+ auto* pCell = static_cast<CGridCellCheck*>(m_grid.GetCell(nRowIndex, 1));
+ pCell->SetCheck(enPosition.isEnable);
+ }
+
+ UINT nCellState = enPosition.isEnable ? GVIS_MODIFIED : GVIS_READONLY;
+
+ SetCellText(nRowIndex, 2, FormatFloatToString(enPosition.range.minValue), nCellState);
+ SetCellText(nRowIndex, 3, FormatFloatToString(enPosition.range.currentValue), nCellState);
+ SetCellText(nRowIndex, 4, FormatFloatToString(enPosition.range.maxValue), nCellState);
+ SetCellText(nRowIndex, 5, CString(enPosition.description.c_str()), nCellState);
+ }
+
+ nRowIndex++;
+ }
+
+ m_grid.ExpandColumnsToFit(FALSE);
+ m_grid.ExpandLastColumn();
+ m_grid.Invalidate();
+ m_grid.UpdateWindow();
+}
+
+void CAxisDetailSettingsDlg::UpdateAxisDetailSettings()
+{
+ // 鑾峰彇杞存暟鎹�
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ auto axisDetails = recipeManager.getAxis(m_nAxisNO);
+
+ auto formatDouble = [](double value) -> CString {
+ CString str;
+ str.Format(_T("%.3f"), value);
+ return str;
+ };
+
+ auto formatInt = [](int value) -> CString {
+ CString str;
+ str.Format(_T("%d"), value);
+ return str;
+ };
+
+ m_staticAxisNO.SetWindowText(CString(axisDetails.number.c_str())); // 杞寸紪鍙�
+ m_staticAxisDescription.SetWindowText(CString(axisDetails.description.c_str())); // 杞存弿杩�
+ m_staticStartAddress.SetWindowText(CString(axisDetails.startAddress.c_str())); // 璧峰鍦板潃
+
+ //GetDlgItem(IDC_EDIT_AXIS_POSITIONING_SPEED_LIMIT)->SetWindowText(formatDouble(axisDetails.maxPositioningSpeed)); // 瀹氫綅閫熷害涓婇檺
+ //GetDlgItem(IDC_EDIT_AXIS_JOG_SPEED_LIMIT)->SetWindowText(formatDouble(axisDetails.maxManualSpeed)); // 鎵嬪姩閫熷害涓婇檺
+ GetDlgItem(IDC_EDIT_AXIS_POSITIONING_POINTS)->SetWindowText(formatInt(axisDetails.positioningPointCount)); // 瀹氫綅鐐规暟
+
+ // 寰姩閲�
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM_MIN)->SetWindowText(formatDouble(axisDetails.jogDistance.minValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM)->SetWindowText(formatDouble(axisDetails.jogDistance.currentValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM_MAX)->SetWindowText(formatDouble(axisDetails.jogDistance.maxValue));
+
+ // 鎵嬪姩閫熷害
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_POS_MIN)->SetWindowText(formatDouble(axisDetails.manualSpeed.minValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_POS)->SetWindowText(formatDouble(axisDetails.manualSpeed.currentValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_POS_MAX)->SetWindowText(formatDouble(axisDetails.manualSpeed.maxValue));
+
+ // 鑷姩閫熷害
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED_MIN)->SetWindowText(formatDouble(axisDetails.autoSpeed.minValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED)->SetWindowText(formatDouble(axisDetails.autoSpeed.currentValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED_MAX)->SetWindowText(formatDouble(axisDetails.autoSpeed.maxValue));
+
+ // 鍔犻�熸椂闂�
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME_MIN)->SetWindowText(formatDouble(axisDetails.accelerationTime.minValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME)->SetWindowText(formatDouble(axisDetails.accelerationTime.currentValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME_MAX)->SetWindowText(formatDouble(axisDetails.accelerationTime.maxValue));
+
+ // 鍑忛�熸椂闂�
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME_MIN)->SetWindowText(formatDouble(axisDetails.decelerationTime.minValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME)->SetWindowText(formatDouble(axisDetails.decelerationTime.currentValue));
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME_MAX)->SetWindowText(formatDouble(axisDetails.decelerationTime.maxValue));
+}
+
+void CAxisDetailSettingsDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_STATIC_AXIS_NUMBER, m_staticAxisNO);
+ DDX_Control(pDX, IDC_STATIC_AXIS_DESCRIP, m_staticAxisDescription);
+ DDX_Control(pDX, IDC_STATIC_START_ADDRESS, m_staticStartAddress);
+ DDX_Control(pDX, IDC_CUSTOM_AXIS_ANCHOR_POINT, m_grid);
+}
+
+
+BEGIN_MESSAGE_MAP(CAxisDetailSettingsDlg, CDialogEx)
+ ON_NOTIFY(NM_CLICK, IDC_CUSTOM_AXIS_ANCHOR_POINT, &CAxisDetailSettingsDlg::OnGridItemChanged)
+ ON_BN_CLICKED(IDC_BUTTON_AXIS_DETAIL_SETTINGS_SAVE, &CAxisDetailSettingsDlg::OnBnClickedButtonAxisDetailSettingsSave)
+ ON_BN_CLICKED(IDC_BUTTON_SET_AXIS_POSITIONING_POINTS, &CAxisDetailSettingsDlg::OnBnClickedButtonSetAxisPositioningPoints)
+END_MESSAGE_MAP()
+
+
+// CAxisDetailSettingsDlg 娑堟伅澶勭悊绋嬪簭
+
+
+BOOL CAxisDetailSettingsDlg::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+ // TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+ CString strTitle;
+ strTitle.Format(_T("Axis缁嗛儴璁惧畾(閰嶆柟: %s)"), m_strRecipeName);
+ SetWindowText(strTitle);
+
+ // 鑾峰彇杞存暟鎹�
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ auto axisDetails = recipeManager.getAxis(m_nAxisNO);
+ if (axisDetails.id == -1) {
+ CString strMsg;
+ strMsg.Format(_T("杞� [%d] 涓嶅瓨鍦紒"), m_nAxisNO);
+ AfxMessageBox(strMsg);
+ return FALSE;
+ }
+
+ UpdateAxisDetailSettings();
+ InitAnchorPontManager();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+void CAxisDetailSettingsDlg::OnGridItemChanged(NMHDR* pNotifyStruct, LRESULT* pResult)
+{
+ NM_GRIDVIEW* pItem = (NM_GRIDVIEW*)pNotifyStruct;
+ int nRow = pItem->iRow;
+ int nCol = pItem->iColumn;
+
+ // 澶勭悊澶嶉�夋鐘舵�佸彉鍖�
+ if (nCol == 1) {
+ // 鑾峰彇澶嶉�夋鐨勫綋鍓嶇姸鎬�
+ CGridCellCheck* pCell = static_cast<CGridCellCheck*>(m_grid.GetCell(nRow, nCol));
+ BOOL bChecked = pCell->GetCheck();
+
+ // 澶勭悊澶嶉�夋鐘舵�佸彉鍖�
+ m_grid.SetItemState(nRow, 2, bChecked ? GVIS_MODIFIED : GVIS_READONLY);
+ m_grid.SetItemState(nRow, 3, bChecked ? GVIS_MODIFIED : GVIS_READONLY);
+ m_grid.SetItemState(nRow, 4, bChecked ? GVIS_MODIFIED : GVIS_READONLY);
+ m_grid.SetItemState(nRow, 5, bChecked ? GVIS_MODIFIED : GVIS_READONLY);
+ }
+
+ *pResult = 0;
+}
+
+void CAxisDetailSettingsDlg::OnBnClickedButtonAxisDetailSettingsSave()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ // 鑾峰彇杞存暟鎹�
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ auto& axisDetails = recipeManager.getAxis(m_nAxisNO);
+
+ // 浠庣晫闈㈡帶浠惰幏鍙栫敤鎴疯緭鍏ョ殑鏁版嵁骞舵洿鏂板埌 axisDetails
+
+ // 杞寸紪鍙枫�佹弿杩板拰璧峰鍦板潃
+ CString strAxisNo, strAxisDesc, strStartAddr;
+ m_staticAxisNO.GetWindowText(strAxisNo);
+ m_staticAxisDescription.GetWindowText(strAxisDesc);
+ m_staticStartAddress.GetWindowText(strStartAddr);
+
+ axisDetails.number = std::string(CT2A(strAxisNo));
+ axisDetails.description = std::string(CT2A(strAxisDesc));
+ axisDetails.startAddress = std::string(CT2A(strStartAddr));
+
+ // 瀹氫綅閫熷害涓婇檺
+ //CString strPosSpeedLimit;
+ //GetDlgItem(IDC_EDIT_AXIS_POSITIONING_SPEED_LIMIT)->GetWindowText(strPosSpeedLimit);
+ //axisDetails.maxPositioningSpeed = _ttof(strPosSpeedLimit); // 杞崲涓� double 绫诲瀷
+
+ // 鎵嬪姩閫熷害涓婇檺
+ //CString strJogSpeedLimit;
+ //GetDlgItem(IDC_EDIT_AXIS_JOG_SPEED_LIMIT)->GetWindowText(strJogSpeedLimit);
+ //axisDetails.maxManualSpeed = _ttof(strJogSpeedLimit);
+
+ // 瀹氫綅鐐规暟
+ CString strPosCount;
+ GetDlgItem(IDC_EDIT_AXIS_POSITIONING_POINTS)->GetWindowText(strPosCount);
+ axisDetails.positioningPointCount = _ttoi(strPosCount); // 杞崲涓� int 绫诲瀷
+
+ // 寰姩閲�
+ CString strJogDistanceMin, strJogDistanceCur, strJogDistanceMax;
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM_MIN)->GetWindowText(strJogDistanceMin);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM)->GetWindowText(strJogDistanceCur);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM_MAX)->GetWindowText(strJogDistanceMax);
+ axisDetails.jogDistance.minValue = _ttof(strJogDistanceMin);
+ axisDetails.jogDistance.currentValue = _ttof(strJogDistanceCur);
+ axisDetails.jogDistance.maxValue = _ttof(strJogDistanceMax);
+
+ // 鎵嬪姩閫熷害
+ CString strManualSpeedMin, strManualSpeedCur, strManualSpeedMax;
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_POS_MIN)->GetWindowText(strManualSpeedMin);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_POS)->GetWindowText(strManualSpeedCur);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_POS_MAX)->GetWindowText(strManualSpeedMax);
+ axisDetails.manualSpeed.minValue = _ttof(strManualSpeedMin);
+ axisDetails.manualSpeed.currentValue = _ttof(strManualSpeedCur);
+ axisDetails.manualSpeed.maxValue = _ttof(strManualSpeedMax);
+
+ // 鑷姩閫熷害
+ CString strAutoSpeedMin, strAutoSpeedCur, strAutoSpeedMax;
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED_MIN)->GetWindowText(strAutoSpeedMin);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED)->GetWindowText(strAutoSpeedCur);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED_MAX)->GetWindowText(strAutoSpeedMax);
+ axisDetails.autoSpeed.minValue = _ttof(strAutoSpeedMin);
+ axisDetails.autoSpeed.currentValue = _ttof(strAutoSpeedCur);
+ axisDetails.autoSpeed.maxValue = _ttof(strAutoSpeedMax);
+
+ // 鍔犻�熸椂闂�
+ CString strAcceTimeMin, strAcceTimeCur, strAcceTimeMax;
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME_MIN)->GetWindowText(strAcceTimeMin);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME)->GetWindowText(strAcceTimeCur);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME_MAX)->GetWindowText(strAcceTimeMax);
+ axisDetails.accelerationTime.minValue = _ttof(strAcceTimeMin);
+ axisDetails.accelerationTime.currentValue = _ttof(strAcceTimeCur);
+ axisDetails.accelerationTime.maxValue = _ttof(strAcceTimeMax);
+
+ // 鍑忛�熸椂闂�
+ CString strDeceTimeMin, strDeceTimeCur, strDeceTimeMax;
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME_MIN)->GetWindowText(strDeceTimeMin);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME)->GetWindowText(strDeceTimeCur);
+ GetDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME_MAX)->GetWindowText(strDeceTimeMax);
+ axisDetails.decelerationTime.minValue = _ttof(strDeceTimeMin);
+ axisDetails.decelerationTime.currentValue = _ttof(strDeceTimeCur);
+ axisDetails.decelerationTime.maxValue = _ttof(strDeceTimeMax);
+
+ // 濡傛灉 positioningPointCount 鍜� positions.size() 涓嶅悓锛屽垯璋冩暣澶у皬
+ if (axisDetails.positioningPointCount != (int)axisDetails.positions.size()) {
+ axisDetails.positions.resize(axisDetails.positioningPointCount);
+ }
+
+ // 鏇存柊琛ㄦ牸涓殑瀹氫綅鐐规暟鎹�
+ for (int i = 0; i < axisDetails.positioningPointCount; i++) {
+ auto& enPosition = axisDetails.positions[i];
+
+ // 浣胯兘鐘舵��
+ BOOL bIsChecked = ((CGridCellCheck*)m_grid.GetCell(i + 1, 1))->GetCheck();
+ enPosition.isEnable = bIsChecked;
+
+ // 鏈�灏忓�笺�佸綋鍓嶅�煎拰鏈�澶у��
+ CString strMin, strCur, strMax;
+ strMin = m_grid.GetItemText(i + 1, 2);
+ strCur = m_grid.GetItemText(i + 1, 3);
+ strMax = m_grid.GetItemText(i + 1, 4);
+ enPosition.range.minValue = _ttof(strMin);
+ enPosition.range.currentValue = _ttof(strCur);
+ enPosition.range.maxValue = _ttof(strMax);
+
+ // 鎻忚堪
+ CString strDesc;
+ strDesc = m_grid.GetItemText(i + 1, 5);
+ enPosition.description = std::string(CT2A(strDesc));
+ }
+
+ // 鏇存柊 RecipeManager 涓殑杞存暟鎹�
+ recipeManager.updateAxis(axisDetails);
+
+ // 淇濆瓨杞存暟鎹埌鏂囦欢
+ CString cstrMessage;
+ if (RecipeManager::getInstance().saveRecipe(std::string(CT2A(m_strRecipeName)))) {
+ cstrMessage.Format(_T("淇濆瓨杞� [%d] 缁嗛儴鍙傛暟鎴愬姛锛�"), m_nAxisNO);
+ SystemLogManager::getInstance().log(SystemLogManager::LogType::Operation, std::string(CT2A(cstrMessage)));
+ }
+ else {
+ cstrMessage.Format(_T("淇濆瓨杞� [%d] 缁嗛儴鍙傛暟澶辫触锛�"), m_nAxisNO);
+ SystemLogManager::getInstance().log(SystemLogManager::LogType::Error, std::string(CT2A(cstrMessage)));
+ }
+
+ AfxMessageBox(cstrMessage);
+}
+
+void CAxisDetailSettingsDlg::OnBnClickedButtonSetAxisPositioningPoints()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ CString strPosCount;
+ GetDlgItem(IDC_EDIT_AXIS_POSITIONING_POINTS)->GetWindowText(strPosCount);
+ if (strPosCount.IsEmpty()) {
+ AfxMessageBox(_T("璇疯緭鍏ュ畾浣嶇偣鏁帮紒"));
+ return;
+ }
+
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ AxisInfo axisDetails = recipeManager.getAxis(m_nAxisNO);
+ axisDetails.positioningPointCount = _ttoi(strPosCount);
+
+ // 鏇存柊 RecipeManager 涓殑杞存暟鎹�
+ recipeManager.updateAxis(axisDetails);
+
+ FillAnchorPontManager();
+}
diff --git a/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h
new file mode 100644
index 0000000..c3422e7
--- /dev/null
+++ b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h
@@ -0,0 +1,50 @@
+锘�#pragma once
+#include "afxdialogex.h"
+#include "GridCtrl.h"
+
+
+// CAxisDetailSettingsDlg 瀵硅瘽妗�
+
+class CAxisDetailSettingsDlg : public CDialogEx
+{
+ DECLARE_DYNAMIC(CAxisDetailSettingsDlg)
+
+public:
+ CAxisDetailSettingsDlg(const CString& strRecipeName, int nAxisNO, CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
+ virtual ~CAxisDetailSettingsDlg();
+
+public:
+ void SetPLC(CPLC* pPLC);
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_DIALOG_AXIS_DETAIL_SETTINGS };
+#endif
+
+private:
+ void InitAnchorPontManager();
+ void FillAnchorPontManager();
+ void UpdateAxisDetailSettings();
+
+
+private:
+ CPLC* m_pPLC;
+ int m_nInitialWidth;
+ int m_nInitialHeight;
+
+ // 鏁版嵁
+ int m_nAxisNO;
+ CString m_strRecipeName;
+
+ // 鎺т欢
+ CStatic m_staticAxisNO, m_staticAxisDescription, m_staticStartAddress;
+ CGridCtrl m_grid;
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 鏀寔
+ virtual BOOL OnInitDialog();
+ afx_msg void OnGridItemChanged(NMHDR* pNotifyStruct, LRESULT* pResult);
+ afx_msg void OnBnClickedButtonAxisDetailSettingsSave();
+ afx_msg void OnBnClickedButtonSetAxisPositioningPoints();
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
index c240ab3..d8add62 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
@@ -5,6 +5,7 @@
#include "BondEq.h"
#include "afxdialogex.h"
#include "AxisSettingsDlg.h"
+#include "AxisDetailSettingsDlg.h"
#include "ToolUnits.h"
#include <cctype>
#include <algorithm>
@@ -43,8 +44,13 @@
m_bReady = FALSE;
m_bBusy = FALSE;
m_bErr = FALSE;
+
for (int i = 0; i < BTN_MAX; i++) {
m_pBlBtns[i] = new CBlButton();
+ }
+
+ for (int i = 0; i < EDIT_MAX; i++) {
+ m_pRegexEdit[i] = new CRegexEdit();
}
for (int i = 0; i < LABEL_MAX; i++) {
@@ -67,6 +73,10 @@
for (int i = 0; i < BTN_MAX; i++) {
delete m_pBlBtns[i];
+ }
+
+ for (int i = 0; i < EDIT_MAX; i++) {
+ delete m_pRegexEdit[i];
}
for (int i = 0; i < LABEL_MAX; i++) {
@@ -92,11 +102,6 @@
DDX_Control(pDX, IDC_STATIC_AXIS_NUMBER, m_staticAxisNO);
DDX_Control(pDX, IDC_STATIC_AXIS_DESCRIP, m_staticAxisDescription);
DDX_Control(pDX, IDC_STATIC_START_ADDRESS, m_staticStartAddress);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_POS, m_editManualSpeed);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_AUTO_SPEED, m_editAutoSpeed);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_ACCE_TIME, m_editAccelerationTime);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_DECE_TIME, m_editDecelerationTime);
- DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_MICROMENTUM, m_editJogDistance);
}
UINT CAxisSettingsDlg::FindIDByName(const CString& strControlID)
@@ -237,6 +242,24 @@
SetLabelColorBasedOnState(*m_pBlLabels[LABEL_ERR], m_bErr, COLOR_RED, COLOR_GREEN_OFF);
}
+void CAxisSettingsDlg::UpdateRegexEdit(CRegexEdit* pRegexEdit, const ValueRange& range, const CString& title)
+{
+ auto formatDouble = [](double value) -> CString {
+ CString str;
+ str.Format(_T("%.3f"), value);
+ return str;
+ };
+
+ pRegexEdit->SetWindowText(formatDouble(range.currentValue));
+ pRegexEdit->SetRegexType(RegexType::Decimal);
+ pRegexEdit->SetValueRange(range.minValue, range.maxValue);
+ pRegexEdit->SetInvalidInputCallback([title, range]() {
+ CString strError;
+ strError.Format(_T("%s鐨勫�煎繀椤诲湪 %.3f 鍜� %.3f 涔嬮棿锛�"), title, range.minValue, range.maxValue);
+ AfxMessageBox(strError);
+ });
+}
+
void CAxisSettingsDlg::updatePageButtonStates()
{
for (int i = 0; i < AXIS_PAGE_SIZE; ++i) {
@@ -276,6 +299,7 @@
RecipeManager& recipeManager = RecipeManager::getInstance();
if (m_strRecipeName.IsEmpty() || !recipeManager.loadRecipe(std::string(CT2A(m_strRecipeName)))) {
AfxMessageBox(_T("鍔犺浇閰嶆柟澶辫触锛�"));
+ recipeManager.saveRecipe(std::string(CT2A(m_strRecipeName)));
return;
}
@@ -311,14 +335,15 @@
};
// 鏇存柊鎺т欢鏄剧ず
- m_staticAxisNO.SetWindowText(CString(axisDetails.number.c_str())); // 杞寸紪鍙�
- m_staticAxisDescription.SetWindowText(CString(axisDetails.description.c_str())); // 杞存弿杩�
- m_staticStartAddress.SetWindowText(CString(axisDetails.startAddress.c_str())); // 璧峰鍦板潃
- m_editJogDistance.SetWindowText(formatDouble(axisDetails.jogDistance.currentValue)); // 寰姩閲�
- m_editManualSpeed.SetWindowText(formatDouble(axisDetails.manualSpeed.currentValue)); // 鎵嬪姩閫熷害
- m_editAutoSpeed.SetWindowText(formatDouble(axisDetails.autoSpeed.currentValue)); // 鑷姩閫熷害
- m_editAccelerationTime.SetWindowText(formatDouble(axisDetails.accelerationTime.currentValue)); // 鍔犻�熸椂闂�
- m_editDecelerationTime.SetWindowText(formatDouble(axisDetails.decelerationTime.currentValue)); // 鍑忛�熸椂闂�
+ m_staticAxisNO.SetWindowText(CString(axisDetails.number.c_str())); // 杞寸紪鍙�
+ m_staticAxisDescription.SetWindowText(CString(axisDetails.description.c_str())); // 杞存弿杩�
+ m_staticStartAddress.SetWindowText(CString(axisDetails.startAddress.c_str())); // 璧峰鍦板潃
+
+ UpdateRegexEdit(m_pRegexEdit[EDIT_MICROMENTUM], axisDetails.jogDistance, _T("寰姩閲�"));
+ UpdateRegexEdit(m_pRegexEdit[EDIT_MANUAL_SPEED], axisDetails.manualSpeed, _T("鎵嬪姩閫熷害"));
+ UpdateRegexEdit(m_pRegexEdit[EDIT_AUTO_SPEED], axisDetails.autoSpeed, _T("鑷姩閫熷害"));
+ UpdateRegexEdit(m_pRegexEdit[EDIT_ACCE_TIME], axisDetails.accelerationTime, _T("鍔犻�熸椂闂�"));
+ UpdateRegexEdit(m_pRegexEdit[EDIT_DECE_TIME], axisDetails.decelerationTime, _T("鍑忛�熸椂闂�"));
}
void CAxisSettingsDlg::refreshPositionDetails(int nAxisId, int pageNumber)
@@ -352,12 +377,28 @@
// 鏄剧ず瀹氫綅鐐圭殑褰撳墠浣嶇疆
CString value;
value.Format(_T("%.3f"), position.range.currentValue);
- if (pPositionCtrl) pPositionCtrl->SetWindowText(value);
+ if (pPositionCtrl) {
+ pPositionCtrl->SetWindowText(value);
+ pPositionCtrl->EnableWindow(position.isEnable);
+
+ if (position.isEnable) {
+ CString strError;
+ strError.Format(_T("瀹氫綅鐐�%d"), i + 1);
+ UpdateRegexEdit((CRegexEdit*)pPositionCtrl, position.range, strError);
+ }
+ }
}
else {
// 娓呯┖鎺т欢鍐呭
- if (pDescriptionCtrl) pDescriptionCtrl->SetWindowText(_T(""));
- if (pPositionCtrl) pPositionCtrl->SetWindowText(_T(""));
+ if (pDescriptionCtrl) {
+ pDescriptionCtrl->SetWindowText(_T(""));
+ pDescriptionCtrl->EnableWindow(FALSE);
+ }
+
+ if (pPositionCtrl) {
+ pPositionCtrl->SetWindowText(_T(""));
+ pPositionCtrl->EnableWindow(FALSE);
+ }
}
}
}
@@ -433,19 +474,19 @@
// 鑾峰彇鐣岄潰涓婄殑淇敼鍙傛暟
CString text;
- m_editManualSpeed.GetWindowText(text);
+ m_pRegexEdit[EDIT_MANUAL_SPEED]->GetWindowText(text);
axisData.manualSpeed.currentValue = _ttof(text);
- m_editAutoSpeed.GetWindowText(text);
+ m_pRegexEdit[EDIT_AUTO_SPEED]->GetWindowText(text);
axisData.autoSpeed.currentValue = _ttof(text);
- m_editAccelerationTime.GetWindowText(text);
+ m_pRegexEdit[EDIT_ACCE_TIME]->GetWindowText(text);
axisData.accelerationTime.currentValue = _ttof(text);
- m_editDecelerationTime.GetWindowText(text);
+ m_pRegexEdit[EDIT_DECE_TIME]->GetWindowText(text);
axisData.decelerationTime.currentValue = _ttof(text);
- m_editJogDistance.GetWindowText(text);
+ m_pRegexEdit[EDIT_MICROMENTUM]->GetWindowText(text);
axisData.jogDistance.currentValue = _ttof(text);
// 鏇存柊瀹氫綅鐐规暟鎹�
@@ -454,7 +495,7 @@
if (index < axisData.positions.size()) {
// 鏋勫缓鎺т欢鍚嶇О
- CString descriptionName, positionName, minValueName, maxValueName;
+ CString descriptionName, positionName;
descriptionName.Format(_T("IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP%d"), i + 1);
positionName.Format(_T("IDC_EDIT_AXIS_ANCHOR_POINT%d"), i + 1);
@@ -463,7 +504,7 @@
CEdit* pPositionEdit = (CEdit*)GetDlgItem(FindIDByName(positionName));
if (pDescriptionEdit && pPositionEdit) {
- CString description, positionValue, minValue, maxValue;
+ CString description, positionValue;
// 鑾峰彇鎺т欢涓殑鏂囨湰
pDescriptionEdit->GetWindowText(description);
@@ -769,17 +810,15 @@
m_nBtnsFlashState8 = ((BYTE)pData[b + 4] | (BYTE)pData[b + 5] << 8);
m_nBtnsFlashState8 |= ((BYTE)pData[b + 6] << 16 | (BYTE)pData[b + 7] << 24);
- AxisInfo axisInfo = RecipeManager::getInstance().getAxis(nAxisId);
- axisInfo.autoSpeed.currentValue = m_fAutoSpeed; // 鑷姩閫熷害
- axisInfo.manualSpeed.currentValue = m_fManualSpeed; // 鎵嬪姩閫熷害
- axisInfo.jogDistance.currentValue = CToolUnits::toInt32(&pData[81 * 2]) * 0.001; // 寰姩閲�
- axisInfo.accelerationTime.currentValue = CToolUnits::toInt32(&pData[62 * 2]) * 0.001; // 鍔犻�熸椂闂�
- axisInfo.decelerationTime.currentValue = CToolUnits::toInt32(&pData[64 * 2]) * 0.001; // 鍑忛�熸椂闂�
-
// 璇诲彇瀹氫綅鐐规暟鎹�
+ AxisInfo axisInfo = RecipeManager::getInstance().getAxis(nAxisId);
for (int i = 0; i < axisInfo.positions.size(); ++i) {
- unsigned int positionAddress = 100 + (i * 2);
- axisInfo.positions[i].range.currentValue = CToolUnits::toInt32(&pData[positionAddress * 2]) * 0.001;
+ if (axisInfo.positions[i].isEnable == FALSE) {
+ unsigned int positionAddress = 100 + (i * 2);
+ //axisInfo.positions[i].range.minValue = CToolUnits::toInt32(&pData[positionAddress * 2]) * 0.001;
+ axisInfo.positions[i].range.currentValue = CToolUnits::toInt32(&pData[positionAddress * 2]) * 0.001;
+ //axisInfo.positions[i].range.maxValue = CToolUnits::toInt32(&pData[positionAddress * 2]) * 0.001;
+ }
}
RecipeManager::getInstance().updateAxis(axisInfo);
@@ -805,15 +844,17 @@
ON_BN_CLICKED(IDC_BUTTON_AXIS_ANCHOR_POINT5, &CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint5)
ON_BN_CLICKED(IDC_BUTTON_AXIS_TEST_OPR, &CAxisSettingsDlg::OnBnClickedButtonAxisTestOpr)
ON_BN_CLICKED(IDC_BUTTON_AXIS_TEST_STOP, &CAxisSettingsDlg::OnBnClickedButtonAxisTestStop)
+ ON_BN_CLICKED(IDC_BUTTON_AXIS_SEV, &CAxisSettingsDlg::OnBnClickedButtonAxisSev)
ON_CBN_SELCHANGE(IDC_COMBO_AXIS_NAME, &CAxisSettingsDlg::OnSelchangeComboAxisName)
ON_BN_CLICKED(IDC_BUTTON_AXIS_SAVE, &CAxisSettingsDlg::OnBnClickedButtonAxisSave)
+ ON_BN_CLICKED(IDC_BUTTON_AXIS_UPDATE_UI, &CAxisSettingsDlg::OnBnClickedButtonAxisUpdateUi)
+ ON_BN_CLICKED(IDC_BUTTON_AXIS_DETAIL_SETTINGS, &CAxisSettingsDlg::OnBnClickedButtonAxisDetailSettings)
ON_MESSAGE(ID_MSG_UPDATA_DATA_TO_UI, &CAxisSettingsDlg::OnUpdateDataToUI)
ON_WM_SIZE()
ON_WM_CTLCOLOR()
ON_WM_SIZING()
ON_WM_TIMER()
ON_WM_CLOSE()
- ON_BN_CLICKED(IDC_BUTTON_AXIS_SEV, &CAxisSettingsDlg::OnBnClickedButtonAxisSev)
END_MESSAGE_MAP()
@@ -830,20 +871,13 @@
SetWindowText(strTitle);
// 闅愯棌鍏夋爣
- //HideEditCursor(IDC_EDIT_AXIS_CURR_POS);
+ HideEditCursor(IDC_EDIT_AXIS_CURR_POS);
HideEditCursor(IDC_EDIT_AXIS_CURR_MANUAL_SPEED);
HideEditCursor(IDC_EDIT_AXIS_CURR_AUTO_SPEED);
HideEditCursor(IDC_EDIT_AXIS_CURR_ROTA_SPEED);
HideEditCursor(IDC_EDIT_AXIS_CURR_LOAD);
HideEditCursor(IDC_EDIT_AXIS_CURR_ERROR_NUMBER);
HideEditCursor(IDC_EDIT_AXIS_CURR_ALARM_NUMBER);
-
- // 娴嬭瘯
- {
- CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT_AXIS_CURR_POS);
- pEdit->EnableWindow(TRUE);
- pEdit->SetReadOnly(FALSE);
- }
// 璁剧疆娴嬭瘯鐘舵��
m_pBlLabels[LABEL_FLS]->SubclassDlgItem(IDC_STATIC_AXIS_TEST_FLS, this);
@@ -861,6 +895,18 @@
pLabel->SetDynamicFont(TRUE);
}
+ // 鍒濆鍖栫紪杈戞
+ m_pRegexEdit[EDIT_MANUAL_SPEED]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_MANUAL_SPEED, this);
+ m_pRegexEdit[EDIT_AUTO_SPEED]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED, this);
+ m_pRegexEdit[EDIT_ACCE_TIME]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME, this);
+ m_pRegexEdit[EDIT_DECE_TIME]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME, this);
+ m_pRegexEdit[EDIT_MICROMENTUM]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM, this);
+ m_pRegexEdit[EDIT_ANCHOR_POINT1]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT1, this);
+ m_pRegexEdit[EDIT_ANCHOR_POINT2]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT2, this);
+ m_pRegexEdit[EDIT_ANCHOR_POINT3]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT3, this);
+ m_pRegexEdit[EDIT_ANCHOR_POINT4]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT4, this);
+ m_pRegexEdit[EDIT_ANCHOR_POINT5]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT5, this);
+
// 鎸夐挳鍒濆鍖�
m_pBlBtns[BTN_PAGE1]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP1, this);
m_pBlBtns[BTN_PAGE2]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP2, this);
@@ -975,6 +1021,11 @@
CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd);
if (pWnd) {
+ if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) {
+ // 闃绘鍥炶溅閿粯璁ゅ鐞嗭紝闃叉瀵硅瘽妗嗗叧闂�
+ return TRUE;
+ }
+
// 鍒ゆ柇榧犳爣鏄惁杩涘叆鎸囧畾鎺т欢鍖哄煙
if (pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP1)->m_hWnd ||
pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP2)->m_hWnd ||
@@ -1202,7 +1253,7 @@
handleAxisOperation(AxisOperationType::POSITION_1, true);
Sleep(200);
handleAxisOperation(AxisOperationType::POSITION_1, false);
- m_pBlBtns[BTN_POINT1]->Flash(1000);
+ m_pBlBtns[BTN_POINT1]->Flash(500);
}
void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint2()
@@ -1298,6 +1349,7 @@
updateDataFromUI(axisId);
if (RecipeManager::getInstance().saveRecipe(std::string(CT2A(m_strRecipeName)))) {
writeAxisDataToPLC(axisId);
+
cstrMessage.Format(_T("淇濆瓨杞� [%d] 鍙傛暟鎴愬姛锛�"), axisId);
SystemLogManager::getInstance().log(SystemLogManager::LogType::Operation, std::string(CT2A(cstrMessage)));
}
@@ -1307,6 +1359,36 @@
}
AfxMessageBox(cstrMessage);
+}
+
+void CAxisSettingsDlg::OnBnClickedButtonAxisUpdateUi()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ int axisId = getCurrentSelectedAxisID();
+ if (axisId == -1) {
+ AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
+ return;
+ }
+
+ refreshAxisDetails(axisId);
+ refreshPositionDetails(axisId, m_currentPage);
+}
+
+void CAxisSettingsDlg::OnBnClickedButtonAxisDetailSettings()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ int nAxisId = getCurrentSelectedAxisID();
+ if (nAxisId == -1) {
+ AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
+ return;
+ }
+
+ CAxisDetailSettingsDlg dlg(m_strRecipeName, nAxisId, this);
+ dlg.SetPLC(m_pPLC);
+ dlg.DoModal();
+
+ refreshAxisDetails(nAxisId);
+ refreshPositionDetails(nAxisId, m_currentPage);
}
LRESULT CAxisSettingsDlg::OnUpdateDataToUI(WPARAM wParam, LPARAM lParam)
@@ -1321,16 +1403,32 @@
// 鏇存柊Labels鐘舵��
UpdateLabels();
-
- // 鏇存柊瀹氫綅鐐�
- //refreshPositionDetails(getCurrentSelectedAxisID(), m_currentPage);
+
+ // 鏇存柊涓嶅彲鍐欑殑瀹氫綅鐐规暟鎹�
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ for (int i = 0; i < AXIS_PAGE_SIZE; ++i) {
+ PositionRange position = recipeManager.getPositionByIndex(getCurrentSelectedAxisID(), m_currentPage, AXIS_PAGE_SIZE, 0);
+ if (position.isEnable) {
+ continue;
+ }
+
+ CString positionName;
+ positionName.Format(_T("IDC_EDIT_AXIS_ANCHOR_POINT%d"), i + 1);
+
+ CEdit* pPositionEdit = (CEdit*)GetDlgItem(FindIDByName(positionName));
+ if (pPositionEdit) {
+ CString positionValue;
+ positionValue.Format(_T("%.3f"), position.range.currentValue);
+ pPositionEdit->GetWindowText(positionValue);
+ }
+ }
// OPR鎸夐挳鏄惁瑕侀棯鐑佹垨鍋滄闂儊
// 06.0鍜�08.0
if (m_nBtnsFlashState6 & 0x01) {
// 06.0
if (!m_pBlBtns[BTN_JOG_OPR]->IsFlash()) {
- m_pBlBtns[BTN_JOG_OPR]->Flash(1000);
+ m_pBlBtns[BTN_JOG_OPR]->Flash(500);
}
}
else if (m_nBtnsFlashState8 & 0x01) {
@@ -1346,7 +1444,7 @@
if (m_nBtnsFlashState6 & v) {
if (!m_pBlBtns[BTN_POINT1]->IsFlash()) {
- m_pBlBtns[BTN_POINT1]->Flash(1000);
+ m_pBlBtns[BTN_POINT1]->Flash(500);
}
}
else if (m_nBtnsFlashState8 & v) {
@@ -1357,7 +1455,7 @@
if (m_nBtnsFlashState6 & (v << 1)) {
if (!m_pBlBtns[BTN_POINT2]->IsFlash()) {
- m_pBlBtns[BTN_POINT2]->Flash(1000);
+ m_pBlBtns[BTN_POINT2]->Flash(500);
}
}
else if (m_nBtnsFlashState8 & (v << 1)) {
@@ -1368,7 +1466,7 @@
if (m_nBtnsFlashState6 & (v << 2)) {
if (!m_pBlBtns[BTN_POINT3]->IsFlash()) {
- m_pBlBtns[BTN_POINT3]->Flash(1000);
+ m_pBlBtns[BTN_POINT3]->Flash(500);
}
}
else if (m_nBtnsFlashState8 & (v << 2)) {
@@ -1379,7 +1477,7 @@
if (m_nBtnsFlashState6 & (v << 3)) {
if (!m_pBlBtns[BTN_POINT4]->IsFlash()) {
- m_pBlBtns[BTN_POINT4]->Flash(1000);
+ m_pBlBtns[BTN_POINT4]->Flash(500);
}
}
else if (m_nBtnsFlashState8 & (v << 3)) {
@@ -1390,7 +1488,7 @@
if (m_nBtnsFlashState6 & (v << 4)) {
if (!m_pBlBtns[BTN_POINT5]->IsFlash()) {
- m_pBlBtns[BTN_POINT5]->Flash(1000);
+ m_pBlBtns[BTN_POINT5]->Flash(500);
}
}
else if (m_nBtnsFlashState8 & (v << 4)) {
diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
index 5093409..ed1e674 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
@@ -2,12 +2,13 @@
#include "afxdialogex.h"
#include "BlButton.h"
#include "BLLabel.h"
+#include "RegexEdit.h"
#include "CPLC.h"
// 姣忛〉瀹氫綅鐐规樉绀轰釜鏁�
#define AXIS_PAGE_SIZE 5
-// LABEL鎺т欢
+// Label鎺т欢
#define LABEL_MAX 6
#define LABEL_FLS 0
#define LABEL_DOG 1
@@ -15,6 +16,19 @@
#define LABEL_READY 3
#define LABEL_BUSY 4
#define LABEL_ERR 5
+
+// RegexEdit鎺т欢
+#define EDIT_MAX 10
+#define EDIT_MANUAL_SPEED 0
+#define EDIT_AUTO_SPEED 1
+#define EDIT_ACCE_TIME 2
+#define EDIT_DECE_TIME 3
+#define EDIT_MICROMENTUM 4
+#define EDIT_ANCHOR_POINT1 5
+#define EDIT_ANCHOR_POINT2 6
+#define EDIT_ANCHOR_POINT3 7
+#define EDIT_ANCHOR_POINT4 8
+#define EDIT_ANCHOR_POINT5 9
// BUTTON鎺т欢
#define BTN_MAX 15
@@ -76,6 +90,7 @@
void SetLabelColor(CBLLabel& label, COLORREF color);
void SetLabelColorBasedOnState(CBLLabel& label, BOOL bState, COLORREF colorTrue, COLORREF colorFalse);
void UpdateLabels();
+ void UpdateRegexEdit(CRegexEdit* pRegexEdit, const ValueRange& range, const CString& title);
void updatePageButtonStates();
void HideEditCursor(int nCtrlID);
int getCurrentSelectedAxisID();
@@ -105,9 +120,10 @@
// 鎺т欢
CBlButton* m_pBlBtns[BTN_MAX];
CBLLabel* m_pBlLabels[LABEL_MAX];
+ CRegexEdit* m_pRegexEdit[EDIT_MAX];
CComboBox m_comboAxisNO;
CStatic m_staticAxisNO, m_staticAxisDescription, m_staticStartAddress;
- CEdit m_editManualSpeed, m_editAutoSpeed, m_editAccelerationTime, m_editDecelerationTime, m_editJogDistance;
+ //CEdit m_editManualSpeed, m_editAutoSpeed, m_editAccelerationTime, m_editDecelerationTime, m_editJogDistance;
std::map<int, CRect> m_mapCtrlLayouts;
std::map<int, CFont*> m_mapFonts;
@@ -154,6 +170,8 @@
afx_msg void OnBnClickedButtonAxisSev();
afx_msg void OnSelchangeComboAxisName();
afx_msg void OnBnClickedButtonAxisSave();
+ afx_msg void OnBnClickedButtonAxisUpdateUi();
+ afx_msg void OnBnClickedButtonAxisDetailSettings();
afx_msg LRESULT OnUpdateDataToUI(WPARAM wParam, LPARAM lParam);
afx_msg void OnTimer(UINT_PTR nIDEvent);
afx_msg void OnClose();
diff --git a/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp b/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
index cd900d3..dee2397 100644
--- a/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
@@ -214,8 +214,8 @@
// 鍒涘缓鍔ㄦ�佹帶浠�
CBLLabel* pStatic = new CBLLabel();
DWORD style = WS_CHILD | WS_VISIBLE | SS_CENTERIMAGE; // 纭繚鍨傜洿灞呬腑
- if (hasBorder) {
- style |= WS_BORDER; // 娣诲姞杈规
+ if (!hasBorder) {
+ pStatic->DisableBorder();
}
pStatic->Create(text, style, CRect(x, y, x + width, y + height), this, id);
@@ -234,6 +234,8 @@
UserRole enRole = userManager.getCurrentUserRole();
if (clickCallback && (enRole == UserRole::SuperAdmin || enRole == UserRole::Operator)) {
pStatic->SetClickCallback(clickCallback);
+ pStatic->SetRoundedCorners(TRUE, 5);
+ pStatic->DisableBorder();
}
// 瀛樺偍鎺т欢鎸囬拡
--
Gitblit v1.9.3