From 723755799a2331ce5f197bffe10af37721c9dcf4 Mon Sep 17 00:00:00 2001
From: darker <mr.darker@163.com>
Date: 星期三, 12 二月 2025 17:45:31 +0800
Subject: [PATCH] 1. 添加 SystemSV 数据 2. 更新指定 ID 的 SystemSV 数据 3. 更新所有 SystemSV 数据 4. 删除指定 ID 的 SystemSV 数据 5.删除所有 SystemSV 数据 6. 添加 EqpSV 数据 7. 添加辅助函数判断VID是否重复和判断名称是否重复
---
SourceCode/Bond/Servo/SECSRuntimeManager.cpp | 286 +++++++++++++++++++++++++++++++++++
SourceCode/Bond/Servo/SECSRuntimeManager.h | 159 +++++++++++++++++--
2 files changed, 424 insertions(+), 21 deletions(-)
diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.cpp b/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
index be4d76d..be02efa 100644
--- a/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
+++ b/SourceCode/Bond/Servo/SECSRuntimeManager.cpp
@@ -39,6 +39,64 @@
return 0;
}
+// 判断VID是否重复
+bool SECSRuntimeManager::isIDDuplicate(int nID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return false;
+ }
+
+ // 定义要检查的表
+ std::vector<std::string> tables = { "SystemSV", "EqpSV", "SystemDV", "EqpDV", "SystemEC", "EqpEC" };
+
+ // 遍历表,检查是否有重复的 ID
+ for (const auto& table : tables) {
+ // 创建 SQL 查询
+ std::string checkSQL = "SELECT COUNT(*) FROM " + table + " WHERE ID = " + std::to_string(nID) + ";";
+
+ // 执行查询
+ auto results = m_pDB->fetchResults(checkSQL);
+ int count = (!results.empty() && !results[0].empty()) ? std::stoi(results[0][0]) : 0;
+
+ // 如果找到了重复的 ID,则返回 true
+ if (count > 0) {
+ return true;
+ }
+ }
+
+ // 如果没有重复,返回 false
+ return false;
+}
+
+// 判断名称是否重复
+bool SECSRuntimeManager::isNameDuplicate(const std::string& sName) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return false;
+ }
+
+ // 定义要检查的表
+ std::vector<std::string> tables = { "SystemSV", "EqpSV", "SystemDV", "EqpDV", "SystemEC", "EqpEC" };
+
+ // 遍历表,检查是否有重复的 Name
+ for (const auto& table : tables) {
+ // 创建 SQL 查询
+ std::string checkSQL = "SELECT COUNT(*) FROM " + table + " WHERE Name = '" + sName + "';";
+
+ // 执行查询
+ auto results = m_pDB->fetchResults(checkSQL);
+ int count = (!results.empty() && !results[0].empty()) ? std::stoi(results[0][0]) : 0;
+
+ // 如果找到了重复的 Name,则返回 true
+ if (count > 0) {
+ return true;
+ }
+ }
+
+ // 如果没有重复,返回 false
+ return false;
+}
+
// 设置数据库连接
void SECSRuntimeManager::setDatabase(BL::Database* db) {
std::lock_guard<std::mutex> lock(m_mutex);
@@ -159,6 +217,201 @@
}
}
+// 添加 SystemSV 数据
+int SECSRuntimeManager::addSystemSV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ if (isIDDuplicate(nID)) {
+ return 2;
+ }
+
+ if (isNameDuplicate(sName)) {
+ return 3;
+ }
+
+ // 如果 Unit 是 "NULL" 字符串或者为空,则插入 NULL 值
+ std::string insertSQL = "INSERT INTO SystemSV (ID, Name, DataType, Length, Unit, Remark, SystemID) VALUES ("
+ + std::to_string(nID) + ", '"
+ + sName + "', '"
+ + sDataType + "', "
+ + (nLength > 0 ? std::to_string(nLength) : "NULL") + ", "
+ + ((sUnit == "NULL" || sUnit.empty()) ? "NULL" : "'" + sUnit + "'") + ", '"
+ + sRemark + "', "
+ + std::to_string(nSystemID) + ");";
+
+ if (!m_pDB->executeQuery(insertSQL)) {
+ return 4;
+ }
+
+ return 0;
+}
+
+// 更新指定 ID 的 SystemSV 数据
+int SECSRuntimeManager::updateIDSystemSV(int nID, int sNewID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ // 检查是否存在该 ID
+ if (!isIDDuplicate(nID)) {
+ return 2;
+ }
+
+ if (isIDDuplicate(sNewID)) {
+ return 3;
+ }
+
+ // 构建更新的 SQL 语句
+ std::string updateSQL = "UPDATE SystemSV SET ID = " + std::to_string(sNewID) + " WHERE ID = " + std::to_string(nID) + ";";
+ if (!m_pDB->executeQuery(updateSQL)) {
+ return 4;
+ }
+
+ return 0;
+}
+
+// 更新所有 SystemSV 数据
+int SECSRuntimeManager::updateAllSystemSV(int nID, int sNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ // 检查是否存在该 ID
+ if (!isIDDuplicate(nID)) {
+ return 2;
+ }
+
+ // 检查新的 ID 是否已存在,如果已存在,则返回错误代码 3。
+ if (isIDDuplicate(sNewID)) {
+ return 3;
+ }
+
+ // 构建更新的 SQL 语句
+ std::string updateSQL = "UPDATE SystemSV SET ";
+
+ bool firstField = true;
+
+ // 如果新的 ID 被提供,更新 ID
+ if (sNewID > 0) {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "ID = " + std::to_string(sNewID);
+ firstField = false;
+ }
+
+ // 更新 Name
+ if (!sName.empty()) {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "Name = '" + sName + "'";
+ firstField = false;
+ }
+
+ // 更新 DataType
+ if (!sDataType.empty()) {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "DataType = '" + sDataType + "'";
+ firstField = false;
+ }
+
+ // 更新 Length
+ if (nLength > 0) {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "Length = " + std::to_string(nLength);
+ firstField = false;
+ }
+
+ // 更新 Unit
+ if (sUnit != "NULL" && !sUnit.empty()) {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "Unit = '" + sUnit + "'";
+ firstField = false;
+ }
+ else if (sUnit == "NULL") {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "Unit = NULL";
+ firstField = false;
+ }
+
+ // 更新 Remark
+ if (!sRemark.empty()) {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "Remark = '" + sRemark + "'";
+ firstField = false;
+ }
+
+ // 更新 SystemID
+ if (nSystemID > 0) {
+ if (!firstField) {
+ updateSQL += ", ";
+ }
+ updateSQL += "SystemID = " + std::to_string(nSystemID);
+ }
+
+ // 添加 WHERE 子句来指定更新哪个记录
+ updateSQL += " WHERE ID = " + std::to_string(nID) + ";";
+
+ // 执行更新操作
+ if (!m_pDB->executeQuery(updateSQL)) {
+ return 4;
+ }
+
+ return 0;
+}
+
+// 删除指定 ID 的 SystemSV 数据
+int SECSRuntimeManager::deleteSystemSVByID(int nID) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ // 检查是否存在该 ID
+ if (!isIDDuplicate(nID)) {
+ return 2;
+ }
+
+ // 构建删除的 SQL 语句
+ std::string deleteSQL = "DELETE FROM SystemSV WHERE ID = " + std::to_string(nID) + ";";
+ if (!m_pDB->executeQuery(deleteSQL)) {
+ return 3;
+ }
+
+ return 0;
+}
+
+int SECSRuntimeManager::deleteAllSystemSV() {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ // 构建删除所有数据的 SQL 语句
+ std::string deleteSQL = "DELETE FROM SystemSV;";
+ if (!m_pDB->executeQuery(deleteSQL)) {
+ return 2;
+ }
+
+ return 0; // 删除成功,返回 0 表示操作成功完成。
+}
+
// 初始化 EqpSV 表
void SECSRuntimeManager::initEqpSVTable() {
std::lock_guard<std::mutex> lock(m_mutex);
@@ -182,6 +435,39 @@
}
}
+// 添加 EqpSV 数据
+int SECSRuntimeManager::addEqpSV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo) {
+ std::lock_guard<std::mutex> lock(m_mutex);
+ if (m_pDB == nullptr) {
+ return 1;
+ }
+
+ if (isIDDuplicate(nID)) {
+ return 2;
+ }
+
+ if (isNameDuplicate(sName)) {
+ return 3;
+ }
+
+ // 构建 SQL 插入语句,插入数据到 EqpSV 表中。
+ std::string insertSQL = "INSERT INTO EqpSV (ID, Name, DataType, Length, Unit, Remark, SeqNo) VALUES ("
+ + std::to_string(nID) + ", '"
+ + sName + "', '"
+ + sDataType + "', "
+ + ((nLength <= 0) ? "NULL" : std::to_string(nLength))+", "
+ + ((sUnit == "NULL" || sUnit.empty()) ? "NULL" : "'" + sUnit + "'")+", '"
+ + sRemark + "', "
+ + std::to_string(nSeqNo) + ");";
+
+ // 执行插入操作,若失败则抛出异常。
+ if (!m_pDB->executeQuery(insertSQL)) {
+ return 4;
+ }
+
+ return 0; // 插入成功,返回 0 表示操作成功完成。
+}
+
// 初始化 SystemDV 表
void SECSRuntimeManager::initSystemDVTable() {
std::lock_guard<std::mutex> lock(m_mutex);
diff --git a/SourceCode/Bond/Servo/SECSRuntimeManager.h b/SourceCode/Bond/Servo/SECSRuntimeManager.h
index 4562c39..8493481 100644
--- a/SourceCode/Bond/Servo/SECSRuntimeManager.h
+++ b/SourceCode/Bond/Servo/SECSRuntimeManager.h
@@ -1,4 +1,4 @@
-#ifndef SECS_RUNTIME_MANAGER_H
+锘�#ifndef SECS_RUNTIME_MANAGER_H
#define SECS_RUNTIME_MANAGER_H
#include <string>
@@ -9,80 +9,191 @@
class SECSRuntimeManager {
public:
/**
- * 获取单例实例
- * @return SECSRuntimeManager实例的引用
+ * 鑾峰彇鍗曚緥瀹炰緥
+ * @return SECSRuntimeManager瀹炰緥鐨勫紩鐢�
*/
static SECSRuntimeManager& getInstance();
/**
- * 设置数据库连接
- * @param db 数据库连接的指针
+ * 璁剧疆鏁版嵁搴撹繛鎺�
+ * @param db 鏁版嵁搴撹繛鎺ョ殑鎸囬拡
*/
void setDatabase(BL::Database* db);
/**
- * 初始化SECS运行设置管理库
- * @return 成功返回true,失败返回false
+ * 鍒濆鍖朣ECS杩愯璁剧疆绠$悊搴�
+ * @return 鎴愬姛杩斿洖true锛屽け璐ヨ繑鍥瀎alse
*/
bool initRuntimeSetting();
/**
- * 销毁SECS运行设置管理库
+ * 閿�姣丼ECS杩愯璁剧疆绠$悊搴�
*/
void termRuntimeSetting();
/**
- * 初始化SystemSV表
+ * 鍒濆鍖朣ystemSV琛�
*/
void initSystemSVTable();
+ /**
+ * 娣诲姞 SystemSV 鏁版嵁
+ * @param nID: 闇�瑕佹坊鍔犵殑 SystemSV 鐨� ID锛屽繀椤绘槸鍞竴鐨勩��
+ * @param sName: 闇�瑕佹坊鍔犵殑 SystemSV 鐨勫悕绉帮紝蹇呴』鏄敮涓�鐨勩��
+ * @param sDataType: 鏁版嵁绫诲瀷锛岃〃绀鸿绯荤粺鍊肩殑绫诲瀷锛屼緥濡� "ASCII"銆�"UINT_1" 绛夈��
+ * @param nLength: 绯荤粺鍊肩殑鏁版嵁闀垮害锛岄�氬父涓轰竴涓鏁存暟锛岀敤浜庤〃绀鸿鏁版嵁鐨勯暱搴︺��
+ * @param sUnit: 绯荤粺鍊肩殑鍗曚綅銆傚鏋滀负绌烘垨鑰呬负 "NULL"锛屽垯鎻掑叆鏁版嵁搴撲腑鐨� NULL 鍊笺��
+ * @param sRemark: 澶囨敞淇℃伅锛屾弿杩拌绯荤粺鍊肩殑鍏朵粬淇℃伅锛屽彲鐢ㄤ簬璇存槑璇ュ瓧娈电殑鐢ㄩ�旀垨鐗规�с��
+ * @param nSystemID: 璇ユ暟鎹墍灞炵殑绯荤粺 ID锛岀敤浜庝笌鍏朵粬琛ㄨ繘琛屽叧鑱斻��
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: ID 閲嶅锛屾棤娉曟彃鍏ユ暟鎹��
+ * @return 3: Name 閲嶅锛屾棤娉曟彃鍏ユ暟鎹��
+ * @return 4: 鎻掑叆鏁版嵁澶辫触銆�
+ * @return 0: 鎻掑叆鎴愬姛锛屾暟鎹凡娣诲姞鍒� SystemSV 琛ㄤ腑銆�
+ *
+ * 姝ゅ嚱鏁扮敤浜庡皢涓�鏉℃柊鐨勬暟鎹彃鍏ュ埌 SystemSV 琛ㄤ腑銆傚畠棣栧厛浼氭鏌ヤ紶鍏ョ殑 `ID` 鍜� `Name` 鏄惁宸插瓨鍦ㄤ簬琛ㄤ腑锛�
+ * 濡傛灉瀛樺湪鍒欒繑鍥炵浉搴旂殑閿欒浠g爜銆傚鏋� `Unit` 鍙傛暟涓� "NULL" 鎴栬�呬负绌猴紝鍑芥暟浼氬皢鍏惰浆鎹负鏁版嵁搴撲腑鐨� NULL 鍊笺��
+ * 鐒跺悗锛屾瀯閫犱竴涓� SQL 鎻掑叆璇彞骞舵墽琛屾彃鍏ユ搷浣溿�傚鏋滄彃鍏ュけ璐ワ紝鍒欐姏鍑哄紓甯搞��
+ * 濡傛灉涓�鍒囬『鍒╋紝杩斿洖 0 琛ㄧず鏁版嵁鎴愬姛鎻掑叆銆�
+ */
+ int addSystemSV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
+
+ /**
+ * 鏇存柊鎸囧畾 ID 鐨� SystemSV 鏁版嵁
+ * @param nID: 闇�瑕佹洿鏂扮殑 SystemSV 鐨勫綋鍓� ID銆�
+ * @param sNewID: 瑕佹洿鏂颁负鐨勬柊 ID銆�
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: 鏈壘鍒版寚瀹氱殑 ID銆�
+ * @return 3: 鏂扮殑 ID 宸茬粡瀛樺湪锛屾棤娉曟洿鏂般��
+ * @return 4: 鏇存柊鎿嶄綔澶辫触銆�
+ * @return 0: 鏇存柊鎴愬姛銆�
+ *
+ * 姝ゅ嚱鏁扮敤浜庢洿鏂� `SystemSV` 琛ㄤ腑鎸囧畾 `nID` 鐨勮褰曪紝灏嗗叾 `ID` 瀛楁鏇存柊涓� `sNewID`銆�
+ * 鍦ㄦ墽琛屾洿鏂板墠锛屽嚱鏁颁細妫�鏌ワ細
+ * 1. 褰撳墠鐨� `nID` 鏄惁瀛樺湪浜庤〃涓��
+ * 2. 鏂扮殑 `sNewID` 鏄惁宸茬粡瀛樺湪浜庤〃涓紝濡傛灉瀛樺湪锛屽垯鏃犳硶杩涜鏇存柊銆�
+ *
+ * 濡傛灉 `nID` 涓嶅瓨鍦紝鍒欒繑鍥為敊璇唬鐮� 2銆傚鏋� `sNewID` 宸茬粡瀛樺湪锛屽垯杩斿洖閿欒浠g爜 3銆�
+ * 濡傛灉鏁版嵁搴撴洿鏂板け璐ワ紝鍒欒繑鍥為敊璇唬鐮� 4銆傛垚鍔熸椂锛岃繑鍥� 0 琛ㄧず鎿嶄綔鎴愬姛銆�
+ */
+ int updateIDSystemSV(int nID, int sNewID);
+
/**
- * 初始化Eqp表
+ * 鏇存柊鎵�鏈� SystemSV 鏁版嵁
+ * @param nID: 闇�瑕佹洿鏂扮殑 SystemSV 鐨勫綋鍓� ID銆�
+ * @param sNewID: 瑕佹洿鏂颁负鐨勬柊 ID锛屽鏋滀负绌烘垨涓� -1锛屽垯涓嶆洿鏂� ID銆�
+ * @param sName: 鏂扮殑鍚嶇О锛屽鏋滀负绌猴紝鍒欎笉鏇存柊銆�
+ * @param sDataType: 鏂扮殑鏁版嵁绫诲瀷锛屽鏋滀负绌猴紝鍒欎笉鏇存柊銆�
+ * @param nLength: 鏂扮殑鏁版嵁闀垮害锛屽鏋滀负璐熷�兼垨闆讹紝鍒欎笉鏇存柊銆�
+ * @param sUnit: 鏂扮殑鍗曚綅锛屽鏋滀负绌烘垨 "NULL"锛屽垯涓嶆洿鏂般��
+ * @param sRemark: 鏂扮殑澶囨敞锛屽鏋滀负绌猴紝鍒欎笉鏇存柊銆�
+ * @param nSystemID: 鏂扮殑绯荤粺 ID锛屽鏋滀负璐熷�硷紝鍒欎笉鏇存柊銆�
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: 娌℃湁鎵惧埌璇� ID 瀵瑰簲鐨勮褰曘��
+ * @return 3: 鏂扮殑 ID 宸茬粡瀛樺湪锛屾棤娉曟洿鏂般��
+ * @return 4: 鏇存柊鎿嶄綔澶辫触銆�
+ * @return 0: 鏇存柊鎴愬姛銆�
+ *
+ * 姝ゅ嚱鏁扮敤浜庢洿鏂版寚瀹� `ID` 鐨� `SystemSV` 鏁版嵁銆傚鏋滄煇涓瓧娈典负绌猴紝鍒欒烦杩囪瀛楁鐨勬洿鏂般��
+ * 濡傛灉缁欏畾鐨� `ID` 涓嶅瓨鍦紝鍒欒繑鍥為敊璇唬鐮� 2銆傚鏋滄柊鐨� `ID` 宸茬粡瀛樺湪锛屽垯杩斿洖閿欒浠g爜 3銆�
+ *
+ * 濡傛灉瀛楁涓虹┖锛岃烦杩囪瀛楁鐨勬洿鏂般��
+ */
+ int updateAllSystemSV(int nID, int sNewID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSystemID);
+
+ /**
+ * 鍒犻櫎鎸囧畾 ID 鐨� SystemSV 鏁版嵁
+ * @param nID: 闇�瑕佸垹闄ょ殑 SystemSV 鐨� ID銆�
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: 鏈壘鍒版寚瀹氱殑 ID 瀵瑰簲鐨勮褰曘��
+ * @return 3: 鍒犻櫎鎿嶄綔澶辫触銆�
+ * @return 0: 鍒犻櫎鎴愬姛銆�
+ *
+ * 姝ゅ嚱鏁扮敤浜庡垹闄� `SystemSV` 琛ㄤ腑鎸囧畾 `nID` 鐨勮褰曘�傚鏋滅粰瀹氱殑 `nID` 涓嶅瓨鍦紝鍒欒繑鍥為敊璇唬鐮� 2銆�
+ * 鍒犻櫎鎿嶄綔鎴愬姛鍚庯紝杩斿洖 0 琛ㄧず鍒犻櫎鎴愬姛銆�
+ */
+ int deleteSystemSVByID(int nID);
+
+ /**
+ * 鍒犻櫎鎵�鏈� SystemSV 鏁版嵁
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: 鍒犻櫎鎿嶄綔澶辫触銆�
+ * @return 0: 鍒犻櫎鎴愬姛銆�
+ *
+ * 姝ゅ嚱鏁扮敤浜庡垹闄� `SystemSV` 琛ㄤ腑鐨勬墍鏈夎褰曘�傚鏋滄暟鎹簱鏈繛鎺ワ紝鍒欒繑鍥為敊璇唬鐮� 1銆�
+ * 濡傛灉鍒犻櫎鎿嶄綔澶辫触锛屽垯杩斿洖閿欒浠g爜 2銆傚垹闄ゆ垚鍔熷悗锛岃繑鍥� 0 琛ㄧず鍒犻櫎鎴愬姛銆�
+ */
+ int deleteAllSystemSV();
+
+ /**
+ * 鍒濆鍖朎qp琛�
*/
void initEqpSVTable();
/**
- * 初始化SystemDV表
+ * 娣诲姞 EqpSV 鏁版嵁
+ * @param nID: 闇�瑕佹坊鍔犵殑 EqpSV 鐨� ID锛屽繀椤绘槸鍞竴鐨勩��
+ * @param sName: 闇�瑕佹坊鍔犵殑 EqpSV 鐨勫悕绉帮紝蹇呴』鏄敮涓�鐨勩��
+ * @param sDataType: 鏁版嵁绫诲瀷锛岃〃绀鸿璁惧鍊肩殑绫诲瀷锛屼緥濡� "ASCII"銆�"UINT_1" 绛夈��
+ * @param nLength: 璁惧鍊肩殑鏁版嵁闀垮害锛岄�氬父涓轰竴涓鏁存暟锛岀敤浜庤〃绀鸿鏁版嵁鐨勯暱搴︺��
+ * @param sUnit: 璁惧鍊肩殑鍗曚綅銆傚鏋滀负绌烘垨鑰呬负 "NULL"锛屽垯鎻掑叆鏁版嵁搴撲腑鐨� NULL 鍊笺��
+ * @param sRemark: 澶囨敞淇℃伅锛屾弿杩拌璁惧鍊肩殑鍏朵粬淇℃伅锛屽彲鐢ㄤ簬璇存槑璇ュ瓧娈电殑鐢ㄩ�旀垨鐗规�с��
+ * @param nSeqNo: 璇ユ暟鎹殑搴忓彿锛岀敤浜庢帓搴忋��
+ * @return 1: 鏁版嵁搴撴湭杩炴帴銆�
+ * @return 2: ID 閲嶅锛屾棤娉曟彃鍏ユ暟鎹��
+ * @return 3: Name 閲嶅锛屾棤娉曟彃鍏ユ暟鎹��
+ * @return 4: 鎻掑叆鏁版嵁澶辫触銆�
+ * @return 0: 鎻掑叆鎴愬姛锛屾暟鎹凡娣诲姞鍒� EqpSV 琛ㄤ腑銆�
+ *
+ * 姝ゅ嚱鏁扮敤浜庡皢涓�鏉℃柊鐨勬暟鎹彃鍏ュ埌 EqpSV 琛ㄤ腑銆傚畠棣栧厛浼氭鏌ヤ紶鍏ョ殑 `ID` 鍜� `Name` 鏄惁宸插瓨鍦ㄤ簬琛ㄤ腑锛�
+ * 濡傛灉瀛樺湪鍒欒繑鍥炵浉搴旂殑閿欒浠g爜銆傚鏋� `Unit` 鍙傛暟涓� "NULL" 鎴栬�呬负绌猴紝鍑芥暟浼氬皢鍏惰浆鎹负鏁版嵁搴撲腑鐨� NULL 鍊笺��
+ * 鐒跺悗锛屾瀯閫犱竴涓� SQL 鎻掑叆璇彞骞舵墽琛屾彃鍏ユ搷浣溿�傚鏋滄彃鍏ュけ璐ワ紝鍒欐姏鍑哄紓甯搞��
+ * 濡傛灉涓�鍒囬『鍒╋紝杩斿洖 0 琛ㄧず鏁版嵁鎴愬姛鎻掑叆銆�
+ */
+ int addEqpSV(int nID, const std::string& sName, const std::string& sDataType, int nLength, const std::string& sUnit, const std::string& sRemark, int nSeqNo);
+
+ /**
+ * 鍒濆鍖朣ystemDV琛�
*/
void initSystemDVTable();
/**
- * 初始化EqpDV表
+ * 鍒濆鍖朎qpDV琛�
*/
void initEqpDVTable();
/**
- * 初始化SystemEC表
+ * 鍒濆鍖朣ystemEC琛�
*/
void initSystemECTable();
/**
- * 初始化EqpEC表
+ * 鍒濆鍖朎qpEC琛�
*/
void initEqpECTable();
/**
- * 初始化SystemEvent表
+ * 鍒濆鍖朣ystemEvent琛�
*/
void initSystemEventTable();
/**
- * 初始化EqpEvent表
+ * 鍒濆鍖朎qpEvent琛�
*/
void initEqpEventTable();
/**
- * 初始化EventLink表
+ * 鍒濆鍖朎ventLink琛�
*/
void initEventLinkTable();
/**
- * 初始化PPID表
+ * 鍒濆鍖朠PID琛�
*/
void initPPIDTable();
/**
- * 初始化RPTID表
+ * 鍒濆鍖朢PTID琛�
*/
void initRPTIDTable();
@@ -90,13 +201,19 @@
SECSRuntimeManager();
~SECSRuntimeManager();
- // 禁止拷贝和赋值
+ // 绂佹鎷疯礉鍜岃祴鍊�
SECSRuntimeManager(const SECSRuntimeManager&) = delete;
SECSRuntimeManager& operator=(const SECSRuntimeManager&) = delete;
- // 从数据库中获取整数
+ // 浠庢暟鎹簱涓幏鍙栨暣鏁�
int getIntFromDB(const std::string& query);
+ // 鍒ゆ柇VID鏄惁閲嶅
+ bool isIDDuplicate(int nID);
+
+ // 鍒ゆ柇鍚嶇О鏄惁閲嶅
+ bool isNameDuplicate(const std::string& sName);
+
BL::Database* m_pDB;
static std::mutex m_mutex;
};
--
Gitblit v1.9.3