From 893975d8197b1ed7241ca630490f8f6b3f7d32ea Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期二, 26 十一月 2024 14:54:28 +0800
Subject: [PATCH] 1. 轴设定界面基本完成 2.轴设定不保存数据库,而是保存.xml文件

---
 SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp |  416 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 415 insertions(+), 1 deletions(-)

diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
index e83a616..9f17adf 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
@@ -39,6 +39,11 @@
 	m_pPLC = pPLC;
 }
 
+void CAxisSettingsDlg::SetRecipeName(const CString& strRecipeName)
+{
+	m_strRecipeName = strRecipeName;
+}
+
 void CAxisSettingsDlg::DoDataExchange(CDataExchange* pDX)
 {
 	CDialogEx::DoDataExchange(pDX);
@@ -48,6 +53,46 @@
 	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)
@@ -155,6 +200,209 @@
 	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) {
+		AfxMessageBox(_T("璇烽�夋嫨涓�涓湁鏁堢殑杞寸紪鍙凤紒"));
+		return -1;
+	}
+
+	CString axisIDStr;
+	m_comboAxisNO.GetLBText(currentIndex, axisIDStr);
+	return _ttoi(axisIDStr);
+}
+
+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()
+{
+	// 鑾峰彇褰撳墠閫変腑鐨勮酱ID
+	RecipeManager& recipeManager = RecipeManager::getInstance();
+	int axisId = getCurrentSelectedAxisID();
+
+	auto axisDetails = recipeManager.getAxis(axisId);
+	if (axisDetails.id == -1 || axisDetails.startAddress.empty()) {
+		AfxMessageBox(_T("鏈壘鍒拌酱淇℃伅锛�"));
+		return;
+	}
+
+	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 pageNumber)
+{
+	RecipeManager& recipeManager = RecipeManager::getInstance();
+	// 姣忛〉鏄剧ず鐨勫畾浣嶇偣鏁伴噺
+	const int pageSize = 5;
+
+	// 鑾峰彇褰撳墠閫変腑鐨勮酱ID
+	int axisId = getCurrentSelectedAxisID();
+	if (axisId == -1) {
+		return;
+	}
+
+	// 鑾峰彇瀹氫綅鐐规暟鎹�
+	auto positions = recipeManager.getPositions(axisId, 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();
+	refreshPositionDetails(m_currentPage);
+	updatePageButtonStates();
+}
+
+void CAxisSettingsDlg::updateDataFromUI()
+{
+	const int pageSize = 5; // 姣忛〉鏄剧ず 5 涓畾浣嶇偣
+
+	// 鑾峰彇褰撳墠閫変腑鐨勮酱 ID
+	int axisId = getCurrentSelectedAxisID();
+	if (axisId == -1) return;
+
+	RecipeManager& recipeManager = RecipeManager::getInstance();
+	auto axisData = recipeManager.getAxis(axisId);
+
+	// 鑾峰彇鐣岄潰涓婄殑淇敼鍙傛暟
+	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);
+}
 
 BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CDialogEx)
 	ON_BN_CLICKED(IDC_BUTTON_AXIS_LAST, &CAxisSettingsDlg::OnBnClickedButtonAxisLast)
@@ -173,6 +421,8 @@
 	ON_BN_CLICKED(IDC_BUTTON_AXIS_TEST_JOG_ADD, &CAxisSettingsDlg::OnBnClickedButtonAxisTestJogAdd)
 	ON_BN_CLICKED(IDC_BUTTON_AXIS_TEST_JOG_SUB, &CAxisSettingsDlg::OnBnClickedButtonAxisTestJogSub)
 	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_WM_SIZE()
 	ON_WM_CTLCOLOR()
 	ON_WM_SIZING()
@@ -188,7 +438,9 @@
 	CDialogEx::OnInitDialog();
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
-	SetWindowText(_T("Axis璁惧畾"));
+	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 };
@@ -198,6 +450,21 @@
 		pLabel->SetTextColor(RGB(255, 255, 255));
 		pLabel->SetAlignment(AlignCenter);
 		pLabel->SetDynamicFont(TRUE);
