add status show function dialog
| | |
| | |
|
| | |
|
| | | */
|
| | |
|
| | | //AFX_EXT_CLASS |
| | | // 此类是从KLink2.dll 导出的
|
| | | class KLINK2_API KLink2 {
|
| | |
|
| | |
| | | int FinishProgram(UCHAR nDst, UCHAR nType, USHORT nStepSize);
|
| | |
|
| | | int ReadRunStat(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
|
| | |
|
| | |
|
| | | };
|
| | |
|
| | |
| | | // TODO: 在此添加额外的初始化
|
| | | ShowParams();
|
| | | // m_liststatus1.SetExtendedStyle();
|
| | | SetTimer(1, 200, NULL);
|
| | | SetTimer(1, 100, NULL);
|
| | |
|
| | | return TRUE; // return TRUE unless you set the focus to a control
|
| | | // 异常: OCX 属性页应返回 FALSE
|
| | |
| | | m_dwError = GetLastError();
|
| | |
|
| | | m_strResult.Format(_T("COM%d OK."), this->m_nPort);
|
| | | LastTime = GetTimeMs();
|
| | | LastTime = GetTimemS();
|
| | | TotalSendBytes = 0; TotalRecvBytes = 0;
|
| | | LastSendBytes = 0; SendBytes = 0; RecvBytes = 0;
|
| | | LastRecvBytes = 0; SendSpeed = 0; RecvSpeed = 0;
|
| | |
| | |
|
| | | int HvSerialPort::CalSpeed()
|
| | | {
|
| | | double thistime = GetTimeMs();
|
| | | double thistime = GetTimemS();
|
| | | double diftime = thistime - LastTime;
|
| | | if (diftime >= 500)
|
| | | {
|
| | |
| | | int nRunCount = 0;
|
| | | //计算接收速度;
|
| | |
|
| | | int LastSpeedTime = (int)GetTimeMs();
|
| | | int LastSpeedTime = (int)GetTimemS();
|
| | | int nThisRecv = 0;
|
| | |
|
| | | COMSTAT cs;
|
| | |
| | | class HvSerialPort
|
| | | {
|
| | | public:
|
| | | double GetTimeMs()
|
| | | double GetTimemS()
|
| | | {
|
| | | LARGE_INTEGER perfreq;
|
| | | LARGE_INTEGER percounter1;
|
| | |
| | | };
|
| | | ~HvSerialPort()
|
| | | {
|
| | | MyThreadProc1ToRun = 0;
|
| | | if (this->m_bOpened) { this->Close(); }
|
| | | this->hCom1 = INVALID_HANDLE_VALUE;
|
| | |
|
| | |
| | | */
|
| | | #pragma once
|
| | | #include "KDefine.h"
|
| | | #include "HvSerialPort.h"
|
| | | #include <functional>
|
| | | class KLink
|
| | | {
|
| | |
| | | public:
|
| | | KLink();
|
| | | virtual ~KLink();
|
| | | HvSerialPort m_SerialPort;
|
| | | #define TYPECOIL 0x00
|
| | | #define TYPEDATA 0x80
|
| | | enum enKLCoilTypes
|
| | |
| | | // 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)
|
| | | END_MESSAGE_MAP()
|
| | |
|
| | |
|
| | |
| | |
|
| | | ///*
|
| | | //WY
|
| | | if (nStep == 1)
|
| | | if (nStep == 0)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWY;
|
| | | DCount = 16;
|
| | |
| | | }
|
| | | ///*
|
| | | //WR
|
| | | if (nStep==2)
|
| | | if (nStep==0)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeWR;
|
| | | DCount = 32;
|
| | |
| | | }
|
| | | //*/
|
| | | //DT
|
| | | if (nStep == 3)
|
| | | if (nStep == 1)
|
| | | {
|
| | | DataType = pDoc->MyKLink1.KLDataTypeDT;
|
| | | DCount = 96;
|
| | |
| | | }
|
| | | 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;
|
| | |
| | |
|
| | | nStep++;
|
| | | // if (nStep == 2) { nStep = 3; }
|
| | | if (nStep > 7) { nStep = 0; }
|
| | | if (nStep > 4) { nStep = 0; }
|
| | | if (nThisFailCount == 0)
|
| | | {
|
| | | MonitorSuccessCount++;
|
| | |
| | | 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);
|
| | |
|
| | |
|
| | | }
|
| | |
|
| | |
| | | #include <propkey.h>
|
| | |
|
| | | #include "CDialogCommSet1.h"
|
| | | #include "CDialogStatusShow.h"
|
| | |
|
| | | #include "HvSerialPort.h"
|
| | | #include <functional>
|
| | |
|
| | |
| | | {OP_MUL,"MUL",3,KLParamWord,"X"},
|
| | | {OP_DIV,"DIV",3,KLParamWord,"/"},
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | };
|
| | | int CMTerm2Doc::nOpDefCount = sizeof(CMTerm2Doc::OpDef) / sizeof(stOpDef);
|
| | |
|
| | |
| | | ON_COMMAND(ID_MENU_SHOW_CONSOLE, &CMTerm2Doc::OnMenuShowConsole)
|
| | |
|
| | | ON_COMMAND(ID_MENU_COMM_TEST, &CMTerm2Doc::OnMenuCommTest)
|
| | | |
| | | |
| | | ON_COMMAND(ID_SIMULATE, &CMTerm2Doc::OnSimulate)
|
| | | ON_UPDATE_COMMAND_UI(ID_SIMULATE, &CMTerm2Doc::OnUpdateSimulate)
|
| | | ON_COMMAND(ID_MENU_STATUS_SHOW, &CMTerm2Doc::OnMenuStatusShow)
|
| | | END_MESSAGE_MAP()
|
| | |
|
| | |
|
| | |
| | |
|
| | | MyKLink1.SetSendCallBackFunc(std::bind(&CMTerm2Doc::SendPacket, this, std::placeholders::_1, std::placeholders::_2));
|
| | | MyKLink1.SetRecvCallBackFunc(std::bind(&CMTerm2Doc::RecvPacket, this, std::placeholders::_1, std::placeholders::_2));
|
| | | StartTime = myHvSerialPort1.GetTimeMs();
|
| | | StartTime = myHvSerialPort1.GetTimemS();
|
| | | }
|
| | |
|
| | | CMTerm2Doc::~CMTerm2Doc()
|
| | |
| | |
|
| | | void CMTerm2Doc::OnTimer(UINT_PTR nIDEvent)
|
| | | {
|
| | | CString s1;
|
| | | // s1.Format(_T("Doc::OntTimer"));
|
| | | // SysLog(s1);
|
| | | if (m_bSimulate && m_bPlcRunning)
|
| | | {
|
| | | //ProcessPLCProg(Progs, m_nProgSteps);
|
| | | myKMachine1.ProcPLC();
|
| | |
|
| | | // update PLC Stat
|
| | | }
|
| | | }
|
| | |
|
| | | void CMTerm2Doc::OnMenuStatusShow()
|
| | | {
|
| | | // TODO: 在此添加命令处理程序代码
|
| | | CDialogStatusShow dialog1;
|
| | | INT_PTR r = dialog1.DoModal();
|
| | | if (r == IDOK)
|
| | | {
|
| | |
|
| | | }
|
| | | }
|
| | |
| | | int AddMonitorData(int nDataType, int nDataAddr, int nDataCount);
|
| | | int ClearMonitor();
|
| | | int DoPLCMonitor();
|
| | | afx_msg void OnMenuStatusShow();
|
| | | };
|
| | |
| | | return -1; // 未能创建
|
| | | }
|
| | |
|
| | | ///*
|
| | | ///* 输入栏
|
| | | if (!m_wndToolBar_InputShow.CreateEx(this, TBSTYLE_FLAT,
|
| | | WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_FLOAT_MULTI | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,
|
| | | CRect(1, 1, 1, 1), IDW_TOOL_BAR2) ||
|
| | |
| | | #define ID_BUTTON33068 33068
|
| | | #define ID_33069 33069
|
| | | #define ID_SIMULATE 33070
|
| | | #define ID_MENU_STATUS_SHOW 33073
|
| | | #define ID_PLC_INFO_DISPLAY 33074
|
| | | #define ID_PLC_INFO_SHOW 33075
|
| | | #define ID_MENU_DATA_MON 33076
|
| | | #define ID_MENU_COIL_MON 33077
|
| | | #define ID_MENU_PLC_INFO_SHOW 33078
|
| | | #define ID_INDICATOR_SEL_TYPE 59135
|
| | | #define ID_INDICATOR_MACHINE_TYPE 59142
|
| | | #define ID_INDICATOR_PROGRAM_POS 59143
|
| | |
| | | #ifdef APSTUDIO_INVOKED
|
| | | #ifndef APSTUDIO_READONLY_SYMBOLS
|
| | | #define _APS_NEXT_RESOURCE_VALUE 336
|
| | | #define _APS_NEXT_COMMAND_VALUE 33073
|
| | | #define _APS_NEXT_COMMAND_VALUE 33079
|
| | | #define _APS_NEXT_CONTROL_VALUE 1016
|
| | | #define _APS_NEXT_SYMED_VALUE 317
|
| | | #endif
|