From 326d3e312c74726814c39c9d112faab03c4a167c Mon Sep 17 00:00:00 2001
From: QuakeGod <QuakeGod@sina.com>
Date: 星期日, 16 一月 2022 13:53:57 +0800
Subject: [PATCH] add status show function dialog

---
 MTerm2/MTerm2CommDevView.cpp |   23 +++++++----
 MTerm2/MainFrm.cpp           |    2 
 MTerm2/CDialogStatusShow.cpp |    2 
 MTerm2/KLink.h               |    2 +
 MTerm2/resource.h            |    8 +++
 MTerm2/MTerm2Doc.h           |    1 
 MTerm1/Settings.ini          |    0 
 MTerm2/HvSerialPort.h        |    3 +
 KLink2/KLink.h               |    3 -
 MTerm2/HvSerialPort.cpp      |    6 +-
 MTerm2/MTerm2Doc.cpp         |   23 +++++++++--
 MTerm2/MTerm2.rc             |    0 
 12 files changed, 52 insertions(+), 21 deletions(-)

diff --git a/KLink2/KLink.h b/KLink2/KLink.h
index 5ab4c85..a6fe5e5 100644
--- a/KLink2/KLink.h
+++ b/KLink2/KLink.h
@@ -18,7 +18,7 @@
 
 
 */
