Subversion Repositories tpanel

Rev

Rev 165 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 165 Rev 193
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 23... Line 23...
23
#include <vector>
23
#include <vector>
24
#include <functional>
24
#include <functional>
25
 
25
 
26
#include "tbutton.h"
26
#include "tbutton.h"
27
#include "tvalidatefile.h"
27
#include "tvalidatefile.h"
-
 
28
#include "tmap.h"
28
 
29
 
29
class TPage;
30
class TPage;
30
class TSubPage;
31
class TSubPage;
31
 
32
 
32
typedef struct PCHAIN_T
33
typedef struct PCHAIN_T
Line 39... Line 40...
39
{
40
{
40
    TSubPage *page{nullptr};
41
    TSubPage *page{nullptr};
41
    SPCHAIN_T *next{nullptr};
42
    SPCHAIN_T *next{nullptr};
42
}SPCHAIN_T;
43
}SPCHAIN_T;
43
 
44
 
44
// Pages with buttons
-
 
45
typedef struct MAP_T
-
 
46
{
-
 
47
    int p{0};           // port number
-
 
48
    int c{0};           // channel number
-
 
49
    int ax{0};          // ??
-
 
50
    int pg{0};          // page number
-
 
51
    int bt{0};          // button number
-
 
52
    std::string pn;     // page name
-
 
53
    std::string bn;     // button name
-
 
54
}MAP_T;
-
 
55
 
-
 
56
// Images
-
 
57
typedef struct MAP_BM_T
-
 
58
{
-
 
59
    std::string i;      // image file name
-
 
60
    int id{0};
-
 
61
    int rt{0};
-
 
62
    int pg{0};          // page number
-
 
63
    int bt{0};          // button number
-
 
64
    int st{0};          // button instance
-
 
65
    int sl{0};
-
 
66
    std::string pn;     // page name
-
 
67
    std::string bn;     // button name
-
 
68
}MAP_BM_T;
-
 
69
 
-
 
70
typedef struct MAP_PM_T
-
 
71
{
-
 
72
    int a{0};
-
 
73
    std::string t;      // Group name
-
 
74
    int pg{0};          // page number
-
 
75
    int bt{0};          // button number
-
 
76
    std::string pn;     // page name
-
 
77
    std::string bn;     // button name
-
 
78
}MAP_PM_T;
-
 
79
 
-
 
80
typedef struct MAPS_T
-
 
81
{
-
 
82
    std::vector<MAP_T> map_cm;
-
 
83
    std::vector<MAP_T> map_am;
-
 
84
    std::vector<MAP_T> map_lm;
-
 
85
    std::vector<MAP_BM_T> map_bm;       // Images
-
 
86
    std::vector<std::string> map_sm;    // sound file names
-
 
87
    std::vector<MAP_T> map_strm;        // System resources
-
 
88
    std::vector<MAP_PM_T> map_pm;       // Button -> text
-
 
89
}MAPS_T;
-
 
90
 
-
 
91
class TAmxCommands : public TValidateFile
45
class TAmxCommands : public TValidateFile
92
{
46
{
93
    public:
47
    public:
94
        typedef struct CMD_TABLE
48
        typedef struct CMD_TABLE
95
        {
49
        {
Line 97... Line 51...
97
            std::vector<int> channels;      // Channels the command affects (200&210, ...)
51
            std::vector<int> channels;      // Channels the command affects (200&210, ...)
98
            std::vector<std::string> pars;  // Rest of parameters of the command
52
            std::vector<std::string> pars;  // Rest of parameters of the command
99
            std::function<void (int port, std::vector<int>& channels, std::vector<std::string>& pars)> command{nullptr};
53
            std::function<void (int port, std::vector<int>& channels, std::vector<std::string>& pars)> command{nullptr};
100
        }CMD_TABLE;
54
        }CMD_TABLE;
101
 
55
 
102
        typedef enum MAP_TYPE
-
 
103
        {
-
 
104
            TYPE_CM = 1,    // ON / OFF
-
 
105
            TYPE_AM,        // TXT, ...
-
 
106
            TYPE_LM        // Bargraphs
-
 
107
        }MAP_TYPE;
-
 
108
 
-
 
109
        TAmxCommands();
56
        TAmxCommands();
110
        ~TAmxCommands();
57
        ~TAmxCommands();
111
 
58
 
112
        void setPChain(PCHAIN_T *ch) { mPChain = ch; }
59
        void setPChain(PCHAIN_T *ch) { mPChain = ch; }
113
        void setSPChain(SPCHAIN_T *ch) { mSPChain = ch; }
60
        void setSPChain(SPCHAIN_T *ch) { mSPChain = ch; }
114
        bool parseCommand(int device, int port, const std::string& cmd);
61
        bool parseCommand(int device, int port, const std::string& cmd);
115
        std::vector<MAP_T> findButtons(int port, std::vector<int>& channels, MAP_TYPE mt = TYPE_AM);
62
        std::vector<TMap::MAP_T> findButtons(int port, std::vector<int>& channels, TMap::MAP_TYPE mt = TMap::TYPE_AM);
116
        std::string findImage(int bt, int page, int instance=0);
63
        std::string findImage(int bt, int page, int instance=0);
117
        std::string findImage(const std::string& name);
64
        std::string findImage(const std::string& name);
118
        std::vector<MAP_T> findButtonByName(const std::string& name);
65
        std::vector<TMap::MAP_T> findButtonByName(const std::string& name);
119
        std::vector<MAP_T> findBargraphs(int port, std::vector<int>& channels);
66
        std::vector<TMap::MAP_T> findBargraphs(int port, std::vector<int>& channels);
120
        std::vector<std::string> findSounds();
67
        std::vector<std::string> findSounds();
121
        bool soundExist(const std::string& sname);
68
        bool soundExist(const std::string& sname);
122
        void registerCommand(std::function<void (int port, std::vector<int>& channels, std::vector<std::string>& pars)> command, const std::string& name);
69
        void registerCommand(std::function<void (int port, std::vector<int>& channels, std::vector<std::string>& pars)> command, const std::string& name);
123
 
70
 
124
    protected:
71
    protected:
Line 129... Line 76...
129
        std::vector<std::string> getFields(std::string& msg, char sep);
76
        std::vector<std::string> getFields(std::string& msg, char sep);
130
 
77
 
131
        std::vector<CMD_TABLE> mCmdTable;
78
        std::vector<CMD_TABLE> mCmdTable;
132
        PCHAIN_T *mPChain{nullptr};
79
        PCHAIN_T *mPChain{nullptr};
133
        SPCHAIN_T *mSPChain{nullptr};
80
        SPCHAIN_T *mSPChain{nullptr};
-
 
81
        TMap *mMap{nullptr};                // Map data of panel file
134
        MAPS_T mMap;
82
        TMap *mSystemMap{nullptr};          // Map data of system settings
135
};
83
};
136
 
84
 
137
#endif
85
#endif