LAPTOP-SNT8I5JK\Boounion
2024-12-12 016703bb359382dc1de4ac204da47b6f29c55c81
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#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