LAPTOP-SNT8I5JK\Boounion
2024-12-02 df0863b2c29fa227d186e6b8aeb4a856dcae12f3
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
#ifndef RECIPE_MANAGER_H
#define RECIPE_MANAGER_H
 
#include <string>
#include <vector>
#include <map>
#include "pugixml.hpp"
 
// ÖáÐÅÏ¢½á¹¹Ìå
struct AxisInfo {
    int id;                                    // ÖáID
    std::string number;                        // Öá±àºÅ
    std::string description;                   // ÖáÃèÊö
    std::string startAddress;                  // ÆðʼµØÖ·
    double jogDistance;                        // Î¢¶¯Á¿
    double manualSpeed;                        // ÊÖ¶¯ËÙ¶È
    double autoSpeed;                          // ×Ô¶¯ËÙ¶È
    double accelerationTime;                   // ¼ÓËÙʱ¼ä
    double decelerationTime;                   // ¼õËÙʱ¼ä
    std::vector<std::pair<std::string, double>> 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<std::pair<std::string, double>> getPositions(int axisId, int pageNumber, int pageSize) const;
 
private:
    RecipeManager();
 
private:
    std::string m_recipeFolder;      // Åä·½Îļþ¼Ð·¾¶
    std::map<int, AxisInfo> m_axes;  // ÖáÐÅÏ¢»º´æ
};
 
#endif // RECIPE_MANAGER_H