From b5e6527c8b3c162340ec3336c3eec0200767c7c9 Mon Sep 17 00:00:00 2001
From: Yao Chunli <56721587@qq.com>
Date: 星期五, 13 五月 2022 08:42:29 +0800
Subject: [PATCH] Merge branch 'dev1' of http://3u015c326.zicp.vip:8111/r/MultiTerminal1 into dev1

---
 MTerm2/DialogEventLog.cpp |  112 +++++++++++++++++++++++++++++--------
 /dev/null                 |    8 --
 MTerm2/resource.h         |    5 +
 MTerm2/MTerm2Doc.h        |    2 
 MTerm2/KLink2.lib         |    0 
 MTerm2/DialogDateTime.cpp |    2 
 MTerm2/DialogEventLog.h   |    6 ++
 MTerm2/MTerm2Doc.cpp      |   25 ++++++++
 MTerm2/MTerm2.rc          |    0 
 9 files changed, 125 insertions(+), 35 deletions(-)

diff --git a/MTerm2/DialogDateTime.cpp b/MTerm2/DialogDateTime.cpp
index 037abec..df4a0d9 100644
--- a/MTerm2/DialogDateTime.cpp
+++ b/MTerm2/DialogDateTime.cpp
@@ -42,7 +42,7 @@
 	CDialogEx::OnInitDialog();
 
 	// TODO:  鍦ㄦ娣诲姞棰濆鐨勫垵濮嬪寲
-	((CButton *)GetDlgItem(IDC_CHECK_SYSTIME))->SetCheck(1);
+	((CButton *)GetDlgItem(IDC_CHECK_SYSTIME))->SetCheck(0);
 	SetTimer(1, 300, NULL);
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
diff --git a/MTerm2/DialogEventLog.cpp b/MTerm2/DialogEventLog.cpp
index f1fe66f..559ae9e 100644
--- a/MTerm2/DialogEventLog.cpp
+++ b/MTerm2/DialogEventLog.cpp
@@ -32,6 +32,7 @@
 BEGIN_MESSAGE_MAP(CDialogEventLog, CDialogEx)
 	ON_BN_CLICKED(IDC_BUTTON_CLEAR_EVENTLOG, &CDialogEventLog::OnBnClickedButtonClearEventlog)
 	ON_BN_CLICKED(IDC_BUTTON_RELOAD, &CDialogEventLog::OnBnClickedButtonReload)
+	ON_WM_TIMER()
 END_MESSAGE_MAP()
 
 KLink::stEventLog KEventLogs[20000];
@@ -87,6 +88,7 @@
 
 	s1.Format(_T("Get EventLogCount Result r=%d  N=%d "), res, nCount);
 	SysLog(s1);
+
 	if (res == pDoc->MyKLink1.KL_OK)
 	{
 		s1.Format(_T("%d"), nCount);
@@ -95,29 +97,14 @@
 	int nStartIndex = 0;
 	int nReadCount = 1;
 	m_list_eventlog.DeleteAllItems();
-	for (int i = 0; i < nCount; i++)
-	{
-		res = pDoc->MyKLink1.GetEventLog(1, i, nReadCount, &KEventLogs[i]);
-		s1.Format(_T(" Get EventLog %d Result r=%d "),i, res);
-		s1.AppendFormat(_T("%d %d %d %d %d %d"), KEventLogs[i].Sign1, KEventLogs[i].Seq1, KEventLogs[i].nTime, KEventLogs[i].nType, KEventLogs[i].nParam1, KEventLogs[i].nParam2);
-		// SysLog(s1);
-		s1.Format(_T("%d"), i);
-		m_list_eventlog.InsertItem(i, s1);
-		s1.Format(_T("%d"), KEventLogs[i].Seq1);
-		m_list_eventlog.SetItemText(i, 1, s1);
 
-		s1.Format(_T("%d"), KEventLogs[i].nTime);
-		CTime ctime1 = KEventLogs[i].nTime;
-		s1 = ctime1.Format(_T("%Y-%m-%d %H:%M:%S"));
-
-		m_list_eventlog.SetItemText(i, 2, s1);
-		s1.Format(_T("%d"), KEventLogs[i].nType);
-		m_list_eventlog.SetItemText(i, 3, s1);
-		s1.Format(_T("%d"), KEventLogs[i].nParam1);
-		m_list_eventlog.SetItemText(i, 4, s1);
-		s1.Format(_T("%d"), KEventLogs[i].nParam2);
-		m_list_eventlog.SetItemText(i, 5, s1);
-	}
+	m_nEventCount = nCount;
+	m_nCurEvent = 0;
+	SetTimer(1, 100, NULL);
+//	for (int i = 0; i < nCount; i++)
+//	{
+//		GetEventLogByIndex(i);
+//	}
 
 	return 0;
 }
