提交 | 用户 | age
|
4b03ae
|
1 |
// CDialogEventLog.cpp: 实现文件
|
Q |
2 |
//
|
|
3 |
|
|
4 |
#include "pch.h"
|
|
5 |
#include "MultiTerminal1.h"
|
|
6 |
#include "CDialogEventLog.h"
|
|
7 |
#include "afxdialogex.h"
|
|
8 |
#include "KLinkDefine.h"
|
|
9 |
#include "KLinkProtocol.h"
|
|
10 |
|
|
11 |
// CDialogEventLog 对话框
|
|
12 |
|
|
13 |
IMPLEMENT_DYNAMIC(CDialogEventLog, CDialogEx)
|
|
14 |
|
|
15 |
CDialogEventLog::CDialogEventLog(CWnd* pParent /*=nullptr*/)
|
|
16 |
: CDialogEx(IDD_DIALOG_EVENTLOG, pParent)
|
|
17 |
{
|
|
18 |
|
|
19 |
}
|
|
20 |
|
|
21 |
CDialogEventLog::~CDialogEventLog()
|
|
22 |
{
|
|
23 |
}
|
|
24 |
|
|
25 |
void CDialogEventLog::DoDataExchange(CDataExchange* pDX)
|
|
26 |
{
|
|
27 |
CDialogEx::DoDataExchange(pDX);
|
|
28 |
DDX_Control(pDX, IDC_LIST_EVENTLOG, m_list_eventlog);
|
|
29 |
}
|
|
30 |
|
|
31 |
|
|
32 |
BEGIN_MESSAGE_MAP(CDialogEventLog, CDialogEx)
|
|
33 |
ON_BN_CLICKED(IDC_BUTTON_CLEAR_EVENTLOG, &CDialogEventLog::OnBnClickedButtonClearEventlog)
|
|
34 |
ON_BN_CLICKED(IDC_BUTTON_RELOAD, &CDialogEventLog::OnBnClickedButtonReload)
|
|
35 |
END_MESSAGE_MAP()
|
|
36 |
|
|
37 |
KLinkProtocol::stEventLog KEventLogs[20000];
|
|
38 |
|
|
39 |
// CDialogEventLog 消息处理程序
|
|
40 |
void CDialogEventLog::OnBnClickedButtonReload()
|
|
41 |
{
|
|
42 |
// TODO: 在此添加控件通知处理程序代码
|
|
43 |
GetEventLogStatus();
|
|
44 |
UpLoadEventLog();
|
|
45 |
}
|
|
46 |
|
|
47 |
void CDialogEventLog::OnBnClickedButtonClearEventlog()
|
|
48 |
{
|
|
49 |
// TODO: 在此添加控件通知处理程序代码
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
int CDialogEventLog::GetEventLogStatus()
|
|
54 |
{
|
|
55 |
// TODO: 在此处添加实现代码.
|
|
56 |
int nCount;
|
|
57 |
int res = MyKLProtocol1.GetEventLogCount(1, &nCount);
|
|
58 |
CString s1;
|
|
59 |
|
|
60 |
s1.Format(_T("Get EventLogCount Result r=%d N=%d "), res, nCount);
|
|
61 |
SysLog(s1);
|
|
62 |
if (res == MyKLProtocol1.KL_OK)
|
|
63 |
{
|
|
64 |
s1.Format(_T("%d"), nCount);
|
|
65 |
GetDlgItem(IDC_EDIT_EVENT_COUNT)->SetWindowText(s1);
|
|
66 |
}
|
|
67 |
|
|
68 |
return 0;
|
|
69 |
}
|
|
70 |
|
|
71 |
int CDialogEventLog::UpLoadEventLog()
|
|
72 |
{
|
|
73 |
// TODO: 在此处添加实现代码.
|
|
74 |
int nCount;
|
|
75 |
int res = MyKLProtocol1.GetEventLogCount(1, &nCount);
|
|
76 |
CString s1;
|
|
77 |
|
|
78 |
s1.Format(_T("Get EventLogCount Result r=%d N=%d "), res, nCount);
|
|
79 |
SysLog(s1);
|
|
80 |
if (res == MyKLProtocol1.KL_OK)
|
|
81 |
{
|
|
82 |
s1.Format(_T("%d"), nCount);
|
|
83 |
GetDlgItem(IDC_EDIT_EVENT_COUNT)->SetWindowText(s1);
|
|
84 |
}
|
|
85 |
int nStartIndex = 0;
|
|
86 |
int nReadCount = 1;
|
|
87 |
m_list_eventlog.DeleteAllItems();
|
|
88 |
for (int i = 0; i < nCount; i++)
|
|
89 |
{
|
|
90 |
res = MyKLProtocol1.GetEventLog(1, i, nReadCount, &KEventLogs[i]);
|
|
91 |
s1.Format(_T(" Get EventLog %d Result r=%d "),i, res);
|
|
92 |
s1.AppendFormat(_T("%d %d %d %d %d %d"), KEventLogs[i].Sign1, KEventLogs[i].Seq1, KEventLogs[i].nTime, KEventLogs[i].nType, KEventLogs[i].nParam1, KEventLogs[i].nParam2);
|
3b04f9
|
93 |
// SysLog(s1);
|
4b03ae
|
94 |
s1.Format(_T("%d"), i);
|
Q |
95 |
m_list_eventlog.InsertItem(i, s1);
|
|
96 |
s1.Format(_T("%d"), KEventLogs[i].Seq1);
|
|
97 |
m_list_eventlog.SetItemText(i, 1, s1);
|
|
98 |
|
|
99 |
s1.Format(_T("%d"), KEventLogs[i].nTime);
|
3b04f9
|
100 |
CTime ctime1 = KEventLogs[i].nTime;
|
Q |
101 |
s1 = ctime1.Format(_T("%Y-%m-%d %H:%M:%S"));
|
|
102 |
|
4b03ae
|
103 |
m_list_eventlog.SetItemText(i, 2, s1);
|
Q |
104 |
s1.Format(_T("%d"), KEventLogs[i].nType);
|
|
105 |
m_list_eventlog.SetItemText(i, 3, s1);
|
|
106 |
s1.Format(_T("%d"), KEventLogs[i].nParam1);
|
|
107 |
m_list_eventlog.SetItemText(i, 4, s1);
|
|
108 |
s1.Format(_T("%d"), KEventLogs[i].nParam2);
|
|
109 |
m_list_eventlog.SetItemText(i, 5, s1);
|
|
110 |
}
|
|
111 |
|
|
112 |
return 0;
|
|
113 |
}
|
|
114 |
|
|
115 |
|
|
116 |
BOOL CDialogEventLog::OnInitDialog()
|
|
117 |
{
|
|
118 |
CDialogEx::OnInitDialog();
|
|
119 |
|
|
120 |
// TODO: 在此添加额外的初始化
|
|
121 |
m_list_eventlog.SetExtendedStyle(LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_ONECLICKACTIVATE | LVS_EX_LABELTIP);
|
|
122 |
m_list_eventlog.DeleteAllItems();
|
|
123 |
while (m_list_eventlog.DeleteColumn(0));
|
|
124 |
m_list_eventlog.InsertColumn(0, _T("NO"), LVCFMT_LEFT, 32, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
125 |
m_list_eventlog.InsertColumn(1, _T("序列号"), LVCFMT_LEFT, 48, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
126 |
m_list_eventlog.InsertColumn(2, _T("时间"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
127 |
m_list_eventlog.InsertColumn(3, _T("类型"), LVCFMT_LEFT, 64, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
128 |
m_list_eventlog.InsertColumn(4, _T("数据1"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
129 |
m_list_eventlog.InsertColumn(5, _T("数据2"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
130 |
|
|
131 |
GetEventLogStatus();
|
|
132 |
UpLoadEventLog();
|
|
133 |
return TRUE; // return TRUE unless you set the focus to a control
|
|
134 |
// 异常: OCX 属性页应返回 FALSE
|
|
135 |
}
|
|
136 |
|
|
137 |
|