LAPTOP-T815PCOQ\25526
2024-12-17 876ad153fd25c0605f516b0f3a6407999db69131
SourceCode/Bond/BondEq/FileManager/RecipeManager.cpp
@@ -10,7 +10,7 @@
}
// 构造函数
RecipeManager::RecipeManager() : m_recipeFolder("Recipe") {}
RecipeManager::RecipeManager() : m_recipeFolder("Recipe"), m_currentRecipeName("") {}
// 加载轴信息
bool RecipeManager::loadAxes(pugi::xml_node axesNode) {
@@ -125,6 +125,11 @@
    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";
@@ -132,9 +137,9 @@
    if (!doc.load_file(filePath.c_str())) {
        std::cerr << "Recipe file not found: " << filePath << ". Loading default recipe." << std::endl;
        generateDefaultRecipe();
        return false; // 文件不存在,但加载了默认数据
        return false; // 文件不存在
    }
   m_currentRecipeName = recipeName;
    auto recipeNode = doc.child("Recipe");
    auto axesNode = recipeNode.child("Axes");
@@ -170,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);