@@ -138,10 +125,87 @@
 	m_list_eventlog.InsertColumn(4, _T("鏁版嵁1"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
 	m_list_eventlog.InsertColumn(5, _T("鏁版嵁2"), LVCFMT_LEFT, 128, -1);//LVCFMT_LEFT, LVCFMT_RIGHT, or LVCFMT_CENTER
 
-	GetEventLogStatus();
-	UpLoadEventLog();
+	SetTimer(0, 10, NULL);
 	return TRUE;  // return TRUE unless you set the focus to a control
 				  // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
 }
 
 
+
+int CDialogEventLog::DelayInit()
+{
+	// TODO: 鍦ㄦ澶勬坊鍔犲疄鐜颁唬鐮�.
+	GetEventLogStatus();
+	UpLoadEventLog();
+	return 0;
+}
+
+
+int CDialogEventLog::GetEventLogByIndex(int nIndex)
+{
+	// TODO: 鍦ㄦ澶勬坊鍔犲疄鐜颁唬鐮�.
+	CMDIFrameWnd  *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
+	CMDIChildWnd  *pChild = (CMDIChildWnd   *)pFrame->GetActiveFrame();
+	CView   *pV = (CView*)pChild->GetActiveView();
+	CMTerm2Doc* pDoc = (CMTerm2Doc *)(pV->GetDocument());
+
+	int nReadCount = 1;
+	int res;
+	CString s1;
+
+	res = pDoc->MyKLink1.GetEventLog(1, nIndex, nReadCount, &KEventLogs[nIndex]);
+	s1.Format(_T(" Get EventLog %d Result r=%d "), nIndex, res);
+	s1.AppendFormat(_T("%d %d %d %d %d %d"), KEventLogs[nIndex].Sign1, KEventLogs[nIndex].Seq1, KEventLogs[nIndex].nTime, KEventLogs[nIndex].nType, KEventLogs[nIndex].nParam1, KEventLogs[nIndex].nParam2);
+	// SysLog(s1);
+	s1.Format(_T("%d"), nIndex);
+	m_list_eventlog.InsertItem(nIndex, s1);
+	s1.Format(_T("%d"), KEventLogs[nIndex].Seq1);
+	m_list_eventlog.SetItemText(nIndex, 1, s1);
+
+	s1.Format(_T("%d"), KEventLogs[nIndex].nTime);
+	CTime ctime1 = KEventLogs[nIndex].nTime;
+	s1 = ctime1.Format(_T("%Y-%m-%d %H:%M:%S"));
+
+	m_list_eventlog.SetItemText(nIndex, 2, s1);
+	s1.Format(_T("%d"), KEventLogs[nIndex].nType);
+	m_list_eventlog.SetItemText(nIndex, 3, s1);
+	s1.Format(_T("%d"), KEventLogs[nIndex].nParam1);
+	m_list_eventlog.SetItemText(nIndex, 4, s1);
+	s1.Format(_T("%d"), KEventLogs[nIndex].nParam2);
+	m_list_eventlog.SetItemText(nIndex, 5, s1);
+
+	return 0;
+}
+
+
+void CDialogEventLog::OnTimer(UINT_PTR nIDEvent)
+{
+	// TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
+	if (nIDEvent == 0) {
+		KillTimer(0);
+		DelayInit();
+	}
+	else if (nIDEvent == 1) {
+
+		GetEventProcess();
+	}
+	else
+	{
+
+	}
+	CDialogEx::OnTimer(nIDEvent);
+}
+
+
+
+int CDialogEventLog::GetEventProcess()
+{
+	// TODO: 鍦ㄦ澶勬坊鍔犲疄鐜颁唬鐮�.
+	if (m_nCurEvent < m_nEventCount)
+	{
+		GetEventLogByIndex(m_nCurEvent);
+		m_nCurEvent++;
+		if (m_nCurEvent >= m_nEventCount) { KillTimer(1); }
+	}
+	return 0;
+}
diff --git a/MTerm2/DialogEventLog.h b/MTerm2/DialogEventLog.h
index 477693b..94d8088 100644
--- a/MTerm2/DialogEventLog.h
+++ b/MTerm2/DialogEventLog.h
@@ -27,4 +27,10 @@
 	virtual BOOL OnInitDialog();
 	int UpLoadEventLog();
 	int GetEventLogStatus();
+	int m_nEventCount;
+	int m_nCurEvent;
+	int GetEventLogByIndex(int nIndex);
+	afx_msg void OnTimer(UINT_PTR nIDEvent);
+	int DelayInit();
+	int GetEventProcess();
 };
