From d362ec98ec0db2039944da31729ad8efcd72834a Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 02 一月 2025 14:19:36 +0800
Subject: [PATCH] 1.20250102合并;
---
SourceCode/Bond/BondEq/CProjectPageMain.cpp | 320 ++++++
SourceCode/Bond/BondEq/Resource.h | 0
SourceCode/Bond/BondEq/CPanelProject.cpp | 31
SourceCode/Bond/BondEq/BondEq.rc | 0
SourceCode/Bond/BondEq/resource1.h | 14
SourceCode/Bond/BondEq/resource2.h | 14
SourceCode/Bond/BondEq/BondEq.vcxproj | 6
SourceCode/Bond/BondEq/AlarmPopupDlg.h | 6
SourceCode/Bond/BondEq/FileManager/RecipeManager.h | 8
SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h | 19
SourceCode/Bond/BondEq/AlarmPopupDlg.cpp | 85 +
SourceCode/Bond/BondEq/ToolUnits.h | 3
SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp | 157 ++
SourceCode/Bond/BondEq/View/AxisSettingsDlg.h | 15
SourceCode/Bond/BondEq/View/UserManagerDlg.cpp | 198 ---
SourceCode/Bond/BondEq/CProjectPageMain.h | 68 +
SourceCode/Bond/BondEq/CComponentPLCDlg.cpp | 7
SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h | 8
SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp | 106 +
SourceCode/Bond/BondEq/View/RecipeListDlg.cpp | 464 +++++++++
SourceCode/Bond/BondEq/Common.h | 3
SourceCode/Bond/BondEq/View/RecipeListDlg.h | 51 +
SourceCode/Bond/BondEq/res_zh.rc | 0
SourceCode/Bond/BondEq/CBonder.cpp | 9
SourceCode/Bond/BondEq/View/UserManagerDlg.h | 15
SourceCode/Bond/BondEq/BondEq.vcxproj.filters | 244 ++++
SourceCode/Bond/BondEq/CBaseDlg.cpp | 341 ++++++
SourceCode/Bond/BondEq/stdafx.h | 2
SourceCode/Bond/BondEq/CBaseDlg.h | 62 +
SourceCode/Bond/BondEq/BondEqDlg.cpp | 15
SourceCode/Bond/x64/Debug/Config/BondEq.db | 0
SourceCode/Bond/BondEq/res_en.rc | 0
SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp | 217 ----
SourceCode/Bond/BondEq/BondEq.vcxproj.user | 6
SourceCode/Bond/BondEq/CBonder.h | 3
SourceCode/Bond/BondEq/CPageAlarm.h | 24
SourceCode/Bond/BondEq/CPanelProject.h | 6
SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp | 193 ---
SourceCode/Bond/BondEq/ToolUnits.cpp | 56 +
Document/Bond软件开发进度表.xlsx | 0
SourceCode/Bond/BondEq/CPageAlarm.cpp | 243 ++++
41 files changed, 2,305 insertions(+), 714 deletions(-)
diff --git "a/Document/Bond\350\275\257\344\273\266\345\274\200\345\217\221\350\277\233\345\272\246\350\241\250.xlsx" "b/Document/Bond\350\275\257\344\273\266\345\274\200\345\217\221\350\277\233\345\272\246\350\241\250.xlsx"
index e92b5b0..376954b 100644
--- "a/Document/Bond\350\275\257\344\273\266\345\274\200\345\217\221\350\277\233\345\272\246\350\241\250.xlsx"
+++ "b/Document/Bond\350\275\257\344\273\266\345\274\200\345\217\221\350\277\233\345\272\246\350\241\250.xlsx"
Binary files differ
diff --git a/SourceCode/Bond/BondEq/AlarmPopupDlg.cpp b/SourceCode/Bond/BondEq/AlarmPopupDlg.cpp
index 5a6e0de..dd9b9b2 100644
--- a/SourceCode/Bond/BondEq/AlarmPopupDlg.cpp
+++ b/SourceCode/Bond/BondEq/AlarmPopupDlg.cpp
@@ -16,6 +16,8 @@
CAlarmPopupDlg::CAlarmPopupDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(IDD_DIALOG_POPUP_ALARM, pParent)
{
+ m_pPLC = nullptr;
+
m_crBkgnd = RGB(225, 225, 225);
m_hbrBkgnd = nullptr;
m_pActiveAlarm = nullptr;
@@ -24,6 +26,13 @@
CAlarmPopupDlg::~CAlarmPopupDlg()
{
}
+
+void CAlarmPopupDlg::SetPLC(CPLC* pPLC)
+{
+ ASSERT(pPLC);
+ m_pPLC = pPLC;
+}
+
void CAlarmPopupDlg::DoDataExchange(CDataExchange* pDX)
{
@@ -36,6 +45,8 @@
ON_WM_DESTROY()
ON_WM_SIZE()
ON_BN_CLICKED(IDC_BUTTON_CLOSE, &CAlarmPopupDlg::OnBnClickedButtonClose)
+ ON_BN_CLICKED(IDC_BUTTON_SOUND_OFF, &CAlarmPopupDlg::OnBnClickedButtonSoundOff)
+ ON_BN_CLICKED(IDC_BUTTON_ALARM_OFF, &CAlarmPopupDlg::OnBnClickedButtonAlarmOff)
END_MESSAGE_MAP()
@@ -115,14 +126,12 @@
// 静音按钮
+ bool bMute = theApp.m_model.getBonder().isMute();
m_btnSoundOff.SubclassDlgItem(IDC_BUTTON_SOUND_OFF, this);
m_btnSoundOff.SetFrameColor(BS_NORMAL, BTN_SOUND_OFF_FRAME_NORMAL);
m_btnSoundOff.SetFrameColor(BS_HOVER, BTN_SOUND_OFF_FRAME_HOVER);
m_btnSoundOff.SetFrameColor(BS_PRESS, BTN_SOUND_OFF_FRAME_PRESS);
- m_btnSoundOff.SetBkgndColor(BS_NORMAL, BTN_SOUND_OFF_BKGND_NORMAL);
- m_btnSoundOff.SetBkgndColor(BS_HOVER, BTN_SOUND_OFF_BKGND_HOVER);
- m_btnSoundOff.SetBkgndColor(BS_PRESS, BTN_SOUND_OFF_BKGND_PRESS);
-
+ SetButtonBackgroundColors(bMute);
// 横线1
CHorizontalLine* pLine = CHorizontalLine::Hook(GetDlgItem(IDC_LINE1)->m_hWnd);
@@ -215,3 +224,71 @@
ShowWindow(SW_HIDE);
}
}
+
+void CAlarmPopupDlg::SetButtonBackgroundColors(bool bMute)
+{
+ if (!bMute) {
+ m_btnSoundOff.SetBkgndColor(BS_NORMAL, BTN_SOUND_OFF_BKGND_NORMAL);
+ m_btnSoundOff.SetBkgndColor(BS_HOVER, BTN_SOUND_OFF_BKGND_HOVER);
+ m_btnSoundOff.SetBkgndColor(BS_PRESS, BTN_SOUND_OFF_BKGND_PRESS);
+ }
+ else {
+ m_btnSoundOff.SetBkgndColor(BS_NORMAL, BTN_SOUND_ON_BKGND_NORMAL);
+ m_btnSoundOff.SetBkgndColor(BS_HOVER, BTN_SOUND_ON_BKGND_HOVER);
+ m_btnSoundOff.SetBkgndColor(BS_PRESS, BTN_SOUND_ON_BKGND_PRESS);
+ }
+}
+
+void CAlarmPopupDlg::OnBnClickedButtonSoundOff()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ if (m_pPLC == nullptr || !m_pPLC->isConnected()) {
+ return;
+ }
+
+ // 向 PLC 写入信号
+ bool bMute = theApp.m_model.getBonder().isMute();
+ char szWrite[4] = { 0x1, 0x0, 0x0, 0x0 };
+ szWrite[0] = !bMute;
+ m_pPLC->writeData(MC::M, 1003, szWrite, 2, [](IMcChannel* pChannel, int nAddr, DWORD nValue, int nFlag) {
+ if (nFlag == 0) {
+ TRACE("操作成功:地址=1003\n", nAddr);
+ }
+ else {
+ TRACE("操作失败:地址=1003,错误码=%d\n", nFlag);
+ }
+ });
+
+ SetButtonBackgroundColors(!bMute);
+}
+
+void CAlarmPopupDlg::OnBnClickedButtonAlarmOff()
+{
+ // TODO: 在此添加控件通知处理程序代码
+ if (m_pPLC == nullptr || !m_pPLC->isConnected()) {
+ return;
+ }
+
+ // 向 PLC 写入信号
+ char szWrite[4] = { 0x1, 0x0, 0x0, 0x0 };
+ m_pPLC->writeData(MC::M, 1009, szWrite, 2, [](IMcChannel* pChannel, int nAddr, DWORD nValue, int nFlag) {
+ if (nFlag == 0) {
+ TRACE("操作成功:地址=1009\n", nAddr);
+ }
+ else {
+ TRACE("操作失败:地址=1009,错误码=%d\n", nFlag);
+ }
+ });
+
+ Sleep(500);
+
+ szWrite[0] = 0x0;
+ m_pPLC->writeData(MC::M, 1009, szWrite, 2, [](IMcChannel* pChannel, int nAddr, DWORD nValue, int nFlag) {
+ if (nFlag == 0) {
+ TRACE("操作成功:地址=1009\n", nAddr);
+ }
+ else {
+ TRACE("操作失败:地址=1009,错误码=%d\n", nFlag);
+ }
+ });
+}
diff --git a/SourceCode/Bond/BondEq/AlarmPopupDlg.h b/SourceCode/Bond/BondEq/AlarmPopupDlg.h
index e9437a2..4479eb3 100644
--- a/SourceCode/Bond/BondEq/AlarmPopupDlg.h
+++ b/SourceCode/Bond/BondEq/AlarmPopupDlg.h
@@ -13,6 +13,8 @@
CAlarmPopupDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~CAlarmPopupDlg();
+public:
+ void SetPLC(CPLC* pPLC);
public:
void AlarmOn();
@@ -20,6 +22,7 @@
private:
void ShowFirstAlarm();
+ void SetButtonBackgroundColors(bool bMute);
private:
COLORREF m_crBkgnd;
@@ -30,6 +33,7 @@
CFont m_fontDescription;
private:
+ CPLC* m_pPLC;
CAlarm* m_pActiveAlarm;
CBlButton m_btnClose;
CBlButton m_btnSoundOff;
@@ -50,4 +54,6 @@
afx_msg void OnDestroy();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnBnClickedButtonClose();
+ afx_msg void OnBnClickedButtonSoundOff();
+ afx_msg void OnBnClickedButtonAlarmOff();
};
diff --git a/SourceCode/Bond/BondEq/BondEq.rc b/SourceCode/Bond/BondEq/BondEq.rc
index a0dffc3..6c020f7 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 a43d4f8..06553f1 100644
--- a/SourceCode/Bond/BondEq/BondEq.vcxproj
+++ b/SourceCode/Bond/BondEq/BondEq.vcxproj
@@ -192,6 +192,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="AlarmPopupDlg.h" />
+ <ClInclude Include="CBaseDlg.h" />
<ClInclude Include="CComponentDlg.h" />
<ClInclude Include="CComponentPLCDlg.h" />
<ClInclude Include="CPLC.h" />
@@ -211,6 +212,7 @@
<ClInclude Include="CPanel.h" />
<ClInclude Include="CParam.h" />
<ClInclude Include="CProjectPageComponents.h" />
+ <ClInclude Include="CProjectPageMain.h" />
<ClInclude Include="CRemoteEqUnitView.h" />
<ClInclude Include="CRemoteEqView.h" />
<ClInclude Include="CHomeDialog.h" />
@@ -263,11 +265,13 @@
<ClInclude Include="View\ChangePasswordDlg.h" />
<ClInclude Include="View\IOMonitoringDlg.h" />
<ClInclude Include="View\LoginDlg.h" />
+ <ClInclude Include="View\RecipeListDlg.h" />
<ClInclude Include="View\SystemLogManagerDlg.h" />
<ClInclude Include="View\UserManagerDlg.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AlarmPopupDlg.cpp" />
+ <ClCompile Include="CBaseDlg.cpp" />
<ClCompile Include="CComponentDlg.cpp" />
<ClCompile Include="CComponentPLCDlg.cpp" />
<ClCompile Include="CPLC.cpp" />
@@ -287,6 +291,7 @@
<ClCompile Include="CPanel.cpp" />
<ClCompile Include="CParam.cpp" />
<ClCompile Include="CProjectPageComponents.cpp" />
+ <ClCompile Include="CProjectPageMain.cpp" />
<ClCompile Include="CRemoteEqUnitView.cpp" />
<ClCompile Include="CRemoteEqView.cpp" />
<ClCompile Include="CHomeDialog.cpp" />
@@ -343,6 +348,7 @@
<ClCompile Include="View\ChangePasswordDlg.cpp" />
<ClCompile Include="View\IOMonitoringDlg.cpp" />
<ClCompile Include="View\LoginDlg.cpp" />
+ <ClCompile Include="View\RecipeListDlg.cpp" />
<ClCompile Include="View\SystemLogManagerDlg.cpp" />
<ClCompile Include="View\UserManagerDlg.cpp" />
</ItemGroup>
diff --git a/SourceCode/Bond/BondEq/BondEq.vcxproj.filters b/SourceCode/Bond/BondEq/BondEq.vcxproj.filters
new file mode 100644
index 0000000..e04981c
--- /dev/null
+++ b/SourceCode/Bond/BondEq/BondEq.vcxproj.filters
@@ -0,0 +1,244 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Manifest Include="res\application.exe.manifest" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="CPLC.cpp" />
+ <ClCompile Include="AccordionWnd.cpp" />
+ <ClCompile Include="Alarm.cpp" />
+ <ClCompile Include="AlarmMonitor.cpp" />
+ <ClCompile Include="ApredTreeCtrl.cpp" />
+ <ClCompile Include="BaseSetPage.cpp" />
+ <ClCompile Include="BlButton.cpp" />
+ <ClCompile Include="BondEq.cpp" />
+ <ClCompile Include="BondEqDlg.cpp" />
+ <ClCompile Include="CBaseView.cpp" />
+ <ClCompile Include="CBonder.cpp" />
+ <ClCompile Include="CDataMonitor1.cpp" />
+ <ClCompile Include="Component.cpp" />
+ <ClCompile Include="Context.cpp" />
+ <ClCompile Include="CPanel.cpp" />
+ <ClCompile Include="CParam.cpp" />
+ <ClCompile Include="CRemoteEqUnitView.cpp" />
+ <ClCompile Include="CRemoteEqView.cpp" />
+ <ClCompile Include="CHomeDialog.cpp" />
+ <ClCompile Include="CMainContainer.cpp" />
+ <ClCompile Include="CPageLogcat.cpp" />
+ <ClCompile Include="CProjectPageRemoteEqs.cpp" />
+ <ClCompile Include="Configuration.cpp" />
+ <ClCompile Include="CPanelProject.cpp" />
+ <ClCompile Include="EQState.cpp" />
+ <ClCompile Include="EQStateMonitor.cpp" />
+ <ClCompile Include="HmTab.cpp" />
+ <ClCompile Include="HmVerticalTab.cpp" />
+ <ClCompile Include="HorizontalLine.cpp" />
+ <ClCompile Include="InputDialog.cpp" />
+ <ClCompile Include="Intent.cpp" />
+ <ClCompile Include="LoadMonitor.cpp" />
+ <ClCompile Include="Log.cpp" />
+ <ClCompile Include="LogEdit.cpp" />
+ <ClCompile Include="McBool.cpp" />
+ <ClCompile Include="McInt.cpp" />
+ <ClCompile Include="McItem.cpp" />
+ <ClCompile Include="McString.cpp" />
+ <ClCompile Include="Model.cpp" />
+ <ClCompile Include="CPageAlarm.cpp" />
+ <ClCompile Include="Recipe.cpp" />
+ <ClCompile Include="SetPage1.cpp" />
+ <ClCompile Include="SetPage2.cpp" />
+ <ClCompile Include="SettingsDlg.cpp" />
+ <ClCompile Include="stdafx.cpp" />
+ <ClCompile Include="ToolUnits.cpp" />
+ <ClCompile Include="TopToolbar.cpp" />
+ <ClCompile Include="VerticalLine.cpp" />
+ <ClCompile Include="DBManager\UserManager.cpp">
+ <Filter>DBManager</Filter>
+ </ClCompile>
+ <ClCompile Include="DBManager\SystemLogManager.cpp">
+ <Filter>DBManager</Filter>
+ </ClCompile>
+ <ClCompile Include="View\ChangePasswordDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="View\LoginDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="View\SystemLogManagerDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="View\UserManagerDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="CProjectPageComponents.cpp" />
+ <ClCompile Include="GB2860SQLite.cpp" />
+ <ClCompile Include="sqlite3.c" />
+ <ClCompile Include="DBManager\AxisManager.cpp">
+ <Filter>DBManager</Filter>
+ </ClCompile>
+ <ClCompile Include="FileManager\RecipeManager.cpp">
+ <Filter>FileManager</Filter>
+ </ClCompile>
+ <ClCompile Include="FileManager\pugixml.cpp">
+ <Filter>FileManager</Filter>
+ </ClCompile>
+ <ClCompile Include="FileManager\IOManager.cpp">
+ <Filter>FileManager</Filter>
+ </ClCompile>
+ <ClCompile Include="View\IOMonitoringDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="CComponentDlg.cpp" />
+ <ClCompile Include="CComponentPLCDlg.cpp" />
+ <ClCompile Include="View\AxisSettingsDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="View\AxisDetailSettingsDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="RegexEdit.cpp" />
+ <ClCompile Include="AlarmPopupDlg.cpp" />
+ <ClCompile Include="DBManager\AlarmManager.cpp">
+ <Filter>DBManager</Filter>
+ </ClCompile>
+ <ClCompile Include="View\RecipeListDlg.cpp">
+ <Filter>View</Filter>
+ </ClCompile>
+ <ClCompile Include="CBaseDlg.cpp" />
+ <ClCompile Include="CProjectPageMain.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="CPLC.h" />
+ <ClInclude Include="AccordionWnd.h" />
+ <ClInclude Include="Alarm.h" />
+ <ClInclude Include="AlarmMonitor.h" />
+ <ClInclude Include="ApredTreeCtrl.h" />
+ <ClInclude Include="BaseSetPage.h" />
+ <ClInclude Include="BlButton.h" />
+ <ClInclude Include="BondEq.h" />
+ <ClInclude Include="BondEqDlg.h" />
+ <ClInclude Include="CBaseView.h" />
+ <ClInclude Include="CBonder.h" />
+ <ClInclude Include="CDataMonitor1.h" />
+ <ClInclude Include="Component.h" />
+ <ClInclude Include="Context.h" />
+ <ClInclude Include="CPanel.h" />
+ <ClInclude Include="CParam.h" />
+ <ClInclude Include="CRemoteEqUnitView.h" />
+ <ClInclude Include="CRemoteEqView.h" />
+ <ClInclude Include="CHomeDialog.h" />
+ <ClInclude Include="CMainContainer.h" />
+ <ClInclude Include="CPageLogcat.h" />
+ <ClInclude Include="CProjectPageRemoteEqs.h" />
+ <ClInclude Include="Common.h" />
+ <ClInclude Include="Configuration.h" />
+ <ClInclude Include="CPanelProject.h" />
+ <ClInclude Include="EQState.h" />
+ <ClInclude Include="EQStateMonitor.h" />
+ <ClInclude Include="HmTab.h" />
+ <ClInclude Include="HmVerticalTab.h" />
+ <ClInclude Include="HorizontalLine.h" />
+ <ClInclude Include="InputDialog.h" />
+ <ClInclude Include="Intent.h" />
+ <ClInclude Include="LoadMonitor.h" />
+ <ClInclude Include="Log.h" />
+ <ClInclude Include="LogEdit.h" />
+ <ClInclude Include="McBool.h" />
+ <ClInclude Include="McInt.h" />
+ <ClInclude Include="McItem.h" />
+ <ClInclude Include="McString.h" />
+ <ClInclude Include="Model.h" />
+ <ClInclude Include="CPageAlarm.h" />
+ <ClInclude Include="Recipe.h" />
+ <ClInclude Include="Resource.h" />
+ <ClInclude Include="SetPage1.h" />
+ <ClInclude Include="SetPage2.h" />
+ <ClInclude Include="SettingsDlg.h" />
+ <ClInclude Include="stdafx.h" />
+ <ClInclude Include="targetver.h" />
+ <ClInclude Include="ToolUnits.h" />
+ <ClInclude Include="TopToolbar.h" />
+ <ClInclude Include="VerticalLine.h" />
+ <ClInclude Include="DBManager\UserManager.h">
+ <Filter>DBManager</Filter>
+ </ClInclude>
+ <ClInclude Include="DBManager\SystemLogManager.h">
+ <Filter>DBManager</Filter>
+ </ClInclude>
+ <ClInclude Include="View\ChangePasswordDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="View\LoginDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="View\SystemLogManagerDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="View\UserManagerDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="CProjectPageComponents.h" />
+ <ClInclude Include="GB2860SQLite.h" />
+ <ClInclude Include="sqlite3.h" />
+ <ClInclude Include="sqlite3ext.h" />
+ <ClInclude Include="DBManager\AxisManager.h">
+ <Filter>DBManager</Filter>
+ </ClInclude>
+ <ClInclude Include="FileManager\RecipeManager.h">
+ <Filter>FileManager</Filter>
+ </ClInclude>
+ <ClInclude Include="FileManager\pugiconfig.hpp">
+ <Filter>FileManager</Filter>
+ </ClInclude>
+ <ClInclude Include="FileManager\pugixml.hpp">
+ <Filter>FileManager</Filter>
+ </ClInclude>
+ <ClInclude Include="FileManager\IOManager.h">
+ <Filter>FileManager</Filter>
+ </ClInclude>
+ <ClInclude Include="View\IOMonitoringDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="CComponentDlg.h" />
+ <ClInclude Include="CComponentPLCDlg.h" />
+ <ClInclude Include="View\AxisSettingsDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="View\AxisDetailSettingsDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="RegexEdit.h" />
+ <ClInclude Include="AlarmPopupDlg.h" />
+ <ClInclude Include="DBManager\AlarmManager.h">
+ <Filter>DBManager</Filter>
+ </ClInclude>
+ <ClInclude Include="View\RecipeListDlg.h">
+ <Filter>View</Filter>
+ </ClInclude>
+ <ClInclude Include="CBaseDlg.h" />
+ <ClInclude Include="CProjectPageMain.h" />
+ </ItemGroup>
+ <ItemGroup>
+ <ResourceCompile Include="BondEq.rc" />
+ </ItemGroup>
+ <ItemGroup>
+ <Image Include="res\BondEq.ico" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="res\BondEq.rc2" />
+ </ItemGroup>
+ <ItemGroup>
+ <Text Include="ReadMe.txt" />
+ </ItemGroup>
+ <ItemGroup>
+ <Filter Include="DBManager">
+ <UniqueIdentifier>{6b00bde2-91aa-41eb-9727-72d846b65036}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="View">
+ <UniqueIdentifier>{d11aa86e-1ee5-4307-89d0-84a9abb7ab1f}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="FileManager">
+ <UniqueIdentifier>{852d5282-c39d-45a3-b4a4-e6dd2a0c52a5}</UniqueIdentifier>
+ </Filter>
+ </ItemGroup>
+</Project>
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/BondEq.vcxproj.user b/SourceCode/Bond/BondEq/BondEq.vcxproj.user
new file mode 100644
index 0000000..847fe46
--- /dev/null
+++ b/SourceCode/Bond/BondEq/BondEq.vcxproj.user
@@ -0,0 +1,6 @@
+锘�<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <RESOURCE_FILE>BondEq.rc</RESOURCE_FILE>
+ </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/BondEqDlg.cpp b/SourceCode/Bond/BondEq/BondEqDlg.cpp
index e30ac6f..0d76f6d 100644
--- a/SourceCode/Bond/BondEq/BondEqDlg.cpp
+++ b/SourceCode/Bond/BondEq/BondEqDlg.cpp
@@ -16,6 +16,8 @@
#include "UserManagerDlg.h"
#include "SystemLogManagerDlg.h"
+// 测试
+#include "RecipeListDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@@ -251,10 +253,12 @@
// 设置配方文件夹路径
RecipeManager& recipeManager = RecipeManager::getInstance();
- std::string strRecipePath = CToolUnits::getCurrentExePath() + _T("\\Recipe");
+ std::string strRecipePath = CToolUnits::getRecipePath();
CToolUnits::createDir(strRecipePath.c_str());
recipeManager.setRecipeFolder(strRecipePath);
-
+ if (!recipeManager.loadRecipe("Default")) {
+ AfxMessageBox("Default 配方加载失败!");
+ }
// 菜单
CMenu menu;
@@ -538,8 +542,11 @@
void CBondEqDlg::OnMenuFileSettings()
{
- CSettingsDlg dlg;
+ CRecipeListDlg dlg;
dlg.DoModal();
+
+ //CSettingsDlg dlg;
+ //dlg.DoModal();
}
void CBondEqDlg::OnUpdateMenuFileSettings(CCmdUI* pCmdUI)
@@ -825,6 +832,7 @@
{
if (m_pAlarmWnd == nullptr) {
m_pAlarmWnd = new CAlarmPopupDlg();
+ m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this);
m_pAlarmWnd->CenterWindow();
}
@@ -835,6 +843,7 @@
{
if (m_pAlarmWnd == nullptr) {
m_pAlarmWnd = new CAlarmPopupDlg();
+ m_pAlarmWnd->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
m_pAlarmWnd->Create(IDD_DIALOG_POPUP_ALARM, this);
m_pAlarmWnd->CenterWindow();
}
diff --git a/SourceCode/Bond/BondEq/CBaseDlg.cpp b/SourceCode/Bond/BondEq/CBaseDlg.cpp
new file mode 100644
index 0000000..86b7926
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CBaseDlg.cpp
@@ -0,0 +1,341 @@
+#include "stdafx.h"
+#include "CBaseDlg.h"
+#include "GridCtrl.h"
+
+// 全局主题对象
+Theme g_lightTheme = { RGB(255, 255, 255), RGB(0, 0, 0), RGB(240, 240, 240), RGB(200, 200, 200) };
+Theme g_darkTheme = { RGB(40, 40, 40), RGB(255, 255, 255), RGB(60, 60, 60), RGB(80, 80, 80) };
+
+CFont g_defaultFont;
+Theme* g_currentTheme = &g_lightTheme;
+
+// 全局资源句柄
+HINSTANCE g_hCurrentResource = NULL;
+
+IMPLEMENT_DYNAMIC(CBaseDlg, CDialogEx)
+
+CBaseDlg::CBaseDlg(UINT nID, CWnd* pPage) : CDialogEx(nID, pPage), m_bResizing(false)
+{
+ m_nID = nID;
+ m_pParent = pPage;
+ m_nInitialWidth = 0;
+ m_nInitialHeight = 0;
+}
+
+CBaseDlg::~CBaseDlg()
+{
+ // shared_ptr会自动清理内存,不需要手动删除
+ m_mapFonts.clear();
+ m_mapCtrlLayouts.clear();
+ m_mapControls.clear();
+}
+
+void CBaseDlg::SwitchTheme(ThemeType enThemeType)
+{
+ // 使用 map 来根据 themeType 查找主题
+ static const std::unordered_map<ThemeType, Theme*> themeMap = {
+ { ThemeType::Light, &g_lightTheme },
+ { ThemeType::Dark, &g_darkTheme }
+ };
+
+ // 设置当前主题
+ auto it = themeMap.find(enThemeType);
+ if (it != themeMap.end()) {
+ g_currentTheme = it->second;
+ }
+ else {
+ g_currentTheme = &g_lightTheme;
+ }
+
+ // 更新控件的外观
+ CWnd* pWnd = GetWindow(GW_CHILD);
+ while (pWnd) {
+ pWnd->Invalidate();
+ pWnd = pWnd->GetNextWindow();
+ }
+
+ // 更新对话框背景颜色
+ SetBackgroundColor(g_currentTheme->backgroundColor);
+}
+
+void CBaseDlg::LoadResourceLibrary(const CString& strLanguage)
+{
+ // 卸载之前加载的资源库
+ UnloadResourceLibrary();
+
+ // 加载新的资源库
+ g_hCurrentResource = AfxLoadLibrary(strLanguage);
+
+ // 设置新的资源句柄
+ if (g_hCurrentResource != NULL) {
+ AfxSetResourceHandle(g_hCurrentResource);
+ }
+}
+
+void CBaseDlg::UnloadResourceLibrary()
+{
+ // 卸载之前加载的资源库
+ if (g_hCurrentResource != NULL) {
+ FreeLibrary(g_hCurrentResource); // 释放当前资源库
+ g_hCurrentResource = NULL; // 清空资源句柄
+ }
+}
+
+CFont* CBaseDlg::GetOrCreateFont(int nFontSize)
+{
+ auto it = m_mapFonts.find(nFontSize);
+ if (it != m_mapFonts.end()) {
+ return it->second.get();
+ }
+
+ // 使用 shared_ptr 来管理字体对象
+ auto font = std::make_shared<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.get();
+}
+
+void CBaseDlg::SetDefaultFont()
+{
+ CFont* defaultFont = GetOrCreateFont(12);
+
+ CWnd* pWnd = GetWindow(GW_CHILD);
+ while (pWnd) {
+ TCHAR szClassName[256];
+ GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+ if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+ pWnd = pWnd->GetNextWindow();
+ continue;
+ }
+
+ pWnd->SetFont(defaultFont, TRUE);
+ pWnd = pWnd->GetNextWindow();
+ }
+}
+
+BOOL CBaseDlg::AddControl(UINT nCtrlID, CWnd* pControl)
+{
+ // 确保控件不重复添加
+ if (m_mapControls.find(nCtrlID) != m_mapControls.end()) {
+ return FALSE; // 控件已经存在
+ }
+
+ m_mapControls[nCtrlID] = std::unique_ptr<CWnd>(pControl);
+ return TRUE;
+}
+
+BOOL CBaseDlg::RemoveControl(UINT nCtrlID)
+{
+ auto it = m_mapControls.find(nCtrlID);
+ if (it != m_mapControls.end()) {
+ m_mapControls.erase(it);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL CBaseDlg::UpdateControlText(UINT nCtrlID, const CString& strText)
+{
+ auto it = m_mapControls.find(nCtrlID);
+ if (it != m_mapControls.end()) {
+ CWnd* pWnd = it->second.get();
+ if (pWnd->GetSafeHwnd() != nullptr)
+ {
+ pWnd->SetWindowText(strText);
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+CWnd* CBaseDlg::GetControl(UINT nCtrlID)
+{
+ auto it = m_mapControls.find(nCtrlID);
+ if (it != m_mapControls.end()) {
+ return it->second.get();
+ }
+ return nullptr;
+}
+
+void CBaseDlg::AdjustControls(float dScaleX, float dScaleY)
+{
+ if (m_bResizing) return; // 防止在调整过程中重复调整
+
+ m_bResizing = true;
+ 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 表示所有项的高度
+ }
+
+ if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+ CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
+ pGridCtrl->SetDefCellHeight(newRect.Height() / 21);
+ pGridCtrl->ExpandColumnsToFit(TRUE);
+ pGridCtrl->ExpandLastColumn();
+ pGridCtrl->Invalidate();
+ pGridCtrl->UpdateWindow();
+ }
+
+ pWnd->MoveWindow(&newRect);
+ AdjustControlFont(pWnd, newRect.Width(), newRect.Height());
+ }
+ pWnd = pWnd->GetNextWindow();
+ }
+ m_bResizing = false;
+}
+
+void CBaseDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight)
+{
+ TCHAR szClassName[256];
+ GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+
+ if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+ return;
+ }
+
+ int fontSize = nHeight / 2;
+ if (fontSize < 8) fontSize = 8;
+ if (fontSize > 32) fontSize = 32;
+
+ CFont* pFont = GetOrCreateFont(fontSize);
+
+ pWnd->SetFont(pFont);
+ pWnd->Invalidate(); // 刷新控件显示
+}
+
+BEGIN_MESSAGE_MAP(CBaseDlg, CDialogEx)
+ ON_WM_SIZE()
+ ON_WM_GETMINMAXINFO()
+ ON_WM_CTLCOLOR()
+END_MESSAGE_MAP()
+
+BOOL CBaseDlg::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+ // 获取当前语言
+ LANGID langId = GetUserDefaultLangID();
+ if (langId == LANG_CHINESE) {
+ // 加载中文资源
+ }
+ else {
+ // 加载英文资源
+ }
+
+ // 获取对话框的工作区(屏幕可用区域)
+ CRect screenRect, dlgRect, clientRect;
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
+ 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;
+
+ // 排除不需要操作的控件(如自定义控件 GridCtrl)
+ TCHAR szClassName[256];
+ GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
+ if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
+ pWnd = pWnd->GetNextWindow();
+ continue;
+ }
+
+ // 设置控件的默认字体
+ pWnd->SetFont(pDefaultFont);
+ }
+ pWnd = pWnd->GetNextWindow();
+ }
+
+ // 将对话框居中
+ GetWindowRect(&dlgRect);
+ int dlgWidth = dlgRect.Width() * 2;
+ int dlgHeight = dlgRect.Height() * 2;
+
+ 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);
+
+ return TRUE;
+}
+
+void CBaseDlg::OnSize(UINT nType, int cx, int cy)
+{
+ CDialogEx::OnSize(nType, cx, cy);
+
+ if (nType == SIZE_MINIMIZED || m_mapCtrlLayouts.empty()) {
+ return;
+ }
+
+ // 检查尺寸变化是否足够大,避免频繁调整
+ //static int lastWidth = 0, lastHeight = 0;
+ //if (abs(cx - lastWidth) < 10 && abs(cy - lastHeight) < 10) {
+ // return;
+ //}
+
+ //lastWidth = cx;
+ //lastHeight = cy;
+
+ // 计算比例并调整布局
+ float dScaleX = static_cast<float>(cx) / m_nInitialWidth;
+ float dScaleY = static_cast<float>(cy) / m_nInitialHeight;
+
+ AdjustControls(dScaleX, dScaleY);
+}
+
+void CBaseDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
+{
+ lpMMI->ptMinTrackSize.x = 400;
+ lpMMI->ptMinTrackSize.y = 300;
+
+ CDialogEx::OnGetMinMaxInfo(lpMMI);
+}
+
+HBRUSH CBaseDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+ if (g_currentTheme) {
+ pDC->SetBkColor(g_currentTheme->backgroundColor);
+ pDC->SetTextColor(g_currentTheme->textColor);
+
+ // 返回背景画刷
+ return CreateSolidBrush(g_currentTheme->backgroundColor);
+ }
+
+ return CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/CBaseDlg.h b/SourceCode/Bond/BondEq/CBaseDlg.h
new file mode 100644
index 0000000..22bd266
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CBaseDlg.h
@@ -0,0 +1,62 @@
+#pragma once
+#include <memory>
+#include <unordered_map>
+
+enum class ThemeType {
+ Light, // 浅色主题
+ Dark // 深色主题
+};
+
+struct Theme {
+ COLORREF backgroundColor;
+ COLORREF textColor;
+ COLORREF buttonColor;
+ COLORREF borderColor;
+};
+
+class CBaseDlg : public CDialogEx
+{
+ DECLARE_DYNAMIC(CBaseDlg)
+
+public:
+ CBaseDlg(UINT nID, CWnd* pPage); // 标准构造函数
+ virtual ~CBaseDlg(); // 析构函数
+
+ // 主题管理
+ void SwitchTheme(ThemeType enThemeType); // 切换主题
+
+ // 资源管理
+ void LoadResourceLibrary(const CString& strLanguage); // 加载资源库
+ void UnloadResourceLibrary(); // 卸载资源库
+
+ // 字体管理
+ CFont* GetOrCreateFont(int nFontSize); // 获取或创建字体
+ void SetDefaultFont(); // 设置默认字体
+
+ // 动态控件管理
+ BOOL AddControl(UINT nCtrlID, CWnd* pControl); // 添加控件
+ BOOL RemoveControl(UINT nCtrlID); // 移除控件
+ BOOL UpdateControlText(UINT nCtrlID, const CString& strText); // 更新控件文本
+ CWnd* GetControl(UINT nCtrlID); // 获取控件
+
+private:
+ void AdjustControls(float dScaleX, float dScaleY); // 调整控件大小
+ void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight); // 调整控件字体
+
+private:
+ UINT m_nID; // 对话框ID
+ CWnd* m_pParent; // 父窗口
+ bool m_bResizing; // 控件是否正在调整大小
+ int m_nInitialWidth; // 对话框初始宽度
+ int m_nInitialHeight; // 对话框初始高度
+ std::unordered_map<int, CRect> m_mapCtrlLayouts; // 控件布局
+ std::map<UINT, std::unique_ptr<CWnd>> m_mapControls; // 控件集合
+ std::unordered_map<int, std::shared_ptr<CFont>> m_mapFonts; // 控件字体
+
+ DECLARE_MESSAGE_MAP()
+public:
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+};
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/CBonder.cpp b/SourceCode/Bond/BondEq/CBonder.cpp
index c4196dd..ac6af65 100644
--- a/SourceCode/Bond/BondEq/CBonder.cpp
+++ b/SourceCode/Bond/BondEq/CBonder.cpp
@@ -133,6 +133,7 @@
AddComponent(pEQStateMonitor1);
pEQStateMonitor1->init();
+ m_bMute = false;
// 初始化各种组件
// 读PLC1配置
@@ -971,4 +972,12 @@
return iter->second;
}
+bool CBonder::isMute()
+{
+ return m_bMute;
+}
+void CBonder::setMute(bool bMute)
+{
+ m_bMute = bMute;
+}
diff --git a/SourceCode/Bond/BondEq/CBonder.h b/SourceCode/Bond/BondEq/CBonder.h
index 25969f4..a64d706 100644
--- a/SourceCode/Bond/BondEq/CBonder.h
+++ b/SourceCode/Bond/BondEq/CBonder.h
@@ -69,6 +69,8 @@
int loadReady(BEQ::IUnit* pUnit, const char* pszMaterielId, const char* pszRecipeId);
int loadComplete(BEQ::IUnit* pUnit, int layer);
int unloadComplete(BEQ::IUnit* pUnit, int layer);
+ bool isMute();
+ void setMute(bool bMute);
public:
int writeInt(int unitId, int addr, int value);
@@ -115,5 +117,6 @@
BEQ::IEquipment* m_pEquipment;
std::map<int, CRecipe*> m_recipes;
std::string m_strCurRecipeName;
+ bool m_bMute;
};
diff --git a/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
index d380353..5ce1ae9 100644
--- a/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
+++ b/SourceCode/Bond/BondEq/CComponentPLCDlg.cpp
@@ -152,9 +152,14 @@
void CComponentPLCDlg::OnBnClickedButtonAxisSetting()
{
+ std::string strName = RecipeManager::getInstance().getCurrentRecipeName();
+ if (strName.empty()) {
+ AfxMessageBox("鏈�夋嫨閰嶆柟锛�", MB_ICONERROR);
+ }
+
CAxisSettingsDlg axisDlg;
axisDlg.SetPLC((CPLC*)m_pContext);
- axisDlg.SetRecipeName(_T("Default"));
+ axisDlg.SetRecipeName(strName.c_str());
axisDlg.DoModal();
}
diff --git a/SourceCode/Bond/BondEq/CPageAlarm.cpp b/SourceCode/Bond/BondEq/CPageAlarm.cpp
index f03c56b..31a91ac 100644
--- a/SourceCode/Bond/BondEq/CPageAlarm.cpp
+++ b/SourceCode/Bond/BondEq/CPageAlarm.cpp
@@ -8,6 +8,7 @@
#include "Common.h"
#include "ToolUnits.h"
+#define PAGE_SIZE 20
// CPageAlarm 对话框
@@ -19,6 +20,16 @@
m_crBkgnd = PAGE_BACKGROUND_COLOR;
m_hbrBkgnd = nullptr;
m_pObserver = nullptr;
+
+ m_strKeyword = "";
+ m_nCurPage = 0;
+ m_nTotalPages = 0;
+ m_nDateTimeFlag = 0;
+
+ memset(m_szTimeStart, 0, sizeof(m_szTimeStart));
+ memset(m_szTimeEnd, 0, sizeof(m_szTimeEnd));
+ m_szTimeStart[0] = '\0';
+ m_szTimeEnd[0] = '\0';
}
CPageAlarm::~CPageAlarm()
@@ -27,6 +38,8 @@
void CPageAlarm::DoDataExchange(CDataExchange* pDX)
{
+ DDX_Control(pDX, IDC_DATETIMEPICKER_START, m_dateTimeStart);
+ DDX_Control(pDX, IDC_DATETIMEPICKER_END, m_dateTimeEnd);
CDialogEx::DoDataExchange(pDX);
}
@@ -35,6 +48,11 @@
ON_WM_CTLCOLOR()
ON_WM_DESTROY()
ON_WM_SIZE()
+ ON_CBN_SELCHANGE(IDC_COMBO_DATETIME, &CPageAlarm::OnCbnSelchangeComboDatetime)
+ ON_BN_CLICKED(IDC_BUTTON_SEARCH, &CPageAlarm::OnBnClickedButtonSearch)
+ ON_BN_CLICKED(IDC_BUTTON_EXPORT, &CPageAlarm::OnBnClickedButtonExport)
+ ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CPageAlarm::OnBnClickedButtonPrevPage)
+ ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CPageAlarm::OnBnClickedButtonNextPage)
END_MESSAGE_MAP()
@@ -82,6 +100,19 @@
CDialogEx::OnInitDialog();
InitRxWindow();
+ // 下拉框控件
+ CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_DATETIME);
+ pComboBox->AddString(_T("不限"));
+ pComboBox->AddString(_T("今天"));
+ pComboBox->AddString(_T("七天内"));
+ pComboBox->AddString(_T("本月"));
+ pComboBox->AddString(_T("今年"));
+ pComboBox->AddString(_T("自定义"));
+ pComboBox->SetCurSel(0);
+
+ // 日期控件
+ m_dateTimeStart.EnableWindow(FALSE);
+ m_dateTimeEnd.EnableWindow(FALSE);
// 报表控件
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_ALARM);
@@ -98,6 +129,10 @@
pListCtrl->InsertColumn(4, _T("发生时间"), LVCFMT_LEFT, 180);
pListCtrl->InsertColumn(5, _T("解除时间"), LVCFMT_LEFT, 180);
+ // 计算总页数
+ int totalRecords = AlarmManager::getInstance().getTotalAlarmCount(m_strKeyword, m_szTimeStart, m_szTimeEnd);
+ m_nTotalPages = (totalRecords + PAGE_SIZE - 1) / PAGE_SIZE;
+ m_nCurPage = 1;
Resize();
LoadAlarms();
@@ -150,13 +185,12 @@
GetClientRect(&rcClient);
pItem = GetDlgItem(IDC_LIST_ALARM);
- pItem->MoveWindow(12, 12, rcClient.Width() - 24, rcClient.Height() - 24);
+ pItem->MoveWindow(12, 52, rcClient.Width() - 24, rcClient.Height() - 64);
}
void CPageAlarm::LoadAlarms()
{
CAlarmMonitor* pMonitor = (CAlarmMonitor*)theApp.m_model.getBonder().GetComponent(ALARM_MONITOR);
-
// 当前正在发生的报警
pMonitor->Lock();
@@ -166,19 +200,9 @@
}
pMonitor->Unlock();
-
- // 获取历史报警数据
- auto vecData = AlarmManager::getInstance().getAllAlarms();
-
- // 填充数据
- CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_ALARM);
- for (auto item : vecData) {
- pListCtrl->InsertItem(0, _T(""));
- pListCtrl->SetItemText(0, 1, item[0].c_str());
- pListCtrl->SetItemText(0, 2, item[1].c_str());
- pListCtrl->SetItemText(0, 3, item[2].c_str());
- pListCtrl->SetItemText(0, 4, item[3].c_str());
- }
+ // 刷新历史报警数据
+ m_nCurPage = 1;
+ UpdatePageData();
}
void CPageAlarm::AddAlarm(CAlarmMonitor* pMonitor, CAlarm* pAlarm)
@@ -213,6 +237,52 @@
}
}
+void CPageAlarm::UpdatePageData()
+{
+ // 根据过滤条件加载数据
+ auto vecData = AlarmManager::getInstance().getFilteredAlarms(m_strKeyword, m_szTimeStart, m_szTimeEnd, m_nCurPage, PAGE_SIZE);
+
+ // 填充数据到控件
+ CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_ALARM);
+ FillDataToListCtrl(pListCtrl, vecData);
+
+ // 更新分页控件(页数和按钮)
+ UpdatePageControls();
+}
+
+void CPageAlarm::UpdatePageControls()
+{
+ // 更新分页信息
+ CString strPage;
+ strPage.Format(_T("第 %d 页"), m_nCurPage);
+ SetDlgItemText(IDC_LABEL_PAGE_NUMBER, strPage);
+
+ // 启用/禁用翻页按钮
+ GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurPage > 1);
+ GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurPage < m_nTotalPages);
+}
+
+void CPageAlarm::FillDataToListCtrl(CListCtrl* pListCtrl, const std::vector<std::vector<std::string>>& vecData)
+{
+ // 清空当前CListCtrl中的所有项
+ for (int i = 0; i < pListCtrl->GetItemCount(); i++) {
+ CAlarm* pAlarm = (CAlarm*)pListCtrl->GetItemData(i);
+ if (pAlarm != nullptr) {
+ pAlarm->release();
+ }
+ }
+ pListCtrl->DeleteAllItems();
+
+ // 遍历数据并插入到CListCtrl中
+ for (const auto& item : vecData) {
+ int nItem = pListCtrl->InsertItem(pListCtrl->GetItemCount(), _T("")); // 插入新行
+ pListCtrl->SetItemText(nItem, 1, item[0].c_str()); // 设置第一列的文本
+ pListCtrl->SetItemText(nItem, 2, item[1].c_str()); // 设置第二列的文本
+ pListCtrl->SetItemText(nItem, 3, item[2].c_str()); // 设置第三列的文本
+ pListCtrl->SetItemText(nItem, 4, item[3].c_str()); // 设置第四列的文本
+ }
+}
+
BOOL CPageAlarm::DestroyWindow()
{
CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_ALARM);
@@ -225,3 +295,146 @@
return CDialogEx::DestroyWindow();
}
+
+void CPageAlarm::OnCbnSelchangeComboDatetime()
+{
+ CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_DATETIME);
+ int nIndex = pComboBox->GetCurSel();
+ int nCount = pComboBox->GetCount();
+ m_dateTimeStart.EnableWindow(nIndex == nCount - 1);
+ m_dateTimeEnd.EnableWindow(nIndex == nCount - 1);
+}
+
+void CPageAlarm::OnBnClickedButtonSearch()
+{
+ // 获取关键字
+ CString cstrKeyword;
+ GetDlgItemText(IDC_EDIT_KEYWORD, cstrKeyword);
+ m_strKeyword = CT2A(cstrKeyword);
+
+ // 获取日期
+ CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_DATETIME);
+ m_nDateTimeFlag = pComboBox->GetCurSel();
+ if (m_nDateTimeFlag == 0) {
+ memset(m_szTimeStart, 0, sizeof(m_szTimeStart));
+ memset(m_szTimeEnd, 0, sizeof(m_szTimeEnd));
+ m_szTimeStart[0] = '\0';
+ m_szTimeEnd[0] = '\0';
+ }
+ else {
+ CTime time = CTime::GetCurrentTime();
+ if (m_nDateTimeFlag == 1) {
+ // 今天
+ sprintf_s(m_szTimeStart, 64, "%d-%02d-%02d 00:00:00", time.GetYear(), time.GetMonth(), time.GetDay());
+ sprintf_s(m_szTimeEnd, 64, "%d-%02d-%02d 23:59:59", time.GetYear(), time.GetMonth(), time.GetDay());
+ }
+ else if (m_nDateTimeFlag == 2) {
+ // 7天内
+ CTime time2 = time - CTimeSpan(7, 0, 0, 0);
+ sprintf_s(m_szTimeStart, 64, "%d-%02d-%02d 00:00:00", time2.GetYear(), time2.GetMonth(), time2.GetDay());
+ sprintf_s(m_szTimeEnd, 64, "%d-%02d-%02d 23:59:59", time.GetYear(), time.GetMonth(), time.GetDay());
+ }
+ else if (m_nDateTimeFlag == 3) {
+ // 本月
+ sprintf_s(m_szTimeStart, 64, "%d-%02d-01 00:00:00", time.GetYear(), time.GetMonth());
+ sprintf_s(m_szTimeEnd, 64, "%d-%02d-%02d 23:59:59", time.GetYear(), time.GetMonth(), time.GetDay());
+ }
+ else if (m_nDateTimeFlag == 4) {
+ // 今年
+ sprintf_s(m_szTimeStart, 64, "%d-01-01 00:00:00", time.GetYear());
+ sprintf_s(m_szTimeEnd, 64, "%d-12-31 23:59:59", time.GetYear());
+ }
+ else if (m_nDateTimeFlag == 5) {
+ // 自定义
+ SYSTEMTIME t1, t2;
+ m_dateTimeStart.GetTime(&t1);
+ m_dateTimeEnd.GetTime(&t2);
+
+ sprintf_s(m_szTimeStart, 64, "%d-%02d-%02d %02d:%02d:%02d",
+ t1.wYear, t1.wMonth, t1.wDay, t1.wHour, t1.wMinute, t1.wSecond);
+ sprintf_s(m_szTimeEnd, 64, "%d-%02d-%02d %02d:%02d:%02d",
+ t2.wYear, t2.wMonth, t2.wDay, t2.wHour, t2.wMinute, t2.wSecond);
+ }
+ }
+
+ // 计算总页数
+ int totalRecords = AlarmManager::getInstance().getTotalAlarmCount(m_strKeyword, m_szTimeStart, m_szTimeEnd);
+ m_nTotalPages = (totalRecords + PAGE_SIZE - 1) / PAGE_SIZE;
+ m_nCurPage = 1;
+
+ UpdatePageData(); // 调用分页更新函数
+}
+
+void CPageAlarm::OnBnClickedButtonExport()
+{
+ CFileDialog fileDialog(FALSE, "csv", "", OFN_HIDEREADONLY, "csv.files(*.csv)|*.csv||");
+ if (fileDialog.DoModal() != IDOK) {
+ return;
+ }
+
+ CStdioFile file;
+ if (!file.Open(fileDialog.GetPathName(), CFile::modeCreate | CFile::modeWrite)) {
+ AfxMessageBox("创建文件失败!");
+ }
+
+ int nSubItemCount = 0;
+ CString strSubItem, strHeader, strRow;
+ char szItem[256];
+ HDITEM hdItem[35];
+ for (int i = 0; i < 35; i++) {
+ hdItem[i].pszText = szItem;
+ hdItem[i].cchTextMax = 256;
+ hdItem[i].mask = HDI_TEXT | HDI_WIDTH;
+ }
+
+ // 先读表头
+ CListCtrl* pListCtrl = (CListCtrl*)GetDlgItem(IDC_LIST_ALARM);
+ CHeaderCtrl* pHeader = pListCtrl->GetHeaderCtrl();
+ nSubItemCount = pHeader->GetItemCount();
+ ASSERT(nSubItemCount <= 35);
+ for (int i = 0; i < pHeader->GetItemCount(); i++) {
+ pHeader->GetItem(i, &hdItem[i]);
+ if (hdItem[i].cxy > 0) {
+ if (!strHeader.IsEmpty()) {
+ strHeader.Append(",");
+ }
+ strHeader.Append(CString(hdItem[i].pszText));
+ }
+ }
+ strHeader.Append("\n");
+ file.WriteString(strHeader);
+
+ // 写表格内容
+ int count = pListCtrl->GetItemCount();
+ for (int i = 0; i < count; i++) {
+ strRow.Empty();
+ for (int j = 0; j < nSubItemCount; j++) {
+ if (hdItem[j].cxy > 0) {
+ if (!strRow.IsEmpty()) {
+ strRow.Append(",");
+ }
+ CString strTemp = pListCtrl->GetItemText(i, j);
+ strTemp.Replace("* ", "");
+ strRow.Append(strTemp);
+ }
+ }
+ strRow.Append("\n");
+ file.WriteString(strRow);
+ }
+
+ file.Close();
+}
+
+void CPageAlarm::OnBnClickedButtonPrevPage()
+{
+ // 点击上一页
+ m_nCurPage--;
+ UpdatePageData(); // 调用分页更新函数
+}
+
+void CPageAlarm::OnBnClickedButtonNextPage()
+{
+ // 点击下一页
+ m_nCurPage++;
+ UpdatePageData(); // 调用分页更新函数
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/CPageAlarm.h b/SourceCode/Bond/BondEq/CPageAlarm.h
index 583a6b2..7d88e52 100644
--- a/SourceCode/Bond/BondEq/CPageAlarm.h
+++ b/SourceCode/Bond/BondEq/CPageAlarm.h
@@ -18,11 +18,30 @@
void LoadAlarms();
void AddAlarm(CAlarmMonitor* pMonitor, CAlarm* pAlarm);
void UpdateAlarm(CAlarmMonitor* pMonitor, CAlarm* pAlarm);
+ void UpdatePageData();
+ void UpdatePageControls();
+ void FillDataToListCtrl(CListCtrl* pListCtrl, const std::vector<std::vector<std::string>>& vecData);
private:
COLORREF m_crBkgnd;
HBRUSH m_hbrBkgnd;
IObserver* m_pObserver;
+
+ // 关键字
+ std::string m_strKeyword;
+
+ // 页码
+ int m_nCurPage;
+ int m_nTotalPages;
+
+ // 日期
+ int m_nDateTimeFlag;
+ char m_szTimeStart[64];
+ char m_szTimeEnd[64];
+
+ // 控件
+ CDateTimeCtrl m_dateTimeStart;
+ CDateTimeCtrl m_dateTimeEnd;
// 对话框数据
@@ -40,4 +59,9 @@
afx_msg void OnDestroy();
afx_msg void OnSize(UINT nType, int cx, int cy);
virtual BOOL DestroyWindow();
+ afx_msg void OnCbnSelchangeComboDatetime();
+ afx_msg void OnBnClickedButtonSearch();
+ afx_msg void OnBnClickedButtonExport();
+ afx_msg void OnBnClickedButtonPrevPage();
+ afx_msg void OnBnClickedButtonNextPage();
};
diff --git a/SourceCode/Bond/BondEq/CPanelProject.cpp b/SourceCode/Bond/BondEq/CPanelProject.cpp
index 0aa4518..355ec58 100644
--- a/SourceCode/Bond/BondEq/CPanelProject.cpp
+++ b/SourceCode/Bond/BondEq/CPanelProject.cpp
@@ -18,7 +18,8 @@
m_hbrBkgnd = nullptr;
m_nPanelWidth = int((double)GetSystemMetrics(SM_CXSCREEN) * 0.25);
m_pAccordionWnd = nullptr;
- m_pPageRemoteEqs = nullptr;
+ //m_pPageRemoteEqs = nullptr;
+ m_pPageMain = nullptr;
m_pPageComponents = nullptr;
}
@@ -71,10 +72,16 @@
m_pAccordionWnd->Setpadding(PADDING_BOTTOM, 2);
m_pAccordionWnd->LoadExpandIcon(strExpandIcon, strCloseIcon);
- m_pPageRemoteEqs = new CProjectPageRemoteEqs();
- m_pPageRemoteEqs->Create(IDD_PROJECT_PAGE_REMOTEEQS, GetDlgItem(IDC_ACCORDION_WND1));
- m_pPageRemoteEqs->ShowWindow(SW_SHOW);
- m_pAccordionWnd->AddItem("杩滅▼璁惧", m_pPageRemoteEqs, 0, TRUE, TRUE);
+ //m_pPageRemoteEqs = new CProjectPageRemoteEqs();
+ //m_pPageRemoteEqs->Create(IDD_PROJECT_PAGE_REMOTEEQS, GetDlgItem(IDC_ACCORDION_WND1));
+ //m_pPageRemoteEqs->ShowWindow(SW_SHOW);
+ //m_pAccordionWnd->AddItem("杩滅▼璁惧", m_pPageRemoteEqs, 0, TRUE, TRUE);
+
+ m_pPageMain = new CProjectPageMain();
+ m_pPageMain->SetPLC(theApp.m_model.getBonder().getPLC("PLC(1)"));
+ m_pPageMain->Create(IDD_PROJECT_PAGE_MAIN, GetDlgItem(IDC_ACCORDION_WND1));
+ m_pPageMain->ShowWindow(SW_SHOW);
+ m_pAccordionWnd->AddItem("涓婚〉闈�", m_pPageMain, 0, TRUE, TRUE);
m_pPageComponents = new CProjectPageComponents();
m_pPageComponents->Create(IDD_PROJECT_PAGE_COMPONENTS, GetDlgItem(IDC_ACCORDION_WND1));
@@ -121,10 +128,16 @@
m_pPageComponents = nullptr;
}
- if (m_pPageRemoteEqs != nullptr) {
- m_pPageRemoteEqs->DestroyWindow();
- delete m_pPageRemoteEqs;
- m_pPageRemoteEqs = nullptr;
+ //if (m_pPageRemoteEqs != nullptr) {
+ // m_pPageRemoteEqs->DestroyWindow();
+ // delete m_pPageRemoteEqs;
+ // m_pPageRemoteEqs = nullptr;
+ //}
+
+ if (m_pPageMain != nullptr) {
+ m_pPageMain->DestroyWindow();
+ delete m_pPageMain;
+ m_pPageMain = nullptr;
}
}
diff --git a/SourceCode/Bond/BondEq/CPanelProject.h b/SourceCode/Bond/BondEq/CPanelProject.h
index 3b3f7f6..947c345 100644
--- a/SourceCode/Bond/BondEq/CPanelProject.h
+++ b/SourceCode/Bond/BondEq/CPanelProject.h
@@ -1,6 +1,7 @@
锘�#pragma once
#include "VerticalLine.h"
-#include "CProjectPageRemoteEqs.h"
+//#include "CProjectPageRemoteEqs.h"
+#include "CProjectPageMain.h"
#include "CProjectPageComponents.h"
#include "AccordionWnd.h"
@@ -29,7 +30,8 @@
HBRUSH m_hbrBkgnd;
int m_nPanelWidth;
CAccordionWnd* m_pAccordionWnd;
- CProjectPageRemoteEqs* m_pPageRemoteEqs;
+ //CProjectPageRemoteEqs* m_pPageRemoteEqs;
+ CProjectPageMain* m_pPageMain;
CProjectPageComponents* m_pPageComponents;
diff --git a/SourceCode/Bond/BondEq/CProjectPageMain.cpp b/SourceCode/Bond/BondEq/CProjectPageMain.cpp
new file mode 100644
index 0000000..9a0693c
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CProjectPageMain.cpp
@@ -0,0 +1,320 @@
+锘�// CProjectPageMain.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "BondEq.h"
+#include "afxdialogex.h"
+#include "CProjectPageMain.h"
+#include "ToolUnits.h"
+
+#define TIMER_INIT 1
+#define TIMER_READ_PLC_DATA 2
+
+#define ID_MSG_UPDATA_DATA_TO_UI WM_USER + 101
+
+// CProjectPageMain 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CProjectPageMain, CDialogEx)
+
+CProjectPageMain::CProjectPageMain(CWnd* pParent /*=nullptr*/)
+ : CDialogEx(IDD_PROJECT_PAGE_MAIN, pParent)
+{
+ m_crBkgnd = PROPAGE_BACKGROUND_COLOR;
+ m_hbrBkgnd = nullptr;
+ m_pObserver = nullptr;
+
+ nVelocityRatio = 0.0;
+ dTactTime = 0.0;
+ nDayShiftCapacity = 0;
+ nNightShiftCapacity = 0;
+}
+
+CProjectPageMain::~CProjectPageMain()
+{
+}
+
+void CProjectPageMain::SetPLC(CPLC* pPLC)
+{
+ ASSERT(pPLC);
+ m_pPLC = pPLC;
+}
+
+void CProjectPageMain::DoDataExchange(CDataExchange* pDX)
+{
+ CDialogEx::DoDataExchange(pDX);
+}
+
+void CProjectPageMain::HandleOperation(OperationType eOpType)
+{
+ WriteOperationDataToPLC(eOpType, true);
+ Sleep(200);
+ WriteOperationDataToPLC(eOpType, false);
+}
+
+void CProjectPageMain::WriteOperationDataToPLC(OperationType eOpType, bool bPressed)
+{
+ if (m_pPLC == nullptr || !m_pPLC->isConnected()) {
+ return;
+ }
+
+ MC::SOFT_COMPONENT enComponent = MC::M;
+ int nStartAddress = 1000;
+
+ // 鏍规嵁鎿嶄綔绫诲瀷璁$畻鐩爣鍦板潃
+ char szWrite[4] = { 0x0, 0x0, 0x0, 0x0 };
+ switch (eOpType) {
+ case OperationType::RUN:
+ nStartAddress = 1002; // RUN 淇″彿鍦板潃 M1002,闂姩淇℃伅 M1103
+ szWrite[0] = bPressed ? 0x01 : 0;
+ break;
+ case OperationType::AUTO:
+ nStartAddress = 1000; // AUTO 淇″彿鍦板潃 M1000,闂姩淇℃伅 M1100
+ szWrite[0] = bPressed ? 0x01 : 0;
+ break;
+ case OperationType::PUASE:
+ nStartAddress = 1004; // PUASE 淇″彿鍦板潃 M1004,闂姩淇℃伅 M1104
+ szWrite[0] = bPressed ? 0x01 : 0;
+ break;
+ case OperationType::MANUAL:
+ nStartAddress = 1001; // MANUAL 淇″彿鍦板潃 M1001,闂姩淇℃伅 M1100
+ szWrite[0] = bPressed ? 0x01 : 0;
+ break;
+ case OperationType::MUTE:
+ nStartAddress = 1003; // MUTE 淇″彿鍦板潃 M1003,闂姩淇℃伅 M1003
+ szWrite[0] = bPressed ? 0x01 : 0;
+ break;
+ case OperationType::OPR:
+ nStartAddress = 1050; // OPR 淇″彿鍦板潃 M1050,闂姩淇℃伅 M1150
+ szWrite[0] = bPressed ? 0x01 : 0;
+ break;
+ case OperationType::STOP:
+ nStartAddress = 1114; // STOP 淇″彿鍦板潃 M1114,闂姩淇℃伅 M1114
+ szWrite[0] = bPressed ? 0x01 : 0;
+ break;
+ default:
+ AfxMessageBox(_T("鏈煡鎿嶄綔绫诲瀷锛�"));
+ return;
+ }
+
+ // 鍚� PLC 鍐欏叆淇″彿
+ m_pPLC->writeData(enComponent, nStartAddress, szWrite, 2, [eOpType, nStartAddress, 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 CProjectPageMain::ReadPLCDataToUI()
+{
+ ASSERT(m_pPLC->isConnected());
+
+ // 鎬讳换鍔℃暟
+ int nPendingTasks = 5;
+
+ auto createReadTask = [this, &nPendingTasks](MC::SOFT_COMPONENT type, int nAddr, auto onProcessData) {
+ return [this, &nPendingTasks, onProcessData](IMcChannel* pChannel, int nAddr, char* pData, unsigned int nDataSize, int nFlag) {
+ if (nDataSize == 2 && nFlag == 0 && ::IsWindow(m_hWnd)) {
+ onProcessData(CToolUnits::toInt16(&pData[0]));
+ }
+
+ // 浠诲姟瀹屾垚锛屽噺灏戣鏁�
+ if (--nPendingTasks == 0) {
+ PostMessage(ID_MSG_UPDATA_DATA_TO_UI);
+ }
+ };
+ };
+
+ m_pPLC->readData(MC::M, 1003, 2, createReadTask(MC::M, 1003, [this](int nValue) {
+ theApp.m_model.getBonder().setMute(nValue != 0);
+ }));
+
+ m_pPLC->readData(MC::D, 530, 2, createReadTask(MC::D, 530, [this](int nValue) {
+ nVelocityRatio = static_cast<unsigned int>(nValue);
+ }));
+
+ m_pPLC->readData(MC::ZR, 1500, 2, createReadTask(MC::ZR, 1500, [this](int nValue) {
+ dTactTime = nValue;
+ }));
+
+ m_pPLC->readData(MC::ZR, 2012, 2, createReadTask(MC::ZR, 2012, [this](int nValue) {
+ nDayShiftCapacity = nValue;
+ }));
+
+ m_pPLC->readData(MC::ZR, 2027, 2, createReadTask(MC::ZR, 2027, [this](int nValue) {
+ nNightShiftCapacity = nValue;
+ }));
+}
+
+BEGIN_MESSAGE_MAP(CProjectPageMain, CDialogEx)
+ ON_WM_CTLCOLOR()
+ ON_WM_DESTROY()
+ ON_WM_SIZE()
+ ON_WM_TIMER()
+ ON_WM_CLOSE()
+ ON_BN_CLICKED(IDC_BUTTON_ACTIVATE, &CProjectPageMain::OnBnClickedButtonActivate)
+ ON_BN_CLICKED(IDC_BUTTON_AUTO, &CProjectPageMain::OnBnClickedButtonAuto)
+ ON_BN_CLICKED(IDC_BUTTON_PUASE, &CProjectPageMain::OnBnClickedButtonPuase)
+ ON_BN_CLICKED(IDC_BUTTON_MANUAL_OPERATION, &CProjectPageMain::OnBnClickedButtonManualOperation)
+ ON_BN_CLICKED(IDC_BUTTON_SOUND_OFF, &CProjectPageMain::OnBnClickedButtonSoundOff)
+ ON_BN_CLICKED(IDC_BUTTON_RESETTING, &CProjectPageMain::OnBnClickedButtonResetting)
+ ON_BN_CLICKED(IDC_BUTTON_STOP, &CProjectPageMain::OnBnClickedButtonStop)
+ ON_MESSAGE(ID_MSG_UPDATA_DATA_TO_UI, &CProjectPageMain::OnUpdateDataToUI)
+END_MESSAGE_MAP()
+
+
+// CProjectPageMain 娑堟伅澶勭悊绋嬪簭
+
+void CProjectPageMain::InitRxWindows()
+{
+ /* code */
+ // 璁㈤槄鏁版嵁
+ IRxWindows* pRxWindows = RX_GetRxWindows();
+ pRxWindows->enableLog(5);
+ if (m_pObserver == NULL) {
+ m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
+ // onNext
+ pAny->addRef();
+ int code = pAny->getCode();
+ //if (true) {
+
+ //}
+ pAny->release();
+ }, [&]() -> void {
+ // onComplete
+ }, [&](IThrowable* pThrowable) -> void {
+ // onErrorm
+ pThrowable->printf();
+ });
+
+ theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
+ ->subscribe(m_pObserver);
+ }
+}
+
+BOOL CProjectPageMain::OnInitDialog()
+{
+ CDialogEx::OnInitDialog();
+
+ InitRxWindows();
+ SetTimer(TIMER_READ_PLC_DATA, 500, nullptr);
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+HBRUSH CProjectPageMain::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+ HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
+
+ if (nCtlColor == CTLCOLOR_STATIC) {
+ pDC->SetBkColor(m_crBkgnd);
+ }
+
+ if (m_hbrBkgnd == nullptr) {
+ m_hbrBkgnd = CreateSolidBrush(m_crBkgnd);
+ }
+
+ return m_hbrBkgnd;
+}
+
+void CProjectPageMain::OnDestroy()
+{
+ CDialogEx::OnDestroy();
+
+ if (m_hbrBkgnd != nullptr) {
+ ::DeleteObject(m_hbrBkgnd);
+ }
+
+ ASSERT(m_pObserver != NULL);
+ m_pObserver->unsubscribe();
+ m_pObserver = NULL;
+}
+
+void CProjectPageMain::OnSize(UINT nType, int cx, int cy)
+{
+ CDialogEx::OnSize(nType, cx, cy);
+
+ CRect rcClient;
+ GetClientRect(&rcClient);
+}
+
+void CProjectPageMain::OnTimer(UINT_PTR nIDEvent)
+{
+ if (TIMER_READ_PLC_DATA == nIDEvent) {
+ ASSERT(m_pPLC);
+
+ if (m_pPLC != nullptr && m_pPLC->isConnected()) {
+ ReadPLCDataToUI();
+ }
+ }
+
+ CDialogEx::OnTimer(nIDEvent);
+}
+
+void CProjectPageMain::OnClose()
+{
+ // TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
+ KillTimer(TIMER_READ_PLC_DATA);
+
+ CDialogEx::OnClose();
+}
+
+void CProjectPageMain::OnBnClickedButtonActivate()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ HandleOperation(OperationType::RUN);
+}
+
+void CProjectPageMain::OnBnClickedButtonAuto()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ HandleOperation(OperationType::AUTO);
+}
+
+void CProjectPageMain::OnBnClickedButtonPuase()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ HandleOperation(OperationType::PUASE);
+}
+
+void CProjectPageMain::OnBnClickedButtonManualOperation()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ HandleOperation(OperationType::MANUAL);
+}
+
+void CProjectPageMain::OnBnClickedButtonSoundOff()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ bool bMute = theApp.m_model.getBonder().isMute();
+ WriteOperationDataToPLC(OperationType::MUTE, !bMute);
+}
+
+void CProjectPageMain::OnBnClickedButtonResetting()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ HandleOperation(OperationType::OPR);
+}
+
+void CProjectPageMain::OnBnClickedButtonStop()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ HandleOperation(OperationType::STOP);
+}
+
+LRESULT CProjectPageMain::OnUpdateDataToUI(WPARAM wParam, LPARAM lParam)
+{
+ CString strText;
+ strText.Format(_T("%d %s"), nVelocityRatio, _T("%"));
+ GetDlgItem(IDC_EDIT_VELOCITY_RATIO)->SetWindowText(strText);
+
+ strText.Format(_T("%.2f"), dTactTime);
+ GetDlgItem(IDC_EDIT_TACT_TIME)->SetWindowText(strText);
+
+ SetDlgItemInt(IDC_EDIT_DAY_SHIFT_CAPACITY, nDayShiftCapacity);
+ SetDlgItemInt(IDC_EDIT_NIGHT_SHIFT_CAPACITY, nNightShiftCapacity);
+
+ return 0;
+}
diff --git a/SourceCode/Bond/BondEq/CProjectPageMain.h b/SourceCode/Bond/BondEq/CProjectPageMain.h
new file mode 100644
index 0000000..21a2387
--- /dev/null
+++ b/SourceCode/Bond/BondEq/CProjectPageMain.h
@@ -0,0 +1,68 @@
+锘�#pragma once
+#include "afxdialogex.h"
+
+// CProjectPageMain 瀵硅瘽妗�
+
+enum class OperationType {
+ RUN = 0, // 鍚姩
+ AUTO, // 鑷姩
+ PUASE, // 鏆傚仠
+ MANUAL, // 鎵嬪姩
+ MUTE, // 闈欓煶
+ OPR, // 澶嶄綅
+ STOP // 鍋滄
+};
+
+class CProjectPageMain : public CDialogEx
+{
+ DECLARE_DYNAMIC(CProjectPageMain)
+
+public:
+ CProjectPageMain(CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
+ virtual ~CProjectPageMain();
+
+public:
+ void SetPLC(CPLC* pPLC);
+
+private:
+ void InitRxWindows();
+ void HandleOperation(OperationType eOpType);
+ void WriteOperationDataToPLC(OperationType eOpType, bool bPressed);
+ void ReadPLCDataToUI();
+
+private:
+ COLORREF m_crBkgnd;
+ HBRUSH m_hbrBkgnd;
+ IObserver* m_pObserver;
+ CPLC* m_pPLC;
+
+ int nVelocityRatio; // 閫熷害姣�
+ double dTactTime; // 鍛ㄦ湡鏃堕棿
+ int nDayShiftCapacity;
+ int nNightShiftCapacity;
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_PROJECT_PAGE_MAIN };
+#endif
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 鏀寔
+
+ DECLARE_MESSAGE_MAP()
+public:
+ virtual BOOL OnInitDialog();
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnDestroy();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnTimer(UINT_PTR nIDEvent);
+ afx_msg void OnClose();
+ afx_msg void OnBnClickedButtonActivate();
+ afx_msg void OnBnClickedButtonAuto();
+ afx_msg void OnBnClickedButtonPuase();
+ afx_msg void OnBnClickedButtonManualOperation();
+ afx_msg void OnBnClickedButtonSoundOff();
+ afx_msg void OnBnClickedButtonResetting();
+ afx_msg void OnBnClickedButtonStop();
+ afx_msg LRESULT OnUpdateDataToUI(WPARAM wParam, LPARAM lParam);
+};
diff --git a/SourceCode/Bond/BondEq/Common.h b/SourceCode/Bond/BondEq/Common.h
index 5a559d2..2a54d66 100644
--- a/SourceCode/Bond/BondEq/Common.h
+++ b/SourceCode/Bond/BondEq/Common.h
@@ -161,6 +161,9 @@
#define BTN_SOUND_OFF_BKGND_NORMAL RGB(255, 127, 39)
#define BTN_SOUND_OFF_BKGND_HOVER RGB(255, 157, 59)
#define BTN_SOUND_OFF_BKGND_PRESS RGB(255, 100, 29)
+#define BTN_SOUND_ON_BKGND_NORMAL RGB(100, 200, 100)
+#define BTN_SOUND_ON_BKGND_HOVER RGB(150, 250, 150)
+#define BTN_SOUND_ON_BKGND_PRESS RGB(50, 150, 50)
/* 按钮id */
diff --git a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
index 86c978d..d0391cb 100644
--- a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
+++ b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
@@ -10,35 +10,17 @@
}
// 构造函数
-RecipeManager::RecipeManager() : m_recipeFolder("Recipe") {}
+RecipeManager::RecipeManager() : m_recipeFolder("Recipe"), m_currentRecipeName("") {}
-// 设置配方文件夹
-void RecipeManager::setRecipeFolder(const std::string& folderPath) {
- m_recipeFolder = folderPath;
-}
-
-// 加载配方(如果文件不存在,加载默认数据)
-bool RecipeManager::loadRecipe(const std::string& recipeName) {
- std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
- pugi::xml_document doc;
-
- if (!doc.load_file(filePath.c_str())) {
- std::cerr << "Recipe file not found: " << filePath << ". Loading default recipe." << std::endl;
- generateDefaultRecipe();
- return false; // 文件不存在,但加载了默认数据
- }
-
+// 加载轴信息
+bool RecipeManager::loadAxes(pugi::xml_node axesNode) {
m_axes.clear();
-
- auto recipe = doc.child("Recipe");
- for (auto axisNode : recipe.child("Axes").children("Axis")) {
+ for (auto axisNode : axesNode.children("Axis")) {
AxisInfo axisInfo;
axisInfo.id = axisNode.attribute("id").as_int();
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(
@@ -68,9 +50,9 @@
);
// 加载 PositionRange 值
- axisInfo.positioningPointCount = axisNode.child("Positions").attribute("positioningPointCount").as_int();
+ axisInfo.positioningPointCount = axisNode.child("Positions").attribute("positioningPointCount").as_int();
for (auto positionNode : axisNode.child("Positions").children("Position")) {
- bool isEnable = positionNode.attribute("isEnable").as_bool();
+ bool isEnable = positionNode.attribute("isEnable").as_bool();
std::string description = positionNode.attribute("description").value();
ValueRange positionRange(
positionNode.attribute("min").as_double(),
@@ -87,26 +69,8 @@
return true;
}
-// 保存配方
-bool RecipeManager::saveRecipe(const std::string& recipeName) {
- // 生成文件路径
- std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
-
- // 创建 XML 文档对象
- pugi::xml_document doc;
-
- // 如果轴数据为空,生成默认配方
- if (m_axes.empty()) {
- generateDefaultRecipe();
- }
-
- // 添加配方根节点
- auto recipe = doc.append_child("Recipe");
-
- // 添加轴列表节点
- auto axesNode = recipe.append_child("Axes");
-
- // 遍历所有轴数据并写入 XML
+// 保存轴信息
+void RecipeManager::saveAxes(pugi::xml_node& axesNode) {
for (const auto& axisEntry : m_axes) {
const AxisInfo& axisInfo = axisEntry.second;
@@ -115,8 +79,6 @@
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");
@@ -156,6 +118,55 @@
positionNode.append_attribute("current") = position.range.currentValue;
}
}
+}
+
+// 设置配方文件夹
+void RecipeManager::setRecipeFolder(const std::string& folderPath) {
+ m_recipeFolder = folderPath;
+}
+
+// 获取当前配方名称
+std::string RecipeManager::getCurrentRecipeName() const {
+ return m_currentRecipeName;
+}
+
+// 加载配方(如果文件不存在,加载默认数据)
+bool RecipeManager::loadRecipe(const std::string& recipeName) {
+ std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
+ pugi::xml_document doc;
+
+ if (!doc.load_file(filePath.c_str())) {
+ std::cerr << "Recipe file not found: " << filePath << ". Loading default recipe." << std::endl;
+ return false; // 文件不存在
+ }
+ m_currentRecipeName = recipeName;
+
+ auto recipeNode = doc.child("Recipe");
+ auto axesNode = recipeNode.child("Axes");
+ loadAxes(axesNode); // 加载轴信息
+
+ return true;
+}
+
+// 保存配方
+bool RecipeManager::saveRecipe(const std::string& recipeName) {
+ // 生成文件路径
+ std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
+
+ // 创建 XML 文档对象
+ pugi::xml_document doc;
+
+ // 如果轴数据为空,生成默认配方
+ if (m_axes.empty()) {
+ generateDefaultRecipe();
+ }
+
+ // 添加配方根节点
+ auto recipeNode = doc.append_child("Recipe");
+
+ // 添加轴信息
+ auto axesNode = recipeNode.append_child("Axes");
+ saveAxes(axesNode);
// 保存 XML 文件
return doc.save_file(filePath.c_str());
@@ -164,13 +175,12 @@
// 生成默认配方
void RecipeManager::generateDefaultRecipe() {
m_axes.clear();
+ m_currentRecipeName = "Default";
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);
diff --git a/SourceCode/Bond/BondEq/FileManager/RecipeManager.h b/SourceCode/Bond/BondEq/FileManager/RecipeManager.h
index f0c873c..ed43b0c 100644
--- a/SourceCode/Bond/BondEq/FileManager/RecipeManager.h
+++ b/SourceCode/Bond/BondEq/FileManager/RecipeManager.h
@@ -52,6 +52,9 @@
// 设置配方文件夹路径
void setRecipeFolder(const std::string& folderPath);
+ // 获取当前配方名称
+ std::string getCurrentRecipeName() const;
+
// 加载配方(文件不存在时加载默认数据)
bool loadRecipe(const std::string& recipeName);
@@ -88,7 +91,12 @@
private:
RecipeManager();
+ // 轴加载和保存函数
+ bool loadAxes(pugi::xml_node axesNode);
+ void saveAxes(pugi::xml_node& axesNode);
+
private:
+ std::string m_currentRecipeName; // 当前配方名称
std::string m_recipeFolder; // 配方文件夹路径
std::map<int, AxisInfo> m_axes; // 轴信息缓存
};
diff --git a/SourceCode/Bond/BondEq/Resource.h b/SourceCode/Bond/BondEq/Resource.h
index 38eeaf8..4e3cdb4 100644
--- a/SourceCode/Bond/BondEq/Resource.h
+++ b/SourceCode/Bond/BondEq/Resource.h
Binary files differ
diff --git a/SourceCode/Bond/BondEq/ToolUnits.cpp b/SourceCode/Bond/BondEq/ToolUnits.cpp
index f9022f8..ad4d92e 100644
--- a/SourceCode/Bond/BondEq/ToolUnits.cpp
+++ b/SourceCode/Bond/BondEq/ToolUnits.cpp
@@ -152,7 +152,7 @@
int CToolUnits::toInt32(const char* pBuffer)
{
- return (pBuffer[0] & 0xff) | (pBuffer[1] & 0xff) << 8 | (pBuffer[2] & 0xff) << 16 | (pBuffer[3] & 0xff) << 24;
+ return (pBuffer[0] & 0xff) | ((pBuffer[1] & 0xff) << 8) | ((pBuffer[2] & 0xff) << 16) | ((pBuffer[3] & 0xff) << 24);
}
int CToolUnits::toInt16(const char* pBuffer)
@@ -247,3 +247,57 @@
strText.Format(_T("%.03f"), value);
pWnd->SetDlgItemText(nCtrlId, strText);
}
+
+std::vector<CString> CToolUnits::GetFileNamesInDirectory(const CString& strFolderPath, const CString& strExtension)
+{
+ std::vector<CString> fileNames;
+
+ // 确保目录路径最后有反斜杠
+ CString strSearchPath = strFolderPath;
+ if (strSearchPath[strSearchPath.GetLength() - 1] != '\\') {
+ strSearchPath += '\\';
+ }
+
+ CString finalExtension = strExtension;
+ if (finalExtension.Find('.') == -1) {
+ finalExtension = '.' + finalExtension;
+ }
+ strSearchPath += "*" + finalExtension;
+
+ std::unique_ptr<CFileFind> finder = std::make_unique<CFileFind>();
+ BOOL bWorking = finder->FindFile(strSearchPath);
+
+ // 遍历文件夹
+ while (bWorking) {
+ bWorking = finder->FindNextFile();
+ if (!finder->IsDirectory()) {
+ CString fileName = finder->GetFileName();
+ int dotPos = fileName.ReverseFind('.');
+ if (dotPos != -1) {
+ fileName = fileName.Left(dotPos);
+ }
+ fileNames.push_back(fileName);
+ }
+ }
+
+ return fileNames;
+}
+
+std::string CToolUnits::getRecipePath()
+{
+ return getCurrentExePath() + "\\Recipe";
+}
+
+std::string CToolUnits::getCurrentTimeString()
+{
+ struct tm ltm;
+ time_t now = time(0);
+ localtime_s(<m, &now); // 使用安全的 localtime_s 函数
+
+ char buffer[256];
+ sprintf_s(buffer, sizeof(buffer), "%04d-%02d-%02d %02d:%02d:%02d",
+ ltm.tm_year + 1900, ltm.tm_mon + 1, ltm.tm_mday,
+ ltm.tm_hour, ltm.tm_min, ltm.tm_sec);
+
+ return std::string(buffer);
+}
\ No newline at end of file
diff --git a/SourceCode/Bond/BondEq/ToolUnits.h b/SourceCode/Bond/BondEq/ToolUnits.h
index cfd7de0..9e8fdfb 100644
--- a/SourceCode/Bond/BondEq/ToolUnits.h
+++ b/SourceCode/Bond/BondEq/ToolUnits.h
@@ -25,5 +25,8 @@
static BOOL getBit(const char c, int index);
static void setBit(char* p, int index);
static void setDlgItemDouble(CWnd* pWnd, int nCtrlId, double value);
+ static std::vector<CString> GetFileNamesInDirectory(const CString& strFolderPath, const CString& strExtension);
+ static std::string getRecipePath();
+ static std::string getCurrentTimeString();
};
diff --git a/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp
index e010f8b..a9baca3 100644
--- a/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.cpp
@@ -11,17 +11,15 @@
// CAxisDetailSettingsDlg 瀵硅瘽妗�
-IMPLEMENT_DYNAMIC(CAxisDetailSettingsDlg, CDialogEx)
+IMPLEMENT_DYNAMIC(CAxisDetailSettingsDlg, CBaseDlg)
CAxisDetailSettingsDlg::CAxisDetailSettingsDlg(const CString& strRecipeName, int nAxisNO, CWnd* pParent /*=nullptr*/)
- : CDialogEx(IDD_DIALOG_AXIS_DETAIL_SETTINGS, pParent)
+ : CBaseDlg(IDD_DIALOG_AXIS_DETAIL_SETTINGS, pParent)
{
m_strRecipeName = strRecipeName;
m_nAxisNO = nAxisNO;
m_pPLC = nullptr;
- m_nInitialWidth = 0;
- m_nInitialHeight = 0;
}
CAxisDetailSettingsDlg::~CAxisDetailSettingsDlg()
@@ -206,9 +204,153 @@
GetDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME_MAX)->SetWindowText(formatDouble(axisDetails.decelerationTime.maxValue));
}
+bool CAxisDetailSettingsDlg::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 CAxisDetailSettingsDlg::writeAxisDataToPLC(int nAxisId)
+{
+ // 鑾峰彇杞存暟鎹�
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ AxisInfo axisData = recipeManager.getAxis(nAxisId);
+
+ MC::SOFT_COMPONENT enComponent;
+ int nStartAddress, nEndAddress, nSize;
+ if (!ParsePLCAddress(CString(axisData.startAddress.c_str()), enComponent, nStartAddress)) {
+ AfxMessageBox(_T("鏃犳晥鐨勮捣濮嬪湴鍧�锛�"));
+ }
+ nEndAddress = nStartAddress + 300;
+ nSize = (nEndAddress - nStartAddress + 1) * 2;
+
+ char szWrite[300] = { 0 };
+
+ auto writeIntToBuffer = [&](int value, int nWriteIndex) {
+ if (nWriteIndex + 4 <= sizeof(szWrite)) {
+ // 灏忕
+ szWrite[nWriteIndex] = static_cast<char>(value & 0xFF); // 浣庡瓧鑺�
+ szWrite[nWriteIndex + 1] = static_cast<char>((value >> 8) & 0xFF); // 娆′綆瀛楄妭
+ szWrite[nWriteIndex + 2] = static_cast<char>((value >> 16) & 0xFF); // 娆¢珮瀛楄妭
+ szWrite[nWriteIndex + 3] = static_cast<char>((value >> 24) & 0xFF); // 楂樺瓧鑺�
+
+ // 澶х
+ //szWrite[nWriteIndex + 3] = static_cast<char>(value & 0xFF); // 楂樺瓧鑺�
+ //szWrite[nWriteIndex + 2] = static_cast<char>((value >> 8) & 0xFF); // 娆¢珮瀛楄妭
+ //szWrite[nWriteIndex + 1] = static_cast<char>((value >> 16) & 0xFF); // 娆′綆瀛楄妭
+ //szWrite[nWriteIndex] = static_cast<char>((value >> 24) & 0xFF); // 浣庡瓧鑺�
+ }
+ };
+
+ // 鍐欏叆鎵嬪姩閫熷害
+ // writeIntToBuffer(static_cast<int>(axisData.manualSpeed.minValue * 1000), 0);
+ writeIntToBuffer(static_cast<int>(axisData.manualSpeed.currentValue * 1000), 82);
+ // writeIntToBuffer(static_cast<int>(axisData.manualSpeed.maxValue * 1000), 0);
+
+ // 鍐欏叆鑷姩閫熷害
+ // writeIntToBuffer(static_cast<int>(axisData.autoSpeed.minValue * 1000), 0);
+ writeIntToBuffer(static_cast<int>(axisData.autoSpeed.currentValue * 1000), 84);
+ // writeIntToBuffer(static_cast<int>(axisData.autoSpeed.maxValue * 1000), 0);
+
+ // 鍐欏叆鍔犻�熸椂闂�
+ // writeIntToBuffer(static_cast<int>(axisData.accelerationTime.minValue * 1000), 0);
+ writeIntToBuffer(static_cast<int>(axisData.accelerationTime.currentValue * 1000), 62);
+ // writeIntToBuffer(static_cast<int>(axisData.accelerationTime.maxValue * 1000), 0);
+
+ // 鍐欏叆鍑忛�熸椂闂�
+ // writeIntToBuffer(static_cast<int>(axisData.decelerationTime.minValue * 1000), 0);
+ writeIntToBuffer(static_cast<int>(axisData.decelerationTime.currentValue * 1000), 64);
+ // writeIntToBuffer(static_cast<int>(axisData.decelerationTime.maxValue * 1000), 0);
+
+ // 鍐欏叆寰姩閲�
+ // writeIntToBuffer(static_cast<int>(axisData.jogDistance.minValue * 1000), 0);
+ writeIntToBuffer(static_cast<int>(axisData.jogDistance.currentValue * 1000), 81);
+ // writeIntToBuffer(static_cast<int>(axisData.jogDistance.maxValue * 1000), 0);
+
+ // 瀹氫綅鐐规暟鎹�
+ int nIndex = 100;
+ for (int i = 0; i < axisData.positions.size(); ++i) {
+ const auto& position = axisData.positions[i];
+ // writeIntToBuffer(static_cast<int>(position.range.minValue * 1000), 0);
+ writeIntToBuffer(static_cast<int>(position.range.currentValue * 1000), nIndex + (i * 2));
+ // writeIntToBuffer(static_cast<int>(position.range.maxValue * 1000), 0);
+ }
+
+ // 鍚� PLC 鍐欏叆淇″彿
+ m_pPLC->writeData(enComponent, nStartAddress, szWrite, nSize, [nStartAddress, &szWrite](IMcChannel* pChannel, int nAddr, DWORD nValue, int nFlag) {
+ if (nFlag == 0) {
+ TRACE("鎿嶄綔鎴愬姛锛氬湴鍧�=%d锛屽��=%s\n", nStartAddress, szWrite);
+ }
+ else {
+ TRACE("鎿嶄綔澶辫触锛氬湴鍧�=%d锛岄敊璇爜=%d\n", nStartAddress, nFlag);
+ }
+ });
+}
+
void CAxisDetailSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialogEx::DoDataExchange(pDX);
+ CBaseDlg::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);
@@ -216,7 +358,7 @@
}
-BEGIN_MESSAGE_MAP(CAxisDetailSettingsDlg, CDialogEx)
+BEGIN_MESSAGE_MAP(CAxisDetailSettingsDlg, CBaseDlg)
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)
@@ -228,7 +370,7 @@
BOOL CAxisDetailSettingsDlg::OnInitDialog()
{
- CDialogEx::OnInitDialog();
+ CBaseDlg::OnInitDialog();
// TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
CString strTitle;
@@ -387,6 +529,7 @@
// 淇濆瓨杞存暟鎹埌鏂囦欢
CString cstrMessage;
if (RecipeManager::getInstance().saveRecipe(std::string(CT2A(m_strRecipeName)))) {
+ writeAxisDataToPLC(m_nAxisNO);
cstrMessage.Format(_T("淇濆瓨杞� [%d] 缁嗛儴鍙傛暟鎴愬姛锛�"), m_nAxisNO);
SystemLogManager::getInstance().log(SystemLogManager::LogType::Operation, std::string(CT2A(cstrMessage)));
}
diff --git a/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h
index c3422e7..181b34e 100644
--- a/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h
+++ b/SourceCode/Bond/BondEq/View/AxisDetailSettingsDlg.h
@@ -1,11 +1,12 @@
锘�#pragma once
#include "afxdialogex.h"
#include "GridCtrl.h"
+#include "CBaseDlg.h"
// CAxisDetailSettingsDlg 瀵硅瘽妗�
-class CAxisDetailSettingsDlg : public CDialogEx
+class CAxisDetailSettingsDlg : public CBaseDlg
{
DECLARE_DYNAMIC(CAxisDetailSettingsDlg)
@@ -25,12 +26,11 @@
void InitAnchorPontManager();
void FillAnchorPontManager();
void UpdateAxisDetailSettings();
-
+ bool ParsePLCAddress(const CString& address, MC::SOFT_COMPONENT& component, int& addr);
+ void writeAxisDataToPLC(int nAxisId);
private:
CPLC* m_pPLC;
- int m_nInitialWidth;
- int m_nInitialHeight;
// 鏁版嵁
int m_nAxisNO;
diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
index d8add62..7cf9480 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.cpp
@@ -21,13 +21,11 @@
// CAxisSettingsDlg 瀵硅瘽妗�
-IMPLEMENT_DYNAMIC(CAxisSettingsDlg, CDialogEx)
+IMPLEMENT_DYNAMIC(CAxisSettingsDlg, CBaseDlg)
CAxisSettingsDlg::CAxisSettingsDlg(CWnd* pParent /*=nullptr*/)
- : CDialogEx(IDD_DIALOG_AXIS_SETTINGS, pParent)
+ : CBaseDlg(IDD_DIALOG_AXIS_SETTINGS, pParent)
{
- m_nInitialWidth = 0;
- m_nInitialHeight = 0;
m_pPLC = nullptr;
m_bSEV = FALSE;
@@ -63,14 +61,6 @@
CAxisSettingsDlg::~CAxisSettingsDlg()
{
- for (auto& pair : m_mapFonts) {
- if (pair.second) {
- pair.second->DeleteObject();
- delete pair.second;
- }
- }
- m_mapFonts.clear();
-
for (int i = 0; i < BTN_MAX; i++) {
delete m_pBlBtns[i];
}
@@ -97,7 +87,7 @@
void CAxisSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialogEx::DoDataExchange(pDX);
+ CBaseDlg::DoDataExchange(pDX);
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);
@@ -130,81 +120,12 @@
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)
{
+ if (label.m_hWnd == nullptr) {
+ return;
+ }
+
// 鑾峰彇鎺т欢鐨勭煩褰㈠尯鍩�
CRect rect;
label.GetClientRect(&rect);
@@ -212,7 +133,7 @@
// 鍔ㄦ�佽绠楀瓧浣撳ぇ灏忥紝鍩轰簬鎺т欢鐨勯珮搴�
int fontSize = rect.Height() / 2; // 鎺т欢楂樺害鐨勪竴鍗婁綔涓哄瓧浣撳ぇ灏�
if (fontSize < 8) fontSize = 8; // 鏈�灏忓瓧浣撳ぇ灏�
- if (fontSize > 30) fontSize = 30; // 鏈�澶у瓧浣撳ぇ灏�
+ if (fontSize > 20) fontSize = 20; // 鏈�澶у瓧浣撳ぇ灏�
// 璁剧疆瀛椾綋澶у皬
label.SetFontSize(fontSize);
@@ -299,7 +220,6 @@
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;
}
@@ -829,7 +749,7 @@
}
-BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CDialogEx)
+BEGIN_MESSAGE_MAP(CAxisSettingsDlg, CBaseDlg)
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)
@@ -851,8 +771,6 @@
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()
END_MESSAGE_MAP()
@@ -863,7 +781,7 @@
BOOL CAxisSettingsDlg::OnInitDialog()
{
- CDialogEx::OnInitDialog();
+ CBaseDlg::OnInitDialog();
// TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
CString strTitle;
@@ -893,6 +811,8 @@
pLabel->SetTextColor(RGB(255, 255, 255));
pLabel->SetAlignment(AlignCenter);
pLabel->SetDynamicFont(TRUE);
+
+ AdjustLabelFont(*pLabel);
}
// 鍒濆鍖栫紪杈戞
@@ -967,47 +887,6 @@
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);
@@ -1053,7 +932,7 @@
}
if (currentIndex == -1) {
- return CDialogEx::PreTranslateMessage(pMsg);
+ return CBaseDlg::PreTranslateMessage(pMsg);
}
CString descriptionCtrlName, positionCtrlName;
@@ -1067,7 +946,7 @@
CWnd* pPositionCtrl = GetDlgItem(positionCtrlId);
if (pDescriptionCtrl == nullptr || pPositionCtrl == nullptr) {
- return CDialogEx::PreTranslateMessage(pMsg);
+ return CBaseDlg::PreTranslateMessage(pMsg);
}
PositionRange& position = recipeManager.getPositionByIndex(getCurrentSelectedAxisID(), m_currentPage, AXIS_PAGE_SIZE, currentIndex);
@@ -1079,7 +958,7 @@
CString strText;
GetDlgItem(IDC_EDIT_AXIS_CURR_POS)->GetWindowText(strText);
if (strText.IsEmpty()) {
- return CDialogEx::PreTranslateMessage(pMsg);;
+ return CBaseDlg::PreTranslateMessage(pMsg);;
}
double enteredValue = _ttof(strText);
@@ -1135,24 +1014,14 @@
}
}
- return CDialogEx::PreTranslateMessage(pMsg);
+ return CBaseDlg::PreTranslateMessage(pMsg);
}
void CAxisSettingsDlg::OnSize(UINT nType, int cx, int cy)
{
- CDialogEx::OnSize(nType, cx, cy);
+ CBaseDlg::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 鐨勫瓧浣撳ぇ灏�
for (auto pLabel : m_pBlLabels) {
AdjustLabelFont(*pLabel);
@@ -1179,30 +1048,6 @@
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()
@@ -1513,7 +1358,7 @@
readPLCDataToUI(nAxisId);
}
- CDialogEx::OnTimer(nIDEvent);
+ CBaseDlg::OnTimer(nIDEvent);
}
void CAxisSettingsDlg::OnClose()
@@ -1521,5 +1366,5 @@
// TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
KillTimer(TIMER_READ_PLC_DATA);
- CDialogEx::OnClose();
+ CBaseDlg::OnClose();
}
diff --git a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
index ed1e674..ef66b8f 100644
--- a/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
+++ b/SourceCode/Bond/BondEq/View/AxisSettingsDlg.h
@@ -4,6 +4,7 @@
#include "BLLabel.h"
#include "RegexEdit.h"
#include "CPLC.h"
+#include "CBaseDlg.h"
// 姣忛〉瀹氫綅鐐规樉绀轰釜鏁�
#define AXIS_PAGE_SIZE 5
@@ -63,7 +64,7 @@
POSITION_5 // 瀹氫綅鐐�5
};
-class CAxisSettingsDlg : public CDialogEx
+class CAxisSettingsDlg : public CBaseDlg
{
DECLARE_DYNAMIC(CAxisSettingsDlg)
@@ -82,10 +83,6 @@
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 SetLabelColorBasedOnState(CBLLabel& label, BOOL bState, COLORREF colorTrue, COLORREF colorFalse);
@@ -108,8 +105,6 @@
private:
CPLC* m_pPLC;
- int m_nInitialWidth;
- int m_nInitialHeight;
// 褰撳墠閫変腑鐨勫畾浣嶉〉闈㈢储寮�
int m_currentPage;
@@ -123,10 +118,6 @@
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;
-
- std::map<int, CRect> m_mapCtrlLayouts;
- std::map<int, CFont*> m_mapFonts;
// 璇诲埌鐨勬暟鎹�
BOOL m_bSEV;
@@ -151,8 +142,6 @@
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();
diff --git a/SourceCode/Bond/BondEq/View/RecipeListDlg.cpp b/SourceCode/Bond/BondEq/View/RecipeListDlg.cpp
new file mode 100644
index 0000000..942dc0b
--- /dev/null
+++ b/SourceCode/Bond/BondEq/View/RecipeListDlg.cpp
@@ -0,0 +1,464 @@
+锘�// RecipeLiseDlg.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "BondEq.h"
+#include "afxdialogex.h"
+#include "RecipeListDlg.h"
+#include "InputDialog.h"
+#include "ToolUnits.h"
+#include <fstream>
+#include <sstream>
+#include <map>
+
+
+// CRecipeListDlg 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CRecipeListDlg, CBaseDlg)
+
+CRecipeListDlg::CRecipeListDlg(CWnd* pParent /*=nullptr*/)
+ : CBaseDlg(IDD_DIALOG_RECIPE_LIST, pParent)
+{
+ m_staticCurrRecipe = new CBLLabel();
+}
+
+CRecipeListDlg::~CRecipeListDlg()
+{
+ if (m_staticCurrRecipe != nullptr) {
+ delete m_staticCurrRecipe;
+ m_staticCurrRecipe = nullptr;
+ }
+}
+
+void CRecipeListDlg::AdjustLabelFont(CBLLabel& label)
+{
+ if (label.m_hWnd == nullptr) {
+ return;
+ }
+
+ // 鑾峰彇鎺т欢鐨勭煩褰㈠尯鍩�
+ 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 CRecipeListDlg::InitRecipeLise()
+{
+ if (m_grid.GetSafeHwnd() == NULL)
+ return;
+
+ int nRows = 1;
+ int nCols = 4;
+
+ 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, 120);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("鎻忚堪"));
+ m_grid.SetColumnWidth(nColIdx, 30);
+ m_grid.SetItemText(nRowIdx, nColIdx++, _T("鍒涘缓鏃堕棿"));
+
+ m_grid.SetFixedRowSelection(FALSE); // 璁剧疆鍥哄畾琛屼笉鍙�変腑
+ m_grid.SetFixedColumnSelection(FALSE); // 璁剧疆鍥哄畾鍒椾笉鍙�変腑
+ m_grid.SetEditable(FALSE); // 璁剧疆鍗曞厓鏍煎彲缂栬緫
+ 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(); // 鏈�鍚庝竴鍒楀~鍏呯綉鏍�
+
+ FillRecipeLise();
+}
+
+void CRecipeListDlg::FillRecipeLise()
+{
+ // 娓呴櫎鏁版嵁琛岋紝淇濈暀琛ㄥご
+ for (int i = m_grid.GetRowCount() - 1; i > 0; --i) {
+ m_grid.DeleteRow(i);
+ }
+
+ // 1. 閬嶅巻鏂囦欢澶逛笅鎵�鏈塜ML鏂囦欢
+ std::string strRecipePath = CToolUnits::getRecipePath();
+ std::vector<CString> vecFile = CToolUnits::GetFileNamesInDirectory(strRecipePath.c_str(), _T(".xml"));
+
+ // 2. 璇诲彇 RecipeList.txt 鏂囦欢
+ std::map<CString, std::pair<CString, CString>> recipeData; // {閰嶆柟鍚�, {鎻忚堪, 鍒涘缓鏃堕棿}}
+ std::ifstream inFile(strRecipePath + "\\RecipeList.txt");
+ if (inFile.is_open()) {
+ std::string line;
+ while (std::getline(inFile, line)) {
+ if (line.empty()) continue; // 璺宠繃绌鸿
+
+ std::istringstream ss(line);
+ std::string name, description, createTime;
+
+ // CSV鏍煎紡瑙f瀽锛堥�楀彿鍒嗛殧锛�
+ if (std::getline(ss, name, ',') &&
+ std::getline(ss, description, ',') &&
+ std::getline(ss, createTime)) {
+ recipeData[CString(name.c_str())] = std::make_pair(CString(description.c_str()), CString(createTime.c_str()));
+ }
+ }
+ inFile.close();
+ }
+
+ // 3. 鏇存柊琛ㄦ牸鏁版嵁
+ int rowIdx = 1;
+ m_grid.SetRowCount(static_cast<int>(vecFile.size()) + 1);
+ for (const auto& fileName : vecFile) {
+ // 浠� RecipeList.txt 鏁版嵁涓煡鎵惧搴旂殑鎻忚堪鍜屽垱寤烘椂闂�
+ CString description = _T("");
+ CString createTime = _T("");
+ auto it = recipeData.find(fileName);
+ if (it != recipeData.end()) {
+ description = it->second.first; // 閰嶆柟鎻忚堪
+ createTime = it->second.second; // 鍒涘缓鏃堕棿
+ }
+
+ // 濉厖琛ㄦ牸鏁版嵁
+ m_grid.SetItemText(rowIdx, 0, CString(std::to_string(rowIdx).c_str())); // No.
+ m_grid.SetItemText(rowIdx, 1, fileName); // 閰嶆柟鍚嶇О
+ m_grid.SetItemText(rowIdx, 2, description); // 閰嶆柟鎻忚堪
+ m_grid.SetItemText(rowIdx, 3, createTime); // 鍒涘缓鏃堕棿
+
+ ++rowIdx;
+ }
+
+ m_grid.ExpandColumnsToFit(FALSE); // 鑷姩璋冩暣鍒楀
+ m_grid.ExpandLastColumn(); // 鏈�鍚庝竴鍒楀~鍏呯綉鏍�
+
+ // 鍒锋柊缃戞牸鎺т欢
+ m_grid.Invalidate();
+ m_grid.UpdateWindow();
+}
+
+void CRecipeListDlg::UpdateDataFile(const CString& strRecipeName, const CString& strNewDescription)
+{
+ CStdioFile file;
+ CFileException fe;
+
+ // 鎵撳紑鏂囦欢浠ヨ鍙栧拰鍐欏叆
+ CString strFilePath;
+ strFilePath.Format(_T("%s\\RecipeList.txt"), CToolUnits::getRecipePath().c_str());
+ if (file.Open(strFilePath, CFile::modeReadWrite | CFile::shareDenyNone, &fe)) {
+ CString strLine;
+ CStringArray arrLines;
+ BOOL bFound = FALSE;
+
+ // 璇诲彇鏂囦欢鍐呭鍒板唴瀛�
+ while (file.ReadString(strLine)) {
+ // 灏嗚繖涓�琛屾寜閫楀彿鍒嗗壊
+ CStringArray arrColumns;
+ int nPos = 0;
+ while ((nPos = strLine.Find(_T(','))) != -1) {
+ arrColumns.Add(strLine.Left(nPos));
+ strLine = strLine.Mid(nPos + 1);
+ }
+ arrColumns.Add(strLine); // 鏈�鍚庝竴鍒�
+
+ // 濡傛灉绗竴鍒楋紙閰嶆柟鍚嶇О锛夊尮閰嶏紝淇敼绗簩鍒楋紙閰嶆柟鎻忚堪锛�
+ if (arrColumns.GetSize() > 0 && arrColumns[0] == strRecipeName) {
+ arrColumns[1] = strNewDescription; // 淇敼閰嶆柟鎻忚堪鍒�
+ bFound = TRUE;
+ }
+
+ // 灏嗕慨鏀瑰悗鐨勮淇濆瓨鍥炲唴瀛�
+ CString strUpdatedLine;
+ for (int i = 0; i < arrColumns.GetSize(); ++i) {
+ if (i > 0) strUpdatedLine += _T(",");
+ strUpdatedLine += arrColumns[i];
+ }
+ arrLines.Add(strUpdatedLine);
+ }
+
+ if (bFound) {
+ // 濡傛灉鎵惧埌浜嗛厤鏂瑰悕绉帮紝淇濆瓨淇敼鍚庣殑鍐呭鍥炴枃浠�
+ file.SeekToBegin();
+ file.SetLength(0); // 娓呯┖鏂囦欢鍐呭
+ for (int i = 0; i < arrLines.GetSize(); ++i) {
+ file.WriteString(arrLines[i] + _T("\n"));
+ }
+ }
+ else {
+ // 濡傛灉娌℃湁鎵惧埌閰嶆柟鍚嶇О锛屽垯杩藉姞鏂伴厤鏂�
+ CString strNewLine;
+ strNewLine.Format(_T("%s,%s,%s"), strRecipeName, strNewDescription, CToolUnits::getCurrentTimeString().c_str());
+ file.SeekToEnd();
+ file.WriteString(strNewLine + _T("\n"));
+ }
+
+ file.Close();
+ }
+ else {
+ AfxMessageBox(_T("鏃犳硶鎵撳紑鏂囦欢"));
+ }
+}
+
+void CRecipeListDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CBaseDlg::DoDataExchange(pDX);
+ DDX_Control(pDX, IDC_CUSTOM_RECIPE_LIST, m_grid);
+}
+
+
+BEGIN_MESSAGE_MAP(CRecipeListDlg, CBaseDlg)
+ ON_BN_CLICKED(IDC_BUTTON_CREATE_RECIPE, &CRecipeListDlg::OnBnClickedButtonCreateRecipe)
+ ON_BN_CLICKED(IDC_BUTTON_DELETE_RECIPE, &CRecipeListDlg::OnBnClickedButtonDeleteRecipe)
+ ON_BN_CLICKED(IDC_BUTTON_SELECT_RECIPE, &CRecipeListDlg::OnBnClickedButtonSelectRecipe)
+ ON_NOTIFY(NM_DBLCLK, IDC_CUSTOM_RECIPE_LIST, &CRecipeListDlg::OnGridCellEditFinished)
+ ON_WM_SIZE()
+END_MESSAGE_MAP()
+
+
+// CRecipeListDlg 娑堟伅澶勭悊绋嬪簭
+
+
+BOOL CRecipeListDlg::OnInitDialog()
+{
+ CBaseDlg::OnInitDialog();
+
+ // TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
+ m_staticCurrRecipe->SubclassDlgItem(IDC_STATIC_CURR_RECIPE, this);
+ m_staticCurrRecipe->SetBkColor(RGB(0, 110, 110));
+ m_staticCurrRecipe->ModifyStyle(0, SS_NOTIFY);
+ m_staticCurrRecipe->SetTextColor(RGB(255, 255, 255));
+ m_staticCurrRecipe->SetAlignment(AlignCenter);
+ m_staticCurrRecipe->SetDynamicFont(TRUE);
+ m_staticCurrRecipe->SetWindowText(RecipeManager::getInstance().getCurrentRecipeName().c_str());
+
+ AdjustLabelFont(*m_staticCurrRecipe);
+
+ InitRecipeLise();
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+void CRecipeListDlg::OnSize(UINT nType, int cx, int cy)
+{
+ CBaseDlg::OnSize(nType, cx, cy);
+
+ // TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+ AdjustLabelFont(*m_staticCurrRecipe);
+}
+
+void CRecipeListDlg::OnBnClickedButtonCreateRecipe()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ CInputDialog inputDialog(_T("閰嶆柟鍚嶇О"), _T("璇疯緭鍏ラ厤鏂瑰悕绉帮細"));
+ if (inputDialog.DoModal() != IDOK) {
+ return;
+ }
+ CString newRecipeName = inputDialog.GetInputText();
+
+ // 楠岃瘉鍚嶇О涓嶉噸澶�
+ std::string recipePath = CToolUnits::getRecipePath();
+ std::string recipeListPath = recipePath + "\\RecipeList.txt";
+ std::vector<CString> existingFiles = CToolUnits::GetFileNamesInDirectory(recipePath.c_str(), ".xml");
+
+ for (const auto& fileName : existingFiles) {
+ if (newRecipeName.Compare(fileName) == 0) {
+ AfxMessageBox(_T("閰嶆柟鍚嶇О宸插瓨鍦紝璇疯緭鍏ュ叾浠栧悕绉帮紒"));
+ return;
+ }
+ }
+
+ // 妫�鏌ユ槸鍚﹁澶嶅埗閫変腑閰嶆柟
+ CString strCopyRecipe = _T("");
+ for (int i = 1; i < m_grid.GetRowCount(); i++) {
+ if (m_grid.IsCellSelected(i, 1)) {
+ strCopyRecipe = m_grid.GetItemText(i, 1);
+
+ CString strMessage;
+ strMessage.Format(_T("Copy [%s] -> [%s]?"), strCopyRecipe, newRecipeName);
+ if (AfxMessageBox(strMessage, MB_YESNO | MB_ICONQUESTION) != IDYES) {
+ strCopyRecipe = _T("");
+ }
+ break;
+ }
+ }
+
+ // 鍒涘缓鏂扮殑XML鏂囦欢
+ CString newRecipeFile = CString(recipePath.c_str()) + "\\" + newRecipeName + ".xml";
+ if (!strCopyRecipe.IsEmpty()) {
+ CString sourceFile = CString(recipePath.c_str()) + "\\" + strCopyRecipe + ".xml";
+ CopyFile(sourceFile, newRecipeFile, FALSE);
+ }
+ else {
+ // 鐢熸垚榛樿XML鏂囦欢
+ RecipeManager& recipeManager = RecipeManager::getInstance();
+ recipeManager.generateDefaultRecipe();
+ if (!recipeManager.saveRecipe(std::string(CT2A(newRecipeName)))) {
+ AfxMessageBox(_T("鍒涘缓閰嶆柟澶辫触锛�"));
+ return;
+ }
+ }
+
+ // 鏇存柊 RecipeList.txt
+ std::ofstream outFile(recipeListPath, std::ios::app); // 杩藉姞妯″紡
+ if (outFile.is_open()) {
+ SYSTEMTIME sysTime;
+ GetLocalTime(&sysTime);
+ char buffer[64];
+ sprintf_s(buffer, "%04d-%02d-%02d %02d:%02d:%02d",
+ sysTime.wYear, sysTime.wMonth, sysTime.wDay,
+ sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
+
+ outFile << CT2A(newRecipeName) << ",榛樿鎻忚堪," << buffer << std::endl;
+ outFile.close();
+ }
+
+ // 鍒锋柊缃戞牸鎺т欢
+ FillRecipeLise();
+}
+
+void CRecipeListDlg::OnBnClickedButtonDeleteRecipe()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ int nSelect = -1;
+ for (int i = 1; i < m_grid.GetRowCount(); i++) {
+ if (m_grid.IsCellSelected(i, 1)) {
+ nSelect = i;
+ break;
+ }
+ }
+
+ if (nSelect < 0) {
+ AfxMessageBox(_T("璇烽�夋嫨瑕佸垹闄ょ殑閰嶆柟锛�"));
+ return;
+ }
+
+ CString selectedRecipe = m_grid.GetItemText(nSelect, 1);
+ if (selectedRecipe.IsEmpty()) {
+ AfxMessageBox(_T("閰嶆柟鍚嶇О鏃犳晥锛�"));
+ return;
+ }
+
+ CString message = _T("纭畾瑕佸垹闄ら厤鏂� \"") + selectedRecipe + _T("\" 鍚楋紵");
+ if (AfxMessageBox(message, MB_YESNO | MB_ICONQUESTION) != IDYES) {
+ return;
+ }
+
+ // 鍒犻櫎XML鏂囦欢
+ std::string recipePath = CToolUnits::getRecipePath();
+ CString xmlFilePath = CString(recipePath.c_str()) + "\\" + selectedRecipe + ".xml";
+ if (!DeleteFile(xmlFilePath)) {
+ AfxMessageBox(_T("鍒犻櫎XML鏂囦欢澶辫触锛�"));
+ return;
+ }
+
+ // 鏇存柊RecipeList.txt鏂囦欢
+ std::string recipeListPath = recipePath + "\\RecipeList.txt";
+ std::ifstream inFile(recipeListPath);
+ std::ofstream outFile(recipeListPath + ".tmp"); // 鍒涘缓涓存椂鏂囦欢
+
+ if (inFile.is_open() && outFile.is_open()) {
+ std::string line;
+ while (std::getline(inFile, line)) {
+ std::istringstream ss(line);
+ std::string name;
+ if (std::getline(ss, name, ',')) {
+ if (selectedRecipe != CString(name.c_str())) {
+ outFile << line << std::endl; // 淇濈暀涓嶅尮閰嶇殑琛�
+ }
+ }
+ }
+ inFile.close();
+ outFile.close();
+
+ // 鏇挎崲鏂囦欢
+ DeleteFile(CString(recipeListPath.c_str()));
+ MoveFile(CString((recipeListPath + ".tmp").c_str()), CString(recipeListPath.c_str()));
+ }
+
+ // 鍒锋柊缃戞牸鎺т欢
+ FillRecipeLise();
+}
+
+void CRecipeListDlg::OnBnClickedButtonSelectRecipe()
+{
+ // TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
+ int nSelect = -1;
+ for (int i = 1; i < m_grid.GetRowCount(); i++) {
+ if (m_grid.IsCellSelected(i, 1)) {
+ nSelect = i;
+ break;
+ }
+ }
+
+ if (nSelect < 0) {
+ AfxMessageBox(_T("璇烽�夋嫨閰嶆柟锛�"));
+ return;
+ }
+
+ CString strSelectedRecipe = m_grid.GetItemText(nSelect, 1);
+ if (RecipeManager::getInstance().loadRecipe(std::string(CT2A(strSelectedRecipe)))) {
+ m_staticCurrRecipe->SetWindowText(strSelectedRecipe);
+ m_staticCurrRecipe->SetBkColor(RGB(0, 110, 110));
+ }
+ else {
+ AfxMessageBox(_T("鍔犺浇閰嶆柟澶辫触锛�"));
+ }
+}
+
+void CRecipeListDlg::OnGridCellEditFinished(NMHDR* pNotifyStruct, LRESULT* pResult)
+{
+ // 鑾峰彇淇敼鐨勮鍒椾俊鎭�
+ NM_GRIDVIEW* pItem = (NM_GRIDVIEW*)pNotifyStruct;
+ int nRow = pItem->iRow;
+ int nCol = pItem->iColumn;
+
+ // 鍙鐞嗏�滈厤鏂规弿杩扳�濆垪鐨勪慨鏀�
+ if (nCol == 2) {
+ CString strRecipeName = m_grid.GetItemText(nRow, 1);
+ CInputDialog inputDialog(_T("閰嶆柟鎻忚堪"), _T("璇疯緭鍏ラ厤鏂规弿杩帮細"));
+ if (inputDialog.DoModal() != IDOK) {
+ *pResult = 0;
+ return;
+ }
+ CString strText = inputDialog.GetInputText();
+ m_grid.SetItemText(nRow, nCol, strText);
+ UpdateDataFile(strRecipeName, strText);
+
+ m_grid.ExpandColumnsToFit(FALSE); // 鑷姩璋冩暣鍒楀
+ m_grid.ExpandLastColumn(); // 鏈�鍚庝竴鍒楀~鍏呯綉鏍�
+
+ // 鍒锋柊缃戞牸鎺т欢
+ m_grid.Invalidate();
+ m_grid.UpdateWindow();
+ }
+
+ *pResult = 0;
+}
diff --git a/SourceCode/Bond/BondEq/View/RecipeListDlg.h b/SourceCode/Bond/BondEq/View/RecipeListDlg.h
new file mode 100644
index 0000000..2dafd08
--- /dev/null
+++ b/SourceCode/Bond/BondEq/View/RecipeListDlg.h
@@ -0,0 +1,51 @@
+锘�#pragma once
+#include "afxdialogex.h"
+#include "GridCtrl.h"
+#include "CBaseDlg.h"
+#include "BLLabel.h"
+
+
+// CRecipeListDlg 瀵硅瘽妗�
+
+class CRecipeListDlg : public CBaseDlg
+{
+ DECLARE_DYNAMIC(CRecipeListDlg)
+
+public:
+ CRecipeListDlg(CWnd* pParent = nullptr); // 鏍囧噯鏋勯�犲嚱鏁�
+ virtual ~CRecipeListDlg();
+
+// 瀵硅瘽妗嗘暟鎹�
+#ifdef AFX_DESIGN_TIME
+ enum { IDD = IDD_DIALOG_RECIPE_LIST };
+#endif
+
+private:
+ //CFont* GetOrCreateFont(int nFontSize);
+ //void AdjustControls(float dScaleX, float dScaleY);
+ //void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
+ void AdjustLabelFont(CBLLabel& label);
+ void InitRecipeLise();
+ void FillRecipeLise();
+ void UpdateDataFile(const CString& strRecipeName, const CString& strNewDescription);
+
+private:
+ //int m_nInitialWidth;
+ //int m_nInitialHeight;
+ //std::map<int, CFont*> m_mapFonts; // 瀛椾綋鏄犲皠
+ //std::map<int, CRect> m_mapCtrlLayouts; // 鎺т欢甯冨眬鏄犲皠
+
+ // 鎺т欢
+ CBLLabel* m_staticCurrRecipe;
+ CGridCtrl m_grid;
+
+protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 鏀寔
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSize(UINT nType, int cx, int cy);
+ afx_msg void OnBnClickedButtonCreateRecipe();
+ afx_msg void OnBnClickedButtonDeleteRecipe();
+ afx_msg void OnBnClickedButtonSelectRecipe();
+ afx_msg void OnGridCellEditFinished(NMHDR* pNotifyStruct, LRESULT* pResult);
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
index f5603fb..499536e 100644
--- a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.cpp
@@ -9,29 +9,20 @@
// CSystemLogManagerDlg 瀵硅瘽妗�
-IMPLEMENT_DYNAMIC(CSystemLogManagerDlg, CDialogEx)
+IMPLEMENT_DYNAMIC(CSystemLogManagerDlg, CBaseDlg)
CSystemLogManagerDlg::CSystemLogManagerDlg(CWnd* pParent /*=nullptr*/)
- : CDialogEx(IDD_DIALOG_SYSTEM_LOG_MANAGER, pParent)
+ : CBaseDlg(IDD_DIALOG_SYSTEM_LOG_MANAGER, pParent)
{
- m_nInitialWidth = 0;
- m_nInitialHeight = 0;
}
CSystemLogManagerDlg::~CSystemLogManagerDlg()
{
- for (auto& pair : m_mapFonts) {
- if (pair.second) {
- pair.second->DeleteObject();
- delete pair.second;
- }
- }
- m_mapFonts.clear();
}
void CSystemLogManagerDlg::DoDataExchange(CDataExchange* pDX)
{
- CDialogEx::DoDataExchange(pDX);
+ CBaseDlg::DoDataExchange(pDX);
DDX_Control(pDX, IDC_COMBO_TYPE, m_comboType);
DDX_Control(pDX, IDC_COMBO_USER, m_comboUser);
DDX_Control(pDX, IDC_DATETIMEPICKER_START, m_dateTimeStart);
@@ -161,24 +152,6 @@
UpdatePageInfo();
}
-CFont* CSystemLogManagerDlg::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 CSystemLogManagerDlg::UpdatePageInfo()
{
// 鏍煎紡鍖栭〉鐮佷俊鎭负 "褰撳墠椤�/鎬婚〉鏁�"
@@ -187,112 +160,13 @@
m_staticPageNum.SetWindowText(pageInfo);
}
-void CSystemLogManagerDlg::SetDefaultFont()
-{
- CFont* defaultFont = GetOrCreateFont(12);
- // 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
- CWnd* pWnd = GetWindow(GW_CHILD);
- while (pWnd) {
- // 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
- TCHAR szClassName[256];
- GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- pWnd = pWnd->GetNextWindow();
- continue;
- }
-
- pWnd->SetFont(defaultFont, TRUE);
- pWnd = pWnd->GetNextWindow();
- }
-}
-
-void CSystemLogManagerDlg::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 琛ㄧず鎵�鏈夐」鐨勯珮搴�
- }
-
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
- pGridCtrl->SetDefCellHeight(newRect.Height() / 21);
- pGridCtrl->ExpandColumnsToFit(TRUE);
- pGridCtrl->ExpandLastColumn();
- pGridCtrl->Invalidate();
- pGridCtrl->UpdateWindow();
- }
-
- pWnd->MoveWindow(&newRect);
- AdjustControlFont(pWnd, newRect.Width(), newRect.Height());
- }
- pWnd = pWnd->GetNextWindow();
- }
-}
-
-void CSystemLogManagerDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight)
-{
- TCHAR szClassName[256];
- GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
-
- // 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- return;
- }
-
- // 鏍规嵁鎺т欢楂樺害鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
- int fontSize = nHeight / 2;
- if (fontSize < 8) fontSize = 8;
-
- // 鑾峰彇鎴栧垱寤哄瓧浣�
- CFont* pFont = GetOrCreateFont(fontSize);
-
- pWnd->SetFont(pFont);
- pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
-}
-
-
-void CSystemLogManagerDlg::AdjustComboBoxStyle(CComboBox& comboBox)
-{
- DWORD dwStyle = comboBox.GetStyle();
- comboBox.ModifyStyle(0, CBS_DROPDOWNLIST | CBS_HASSTRINGS | CBS_OWNERDRAWFIXED);
-
- comboBox.Invalidate();
- comboBox.UpdateWindow();
-}
-
-
-void CSystemLogManagerDlg::AdjustDateTimeCtrlStyle(CDateTimeCtrl& dateTimeCtrl)
-{
- dateTimeCtrl.ModifyStyle(0, DTS_RIGHTALIGN);
- dateTimeCtrl.Invalidate();
- dateTimeCtrl.UpdateWindow();
-}
-
-
-BEGIN_MESSAGE_MAP(CSystemLogManagerDlg, CDialogEx)
+BEGIN_MESSAGE_MAP(CSystemLogManagerDlg, CBaseDlg)
ON_BN_CLICKED(IDC_BUTTON_SEARCH, &CSystemLogManagerDlg::OnBnClickedButtonSearch)
ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CSystemLogManagerDlg::OnBnClickedButtonPrevPage)
ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CSystemLogManagerDlg::OnBnClickedButtonNextPage)
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, &CSystemLogManagerDlg::OnSelchangeComboType)
ON_CBN_SELCHANGE(IDC_COMBO_USER, &CSystemLogManagerDlg::OnSelchangeComboUser)
- ON_WM_SIZE()
- ON_WM_GETMINMAXINFO()
END_MESSAGE_MAP()
@@ -301,7 +175,7 @@
BOOL CSystemLogManagerDlg::OnInitDialog()
{
- CDialogEx::OnInitDialog();
+ CBaseDlg::OnInitDialog();
// TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
SetWindowText(_T("绯荤粺杩愯鏃ュ織"));
@@ -330,88 +204,11 @@
COleDateTime defaultStartTime = currentTime - COleDateTimeSpan(30, 0, 0, 0);
m_dateTimeStart.SetTime(defaultStartTime);
- 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;
-
- // 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
- TCHAR szClassName[256];
- GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- pWnd = pWnd->GetNextWindow();
- continue;
- }
-
- // 璁剧疆榛樿瀛椾綋
- 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);
-
InitSystemLogManager();
return TRUE; // return TRUE unless you set the focus to a control
// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
}
-
-
-void CSystemLogManagerDlg::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);
-}
-
-
-void CSystemLogManagerDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
-{
- // TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
- lpMMI->ptMinTrackSize.x = 400; // 鏈�灏忓搴�
- lpMMI->ptMinTrackSize.y = 300; // 鏈�灏忛珮搴�
-
- CDialogEx::OnGetMinMaxInfo(lpMMI);
-}
-
void CSystemLogManagerDlg::OnBnClickedButtonSearch()
{
@@ -426,7 +223,6 @@
AfxMessageBox(errorMsg, MB_ICONERROR);
}
}
-
void CSystemLogManagerDlg::OnBnClickedButtonPrevPage()
{
@@ -447,7 +243,6 @@
}
}
-
void CSystemLogManagerDlg::OnBnClickedButtonNextPage()
{
// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
@@ -467,7 +262,6 @@
}
}
-
void CSystemLogManagerDlg::OnSelchangeComboType()
{
// TODO: 鍦ㄦ娣诲姞鎺т欢閫氱煡澶勭悊绋嬪簭浠g爜
@@ -481,7 +275,6 @@
AfxMessageBox(errorMsg, MB_ICONERROR);
}
}
-
void CSystemLogManagerDlg::OnSelchangeComboUser()
{
diff --git a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
index 9cd5ea5..e5d1396 100644
--- a/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
+++ b/SourceCode/Bond/BondEq/View/SystemLogManagerDlg.h
@@ -1,10 +1,11 @@
锘�#pragma once
#include "afxdialogex.h"
#include "GridCtrl.h"
+#include "CBaseDlg.h"
// CSystemLogManagerDlg 瀵硅瘽妗�
-class CSystemLogManagerDlg : public CDialogEx
+class CSystemLogManagerDlg : public CBaseDlg
{
DECLARE_DYNAMIC(CSystemLogManagerDlg)
@@ -20,21 +21,11 @@
private:
void InitSystemLogManager();
void FillSystemLogManager();
- CFont* GetOrCreateFont(int nFontSize);
void UpdatePageInfo();
- void SetDefaultFont();
- void AdjustControls(float dScaleX, float dScaleY);
- void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
- void AdjustComboBoxStyle(CComboBox& comboBox);
- void AdjustDateTimeCtrlStyle(CDateTimeCtrl& dateTimeCtrl);
private:
- int m_nInitialWidth; // 鍒濆瀹藉害
- int m_nInitialHeight; // 鍒濆楂樺害
int m_nCurrentPage; // 褰撳墠椤电爜
int m_nTotalPages; // 鎬婚〉鏁�
- std::map<int, CRect> m_mapCtrlLayouts; // 瀛樺偍鎺т欢鐨勫垵濮嬪竷灞�淇℃伅
- std::map<int, CFont*> m_mapFonts; // 绠$悊瀛椾綋鐨勫鍣紝閿负瀛椾綋澶у皬
private:
CComboBox m_comboType;
@@ -47,15 +38,11 @@
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 鏀寔
-
- DECLARE_MESSAGE_MAP()
-public:
virtual BOOL OnInitDialog();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
afx_msg void OnBnClickedButtonSearch();
afx_msg void OnBnClickedButtonPrevPage();
afx_msg void OnBnClickedButtonNextPage();
afx_msg void OnSelchangeComboType();
afx_msg void OnSelchangeComboUser();
+ DECLARE_MESSAGE_MAP()
};
diff --git a/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp b/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
index 849c4a9..a3de9ff 100644
--- a/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/UserManagerDlg.cpp
@@ -8,37 +8,27 @@
#include "InputDialog.h"
#include "NewCellTypes/GridCellCombo.h"
#include "NewCellTypes/GridCellNumeric.h"
-
#include <set>
const COLORREF CURR_USER_BK_COLOR = RGB(0, 255, 0);
// CUserManagerDlg 瀵硅瘽妗�
-IMPLEMENT_DYNAMIC(CUserManagerDlg, CDialogEx)
+IMPLEMENT_DYNAMIC(CUserManagerDlg, CBaseDlg)
CUserManagerDlg::CUserManagerDlg(CWnd* pParent /*=nullptr*/)
- : CDialogEx(IDD_DIALOG_USER_MANAGER, pParent)
+ : CBaseDlg(IDD_DIALOG_USER_MANAGER, pParent)
{
- m_nInitialWidth = 0;
- m_nInitialHeight = 0;
}
CUserManagerDlg::~CUserManagerDlg()
{
- for (auto& pair : m_mapFonts) {
- if (pair.second) {
- pair.second->DeleteObject();
- delete pair.second;
- }
- }
- m_mapFonts.clear();
}
void CUserManagerDlg::DoDataExchange(CDataExchange* pDX)
{
DDX_Control(pDX, IDC_CUSTOM_USER, m_gridUserManager);
- CDialogEx::DoDataExchange(pDX);
+ CBaseDlg::DoDataExchange(pDX);
}
void CUserManagerDlg::InitUserManager()
@@ -350,111 +340,12 @@
return false;
}
-CFont* CUserManagerDlg::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 CUserManagerDlg::SetDefaultFont()
-{
- CFont* defaultFont = GetOrCreateFont(12);
-
- // 閬嶅巻鎵�鏈夋帶浠讹紝搴旂敤榛樿瀛椾綋
- CWnd* pWnd = GetWindow(GW_CHILD);
- while (pWnd) {
- // 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
- TCHAR szClassName[256];
- GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- pWnd = pWnd->GetNextWindow();
- continue;
- }
-
- pWnd->SetFont(defaultFont, TRUE);
- pWnd = pWnd->GetNextWindow();
- }
-}
-
-void CUserManagerDlg::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 琛ㄧず鎵�鏈夐」鐨勯珮搴�
- }
-
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- CGridCtrl* pGridCtrl = (CGridCtrl*)pWnd;
- pGridCtrl->SetDefCellHeight(newRect.Height() / 21);
- pGridCtrl->ExpandColumnsToFit(TRUE);
- pGridCtrl->ExpandLastColumn();
- pGridCtrl->Invalidate();
- pGridCtrl->UpdateWindow();
- }
-
- pWnd->MoveWindow(&newRect);
- AdjustControlFont(pWnd, newRect.Width(), newRect.Height());
- }
- pWnd = pWnd->GetNextWindow();
- }
-}
-
-void CUserManagerDlg::AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight)
-{
- TCHAR szClassName[256];
- GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
-
- // 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- return;
- }
-
- // 鏍规嵁鎺т欢楂樺害鍔ㄦ�佽皟鏁村瓧浣撳ぇ灏�
- int fontSize = nHeight / 2;
- if (fontSize < 8) fontSize = 8;
-
- // 鑾峰彇鎴栧垱寤哄瓧浣�
- CFont* pFont = GetOrCreateFont(fontSize);
-
- pWnd->SetFont(pFont);
- pWnd->Invalidate(); // 鍒锋柊鎺т欢鏄剧ず
-}
-
-BEGIN_MESSAGE_MAP(CUserManagerDlg, CDialogEx)
- ON_WM_SIZE()
+BEGIN_MESSAGE_MAP(CUserManagerDlg, CBaseDlg)
ON_NOTIFY(GVN_COMBOSELCHANGE, IDC_CUSTOM_USER, &CUserManagerDlg::OnGridComboSelChange)
ON_BN_CLICKED(IDC_BUTTON_ADD, &CUserManagerDlg::OnBnClickedButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DEL, &CUserManagerDlg::OnBnClickedButtonDel)
ON_BN_CLICKED(IDOK, &CUserManagerDlg::OnBnClickedOk)
ON_BN_CLICKED(IDC_BUTTON_INSERT, &CUserManagerDlg::OnBnClickedButtonInsert)
- ON_WM_GETMINMAXINFO()
END_MESSAGE_MAP()
@@ -463,59 +354,10 @@
BOOL CUserManagerDlg::OnInitDialog()
{
- CDialogEx::OnInitDialog();
+ CBaseDlg::OnInitDialog();
// TODO: 鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
- CRect screenRect, dlgRect, clientRect;
SetWindowText(_T("鐢ㄦ埛绠$悊"));
- SystemParametersInfo(SPI_GETWORKAREA, 0, &screenRect, 0);
-
- 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;
-
- // 璺宠繃鐗规畩鎺т欢锛堝 MFCGridCtrl锛�
- TCHAR szClassName[256];
- GetClassName(pWnd->m_hWnd, szClassName, sizeof(szClassName));
- if (_tcsicmp(szClassName, _T("MFCGridCtrl")) == 0) {
- pWnd = pWnd->GetNextWindow();
- continue;
- }
-
- // 璁剧疆榛樿瀛椾綋
- pWnd->SetFont(pDefaultFont);
- }
- pWnd = pWnd->GetNextWindow();
- }
-
- GetWindowRect(&dlgRect);
- int dlgWidth = dlgRect.Width() * 3;
- int dlgHeight = dlgRect.Height() * 3;
-
- 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);
// 鍒濆鍖栫敤鎴风鐞嗚〃鏍�
InitUserManager();
@@ -523,34 +365,6 @@
return TRUE; // return TRUE unless you set the focus to a control
// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
}
-
-
-void CUserManagerDlg::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);
-}
-
-
-void CUserManagerDlg::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
-{
- // TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
- lpMMI->ptMinTrackSize.x = 400; // 鏈�灏忓搴�
- lpMMI->ptMinTrackSize.y = 300; // 鏈�灏忛珮搴�
-
- CDialogEx::OnGetMinMaxInfo(lpMMI);
-}
-
void CUserManagerDlg::OnGridComboSelChange(NMHDR* pNMHDR, LRESULT* pResult)
{
@@ -726,5 +540,5 @@
}
userManager.setUsers(vecData);
- CDialogEx::OnOK();
+ CBaseDlg::OnOK();
}
diff --git a/SourceCode/Bond/BondEq/View/UserManagerDlg.h b/SourceCode/Bond/BondEq/View/UserManagerDlg.h
index c311784..545a019 100644
--- a/SourceCode/Bond/BondEq/View/UserManagerDlg.h
+++ b/SourceCode/Bond/BondEq/View/UserManagerDlg.h
@@ -1,10 +1,11 @@
锘�#pragma once
#include "afxdialogex.h"
#include "GridCtrl.h"
+#include "CBaseDlg.h"
// CUserManagerDlg 瀵硅瘽妗�
-class CUserManagerDlg : public CDialogEx
+class CUserManagerDlg : public CBaseDlg
{
DECLARE_DYNAMIC(CUserManagerDlg)
@@ -23,19 +24,11 @@
void AddRow(CGridCtrl* pGridCtrl);
void DeleteSelectedRow(CGridCtrl* pGridCtrl);
bool IsUsernameDuplicate(const CString& username);
- CFont* GetOrCreateFont(int nFontSize);
- void SetDefaultFont();
- void AdjustControls(float dScaleX, float dScaleY);
- void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);
private:
- int m_nInitialWidth;
- int m_nInitialHeight;
- std::map<int, CRect> m_mapCtrlLayouts;
- std::map<int, CFont*> m_mapFonts;
std::map<CString, CString> m_mapRoleDescriptions;
-private:
+ // 鎺т欢
CGridCtrl m_gridUserManager;
protected:
@@ -44,8 +37,6 @@
DECLARE_MESSAGE_MAP()
public:
virtual BOOL OnInitDialog();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
afx_msg void OnGridComboSelChange(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnBnClickedButtonAdd();
afx_msg void OnBnClickedButtonInsert();
diff --git a/SourceCode/Bond/BondEq/res_en.rc b/SourceCode/Bond/BondEq/res_en.rc
new file mode 100644
index 0000000..4d18f6f
--- /dev/null
+++ b/SourceCode/Bond/BondEq/res_en.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/res_zh.rc b/SourceCode/Bond/BondEq/res_zh.rc
new file mode 100644
index 0000000..f6d08d0
--- /dev/null
+++ b/SourceCode/Bond/BondEq/res_zh.rc
Binary files differ
diff --git a/SourceCode/Bond/BondEq/resource1.h b/SourceCode/Bond/BondEq/resource1.h
new file mode 100644
index 0000000..5ed6b8c
--- /dev/null
+++ b/SourceCode/Bond/BondEq/resource1.h
@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by res_en.rc
+
+// 新对象的下一组默认值
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/SourceCode/Bond/BondEq/resource2.h b/SourceCode/Bond/BondEq/resource2.h
new file mode 100644
index 0000000..785107b
--- /dev/null
+++ b/SourceCode/Bond/BondEq/resource2.h
@@ -0,0 +1,14 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by res_zh.rc
+
+// 新对象的下一组默认值
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 101
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1001
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/SourceCode/Bond/BondEq/stdafx.h b/SourceCode/Bond/BondEq/stdafx.h
index 95c78f8..cef3da3 100644
--- a/SourceCode/Bond/BondEq/stdafx.h
+++ b/SourceCode/Bond/BondEq/stdafx.h
@@ -56,7 +56,7 @@
// 控件样式
static UINT g_nGridFixCellColor = RGB(144, 200, 246);
static UINT g_nGridFixFontColor = RGB(0, 0, 0);
-static UINT g_nGridCellColor = RGB(255, 255, 255);
+static UINT g_nGridCellColor = RGB(255, 255, 224);
static UINT g_nGridCellColor_NonSelect = RGB(150, 150, 150);
static UINT g_nGridCellReadyColor = RGB(255, 255, 0);
static UINT g_nGridCellOnColor = RGB(255, 69, 0);
diff --git a/SourceCode/Bond/x64/Debug/Config/BondEq.db b/SourceCode/Bond/x64/Debug/Config/BondEq.db
index 8d301ed..804b3fc 100644
--- a/SourceCode/Bond/x64/Debug/Config/BondEq.db
+++ b/SourceCode/Bond/x64/Debug/Config/BondEq.db
Binary files differ
--
Gitblit v1.9.3