chenluhua1980
2026-01-06 4d9d8d22e3666076988c30afb4e7c6fe365c19aa
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#pragma once
#include "CExpandableListCtrl.h"
#include "GlassLogDb.h"
#include <unordered_map>
 
// ====== 编译开关说明 ======
// USE_MOCK_SENSOR_DATA: 1=启用模拟传感器数据生成;0=使用真实数据
// 在 CPageGlassList.cpp 中定义
 
 
// CPageGlassList 对话框
 
class CPageGlassList : public CDialogEx
{
    DECLARE_DYNAMIC(CPageGlassList)
 
public:
    CPageGlassList(CWnd* pParent = nullptr);   // 标准构造函数
    virtual ~CPageGlassList();
 
private:
    COLORREF m_crBkgnd;
    HBRUSH m_hbrBkgnd;
    IObserver* m_pObserver;
 
    // 搜索关键字
    GlassLogDb::Filters m_filters;
    std::string m_strStatus;
 
    // 页码
    int m_nCurPage;
    int m_nTotalPages;
 
    // 日期
    char m_szTimeStart[64];
    char m_szTimeEnd[64];
 
    // 控件
    CDateTimeCtrl m_dateTimeStart;
    CDateTimeCtrl m_dateTimeEnd;
    CExpandableListCtrl m_listCtrl;
 
private:
    int  m_nColCount = 0;
    bool m_rebuilding = false;
 
private:
    void InitRxWindows();
    void Resize();
    void InitStatusCombo();
    void InitTimeRangeCombo();
    void InitDateTimeControls();
    void LoadData();
    void UpdatePageData();
    void UpdatePageControls();
    void InsertWipRow(SERVO::CGlass* pGlass);
    static bool GlassMatchesFilters(const SERVO::CGlass& g,
        const GlassLogDb::Filters& f,
        bool useEndTime = false);
    void UpdateWipData();
    bool eraseGlassInVector(SERVO::CGlass* pGlass, std::vector<SERVO::CGlass*>& glasses);
    void UpdateWipRow(unsigned int index, SERVO::CGlass* pGlass);
    bool WriteAnsiStringAsUtf8ToFile(const CString& ansiContent, const CString& filePath);
    void ExportToCsv(const GlassLogDb::Row& row, const CString& filePath);
    void ExportToJson(const GlassLogDb::Row& row, const CString& filePath);
    void ExportBasicInfo(CString& csvContent, const GlassLogDb::Row& row);
    void ExportProcessParams(CString& csvContent, const GlassLogDb::Row& row);
    void ExportSensorData(CString& csvContent, const GlassLogDb::Row& row);
    static std::vector<std::string> getMachineColumnOrder(int machineId, const std::unordered_map<std::string, std::vector<SERVO::SVDataItem>>* actualData = nullptr);
    static std::string timePointToString(const std::chrono::system_clock::time_point& tp);
    static int64_t timePointToMs(const std::chrono::system_clock::time_point& tp);
    void GenerateMockSVData(SERVO::CGlass& glass);
    double GenerateMockValue(int machineId, const std::string& dataType, int index);
 
// 对话框数据
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_PAGE_GLASS_LIST };
#endif
 
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
    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 OnCbnSelchangeComboDatetime();
    afx_msg void OnCbnSelchangeComboStatusFilter();
    afx_msg void OnBnClickedButtonSearch();
    afx_msg void OnBnClickedButtonExport();
    afx_msg void OnBnClickedButtonPrevPage();
    afx_msg void OnBnClickedButtonNextPage();
    afx_msg void OnShowFullText(NMHDR* pNMHDR, LRESULT* pResult);
    virtual BOOL PreTranslateMessage(MSG* pMsg);
    DECLARE_MESSAGE_MAP()
public:
    afx_msg void OnBnClickedButtonExportRow();
};