LAPTOP-SNT8I5JK\Boounion
2025-07-28 bfe14e41fa5b07771d78af4511ba18d706bc23cc
SourceCode/Bond/BondEq/View/IOMonitoringDlg.h
@@ -2,6 +2,7 @@
#include "afxdialogex.h"
#include "IOManager.h"
#include "BLLabel.h"
#include "CPLC.h"
// CIOMonitoringDlg 对话框
@@ -14,6 +15,7 @@
   CIOMonitoringDlg(CWnd* pParent = nullptr);   // 标准构造函数
   virtual ~CIOMonitoringDlg();
   void SetIOManager(const std::string& machineName); // 设置 IOManager 和机器名
   void SetPLC(CPLC* pPLC); // 设置 PLC
// 对话框数据
#ifdef AFX_DESIGN_TIME
@@ -26,14 +28,21 @@
   void AdjustControls(float dScaleX, float dScaleY);            // 调整控件大小
   void AdjustControlFont(CWnd* pWnd, int nWidth, int nHeight);   // 调整控件字体大小
   void UpdatePageInfo();         // 更新分页信息
   void CreateDynamicControls();   // 动态创建控件
   void CreateStaticControl(int x, int y, int width, int height, const CString& text, bool hasBorder = false, TextAlign alignment = AlignLeft, std::function<void()> clickCallback = nullptr); // 创建静态控件
   void DisplayCurrentPage();      // 显示当前页数据
   void ClearDynamicControls();   // 清除动态创建的控件
   void UpdatePLCStates();         // 定时器更新状态的方法
   void UpdatePageInfo();          // 更新分页信息
   void CreateDynamicControls();    // 动态创建控件
   CWnd* CreateStaticControl(UINT id, int x, int y, int width, int height, const CString& text, bool hasBorder = false, TextAlign alignment = AlignLeft, std::function<void()> clickCallback = nullptr); // 创建静态控件
   CWnd* GetStaticControl(UINT id); // 获取静态控件
   CString& GetStaticControlAddrText(UINT id, CString& strAddr); // 获取静态控件地址文本
   void DisplayCurrentPage();       // 显示当前页数据
   void ClearDynamicControls();    // 清除动态创建的控件
   bool ParsePLCAddress(const CString& address, MC::SOFT_COMPONENT& component, int& addr); // 解析 PLC 地址
   bool GeneratePLCAddress(MC::SOFT_COMPONENT component, int addr, CString& address, bool bHexFormat = false); // 生成 PLC 地址
   void ReadPLCData(MC::SOFT_COMPONENT softComponent, int startAddr, int endAddr, std::function<void(IMcChannel*, int, char*, unsigned int, int)> callback); // 读取 PLC 数据
   void ReadPLCStates();          // 定时器读PLC
   void UpdatePLCStatesToUI();       // 定时器更新状态的方法
private:
   CPLC* m_pPLC;
   int m_nInitialWidth;
   int m_nInitialHeight;
   int m_nCurrentPage; // 当前页
@@ -44,6 +53,8 @@
   std::map<int, CFont*> m_mapFonts;      // 字体映射
   std::map<int, CRect> m_mapCtrlLayouts;   // 控件布局映射
   std::vector<IOData> m_displayData;      // 当前显示的数据
   std::vector<BOOL> m_inputStates;        // 输入状态
   std::vector<BOOL> m_outputStates;       // 输出状态
   std::vector<CString> m_inputPLCAddresses;  // 存储 1 列 PLC 地址
   std::vector<CString> m_outputPLCAddresses; // 存储 4 列 PLC 地址
@@ -60,6 +71,7 @@
   afx_msg void OnSize(UINT nType, int cx, int cy);
   afx_msg void OnBnClickedButtonPrevPage();
   afx_msg void OnBnClickedButtonNextPage();
   afx_msg LRESULT OnIoClicked(WPARAM wParam, LPARAM lParam);
   afx_msg void OnTimer(UINT_PTR nIDEvent);
   afx_msg void OnClose();
};