| | |
| | | // ON_WM_MOUSEWHEEL()
|
| | | // ON_BN_CLICKED(IDC_BUTTON_CLEAR_STAT, &CMTerm1CommDevView::OnBnClickedButtonClearStat)
|
| | | // ON_BN_CLICKED(IDC_BUTTON_READ, &CMTerm1CommDevView::OnBnClickedButtonRead)
|
| | | // ON_BN_CLICKED(IDC_BUTTON11, &CMTerm1CommDevView::OnBnClickedButton11)
|
| | | ON_BN_CLICKED(IDC_BUTTON11, &CMTerm1CommDevView::OnBnClickedButton11)
|
| | | ON_BN_CLICKED(IDC_BUTTON12, &CMTerm1CommDevView::OnBnClickedButton12)
|
| | | ON_BN_CLICKED(IDC_BUTTON13, &CMTerm1CommDevView::OnBnClickedButton13)
|
| | | ON_BN_CLICKED(IDC_BUTTON31, &CMTerm1CommDevView::OnBnClickedButton31)
|
| | | ON_BN_CLICKED(IDC_BUTTON2, &CMTerm1CommDevView::OnBnClickedButton2)
|
| | | ON_BN_CLICKED(IDC_BUTTON3, &CMTerm1CommDevView::OnBnClickedButton3)
|
| | | ON_BN_CLICKED(IDC_BUTTON5, &CMTerm1CommDevView::OnBnClickedButton5)
|
| | | ON_BN_CLICKED(IDC_BUTTON9, &CMTerm1CommDevView::OnBnClickedButton9)
|
| | | END_MESSAGE_MAP()
|
| | |
|
| | |
|
| | | // CMTerm1CommDevView 诊断
|
| | |
|
| | | /*
|
| | | #ifdef _DEBUG
|
| | | void CMTerm1CommDevView::AssertValid() const
|
| | | {
|
| | |
| | | }
|
| | | #endif
|
| | | #endif //_DEBUG
|
| | | */
|
| | | BOOL CMTerm1CommDevView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
|
| | | {
|
| | | // TODO: 在此添加专用代码和/或调用基类
|
| | |
|
| | | return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
|
| | | }
|
| | |
|
| | | // CMTerm1CommDevView 消息处理程序
|
| | |
|
| | |
| | | int CMTerm1CommDevView::Clear_COM_Stats()
|
| | | {
|
| | | // TODO: 在此处添加实现代码.
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | pDoc->MyKLink1.MySerPort1.TotalSendBytes = 0;
|
| | | pDoc->MyKLink1.MySerPort1.TotalRecvBytes = 0;
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | theApp.MyKLink1.MySerPort1.TotalSendBytes = 0;
|
| | | theApp.MyKLink1.MySerPort1.TotalRecvBytes = 0;
|
| | |
|
| | | MonitorTotalCount = 0;
|
| | | MonitorSuccessCount = 0;
|
| | |
| | |
|
| | | int CMTerm1CommDevView::UpdateDataDisplay()
|
| | | {
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | if (!m_bOnline) return 0;
|
| | | static int stepCount = 0;
|
| | | CString s1, s2;
|
| | | pDoc->MyKLink1.MySerPort1.CalSpeed();
|
| | | s1.Format(_T("Send %8d %5d Bps \r\nRecv %8d %5d Bps\r\n"), pDoc->MyKLink1.MySerPort1.TotalSendBytes, pDoc->MyKLink1.MySerPort1.SendSpeed, pDoc->MyKLink1.MySerPort1.TotalRecvBytes, pDoc->MyKLink1.MySerPort1.RecvSpeed);
|
| | | theApp.MyKLink1.MySerPort1.CalSpeed();
|
| | | s1.Format(_T("Send %8d %5d Bps \r\nRecv %8d %5d Bps\r\n"), theApp.MyKLink1.MySerPort1.TotalSendBytes, theApp.MyKLink1.MySerPort1.SendSpeed, theApp.MyKLink1.MySerPort1.TotalRecvBytes, theApp.MyKLink1.MySerPort1.RecvSpeed);
|
| | |
|
| | | // s1.AppendFormat(_T("Total S %8d \r\nTotal R %8d \r\n"), MySerialCom1.TotalSendBytes, MySerialCom1.TotalRecvBytes);
|
| | | s1 += intToString(pDoc->MyKLink1.MySerPort1.TotalRecvBytes) + _T("\r\n");
|
| | | s1 += intToString(theApp.MyKLink1.MySerPort1.TotalRecvBytes) + _T("\r\n");
|
| | | // stepCount++;
|
| | |
|
| | | // static double LastCalTime = 0;
|
| | | // double thisTime = GetTimemS();
|
| | | pDoc->MyKLink1.CalSpeed();
|
| | | theApp.MyKLink1.CalSpeed();
|
| | | /*
|
| | | if (thisTime - LastCalTime > 500)
|
| | | {
|
| | |
| | | }
|
| | | */
|
| | | s1.AppendFormat(_T("MT %6d Seq %d/%d %d/S \r\nOK %6d NG %d "),
|
| | | pDoc->MyKLink1.m_nTotalSendCount, pDoc->MyKLink1.m_nSeq, pDoc->MyKLink1.m_nRSeq, pDoc->MyKLink1.m_SendSpeed,
|
| | | pDoc->MyKLink1.m_nTotalRecvCount, pDoc->MyKLink1.m_nTotalSendCount-pDoc->MyKLink1.m_nTotalRecvCount);
|
| | | theApp.MyKLink1.m_nTotalSendCount, theApp.MyKLink1.m_nSeq, theApp.MyKLink1.m_nRSeq, theApp.MyKLink1.m_SendSpeed,
|
| | | theApp.MyKLink1.m_nTotalRecvCount, theApp.MyKLink1.m_nTotalSendCount-theApp.MyKLink1.m_nTotalRecvCount);
|
| | | SetDlgItemText(IDC_STATIC_SPEED, s1);
|
| | |
|
| | |
|
| | | if (!m_bMonitoring) return 0;
|
| | | int nCount = 32;
|
| | | s2.Empty();// s2.AppendFormat(_T("%d "), MonitorSuccessCount);
|
| | | nCount = 16;
|
| | | s2.Append(_T("WX "));
|
| | | s2.Append(_T("WX "));
|
| | | for (int i = 0; i < (nCount + 15) / 16; i++)
|
| | | {
|
| | | //s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 8; j++)
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%04X"), pDoc->MyKLink1.MEM.WX[i * 8 + j]);
|
| | | s2.AppendFormat(_T("%02X"), theApp.MyKLink1.MEM.WXB[i * 16 + j]);
|
| | | if (j == 7) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | | nCount = 16;
|
| | | s2.Append(_T("WY "));
|
| | | for (int i = 0; i < (nCount + 15) / 16; i++)
|
| | | {
|
| | | // s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%02X"), theApp.MyKLink1.MEM.WYB[i * 16 + j]);
|
| | | if (j == 7) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | | nCount = 16;
|
| | | s2.Append(_T("WLX "));
|
| | | for (int i = 0; i < (nCount + 15) / 16; i++)
|
| | | {
|
| | | //s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%02X"), theApp.MyKLink1.MEM.WLXB[i * 16 + j]);
|
| | | if (j == 7) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | | nCount = 16;
|
| | | s2.Append(_T("WLY "));
|
| | | for (int i = 0; i < (nCount + 15) / 16; i++)
|
| | | {
|
| | | // s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%02X"), theApp.MyKLink1.MEM.WLYB[i * 16 + j]);
|
| | | if (j == 7) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | | /*
|
| | | nCount = 16;
|
| | | s2.Append(_T("WFX "));
|
| | | for (int i = 0; i < (nCount + 15) / 16; i++)
|
| | | {
|
| | | //s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%04X"), theApp.MyKLink1.MEM.WFXB[i * 16 + j]);
|
| | | if (j == 3) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | | nCount = 16;
|
| | | s2.Append(_T("WY "));
|
| | | s2.Append(_T("WFY "));
|
| | | for (int i = 0; i < (nCount + 15) / 16; i++)
|
| | | {
|
| | | // s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 8; j++)
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%04X"), pDoc->MyKLink1.MEM.WY[i * 8 + j]);
|
| | | s2.AppendFormat(_T("%04X"), theApp.MyKLink1.MEM.WFYB[i * 16 + j]);
|
| | | if (j == 3) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | | */
|
| | | nCount = 32;
|
| | | s2.Append(_T(" WR\r\n"));
|
| | | for (int i = 0; i < (nCount + 15) / 16; i++)
|
| | |
| | | s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 8; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%04X"), pDoc->MyKLink1.MEM.WR[i * 8 + j]);
|
| | | s2.AppendFormat(_T("%04X"), theApp.MyKLink1.MEM.WR[i * 8 + j]);
|
| | | if (j == 3) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | |
| | | s2.AppendFormat(_T("%02X: "), i * 16);
|
| | | for (int j = 0; j < 8; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%04X"), pDoc->MyKLink1.MEM.DT[i * 8 + j]);
|
| | | s2.AppendFormat(_T("%04X"), theApp.MyKLink1.MEM.DT[i * 8 + j]);
|
| | | if (j == 3) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | |
| | | s2.AppendFormat(_T("%3X: "), i * 16);
|
| | | for (int j = 0; j < 8; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%04X"), pDoc->MyKLink1.MEM.SDT[i * 8 + j]);
|
| | | s2.AppendFormat(_T("%04X"), theApp.MyKLink1.MEM.SDT[i * 8 + j]);
|
| | | if (j == 3) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | |
| | | s2.AppendFormat(_T("%3X: "), i * 16);
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%02X"), pDoc->MyKLink1.MEM.WDB[i * 16 + j]);
|
| | | s2.AppendFormat(_T("%02X"), theApp.MyKLink1.MEM.WDB[i * 16 + j]);
|
| | | if (j == 7) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | |
| | | SetDlgItemText(IDC_EDIT_MON3, s2);
|
| | | }
|
| | |
|
| | | // s2.AppendFormat(_T("%d\r\n"), pDoc->MyKLink1.MEM.SDD[5]);
|
| | | // s2.AppendFormat(_T("%d\r\n"), theApp.MyKLink1.MEM.SDD[5]);
|
| | |
|
| | | nCount = 32;
|
| | | //SetRedraw(FALSE);
|
| | |
| | | s1.Empty();
|
| | | s1.Format(_T("主机\r\n"));
|
| | |
|
| | | s1.AppendFormat(_T("00 跳线 %02X %s 当前 %02X\r\n"), pDoc->MyKLink1.MEM.SDD[0], intToBinString(pDoc->MyKLink1.MEM.SDD[0]), pDoc->MyKLink1.MEM.SDD[1]);
|
| | | // s1.AppendFormat(_T("当前跳线 %02X %s\r\n"), pDoc->MyKLink1.MEM.SDD[1], intToBinString(pDoc->MyKLink1.MEM.SDD[1]));
|
| | | s1.AppendFormat(_T("02 Tick计数 %u \r\n"), pDoc->MyKLink1.MEM.SDD[2]);
|
| | | s1.AppendFormat(_T("03 nRunCount %u \r\n"), pDoc->MyKLink1.MEM.SDD[3]);
|
| | | s1.AppendFormat(_T("04 RunStat %d \r\n"), pDoc->MyKLink1.MEM.SDD[4]);
|
| | | s1.AppendFormat(_T("05 ErrStat %d \r\n"), pDoc->MyKLink1.MEM.SDD[5]);
|
| | | s1.AppendFormat(_T("06 PwrOnCount %d \r\n"), pDoc->MyKLink1.MEM.SDD[6]);
|
| | | s1.AppendFormat(_T("07 ThisRunTime %d \r\n"), pDoc->MyKLink1.MEM.SDD[7]);
|
| | | s1.AppendFormat(_T("00 跳线 %02X %s 当前 %02X\r\n"), theApp.MyKLink1.MEM.SDD[0], intToBinString(theApp.MyKLink1.MEM.SDD[0]), theApp.MyKLink1.MEM.SDD[1]);
|
| | | // s1.AppendFormat(_T("当前跳线 %02X %s\r\n"), theApp.MyKLink1.MEM.SDD[1], intToBinString(theApp.MyKLink1.MEM.SDD[1]));
|
| | | s1.AppendFormat(_T("02 Tick计数 %u \r\n"), theApp.MyKLink1.MEM.SDD[2]);
|
| | | s1.AppendFormat(_T("03 nRunCount %u \r\n"), theApp.MyKLink1.MEM.SDD[3]);
|
| | | s1.AppendFormat(_T("04 RunStat %d \r\n"), theApp.MyKLink1.MEM.SDD[4]);
|
| | | s1.AppendFormat(_T("05 ErrStat %d \r\n"), theApp.MyKLink1.MEM.SDD[5]);
|
| | | s1.AppendFormat(_T("06 PwrOnCount %d \r\n"), theApp.MyKLink1.MEM.SDD[6]);
|
| | | int nTime1 = theApp.MyKLink1.MEM.SDD[7];
|
| | | s1.AppendFormat(_T("07 ThisRunTime %d %dd %02d:%02d:%02d\r\n"), nTime1, nTime1 / 86400, nTime1 / 3600 % 24, nTime1 / 60 % 60, nTime1 % 60);
|
| | | nTime1 = theApp.MyKLink1.MEM.SDD[8];
|
| | | s1.AppendFormat(_T("08 TotalTime %d %dd %02d:%02d:%02d\r\n"), nTime1, nTime1 / 86400, nTime1 / 3600 % 24, nTime1 / 60 % 60, nTime1 % 60);
|
| | | s1.AppendFormat(_T("09 CurTime %d "), theApp.MyKLink1.MEM.SDD[9]);
|
| | |
|
| | | int nTime1 = pDoc->MyKLink1.MEM.SDD[7];
|
| | | s1.AppendFormat(_T("%dd %02d:%02d:%02d \r\n"), nTime1 / 86400, nTime1 / 3600 % 24, nTime1 / 60 % 60, nTime1 % 60);
|
| | | s1.AppendFormat(_T("08 TotalTime %d \r\n"), pDoc->MyKLink1.MEM.SDD[8]);
|
| | | nTime1 = pDoc->MyKLink1.MEM.SDD[8];
|
| | | s1.AppendFormat(_T("%dd %02d:%02d:%02d \r\n"), nTime1 / 86400, nTime1 / 3600 % 24, nTime1 / 60 % 60, nTime1 % 60);
|
| | | s1.AppendFormat(_T("09 CurTime %d \r\n"), pDoc->MyKLink1.MEM.SDD[9]);
|
| | |
|
| | | nTime1 = pDoc->MyKLink1.MEM.SDD[9];
|
| | | nTime1 = theApp.MyKLink1.MEM.SDD[9];
|
| | | __time32_t time1 = nTime1;
|
| | | CString s3;
|
| | | //_tctime32_s(s3.GetBuffer(1024),1024, &time1);
|
| | |
| | | if (nTime1 >= 0) s3 = ctime1.Format(_T("%Y-%m-%d %H:%M:%S"));
|
| | | s1.Append(s3 + _T("\r\n"));
|
| | | // s1.AppendFormat(_T("%04d-%02d-%02d %02d:%02d:%02d \r\n"), nTime1 / 86400, nTime1 / 3600 % 24, nTime1 / 60 % 60, nTime1 % 60);
|
| | | s1.AppendFormat(_T("10 PwrFailCount %d \r\n"), pDoc->MyKLink1.MEM.SDD[10]);
|
| | | s1.AppendFormat(_T("11 LastPwrFailTime %d \r\n"), pDoc->MyKLink1.MEM.SDD[11]);
|
| | | nTime1 = pDoc->MyKLink1.MEM.SDD[11];
|
| | | s1.AppendFormat(_T("10 PwrFailCount %d \r\n"), theApp.MyKLink1.MEM.SDD[10]);
|
| | | s1.AppendFormat(_T("11 LastPwrFailTime %d \r\n"), theApp.MyKLink1.MEM.SDD[11]);
|
| | | nTime1 = theApp.MyKLink1.MEM.SDD[11];
|
| | | time1 = nTime1;
|
| | | _tctime32_s(s3.GetBuffer(1024), 1024, &time1);
|
| | | s3.ReleaseBuffer();
|
| | |
| | | s3 = ctime1.Format(_T("%Y-%m-%d %H:%M:%S"));
|
| | | s1.Append(s3 + _T("\r\n"));
|
| | |
|
| | | s1.AppendFormat(_T("12 LastScanTime uS %u \r\n"), pDoc->MyKLink1.MEM.SDD[12]);
|
| | | s1.AppendFormat(_T("13 ScanTime uS %d \r\n"), pDoc->MyKLink1.MEM.SDD[13]);
|
| | | s1.AppendFormat(_T("14 MinScanTime uS %d \r\n"), pDoc->MyKLink1.MEM.SDD[14]);
|
| | | s1.AppendFormat(_T("15 %d \r\n"), pDoc->MyKLink1.MEM.SDD[15]);
|
| | | s1.AppendFormat(_T("16 %d \r\n"), pDoc->MyKLink1.MEM.SDD[16]);
|
| | | s1.AppendFormat(_T("17 %d \r\n"), pDoc->MyKLink1.MEM.SDD[17]);
|
| | | s1.AppendFormat(_T("18 %d \r\n"), pDoc->MyKLink1.MEM.SDD[18]);
|
| | | s1.AppendFormat(_T("19 %d \r\n"), pDoc->MyKLink1.MEM.SDD[19]);
|
| | | s1.AppendFormat(_T("20 %d \r\n"), pDoc->MyKLink1.MEM.SDD[20]);
|
| | | s1.AppendFormat(_T("21 %d \r\n"), pDoc->MyKLink1.MEM.SDD[21]);
|
| | | s1.AppendFormat(_T("22 %d \r\n"), pDoc->MyKLink1.MEM.SDD[22]);
|
| | | s1.AppendFormat(_T("23 %d \r\n"), pDoc->MyKLink1.MEM.SDD[23]);
|
| | | s1.AppendFormat(_T("12 LastScanTime uS %u \r\n"), theApp.MyKLink1.MEM.SDD[12]);
|
| | | s1.AppendFormat(_T("13 ScanTime uS %d \r\n"), theApp.MyKLink1.MEM.SDD[13]);
|
| | | s1.AppendFormat(_T("14 MinScanTime uS %d \r\n"), theApp.MyKLink1.MEM.SDD[14]);
|
| | | s1.AppendFormat(_T("15 %d \r\n"), theApp.MyKLink1.MEM.SDD[15]);
|
| | | s1.AppendFormat(_T("16 %d \r\n"), theApp.MyKLink1.MEM.SDD[16]);
|
| | | s1.AppendFormat(_T("17 %d \r\n"), theApp.MyKLink1.MEM.SDD[17]);
|
| | | s1.AppendFormat(_T("18 %d \r\n"), theApp.MyKLink1.MEM.SDD[18]);
|
| | | s1.AppendFormat(_T("19 %d \r\n"), theApp.MyKLink1.MEM.SDD[19]);
|
| | | s1.AppendFormat(_T("20 %d \r\n"), theApp.MyKLink1.MEM.SDD[20]);
|
| | | // s1.AppendFormat(_T("21 %d \r\n"), theApp.MyKLink1.MEM.SDD[21]);
|
| | | // s1.AppendFormat(_T("22 %d \r\n"), theApp.MyKLink1.MEM.SDD[22]);
|
| | | // s1.AppendFormat(_T("23 %d \r\n"), theApp.MyKLink1.MEM.SDD[23]);
|
| | |
|
| | | float Vref = 1.2f;
|
| | | float Vcor = (float)pDoc->MyKLink1.MEM.SDT[53] / pDoc->MyKLink1.MEM.SDT[55];
|
| | | //theApp.MyKLink1.MEM.SDT[56] = 1521;
|
| | | float Vcor = (float)theApp.MyKLink1.MEM.SDT[48 + 18] / theApp.MyKLink1.MEM.SDT[48 + 17];
|
| | | float V33 = 3.3f * Vcor;
|
| | |
|
| | | s1.AppendFormat(_T("24 24V电压 %d %.2f V \r\n"), pDoc->MyKLink1.MEM.SDT[48], pDoc->MyKLink1.MEM.SDT[48] * V33 / 4096 * 11);
|
| | | s1.AppendFormat(_T("25 %d \r\n"), pDoc->MyKLink1.MEM.SDT[49]);
|
| | | s1.AppendFormat(_T("26 5V 电压 %d %.3f V \r\n"), pDoc->MyKLink1.MEM.SDT[50], pDoc->MyKLink1.MEM.SDT[50] * V33 / 4096 * 2);
|
| | | s1.AppendFormat(_T("27 %d \r\n"), pDoc->MyKLink1.MEM.SDT[51]);
|
| | | s1.AppendFormat(_T("28 %d \r\n"), pDoc->MyKLink1.MEM.SDT[52]);
|
| | | s1.AppendFormat(_T("29 %d \r\n"), pDoc->MyKLink1.MEM.SDT[53]);
|
| | | float temp = (1430 - pDoc->MyKLink1.MEM.SDT[54]* 0.806f ) / 4.3f + 25;
|
| | | s1.AppendFormat(_T("30 芯片温度 %d %.1f ℃ \r\n"), pDoc->MyKLink1.MEM.SDT[54],temp);
|
| | | s1.AppendFormat(_T("31 1.2V参考 %d 3.3V电压 %.3f V \r\n"), pDoc->MyKLink1.MEM.SDT[55], V33);
|
| | | s1.AppendFormat(_T("24 ADC0 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 0]);
|
| | | s1.AppendFormat(_T("25 ADC1 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 1]);
|
| | | s1.AppendFormat(_T("26 ADC2 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 2]);
|
| | | s1.AppendFormat(_T("27 ADC3 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 3]);
|
| | | s1.AppendFormat(_T("28 ADC4 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 4]);
|
| | | s1.AppendFormat(_T("29 ADC5 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 5]);
|
| | | s1.AppendFormat(_T("30 ADC6 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 6]);
|
| | | s1.AppendFormat(_T("30 ADC7 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 7]);
|
| | | s1.AppendFormat(_T("30 ADC8 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 8]);
|
| | |
|
| | | float temp = (1430 - theApp.MyKLink1.MEM.SDT[48 + 16]* 0.806f ) / 4.3f + 25;
|
| | | s1.AppendFormat(_T("31 芯片温度 %d %.1f ℃ \r\n"), theApp.MyKLink1.MEM.SDT[48 + 16],temp);
|
| | | s1.AppendFormat(_T("32 1.2V参考 %d 3.3V电压 %.3f V \r\n"), theApp.MyKLink1.MEM.SDT[48 + 17], V33);
|
| | | s1.AppendFormat(_T("33 1.2V校准电压 %d \r\n"), theApp.MyKLink1.MEM.SDT[48 + 18]);
|
| | |
|
| | | s2 += s1;
|
| | | s2.AppendFormat(_T("\r\n"));
|
| | |
|
| | |
|
| | | //型号
|
| | |
| | | //令牌 广播形式, 环路形式
|
| | | //
|
| | |
|
| | | s1.Format(_T("PosX %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[24]);
|
| | | s1.AppendFormat(_T("PosY %d \r\n"),(signed short) theApp.MyKLink1.MEM.WDT[25]);
|
| | | s1.AppendFormat(_T("PosZ %d \r\n"), theApp.MyKLink1.MEM.WDT[26]);
|
| | | s1.AppendFormat(_T("PosZ1 %d \r\n"), theApp.MyKLink1.MEM.WDT[27]);
|
| | | s1.AppendFormat(_T("PosZ2 %d \r\n"), theApp.MyKLink1.MEM.WDT[28]);
|
| | | s1.AppendFormat(_T("PosZ3 %d \r\n"), theApp.MyKLink1.MEM.WDT[29]);
|
| | | s1.AppendFormat(_T("result0 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[32]);
|
| | | s1.AppendFormat(_T("result1 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[33]);
|
| | | s1.AppendFormat(_T("result2 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[34]);
|
| | | s1.AppendFormat(_T("result3 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[35]);
|
| | | s1.AppendFormat(_T("result4 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[36]);
|
| | | s1.AppendFormat(_T("result5 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[37]);
|
| | | s1.AppendFormat(_T("result6 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[38]);
|
| | | s1.AppendFormat(_T("result7 %d \r\n"), (signed short)theApp.MyKLink1.MEM.WDT[39]);
|
| | |
|
| | | s2 += s1;
|
| | | s2.AppendFormat(_T("\r\n"));
|
| | | /*
|
| | |
|
| | | int nOffset = 32;
|
| | | s1.Empty();
|
| | | s1.Format(_T("子机1\r\n"));
|
| | | KLink1::pChnStat pchnstat1 = (KLink1::pChnStat)&(pDoc->MyKLink1.MEM.SDD[nOffset + 0]);
|
| | | KLink1::pChnStat pchnstat1 = (KLink1::pChnStat)&(theApp.MyKLink1.MEM.SDD[nOffset + 0]);
|
| | | unsigned int nSendPackets = pchnstat1->SendPackets;
|
| | | s1.AppendFormat(_T("当前状态: %04X\r\n"), pchnstat1->Stat);
|
| | | s1.AppendFormat(_T("发收包数:%6d/%6d(%.2f%%)\r\n发送时间 %10u (uS)\r\n"),
|
| | |
| | |
|
| | | nOffset = 32 + 24;
|
| | | s1.Format(_T("子机2\r\n"));
|
| | | pchnstat1 = (KLink1::pChnStat)&(pDoc->MyKLink1.MEM.SDD[nOffset + 0]);
|
| | | pchnstat1 = (KLink1::pChnStat)&(theApp.MyKLink1.MEM.SDD[nOffset + 0]);
|
| | | nSendPackets = pchnstat1->SendPackets;
|
| | | s1.AppendFormat(_T("当前状态: %04X\r\n"), pchnstat1->Stat);
|
| | | s1.AppendFormat(_T("发收包数:%6d/%6d(%.2f%%)\r\n发送时间 %10u (uS)\r\n"),
|
| | |
| | | pchnstat1->ClientSendPkts);
|
| | |
|
| | | s2 += s1;
|
| | | // */
|
| | |
|
| | | //m_edit_mon2.SetSel(0, -1);
|
| | | //m_edit_mon2.ReplaceSel(s2);
|
| | | SetDlgItemText(IDC_EDIT_MON2, s2);
|
| | | }
|
| | |
|
| | | s1.Empty();
|
| | | pstWLRunStat pWLRunStat = (pstWLRunStat)(&pDoc->KWLB);
|
| | | s1.Format(_T("状态 %04X %04X 步骤 %04X \r\n"), pWLRunStat->Stat, pWLRunStat->curStat, pWLRunStat->runStep);
|
| | |
|
| | | s1 += _T("发送数量: ") + intToString(pWLRunStat->sentCount) + _T(" 对方收到: ") + intToString(pWLRunStat->targetRecvdCount) + _T(" 差值: ") + intToString(pWLRunStat->sentCount - pWLRunStat->targetRecvdCount) + _T("\r\n");
|
| | | s1 += _T("接收数量: ") + intToString(pWLRunStat->recvCount) + _T(" 对方发出: ") + intToString(pWLRunStat->targetSentCount) + _T(" 差值: ") + intToString(pWLRunStat->targetSentCount - pWLRunStat->recvCount) + _T("\r\n");
|
| | |
|
| | | s1 += _T("发送时间: ") + fixToString(pWLRunStat->lastSendtime,0,1) + _T(" mS\r\n");
|
| | | s1 += _T("发完时间: ") + fixToString(pWLRunStat->lastSenttime, 0, 1) + _T(" ") + fixToString(pWLRunStat->lastSenttime - pWLRunStat->lastSendtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("接收时间: ") + fixToString(pWLRunStat->lastRecvtime,0,1) + _T(" mS\r\n");
|
| | | s1 += _T("收到时间: ") + fixToString(pWLRunStat->lastRecvdtime, 0, 1) + _T(" ") + fixToString(pWLRunStat->lastRecvdtime - pWLRunStat->lastRecvtime, 0, 1) + +_T(" mS\r\n");
|
| | | s1 += _T("动作时间: ") + fixToString(pWLRunStat->lastActTime,0,1) + _T(" mS\r\n");
|
| | | s1 += _T("响应时间: ") + fixToString(pWLRunStat->lastAckTime,0,1) + _T(" ") + fixToString(pWLRunStat->lastAckTime - pWLRunStat->lastActTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("循环时间: ") + fixToString(pWLRunStat->cycleTime,0,1) + _T(" mS\r\n");
|
| | | s1 += _T("延迟: ") + fixToString(pWLRunStat->latancy,0,1) + _T(" mS\r\n");
|
| | | s1.AppendFormat(_T("丢包数量: %d 连续丢包: %d 最大连续 %d\r\n"), pWLRunStat->LostPackets, pWLRunStat->CtnLstPkts, pWLRunStat->MaxCtnLstPkts);
|
| | | s1.AppendFormat(_T("发送错误: %d 接收错误: %d 时间 %s mS\r\n"), pWLRunStat->TXErr, pWLRunStat->RXErr, fixToString(pWLRunStat->lastErrTime,0,1));
|
| | | s1.AppendFormat(_T("CRC错误: %d\r\n"), pWLRunStat->CRCErr);
|
| | | s1.AppendFormat(_T("CAD次数: %d\r\n"), pWLRunStat->CADDoneCount);
|
| | | s1.AppendFormat(_T("小错误1: %d 中错误2: %d 大错误3: %d\r\n"), pWLRunStat->Err1Count, pWLRunStat->Err2Count, pWLRunStat->Err3Count);
|
| | |
|
| | | s1.AppendFormat(_T("步骤错误1: %d 步骤错误2: %d\r\n"), pWLRunStat->StepErr1, pWLRunStat->StepErr2);
|
| | |
|
| | | s1.AppendFormat(_T("本机信号强度: %d dBm SNR %d dBm\r\n"), pWLRunStat->RSSI, pWLRunStat->SNR);
|
| | | s1.AppendFormat(_T("对方信号强度: %d dBm SNR %d dBm\r\n"), pWLRunStat->tRSSI, pWLRunStat->tSNR);
|
| | |
|
| | | // pstWLRunStat pWLRunStat = (pstWLRunStat)(theApp.MyKLink1.MEM.KWLB);
|
| | | s1 = KWRunStatToString((pstWLRunStat)(theApp.MyKLink1.MEM.KWLB));
|
| | | SetDlgItemText(IDC_EDIT_MON4, s1);
|
| | | //SetRedraw(TRUE);
|
| | | //s1.Append(s2);
|
| | |
| | | UpdateStatusBar(-1);
|
| | | return 0;
|
| | | }
|
| | | CString CMTerm1CommDevView::KWRunStatToString(pstWLRunStat pWLRunStat1)
|
| | | {
|
| | | CString s1;
|
| | | // pstWLRunStat pWLRunStat1 = (pstWLRunStat)(theApp.MyKLink1.MEM.KWLB);
|
| | | s1.Format(_T("stsize %d 无线状态 %04X %04X 步骤 %04X \r\n"), sizeof(stWLRunStat), pWLRunStat1->Status, pWLRunStat1->curStat, pWLRunStat1->runStep);
|
| | | s1.AppendFormat(_T("频率 %.3f Bw %d TxP %ddBm Fctr %d CDR %d ToA %dmS\r\n"),
|
| | | float(pWLRunStat1->RF_Freq / 1000000.0f), pWLRunStat1->LoraBandWidth, pWLRunStat1->Tx_Power, pWLRunStat1->LoRaFactor, pWLRunStat1->LoRaCodingRate, pWLRunStat1->nTimeOnAir);
|
| | | s1 += _T("当前子机: ") + intToString(pWLRunStat1->nCurClient) + _T("\r\n");
|
| | | // s1 += _T("频率: ") + intToString(pWLRunStat1->RF_Freq) + _T(" 空中时间: ") + intToString(pWLRunStat1->nTimeOnAir) + _T("\r\n");
|
| | | // s1 += _T("BW: ") + intToString(pWLRunStat1->LoraBandWidth) + _T(" Tx_Pwr: ") + intToString(pWLRunStat1->Tx_Power) +_T(" ");
|
| | | // s1 += _T("Factor: ") + intToString(pWLRunStat1->LoRaFactor) + _T(" CodingRate : ") + intToString(pWLRunStat1->LoRaCodingRate) + _T("\r\n");
|
| | |
|
| | | s1 += _T("发送数量: ") + intToString(pWLRunStat1->sentCount) + _T(" 对方收到: ") + intToString(pWLRunStat1->targetRecvdCount) + _T(" 差值: ") + intToString(pWLRunStat1->sentCount - pWLRunStat1->targetRecvdCount) + _T("\r\n");
|
| | | s1 += _T("接收数量: ") + intToString(pWLRunStat1->recvCount) + _T(" 对方发出: ") + intToString(pWLRunStat1->targetSentCount) + _T(" 差值: ") + intToString(pWLRunStat1->targetSentCount - pWLRunStat1->recvCount) + _T("\r\n");
|
| | |
|
| | | s1 += _T("发送时间: ") + fixToString(pWLRunStat1->lastSendtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("发完时间: ") + fixToString(pWLRunStat1->lastSenttime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastSenttime - pWLRunStat1->lastSendtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("接收时间: ") + fixToString(pWLRunStat1->lastRecvtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("收到时间: ") + fixToString(pWLRunStat1->lastRecvdtime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastRecvdtime - pWLRunStat1->lastRecvtime, 0, 1) + +_T(" mS\r\n");
|
| | | s1 += _T("动作时间: ") + fixToString(pWLRunStat1->lastActTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("响应时间: ") + fixToString(pWLRunStat1->lastAckTime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastAckTime - pWLRunStat1->lastActTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("循环时间: ") + fixToString(pWLRunStat1->cycleTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("延迟: ") + fixToString(pWLRunStat1->latancy, 0, 1) + _T(" mS\r\n");
|
| | | s1.AppendFormat(_T("丢包数量: %d 连续丢包: %d 最大连续 %d\r\n"), pWLRunStat1->LostPackets, pWLRunStat1->CtnLstPkts, pWLRunStat1->MaxCtnLstPkts);
|
| | | s1.AppendFormat(_T("发送错误: %d 接收错误: %d 时间 %s mS\r\n"), pWLRunStat1->TXErr, pWLRunStat1->RXErr, fixToString(pWLRunStat1->lastErrTime, 0, 1));
|
| | | s1.AppendFormat(_T("CRC错误: %d 包格式错误 %d 地址错误 %d %04X\r\n"), pWLRunStat1->CRCErr, pWLRunStat1->PktErr, pWLRunStat1->ChnErr, pWLRunStat1->nErrChn);
|
| | | s1.AppendFormat(_T("CAD次数: %d OK %d NG %d TimeOut %d Per %.2f%% \r\n"), pWLRunStat1->CADDoneCount, pWLRunStat1->CADOkCount, pWLRunStat1->CADNgCount, pWLRunStat1->CADTimeOut, pWLRunStat1->CADNgCount*100.f/pWLRunStat1->CADDoneCount);
|
| | | s1.AppendFormat(_T("小错误1: %d 中错误2: %d 大错误3: %d\r\n"), pWLRunStat1->Err1Count, pWLRunStat1->Err2Count, pWLRunStat1->Err3Count);
|
| | |
|
| | | s1.AppendFormat(_T("步骤错误1: %d 步骤错误2: %d\r\n"), pWLRunStat1->StepErr1, pWLRunStat1->StepErr2);
|
| | | CString s2;
|
| | | if (pWLRunStat1->RSSI < -100) { s2.Format(_T("(0%%)")); }
|
| | | else if (pWLRunStat1->RSSI > 0) { s2.Format(_T("(100%%)")); }
|
| | | else { s2.Format(_T("(%d%%)"), pWLRunStat1->RSSI + 100); }
|
| | | s1.AppendFormat(_T("本机信号强度: %d dBm SNR %d dB ▁▃▅▇\r\n"), pWLRunStat1->RSSI, pWLRunStat1->SNR);
|
| | | if (pWLRunStat1->tRSSI < -100) { s2.Format(_T("(0%%)")); }
|
| | | else if (pWLRunStat1->tRSSI > 0) { s2.Format(_T("(100%%)")); }
|
| | | else { s2.Format(_T("(%d%%)"), pWLRunStat1->tRSSI + 100); }
|
| | | s1.AppendFormat(_T("对方信号强度: %d dBm SNR %d dB ▁▃▅▇\r\n"), pWLRunStat1->tRSSI, pWLRunStat1->tSNR);
|
| | | return s1;
|
| | | }
|
| | |
|
| | | CString CMTerm1CommDevView::KWRunStatToString(pstWLRunStatV12 pWLRunStat1)
|
| | | {
|
| | | CString s1;
|
| | | // pstWLRunStat pWLRunStat1 = (pstWLRunStat)(theApp.MyKLink1.MEM.KWLB);
|
| | | s1.Format(_T("stsize %d 无线状态 %04X %04X 步骤 %04X \r\n"),sizeof(stWLRunStatV12), pWLRunStat1->Status, pWLRunStat1->curStat, pWLRunStat1->runStep);
|
| | | s1 += _T("频率: ") + intToString(pWLRunStat1->RF_Freq) + _T(" 空中时间: ") + intToString(pWLRunStat1->nTimeOnAir) + _T("\r\n");
|
| | |
|
| | | s1 += _T("发送数量: ") + intToString(pWLRunStat1->sentCount) + _T(" 对方收到: ") + intToString(pWLRunStat1->targetRecvdCount) + _T(" 差值: ") + intToString(pWLRunStat1->sentCount - pWLRunStat1->targetRecvdCount) + _T("\r\n");
|
| | | s1 += _T("接收数量: ") + intToString(pWLRunStat1->recvCount) + _T(" 对方发出: ") + intToString(pWLRunStat1->targetSentCount) + _T(" 差值: ") + intToString(pWLRunStat1->targetSentCount - pWLRunStat1->recvCount) + _T("\r\n");
|
| | |
|
| | | s1 += _T("发送时间: ") + fixToString(pWLRunStat1->lastSendtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("发完时间: ") + fixToString(pWLRunStat1->lastSenttime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastSenttime - pWLRunStat1->lastSendtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("接收时间: ") + fixToString(pWLRunStat1->lastRecvtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("收到时间: ") + fixToString(pWLRunStat1->lastRecvdtime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastRecvdtime - pWLRunStat1->lastRecvtime, 0, 1) + +_T(" mS\r\n");
|
| | | s1 += _T("动作时间: ") + fixToString(pWLRunStat1->lastActTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("响应时间: ") + fixToString(pWLRunStat1->lastAckTime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastAckTime - pWLRunStat1->lastActTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("循环时间: ") + fixToString(pWLRunStat1->cycleTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("延迟: ") + fixToString(pWLRunStat1->latancy, 0, 1) + _T(" mS\r\n");
|
| | | s1.AppendFormat(_T("丢包数量: %d 连续丢包: %d 最大连续 %d\r\n"), pWLRunStat1->LostPackets, pWLRunStat1->CtnLstPkts, pWLRunStat1->MaxCtnLstPkts);
|
| | | s1.AppendFormat(_T("发送错误: %d 接收错误: %d 时间 %s mS\r\n"), pWLRunStat1->TXErr, pWLRunStat1->RXErr, fixToString(pWLRunStat1->lastErrTime, 0, 1));
|
| | | s1.AppendFormat(_T("CRC错误: %d 频道错误 %d 包错误 %d\r\n"), pWLRunStat1->CRCErr, pWLRunStat1->ChnErr, pWLRunStat1->PktErr);
|
| | | s1.AppendFormat(_T("CAD次数: %d\r\n"), pWLRunStat1->CADDoneCount);
|
| | | s1.AppendFormat(_T("小错误1: %d 中错误2: %d 大错误3: %d\r\n"), pWLRunStat1->Err1Count, pWLRunStat1->Err2Count, pWLRunStat1->Err3Count);
|
| | |
|
| | | s1.AppendFormat(_T("步骤错误1: %d 步骤错误2: %d\r\n"), pWLRunStat1->StepErr1, pWLRunStat1->StepErr2);
|
| | | CString s2;
|
| | | if (pWLRunStat1->RSSI < -100) { s2.Format(_T("(0%%)")); }
|
| | | else if (pWLRunStat1->RSSI > 0) { s2.Format(_T("(100%%)")); }
|
| | | else { s2.Format(_T("(%d%%)"), pWLRunStat1->RSSI + 100); }
|
| | | s1.AppendFormat(_T("本机信号强度: %d dBm ▁▃▅▇ SNR %d dB\r\n"), pWLRunStat1->RSSI, pWLRunStat1->SNR);
|
| | | if (pWLRunStat1->tRSSI < -100) { s2.Format(_T("(0%%)")); }
|
| | | else if (pWLRunStat1->tRSSI > 0) { s2.Format(_T("(100%%)")); }
|
| | | else { s2.Format(_T("(%d%%)"), pWLRunStat1->tRSSI + 100); }
|
| | | s1.AppendFormat(_T("对方信号强度: %d dBm ▁▃▅▇ SNR %d dB\r\n"), pWLRunStat1->tRSSI, pWLRunStat1->tSNR);
|
| | | return s1;
|
| | | }
|
| | |
|
| | | CString CMTerm1CommDevView::KWRunStatToString(pstWLRunStatV1 pWLRunStat1)
|
| | | {
|
| | | CString s1;
|
| | | // pstWLRunStat pWLRunStat1 = (pstWLRunStat)(theApp.MyKLink1.MEM.KWLB);
|
| | | s1.Format(_T("stsize %d 无线状态 %04X %04X 步骤 %04X \r\n"), sizeof(stWLRunStatV1), pWLRunStat1->Status, pWLRunStat1->curStat, pWLRunStat1->runStep);
|
| | | // s1 += _T("频率: ") + intToString(pWLRunStat1->RF_Freq) + _T(" 空中时间: ") + intToString(pWLRunStat1->nTimeOnAir) + _T("\r\n");
|
| | |
|
| | | s1 += _T("发送数量: ") + intToString(pWLRunStat1->sentCount) + _T(" 对方收到: ") + intToString(pWLRunStat1->targetRecvdCount) + _T(" 差值: ") + intToString(pWLRunStat1->sentCount - pWLRunStat1->targetRecvdCount) + _T("\r\n");
|
| | | s1 += _T("接收数量: ") + intToString(pWLRunStat1->recvCount) + _T(" 对方发出: ") + intToString(pWLRunStat1->targetSentCount) + _T(" 差值: ") + intToString(pWLRunStat1->targetSentCount - pWLRunStat1->recvCount) + _T("\r\n");
|
| | |
|
| | | s1 += _T("发送时间: ") + fixToString(pWLRunStat1->lastSendtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("发完时间: ") + fixToString(pWLRunStat1->lastSenttime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastSenttime - pWLRunStat1->lastSendtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("接收时间: ") + fixToString(pWLRunStat1->lastRecvtime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("收到时间: ") + fixToString(pWLRunStat1->lastRecvdtime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastRecvdtime - pWLRunStat1->lastRecvtime, 0, 1) + +_T(" mS\r\n");
|
| | | s1 += _T("动作时间: ") + fixToString(pWLRunStat1->lastActTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("响应时间: ") + fixToString(pWLRunStat1->lastAckTime, 0, 1) + _T(" ") + fixToString(pWLRunStat1->lastAckTime - pWLRunStat1->lastActTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("循环时间: ") + fixToString(pWLRunStat1->cycleTime, 0, 1) + _T(" mS\r\n");
|
| | | s1 += _T("延迟: ") + fixToString(pWLRunStat1->latancy, 0, 1) + _T(" mS\r\n");
|
| | | s1.AppendFormat(_T("丢包数量: %d 连续丢包: %d 最大连续 %d\r\n"), pWLRunStat1->LostPackets, pWLRunStat1->CtnLstPkts, pWLRunStat1->MaxCtnLstPkts);
|
| | | s1.AppendFormat(_T("发送错误: %d 接收错误: %d 时间 %s mS\r\n"), pWLRunStat1->TXErr, pWLRunStat1->RXErr, fixToString(pWLRunStat1->lastErrTime, 0, 1));
|
| | | s1.AppendFormat(_T("CRC错误: %d \r\n"), pWLRunStat1->CRCErr);
|
| | | s1.AppendFormat(_T("CAD次数: %d\r\n"), pWLRunStat1->CADDoneCount);
|
| | | s1.AppendFormat(_T("小错误1: %d 中错误2: %d 大错误3: %d\r\n"), pWLRunStat1->Err1Count, pWLRunStat1->Err2Count, pWLRunStat1->Err3Count);
|
| | |
|
| | | s1.AppendFormat(_T("步骤错误1: %d 步骤错误2: %d\r\n"), pWLRunStat1->StepErr1, pWLRunStat1->StepErr2);
|
| | | CString s2;
|
| | | if (pWLRunStat1->RSSI < -100) { s2.Format(_T("(0%%)")); }
|
| | | else if (pWLRunStat1->RSSI > 0) { s2.Format(_T("(100%%)")); }
|
| | | else { s2.Format(_T("(%d%%)"), pWLRunStat1->RSSI+100); }
|
| | | s1.AppendFormat(_T("本机信号强度: %ddBm %s ▁▃▅▇ 信噪比 SNR %d dB\r\n"), pWLRunStat1->RSSI, s2, pWLRunStat1->SNR);
|
| | | if (pWLRunStat1->tRSSI < -100) { s2.Format(_T("(0%%)")); }
|
| | | else if (pWLRunStat1->tRSSI > 0) { s2.Format(_T("(100%%)")); }
|
| | | else { s2.Format(_T("(%d%%)"), pWLRunStat1->tRSSI + 100); }
|
| | | s1.AppendFormat(_T("对方信号强度: %ddBm %s ▁▃▅▇ 信噪比 SNR %d dB\r\n"), pWLRunStat1->tRSSI,s2, pWLRunStat1->tSNR);
|
| | | return s1;
|
| | | }
|
| | |
|
| | | int CMTerm1CommDevView::UpdateStatusBar(int nIndex)
|
| | | {
|
| | | // TODO: 在此处添加实现代码.
|
| | | CString s1;
|
| | | return 0;
|
| | | CMTerm1Doc * pDoc = (CMTerm1Doc*)GetDocument();
|
| | |
|
| | | if (nIndex == idxMachineType || nIndex == -1) { //机型代码
|
| | |
| | | // ProcessInput();
|
| | | //DrawPic1();
|
| | | // MyLogger1.UpdateLogDisplay(0);
|
| | | //MonitorPLC();
|
| | | UpdateDataDisplay();
|
| | | UpdateLEDDisplay();
|
| | | }
|
| | |
| | |
|
| | | int CMTerm1CommDevView::DisplayParams()
|
| | | {
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | CString s1, s2;
|
| | | Hash & ModelConfg = MyCfg1["Model"];
|
| | | ModelConfg.SetCtrlList(this, myCfgValCtrls, nMarkConfigs);
|
| | |
| | | m_combo_com_baud.AddString(_T("1000000"));
|
| | | m_combo_com_baud.AddString(_T("2000000"));
|
| | | m_combo_com_baud.AddString(_T("3000000"));
|
| | | sBaudSelStr = _T("230400");
|
| | | sBaudSelStr = _T("115200");
|
| | | m_combo_com_baud.SelectString(0, sBaudSelStr);
|
| | |
|
| | | MyThreadProc1ToRun = 0;
|
| | |
| | | int CMTerm1CommDevView::OpenResource(CStringA ResourceStr)
|
| | | {
|
| | | CString s1;
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *) GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *) GetDocument();
|
| | |
|
| | | int r = pDoc->Connect();
|
| | | s1.Format(_T("Open %s = %d"), pDoc->MyKLink1.m_resultStr, r);
|
| | | //int r = pDoc->Connect();
|
| | | int r = theApp.MyKLink1.Connect();
|
| | | s1.Format(_T("Open %s = %d"), theApp.MyKLink1.m_resultStr, r);
|
| | | SysLog(s1);
|
| | | if (r == pDoc->MyKLink1.MySerPort1.R_OK)
|
| | | if (r == theApp.MyKLink1.MySerPort1.R_OK)
|
| | | {
|
| | | m_bResourceOpened = true;
|
| | | // pDoc->MyKLink1.Open();
|
| | | // theApp.MyKLink1.Open();
|
| | | m_static_connect.SetCtlColor(RGB(0, 255, 0));
|
| | | return true;
|
| | | }
|
| | |
| | |
|
| | | int CMTerm1CommDevView::CloseResource()
|
| | | {
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | |
|
| | | m_static_connect.SetCtlColor(RGB(80, 80, 80));
|
| | | if (m_bResourceOpened)
|
| | | {
|
| | | pDoc->DisConnect();
|
| | | pDoc->MyKLink1.Close();
|
| | | //pDoc->DisConnect();
|
| | | theApp.MyKLink1.Close();
|
| | | m_bResourceOpened = false;
|
| | | }
|
| | | return 0;
|
| | |
| | |
|
| | | int CMTerm1CommDevView::MonitorPLC()
|
| | | {
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | |
|
| | | if (m_bMonitoring && pDoc->MyKLink1.MySerPort1.m_bOpened)
|
| | | if (m_bMonitoring && theApp.MyKLink1.MySerPort1.m_bOpened)
|
| | | {
|
| | | unsigned char DstAddr = 1;
|
| | | unsigned char DataType = pDoc->MyKLink1.KLDataTypeSDT;
|
| | | unsigned char DataType = theApp.MyKLink1.KLDataTypeSDT;
|
| | | unsigned short DAddr = 0;
|
| | | unsigned char DCount = 32;
|
| | | // unsigned char Data1[256];
|
| | |
| | | ///*
|
| | | if (nStep == 0)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWX;
|
| | | DataType = theApp.MyKLink1.KLDataTypeWX;
|
| | | DAddr = 0;
|
| | | DCount = 16;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &pDoc->MyKLink1.MEM.WXB[DAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &theApp.MyKLink1.MEM.WXB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | |
|
| | |
| | | //WY
|
| | | if (nStep == 0)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWY;
|
| | | DataType = theApp.MyKLink1.KLDataTypeWY;
|
| | | DAddr = 0;
|
| | | DCount = 16;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &pDoc->MyKLink1.MEM.WYB[DAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &theApp.MyKLink1.MEM.WYB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | | //*/
|
| | | }
|
| | | //*/
|
| | | // WLX
|
| | | ///*
|
| | | if (nStep == 0)
|
| | | {
|
| | | DataType = theApp.MyKLink1.KLDataTypeWLX;
|
| | | DAddr = 0;
|
| | | DCount = 16;
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &theApp.MyKLink1.MEM.WLXB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | |
|
| | | }
|
| | | //*/
|
| | |
|
| | | ///*
|
| | | //WLY
|
| | | if (nStep == 0)
|
| | | {
|
| | | DataType = theApp.MyKLink1.KLDataTypeWLY;
|
| | | DAddr = 0;
|
| | | DCount = 16;
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &theApp.MyKLink1.MEM.WLYB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | | }
|
| | | //*/
|
| | | ///*
|
| | | //WR
|
| | | if (nStep==0)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWR;
|
| | | DataType = theApp.MyKLink1.KLDataTypeWR;
|
| | | DAddr = 0;
|
| | | DCount = 32;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &pDoc->MyKLink1.MEM.WRB[DAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &theApp.MyKLink1.MEM.WRB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | | }
|
| | |
| | | //DT
|
| | | if (nStep == 1)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeDT;
|
| | | DataType = theApp.MyKLink1.KLDataTypeDT;
|
| | | DAddr = 0;
|
| | | DCount = 96;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &pDoc->MyKLink1.MEM.DTB[DAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &nCount, &theApp.MyKLink1.MEM.DTB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | |
|
| | |
| | | if (nStep >= 2 && nStep <= 4)
|
| | | {
|
| | | int nBlock = nStep - 2;
|
| | | DataType = pDoc->MyKLink1.KLDataTypeSDT;
|
| | | DataType = theApp.MyKLink1.KLDataTypeSDT;
|
| | | ByteAddr = nBlock * 128;
|
| | | DCount = 128;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &pDoc->MyKLink1.MEM.SDB[ByteAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &theApp.MyKLink1.MEM.SDB[ByteAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | for (int i = 0; i < DCount; i++) { SDTbuf[ByteAddr + i] = pDoc->MyKLink1.MEM.SDB[ByteAddr + i]; }
|
| | | for (int i = 0; i < DCount; i++) { SDTbuf[ByteAddr + i] = theApp.MyKLink1.MEM.SDB[ByteAddr + i]; }
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | | }
|
| | | if (nStep >= 5 && nStep <= 7)
|
| | | {
|
| | | int nBlock = nStep - 5;
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWDT;
|
| | | DataType = theApp.MyKLink1.KLDataTypeWDT;
|
| | | ByteAddr = nBlock * 128;
|
| | | DCount = 128;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &pDoc->MyKLink1.MEM.WDB[ByteAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &theApp.MyKLink1.MEM.WDB[ByteAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | for (int i = 0; i < DCount; i++) { WDTbuf[ByteAddr + i] = pDoc->MyKLink1.MEM.WDB[ByteAddr + i]; }
|
| | | for (int i = 0; i < DCount; i++) { WDTbuf[ByteAddr + i] = theApp.MyKLink1.MEM.WDB[ByteAddr + i]; }
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | | }
|
| | |
| | | if (nStep >= 8 && nStep <= 13)
|
| | | {
|
| | | int nBlock = nStep - 8;
|
| | | DataType = pDoc->MyKLink1.KLDataTypeKBD;
|
| | | DataType = theApp.MyKLink1.KLDataTypeKBD;
|
| | | ByteAddr = nBlock * 128;
|
| | | DCount = 128;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &pDoc->KBDB[ByteAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &theApp.MyKLink1.MEM.KBDB[ByteAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | //for (int i = 0; i < DCount; i++) { WDTbuf[ByteAddr + i] = pDoc->MyKLink1.MEM.WDB[ByteAddr + i]; }
|
| | | //for (int i = 0; i < DCount; i++) { WDTbuf[ByteAddr + i] = theApp.MyKLink1.MEM.WDB[ByteAddr + i]; }
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | | }
|
| | | if (nStep >= 14 && nStep <= 14)
|
| | | {
|
| | | int nBlock = nStep - 14;
|
| | | DataType = pDoc->MyKLink1.KLDataTypeKWLD;
|
| | | DataType = theApp.MyKLink1.KLDataTypeKWLD;
|
| | | ByteAddr = nBlock * 128;
|
| | | DCount = 128;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &pDoc->KWLB[ByteAddr]);
|
| | | res = theApp.MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &nCount, &theApp.MyKLink1.MEM.KWLB[ByteAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | if (res == theApp.MyKLink1.KL_OK)
|
| | | {
|
| | | //for (int i = 0; i < DCount; i++) { WDTbuf[ByteAddr + i] = pDoc->MyKLink1.MEM.WDB[ByteAddr + i]; }
|
| | | //for (int i = 0; i < DCount; i++) { WDTbuf[ByteAddr + i] = theApp.MyKLink1.MEM.WDB[ByteAddr + i]; }
|
| | | nThisSuccessCount++;
|
| | | }
|
| | | else
|
| | | {
|
| | | nThisFailCount++;
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, pDoc->MyKLink1.m_resultStr);
|
| | | s1.Format(_T("R:= %d %s \r\n"), res, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | }
|
| | | }
|
| | |
| | | CString s1, s2;
|
| | | SysLog(_T("线程开始运行\r\n"));
|
| | | MyThreadProc1Running = 1;
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | |
|
| | |
|
| | | /*
|
| | |
| | | //s2.GetLength();
|
| | | // memcpy(send1,s2,bytetosend1);
|
| | |
|
| | | pDoc->MyAnsiParser1.AttachWnd(m_edit_display.GetSafeHwnd());
|
| | | pDoc->MyAnsiParser1.SetScreenWH(150, 40);
|
| | | // pDoc->MyAnsiParser1.AttachWnd(m_edit_display.GetSafeHwnd());
|
| | | // pDoc->MyAnsiParser1.SetScreenWH(150, 40);
|
| | |
|
| | | // CClientDC hcurDC(this);
|
| | | HWND hDrawXY = GetDlgItem(IDC_STATIC_DRAW_XY)->m_hWnd;
|
| | |
| | | nDataToSend = LastSendLength;
|
| | | // s1.Format(_T("BulkToSend %d Bytes"), nDataToSend);
|
| | | // SysLog(s1);
|
| | | dwSent = pDoc->MyKLink1.SendPacket((char *)send1, nDataToSend);
|
| | | dwSent = theApp.MyKLink1.SendPacket((char *)send1, nDataToSend);
|
| | | s1.Format(_T("S %d ->"), nDataToSend);
|
| | | for (int i = 0; i < nDataToSend; i++)
|
| | | {
|
| | |
| | | {
|
| | | s1.Format(_T("ToSend %d Bytes"), nDataToSend);
|
| | | SysLog(s1);
|
| | | dwSent = pDoc->MyKLink1.SendPacket((char *)send1, nDataToSend);
|
| | | dwSent = theApp.MyKLink1.SendPacket((char *)send1, nDataToSend);
|
| | | s1.Format(_T("S %d ->"), nDataToSend);
|
| | | for (int i = 0; i < nDataToSend; i++)
|
| | | {
|
| | |
| | | SysLog(s1);
|
| | | }
|
| | | //ReadFile(hCom, recv1, dNumtoRead, &wCount2, &ovlap2);
|
| | | wCount2 = pDoc->MyKLink1.RecvPacket((char *)recv1, dNumtoRead);
|
| | | wCount2 = theApp.MyKLink1.RecvPacket((char *)recv1, dNumtoRead);
|
| | | // WaitForSingleObject(ovlap2.hEvent,800);
|
| | | // GetOverlappedResult(hCom,&ovlap2,&wCount2,TRUE);
|
| | | if (wCount2 == 0) continue;
|
| | |
| | | s1.Append(_T("\r\n"));
|
| | | // SysLog(s1);
|
| | | //continue;
|
| | | pDoc->MyKLink1.ParseRplyPacket(recv1, wCount2, &nCmd, &nStatus, &nCount, databuf1);
|
| | | theApp.MyKLink1.ParseRplyPacket(recv1, wCount2, &nCmd, &nStatus, &nCount, databuf1);
|
| | |
|
| | | s1.Format(_T("R-> Cmd:%02X Status:%04X Count:%02d \r\nData: "), nCmd, nStatus, nCount);
|
| | | s2.Empty();
|
| | |
| | | s1.Append(s2);
|
| | | s1.Append(_T("\r\n"));
|
| | | SysLog(s1);
|
| | | int HasData = pDoc->MyDataParser1.PutIn(recv1, wCount2);
|
| | | int HasData = 0; // pDoc->MyDataParser1.PutIn(recv1, wCount2);
|
| | | CStringA sA1;
|
| | | TToAnsi(s1, sA1);
|
| | | // MyAnsiParser1.PutIn((unsigned char *)sA1.GetBuffer(), sA1.GetLength()); sA1.ReleaseBuffer();
|
| | | // MyAnsiParser1.PutIn(recv1, wCount2);
|
| | | if (HasData)
|
| | | {
|
| | | pDoc->MyDataParser1.GetOutput(&handx, &handy);
|
| | | //pDoc->MyDataParser1.GetOutput(&handx, &handy);
|
| | | if (oldhandx != handx || oldhandy != handy)
|
| | | {
|
| | | DrawCross(hDrawXY, handx, handy);
|
| | |
| | | void CMTerm1CommDevView::OnBnClickedButtonStop()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | |
|
| | | m_bMonitoring = true;
|
| | | OnMenuMonitor();
|
| | |
| | | {
|
| | | SysLog(_T("线程未运行\r\n"));
|
| | | }
|
| | | pDoc->MyKLink1.Close();
|
| | | theApp.MyKLink1.Close();
|
| | | }
|
| | |
|
| | |
|
| | | void CMTerm1CommDevView::OnBnClickedButtonClrscr()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | CString s1;
|
| | | s1.Format(_T("Clear Screen \r\n"));
|
| | | SysLog(s1);
|
| | | pDoc->MyAnsiParser1.ClrScreen();
|
| | | //pDoc->MyAnsiParser1.ClrScreen();
|
| | | }
|
| | |
|
| | |
|
| | |
| | | void CMTerm1CommDevView::OnBnClickedButtonDo()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | |
|
| | | unsigned char buf1[256];
|
| | | unsigned char buf2[256];
|
| | |
| | | Data2[i] = Xtoi(Resultstrs[i]);
|
| | | }
|
| | |
|
| | | int ExtFrameLen = pDoc->MyKLink1.MakeExtDataFrame(buf2, ExtDataDst, ExtDataType, ExtDataLen, Data2);
|
| | | int ExtFrameLen = theApp.MyKLink1.MakeExtDataFrame(buf2, ExtDataDst, ExtDataType, ExtDataLen, Data2);
|
| | |
|
| | | KLink1::unKLStat nStat1 = { 0 };
|
| | | nStat1.HasExt = bExtData;
|
| | | nStat1.nSEQ = pDoc->MyKLink1.GetNextSeq();
|
| | | nStat1.nSEQ = theApp.MyKLink1.GetNextSeq();
|
| | | // Cmd += 0x30; //KLink::cmdRead
|
| | | int len1 = pDoc->MyKLink1.MakeReqPacketEx(buf1, DstAddr, nStat1.StatByte, Cmd, DataType, DAddr, DCount, Data1, ExtFrameLen, buf2);
|
| | | int len1 = theApp.MyKLink1.MakeReqPacketEx(buf1, DstAddr, nStat1.StatByte, Cmd, DataType, DAddr, DCount, Data1, ExtFrameLen, buf2);
|
| | | s1.Format(_T("S %d ->"), len1);
|
| | | int res = 0;
|
| | | int SendType = 1;
|
| | | if (SendType == 1)
|
| | | {
|
| | | res = pDoc->MyKLink1.SendPacket((char *)buf1, len1);
|
| | | res = theApp.MyKLink1.SendPacket((char *)buf1, len1);
|
| | | for (int i = 0; i < len1; i++)
|
| | | {
|
| | | s1.AppendFormat(_T("%02X "), buf1[i]);
|
| | |
| | | for (int i = 0; i < 10; i++)
|
| | | {
|
| | | nTryCount++;
|
| | | int len = pDoc->MyKLink1.RecvPacket((char *)recv1 + len2, numToRead - len2);
|
| | | int len = theApp.MyKLink1.RecvPacket((char *)recv1 + len2, numToRead - len2);
|
| | | if (len >0) len2 += len;
|
| | | if (len2 >= numToRead) break;
|
| | | if (len2 > 0) {
|
| | |
| | |
|
| | | //continue;
|
| | | unsigned short databuf1[256];
|
| | | pDoc->MyKLink1.ParseRplyPacket(recv1, wCount2, &nCmd, &nStatus, &nCount, databuf1);
|
| | | theApp.MyKLink1.ParseRplyPacket(recv1, wCount2, &nCmd, &nStatus, &nCount, databuf1);
|
| | |
|
| | | s1.Format(_T("R: Cmd:%02X St:%02X N:%02d D:\r\n"), nCmd, nStatus, nCount);
|
| | | CString s2;
|
| | |
| | | void CMTerm1CommDevView::OnMenuOffline()
|
| | | {
|
| | | // TODO: 在此添加命令处理程序代码
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | |
|
| | | CString s1;
|
| | | m_bOnline = false;
|
| | |
| | | {
|
| | | SysLog(_T("线程未运行\r\n"));
|
| | | }
|
| | | pDoc->MyKLink1.Close();
|
| | | theApp.MyKLink1.Close();
|
| | | }
|
| | |
|
| | | void CMTerm1CommDevView::OnUpdateMenuOffline(CCmdUI *pCmdUI)
|
| | |
| | | void CMTerm1CommDevView::OnBnClickedButton12()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | CString s1;
|
| | | /*
|
| | | CString s1;
|
| | | pDoc->MyKLink1.MySerPort1.SetParams(1, 115200, _T("8-N-1"));
|
| | | int r = pDoc->MyKLink1.MySerPort1.Open();
|
| | | s1.Format(_T("%d %s"), r, pDoc->MyKLink1.MySerPort1.m_strResult);
|
| | | theApp.MyKLink1.MySerPort1.SetParams(1, 115200, _T("8-N-1"));
|
| | | int r = theApp.MyKLink1.MySerPort1.Open();
|
| | | s1.Format(_T("%d %s"), r, theApp.MyKLink1.MySerPort1.m_strResult);
|
| | | SysLog(s1);
|
| | | */
|
| | | int k = theApp.MyKLink1.ResetDevice(1, 0);
|
| | | s1.Format(_T("ResetDevice = %d"), k);
|
| | | SysLog(s1);
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | | void CMTerm1CommDevView::OnBnClickedButton13()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | // CMTerm1Doc *pDoc = (CMTerm1Doc *)GetDocument();
|
| | | /*
|
| | | CString s1;
|
| | | int r = pDoc->MyKLink1.MySerPort1.Close();
|
| | | s1.Format(_T("%d %s"), r, pDoc->MyKLink1.MySerPort1.m_strResult);
|
| | | int r = theApp.MyKLink1.MySerPort1.Close();
|
| | | s1.Format(_T("%d %s"), r, theApp.MyKLink1.MySerPort1.m_strResult);
|
| | | SysLog(s1);
|
| | |
|
| | | double REPO_RATE(0.0);
|
| | |
| | |
|
| | | }
|
| | |
|
| | | // 热电阻电压转温度 查表
|
| | | const short tempTab[] =
|
| | | {
|
| | | 261, -20,
|
| | | 276, -19,
|
| | | 291, -18,
|
| | | 307, -17,
|
| | | 324, -16,
|
| | | 341, -15,
|
| | | 359, -14,
|
| | | 378, -13,
|
| | | 397, -12,
|
| | | 417, -11,
|
| | | 438, -10,
|
| | | 460, -9,
|
| | | 483, -8,
|
| | | 506, -7,
|
| | | 530, -6,
|
| | | 555, -5,
|
| | | 581, -4,
|
| | | 608, -3,
|
| | | 635, -2,
|
| | | 663, -1,
|
| | | 692, 0,
|
| | | 722, 1,
|
| | | 753, 2,
|
| | | 784, 3,
|
| | | 817, 4,
|
| | | 850, 5,
|
| | | 884, 6,
|
| | | 918, 7,
|
| | | 954, 8,
|
| | | 990, 9,
|
| | | 1026, 10,
|
| | | 1064, 11,
|
| | | 1102, 12,
|
| | | 1140, 13,
|
| | | 1179, 14,
|
| | | 1219, 15,
|
| | | 1259, 16,
|
| | | 1300, 17,
|
| | | 1341, 18,
|
| | | 1383, 19,
|
| | | 1425, 20,
|
| | | 1467, 21,
|
| | | 1509, 22,
|
| | | 1552, 23,
|
| | | 1595, 24,
|
| | | 1638, 25,
|
| | | 1682, 26,
|
| | | 1725, 27,
|
| | | 1768, 28,
|
| | | 1812, 29,
|
| | | 1855, 30,
|
| | | 1899, 31,
|
| | | 1942, 32,
|
| | | 1985, 33,
|
| | | 2028, 34,
|
| | | 2070, 35,
|
| | | 2113, 36,
|
| | | 2155, 37,
|
| | | 2196, 38,
|
| | | 2238, 39,
|
| | | 2279, 40,
|
| | | 2319, 41,
|
| | | 2359, 42,
|
| | | 2399, 43,
|
| | | 2438, 44,
|
| | | 2477, 45,
|
| | | 2515, 46,
|
| | | 2552, 47,
|
| | | 2589, 48,
|
| | | 2626, 49,
|
| | | 2661, 50,
|
| | | 2697, 51,
|
| | | 2731, 52,
|
| | | 2765, 53,
|
| | | 2798, 54,
|
| | | 2831, 55,
|
| | | 2863, 56,
|
| | | 2895, 57,
|
| | | 2926, 58,
|
| | | 2956, 59,
|
| | | 2985, 60,
|
| | | 3014, 61,
|
| | | 3042, 62,
|
| | | 3070, 63,
|
| | | 3097, 64,
|
| | | 3123, 65,
|
| | | 3149, 66,
|
| | | 3174, 67,
|
| | | 3199, 68,
|
| | | 3222, 69,
|
| | | 3246, 70,
|
| | | 3268, 71,
|
| | | 3290, 72,
|
| | | 3312, 73,
|
| | | 3333, 74,
|
| | | 3354, 75,
|
| | | 3374, 76,
|
| | | 3393, 77,
|
| | | 3412, 78,
|
| | | 3430, 79,
|
| | | 3448, 80,
|
| | | 3466, 81,
|
| | | 3483, 82,
|
| | | 3499, 83,
|
| | | 3515, 84,
|
| | | 3531, 85,
|
| | | 3546, 86,
|
| | | 3561, 87,
|
| | | 3575, 88,
|
| | | 3589, 89,
|
| | | 3603, 90,
|
| | | 3616, 91,
|
| | | 3629, 92,
|
| | | 3641, 93,
|
| | | 3653, 94,
|
| | | 3665, 95,
|
| | | 3676, 96,
|
| | | 3687, 97,
|
| | | 3698, 98,
|
| | | 3708, 99,
|
| | | 3719, 100,
|
| | | 3729, 101,
|
| | | 3738, 102,
|
| | | 3747, 103,
|
| | | 3757, 104,
|
| | | 3765, 105,
|
| | | 3774, 106,
|
| | | 3782, 107,
|
| | | 3790, 108,
|
| | | 3798, 109,
|
| | | 3806, 110,
|
| | | };
|
| | |
|
| | | int lookupTempTab(unsigned short value)
|
| | | {
|
| | | int n = sizeof(tempTab) / (sizeof(short) * 2);
|
| | | int p, q, r;
|
| | | p = 0; q = n - 1;
|
| | | r = (p + q) / 2;
|
| | | while (p < q && p != r && q != r) {
|
| | | short tempValue = tempTab[r * 2];
|
| | | if (tempValue == value) { break; }
|
| | | else if (tempValue < value) { p = r; r = (p + q) / 2; }
|
| | | else if (tempValue > value) { q = r; r = (p + q) / 2; }
|
| | | }
|
| | | short value1 = tempTab[r * 2];
|
| | | short temp1 = tempTab[r * 2 + 1] * 10;
|
| | | if (r == n - 1) return temp1;
|
| | | short value2 = tempTab[(r + 1) * 2];
|
| | | short temp2 = tempTab[(r + 1) * 2 + 1] * 10;
|
| | |
|
| | | int temp3 = temp1 + (temp2 - temp1) * (value - value1) / (value2 - value1); // 线性插值
|
| | | return temp3;
|
| | | }
|
| | |
|
| | |
|
| | | void CMTerm1CommDevView::OnBnClickedButton5()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | double a, b, c, d, e;
|
| | | double m = 0;
|
| | | int nCount = 360;
|
| | | int nMaxIndex=0;
|
| | | for (int i = 0; i < nCount; i++)
|
| | | {
|
| | | a = (double)i * 2 * 3.141592653589793238462643383279 / nCount;
|
| | | b = (double)(i+1) * 2 * 3.141592653589793238462643383279 / nCount ;
|
| | |
|
| | | c = (sin(a) + sin(b)) / 2;
|
| | | d = sin((a + b) / 2);
|
| | | e = abs(d - c);
|
| | | if (e > m) { m = e; nMaxIndex = i; }
|
| | |
|
| | | }
|
| | | CString s1;
|
| | | s1.Format(_T("检验查表插值法 计算正弦值 最大误差\r\n"));
|
| | | s1.AppendFormat(_T("0-180 正弦表分为 %d 点, 两点之间进行插值,找最大误差点\r\n"),nCount);
|
| | | s1.AppendFormat(_T("max diff %lf index %d"), m, nMaxIndex);
|
| | | SysLog(s1);
|
| | |
|
| | | nCount = 10;
|
| | | int nDigit = 8;
|
| | | s1.Format(_T("随机输出 %d 个 %d 位数\r\n"),nCount,nDigit);
|
| | | for (int i = 0; i < nCount; i++) {
|
| | | CString s2;
|
| | | for (int j = 0; j < nDigit; j++) {
|
| | | int k = rand() % 10;
|
| | | s2.AppendFormat(_T("%d"), k);
|
| | | }
|
| | | s1 += s2 + _T("\r\n");
|
| | | }
|
| | | SysLog(s1);
|
| | |
|
| | | s1.Empty();
|
| | | CString s2;
|
| | | for (int i = 0; i < 4096; i++) {
|
| | | int j = lookupTempTab(i);
|
| | | s2.Format(_T("%d %d \r\n"), i, j);
|
| | | s1 += s2;
|
| | | }
|
| | | SysLog(s1);
|
| | | }
|
| | |
|
| | |
|
| | | void CMTerm1CommDevView::OnBnClickedButton9()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | // Select File
|
| | | CMTerm1Doc* pDoc = (CMTerm1Doc*)GetDocument();
|
| | | CString s1;
|
| | | USHORT len1;
|
| | | USHORT buf1[1024];
|
| | | int r2 = theApp.MyKLink1.GetInfo(1, &len1, buf1);
|
| | | pKMInfoBlock pinfob = (pKMInfoBlock)buf1;
|
| | | if (r2 == 0 && len1 > 0) {
|
| | | for (int i = 0; i < len1 / 2; i++) {
|
| | | s1.AppendFormat(_T("%04X "), buf1[i]);
|
| | | }
|
| | | s1 += _T("\r\n");
|
| | |
|
| | | s1.AppendFormat(_T(" DeviceType %04X \t "), pinfob->nDeviceTypeVer);
|
| | | s1.AppendFormat(_T(" nProgVer %04X \r\n"), pinfob->nProgVer);
|
| | | }
|
| | | SysLog(s1);
|
| | | myLogger1.UpdateLogDisplay();
|
| | |
|
| | | unsigned char filebuf[65536];
|
| | | unsigned int blocksize = 128;
|
| | | stNewAppInfoBlock NewAppInfo;
|
| | |
|
| | |
|
| | | CFileDialog dialog1(true);
|
| | | INT_PTR r = dialog1.DoModal();
|
| | | if (r == IDOK)
|
| | | {
|
| | | CString sFilePathName = dialog1.GetPathName();
|
| | | //OpenFile
|
| | | CFile file1;
|
| | | CFileException e;
|
| | | bool r = file1.Open(sFilePathName, CFile::modeRead | CFile::typeBinary, &e);
|
| | | s1.Format(_T("Open File %s = %d"), sFilePathName, r);
|
| | | DbgLog(s1);
|
| | | if (r)
|
| | | {
|
| | | int len1 = (int)file1.GetLength();
|
| | | file1.Read(filebuf, len1);
|
| | | file1.Close();
|
| | | unsigned short crc2 = crc16tablefast(filebuf, len1);
|
| | | unsigned char* buf2 = filebuf + 0x1000; ;
|
| | | //s1.Format(_T("GetInfo From File = %d %d \r\n"), j, len1);
|
| | |
|
| | | pKMInfoBlock pinfof = (pKMInfoBlock)buf2;
|
| | |
|
| | |
|
| | | s1.Format(_T(" 目标模块 类型 %04X 版本 %x, \r\n 固件文件 类型 %04X 版本 %x, %d Bytes\r\n 是否继续"), pinfob->nDeviceTypeVer, pinfob->nProgVer,pinfof->nDeviceTypeVer,pinfof->nProgVer,len1);
|
| | | int r3 = AfxMessageBox(s1, MB_YESNO);
|
| | | if (r3 == IDYES) {
|
| | | int bError = 0;
|
| | | for (int i = 0; i < len1; i += blocksize)
|
| | | {
|
| | | int sendsize = len1 - i;
|
| | | if (sendsize > blocksize) { sendsize = blocksize; }
|
| | | int k = 999;
|
| | | int j = 0;
|
| | | double time1 = GetTimemS();
|
| | | for (j = 0; j < 5 && k != 0; j++) {
|
| | | k = theApp.MyKLink1.WriteFirmware(1, 0, i, sendsize, filebuf + i);
|
| | | if (k) {
|
| | | double time2 = GetTimemS();
|
| | | s1.Format(_T("Wr@ %x %dB = %d re %d %.2fmS %s "), i, sendsize, k, j, time2 - time1, theApp.MyKLink1.m_resultStr);
|
| | | SysLog(s1);
|
| | | myLogger1.UpdateLogDisplay();
|
| | | Sleep(30);
|
| | | }
|
| | | }
|
| | | double time2 = GetTimemS();
|
| | | s1.Format(_T("Wr@ %x %dB = %d re %d %.2fmS"), i, sendsize, k, j, time2 - time1);
|
| | | SysLog(s1);
|
| | | myLogger1.UpdateLogDisplay();
|
| | | if (k) { // 出现错误; |
| | | bError = 1; |
| | | CString sErr;
|
| | | sErr = KLink1::GetErrDescStr(k);
|
| | | s1.Format(_T("下载出错 %d, %s"), k,sErr);
|
| | | int r3 = AfxMessageBox(s1);
|
| | | break; //跳出 |
| | | } |
| | | }
|
| | | if (bError == 0) {
|
| | | NewAppInfo.Length = len1;
|
| | | NewAppInfo.Sign = 0x55AA;
|
| | | NewAppInfo.Version = 0x109;
|
| | | NewAppInfo.nCRC = crc2;
|
| | |
|
| | | int k = theApp.MyKLink1.WriteFirmInfo(1, 0, 0, sizeof(NewAppInfo), (UCHAR*)&NewAppInfo);
|
| | | s1.Format(_T("Write InfoBlock %d bytes = %d"), sizeof(NewAppInfo), k);
|
| | | SysLog(s1);
|
| | | Sleep(100);
|
| | | int r5 = theApp.MyKLink1.ResetDevice(1, 0);
|
| | | s1.Format(_T("ResetDevice = %d"), r5);
|
| | | SysLog(s1);
|
| | | myLogger1.UpdateLogDisplay();
|
| | | Sleep(2000);
|
| | | }
|
| | | OnMenuOffline();
|
| | | OnMenuOnline();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|