From 8da35975404dd92801b1006f76f2ea6c200016d2 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期四, 05 十二月 2024 09:03:22 +0800
Subject: [PATCH] 1.IO测试页面;
---
SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp | 362 ++++++++++++++++++++++++++++++++++-----------------
1 files changed, 242 insertions(+), 120 deletions(-)
diff --git a/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp b/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
index dfc430a..ad1e83d 100644
--- a/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
+++ b/SourceCode/Bond/BondEq/View/IOMonitoringDlg.cpp
@@ -9,6 +9,12 @@
#define TIMER_INIT 1
#define TIMER_READ_PLC_DATA 2
+#define TIMER_READ_UPDATE 3
+
+#define LABEL_ID_BEGIN 2000
+#define ADDR_WND _T("ADDR_WND")
+
+#define ID_MSG_IO_CLICK WM_USER + 101
// CIOMonitoringDlg 瀵硅瘽妗�
@@ -170,65 +176,40 @@
int colWidthLarge = availableWidth * 4 / 14; // 澶у搴﹀垪姣斾緥
int groupWidth = colWidthSmall * 2 + colWidthLarge; // 姣忕粍鎬诲搴�
+ UINT id = LABEL_ID_BEGIN;
for (int i = 0; i < m_nRowsPerPage; ++i) {
// 姣忎竴琛岀殑璧峰 Y 鍧愭爣
int y = topMargin + i * (rowHeight + verticalSpacing);
// 鍒涘缓绗� 1 缁� (0, 1, 2)
int x = sideMargin; // 浠庡乏杈硅窛寮�濮�
- CreateStaticControl(x, y, colWidthSmall, rowHeight, _T("OFF"), true, AlignCenter);
+ CreateStaticControl(++id, x, y, colWidthSmall, rowHeight, _T("OFF"), true, AlignCenter);
x += colWidthSmall;
- CreateStaticControl(x, y, colWidthSmall, rowHeight, _T("X1000"), false, AlignCenter);
+ CreateStaticControl(++id, x, y, colWidthSmall, rowHeight, _T("X1000"), false, AlignCenter);
x += colWidthSmall;
- CreateStaticControl(x, y, colWidthLarge, rowHeight, _T("鎻忚堪鏂囨湰"), false);
+ CreateStaticControl(++id, x, y, colWidthLarge, rowHeight, _T("鎻忚堪鏂囨湰"), false);
// 绗� 2 缁勮捣濮嬩綅缃紝鍔犱笂缁勯棿璺�
x += colWidthLarge + groupSpacing;
// 鍒涘缓绗� 2 缁� (3, 4, 5)
- CreateStaticControl(x, y, colWidthSmall, rowHeight, _T("OFF"), true, AlignCenter, [this, i]() {
+ id++;
+ CWnd* pBtn = CreateStaticControl(id, x, y, colWidthSmall, rowHeight, _T("OFF"), true, AlignCenter, [this, id, i, x, y]() {
// 鑷畾涔夌偣鍑讳簨浠剁殑閫昏緫
auto* pControl = static_cast<CBLLabel*>(m_staticControls[i * m_nCols + 3]);
CString currentText;
pControl->GetWindowText(currentText);
-
- BOOL bOn = FALSE;
- if (currentText == _T("OFF")) {
- //pControl->SetBkColor(RGB(0, 255, 0)); // 缁胯壊鑳屾櫙
- //pControl->SetText(_T("ON")); // 鏇存柊鏂囨湰涓� ON
- bOn = TRUE;
- }
- else {
- //pControl->SetBkColor(RGB(255, 0, 0)); // 绾㈣壊鑳屾櫙
- //pControl->SetText(_T("OFF")); // 鏇存柊鏂囨湰涓� OFF
- bOn = FALSE;
- }
-
- pControl = static_cast<CBLLabel*>(m_staticControls[i * m_nCols + 4]);
- pControl->GetWindowText(currentText);
-
- int nAddress;
- MC::SOFT_COMPONENT component;
- if (ParsePLCAddress(currentText, component, nAddress) && m_pPLC) {
- TRACE("鍦板潃瑙f瀽鎴愬姛: %s\n", currentText);
- m_pPLC->writeBit(component, nAddress, bOn, [](IMcChannel* pChannel, int addr, DWORD value, int flag) {
- if (flag == 0) {
- TRACE("鍐欏叆鎴愬姛: 鍦板潃: %d, 鍊�: %lu\n", addr, value);
- }
- else {
- TRACE("鍐欏叆澶辫触: 鍦板潃: %d, 閿欒鐮�: %d\n", addr, flag);
- }
- });
- }
+ PostMessage(ID_MSG_IO_CLICK, id, currentText == _T("OFF") ? 1 : 0);
});
x += colWidthSmall;
- CreateStaticControl(x, y, colWidthSmall, rowHeight, _T("Y1010"), false, AlignCenter);
+ CWnd* pLabel = CreateStaticControl(++id, x, y, colWidthSmall, rowHeight, _T("Y1010"), false, AlignCenter);
x += colWidthSmall;
- CreateStaticControl(x, y, colWidthLarge, rowHeight, _T("鎻忚堪鏂囨湰"), false);
+ CreateStaticControl(++id, x, y, colWidthLarge, rowHeight, _T("鎻忚堪鏂囨湰"), false);
+ ::SetProp(pBtn->GetSafeHwnd(), ADDR_WND, pLabel);
}
}
-void CIOMonitoringDlg::CreateStaticControl(int x, int y, int width, int height, const CString& text, bool hasBorder, TextAlign alignment, std::function<void()> clickCallback)
+CWnd* CIOMonitoringDlg::CreateStaticControl(UINT id, int x, int y, int width, int height, const CString& text, bool hasBorder, TextAlign alignment, std::function<void()> clickCallback)
{
// 鍒涘缓鍔ㄦ�佹帶浠�
CBLLabel* pStatic = new CBLLabel();
@@ -236,7 +217,7 @@
if (hasBorder) {
style |= WS_BORDER; // 娣诲姞杈规
}
- pStatic->Create(text, style, CRect(x, y, x + width, y + height), this);
+ pStatic->Create(text, style, CRect(x, y, x + width, y + height), this, id);
// 璁剧疆鏂囨湰瀵归綈鏂瑰紡
pStatic->SetAlignment(alignment);
@@ -255,6 +236,33 @@
// 瀛樺偍鎺т欢鎸囬拡
m_staticControls.push_back(pStatic);
+
+ return pStatic;
+}
+
+CWnd* CIOMonitoringDlg::GetStaticControl(UINT id)
+{
+ for (auto item : m_staticControls) {
+ TRACE(">>id锛�%d\n", item->GetDlgCtrlID());
+ if (item->GetDlgCtrlID() == id) {
+ return item;
+ }
+ }
+
+ return nullptr;
+}
+
+CString& CIOMonitoringDlg::GetStaticControlAddrText(UINT id, CString& strAddr)
+{
+ CWnd* pBtn = GetStaticControl(id);
+ if (pBtn != nullptr) {
+ CWnd* pLabel = (CWnd*)::GetProp(pBtn->GetSafeHwnd(), ADDR_WND);
+ if (pLabel != nullptr) {
+ pLabel->GetWindowText(strAddr);
+ }
+ }
+
+ return strAddr;
}
void CIOMonitoringDlg::DisplayCurrentPage()
@@ -326,109 +334,200 @@
// 鎻愬彇缁勪欢绫诲瀷锛堢涓�涓瓧绗︼級
TCHAR componentChar = address[0];
+ if (address.Left(2) == _T("ZR")) {
+ component = MC::SOFT_COMPONENT::ZR;
+ // 鎻愬彇鏁板瓧閮ㄥ垎锛堝幓闄R鍓嶇紑锛�
+ CString numericAddress = address.Mid(2);
+ addr = _tcstoul(numericAddress, nullptr, 16);
+ return addr != 0 || numericAddress.CompareNoCase(_T("0")) == 0; // 濡傛灉鏄� "0"锛屼篃璁や负鏈夋晥
+ }
+
+ // 瀵逛簬鍏朵粬缁勪欢锛屾寜鐓у父瑙勮鍒欏鐞�
+ CString hexAddress = address.Mid(1);
switch (componentChar) {
case 'D':
component = MC::SOFT_COMPONENT::D;
+ addr = _ttoi(hexAddress);
break;
case 'M':
component = MC::SOFT_COMPONENT::M;
+ addr = _tcstoul(hexAddress, nullptr, 16);
break;
case 'X':
component = MC::SOFT_COMPONENT::X;
+ addr = _tcstoul(hexAddress, nullptr, 16);
break;
case 'Y':
component = MC::SOFT_COMPONENT::Y;
+ addr = _tcstoul(hexAddress, nullptr, 16);
+ break;
+ case 'W':
+ component = MC::SOFT_COMPONENT::W;
+ addr = _tcstoul(hexAddress, nullptr, 16);
+ break;
+ case 'L':
+ component = MC::SOFT_COMPONENT::L;
+ addr = _tcstoul(hexAddress, nullptr, 16);
+ break;
+ case 'S':
+ component = MC::SOFT_COMPONENT::S;
+ addr = _tcstoul(hexAddress, nullptr, 16);
+ break;
+ case 'B':
+ component = MC::SOFT_COMPONENT::B;
+ addr = _tcstoul(hexAddress, nullptr, 16);
+ break;
+ case 'F':
+ component = MC::SOFT_COMPONENT::F;
+ addr = _tcstoul(hexAddress, nullptr, 16);
break;
default:
return false;
}
- CString hexAddress = address.Mid(1);
- addr = _tcstoul(hexAddress, nullptr, 16);
+ // 妫�鏌ュ湴鍧�鏄惁鏈夋晥
+ if (addr == 0 && hexAddress.CompareNoCase(_T("0")) != 0) {
+ return false;
+ }
return true;
}
-void CIOMonitoringDlg::UpdatePLCStates()
+bool CIOMonitoringDlg::GeneratePLCAddress(MC::SOFT_COMPONENT component, int addr, CString& address, bool bHexFormat)
{
- // 绀轰緥锛氫粠 PLC 鑾峰彇鍊硷紝杩欓噷鐢ㄩ殢鏈哄�兼ā鎷�
- //for (size_t i = 0; i < m_inputPLCAddresses.size(); ++i) {
- // // 妯℃嫙鑾峰彇杈撳叆鐘舵��
- // bool inputState = (rand() % 2 == 0); // 鍋跺皵涓� true/false
- // auto* inputControl = static_cast<CBLLabel*>(m_staticControls[i * m_nCols + 0]);
- // inputControl->SetBkColor(inputState ? RGB(0, 255, 0) : RGB(255, 0, 0));
- // inputControl->SetText(inputState ? _T("ON") : _T("OFF"));
- //}
-
- //for (size_t i = 0; i < m_outputPLCAddresses.size(); ++i) {
- // // 妯℃嫙鑾峰彇杈撳嚭鐘舵��
- // bool outputState = (rand() % 2 == 0); // 鍋跺皵涓� true/false
- // auto* outputControl = static_cast<CBLLabel*>(m_staticControls[i * m_nCols + 3]);
- // outputControl->SetBkColor(outputState ? RGB(0, 255, 0) : RGB(255, 0, 0));
- // outputControl->SetText(outputState ? _T("ON") : _T("OFF"));
- //}
-
- // 杈撳叆鍦板潃鐨勮鍙�
- if (!m_inputPLCAddresses.empty()) {
- // 鑾峰彇璧峰鍦板潃鍜岄暱搴�
- CString startAddressStr = m_inputPLCAddresses.front();
- CString endAddressStr = m_inputPLCAddresses.back();
- MC::SOFT_COMPONENT component;
- int startAddress, endAddress;
-
- // 瑙f瀽璧峰鍜岀粨鏉熷湴鍧�
- if (ParsePLCAddress(startAddressStr, component, startAddress) &&
- ParsePLCAddress(endAddressStr, component, endAddress)) {
- int inputSize = endAddress - startAddress + 1;
-
- // 鍥炶皟澶勭悊杈撳叆鏁版嵁
- auto funOnReadInput = [this, startAddress](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) {
- if (nDataSize == (unsigned int)(m_inputPLCAddresses.size()) && flag == 0) {
- for (size_t i = 0; i < m_inputPLCAddresses.size(); ++i) {
- int offset = i;
- int value = CToolUnits::toInt16(&pData[offset]);
-
- auto* inputControl = static_cast<CBLLabel*>(m_staticControls[i * m_nCols + 0]); // 绗� 0 鍒�
- inputControl->SetBkColor(value ? RGB(0, 255, 0) : RGB(255, 0, 0)); // 鏇存柊鑳屾櫙棰滆壊
- inputControl->SetText(value ? _T("ON") : _T("OFF")); // 鏇存柊鏂囨湰
- }
- }
- };
-
- // 璇诲彇杈撳叆鏁版嵁
- m_pPLC->readData(component, startAddress, inputSize, funOnReadInput);
- }
+ // 鏍规嵁缁勪欢绫诲瀷鐢熸垚鍓嶇紑
+ CString prefix;
+ switch (component) {
+ case MC::SOFT_COMPONENT::D:
+ prefix = _T("D");
+ break;
+ case MC::SOFT_COMPONENT::M:
+ prefix = _T("M");
+ break;
+ case MC::SOFT_COMPONENT::X:
+ prefix = _T("X");
+ break;
+ case MC::SOFT_COMPONENT::Y:
+ prefix = _T("Y");
+ break;
+ case MC::SOFT_COMPONENT::W:
+ prefix = _T("W");
+ break;
+ case MC::SOFT_COMPONENT::L:
+ prefix = _T("L");
+ break;
+ case MC::SOFT_COMPONENT::S:
+ prefix = _T("S");
+ break;
+ case MC::SOFT_COMPONENT::B:
+ prefix = _T("B");
+ break;
+ case MC::SOFT_COMPONENT::F:
+ prefix = _T("F");
+ break;
+ case MC::SOFT_COMPONENT::ZR:
+ prefix = _T("ZR");
+ break;
+ default:
+ return false; // 濡傛灉鏄湭鐭ョ粍浠剁被鍨嬶紝杩斿洖澶辫触
}
- // 杈撳嚭鍦板潃鐨勮鍙�
- if (!m_outputPLCAddresses.empty()) {
- // 鑾峰彇璧峰鍦板潃鍜岄暱搴�
- CString startAddressStr = m_outputPLCAddresses.front();
- CString endAddressStr = m_outputPLCAddresses.back();
- MC::SOFT_COMPONENT component;
- int startAddress, endAddress;
+ // 鏍规嵁 bHexFormat 鍒ゆ柇杈撳嚭鏍煎紡
+ CString strAddr;
+ if (bHexFormat) {
+ strAddr.Format(_T("%X"), addr); // 鍗佸叚杩涘埗鏍煎紡
+ }
+ else {
+ strAddr.Format(_T("%d"), addr); // 鍗佽繘鍒舵牸寮�
+ }
- // 瑙f瀽璧峰鍜岀粨鏉熷湴鍧�
- if (ParsePLCAddress(startAddressStr, component, startAddress) &&
- ParsePLCAddress(endAddressStr, component, endAddress)) {
- int outputSize = endAddress - startAddress + 1;
+ // 鐢熸垚鏈�缁堢殑鍦板潃瀛楃涓�
+ address = prefix + strAddr;
+ return true;
+}
- // 鍥炶皟澶勭悊杈撳嚭鏁版嵁
- auto funOnReadOutput = [this, startAddress](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) {
- if (nDataSize == (unsigned int)(m_outputPLCAddresses.size()) && flag == 0) {
- for (size_t i = 0; i < m_outputPLCAddresses.size(); ++i) {
- int offset = i;
- int value = CToolUnits::toInt16(&pData[offset]);
+// 澶勭悊PLC鏁版嵁璇诲彇鐨勯�氱敤鏂规硶
+void CIOMonitoringDlg::ReadPLCData(MC::SOFT_COMPONENT softComponent, int startAddr, int endAddr, std::function<void(IMcChannel*, int, char*, unsigned int, int)> callback)
+{
+ int nSize;
+ // 妫�鏌ュ湴鍧�鏄惁鏈夋晥锛屼互鍙婄粍浠舵槸鍚﹀尮閰�
+ nSize = endAddr - startAddr + 1;
+ if (nSize < 1) {
+ return;
+ }
- auto* outputControl = static_cast<CBLLabel*>(m_staticControls[i * m_nCols + 3]); // 绗� 3 鍒�
- outputControl->SetBkColor(value ? RGB(0, 255, 0) : RGB(255, 0, 0)); // 鏇存柊鑳屾櫙棰滆壊
- outputControl->SetText(value ? _T("ON") : _T("OFF")); // 鏇存柊鏂囨湰
- }
+ // 璇诲彇鏁版嵁
+ m_pPLC->readData(softComponent, startAddr, nSize, callback);
+}
+
+void CIOMonitoringDlg::ReadPLCStates()
+{
+ if (m_displayData.empty()) {
+ return;
+ }
+
+ auto startData = m_displayData.front();
+ auto endData = m_displayData.back();
+ MC::SOFT_COMPONENT startSoftComponent, endSoftComponent;
+ int startAddr, endAddr;
+ ParsePLCAddress(CString(startData.inputAddress.c_str()), startSoftComponent, startAddr);
+ ParsePLCAddress(CString(endData.inputAddress.c_str()), endSoftComponent, endAddr);
+ ASSERT(startSoftComponent == endSoftComponent);
+
+ // 璇诲彇杈撳叆鏁版嵁
+ ReadPLCData(startSoftComponent, startAddr, endAddr, [this, startAddr](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) {
+ for (auto& data : m_displayData) {
+ int nAddress;
+ MC::SOFT_COMPONENT enComponent;
+ if (ParsePLCAddress(CString(data.inputAddress.c_str()), enComponent, nAddress)) {
+ int nOffset = nAddress - startAddr;
+ if (nOffset >= 0 && nOffset < nDataSize) {
+ int byteIndex = nOffset / 8;
+ int bitIndex = nOffset % 8;
+ data.bInputStates = CToolUnits::getBit(pData[byteIndex], bitIndex);
}
- };
+ }
+ }
+ });
- // 璇诲彇杈撳嚭鏁版嵁
- m_pPLC->readData(component, startAddress, outputSize, funOnReadOutput);
+ // 璇诲彇杈撳嚭鏁版嵁
+ int startAddr2, endAddr2;
+ ParsePLCAddress(CString(startData.outputAddress.c_str()), startSoftComponent, startAddr2);
+ ParsePLCAddress(CString(endData.outputAddress.c_str()), endSoftComponent, endAddr2);
+ ASSERT(startSoftComponent == endSoftComponent);
+ ReadPLCData(startSoftComponent, startAddr2, endAddr2, [this, startAddr2](IMcChannel* pChannel, int addr, char* pData, unsigned int nDataSize, int flag) {
+ for (auto& data : m_displayData) {
+ int nAddress;
+ MC::SOFT_COMPONENT enComponent;
+ if (ParsePLCAddress(CString(data.outputAddress.c_str()), enComponent, nAddress)) {
+ int nOffset = nAddress - startAddr2;
+ if (nOffset >= 0 && nOffset < nDataSize) {
+ int byteIndex = nOffset / 8;
+ int bitIndex = nOffset % 8;
+ data.bOutputStates = CToolUnits::getBit(pData[byteIndex], bitIndex);
+ TRACE(">>>> %d %d %d |||| %d\n", nOffset, byteIndex, bitIndex, data.bOutputStates);
+ }
+ }
+ }
+ });
+}
+
+void CIOMonitoringDlg::UpdatePLCStatesToUI()
+{
+ int startIndex = (m_nCurrentPage - 1) * m_nRowsPerPage;
+ int endIndex = min(startIndex + m_nRowsPerPage, static_cast<int>(m_displayData.size()));
+
+ for (int i = 0; i < m_nRowsPerPage; ++i) {
+ int row = i;
+
+ if (startIndex + i < endIndex) {
+ const auto& data = m_displayData[startIndex + i];
+ // 璁剧疆鍐呭鍜岃儗鏅鑹�
+ m_staticControls[row * m_nCols + 0]->SetText(data.bInputStates ? _T("ON") : _T("OFF"));
+ m_staticControls[row * m_nCols + 0]->SetBkColor(data.bInputStates ? RGB(0, 255, 0) : RGB(255, 0, 0));
+
+ m_staticControls[row * m_nCols + 3]->SetText(data.bOutputStates ? _T("ON") : _T("OFF"));
+ m_staticControls[row * m_nCols + 3]->SetBkColor(data.bOutputStates ? RGB(0, 255, 0) : RGB(255, 0, 0));
}
}
}
@@ -436,6 +535,7 @@
BEGIN_MESSAGE_MAP(CIOMonitoringDlg, CDialogEx)
ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CIOMonitoringDlg::OnBnClickedButtonPrevPage)
ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CIOMonitoringDlg::OnBnClickedButtonNextPage)
+ ON_MESSAGE(ID_MSG_IO_CLICK, &CIOMonitoringDlg::OnIoClicked)
ON_WM_SIZE()
ON_WM_TIMER()
ON_WM_CLOSE()
@@ -502,10 +602,9 @@
CreateDynamicControls();
DisplayCurrentPage();
- GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurrentPage > 1);
- GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurrentPage < m_nTotalPages);
SetTimer(TIMER_READ_PLC_DATA, 500, nullptr);
+ SetTimer(TIMER_READ_UPDATE, 200, nullptr);
return TRUE; // return TRUE unless you set the focus to a control
// 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
@@ -537,9 +636,6 @@
else {
AfxMessageBox(_T("宸茬粡鏄涓�椤碉紒"));
}
-
- GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurrentPage > 1);
- GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurrentPage < m_nTotalPages);
}
void CIOMonitoringDlg::OnBnClickedButtonNextPage()
@@ -552,9 +648,30 @@
else {
AfxMessageBox(_T("宸茬粡鏄渶鍚庝竴椤碉紒"));
}
+}
- GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurrentPage > 1);
- GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurrentPage < m_nTotalPages);
+LRESULT CIOMonitoringDlg::OnIoClicked(WPARAM wParam, LPARAM lParam)
+{
+ CString strAddr;
+ GetStaticControlAddrText((UINT)wParam, strAddr);
+
+ BOOL bOn = (BOOL)lParam;
+ int nAddress;
+ MC::SOFT_COMPONENT component;
+ if (ParsePLCAddress(strAddr, component, nAddress) && m_pPLC) {
+ TRACE("鍦板潃瑙f瀽鎴愬姛: %s %d\n", strAddr, GetCurrentThreadId());
+ int n = m_pPLC->writeBit(component, nAddress, bOn, [](IMcChannel* pChannel, int addr, DWORD value, int flag) {
+ if (flag == 0) {
+ TRACE("鍐欏叆鎴愬姛: 鍦板潃: %d, 鍊�: %lu\n", addr, value);
+ }
+ else {
+ TRACE("鍐欏叆澶辫触: 鍦板潃: %d, 閿欒鐮�: %d\n", addr, flag);
+ }
+ });
+ TRACE("鍦板潃瑙f瀽鎴愬姛2: %d\n", n);
+ }
+
+ return 0;
}
void CIOMonitoringDlg::OnTimer(UINT_PTR nIDEvent)
@@ -562,9 +679,13 @@
// TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
if (TIMER_READ_PLC_DATA == nIDEvent) {
ASSERT(m_pPLC);
- UpdatePLCStates();
- Sleep(100);
+ ReadPLCStates();
}
+ else if (TIMER_READ_UPDATE == nIDEvent) {
+ ASSERT(m_pPLC);
+ UpdatePLCStatesToUI();
+ }
+
CDialogEx::OnTimer(nIDEvent);
}
@@ -572,5 +693,6 @@
{
// TODO: 鍦ㄦ娣诲姞娑堟伅澶勭悊绋嬪簭浠g爜鍜�/鎴栬皟鐢ㄩ粯璁ゅ��
KillTimer(TIMER_READ_PLC_DATA);
+ KillTimer(TIMER_READ_UPDATE);
CDialogEx::OnClose();
}
--
Gitblit v1.9.3