From f5fa7d2058fec2342c3e3e3955089b8f9f9a630f Mon Sep 17 00:00:00 2001
From: LAPTOP-T815PCOQ\25526 <mr.liuyang@126.com>
Date: 星期五, 10 一月 2025 15:02:15 +0800
Subject: [PATCH] 1. 添加IO模块
---
SourceCode/Bond/BoounionPLC/Model.cpp | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/SourceCode/Bond/BoounionPLC/Model.cpp b/SourceCode/Bond/BoounionPLC/Model.cpp
index b915b33..eac0e4f 100644
--- a/SourceCode/Bond/BoounionPLC/Model.cpp
+++ b/SourceCode/Bond/BoounionPLC/Model.cpp
@@ -75,10 +75,12 @@
g_pModel = this;
- // 模拟从文档或数据库加载PLC列表
- addPlc("Test1", "127.0.0.1", 1001);
- addPlc("Test2", "127.0.0.1", 1002);
-
+ // 获取所有PLC信息
+ std::vector<PlcInfo> plcList;
+ m_configuration.getAllPLCInfo(plcList);
+ for (const auto& plc : plcList) {
+ addPlc(plc.strName, plc.strIp, plc.nPort);
+ }
return 0;
}
@@ -326,6 +328,11 @@
pPLC->init();
m_mapPlc[pszName] = pPLC;
+ CString strDir;
+ strDir.Format(_T("%s\\PLCs\\%s"), (LPTSTR)(LPCTSTR)m_strWorkDir, (LPTSTR)(LPCTSTR)pszName);
+ CToolUnits::createDir(strDir);
+ m_configuration.addPLC(pszName, pszIp, port);
+
notifyPtr(RX_CODE_ADD_PLC, pPLC);
return 0;
}
@@ -335,11 +342,15 @@
auto iter = m_mapPlc.find(pszName);
if (iter == m_mapPlc.end()) return -1;
+ CString strDir;
+ strDir.Format(_T("%s\\PLCs\\%s"), (LPTSTR)(LPCTSTR)m_strWorkDir, (LPTSTR)(LPCTSTR)pszName);
+ CToolUnits::deleteDir(strDir);
+ m_configuration.removePLC(pszName);
+
notifyPtr(RX_CODE_REMOVE_PLC, iter->second);
delete iter->second;
m_mapPlc.erase(iter);
- m_strCurrPlc = "";
return 0;
}
@@ -347,6 +358,8 @@
{
if (pPlc != nullptr) {
m_strCurrPlc = pPlc->getName();
+ } else {
+ m_strCurrPlc = "";
}
}
--
Gitblit v1.9.3