11 |
andreas |
1 |
/*
|
193 |
andreas |
2 |
* Copyright (C) 2020 to 2022 by Andreas Theofilu <andreas@theosys.at>
|
11 |
andreas |
3 |
*
|
|
|
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
|
|
|
6 |
* the Free Software Foundation; either version 3 of the License, or
|
|
|
7 |
* (at your option) any later version.
|
|
|
8 |
*
|
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
12 |
* GNU General Public License for more details.
|
|
|
13 |
*
|
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
|
15 |
* along with this program; if not, write to the Free Software Foundation,
|
|
|
16 |
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
17 |
*/
|
|
|
18 |
|
|
|
19 |
#ifndef __TAMXCOMMANDS_H__
|
|
|
20 |
#define __TAMXCOMMANDS_H__
|
|
|
21 |
|
|
|
22 |
#include <string>
|
|
|
23 |
#include <vector>
|
|
|
24 |
#include <functional>
|
|
|
25 |
|
14 |
andreas |
26 |
#include "tbutton.h"
|
|
|
27 |
#include "tvalidatefile.h"
|
193 |
andreas |
28 |
#include "tmap.h"
|
14 |
andreas |
29 |
|
|
|
30 |
class TPage;
|
|
|
31 |
class TSubPage;
|
|
|
32 |
|
|
|
33 |
typedef struct PCHAIN_T
|
11 |
andreas |
34 |
{
|
14 |
andreas |
35 |
TPage *page{nullptr};
|
|
|
36 |
PCHAIN_T *next{nullptr};
|
|
|
37 |
}PCHAIN_T;
|
|
|
38 |
|
|
|
39 |
typedef struct SPCHAIN_T
|
|
|
40 |
{
|
|
|
41 |
TSubPage *page{nullptr};
|
|
|
42 |
SPCHAIN_T *next{nullptr};
|
|
|
43 |
}SPCHAIN_T;
|
|
|
44 |
|
|
|
45 |
class TAmxCommands : public TValidateFile
|
|
|
46 |
{
|
11 |
andreas |
47 |
public:
|
|
|
48 |
typedef struct CMD_TABLE
|
|
|
49 |
{
|
|
|
50 |
std::string cmd; // The command (^TXT, ^BMP, ...)
|
|
|
51 |
std::vector<int> channels; // Channels the command affects (200&210, ...)
|
|
|
52 |
std::vector<std::string> pars; // Rest of parameters of the command
|
|
|
53 |
std::function<void (int port, std::vector<int>& channels, std::vector<std::string>& pars)> command{nullptr};
|
|
|
54 |
}CMD_TABLE;
|
|
|
55 |
|
|
|
56 |
TAmxCommands();
|
|
|
57 |
~TAmxCommands();
|
|
|
58 |
|
14 |
andreas |
59 |
void setPChain(PCHAIN_T *ch) { mPChain = ch; }
|
|
|
60 |
void setSPChain(SPCHAIN_T *ch) { mSPChain = ch; }
|
11 |
andreas |
61 |
bool parseCommand(int device, int port, const std::string& cmd);
|
193 |
andreas |
62 |
std::vector<TMap::MAP_T> findButtons(int port, std::vector<int>& channels, TMap::MAP_TYPE mt = TMap::TYPE_AM);
|
165 |
andreas |
63 |
std::string findImage(int bt, int page, int instance=0);
|
|
|
64 |
std::string findImage(const std::string& name);
|
193 |
andreas |
65 |
std::vector<TMap::MAP_T> findButtonByName(const std::string& name);
|
|
|
66 |
std::vector<TMap::MAP_T> findBargraphs(int port, std::vector<int>& channels);
|
107 |
andreas |
67 |
std::vector<std::string> findSounds();
|
118 |
andreas |
68 |
bool soundExist(const std::string& sname);
|
11 |
andreas |
69 |
void registerCommand(std::function<void (int port, std::vector<int>& channels, std::vector<std::string>& pars)> command, const std::string& name);
|
|
|
70 |
|
14 |
andreas |
71 |
protected:
|
|
|
72 |
bool readMap();
|
|
|
73 |
|
11 |
andreas |
74 |
private:
|
|
|
75 |
bool extractChannels(const std::string& schan, std::vector<int> *ch);
|
14 |
andreas |
76 |
std::vector<std::string> getFields(std::string& msg, char sep);
|
11 |
andreas |
77 |
|
|
|
78 |
std::vector<CMD_TABLE> mCmdTable;
|
14 |
andreas |
79 |
PCHAIN_T *mPChain{nullptr};
|
|
|
80 |
SPCHAIN_T *mSPChain{nullptr};
|
193 |
andreas |
81 |
TMap *mMap{nullptr}; // Map data of panel file
|
|
|
82 |
TMap *mSystemMap{nullptr}; // Map data of system settings
|
11 |
andreas |
83 |
};
|
|
|
84 |
|
|
|
85 |
#endif
|