#ifndef RECIPE_MANAGER_H
|
#define RECIPE_MANAGER_H
|
|
#include <string>
|
#include <vector>
|
#include <map>
|
#include "pugixml.hpp"
|
|
struct ValueRange {
|
double minValue; // ×îСֵ
|
double maxValue; // ×î´óÖµ
|
double currentValue; // µ±Ç°Öµ
|
|
// ¹¹Ô캯Êý³õʼ»¯
|
ValueRange(double minVal = 0.0, double maxVal = 0.0, double curVal = 0.0)
|
: minValue(minVal), maxValue(maxVal), currentValue(curVal) {}
|
};
|
|
struct PositionRange {
|
BOOL isEnable; // ÊÇ·ñÆôÓÃ
|
std::string description; // ¶¨Î»µãÃèÊö
|
ValueRange range; // λÖõÄ×îСֵ¡¢×î´óÖµºÍµ±Ç°Öµ
|
|
// ¹¹Ô캯Êý³õʼ»¯
|
PositionRange(BOOL b = TRUE, const std::string& desc = "", const ValueRange& r = ValueRange())
|
:isEnable(b), description(desc), range(r) {}
|
};
|
|
// ÖáÐÅÏ¢½á¹¹Ìå
|
struct AxisInfo {
|
int id; // ÖáID
|
int positioningPointCount; // ¶¨Î»µãÊý
|
//double maxPositioningSpeed; // ¶¨Î»ËÙ¶ÈÉÏÏÞ
|
//double maxManualSpeed; // ÊÖ¶¯ËÙ¶ÈÉÏÏÞ
|
std::string number; // Öá±àºÅ
|
std::string description; // ÖáÃèÊö
|
std::string startAddress; // ÆðʼµØÖ·
|
ValueRange jogDistance; // ΢¶¯Á¿£¨×îСֵ¡¢×î´óÖµ¡¢µ±Ç°Öµ£©
|
ValueRange manualSpeed; // ÊÖ¶¯ËÙ¶È£¨×îСֵ¡¢×î´óÖµ¡¢µ±Ç°Öµ£©
|
ValueRange autoSpeed; // ×Ô¶¯ËÙ¶È£¨×îСֵ¡¢×î´óÖµ¡¢µ±Ç°Öµ£©
|
ValueRange accelerationTime; // ¼ÓËÙʱ¼ä£¨×îСֵ¡¢×î´óÖµ¡¢µ±Ç°Öµ£©
|
ValueRange decelerationTime; // ¼õËÙʱ¼ä£¨×îСֵ¡¢×î´óÖµ¡¢µ±Ç°Öµ£©
|
std::vector<PositionRange> positions; // ¶¨Î»µã£ºÃèÊö¡¢Î»Öü°×îС×î´óÖµ
|
};
|
|
// Åä·½¹ÜÀíÀà
|
class RecipeManager {
|
public:
|
// µ¥Àýģʽ»ñȡʵÀý
|
static RecipeManager& getInstance();
|
|
// ÉèÖÃÅä·½Îļþ¼Ð·¾¶
|
void setRecipeFolder(const std::string& folderPath);
|
|
// ¼ÓÔØÅä·½£¨Îļþ²»´æÔÚʱ¼ÓÔØÄ¬ÈÏÊý¾Ý£©
|
bool loadRecipe(const std::string& recipeName);
|
|
// ±£´æÅä·½
|
bool saveRecipe(const std::string& recipeName);
|
|
// Éú³ÉĬÈÏÅä·½
|
void generateDefaultRecipe();
|
|
// »ñÈ¡ËùÓÐÖáÐÅÏ¢
|
const std::map<int, AxisInfo>& getAxes() const;
|
|
// »ñÈ¡µ¥¸öÖáÐÅÏ¢
|
AxisInfo getAxis(int axisId) const;
|
|
// ¸üÐÂÖáÐÅÏ¢
|
bool updateAxis(const AxisInfo& axisInfo);
|
|
// Ìí¼ÓеÄÖáÐÅÏ¢
|
bool addAxis(const AxisInfo& axisInfo);
|
|
// ɾ³ýÖáÐÅÏ¢
|
bool deleteAxis(int axisId);
|
|
// »ñÈ¡ËùÓÐÖáID
|
std::vector<int> getAllAxisID() const;
|
|
// »ñȡָ¶¨Ò³µÄ¶¨Î»µã
|
std::vector<PositionRange> getPositions(int axisId, int pageNumber, int pageSize) const;
|
|
// »ñȡָ¶¨Ò³µÄ¶¨Î»µã
|
PositionRange getPositionByIndex(int axisId, int pageNumber, int pageSize, int currentIndex) const;
|
|
private:
|
RecipeManager();
|
|
private:
|
std::string m_recipeFolder; // Åä·½Îļþ¼Ð·¾¶
|
std::map<int, AxisInfo> m_axes; // ÖáÐÅÏ¢»º´æ
|
};
|
|
#endif // RECIPE_MANAGER_H
|