| | |
| | | } |
| | | |
| | | // 构造函数 |
| | | RecipeManager::RecipeManager() : m_recipeFolder("Recipe") {} |
| | | RecipeManager::RecipeManager() : m_recipeFolder("Recipe"), m_currentRecipeName("") {} |
| | | |
| | | // 加载轴信息 |
| | | bool RecipeManager::loadAxes(pugi::xml_node axesNode) { |
| | |
| | | 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"; |
| | |
| | | |
| | | 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"); |
| | |
| | | // 生成默认配方 |
| | | 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); |