LAPTOP-SNT8I5JK\Boounion
2025-08-27 38f2ff1e5bc6c4434875e03b8cadc8f3f4e39bf6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#pragma once
#include "afxdialogex.h"
#include "BlButton.h"
 
// BUTTON控件
#define BTN_MAX            7
#define BTN_RUN            0
#define BTN_AUTO        1
#define BTN_PUASE        2
#define BTN_MANUAL        3
#define BTN_MUTE        4
#define BTN_OPR            5
#define BTN_STOP        6
 
// 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 SetButtonBackgroundColors(CBlButton* btn, bool bOff);
    void HandleOperation(OperationType eOpType);
    void WriteOperationDataToPLC(OperationType eOpType, bool bPressed);
 
private:
    COLORREF m_crBkgnd;
    HBRUSH m_hbrBkgnd;
    IObserver* m_pObserver;
    CPLC* m_pPLC;
 
private:
    // 控件
    CBlButton* m_pBlBtns[BTN_MAX];
 
// 对话框数据
#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);
};