This file is indexed.

/usr/include/ola/rdm/RDMAPI.h is in libola-dev 0.10.5.nojsmin-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   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
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
/*
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 * RDMAPI.h
 * Provide a generic RDM API that can use different implementations.
 * Copyright (C) 2010 Simon Newton
 *
 * This class provides a high level C++ RDM API for PIDs defined in
 * E1.20. It includes errors checking for out-of-range arguments. Each RDM
 * method takes a pointer to a string, which will be populated with an English
 * error message if the command fails.
 */

/**
 * @addtogroup rdm_api
 * @{
 * @file RDMAPI.h
 * @brief Provide a generic RDM API that can use different implementations.
 *
 * This class provides a high level C++ RDM API for PIDS defined in E1.20. It
 * includes error checking for out-of-range arguments. Each RDM method takes a
 * pointer to a string, which will be populated with an english error message
 * if the command fails.
 * @}
 *
 */
#ifndef INCLUDE_OLA_RDM_RDMAPI_H_
#define INCLUDE_OLA_RDM_RDMAPI_H_

#include <stdint.h>
#include <ola/Callback.h>
#include <ola/base/Macro.h>
#include <ola/rdm/RDMAPIImplInterface.h>
#include <ola/rdm/RDMEnums.h>
#include <ola/rdm/UID.h>
#include <map>
#include <string>
#include <vector>

namespace ola {
namespace rdm {

/*
 * Represents a Status Message
 */
typedef struct {
  uint16_t sub_device;
  uint16_t status_message_id;
  int16_t value1;
  int16_t value2;
  uint8_t status_type;
} StatusMessage;


/*
 * Represents the description for a parameter
 */
typedef struct {
  uint16_t pid;
  uint8_t pdl_size;
  uint8_t data_type;
  uint8_t command_class;
  uint8_t unit;
  uint8_t prefix;
  uint32_t min_value;
  uint32_t default_value;
  uint32_t max_value;
  std::string description;
} ParameterDescriptor;


/*
 * Represents a DeviceDescriptor reply
 */
PACK(
struct device_info_s {
  uint8_t protocol_version_high;
  uint8_t protocol_version_low;
  uint16_t device_model;
  uint16_t product_category;
  uint32_t software_version;
  uint16_t dmx_footprint;
  uint8_t current_personality;
  uint8_t personality_count;
  uint16_t dmx_start_address;
  uint16_t sub_device_count;
  uint8_t sensor_count;
});

typedef struct device_info_s DeviceDescriptor;


/*
 * Information about a DMX slot
 */
PACK(
struct slot_info_s {
  uint16_t slot_offset;
  uint8_t slot_type;
  uint16_t slot_label;
});

typedef struct slot_info_s SlotDescriptor;

/*
 * The default values for a slot
 */
PACK(
struct slot_default_s {
  uint16_t slot_offset;
  uint8_t default_value;
});

typedef struct slot_default_s SlotDefault;


/*
 * Sensor definition
 */
typedef struct {
  uint8_t sensor_number;
  uint8_t type;
  uint8_t unit;
  uint8_t prefix;
  int16_t range_min;
  int16_t range_max;
  int16_t normal_min;
  int16_t normal_max;
  uint8_t recorded_value_support;
  std::string description;
} SensorDescriptor;


/*
 * Sensor values
 */
PACK(
struct sensor_values_s {
  uint8_t sensor_number;
  int16_t present_value;
  int16_t lowest;
  int16_t highest;
  int16_t recorded;
});

typedef struct sensor_values_s SensorValueDescriptor;

/*
 * Clock structure
 */
PACK(
struct clock_value_s {
  uint16_t year;
  uint8_t month;
  uint8_t day;
  uint8_t hour;
  uint8_t minute;
  uint8_t second;
});

typedef struct clock_value_s ClockValue;

/*
 * The interface for objects which deal with queued messages
 */
class QueuedMessageHandler {
 public:
    virtual ~QueuedMessageHandler() {}

