提交 | 用户 | age
|
0ed438
|
1 |
// CDialogStatusShow.cpp: 实现文件
|
Q |
2 |
//
|
|
3 |
|
|
4 |
#include "pch.h"
|
|
5 |
#include "MTerm2.h"
|
65f713
|
6 |
#include "DialogStatusShow.h"
|
0ed438
|
7 |
#include "afxdialogex.h"
|
65f713
|
8 |
//#include "KLink.h"
|
0ed438
|
9 |
#include "MTerm2Doc.h"
|
Q |
10 |
// CDialogStatusShow 对话框
|
|
11 |
|
|
12 |
IMPLEMENT_DYNAMIC(CDialogStatusShow, CDialogEx)
|
|
13 |
|
|
14 |
CDialogStatusShow::CDialogStatusShow(CWnd* pParent /*=nullptr*/)
|
|
15 |
: CDialogEx(IDD_DIALOG_STATUS_SHOW, pParent)
|
|
16 |
{
|
|
17 |
|
|
18 |
}
|
|
19 |
|
|
20 |
CDialogStatusShow::~CDialogStatusShow()
|
|
21 |
{
|
|
22 |
}
|
|
23 |
|
|
24 |
void CDialogStatusShow::DoDataExchange(CDataExchange* pDX)
|
|
25 |
{
|
|
26 |
CDialogEx::DoDataExchange(pDX);
|
|
27 |
DDX_Control(pDX, IDC_LIST_STATUS1, m_liststatus1);
|
|
28 |
}
|
|
29 |
|
|
30 |
|
|
31 |
BEGIN_MESSAGE_MAP(CDialogStatusShow, CDialogEx)
|
|
32 |
ON_WM_CLOSE()
|
|
33 |
ON_WM_TIMER()
|
|
34 |
END_MESSAGE_MAP()
|
|
35 |
|
|
36 |
|
|
37 |
// CDialogStatusShow 消息处理程序
|
|
38 |
|
|
39 |
|
|
40 |
BOOL CDialogStatusShow::OnInitDialog()
|
|
41 |
{
|
|
42 |
CDialogEx::OnInitDialog();
|
|
43 |
|
|
44 |
// TODO: 在此添加额外的初始化
|
|
45 |
ShowParams();
|
|
46 |
// m_liststatus1.SetExtendedStyle();
|
326d3e
|
47 |
SetTimer(1, 100, NULL);
|
0ed438
|
48 |
|
Q |
49 |
return TRUE; // return TRUE unless you set the focus to a control
|
|
50 |
// 异常: OCX 属性页应返回 FALSE
|
|
51 |
}
|
|
52 |
|
|
53 |
int CDialogStatusShow::ShowParams()
|
|
54 |
{
|
|
55 |
// TODO: 在此处添加实现代码.
|
|
56 |
m_liststatus1.SetExtendedStyle(LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_ONECLICKACTIVATE | LVS_EX_LABELTIP);
|
|
57 |
m_liststatus1.DeleteAllItems();
|
|
58 |
while (m_liststatus1.DeleteColumn(0));
|
|
59 |
m_liststatus1.InsertColumn(0, _T("NO"), LVCFMT_LEFT, 96, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
60 |
m_liststatus1.InsertColumn(1, _T("子机1"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
61 |
m_liststatus1.InsertColumn(2, _T("子机2"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
62 |
m_liststatus1.InsertColumn(3, _T("子机3"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
|
|
63 |
|
|
64 |
m_liststatus1.InsertItem(0, _T("状态"));
|
|
65 |
m_liststatus1.InsertItem(1, _T("发送包计数"));
|
|
66 |
m_liststatus1.InsertItem(2, _T("接收包计数"));
|
|
67 |
m_liststatus1.InsertItem(3, _T("发送时间(uS)"));
|
|
68 |
m_liststatus1.InsertItem(4, _T("丢包计数"));
|
|
69 |
m_liststatus1.InsertItem(5, _T("连续丢包"));
|
|
70 |
m_liststatus1.InsertItem(6, _T("最大连续"));
|
|
71 |
m_liststatus1.InsertItem(7, _T("非包计数"));
|
|
72 |
// m_liststatus1.InsertItem(8, _T("无结尾包"));
|
|
73 |
m_liststatus1.InsertItem(8, _T("包长错误"));
|
|
74 |
m_liststatus1.InsertItem(9, _T("校验错误"));
|
|
75 |
m_liststatus1.InsertItem(10, _T("超时错误"));
|
|
76 |
m_liststatus1.InsertItem(11, _T("返回延迟(uS)"));
|
|
77 |
m_liststatus1.InsertItem(12, _T("最大延迟(uS)"));
|
|
78 |
m_liststatus1.InsertItem(13, _T("循环时间(uS)"));
|
|
79 |
m_liststatus1.InsertItem(14, _T("子机接收"));
|
|
80 |
m_liststatus1.InsertItem(15, _T("子机发送"));
|
|
81 |
m_liststatus1.InsertItem(16, _T("子机非包"));
|
|
82 |
m_liststatus1.InsertItem(17, _T("子机非ID"));
|
|
83 |
// m_liststatus1.InsertItem(18, _T("子机无尾"));
|
|
84 |
m_liststatus1.InsertItem(18, _T("子机包长"));
|
|
85 |
m_liststatus1.InsertItem(19, _T("子机校验"));
|
|
86 |
m_liststatus1.InsertItem(20, _T("子机超时"));
|
|
87 |
|
|
88 |
|
|
89 |
return 0;
|
|
90 |
}
|
|
91 |
|
|
92 |
|
|
93 |
int CDialogStatusShow::GetParams()
|
|
94 |
{
|
|
95 |
// TODO: 在此处添加实现代码.
|
|
96 |
return 0;
|
|
97 |
}
|
|
98 |
|
|
99 |
int CDialogStatusShow::DoMonitor()
|
|
100 |
{
|
|
101 |
// TODO: 在此处添加实现代码.
|
|
102 |
return 0;
|
|
103 |
}
|
|
104 |
|
|
105 |
int CDialogStatusShow::UpdateDisplay()
|
|
106 |
{
|
|
107 |
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
|
108 |
CMDIChildWnd *pChild = (CMDIChildWnd *)pFrame->GetActiveFrame();
|
|
109 |
CView *pV = (CView*)pChild->GetActiveView();
|
|
110 |
CMTerm2Doc* pDoc = (CMTerm2Doc *)(pV->GetDocument());
|
|
111 |
|
|
112 |
// TODO: 在此处添加实现代码.
|
|
113 |
CString s1, s2;
|
|
114 |
int nOffset = 0;
|
|
115 |
KLink::pChnStat pchnstat1;
|
|
116 |
unsigned int nSendPackets;
|
|
117 |
int nChilds = 3;
|
|
118 |
//子机1
|
|
119 |
//子机2
|
|
120 |
for (int i = 0; i < 3; i++)
|
|
121 |
{
|
|
122 |
nOffset = 32 + 24 * i;
|
|
123 |
pchnstat1 = (KLink::pChnStat)&(pDoc->MyKLink1.MEM.SDD[nOffset + 0]);
|
|
124 |
nSendPackets = pchnstat1->SendPackets;
|
|
125 |
if (nSendPackets == 0) nSendPackets = 1;
|
|
126 |
s1.Format(_T("%08X"), pchnstat1->Stat);
|
|
127 |
m_liststatus1.SetItemText(0, 1 + i, s1);
|
|
128 |
|
|
129 |
s1.Format(_T("%u"), pchnstat1->SendPackets);
|
|
130 |
m_liststatus1.SetItemText(1, 1 + i, s1);
|
|
131 |
s1.Format(_T("%u (%.3f%%)"), pchnstat1->RecvPackets, pchnstat1->RecvPackets *100.0 / nSendPackets);
|
|
132 |
m_liststatus1.SetItemText(2, 1 + i, s1);
|
|
133 |
s1.Format(_T("%u"), pchnstat1->LastSentTimeuS);
|
|
134 |
m_liststatus1.SetItemText(3, 1 + i, s1);
|
|
135 |
s1.Format(_T("%u (%.3f%%)"), pchnstat1->LostPackets, pchnstat1->LostPackets *100.0 / nSendPackets);
|
|
136 |
m_liststatus1.SetItemText(4, 1 + i, s1);
|
|
137 |
|
|
138 |
s1.Format(_T("%u"), pchnstat1->CtnLstPkts);
|
|
139 |
m_liststatus1.SetItemText(5, 1 + i, s1);
|
|
140 |
s1.Format(_T("%u"), pchnstat1->MaxCtnLstPkts);
|
|
141 |
m_liststatus1.SetItemText(6, 1 + i, s1);
|
|
142 |
s1.Format(_T("%u (%.3f%%)"), pchnstat1->NotPkgErr, pchnstat1->NotPkgErr * 100.0 / nSendPackets);
|
|
143 |
m_liststatus1.SetItemText(7, 1 + i, s1);
|
|
144 |
//s1.Format(_T("%u (%.2f%%)"), pchnstat1->NoEndErr, pchnstat1->NoEndErr * 100.0 / nSendPackets);
|
|
145 |
//m_liststatus1.SetItemText(8, 1 + i, s1);
|
|
146 |
|
|
147 |
s1.Format(_T("%u (%.3f%%)"), pchnstat1->PkgLenErr, pchnstat1->PkgLenErr * 100.0 / nSendPackets);
|
|
148 |
m_liststatus1.SetItemText(8, 1 + i, s1);
|
|
149 |
s1.Format(_T("%u (%.3f%%)"), pchnstat1->BCCErr, pchnstat1->BCCErr * 100.0 / nSendPackets);
|
|
150 |
m_liststatus1.SetItemText(9, 1 + i, s1);
|
|
151 |
s1.Format(_T("%u (%.3f%%)"), pchnstat1->TimeOutErr, pchnstat1->TimeOutErr * 100.0 / nSendPackets);
|
|
152 |
m_liststatus1.SetItemText(10, 1 + i, s1);
|
|
153 |
s1.Format(_T("%u"), pchnstat1->Delay);
|
|
154 |
m_liststatus1.SetItemText(11, 1 + i, s1);
|
|
155 |
s1.Format(_T("%u"), pchnstat1->MaxDelay);
|
|
156 |
m_liststatus1.SetItemText(12, 1 + i, s1);
|
|
157 |
s1.Format(_T("%u"), pchnstat1->SendTimeInterval);
|
|
158 |
m_liststatus1.SetItemText(13, 1 + i, s1);
|
|
159 |
|
|
160 |
|
|
161 |
s1.Format(_T("%u"), pchnstat1->ClientRecvPkts);
|
|
162 |
m_liststatus1.SetItemText(14, 1 + i, s1);
|
|
163 |
s1.Format(_T("%u"), pchnstat1->ClientSendPkts);
|
|
164 |
m_liststatus1.SetItemText(15, 1 + i, s1);
|
|
165 |
s1.Format(_T("%u"), pchnstat1->ClientNotPktErr);
|
|
166 |
m_liststatus1.SetItemText(16, 1 + i, s1);
|
|
167 |
s1.Format(_T("%u"), pchnstat1->ClientMisIdPkts);
|
|
168 |
m_liststatus1.SetItemText(17, 1 + i, s1);
|
|
169 |
// s1.Format(_T("%u"), pchnstat1->ClientNoEndErr);
|
|
170 |
// m_liststatus1.SetItemText(18, 1 + i, s1);
|
|
171 |
s1.Format(_T("%u"), pchnstat1->ClientPkgLenErr);
|
|
172 |
m_liststatus1.SetItemText(18, 1 + i, s1);
|
|
173 |
s1.Format(_T("%u"), pchnstat1->ClientBccErr);
|
|
174 |
m_liststatus1.SetItemText(19, 1 + i, s1);
|
|
175 |
s1.Format(_T("%u"), pchnstat1->ClientTimeOutErr);
|
|
176 |
m_liststatus1.SetItemText(20, 1 + i, s1);
|
|
177 |
|
|
178 |
}
|
|
179 |
|
|
180 |
return 0;
|
|
181 |
}
|
|
182 |
|
|
183 |
void CDialogStatusShow::OnTimer(UINT_PTR nIDEvent)
|
|
184 |
{
|
|
185 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
186 |
if (nIDEvent ==0)
|
|
187 |
{ }
|
|
188 |
else if (nIDEvent == 1)
|
|
189 |
{
|
|
190 |
DoMonitor();
|
|
191 |
UpdateDisplay();
|
|
192 |
}else {}
|
|
193 |
CDialogEx::OnTimer(nIDEvent);
|
|
194 |
}
|
|
195 |
|
|
196 |
void CDialogStatusShow::OnClose()
|
|
197 |
{
|
|
198 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
199 |
KillTimer(1);
|
|
200 |
GetParams();
|
|
201 |
|
|
202 |
CDialogEx::OnClose();
|
|
203 |
}
|
|
204 |
|
|
205 |
|