// CDialogStatusShow.cpp: 实现文件 // #include "pch.h" #include "MultiTerminal1.h" #include "CDialogStatusShow.h" #include "afxdialogex.h" #include "KLinkProtocol.h" // CDialogStatusShow 对话框 IMPLEMENT_DYNAMIC(CDialogStatusShow, CDialogEx) CDialogStatusShow::CDialogStatusShow(CWnd* pParent /*=nullptr*/) : CDialogEx(IDD_DIALOG_STATUS_SHOW, pParent) { } CDialogStatusShow::~CDialogStatusShow() { } void CDialogStatusShow::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST_STATUS1, m_liststatus1); } BEGIN_MESSAGE_MAP(CDialogStatusShow, CDialogEx) ON_WM_CLOSE() ON_WM_TIMER() END_MESSAGE_MAP() // CDialogStatusShow 消息处理程序 BOOL CDialogStatusShow::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 ShowParams(); // m_liststatus1.SetExtendedStyle(); SetTimer(1, 200, NULL); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } int CDialogStatusShow::ShowParams() { // TODO: 在此处添加实现代码. m_liststatus1.SetExtendedStyle(LVS_EX_DOUBLEBUFFER | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_ONECLICKACTIVATE | LVS_EX_LABELTIP); m_liststatus1.DeleteAllItems(); while (m_liststatus1.DeleteColumn(0)); m_liststatus1.InsertColumn(0, _T("NO"), LVCFMT_LEFT, 96, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER m_liststatus1.InsertColumn(1, _T("子机1"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER m_liststatus1.InsertColumn(2, _T("子机2"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER m_liststatus1.InsertColumn(3, _T("子机3"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER m_liststatus1.InsertItem(0, _T("状态")); m_liststatus1.InsertItem(1, _T("发送包计数")); m_liststatus1.InsertItem(2, _T("接收包计数")); m_liststatus1.InsertItem(3, _T("发送时间(uS)")); m_liststatus1.InsertItem(4, _T("丢包计数")); m_liststatus1.InsertItem(5, _T("连续丢包")); m_liststatus1.InsertItem(6, _T("最大连续")); m_liststatus1.InsertItem(7, _T("非包计数")); // m_liststatus1.InsertItem(8, _T("无结尾包")); m_liststatus1.InsertItem(8, _T("包长错误")); m_liststatus1.InsertItem(9, _T("校验错误")); m_liststatus1.InsertItem(10, _T("超时错误")); m_liststatus1.InsertItem(11, _T("返回延迟(uS)")); m_liststatus1.InsertItem(12, _T("最大延迟(uS)")); m_liststatus1.InsertItem(13, _T("循环时间(uS)")); m_liststatus1.InsertItem(14, _T("子机接收")); m_liststatus1.InsertItem(15, _T("子机发送")); m_liststatus1.InsertItem(16, _T("子机非包")); m_liststatus1.InsertItem(17, _T("子机非ID")); // m_liststatus1.InsertItem(18, _T("子机无尾")); m_liststatus1.InsertItem(18, _T("子机包长")); m_liststatus1.InsertItem(19, _T("子机校验")); m_liststatus1.InsertItem(20, _T("子机超时")); return 0; } int CDialogStatusShow::GetParams() { // TODO: 在此处添加实现代码. return 0; } int CDialogStatusShow::DoMonitor() { // TODO: 在此处添加实现代码. return 0; } int CDialogStatusShow::UpdateDisplay() { // TODO: 在此处添加实现代码. CString s1, s2; int nOffset = 0; KLinkProtocol::pChnStat pchnstat1; unsigned int nSendPackets; int nChilds = 3; //子机1 //子机2 for (int i = 0; i < 3; i++) { nOffset = 32 + 24 * i; pchnstat1 = (KLinkProtocol::pChnStat)&MyKLProtocol1.MEM.SDD[nOffset + 0]; nSendPackets = pchnstat1->SendPackets; if (nSendPackets == 0) nSendPackets = 1; s1.Format(_T("%08X"), pchnstat1->Stat); m_liststatus1.SetItemText(0, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->SendPackets); m_liststatus1.SetItemText(1, 1 + i, s1); s1.Format(_T("%u (%.3f%%)"), pchnstat1->RecvPackets, pchnstat1->RecvPackets *100.0 / nSendPackets); m_liststatus1.SetItemText(2, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->LastSentTimeuS); m_liststatus1.SetItemText(3, 1 + i, s1); s1.Format(_T("%u (%.3f%%)"), pchnstat1->LostPackets, pchnstat1->LostPackets *100.0 / nSendPackets); m_liststatus1.SetItemText(4, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->CtnLstPkts); m_liststatus1.SetItemText(5, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->MaxCtnLstPkts); m_liststatus1.SetItemText(6, 1 + i, s1); s1.Format(_T("%u (%.3f%%)"), pchnstat1->NotPkgErr, pchnstat1->NotPkgErr * 100.0 / nSendPackets); m_liststatus1.SetItemText(7, 1 + i, s1); //s1.Format(_T("%u (%.2f%%)"), pchnstat1->NoEndErr, pchnstat1->NoEndErr * 100.0 / nSendPackets); //m_liststatus1.SetItemText(8, 1 + i, s1); s1.Format(_T("%u (%.3f%%)"), pchnstat1->PkgLenErr, pchnstat1->PkgLenErr * 100.0 / nSendPackets); m_liststatus1.SetItemText(8, 1 + i, s1); s1.Format(_T("%u (%.3f%%)"), pchnstat1->BCCErr, pchnstat1->BCCErr * 100.0 / nSendPackets); m_liststatus1.SetItemText(9, 1 + i, s1); s1.Format(_T("%u (%.3f%%)"), pchnstat1->TimeOutErr, pchnstat1->TimeOutErr * 100.0 / nSendPackets); m_liststatus1.SetItemText(10, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->Delay); m_liststatus1.SetItemText(11, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->MaxDelay); m_liststatus1.SetItemText(12, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->SendTimeInterval); m_liststatus1.SetItemText(13, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->ClientRecvPkts); m_liststatus1.SetItemText(14, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->ClientSendPkts); m_liststatus1.SetItemText(15, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->ClientNotPktErr); m_liststatus1.SetItemText(16, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->ClientMisIdPkts); m_liststatus1.SetItemText(17, 1 + i, s1); // s1.Format(_T("%u"), pchnstat1->ClientNoEndErr); // m_liststatus1.SetItemText(18, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->ClientPkgLenErr); m_liststatus1.SetItemText(18, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->ClientBccErr); m_liststatus1.SetItemText(19, 1 + i, s1); s1.Format(_T("%u"), pchnstat1->ClientTimeOutErr); m_liststatus1.SetItemText(20, 1 + i, s1); } return 0; } void CDialogStatusShow::OnTimer(UINT_PTR nIDEvent) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (nIDEvent ==0) { } else if (nIDEvent == 1) { DoMonitor(); UpdateDisplay(); }else {} CDialogEx::OnTimer(nIDEvent); } void CDialogStatusShow::OnClose() { // TODO: 在此添加消息处理程序代码和/或调用默认值 KillTimer(1); GetParams(); CDialogEx::OnClose(); }