    virtual void ProxiedDeviceCount(const ResponseStatus &status,
                                    uint16_t device_count,
                                    bool list_changed) = 0;
    virtual void ProxiedDevices(const ResponseStatus &status,
                                const std::vector<UID> &uids) = 0;
    virtual void CommStatus(const ResponseStatus &status,
                            uint16_t short_message,
                            uint16_t length_mismatch,
                            uint16_t checksum_fail) = 0;
    virtual void StatusMessages(const ResponseStatus &status,
                                const std::vector<StatusMessage> &messages) = 0;
    virtual void StatusIdDescription(const ResponseStatus &status,
                                     const std::string &status_id) = 0;
    virtual void SubDeviceReporting(const ResponseStatus &status,
                                    uint8_t status_type) = 0;
    virtual void SupportedParameters(
        const ResponseStatus &status,
        const std::vector<uint16_t> &parameters) = 0;
    virtual void ParameterDescription(
        const ResponseStatus &status,
        const ParameterDescriptor &description) = 0;
    virtual void DeviceInfo(const ResponseStatus &status,
                            const DeviceDescriptor &device_info) = 0;
    virtual void ProductDetailIdList(const ResponseStatus &status,
                                     const std::vector<uint16_t> &ids) = 0;
    virtual void DeviceModelDescription(const ResponseStatus &status,
                                        const std::string &description) = 0;
    virtual void ManufacturerLabel(const ResponseStatus &status,
                                   const std::string &label) = 0;
    virtual void DeviceLabel(const ResponseStatus &status,
                             const std::string &label) = 0;
    virtual void FactoryDefaults(const ResponseStatus &status,
                                 bool using_defaults) = 0;
    virtual void LanguageCapabilities(
        const ResponseStatus &status,
        const std::vector<std::string> &langs) = 0;
    virtual void Language(const ResponseStatus &status,
                          const std::string &language) = 0;
    virtual void SoftwareVersionLabel(const ResponseStatus &status,
                                      const std::string &label) = 0;
    virtual void BootSoftwareVersion(const ResponseStatus &status,
                                     uint32_t version) = 0;
    virtual void BootSoftwareVersionLabel(const ResponseStatus &status,
                                          const std::string &label) = 0;
    virtual void DMXPersonality(const ResponseStatus &status,
                                uint8_t current_personality,
                                uint8_t personality_count) = 0;
    virtual void DMXPersonalityDescription(const ResponseStatus &status,
                                           uint8_t personality,
                                           uint16_t slots_requires,
                                           const std::string &label) = 0;
    virtual void DMXAddress(const ResponseStatus &status,
                            uint16_t start_address) = 0;
    virtual void SlotInfo(const ResponseStatus &status,
                          const std::vector<SlotDescriptor> &slots) = 0;
    virtual void SlotDescription(const ResponseStatus &status,
                                 uint16_t slot_offset,
                                 const std::string &description) = 0;
    virtual void SlotDefaultValues(
        const ResponseStatus &status,
        const std::vector<SlotDefault> &defaults) = 0;
    virtual void SensorDefinition(const ResponseStatus &status,
                                  const SensorDescriptor &descriptor) = 0;
    virtual void SensorValue(const ResponseStatus &status,
                             const SensorValueDescriptor &descriptor) = 0;
    virtual void DeviceHours(const ResponseStatus &status,
                             uint32_t hours) = 0;
    virtual void LampHours(const ResponseStatus &status,
                           uint32_t hours) = 0;
    virtual void LampStrikes(const ResponseStatus &status,
                             uint32_t hours) = 0;
    virtual void LampState(const ResponseStatus &status,
                           uint8_t state) = 0;
    virtual void LampMode(const ResponseStatus &status,
                          uint8_t mode) = 0;
    virtual void DevicePowerCycles(const ResponseStatus &status,
                                   uint32_t hours) = 0;
    virtual void DisplayInvert(const ResponseStatus &status,
                               uint8_t invert_mode) = 0;
    virtual void DisplayLevel(const ResponseStatus &status,
                              uint8_t level) = 0;
    virtual void PanInvert(const ResponseStatus &status,
                           uint8_t inverted) = 0;
    virtual void TiltInvert(const ResponseStatus &status,
                            uint8_t inverted) = 0;
    virtual void PanTiltSwap(const ResponseStatus &status,
                             uint8_t inverted) = 0;
    virtual void IdentifyDevice(const ResponseStatus &status,
                                bool mode) = 0;
    virtual void Clock(const ResponseStatus &status,
                       const ClockValue &clock) = 0;
    virtual void PowerState(const ResponseStatus &status,
                            uint8_t power_state) = 0;
    virtual void ResetDevice(const ResponseStatus &status,
                             uint8_t reset_device) = 0;
    virtual void SelfTestEnabled(const ResponseStatus &status,
                                 bool is_enabled) = 0;
    virtual void SelfTestDescription(const ResponseStatus &status,
                                     uint8_t self_test_number,
                                     const std::string &description) = 0;
    virtual void PresetPlaybackMode(const ResponseStatus &status,
                                    uint16_t preset_mode,
                                    uint8_t level) = 0;