diff --git a/MTerm2/KLink2.lib b/MTerm2/KLink2.lib
new file mode 100644
index 0000000..0f1defc
--- /dev/null
+++ b/MTerm2/KLink2.lib
Binary files differ
diff --git a/MTerm2/MTerm2.rc b/MTerm2/MTerm2.rc
index 8247f7c..4ce617f 100644
--- a/MTerm2/MTerm2.rc
+++ b/MTerm2/MTerm2.rc
Binary files differ
diff --git a/MTerm2/MTerm2Doc.cpp b/MTerm2/MTerm2Doc.cpp
index 8500f61..95a36ee 100644
--- a/MTerm2/MTerm2Doc.cpp
+++ b/MTerm2/MTerm2Doc.cpp
@@ -30,7 +30,8 @@
 #include "DialogStatusShow.h"
 #include "DialogSysRegSet.h"
 #include "DialogFactCfg.h"
-
+#include "DialogDateTime.h"
+#include "DialogEventLog.h"
 #include "HvSerialPort.h"
 #include <functional>
 
@@ -157,6 +158,8 @@
 	ON_UPDATE_COMMAND_UI(ID_SIMULATE, &CMTerm2Doc::OnUpdateSimulate)
 	ON_COMMAND(ID_MENU_STATUS_SHOW, &CMTerm2Doc::OnMenuStatusShow)
 	ON_COMMAND(ID_MENU_FACT_CFG, &CMTerm2Doc::OnMenuFactCfg)
+	ON_COMMAND(ID_MENU_DATETIME_SET, &CMTerm2Doc::OnMenuDatetimeSet)
+	ON_COMMAND(ID_MENU_EVENT_LOG, &CMTerm2Doc::OnMenuEventLog)
 END_MESSAGE_MAP()
 
 
@@ -1958,4 +1961,24 @@
 	}
 }
 
+void CMTerm2Doc::OnMenuDatetimeSet()
+{
+	// TODO: 鍦ㄦ娣诲姞鍛戒护澶勭悊绋嬪簭浠g爜
+	CDialogDateTime dialog1;
+	INT_PTR r = dialog1.DoModal();
+	if (r == IDOK)
+	{
 
+	}
+}
+
+void CMTerm2Doc::OnMenuEventLog()
+{
+	// TODO: 鍦ㄦ娣诲姞鍛戒护澶勭悊绋嬪簭浠g爜
+	CDialogEventLog dialog1;
+	INT_PTR r = dialog1.DoModal();
+	if (r == IDOK)
+	{
+
+	}
+}
diff --git a/MTerm2/MTerm2Doc.h b/MTerm2/MTerm2Doc.h
index 513e170..724f64e 100644
--- a/MTerm2/MTerm2Doc.h
+++ b/MTerm2/MTerm2Doc.h
@@ -279,4 +279,6 @@
 	int DoPLCMonitor(); 
 	afx_msg void OnMenuStatusShow();
 	afx_msg void OnMenuFactCfg();
+	afx_msg void OnMenuDatetimeSet();
+	afx_msg void OnMenuEventLog();
 };
diff --git a/MTerm2/resource.h b/MTerm2/resource.h
index c370656..c8b2c8a 100644
--- a/MTerm2/resource.h
+++ b/MTerm2/resource.h
@@ -498,6 +498,9 @@
 #define ID_MENU_PLC_INFO_SHOW           33078
 #define ID_33079                        33079
 #define ID_MENU_FACT_CFG                33080
+#define ID_DATETIME_SET                 33081
+#define ID_MENU_DATETIME_SET            33082
+#define ID_MENU_EVENT_LOG               33083
 #define ID_INDICATOR_SEL_TYPE           59135
 #define ID_INDICATOR_MACHINE_TYPE       59142
 #define ID_INDICATOR_PROGRAM_POS        59143
@@ -512,7 +515,7 @@
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        349
-#define _APS_NEXT_COMMAND_VALUE         33081
+#define _APS_NEXT_COMMAND_VALUE         33084
 #define _APS_NEXT_CONTROL_VALUE         1061
 #define _APS_NEXT_SYMED_VALUE           318
 #endif
diff --git a/MultiTerminal1/Settings.ini b/MultiTerminal1/Settings.ini
deleted file mode 100644
index 4c83c76..0000000
--- a/MultiTerminal1/Settings.ini
+++ /dev/null
@@ -1,8 +0,0 @@
-[Model]
-AutoStart=0
-Baud=230400
-LastComPort=2
-Ref1=Ref1
-[Resources]
-Count=Count
-LastAddr=LastAddr

--
Gitblit v1.9.1