| | |
| | | #include "framework.h"
|
| | | #include "MTerm2.h"
|
| | | #include "MTerm2Doc.h"
|
| | | #include "ChildFrm.h"
|
| | |
|
| | | #include "MTerm2CommDevView.h"
|
| | |
|
| | |
| | | #include <SetupAPI.h>
|
| | | #include "../MyLib/Functions.hpp"
|
| | | #include "../MyLib/UI_Func/UI_Func.hpp"
|
| | | #include "CAnsiParser.h"
|
| | | #include "CDataParser1.h"
|
| | | #include "AnsiParser.h"
|
| | | #include "DataParser1.h"
|
| | | #include "KLink.h"
|
| | | //#include "../MyLib/SerialCom/SerialCom.hpp"
|
| | | #include <Dbt.h>
|
| | | #include "CDialogCommSet1.h"
|
| | | #include "CDialogSysRegSet.h"
|
| | | #include "CDialogStatusShow.h"
|
| | | #include "CDialogInfoDisplay.h"
|
| | | #include "DialogCommSet1.h"
|
| | | #include "DialogSysRegSet.h"
|
| | | #include "DialogStatusShow.h"
|
| | | #include "DialogInfoDisplay.h"
|
| | |
|
| | | #include "CDialogCoilMon.h"
|
| | | #include "CDialogDataMon.h"
|
| | | #include "DialogCoilMon.h"
|
| | | #include "DialogDataMon.h"
|
| | |
|
| | | #include "CDialogProgress.h"
|
| | | #include "CDialogEventLog.h"
|
| | | #include "CDialogDateTime.h"
|
| | | #include "CDialogForceIO.h"
|
| | | #include "DialogProgress.h"
|
| | | #include "DialogEventLog.h"
|
| | | #include "DialogDateTime.h"
|
| | | #include "DialogForceIO.h"
|
| | | #include "HvSerialPort.h"
|
| | |
|
| | | #ifdef _DEBUG
|
| | |
| | | // ON_BN_CLICKED(IDC_BUTTON_CLEAR_STAT, &CMTerm2CommDevView::OnBnClickedButtonClearStat)
|
| | | // ON_BN_CLICKED(IDC_BUTTON_READ, &CMTerm2CommDevView::OnBnClickedButtonRead)
|
| | | // ON_BN_CLICKED(IDC_BUTTON11, &CMTerm2CommDevView::OnBnClickedButton11)
|
| | | // ON_BN_CLICKED(IDC_BUTTON12, &CMTerm2CommDevView::OnBnClickedButton12)
|
| | | // ON_BN_CLICKED(IDC_BUTTON13, &CMTerm2CommDevView::OnBnClickedButton13)
|
| | | ON_BN_CLICKED(IDC_BUTTON12, &CMTerm2CommDevView::OnBnClickedButton12)
|
| | | ON_BN_CLICKED(IDC_BUTTON13, &CMTerm2CommDevView::OnBnClickedButton13)
|
| | | ON_BN_CLICKED(IDC_BUTTON31, &CMTerm2CommDevView::OnBnClickedButton31)
|
| | | ON_BN_CLICKED(IDC_BUTTON2, &CMTerm2CommDevView::OnBnClickedButton2)
|
| | | ON_BN_CLICKED(IDC_BUTTON3, &CMTerm2CommDevView::OnBnClickedButton3)
|
| | | END_MESSAGE_MAP()
|
| | |
|
| | |
|
| | |
| | | {
|
| | | CFormView::OnInitialUpdate();
|
| | | // TODO: 在此添加专用代码和/或调用基类
|
| | |
|
| | | // ResizeParentToFit();
|
| | | // ((CChildFrame *)GetParentFrame())->RecalcLayout();
|
| | | m_bResourceOpened = 0;
|
| | |
|
| | | LoadResourceList();
|
| | |
| | | // InitCamera();
|
| | | // InitPlcComm();
|
| | | // InitAnalyzer();
|
| | | SetTimer(1, 50, NULL); //plc
|
| | | SetTimer(1, 20, NULL); //plc
|
| | | SetTimer(3, 300, NULL); //Analyzer
|
| | | SetTimer(4, 1000, NULL); //Speed;
|
| | | m_static_connect.SetCtlColor(RGB(255, 0, 0));
|
| | |
| | | // s1.AppendFormat(_T("Total S %8d \r\nTotal R %8d \r\n"), MySerialCom1.TotalSendBytes, MySerialCom1.TotalRecvBytes);
|
| | | s1 += intToString(pDoc->myHvSerialPort1.TotalRecvBytes) + _T("\r\n");
|
| | | // stepCount++;
|
| | | static double LastCalTime = GetTimemS();
|
| | |
|
| | | static double LastCalTime = 0;
|
| | | double thisTime = GetTimemS();
|
| | | if (thisTime - LastCalTime > 500)
|
| | | {
|
| | |
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | |
|
| | | for (int i = 8; i < (nCount + 15) / 16; i++)
|
| | | {
|
| | | s2.AppendFormat(_T("%3X: "), i * 16);
|
| | | for (int j = 0; j < 16; j++)
|
| | | {
|
| | | s2.AppendFormat(_T("%02X"), pDoc->MyKLink1.MEM.SDB[i * 16 + j]);
|
| | | if (j == 7) { s2.Append(_T(" ")); }
|
| | | else { s2.Append(_T(" ")); }
|
| | | }
|
| | | s2.Append(_T("\r\n"));
|
| | | }
|
| | |
|
| | | // s2.AppendFormat(_T("%d\r\n"), pDoc->MyKLink1.MEM.SDD[5]);
|
| | |
|
| | | nCount = 32;
|
| | |
| | | s1.Empty();
|
| | | s1.Format(_T("主机\r\n"));
|
| | |
|
| | | s1.AppendFormat(_T("跳线 %02X %s 当前 %02X\r\n"), pDoc->MyKLink1.MEM.SDD[0], intToBinString(pDoc->MyKLink1.MEM.SDD[0]), pDoc->MyKLink1.MEM.SDD[1]);
|
| | | 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("Tick计数 %u \r\n"), pDoc->MyKLink1.MEM.SDD[2]);
|
| | | 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]);
|
| | |
| | | s3 = ctime1.Format(_T("%Y-%m-%d %H:%M:%S"));
|
| | | s1.Append(s3 + _T("\r\n"));
|
| | |
|
| | | s1.AppendFormat(_T("12 LastScanTime uS %d \r\n"), pDoc->MyKLink1.MEM.SDD[12]);
|
| | | 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("22 %d \r\n"), pDoc->MyKLink1.MEM.SDD[22]);
|
| | | s1.AppendFormat(_T("23 %d \r\n"), pDoc->MyKLink1.MEM.SDD[23]);
|
| | |
|
| | | float Vref = 1.215f;
|
| | | float V33 = Vref * 4096 / pDoc->MyKLink1.MEM.SDT[55];
|
| | | float Vref = 1.2f;
|
| | | float Vcor = (float)pDoc->MyKLink1.MEM.SDT[53] / pDoc->MyKLink1.MEM.SDT[55];
|
| | | float V33 = 3.3f * Vcor;
|
| | |
|
| | | s1.AppendFormat(_T("24 %d %.3f \r\n"), pDoc->MyKLink1.MEM.SDT[48], pDoc->MyKLink1.MEM.SDT[48] * V33 / 4096 * 11);
|
| | | 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 %d %.3f \r\n"), pDoc->MyKLink1.MEM.SDT[50], pDoc->MyKLink1.MEM.SDT[50] * V33 / 4096 * 2);
|
| | | 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]);
|
| | | s1.AppendFormat(_T("30 %d \r\n"), pDoc->MyKLink1.MEM.SDT[54]);
|
| | | s1.AppendFormat(_T("31 %d %.3f \r\n"), pDoc->MyKLink1.MEM.SDT[55], V33);
|
| | | 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);
|
| | |
|
| | |
|
| | |
|
| | |
| | | //DrawPic1();
|
| | | // MyLogger1.UpdateLogDisplay(0);
|
| | | UpdateDataDisplay();
|
| | | UpdateLEDDisplay();
|
| | | }
|
| | | else if (nIDEvent == 3)
|
| | | {
|
| | |
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWX;
|
| | | DCount = 16;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DCount, DataType, DAddr, &pDoc->MyKLink1.MEM.WXB[DAddr]);
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &pDoc->MyKLink1.MEM.WXB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | {
|
| | |
| | |
|
| | | ///*
|
| | | //WY
|
| | | if (nStep == 1)
|
| | | if (nStep == 0)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWY;
|
| | | DCount = 16;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DCount, DataType, DAddr, &pDoc->MyKLink1.MEM.WYB[DAddr]);
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &pDoc->MyKLink1.MEM.WYB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | {
|
| | |
| | | }
|
| | | ///*
|
| | | //WR
|
| | | if (nStep==2)
|
| | | if (nStep==0)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWR;
|
| | | DCount = 32;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DCount, DataType, DAddr, &pDoc->MyKLink1.MEM.WRB[DAddr]);
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &pDoc->MyKLink1.MEM.WRB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | {
|
| | |
| | | }
|
| | | //*/
|
| | | //DT
|
| | | if (nStep == 3)
|
| | | if (nStep == 1)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeDT;
|
| | | DCount = 96;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DCount, DataType, DAddr, &pDoc->MyKLink1.MEM.DTB[DAddr]);
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, DAddr, DCount, &pDoc->MyKLink1.MEM.DTB[DAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | {
|
| | |
| | | }
|
| | | int ByteAddr = 0;
|
| | | //SDT
|
| | | if (nStep >= 4 && nStep <= 7)
|
| | | if (nStep >= 2 && nStep <= 4)
|
| | | {
|
| | | int nBlock = nStep - 4;
|
| | | int nBlock = nStep - 2;
|
| | | DataType = pDoc->MyKLink1.KLDataTypeSDT;
|
| | | ByteAddr = nBlock * 128;
|
| | | DCount = 128;
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DCount, DataType, ByteAddr, &pDoc->MyKLink1.MEM.SDB[ByteAddr]);
|
| | | res = pDoc->MyKLink1.ReadDataByte(DstAddr, DataType, ByteAddr, DCount, &pDoc->MyKLink1.MEM.SDB[ByteAddr]);
|
| | | nCount = DCount;
|
| | | if (res == pDoc->MyKLink1.KL_OK)
|
| | | {
|
| | |
| | |
|
| | | nStep++;
|
| | | // if (nStep == 2) { nStep = 3; }
|
| | | if (nStep > 7) { nStep = 0; }
|
| | | if (nStep > 4) { nStep = 0; }
|
| | | MonitorSuccessCount += nThisSuccessCount;
|
| | | MonitorFailCount += nThisFailCount;
|
| | | if (nThisFailCount == 0)
|
| | | {
|
| | | MonitorSuccessCount++;
|
| | |
|
| | |
|
| | | }
|
| | | else
|
| | | {
|
| | | MonitorFailCount++;
|
| | |
|
| | | }
|
| | | }
|
| | | return 0;
|
| | |
| | | // s3.Format("%d %d ",recv2length,wCount2);AppendText(s3);
|
| | |
|
| | | s1.Format(_T("R %d(Try %d %d)=%d->"), dNumtoRead, nTryCount, nTryCount2, wCount2);
|
| | | for (DWORD i = 0; i < 8 && i < wCount2; i++)
|
| | | for (DWORD i = 0; i < 16 && i < wCount2; i++)
|
| | | {
|
| | | s1.AppendFormat(_T("%02X "), recv1[i]);
|
| | | }
|
| | |
| | | int r = pDoc->myHvSerialPort1.Close();
|
| | | s1.Format(_T("%d %s"), r, pDoc->myHvSerialPort1.m_strResult);
|
| | | SysLog(s1);
|
| | |
|
| | | double REPO_RATE(0.0);
|
| | | REPO_RATE = _tstof(_T(""));
|
| | | s1.Format(_T("RAPO_RATE = %f \n"), REPO_RATE);
|
| | | SysLog(s1);
|
| | |
|
| | |
|
| | | }
|
| | | enum enStat
|
| | | {
|
| | | normal=0,
|
| | | setchn=1,
|
| | | setvalue=2,
|
| | | setonoff=3,
|
| | |
|
| | | };
|
| | | int nStat = 0;
|
| | | int ntimecount = 0;
|
| | | #define MaxTimeOut 50
|
| | |
|
| | | int nCurChn = 0;
|
| | | int nValue[4] = { 100,200,300,400 };
|
| | | int LedOn[4] = { 0 };
|
| | | int flickTimer = 0;
|
| | | int CMTerm2CommDevView::UpdateLEDDisplay()
|
| | | {
|
| | | // TODO: 在此处添加实现代码.
|
| | | flickTimer++;
|
| | | int bHide = 0;
|
| | | if ((flickTimer & 0x7) > 3) { bHide = 1; }
|
| | |
|
| | | CString s1;
|
| | | s1 = _T("0000");
|
| | |
|
| | | s1.Format(_T("%d%03d"), nCurChn, nValue[nCurChn]);
|
| | | if (nStat == setchn && bHide)
|
| | | {
|
| | | s1.Format(_T(" %03d"), nValue[nCurChn]);
|
| | | }
|
| | | if (nStat == setvalue && bHide)
|
| | | {
|
| | | s1.Format(_T("%d "),nCurChn);
|
| | | }
|
| | | if (nStat == setonoff && bHide)
|
| | | {
|
| | | s1.Format(_T(" "), nCurChn);
|
| | | }
|
| | |
|
| | | SetDlgItemText(IDC_EDIT31, s1);
|
| | |
|
| | | s1.Format(_T("%d %d %d %d"), LedOn[0], LedOn[1], LedOn[2], LedOn[3]);
|
| | | SetDlgItemText(IDC_EDIT32, s1);
|
| | |
|
| | | ntimecount++;
|
| | | if (ntimecount >= MaxTimeOut) { nStat = normal; }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | void CMTerm2CommDevView::OnBnClickedButton31()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | ntimecount = 0;
|
| | | if (nStat == setchn)
|
| | | {
|
| | | nCurChn++;
|
| | | if (nCurChn >= 4) { nCurChn = 0; }
|
| | | }
|
| | | if (nStat == setvalue)
|
| | | {
|
| | | nValue[nCurChn] ++;
|
| | | if (nValue[nCurChn] > 999) { nValue[nCurChn] = 999; }
|
| | | }
|
| | | if (nStat == setonoff)
|
| | | {
|
| | | LedOn[nCurChn] =1;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | void CMTerm2CommDevView::OnBnClickedButton2()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | ntimecount = 0;
|
| | | if (nStat == setchn)
|
| | | {
|
| | | nCurChn--;
|
| | | if (nCurChn <0) { nCurChn = 3; }
|
| | | }
|
| | | if (nStat == setvalue)
|
| | | {
|
| | | nValue[nCurChn] --;
|
| | | if (nValue[nCurChn] <= 0) { nValue[nCurChn] = 0; }
|
| | | }
|
| | | if (nStat == setonoff)
|
| | | {
|
| | | LedOn[nCurChn] = 0;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | void CMTerm2CommDevView::OnBnClickedButton3()
|
| | | {
|
| | | // TODO: 在此添加控件通知处理程序代码
|
| | | ntimecount = 0;
|
| | | if (nStat == normal)
|
| | | {
|
| | | nStat = setchn;
|
| | | } else if (nStat == setchn)
|
| | | {
|
| | | nStat = setvalue;
|
| | | } else if (nStat == setvalue)
|
| | | {
|
| | | nStat = setonoff;
|
| | | }
|
| | | else if (nStat == setonoff)
|
| | | {
|
| | | nStat = setchn;
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | |
|
| | |
|