From bc7f1c4e028e69be51079b59dae4ae5c4d43f5bb Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期六, 31 一月 2026 21:54:56 +0800
Subject: [PATCH] 1.状态指示图,目前灰色表示掉线,绿色表示在线。增加Slot的小点表示有没有料,及加工状态 。 2.增加图示

---
 SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp |  106 +++++++++++++++++++++++++++++------------------------
 1 files changed, 58 insertions(+), 48 deletions(-)

diff --git a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
index 86c978d..d0391cb 100644
--- a/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
+++ b/SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
@@ -10,35 +10,17 @@
 }
 
 // 构造函数
-RecipeManager::RecipeManager() : m_recipeFolder("Recipe") {}
+RecipeManager::RecipeManager() : m_recipeFolder("Recipe"), m_currentRecipeName("") {}
 
-// 设置配方文件夹
-void RecipeManager::setRecipeFolder(const std::string& folderPath) {
-    m_recipeFolder = folderPath;
-}
-
-// 加载配方(如果文件不存在,加载默认数据)
-bool RecipeManager::loadRecipe(const std::string& recipeName) {
-    std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
-    pugi::xml_document doc;
-
-    if (!doc.load_file(filePath.c_str())) {
-        std::cerr << "Recipe file not found: " << filePath << ". Loading default recipe." << std::endl;
-        generateDefaultRecipe();
-        return false; // 文件不存在,但加载了默认数据
-    }
-
+// 加载轴信息
+bool RecipeManager::loadAxes(pugi::xml_node axesNode) {
     m_axes.clear();
-
-    auto recipe = doc.child("Recipe");
-    for (auto axisNode : recipe.child("Axes").children("Axis")) {
+    for (auto axisNode : axesNode.children("Axis")) {
         AxisInfo axisInfo;
         axisInfo.id = axisNode.attribute("id").as_int();
         axisInfo.number = axisNode.attribute("number").value();
         axisInfo.description = axisNode.attribute("description").value();
         axisInfo.startAddress = axisNode.attribute("start_address").value();
-        //axisInfo.maxPositioningSpeed = axisNode.attribute("maxPositioningSpeed").as_double();
-        //axisInfo.maxManualSpeed = axisNode.attribute("maxManualSpeed").as_double();
 
         // 加载 ValueRange 值
         axisInfo.jogDistance = ValueRange(
@@ -68,9 +50,9 @@
         );
 
         // 加载 PositionRange 值
-		axisInfo.positioningPointCount = axisNode.child("Positions").attribute("positioningPointCount").as_int();
+        axisInfo.positioningPointCount = axisNode.child("Positions").attribute("positioningPointCount").as_int();
         for (auto positionNode : axisNode.child("Positions").children("Position")) {
-			bool isEnable = positionNode.attribute("isEnable").as_bool();
+            bool isEnable = positionNode.attribute("isEnable").as_bool();
             std::string description = positionNode.attribute("description").value();
             ValueRange positionRange(
                 positionNode.attribute("min").as_double(),
@@ -87,26 +69,8 @@
     return true;
 }
 
-// 保存配方
-bool RecipeManager::saveRecipe(const std::string& recipeName) {
-    // 生成文件路径
-    std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
-
-    // 创建 XML 文档对象
-    pugi::xml_document doc;
-
-    // 如果轴数据为空,生成默认配方
-    if (m_axes.empty()) {
-        generateDefaultRecipe();
-    }
-
-    // 添加配方根节点
-    auto recipe = doc.append_child("Recipe");
-
-    // 添加轴列表节点
-    auto axesNode = recipe.append_child("Axes");
-
-    // 遍历所有轴数据并写入 XML
+// 保存轴信息
+void RecipeManager::saveAxes(pugi::xml_node& axesNode) {
     for (const auto& axisEntry : m_axes) {
         const AxisInfo& axisInfo = axisEntry.second;
 
@@ -115,8 +79,6 @@
         axisNode.append_attribute("number") = axisInfo.number.c_str();
         axisNode.append_attribute("description") = axisInfo.description.c_str();
         axisNode.append_attribute("start_address") = axisInfo.startAddress.c_str();
-        //axisNode.append_attribute("maxPositioningSpeed") = axisInfo.maxPositioningSpeed;
-        //axisNode.append_attribute("maxManualSpeed") = axisInfo.maxManualSpeed;
 
         // 保存 ValueRange 值
         auto jog_distance = axisNode.append_child("jog_distance");
@@ -156,6 +118,55 @@
             positionNode.append_attribute("current") = position.range.currentValue;
         }
     }
+}
+
+// 设置配方文件夹
+void RecipeManager::setRecipeFolder(const std::string& folderPath) {
+    m_recipeFolder = folderPath;
+}
+
+// 获取当前配方名称
+std::string RecipeManager::getCurrentRecipeName() const {
+	return m_currentRecipeName;
+}
+
+// 加载配方(如果文件不存在,加载默认数据)
+bool RecipeManager::loadRecipe(const std::string& recipeName) {
+    std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
+    pugi::xml_document doc;
+
+    if (!doc.load_file(filePath.c_str())) {
+        std::cerr << "Recipe file not found: " << filePath << ". Loading default recipe." << std::endl;
+        return false; // 文件不存在
+    }
+	m_currentRecipeName = recipeName;
+
+    auto recipeNode = doc.child("Recipe");
+    auto axesNode = recipeNode.child("Axes");
+    loadAxes(axesNode);  // 加载轴信息
+
+    return true;
+}
+
+// 保存配方
+bool RecipeManager::saveRecipe(const std::string& recipeName) {
+    // 生成文件路径
+    std::string filePath = m_recipeFolder + "/" + recipeName + ".xml";
+
+    // 创建 XML 文档对象
+    pugi::xml_document doc;
+
+    // 如果轴数据为空,生成默认配方
+    if (m_axes.empty()) {
+        generateDefaultRecipe();
+    }
+
+    // 添加配方根节点
+    auto recipeNode = doc.append_child("Recipe");
+
+    // 添加轴信息
+    auto axesNode = recipeNode.append_child("Axes");
+    saveAxes(axesNode);
 
     // 保存 XML 文件
     return doc.save_file(filePath.c_str());
@@ -164,13 +175,12 @@
 // 生成默认配方
 void RecipeManager::generateDefaultRecipe() {
     m_axes.clear();
+	m_currentRecipeName = "Default";
 
     for (int axisId = 1; axisId <= 12; ++axisId) {
         AxisInfo axisInfo;
         axisInfo.id = axisId;
         axisInfo.positioningPointCount = 25;
-		//axisInfo.maxPositioningSpeed = 100.0;
-		//axisInfo.maxManualSpeed = 100.0;
         axisInfo.number = "M100-M" + std::to_string(axisId);
         axisInfo.description = "Default_Axis" + std::to_string(axisId);
         axisInfo.startAddress = "ZR" + std::to_string(10000 + (axisId - 1) * 300);

--
Gitblit v1.9.3