    virtual void DefaultHandler(const ResponseStatus &status,
                                uint16_t pid,
                                const std::string &data) = 0;
};


/*
 * The high level RDM API.
 */
class RDMAPI {
 public:
    explicit RDMAPI(class RDMAPIImplInterface *impl):
      m_impl(impl) {
    }
    ~RDMAPI() {}

    // This is used to check for queued messages
    uint8_t OutstandingMessagesCount(const UID &uid);

    // Proxy methods
    bool GetProxiedDeviceCount(
        unsigned int universe,
        const UID &uid,
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint16_t,
                                bool> *callback,
        std::string *error);

    bool GetProxiedDevices(
        unsigned int universe,
        const UID &uid,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<UID>&> *callback,
        std::string *error);

    // Network Managment Methods
    bool GetCommStatus(
        unsigned int universe,
        const UID &uid,
        ola::SingleUseCallback4<void,
                                const ResponseStatus&,
                                uint16_t,
                                uint16_t,
                                uint16_t> *callback,
        std::string *error);

    bool ClearCommStatus(
        unsigned int universe,
        const UID &uid,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    // There are two types of queued message calls, one that takes a
    // QueuedMessageHandler and the other than just takes a callback.

    // When complete, the appropriate method will be called on the handler.
    bool GetQueuedMessage(
        unsigned int universe,
        const UID &uid,
        rdm_status_type status_type,
        QueuedMessageHandler *handler,
        std::string *error);

    // When complete, the callback will be run. It's up to the caller to unpack
    // the message.
    bool GetQueuedMessage(
        unsigned int universe,
        const UID &uid,
        rdm_status_type status_type,
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint16_t,
                                const std::string&> *callback,
        std::string *error);

    bool GetStatusMessage(
        unsigned int universe,
        const UID &uid,
        rdm_status_type status_type,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<StatusMessage>&> *callback,
        std::string *error);

    bool GetStatusIdDescription(
        unsigned int universe,
        const UID &uid,
        uint16_t status_id,
        ola::SingleUseCallback2<void, const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool ClearStatusId(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetSubDeviceReporting(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint8_t> *callback,
        std::string *error);

    bool SetSubDeviceReporting(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        rdm_status_type status_type,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    // Information Methods
    bool GetSupportedParameters(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<uint16_t> &> *callback,
        std::string *error);

    bool GetParameterDescription(
        unsigned int universe,
        const UID &uid,
        uint16_t pid,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const ParameterDescriptor&> *callback,
        std::string *error);

    bool GetDeviceInfo(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const DeviceDescriptor&> *callback,
        std::string *error);

    bool GetProductDetailIdList(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<uint16_t> &> *callback,
        std::string *error);

    bool GetDeviceModelDescription(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool GetManufacturerLabel(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool GetDeviceLabel(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool SetDeviceLabel(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        const std::string &label,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetFactoryDefaults(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                bool> *callback,
        std::string *error);

    bool ResetToFactoryDefaults(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetLanguageCapabilities(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<std::string>&> *callback,
        std::string *error);

    bool GetLanguage(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool SetLanguage(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        const std::string &language,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetSoftwareVersionLabel(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool GetBootSoftwareVersion(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        std::string *error);

    bool GetBootSoftwareVersionLabel(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool GetDMXPersonality(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint8_t,
                                uint8_t> *callback,
        std::string *error);

    bool SetDMXPersonality(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t personality,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetDMXPersonalityDescription(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t personality,
        ola::SingleUseCallback4<void,
                                const ResponseStatus&,
                                uint8_t,
                                uint16_t,
                                const std::string&> *callback,
        std::string *error);

    bool GetDMXAddress(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint16_t> *callback,
        std::string *error);

    bool SetDMXAddress(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint16_t start_address,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetSlotInfo(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<SlotDescriptor>&> *callback,
        std::string *error);

    bool GetSlotDescription(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint16_t slot_offset,
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint16_t,
                                const std::string&> *callback,
        std::string *error);

    bool GetSlotDefaultValues(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<SlotDefault>&> *callback,
        std::string *error);

    bool GetSensorDefinition(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t sensor_number,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const SensorDescriptor&> *callback,
        std::string *error);

    bool GetSensorValue(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t sensor_number,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const SensorValueDescriptor&> *callback,
        std::string *error);

    bool SetSensorValue(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t sensor_number,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const SensorValueDescriptor&> *callback,
        std::string *error);

    bool RecordSensors(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t sensor_number,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetDeviceHours(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        std::string *error);

    bool SetDeviceHours(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint32_t device_hours,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetLampHours(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        std::string *error);

    bool SetLampHours(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint32_t lamp_hours,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetLampStrikes(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        std::string *error);

    bool SetLampStrikes(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint32_t lamp_strikes,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetLampState(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetLampState(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t lamp_state,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetLampMode(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetLampMode(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t lamp_mode,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetDevicePowerCycles(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        std::string *error);

    bool SetDevicePowerCycles(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint32_t power_cycles,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetDisplayInvert(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetDisplayInvert(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t display_invert,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetDisplayLevel(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetDisplayLevel(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t display_level,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetPanInvert(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetPanInvert(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t invert,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetTiltInvert(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetTiltInvert(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t invert,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetPanTiltSwap(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetPanTiltSwap(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t swap,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetClock(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const ClockValue&> *callback,
        std::string *error);

    bool SetClock(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        const ClockValue &clock,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetIdentifyDevice(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, bool> *callback,
        std::string *error);

    bool IdentifyDevice(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        bool mode,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool ResetDevice(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        bool warm_reset,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetPowerState(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        std::string *error);

    bool SetPowerState(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        rdm_power_state power_state,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool SetResetDevice(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        rdm_reset_device_mode reset_device,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetDnsHostname(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool SetDnsHostname(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        const std::string &label,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool GetDnsDomainName(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        std::string *error);

    bool SetDnsDomainName(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        const std::string &label,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool SelfTestEnabled(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, bool> *callback,
        std::string *error);

    bool PerformSelfTest(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t self_test_number,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool SelfTestDescription(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t self_test_number,
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint8_t,
                                const std::string&> *callback,
        std::string *error);

    bool CapturePreset(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint16_t scene,
        uint16_t fade_up_time,
        uint16_t fade_down_time,
        uint16_t wait_time,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    bool PresetPlaybackMode(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint16_t,
                                uint8_t> *callback,
        std::string *error);

    bool SetPresetPlaybackMode(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint16_t playback_mode,
        uint8_t level,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        std::string *error);

    // Handlers, these are called by the RDMAPIImpl.

    // Generic handlers
    void _HandleCustomLengthLabelResponse(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        uint8_t length,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleLabelResponse(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleBoolResponse(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                bool> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleU8Response(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint8_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleU32Response(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleEmptyResponse(
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    // specific handlers follow
    void _HandleGetProxiedDeviceCount(
      ola::SingleUseCallback3<void,
                              const ResponseStatus&,
                              uint16_t,
                              bool> *callback,
      const ResponseStatus &status,
      const std::string &data);

    void _HandleGetProxiedDevices(
      ola::SingleUseCallback2<void,
                              const ResponseStatus&,
                              const std::vector<UID>&> *callback,
      const ResponseStatus &status,
      const std::string &data);

    void _HandleGetCommStatus(
        ola::SingleUseCallback4<void,
                                const ResponseStatus&,
                                uint16_t,
                                uint16_t,
                                uint16_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleQueuedMessage(
        QueuedMessageHandler *handler,
        const ResponseStatus &status,
        uint16_t pid,
        const std::string &data);

    void _HandleGetStatusMessage(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<StatusMessage>&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetSubDeviceReporting(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint8_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetSupportedParameters(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<uint16_t>&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetParameterDescriptor(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const ParameterDescriptor&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetDeviceDescriptor(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const DeviceDescriptor&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetProductDetailIdList(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<uint16_t>&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetLanguageCapabilities(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<std::string>&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetLanguage(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::string&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetBootSoftwareVersion(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetDMXPersonality(
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint8_t,
                                uint8_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetDMXPersonalityDescription(
        ola::SingleUseCallback4<void,
                                const ResponseStatus&,
                                uint8_t,
                                uint16_t,
                                const std::string&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetDMXAddress(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint16_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetSlotInfo(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<SlotDescriptor>&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetSlotDescription(
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint16_t,
                                const std::string&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetSlotDefaultValues(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const std::vector<SlotDefault>&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleGetSensorDefinition(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const SensorDescriptor&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleSensorValue(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const SensorValueDescriptor&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleClock(
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                const ClockValue&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandleSelfTestDescription(
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint8_t,
                                const std::string&> *callback,
        const ResponseStatus &status,
        const std::string &data);

    void _HandlePlaybackMode(
        ola::SingleUseCallback3<void,
                                const ResponseStatus&,
                                uint16_t,
                                uint8_t> *callback,
        const ResponseStatus &status,
        const std::string &data);

 private:
    class RDMAPIImplInterface *m_impl;
    std::map<UID, uint8_t> m_outstanding_messages;

    bool GenericGetU8(
        unsigned int universe,
        const UID &uid,
        uint8_t sub_device,
        ola::SingleUseCallback2<void, const ResponseStatus&, uint8_t> *callback,
        uint16_t pid,
        std::string *error);

    bool GenericSetU8(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint8_t value,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        uint16_t pid,
        std::string *error);

    bool GenericGetU32(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        ola::SingleUseCallback2<void,
                                const ResponseStatus&,
                                uint32_t> *callback,
        uint16_t pid,
        std::string *error);

    bool GenericSetU32(
        unsigned int universe,
        const UID &uid,
        uint16_t sub_device,
        uint32_t value,
        ola::SingleUseCallback1<void, const ResponseStatus&> *callback,
        uint16_t pid,
        std::string *error);

    // Check that a callback is not null
    template <typename callback_type>
    bool CheckCallback(std::string *error, const callback_type *cb) {
      if (cb == NULL) {
        if (error)
          *error = "Callback is null, this is a programming error";
        return true;
      }
      return false;
    }

    // Check that a UID is not a broadcast address
    template <typename callback_type>
    bool CheckNotBroadcast(const UID &uid, std::string *error,
                           const callback_type *cb) {
      if (uid.IsBroadcast()) {
        if (error)
          *error = "Cannot send to broadcast address";
        delete cb;
        return true;
      }
      return false;
    }

    // Check the subdevice value is valid
    template <typename callback_type>
    bool CheckValidSubDevice(uint16_t sub_device,
                             bool broadcast_allowed,
                             std::string *error,
                             const callback_type *cb) {
      if (sub_device <= 0x0200)
        return false;

      if (broadcast_allowed && sub_device == ALL_RDM_SUBDEVICES)
        return false;

      if (error) {
        *error = "Sub device must be <= 0x0200";
        if (broadcast_allowed)
          *error += " or 0xffff";
      }
      delete cb;
      return true;
    }

    bool CheckReturnStatus(bool status, std::string *error);
    void SetIncorrectPDL(ResponseStatus *status,
                         unsigned int actual,
                         unsigned int expected);
};
}  // namespace rdm
}  // namespace ola
#endif  // INCLUDE_OLA_RDM_RDMAPI_H_