chenluhua1980
2025-11-18 3cb4638bcb93a8fdf4cfea140025bbc299d35d47
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// DeviceRecipeParamDlg.cpp: 实现文件
//
 
#include "stdafx.h"
#include "Servo.h"
#include "afxdialogex.h"
#include "DeviceRecipeParamDlg.h"
 
 
// CDeviceRecipeParamDlg 对话框
 
IMPLEMENT_DYNAMIC(CDeviceRecipeParamDlg, CDialogEx)
 
CDeviceRecipeParamDlg::CDeviceRecipeParamDlg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_DIALOG_DEVICE_RECIPE_PARAM, pParent)
{
    m_pEquipment = nullptr;
    m_nDeviceRecipeID = 0;
    m_strDeviceRecipeName = _T("");
}
 
CDeviceRecipeParamDlg::~CDeviceRecipeParamDlg()
{
}
 
void CDeviceRecipeParamDlg::setEquipment(SERVO::CEquipment* pEquipment)
{
    m_pEquipment = pEquipment;
}
 
void CDeviceRecipeParamDlg::setDeviceRecipeID(int nDeviceRecipeID)
{
    m_nDeviceRecipeID = nDeviceRecipeID;
}
 
void CDeviceRecipeParamDlg::setDeviceRecipeName(const CString& strDeviceRecipeName)
{
    m_strDeviceRecipeName = strDeviceRecipeName;
}
 
void CDeviceRecipeParamDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_LIST_RECIPE_PARAM, m_wndRecipeParamList);
}
 
 
BEGIN_MESSAGE_MAP(CDeviceRecipeParamDlg, CDialogEx)
END_MESSAGE_MAP()
 
 
// CDeviceRecipeParamDlg 消息处理程序
 
BOOL CDeviceRecipeParamDlg::OnInitDialog()
{
    CDialogEx::OnInitDialog();
 
    // TODO:  在此添加额外的初始化
    CRect rc;
    m_wndRecipeParamList.GetClientRect(&rc);
    int nColWidth = rc.Width() / 2;
    m_wndRecipeParamList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
    m_wndRecipeParamList.InsertColumn(0, _T("参数名"), LVCFMT_LEFT, nColWidth);
    m_wndRecipeParamList.InsertColumn(1, _T("参数值"), LVCFMT_LEFT, nColWidth);
 
    if (nullptr == m_pEquipment) {
        return FALSE;
    }
 
    CString strTitle;
    if (!m_strDeviceRecipeName.IsEmpty()) {
        strTitle.Format(_T("%s - %s 配方参数"), m_pEquipment->getName().c_str(), m_strDeviceRecipeName);
    }
    else {
        strTitle.Format(_T("%s 配方参数"), m_pEquipment->getName().c_str());
    }
    SetWindowText(strTitle);
 
    SERVO::CRecipeList* pRecipeList = m_pEquipment->getRecipeList(0);
    ASSERT(pRecipeList);
    auto rawDatas = pRecipeList->getParamsRawData();
    for (auto item : rawDatas) {
        if (m_nDeviceRecipeID != 0 && item.first != m_nDeviceRecipeID) {
            continue;
        }
 
        std::vector<CParam> params;
        m_pEquipment->parsingParams((const char*)item.second.data(), item.second.size(), params);
        for (auto p : params) {
            CString strName(p.getName().c_str());
            CString strValue;
 
            switch (p.getValueType()) {
            case PVT_INT:
                strValue.Format(_T("%d"), p.getIntValue());
                break;
            case PVT_DOUBLE:
                strValue.Format(_T("%.6f"), p.getDoubleValue());
                break;
            default:
                strValue = _T("未知类型");
                break;
            }
 
            int nCount = m_wndRecipeParamList.GetItemCount();
            int nIndex = m_wndRecipeParamList.InsertItem(nCount, strName);
            m_wndRecipeParamList.SetItemText(nIndex, 1, strValue);
        }
    }
 
    return TRUE;  // return TRUE unless you set the focus to a control
    // 异常: OCX 属性页应返回 FALSE
}