Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 andreas 1
/*
101 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
#include "tamxcommands.h"
209 andreas 20
#include "tpagemanager.h"
11 andreas 21
#include "terror.h"
22
#include "tresources.h"
14 andreas 23
#include "tconfig.h"
78 andreas 24
#include "texpat++.h"
326 andreas 25
#if TESTMODE == 1
26
#include "testmode.h"
27
#endif
11 andreas 28
 
83 andreas 29
#include <string>
30
#include <vector>
31
 
186 andreas 32
#if __cplusplus < 201402L
33
#   error "This module requires at least C++14 standard!"
34
#else
35
#   if __cplusplus < 201703L
36
#       include <experimental/filesystem>
37
namespace fs = std::experimental::filesystem;
38
#       warning "Support for C++14 and experimental filesystem will be removed in a future version!"
39
#   else
40
#       include <filesystem>
41
#       ifdef __ANDROID__
42
namespace fs = std::__fs::filesystem;
43
#       else
44
namespace fs = std::filesystem;
45
#       endif
46
#   endif
47
#endif
48
 
11 andreas 49
using std::string;
50
using std::vector;
78 andreas 51
using namespace Expat;
11 andreas 52
 
53
typedef struct CMD_DEFINATIONS
54
{
55
    string cmd;
56
    bool hasChannels{false};
57
    bool hasPars{false};
14 andreas 58
    char separator{0};
11 andreas 59
}CMD_DEFINATIONS;
60
 
61
CMD_DEFINATIONS cmdDefinations[] = {
14 andreas 62
    { "@WLD", false, true, ',' },
63
    { "@AFP", false, true, ',' },
127 andreas 64
    { "^AFP", false, true, ',' },
14 andreas 65
    { "@GCE", false, true, ',' },
127 andreas 66
    { "^GCE", false, true, ',' },
14 andreas 67
    { "@APG", false, true, ';' },
68
    { "@CPG", false, true, ',' },
69
    { "@DPG", false, true, ';' },
70
    { "@PDR", false, true, ';' },
71
    { "@PHE", false, true, ';' },
72
    { "@PHP", false, true, ';' },
73
    { "@PHT", false, true, ';' },
74
    { "@PPA", false, true, ',' },
104 andreas 75
    { "^PPA", false, true, ',' },
14 andreas 76
    { "@PPF", false, true, ';' },
104 andreas 77
    { "^PPF", false, true, ';' },
14 andreas 78
    { "@PPG", false, true, ';' },
104 andreas 79
    { "^PPG", false, true, ';' },
14 andreas 80
    { "@PPK", false, true, ',' },
104 andreas 81
    { "^PPK", false, true, ',' },
14 andreas 82
    { "@PPM", false, true, ';' },
104 andreas 83
    { "^PPM", false, true, ';' },
14 andreas 84
    { "@PPN", false, true, ';' },
104 andreas 85
    { "^PPN", false, true, ';' },
14 andreas 86
    { "@PPT", false, true, ';' },
104 andreas 87
    { "^PPT", false, true, ';' },
14 andreas 88
    { "@PPX", false, false, '\0' },
104 andreas 89
    { "^PPX", false, false, '\0' },
14 andreas 90
    { "@PSE", false, true, ';' },
91
    { "@PSP", false, true, ';' },
92
    { "@PST", false, true, ';' },
93
    { "PAGE", false, true, ',' },
104 andreas 94
    { "^PGE", false, true, ',' },
14 andreas 95
    { "PPOF", false, true, ';' },
96
    { "PPOG", false, true, ';' },
97
    { "PPON", false, true, ';' },
98
    { "^ANI", true, true, ',' },
99
    { "^APF", true, true, ',' },
100
    { "^BAT", true, true, ',' },
101
    { "^BAU", true, true, ',' },
102
    { "^BCB", true, true, ',' },
103
    { "?BCB", true, true, ',' },
104
    { "^BCF", true, true, ',' },
105
    { "?BCF", true, true, ',' },
106
    { "^BCT", true, true, ',' },
107
    { "?BCT", true, true, ',' },
108
    { "^BDO", true, true, ',' },
109
    { "^BFB", true, true, ',' },
110
    { "^BIM", true, true, ',' },
111
    { "^BLN", true, true, ',' },
112
    { "^BMC", true, true, ',' },
113
    { "^BMF", true, true, ',' },
114
    { "^BMI", true, true, ',' },
115
    { "^BML", true, true, ',' },
116
    { "^BMP", true, true, ',' },
117
    { "?BMP", true, true, ',' },
118
    { "^BNC", true, true, ',' },
119
    { "^BNN", true, true, ',' },
120
    { "^BNT", true, true, ',' },
121
    { "^BOP", true, true, ',' },
122
    { "?BOP", true, true, ',' },
123
    { "^BOR", true, true, ',' },
124
    { "^BOS", true, true, ',' },
125
    { "^BPP", true, true, ',' },
126
    { "^BRD", true, true, ',' },
127
    { "?BRD", true, true, ',' },
128
    { "^BSF", true, true, ',' },
129
    { "^BSP", true, true, ',' },
130
    { "^BSM", true, false, ',' },
131
    { "^BSO", true, true, ',' },
132
    { "^BVL", true, true, ',' },
133
    { "^BVN", false, true, ',' },
134
    { "^BVP", true, true, ',' },
135
    { "^BVT", true, true, ',' },
136
    { "^BWW", true, true, ',' },
137
    { "?BWW", true, true, ',' },
138
    { "^CPF", true, false, ',' },
139
    { "^DLD", false, false, ',' },
140
    { "^DPF", true, true, ',' },
141
    { "^ENA", true, true, ',' },
142
    { "^FON", true, true, ',' },
143
    { "?FON", true, true, ',' },
144
    { "^GDI", true, true, ',' },
145
    { "^GIV", true, true, ',' },
146
    { "^GLH", true, true, ',' },
147
    { "^GLL", true, true, ',' },
148
    { "^GRD", true, true, ',' },
149
    { "^GRU", true, true, ',' },
150
    { "^GSC", true, true, ',' },
151
    { "^GSN", true, true, ',' },
152
    { "^ICO", true, true, ',' },
153
    { "?ICO", true, true, ',' },
154
    { "^IRM", false, true, ',' },
155
    { "^JSB", true, true, ',' },
156
    { "?JSB", true, true, ',' },
157
    { "^JSI", true, true, ',' },
158
    { "?JSI", true, true, ',' },
159
    { "^JST", true, true, ',' },
160
    { "?JST", true, true, ',' },
161
    { "^MBT", false, false, ',' },
162
    { "^MDC", false, false, ',' },
163
    { "^SHO", true, true, ',' },
164
    { "^TEC", true, true, ',' },
165
    { "?TEC", true, true, ',' },
166
    { "^TEF", true, true, ',' },
167
    { "?TEF", true, true, ',' },
168
    { "^TOP", false, true, ',' },
169
    { "^TXT", true, true, ',' },
170
    { "?TXT", true, true, ',' },
171
    { "^UNI", true, true, ',' },
104 andreas 172
    { "^UTF", true, true, ',' },
14 andreas 173
    { "^LPC", false, true, ',' },
174
    { "^LPR", false, true, ',' },
175
    { "^LPS", false, true, ',' },
176
    { "ABEEP", false, false, ',' },
177
    { "ADBEEP", false, false, ',' },
178
    { "@AKB", false, true, ';' },
179
    { "AKEYB", false, true, ',' },
180
    { "AKEYP", false, true, ',' },
181
    { "AKEYR", false, true, ',' },
182
    { "@AKP", false, true, ';' },
183
    { "@AKR", false, false, ',' },
184
    { "BEEP", false, false, ',' },
104 andreas 185
    { "^ABP", false, false, ',' },
14 andreas 186
    { "BRIT", false, true, ',' },
187
    { "@BRT", false, true, ',' },
188
    { "DBEEP", false, false, ',' },
104 andreas 189
    { "^ADP", false, false, ',' },
14 andreas 190
    { "@EKP", false, true, ';' },
191
    { "PKEYP", false, true, ',' },
63 andreas 192
    { "@PKB", false, true, ';' },
104 andreas 193
    { "^PKB", false, true, ';' },
14 andreas 194
    { "@PKP", false, true, ';' },
104 andreas 195
    { "^PKP", false, true, ';' },
14 andreas 196
    { "SETUP", false, false, ',' },
104 andreas 197
    { "^STP", false, false, ',' },
14 andreas 198
    { "SHUTDOWN", false, false, ',' },
199
    { "SLEEP", false, false, ',' },
200
    { "@SOU", false, true, ',' },
104 andreas 201
    { "^SOU", false, true, ',' },
14 andreas 202
    { "@TKP", false, true, ';' },
104 andreas 203
    { "^TKP", false, true, ';' },
14 andreas 204
    { "TPAGEON", false, false, ',' },
205
    { "TPAGEOFF", false, false, ',' },
206
    { "@VKB", false, false, ',' },
104 andreas 207
    { "^VKB", false, false, ',' },
14 andreas 208
    { "WAKE", false, false, ',' },
209
    { "^CAL", false, false, ',' },
210
    { "^KPS", false, true, ',' },
211
    { "^VKS", false, true, ',' },
127 andreas 212
    { "^WCN?", false, true, ',' },
14 andreas 213
    { "@PWD", false, true, ',' },
214
    { "^PWD", false, true, ',' },
215
    { "^BBR", true, true, ',' },
216
    { "^RAF", false, true, ',' },
217
    { "^RFR", false, true, ',' },
218
    { "^RMF", false, true, ',' },
219
    { "^RSR", false, true, ',' },
220
    { "^MODEL?", false, false, ',' },
127 andreas 221
    { "^MOD", false, false, ',' },
222
    { "^VER?", false, false, ',' },
14 andreas 223
    { "^ICS", false, true, ',' },
224
    { "^ICE", false, false, ',' },
225
    { "^ICM", false, true, ',' },
226
    { "^PHN", false, true, ',' },
227
    { "?PHN", false, true, ',' },
233 andreas 228
    { "^LVC", false, true, ',' },
227 andreas 229
    { "^LVD", true, true, ',' },
230
    { "^LVE", true, true, ',' },
231
    { "^LVF", true, true, ',' },
233 andreas 232
    { "^LVL", true, true, ',' },
233
    { "^LVM", true, true, '|' },
234
    { "^LVN", true, true, ',' },
235
    { "^LVR", true, true, ',' },
236
    { "^LVS", true, true, ',' },
127 andreas 237
    { "GET ", false, false, ',' },
238
    { "SET ", false, false, ',' },
14 andreas 239
    { "LEVON", false, false, ',' },
318 andreas 240
    { "LEVOF", false, false, ',' },
14 andreas 241
    { "RXON", false, false, ',' },
242
    { "ON", false, true, ',' },
243
    { "OFF", false, true, ',' },
15 andreas 244
    { "LEVEL", false, true, ',' },
245
    { "BLINK", false, true, ',' },
23 andreas 246
    { "#FTR", false, true, ':' },
134 andreas 247
    { "TPCCMD", false, true, ',' },
248
    { "TPCACC", false, true, ',' },
153 andreas 249
    { "TPCSIP", false, true, ',' },
300 andreas 250
    { "^EPR", true, true, ',' },
251
    { "^SCE", true, true, ',' },
252
    { "^SDR", true, true, ',' },
318 andreas 253
    { "^SHA", true, false, ',' },
300 andreas 254
    { "^SHD", true, true, ',' },
255
    { "^SSH", true, true, ',' },
256
    { "^STG", true, true, ',' },
326 andreas 257
    { "^MUT", false, true, ',' },
14 andreas 258
    { "", false, false, '\0' }
11 andreas 259
};
260
 
261
CMD_DEFINATIONS& findCmdDefines(const string& cmd)
262
{
263
    DECL_TRACER("findCmdDefines(const string& cmd)");
264
 
265
    int i = 0;
101 andreas 266
    string uCmd = cmd;
267
    uCmd = toUpper(uCmd);
11 andreas 268
 
269
    while (cmdDefinations[i].cmd.length() > 0)
270
    {
101 andreas 271
        if (cmdDefinations[i].cmd.compare(uCmd) == 0)
11 andreas 272
            return cmdDefinations[i];
273
 
274
        i++;
275
    }
276
 
277
    return cmdDefinations[i];
278
}
279
 
280
TAmxCommands::TAmxCommands()
281
{
282
    DECL_TRACER("TAmxCommands::TAmxCommands()");
283
}
284
 
285
TAmxCommands::~TAmxCommands()
286
{
287
    DECL_TRACER("TAmxCommands::~TAmxCommands()");
194 andreas 288
 
289
    if (mMap && mSystemMap && mMap != mSystemMap)
290
    {
291
        delete mMap;
292
        delete mSystemMap;
293
    }
294
    else if (mMap)
295
        delete mMap;
296
    else if (mSystemMap)
297
        delete mSystemMap;
11 andreas 298
}
299
 
14 andreas 300
bool TAmxCommands::readMap()
301
{
302
    DECL_TRACER("TAmxCommands::readMap()");
303
 
193 andreas 304
    bool err = false;
186 andreas 305
    string projectPath = TConfig::getProjectPath();
306
 
193 andreas 307
    if (fs::exists(projectPath + "/prj.xma"))
88 andreas 308
    {
194 andreas 309
        mMap = new TMap(projectPath);
193 andreas 310
        err = mMap->haveError();
88 andreas 311
    }
14 andreas 312
 
193 andreas 313
    projectPath += "/__system";
14 andreas 314
 
193 andreas 315
    if (fs::exists(projectPath + "/prj.xma"))
14 andreas 316
    {
194 andreas 317
        mSystemMap = new TMap(projectPath);
14 andreas 318
 
193 andreas 319
        if (!err)
194 andreas 320
            err = mSystemMap->haveError();
14 andreas 321
    }
322
 
194 andreas 323
    if (!mMap)
324
        mMap = mSystemMap;
325
 
193 andreas 326
    return !err;
14 andreas 327
}
328
 
329
vector<string> TAmxCommands::getFields(string& msg, char sep)
330
{
331
    DECL_TRACER("TAmxCommands::getFields(string& msg, char sep)");
332
 
333
    vector<string> flds;
334
    bool bStr = false;
335
    string part;
336
 
16 andreas 337
    for (size_t i = 0; i < msg.length(); i++)
14 andreas 338
    {
16 andreas 339
        if (msg.at(i) == sep && !bStr)
14 andreas 340
        {
341
            flds.push_back(part);
342
            part.clear();
343
            continue;
344
        }
16 andreas 345
        else if (msg.at(i) == '\'' && !bStr)
14 andreas 346
            bStr = true;
16 andreas 347
        else if (msg.at(i) == '\'' && bStr)
14 andreas 348
            bStr = false;
349
        else
16 andreas 350
            part.append(msg.substr(i, 1));
14 andreas 351
    }
352
 
353
    if (!part.empty())
354
        flds.push_back(part);
355
 
83 andreas 356
    if (flds.size() > 0 && TStreamError::checkFilter(HLOG_DEBUG))
14 andreas 357
    {
358
        MSG_DEBUG("Found fields:");
359
        vector<string>::iterator iter;
360
        int i = 1;
361
 
118 andreas 362
        for (iter = flds.begin(); iter != flds.end(); ++iter)
14 andreas 363
        {
364
            MSG_DEBUG("    " << i << ": " << *iter);
365
            i++;
366
        }
367
    }
368
 
369
    return flds;
370
}
371
 
193 andreas 372
vector<TMap::MAP_T> TAmxCommands::findButtons(int port, vector<int>& channels, TMap::MAP_TYPE mt)
14 andreas 373
{
193 andreas 374
    DECL_TRACER("TAmxCommands::findButtons(int port, vector<int>& channels, TMap::MAP_TYPE mt)");
14 andreas 375
 
193 andreas 376
    vector<TMap::MAP_T> map;
14 andreas 377
 
209 andreas 378
    if (gPageManager && gPageManager->isSetupActive())
379
        map = mSystemMap->findButtons(port, channels, mt);
380
    else
381
        map = mMap->findButtons(port, channels, mt);
19 andreas 382
 
14 andreas 383
    return map;
384
}
385
 
165 andreas 386
string TAmxCommands::findImage(int bt, int page, int instance)
387
{
388
    DECL_TRACER("TAmxCommands::findImage(int bt, int page, int instance)");
389
 
209 andreas 390
    if (page < SYSTEM_PAGE_START)
193 andreas 391
        return mMap->findImage(bt, page, instance);
165 andreas 392
 
193 andreas 393
    return mSystemMap->findImage(bt, page, instance);
165 andreas 394
}
395
 
396
string TAmxCommands::findImage(const string& name)
397
{
398
    DECL_TRACER("TAmxCommands::findImage(const string& name)");
399
 
193 andreas 400
    string str = mMap->findImage(name);
165 andreas 401
 
193 andreas 402
    if (str.empty())
403
        return mSystemMap->findImage(name);
165 andreas 404
 
193 andreas 405
    return str;
165 andreas 406
}
407
 
193 andreas 408
vector<TMap::MAP_T> TAmxCommands::findButtonByName(const string& name)
97 andreas 409
{
410
    DECL_TRACER("TAmxCommands::findButtonByName(const string& name)");
411
 
193 andreas 412
    vector<TMap::MAP_T> map = mMap->findButtonByName(name);
97 andreas 413
 
193 andreas 414
    if (map.empty())
415
        return mSystemMap->findButtonByName(name);
97 andreas 416
 
417
    return map;
418
}
419
 
193 andreas 420
vector<TMap::MAP_T> TAmxCommands::findBargraphs(int port, vector<int>& channels)
15 andreas 421
{
422
    DECL_TRACER("TAmxCommands::findBargraphs(int port, vector<int>& channels)");
423
 
193 andreas 424
    vector<TMap::MAP_T> map = mMap->findBargraphs(port, channels);
15 andreas 425
 
193 andreas 426
    if (map.empty())
427
        return mSystemMap->findBargraphs(port, channels);
83 andreas 428
 
15 andreas 429
    return map;
430
}
431
 
107 andreas 432
vector<string> TAmxCommands::findSounds()
433
{
434
    DECL_TRACER("TAmxCommands::findSounds()");
435
 
193 andreas 436
    return mMap->findSounds();      // This is enough because there are no sounds in the system settings
107 andreas 437
}
438
 
118 andreas 439
bool TAmxCommands::soundExist(const string& sname)
107 andreas 440
{
441
    DECL_TRACER("TAmxCommands::soundExist(const string sname)");
442
 
193 andreas 443
    return mMap->soundExist(sname);
107 andreas 444
}
445
 
11 andreas 446
bool TAmxCommands::parseCommand(int device, int port, const string& cmd)
447
{
448
    DECL_TRACER("TAmxCommands::parseCommand(int device, int port, const string& cmd)");
169 andreas 449
 
11 andreas 450
    vector<CMD_TABLE>::iterator iter;
16 andreas 451
    size_t pos = cmd.find_first_of("-");
127 andreas 452
    int system = TConfig::getSystem();
453
    string scmd = getCommand(cmd);
11 andreas 454
 
127 andreas 455
    MSG_TRACE("Parsing for device <" << device << ":" << port << ":" << system << "> the command: " << scmd);
13 andreas 456
 
11 andreas 457
    if (pos != string::npos)    // Command with parameters
458
    {
459
        string rest = cmd.substr(pos + 1);
460
 
118 andreas 461
        for (iter = mCmdTable.begin(); iter != mCmdTable.end(); ++iter)
11 andreas 462
        {
13 andreas 463
            iter->channels.clear();
464
            iter->pars.clear();
465
 
153 andreas 466
            if (iter->cmd.compare(scmd) == 0 && iter->command)
11 andreas 467
            {
153 andreas 468
                CMD_DEFINATIONS cdef = findCmdDefines(scmd);
11 andreas 469
 
470
                if (cdef.cmd.empty())
471
                {
153 andreas 472
                    MSG_WARNING("Command \"" << scmd << "\" not found in command table! Ignoring it.");
11 andreas 473
                    continue;
474
                }
475
 
476
                if (cdef.hasChannels || cdef.hasPars)
477
                {
14 andreas 478
                    vector<string> parts = getFields(rest, cdef.separator);
11 andreas 479
 
480
                    if (cdef.hasChannels)
13 andreas 481
                        extractChannels(parts[0], &iter->channels);
11 andreas 482
 
483
                    if (cdef.hasPars)
484
                    {
13 andreas 485
                        MSG_DEBUG("Command may have parameters. Found " << parts.size() << " parameters.");
11 andreas 486
 
13 andreas 487
                        if (parts.size() > 0)
11 andreas 488
                        {
13 andreas 489
                            vector<string>::iterator piter;
490
                            int cnt = 0;
491
 
118 andreas 492
                            for (piter = parts.begin(); piter != parts.end(); ++piter)
11 andreas 493
                            {
13 andreas 494
                                if (cdef.hasChannels && !cnt)
495
                                {
496
                                    cnt++;
497
                                    continue;
498
                                }
499
 
500
                                iter->pars.push_back(*piter);
11 andreas 501
                                cnt++;
502
                            }
503
                        }
13 andreas 504
                        else
505
                            iter->pars.push_back(rest);
11 andreas 506
                    }
507
                }
508
 
509
                iter->command(port, iter->channels, iter->pars);
510
                return true;
511
            }
512
        }
513
    }
514
    else        // Command without parameter
515
    {
118 andreas 516
        for (iter = mCmdTable.begin(); iter != mCmdTable.end(); ++iter)
11 andreas 517
        {
153 andreas 518
            if (iter->cmd.compare(scmd) == 0 && iter->command)
11 andreas 519
            {
520
                iter->command(port, iter->channels, iter->pars);
521
                return true;
522
            }
523
        }
524
    }
525
 
526
    MSG_WARNING("Command \"" << cmd << "\" currently not supported!");
326 andreas 527
#if TESTMODE == 1
528
    __done = true;
529
#endif
11 andreas 530
    return false;
531
}
532
 
533
bool TAmxCommands::extractChannels(const string& schan, vector<int>* ch)
534
{
535
    DECL_TRACER("TAmxCommands::extractChannels(const string& schan, vector<int>* ch)");
536
 
537
    if (!ch || schan.empty())
538
        return false;
539
 
16 andreas 540
    if (schan.find("&") == string::npos && schan.find(".") == string::npos)
11 andreas 541
    {
542
        int c = atoi(schan.c_str());
543
        ch->push_back(c);
544
        return true;
545
    }
546
 
547
    if (schan.find("&") != string::npos)
548
    {
549
        vector<string> parts = StrSplit(schan, "&");
550
        vector<string>::iterator iter;
551
 
83 andreas 552
        if (parts.size() > 0)
11 andreas 553
        {
118 andreas 554
            for (iter = parts.begin(); iter != parts.end(); ++iter)
11 andreas 555
            {
83 andreas 556
                if (iter->find(".") != string::npos)
557
                {
558
                    vector<string> p2 = StrSplit(*iter, ".");
11 andreas 559
 
83 andreas 560
                    if (p2.size() >= 2)
561
                    {
562
                        for (int i = atoi(p2[0].c_str()); i <= atoi(p2[1].c_str()); i++)
563
                            ch->push_back(i);
564
                    }
565
                    else if (p2.size() > 0)
566
                        ch->push_back(atoi(p2[0].c_str()));
38 andreas 567
                }
83 andreas 568
                else
569
                    ch->push_back(atoi(iter->c_str()));
11 andreas 570
            }
571
        }
572
    }
573
    else
574
    {
575
        vector<string> parts = StrSplit(schan, ".");
576
 
38 andreas 577
        if (parts.size() >= 2)
578
        {
60 andreas 579
            for (int i = atoi(parts[0].c_str()); i <= atoi(parts[1].c_str()); i++)
38 andreas 580
                ch->push_back(i);
581
        }
582
        else if (parts.size() > 0)
583
            ch->push_back(atoi(parts[0].c_str()));
11 andreas 584
    }
585
 
586
    return true;
587
}
588
 
589
void TAmxCommands::registerCommand(std::function<void (int port, vector<int>& channels, vector<string>& pars)> command, const string& name)
590
{
591
    DECL_TRACER("TAmxCommands::registerCommand(std::function<void (vector<int>& channels, vector<string>& pars)> command, const string& name)");
592
 
593
    vector<CMD_TABLE>::iterator iter;
594
 
118 andreas 595
    for (iter = mCmdTable.begin(); iter != mCmdTable.end(); ++iter)
11 andreas 596
    {
597
        if (iter->cmd.compare(name) == 0)
598
        {
599
            iter->command = command;
600
            iter->channels.clear();
601
            iter->pars.clear();
602
            return;
603
        }
604
    }
605
 
606
    CMD_TABLE ctbl;
607
    ctbl.cmd = name;
608
    ctbl.command = command;
609
    mCmdTable.push_back(ctbl);
610
}