From 829fe6c6bc33d53fda9c31fd45a37e1df87befff Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 30 一月 2026 11:16:24 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang

---
 SourceCode/Bond/Servo/RecipeManager.h |  150 ++++++++++++++++++++++++++++----------------------
 1 files changed, 84 insertions(+), 66 deletions(-)

diff --git a/SourceCode/Bond/Servo/RecipeManager.h b/SourceCode/Bond/Servo/RecipeManager.h
index f25d36c..70837c0 100644
--- a/SourceCode/Bond/Servo/RecipeManager.h
+++ b/SourceCode/Bond/Servo/RecipeManager.h
@@ -1,4 +1,4 @@
-#ifndef RECIPE_MANAGER_H
+锘�#ifndef RECIPE_MANAGER_H
 #define RECIPE_MANAGER_H
 
 #include <string>
@@ -6,110 +6,128 @@
 #include <mutex>
 #include <unordered_map>
 #include "Database.h"
+#include "CParam.h"
 
-// 单个设备配方映射信息
+
+// 鍗曚釜璁惧閰嶆柟鏄犲皠淇℃伅
 struct DeviceRecipe {
-    int nDeviceID;               // 设备ID
-    int nRecipeID;               // 该设备对应的子配方ID
-    std::string strPPID;         // 配方ID(主键)
-    std::string strDeviceName;   // 设备名称 
+	int nDeviceID;							// 璁惧ID
+	int nRecipeID;							// 瀛愰厤鏂笽D
+	std::string strRecipeName;				// 璁惧鍚嶇О
+	std::string strDeviceName;				// 瀛愰厤鏂瑰悕绉� 
+	std::vector<uint8_t> paramsRawData;     // 鍘熷鍙傛暟鏁版嵁
+	std::vector<CParam*> m_params;			// 鍙傛暟瀵硅薄鍒楄〃
 };
 
-// 配方信息
+// 閰嶆柟淇℃伅
 struct RecipeInfo {
-    std::string strPPID;         // 配方ID
-    std::string strDescription;  // 配方描述
-    std::string strCreateTime;   // 创建时间
-    std::vector<DeviceRecipe> vecDeviceList;  // 关联的设备信息列表
+	std::string strPPID;         // 閰嶆柟ID
+	std::string strDescription;  // 閰嶆柟鎻忚堪
+	std::string strCreateTime;   // 鍒涘缓鏃堕棿
+	std::vector<DeviceRecipe> vecDeviceList;  // 鍏宠仈鐨勮澶囦俊鎭垪琛�
 };
 