-
+//AFX_EXT_CLASS 
 // 此类是从KLink2.dll 导出的
 class KLINK2_API KLink2 {
 
@@ -637,7 +637,6 @@
 	int FinishProgram(UCHAR nDst, UCHAR nType, USHORT nStepSize);
 
 	int ReadRunStat(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
-
 
 };
 
diff --git a/MTerm1/Settings.ini b/MTerm1/Settings.ini
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/MTerm1/Settings.ini
diff --git a/MTerm2/CDialogStatusShow.cpp b/MTerm2/CDialogStatusShow.cpp
index ff1892b..2739947 100644
--- a/MTerm2/CDialogStatusShow.cpp
+++ b/MTerm2/CDialogStatusShow.cpp
@@ -44,7 +44,7 @@
 	// 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
diff --git a/MTerm2/HvSerialPort.cpp b/MTerm2/HvSerialPort.cpp
index ad08a00..49b4dbe 100644
--- a/MTerm2/HvSerialPort.cpp
+++ b/MTerm2/HvSerialPort.cpp
@@ -49,7 +49,7 @@
 		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;
@@ -155,7 +155,7 @@
 
 int HvSerialPort::CalSpeed()
 {
-	double thistime = GetTimeMs();
+	double thistime = GetTimemS();
 	double diftime = thistime - LastTime;
 	if (diftime >= 500)
 	{
@@ -250,7 +250,7 @@
 	int nRunCount = 0;
 	//计算接收速度;
 
-	int LastSpeedTime = (int)GetTimeMs();
+	int LastSpeedTime = (int)GetTimemS();
 	int nThisRecv = 0;
 
 	COMSTAT cs;
diff --git a/MTerm2/HvSerialPort.h b/MTerm2/HvSerialPort.h
index 7d71d47..4a33ff3 100644
--- a/MTerm2/HvSerialPort.h
+++ b/MTerm2/HvSerialPort.h
@@ -2,7 +2,7 @@
 class HvSerialPort
 {
 public:
-	double GetTimeMs()
+	double GetTimemS()
 	{
 		LARGE_INTEGER perfreq;
 		LARGE_INTEGER percounter1;
@@ -64,6 +64,7 @@
 	};
 	~HvSerialPort()
 	{
+		MyThreadProc1ToRun = 0;
 		if (this->m_bOpened) { this->Close(); }
 		this->hCom1 = INVALID_HANDLE_VALUE;
 
diff --git a/MTerm2/KLink.h b/MTerm2/KLink.h
index 42399c9..8cdfb8f 100644
--- a/MTerm2/KLink.h
+++ b/MTerm2/KLink.h
@@ -5,6 +5,7 @@
 */
 #pragma once
 #include "KDefine.h"
+#include "HvSerialPort.h"
 #include <functional>
 class KLink
 {
@@ -15,6 +16,7 @@
 public:
 	KLink();
 	virtual ~KLink();
+	HvSerialPort m_SerialPort;
 #define TYPECOIL 0x00
 #define TYPEDATA 0x80
 	enum enKLCoilTypes
diff --git a/MTerm2/MTerm2.rc b/MTerm2/MTerm2.rc
index a6e7260..4d4d8da 100644
--- a/MTerm2/MTerm2.rc
+++ b/MTerm2/MTerm2.rc
Binary files differ
diff --git a/MTerm2/MTerm2CommDevView.cpp b/MTerm2/MTerm2CommDevView.cpp
index 04b3203..cf8583f 100644
--- a/MTerm2/MTerm2CommDevView.cpp
+++ b/MTerm2/MTerm2CommDevView.cpp
@@ -138,8 +138,8 @@
 //	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()
 
 
@@ -989,7 +989,7 @@
 
 		///*
 		//WY
-		if (nStep == 1)
+		if (nStep == 0)
 		{
 			DataType = pDoc->MyKLink1.KLDataTypeWY;
 			DCount = 16;
@@ -1009,7 +1009,7 @@
 		}
 		///*
 		//WR
-		if (nStep==2)
+		if (nStep==0)
 		{
 			DataType = pDoc->MyKLink1.KLDataTypeWR;
 			DCount = 32;
@@ -1028,7 +1028,7 @@
 		}
 		//*/
 		//DT
-		if (nStep == 3)
+		if (nStep == 1)
 		{
 			DataType = pDoc->MyKLink1.KLDataTypeDT;
 			DCount = 96;
@@ -1048,9 +1048,9 @@
 		}
 		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;
@@ -1071,7 +1071,7 @@
 
 		nStep++;
 //		if (nStep == 2) { nStep = 3; }
-		if (nStep > 7) { nStep = 0; }
+		if (nStep > 4) { nStep = 0; }
 		if (nThisFailCount == 0)
 		{
 			MonitorSuccessCount++;
@@ -2098,5 +2098,12 @@
 	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);
+
+
 }
 
diff --git a/MTerm2/MTerm2Doc.cpp b/MTerm2/MTerm2Doc.cpp
index 4eab988..067073d 100644
--- a/MTerm2/MTerm2Doc.cpp
+++ b/MTerm2/MTerm2Doc.cpp
@@ -27,6 +27,8 @@
 #include <propkey.h>
 
 #include "CDialogCommSet1.h"
+#include "CDialogStatusShow.h"
+
 #include "HvSerialPort.h"
 #include <functional>
 
@@ -122,9 +124,6 @@
 	{OP_MUL,"MUL",3,KLParamWord,"X"},
 	{OP_DIV,"DIV",3,KLParamWord,"/"},
 
-
-
-
 };
 int CMTerm2Doc::nOpDefCount = sizeof(CMTerm2Doc::OpDef) / sizeof(stOpDef);
 
@@ -150,8 +149,11 @@
 	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()
 
 
@@ -163,7 +165,7 @@
 
 	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()
@@ -1912,12 +1914,25 @@
 
 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: 鍦ㄦ娣诲姞鍛戒护澶勭悊绋嬪簭浠g爜
+	CDialogStatusShow dialog1;
+	INT_PTR r = dialog1.DoModal();
+	if (r == IDOK)
+	{
 
 	}
 }
diff --git a/MTerm2/MTerm2Doc.h b/MTerm2/MTerm2Doc.h
index af33870..10965a4 100644
--- a/MTerm2/MTerm2Doc.h
+++ b/MTerm2/MTerm2Doc.h
@@ -277,4 +277,5 @@
 	int AddMonitorData(int nDataType, int nDataAddr, int nDataCount);
 	int ClearMonitor();
 	int DoPLCMonitor(); 
+	afx_msg void OnMenuStatusShow();
 };
diff --git a/MTerm2/MainFrm.cpp b/MTerm2/MainFrm.cpp
index 536e48d..c1df827 100644
--- a/MTerm2/MainFrm.cpp
+++ b/MTerm2/MainFrm.cpp
@@ -78,7 +78,7 @@
 		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) ||
diff --git a/MTerm2/resource.h b/MTerm2/resource.h
index ea41156..88cebdf 100644
--- a/MTerm2/resource.h
+++ b/MTerm2/resource.h
@@ -393,6 +393,12 @@
 #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
@@ -407,7 +413,7 @@
 #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

--
Gitblit v1.9.1