Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
193 andreas 1
/*
2
 * Copyright (C) 2022 by Andreas Theofilu <andreas@theosys.at>
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 __TMAP_H__
20
#define __TMAP_H__
21
 
22
#include <string>
23
#include <vector>
24
 
25
#include "tvalidatefile.h"
26
 
27
// Pages with buttons
28
class TMap : public TValidateFile
29
{
30
    public:
31
        TMap(const std::string &file);
32
 
33
        typedef enum MAP_TYPE
34
        {
35
            TYPE_CM = 1,    // ON / OFF
36
            TYPE_AM,        // TXT, ...
37
            TYPE_LM        // Bargraphs
38
        }MAP_TYPE;
39
 
40
        typedef struct MAP_T
41
        {
42
            int p{0};           // port number
43
            int c{0};           // channel number
44
            int ax{0};          // ??
45
            int pg{0};          // page number
46
            int bt{0};          // button number
47
            std::string pn;     // page name
48
            std::string bn;     // button name
49
        }MAP_T;
50
 
51
        // Images
52
        typedef struct MAP_BM_T
53
        {
54
            std::string i;      // image file name
55
            int id{0};
56
            int rt{0};
57
            int pg{0};          // page number
58
            int bt{0};          // button number
59
            int st{0};          // button instance
60
            int sl{0};
61
            std::string pn;     // page name
62
            std::string bn;     // button name
63
        }MAP_BM_T;
64
 
65
        typedef struct MAP_PM_T
66
        {
67
            int a{0};
68
            std::string t;      // Group name
69
            int pg{0};          // page number
70
            int bt{0};          // button number
71
            std::string pn;     // page name
72
            std::string bn;     // button name
73
        }MAP_PM_T;
74
 
75
        typedef struct MAPS_T
76
        {
77
            std::vector<MAP_T> map_cm;
78
            std::vector<MAP_T> map_am;
79
            std::vector<MAP_T> map_lm;
80
            std::vector<MAP_BM_T> map_bm;       // Images
81
            std::vector<std::string> map_sm;    // sound file names
82
            std::vector<MAP_T> map_strm;        // System resources
83
            std::vector<MAP_PM_T> map_pm;       // Button -> text
84
        }MAPS_T;
85
 
86
        std::vector<MAP_T> findButtons(int port, std::vector<int>& channels, MAP_TYPE mt = TYPE_AM);
87
        std::vector<MAP_T> findButtonByName(const std::string& name);
88
        std::string findImage(int bt, int page, int instance=0);
89
        std::string findImage(const std::string& name);
90
        std::vector<MAP_T> findBargraphs(int port, std::vector<int>& channels);
91
        std::vector<std::string> findSounds();
92
        bool soundExist(const std::string& sname);
93
 
94
        bool haveError() { return mError; }
95
 
96
    protected:
97
        bool readMap();
98
 
99
    private:
100
        std::string mFile;
101
        MAPS_T mMap;
102
        bool mError{false};
103
};
104
 
105
#endif