+	}
+
+	// 鍒濆鍖栧綋鍓嶉〉闈负绗竴椤�
+	m_currentPage = 1;
+	updatePageButtonStates();
+
+	try {
+		initializeAxisIDCombo();
+		refreshAxisDetails();
+		refreshPositionDetails(m_currentPage);
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鍒濆鍖栨帶浠跺け璐ワ細%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
 	}
 
 	CRect screenRect, dlgRect, clientRect;
@@ -267,6 +534,28 @@
 	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)
@@ -296,36 +585,127 @@
 void CAxisSettingsDlg::OnBnClickedButtonAxisLast()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		updateAxisSelection(-1);
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鑾峰彇涓嬩竴涓酱澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisNext()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		updateAxisSelection(1);
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鑾峰彇涓婁竴涓酱澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup1()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		if (m_currentPage == 1) {
+			return;
+		}
+		updateDataFromUI();
+
+		m_currentPage = 1;
+		refreshPositionDetails(1);
+		updatePageButtonStates();
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鍒锋柊瀹氫綅缁�1澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup2()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		if (m_currentPage == 2) {
+			return;
+		}
+		updateDataFromUI();
+
+		m_currentPage = 2;
+		refreshPositionDetails(2);
+		updatePageButtonStates();
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鍒锋柊瀹氫綅缁�2澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup3()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		if (m_currentPage == 3) {
+			return;
+		}
+		updateDataFromUI();
+
+		m_currentPage = 3;
+		refreshPositionDetails(3);
+		updatePageButtonStates();
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鍒锋柊瀹氫綅缁�3澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup4()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		if (m_currentPage == 4) {
+			return;
+		}
+		updateDataFromUI();
+
+		m_currentPage = 4;
+		refreshPositionDetails(4);
+		updatePageButtonStates();
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鍒锋柊瀹氫綅缁�4澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPointGroup5()
 {
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		if (m_currentPage == 5) {
+			return;
+		}
+		updateDataFromUI();
+
+		m_currentPage = 5;
+		refreshPositionDetails(5);
+		updatePageButtonStates();
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鍒锋柊瀹氫綅缁�5澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
 }
 
 void CAxisSettingsDlg::OnBnClickedButtonAxisAnchorPoint1()
@@ -373,6 +753,40 @@
 	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
 }
 
+void CAxisSettingsDlg::OnSelchangeComboAxisName()
+{
+	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	try {
+		refreshAxisDetails();
+		refreshPositionDetails(m_currentPage);
+		updatePageButtonStates();
+	}
+	catch (const std::exception& ex) {
+		CString errorMsg;
+		errorMsg.Format(_T("鍒锋柊鎺т欢澶辫触锛�%s"), CString(ex.what()));
+		AfxMessageBox(errorMsg, MB_ICONERROR);
+	}
+}
+
+void CAxisSettingsDlg::OnBnClickedButtonAxisSave()
+{
+	// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+	CString cstrMessage;
+	cstrMessage.Format(_T("鏄惁淇濆瓨杞� [%d] 鍙傛暟锛�"), getCurrentSelectedAxisID());
+	int ret = AfxMessageBox(_T(cstrMessage), MB_OKCANCEL | MB_ICONEXCLAMATION);
+	if (ret != IDOK) {
+		return;
+	}
+
+	updateDataFromUI();
+	if (RecipeManager::getInstance().saveRecipe(std::string(CT2A(m_strRecipeName)))) {
+		AfxMessageBox(_T("淇濆瓨鎴愬姛锛�"));
+	}
+	else {
+		AfxMessageBox(_T("淇濆瓨澶辫触锛�"));
+	}
+}
+
 void CAxisSettingsDlg::OnTimer(UINT_PTR nIDEvent)
 {
 	if (TIMER_READ_PLC_DATA == nIDEvent) {

--
Gitblit v1.9.3