-using RecipeMap = std::unordered_map<std::string, RecipeInfo>; // 按 PPID 映射的配方表
+using RecipeMap = std::unordered_map<std::string, RecipeInfo>; // 鎸� PPID 鏄犲皠鐨勯厤鏂硅〃
 
 class RecipeManager {
 public:
-    // 获取单例
-    static RecipeManager& getInstance();
+	// 鑾峰彇鍗曚緥
+	static RecipeManager& getInstance();
 
-    // 初始化配方数据库
-    bool initRecipeTable();
+	// 鍒濆鍖栭厤鏂规暟鎹簱
+	bool initRecipeTable();
 
-    // 销毁表或关闭连接
-    void termRecipeTable();
-    bool destroyRecipeTable();
+	// 閿�姣佽〃鎴栧叧闂繛鎺�
+	void termRecipeTable();
+	bool destroyRecipeTable();
 
-	// 检查 PPID 是否存在
-    bool ppidExists(const std::string& ppid);
+	// 妫�鏌� PPID 鏄惁瀛樺湪
+	bool ppidExists(const std::string& ppid);
 
-	// 检查设备是否存在于指定 PPID 的配方中
+	// 妫�鏌ヨ澶囨槸鍚﹀瓨鍦ㄤ簬鎸囧畾 PPID 鐨勯厤鏂逛腑
 	bool deviceExists(const std::string& ppid, int nDeviceID);
 
-    // 添加一个配方及其设备映射
-    bool addRecipe(const RecipeInfo& recipe);
+	// 娣诲姞涓�涓厤鏂瑰強鍏惰澶囨槧灏�
+	bool addRecipe(const RecipeInfo& recipe);
 
-	// 添加设备到指定配方
-    bool addRecipeDevice(const std::string& ppid, const DeviceRecipe& device);
+	// 娣诲姞璁惧鍒版寚瀹氶厤鏂�
+	bool addRecipeDevice(const std::string& ppid, const DeviceRecipe& device);
 
-	// 删除指定 PPID 的设备配方
-    bool deleteRecipeDeviceByID(const std::string& ppid, int nDeviceID);
+	// 鍒犻櫎鎸囧畾 PPID 鐨勮澶囬厤鏂�
+	bool deleteRecipeDeviceByID(const std::string& ppid, int nDeviceID);
 
-	// 删除指定 PPID 的设备配方(通过设备名称)
-    bool deleteRecipeDeviceByName(const std::string& ppid, const std::string& strDeviceName);
+	// 鍒犻櫎鎸囧畾 PPID 鐨勮澶囬厤鏂癸紙閫氳繃璁惧鍚嶇О锛�
+	bool deleteRecipeDeviceByName(const std::string& ppid, const std::string& strDeviceName);
 
-    // 查询所有配方
-    std::vector<RecipeInfo> getAllRecipes();
+	// 鏌ヨ鎵�鏈夐厤鏂�
+	std::vector<RecipeInfo> getAllRecipes();
 
-	// 根据 PPID 或描述查询配方
-    std::vector<RecipeInfo> getRecipesByKeyword(const std::string& keyword);
+	// 鏍规嵁 PPID 鎴栨弿杩版煡璇㈤厤鏂�
+	std::vector<RecipeInfo> getRecipesByKeyword(const std::string& keyword);
 
-	// 获取所有 PPID
-    std::vector<std::string> getAllPPID() const;
+	// 鑾峰彇鎵�鏈� PPID
+	std::vector<std::string> getAllPPID() const;
 
-    // 按 PPID 查询配方
-    RecipeInfo getRecipeByPPID(const std::string& ppid);
+	// 鎸� ID 鏌ヨ PPID
+	std::string getPPIDById(int nId);
 
-    // 根据 PPID 和设备ID 获取设备配方ID
-    int getDeviceRecipeIDByID(const std::string& ppid, int nDeviceID);
+	// 鎸� PPID 鏌ヨ ID
+	int getIdByPPID(const std::string& ppid);
 
-    // 根据 PPID 和设备名称 获取设备配方ID
-    int getDeviceRecipeIDByName(const std::string& ppid, const std::string& strDeviceName);
+	// 鎸� PPID 鏌ヨ閰嶆柟
+	RecipeInfo getRecipeByPPID(const std::string& ppid);
 
-    // 删除指定 PPID 的配方
-    bool deleteRecipeByPPID(const std::string& ppid);
+	// 鏍规嵁 PPID 鍜岃澶嘔D 鑾峰彇璁惧閰嶆柟ID
+	int getDeviceRecipeIDByID(const std::string& ppid, int nDeviceID);
 
-    // 更新指定 PPID 的配方
-    bool updateRecipe(const RecipeInfo& recipe);
+	// 鏍规嵁 PPID 鍜岃澶囧悕绉� 鑾峰彇璁惧閰嶆柟ID
+	int getDeviceRecipeIDByName(const std::string& ppid, const std::string& strDeviceName);
 
-	// 更新 PPID(通过旧 PPID 和新 PPID)
-    bool updatePPID(const std::string& oldPPID, const std::string& newPPID);
+	// 鍒犻櫎鎸囧畾 PPID 鐨勯厤鏂�
+	bool deleteRecipeByPPID(const std::string& ppid);
 
-	// 更新配方描述(通过 PPID)
-    bool updateDescription(const std::string& ppid, const std::string& newDescription);
+	// 鏇存柊鎸囧畾 PPID 鐨勯厤鏂�
+	bool updateRecipe(const RecipeInfo& recipe);
 
-	// 更新设备配方ID(通过 PPID 和设备ID)
-    bool updateDeviceRecipeIDByID(const std::string& ppid, int nDeviceID, int nNewRecipeID);
+	// 鏇存柊 PPID锛堥�氳繃鏃� PPID 鍜屾柊 PPID锛�
+	bool updatePPID(const std::string& oldPPID, const std::string& newPPID);
 
-	// 更新设备配方ID(通过 PPID 和设备名称)
-    bool updateDeviceRecipeIDByName(const std::string& ppid, const std::string& strDeviceName, int nNewRecipeID);
+	// 鏇存柊閰嶆柟鎻忚堪锛堥�氳繃 PPID锛�
+	bool updateDescription(const std::string& ppid, const std::string& newDescription);
 
-    // 模拟插入数据(测试用)
-    void insertMockData();
+	// 鏇存柊璁惧閰嶆柟ID锛堥�氳繃 PPID 鍜岃澶嘔D锛�
+	bool updateDeviceRecipeIDByID(const std::string& ppid, int nDeviceID, int nNewRecipeID);
 
-    // 读取配方文件(CSV 或 JSON)
-    bool readRecipeFile(const std::string& filename);
+	// 鏇存柊璁惧閰嶆柟ID锛堥�氳繃 PPID 鍜岃澶囧悕绉帮級
+	bool updateDeviceRecipeIDByName(const std::string& ppid, const std::string& strDeviceName, int nNewRecipeID);
 
-    // 保存配方到文件
-    bool saveRecipeFile(const std::string& filename);
+	bool addDeviceRecipe(const std::string& strDeviceName, int nID, const std::string& strName, const std::string& strPara);
+	bool updateDeviceRecipeName(const std::string& strDeviceName, int nID, const std::string& strNewName);
+	bool updateDeviceRecipePara(const std::string& strDeviceName, int nID, const std::string& strNewPara);
+	std::string getDeviceRecipeName(const std::string& strDeviceName, int nID);
+	std::string getDeviceRecipePara(const std::string& strDeviceName, int nID);
+	bool deleteDeviceRecipe(const std::string& strDeviceName, int nID);
+	std::vector<std::pair<int, std::string>> getDeviceRecipes(const std::string& strDeviceName);
+
+	// 妯℃嫙鎻掑叆鏁版嵁锛堟祴璇曠敤锛�
+	void insertMockData();
+
+	// 璇诲彇閰嶆柟鏂囦欢锛圕SV 鎴� JSON锛�
+	bool readRecipeFile(const std::string& filename);
+
+	// 淇濆瓨閰嶆柟鍒版枃浠�
+	bool saveRecipeFile(const std::string& filename);
 
 private:
-    RecipeManager();
-    ~RecipeManager();
+	RecipeManager();
+	~RecipeManager();
 
-    RecipeManager(const RecipeManager&) = delete;
-    RecipeManager& operator=(const RecipeManager&) = delete;
+	RecipeManager(const RecipeManager&) = delete;
+	RecipeManager& operator=(const RecipeManager&) = delete;
 
 private:
-    BL::Database* m_pDB;
-    static std::recursive_mutex m_mutex;
+	BL::Database* m_pDB;
+	static std::recursive_mutex m_mutex;
 };
 
 #endif // RECIPE_MANAGER_H
\ No newline at end of file

--
Gitblit v1.9.3