Open Lighting Architecture  Latest Git
RDMAPI.h
Go to the documentation of this file.
1 /*
2  * This library is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU Lesser General Public
4  * License as published by the Free Software Foundation; either
5  * version 2.1 of the License, or (at your option) any later version.
6  *
7  * This library is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10  * Lesser General Public License for more details.
11  *
12  * You should have received a copy of the GNU Lesser General Public
13  * License along with this library; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15  *
16  * RDMAPI.h
17  * Provide a generic RDM API that can use different implementations.
18  * Copyright (C) 2010 Simon Newton
19  *
20  * This class provides a high level C++ RDM API for PIDs defined in
21  * E1.20. It includes errors checking for out-of-range arguments. Each RDM
22  * method takes a pointer to a string, which will be populated with an English
23  * error message if the command fails.
24  */
25 
39 #ifndef INCLUDE_OLA_RDM_RDMAPI_H_
40 #define INCLUDE_OLA_RDM_RDMAPI_H_
41 
42 #include <stdint.h>
43 #include <ola/Callback.h>
44 #include <ola/base/Macro.h>
46 #include <ola/rdm/RDMEnums.h>
47 #include <ola/rdm/UID.h>
48 #include <map>
49 #include <string>
50 #include <vector>
51 
52 namespace ola {
53 namespace rdm {
54 
55 /*
56  * Represents a Status Message
57  */
58 typedef struct {
59  uint16_t sub_device;
60  uint16_t status_message_id;
61  int16_t value1;
62  int16_t value2;
63  uint8_t status_type;
65 
66 
67 /*
68  * Represents the description for a parameter
69  */
70 typedef struct {
71  uint16_t pid;
72  uint8_t pdl_size;
73  uint8_t data_type;
74  uint8_t command_class;
75  uint8_t unit;
76  uint8_t prefix;
77  uint32_t min_value;
78  uint32_t default_value;
79  uint32_t max_value;
80  std::string description;
82 
83 
84 /*
85  * Represents a DeviceDescriptor reply
86  */
87 PACK(
88 struct device_info_s {
89  uint8_t protocol_version_high;
90  uint8_t protocol_version_low;
91  uint16_t device_model;
92  uint16_t product_category;
93  uint32_t software_version;
94  uint16_t dmx_footprint;
95  uint8_t current_personality;
96  uint8_t personality_count;
97  uint16_t dmx_start_address;
98  uint16_t sub_device_count;
99  uint8_t sensor_count;
100 });
101 
102 typedef struct device_info_s DeviceDescriptor;
103 
104 
105 /*
106  * Information about a DMX slot
107  */
108 PACK(
109 struct slot_info_s {
110  uint16_t slot_offset;
111  uint8_t slot_type;
112  uint16_t slot_label;
113 });
114 
115 typedef struct slot_info_s SlotDescriptor;
116 
117 /*
118  * The default values for a slot
119  */
120 PACK(
121 struct slot_default_s {
122  uint16_t slot_offset;
123  uint8_t default_value;
124 });
125 
126 typedef struct slot_default_s SlotDefault;
127 
128 
129 /*
130  * Sensor definition
131  */
132 typedef struct {
133  uint8_t sensor_number;
134  uint8_t type;
135  uint8_t unit;
136  uint8_t prefix;
137  int16_t range_min;
138  int16_t range_max;
139  int16_t normal_min;
140  int16_t normal_max;
141  uint8_t recorded_value_support;
142  std::string description;
144 
145 
146 /*
147  * Sensor values
148  */
149 PACK(
150 struct sensor_values_s {
151  uint8_t sensor_number;
152  int16_t present_value;
153  int16_t lowest;
154  int16_t highest;
155  int16_t recorded;
156 });
157 
158 typedef struct sensor_values_s SensorValueDescriptor;
159 
160 /*
161  * Clock structure
162  */
163 PACK(
164 struct clock_value_s {
165  uint16_t year;
166  uint8_t month;
167  uint8_t day;
168  uint8_t hour;
169  uint8_t minute;
170  uint8_t second;
171 });
172 
173 typedef struct clock_value_s ClockValue;
174 
175 /*
176  * Dimmer info values
177  */
178 typedef struct {
179  uint16_t min_level_lower_limit;
180  uint16_t min_level_upper_limit;
181  uint16_t max_level_lower_limit;
182  uint16_t max_level_upper_limit;
183  uint8_t curves_supported;
184  uint8_t resolution;
185  bool split_levels_supported;
187 
188 /*
189  * Dimmer minimum values
190  */
191 typedef struct {
192  uint16_t min_level_increasing;
193  uint16_t min_level_decreasing;
194  bool on_below_min;
196 
197 /*
198  * The interface for objects which deal with queued messages
199  */
201  public:
202  virtual ~QueuedMessageHandler() {}
203 
204  virtual void ProxiedDeviceCount(const ResponseStatus &status,
205  uint16_t device_count,
206  bool list_changed) = 0;
207  virtual void ProxiedDevices(const ResponseStatus &status,
208  const std::vector<UID> &uids) = 0;
209  virtual void CommStatus(const ResponseStatus &status,
210  uint16_t short_message,
211  uint16_t length_mismatch,
212  uint16_t checksum_fail) = 0;
213  virtual void StatusMessages(const ResponseStatus &status,
214  const std::vector<StatusMessage> &messages) = 0;
215  virtual void StatusIdDescription(const ResponseStatus &status,
216  const std::string &status_id) = 0;
217  virtual void SubDeviceReporting(const ResponseStatus &status,
218  uint8_t status_type) = 0;
219  virtual void SupportedParameters(
220  const ResponseStatus &status,
221  const std::vector<uint16_t> &parameters) = 0;
222  virtual void ParameterDescription(
223  const ResponseStatus &status,
224  const ParameterDescriptor &description) = 0;
225  virtual void DeviceInfo(const ResponseStatus &status,
226  const DeviceDescriptor &device_info) = 0;
227  virtual void ProductDetailIdList(const ResponseStatus &status,
228  const std::vector<uint16_t> &ids) = 0;
229  virtual void DeviceModelDescription(const ResponseStatus &status,
230  const std::string &description) = 0;
231  virtual void ManufacturerLabel(const ResponseStatus &status,
232  const std::string &label) = 0;
233  virtual void DeviceLabel(const ResponseStatus &status,
234  const std::string &label) = 0;
235  virtual void FactoryDefaults(const ResponseStatus &status,
236  bool using_defaults) = 0;
237  virtual void LanguageCapabilities(
238  const ResponseStatus &status,
239  const std::vector<std::string> &langs) = 0;
240  virtual void Language(const ResponseStatus &status,
241  const std::string &language) = 0;
242  virtual void SoftwareVersionLabel(const ResponseStatus &status,
243  const std::string &label) = 0;
244  virtual void BootSoftwareVersion(const ResponseStatus &status,
245  uint32_t version) = 0;
246  virtual void BootSoftwareVersionLabel(const ResponseStatus &status,
247  const std::string &label) = 0;
248  virtual void DMXPersonality(const ResponseStatus &status,
249  uint8_t current_personality,
250  uint8_t personality_count) = 0;
251  virtual void DMXPersonalityDescription(const ResponseStatus &status,
252  uint8_t personality,
253  uint16_t slots_requires,
254  const std::string &label) = 0;
255  virtual void DMXAddress(const ResponseStatus &status,
256  uint16_t start_address) = 0;
257  virtual void SlotInfo(const ResponseStatus &status,
258  const std::vector<SlotDescriptor> &slots) = 0;
259  virtual void SlotDescription(const ResponseStatus &status,
260  uint16_t slot_offset,
261  const std::string &description) = 0;
262  virtual void SlotDefaultValues(
263  const ResponseStatus &status,
264  const std::vector<SlotDefault> &defaults) = 0;
265  virtual void SensorDefinition(const ResponseStatus &status,
266  const SensorDescriptor &descriptor) = 0;
267  virtual void SensorValue(const ResponseStatus &status,
268  const SensorValueDescriptor &descriptor) = 0;
269  virtual void DeviceHours(const ResponseStatus &status,
270  uint32_t hours) = 0;
271  virtual void LampHours(const ResponseStatus &status,
272  uint32_t hours) = 0;
273  virtual void LampStrikes(const ResponseStatus &status,
274  uint32_t hours) = 0;
275  virtual void LampState(const ResponseStatus &status,
276  uint8_t state) = 0;
277  virtual void LampMode(const ResponseStatus &status,
278  uint8_t mode) = 0;
279  virtual void DevicePowerCycles(const ResponseStatus &status,
280  uint32_t hours) = 0;
281  virtual void DisplayInvert(const ResponseStatus &status,
282  uint8_t invert_mode) = 0;
283  virtual void DisplayLevel(const ResponseStatus &status,
284  uint8_t level) = 0;
285  virtual void PanInvert(const ResponseStatus &status,
286  uint8_t inverted) = 0;
287  virtual void TiltInvert(const ResponseStatus &status,
288  uint8_t inverted) = 0;
289  virtual void PanTiltSwap(const ResponseStatus &status,
290  uint8_t inverted) = 0;
291  virtual void IdentifyDevice(const ResponseStatus &status,
292  bool mode) = 0;
293  virtual void Clock(const ResponseStatus &status,
294  const ClockValue &clock) = 0;
295  virtual void PowerState(const ResponseStatus &status,
296  uint8_t power_state) = 0;
297  virtual void ResetDevice(const ResponseStatus &status,
298  uint8_t reset_device) = 0;
299  virtual void SelfTestEnabled(const ResponseStatus &status,
300  bool is_enabled) = 0;
301  virtual void SelfTestDescription(const ResponseStatus &status,
302  uint8_t self_test_number,
303  const std::string &description) = 0;
304  virtual void PresetPlaybackMode(const ResponseStatus &status,
305  uint16_t preset_mode,
306  uint8_t level) = 0;
307 
308  virtual void DefaultHandler(const ResponseStatus &status,
309  uint16_t pid,
310  const std::string &data) = 0;
311 };
312 
313 
314 /*
315  * The high level RDM API.
316  */
317 class RDMAPI {
318  public:
319  explicit RDMAPI(class RDMAPIImplInterface *impl):
320  m_impl(impl) {
321  }
322  ~RDMAPI() {}
323 
324  // This is used to check for queued messages
325  uint8_t OutstandingMessagesCount(const UID &uid);
326 
327  // Proxy methods
328  bool GetProxiedDeviceCount(
329  unsigned int universe,
330  const UID &uid,
332  const ResponseStatus&,
333  uint16_t,
334  bool> *callback,
335  std::string *error);
336 
337  bool GetProxiedDevices(
338  unsigned int universe,
339  const UID &uid,
341  const ResponseStatus&,
342  const std::vector<UID>&> *callback,
343  std::string *error);
344 
345  // Network Management Methods
346  bool GetCommStatus(
347  unsigned int universe,
348  const UID &uid,
350  const ResponseStatus&,
351  uint16_t,
352  uint16_t,
353  uint16_t> *callback,
354  std::string *error);
355 
356  bool ClearCommStatus(
357  unsigned int universe,
358  const UID &uid,
360  std::string *error);
361 
362  // There are two types of queued message calls, one that takes a
363  // QueuedMessageHandler and the other than just takes a callback.
364 
365  // When complete, the appropriate method will be called on the handler.
366  bool GetQueuedMessage(
367  unsigned int universe,
368  const UID &uid,
369  rdm_status_type status_type,
370  QueuedMessageHandler *handler,
371  std::string *error);
372 
373  // When complete, the callback will be run. It's up to the caller to unpack
374  // the message.
375  bool GetQueuedMessage(
376  unsigned int universe,
377  const UID &uid,
378  rdm_status_type status_type,
380  const ResponseStatus&,
381  uint16_t,
382  const std::string&> *callback,
383  std::string *error);
384 
385  bool GetStatusMessage(
386  unsigned int universe,
387  const UID &uid,
388  rdm_status_type status_type,
390  const ResponseStatus&,
391  const std::vector<StatusMessage>&> *callback,
392  std::string *error);
393 
394  bool GetStatusIdDescription(
395  unsigned int universe,
396  const UID &uid,
397  uint16_t status_id,
399  const std::string&> *callback,
400  std::string *error);
401 
402  bool ClearStatusId(
403  unsigned int universe,
404  const UID &uid,
405  uint16_t sub_device,
407  std::string *error);
408 
409  bool GetSubDeviceReporting(
410  unsigned int universe,
411  const UID &uid,
412  uint16_t sub_device,
414  const ResponseStatus&,
415  uint8_t> *callback,
416  std::string *error);
417 
418  bool SetSubDeviceReporting(
419  unsigned int universe,
420  const UID &uid,
421  uint16_t sub_device,
422  rdm_status_type status_type,
424  std::string *error);
425 
426  // Information Methods
427  bool GetSupportedParameters(
428  unsigned int universe,
429  const UID &uid,
430  uint16_t sub_device,
432  const ResponseStatus&,
433  const std::vector<uint16_t> &> *callback,
434  std::string *error);
435 
436  bool GetParameterDescription(
437  unsigned int universe,
438  const UID &uid,
439  uint16_t pid,
441  const ResponseStatus&,
442  const ParameterDescriptor&> *callback,
443  std::string *error);
444 
445  bool GetDeviceInfo(
446  unsigned int universe,
447  const UID &uid,
448  uint16_t sub_device,
450  const ResponseStatus&,
451  const DeviceDescriptor&> *callback,
452  std::string *error);
453 
454  bool GetProductDetailIdList(
455  unsigned int universe,
456  const UID &uid,
457  uint16_t sub_device,
459  const ResponseStatus&,
460  const std::vector<uint16_t> &> *callback,
461  std::string *error);
462 
463  bool GetDeviceModelDescription(
464  unsigned int universe,
465  const UID &uid,
466  uint16_t sub_device,
468  const ResponseStatus&,
469  const std::string&> *callback,
470  std::string *error);
471 
472  bool GetManufacturerLabel(
473  unsigned int universe,
474  const UID &uid,
475  uint16_t sub_device,
477  const ResponseStatus&,
478  const std::string&> *callback,
479  std::string *error);
480 
481  bool GetDeviceLabel(
482  unsigned int universe,
483  const UID &uid,
484  uint16_t sub_device,
486  const ResponseStatus&,
487  const std::string&> *callback,
488  std::string *error);
489 
490  bool SetDeviceLabel(
491  unsigned int universe,
492  const UID &uid,
493  uint16_t sub_device,
494  const std::string &label,
496  std::string *error);
497 
498  bool GetFactoryDefaults(
499  unsigned int universe,
500  const UID &uid,
501  uint16_t sub_device,
503  const ResponseStatus&,
504  bool> *callback,
505  std::string *error);
506 
507  bool ResetToFactoryDefaults(
508  unsigned int universe,
509  const UID &uid,
510  uint16_t sub_device,
512  std::string *error);
513 
514  bool GetLanguageCapabilities(
515  unsigned int universe,
516  const UID &uid,
517  uint16_t sub_device,
519  const ResponseStatus&,
520  const std::vector<std::string>&> *callback,
521  std::string *error);
522 
523  bool GetLanguage(
524  unsigned int universe,
525  const UID &uid,
526  uint16_t sub_device,
528  const ResponseStatus&,
529  const std::string&> *callback,
530  std::string *error);
531 
532  bool SetLanguage(
533  unsigned int universe,
534  const UID &uid,
535  uint16_t sub_device,
536  const std::string &language,
538  std::string *error);
539 
540  bool GetSoftwareVersionLabel(
541  unsigned int universe,
542  const UID &uid,
543  uint16_t sub_device,
545  const ResponseStatus&,
546  const std::string&> *callback,
547  std::string *error);
548 
549  bool GetBootSoftwareVersion(
550  unsigned int universe,
551  const UID &uid,
552  uint16_t sub_device,
554  const ResponseStatus&,
555  uint32_t> *callback,
556  std::string *error);
557 
558  bool GetBootSoftwareVersionLabel(
559  unsigned int universe,
560  const UID &uid,
561  uint16_t sub_device,
563  const ResponseStatus&,
564  const std::string&> *callback,
565  std::string *error);
566 
567  bool GetDMXPersonality(
568  unsigned int universe,
569  const UID &uid,
570  uint16_t sub_device,
572  const ResponseStatus&,
573  uint8_t,
574  uint8_t> *callback,
575  std::string *error);
576 
577  bool SetDMXPersonality(
578  unsigned int universe,
579  const UID &uid,
580  uint16_t sub_device,
581  uint8_t personality,
583  std::string *error);
584 
585  bool GetDMXPersonalityDescription(
586  unsigned int universe,
587  const UID &uid,
588  uint16_t sub_device,
589  uint8_t personality,
591  const ResponseStatus&,
592  uint8_t,
593  uint16_t,
594  const std::string&> *callback,
595  std::string *error);
596 
597  bool GetDMXAddress(
598  unsigned int universe,
599  const UID &uid,
600  uint16_t sub_device,
602  const ResponseStatus&,
603  uint16_t> *callback,
604  std::string *error);
605 
606  bool SetDMXAddress(
607  unsigned int universe,
608  const UID &uid,
609  uint16_t sub_device,
610  uint16_t start_address,
612  std::string *error);
613 
614  bool GetSlotInfo(
615  unsigned int universe,
616  const UID &uid,
617  uint16_t sub_device,
619  const ResponseStatus&,
620  const std::vector<SlotDescriptor>&> *callback,
621  std::string *error);
622 
623  bool GetSlotDescription(
624  unsigned int universe,
625  const UID &uid,
626  uint16_t sub_device,
627  uint16_t slot_offset,
629  const ResponseStatus&,
630  uint16_t,
631  const std::string&> *callback,
632  std::string *error);
633 
634  bool GetSlotDefaultValues(
635  unsigned int universe,
636  const UID &uid,
637  uint16_t sub_device,
639  const ResponseStatus&,
640  const std::vector<SlotDefault>&> *callback,
641  std::string *error);
642 
643  bool GetSensorDefinition(
644  unsigned int universe,
645  const UID &uid,
646  uint16_t sub_device,
647  uint8_t sensor_number,
649  const ResponseStatus&,
650  const SensorDescriptor&> *callback,
651  std::string *error);
652 
653  bool GetSensorValue(
654  unsigned int universe,
655  const UID &uid,
656  uint16_t sub_device,
657  uint8_t sensor_number,
659  const ResponseStatus&,
660  const SensorValueDescriptor&> *callback,
661  std::string *error);
662 
663  bool SetSensorValue(
664  unsigned int universe,
665  const UID &uid,
666  uint16_t sub_device,
667  uint8_t sensor_number,
669  const ResponseStatus&,
670  const SensorValueDescriptor&> *callback,
671  std::string *error);
672 
673  bool RecordSensors(
674  unsigned int universe,
675  const UID &uid,
676  uint16_t sub_device,
677  uint8_t sensor_number,
679  std::string *error);
680 
681  bool GetDeviceHours(
682  unsigned int universe,
683  const UID &uid,
684  uint16_t sub_device,
686  const ResponseStatus&,
687  uint32_t> *callback,
688  std::string *error);
689 
690  bool SetDeviceHours(
691  unsigned int universe,
692  const UID &uid,
693  uint16_t sub_device,
694  uint32_t device_hours,
696  std::string *error);
697 
698  bool GetLampHours(
699  unsigned int universe,
700  const UID &uid,
701  uint16_t sub_device,
703  const ResponseStatus&,
704  uint32_t> *callback,
705  std::string *error);
706 
707  bool SetLampHours(
708  unsigned int universe,
709  const UID &uid,
710  uint16_t sub_device,
711  uint32_t lamp_hours,
713  std::string *error);
714 
715  bool GetLampStrikes(
716  unsigned int universe,
717  const UID &uid,
718  uint16_t sub_device,
720  const ResponseStatus&,
721  uint32_t> *callback,
722  std::string *error);
723 
724  bool SetLampStrikes(
725  unsigned int universe,
726  const UID &uid,
727  uint16_t sub_device,
728  uint32_t lamp_strikes,
730  std::string *error);
731 
732  bool GetLampState(
733  unsigned int universe,
734  const UID &uid,
735  uint16_t sub_device,
737  std::string *error);
738 
739  bool SetLampState(
740  unsigned int universe,
741  const UID &uid,
742  uint16_t sub_device,
743  uint8_t lamp_state,
745  std::string *error);
746 
747  bool GetLampMode(
748  unsigned int universe,
749  const UID &uid,
750  uint16_t sub_device,
752  std::string *error);
753 
754  bool SetLampMode(
755  unsigned int universe,
756  const UID &uid,
757  uint16_t sub_device,
758  uint8_t lamp_mode,
760  std::string *error);
761 
762  bool GetDevicePowerCycles(
763  unsigned int universe,
764  const UID &uid,
765  uint16_t sub_device,
767  const ResponseStatus&,
768  uint32_t> *callback,
769  std::string *error);
770 
771  bool SetDevicePowerCycles(
772  unsigned int universe,
773  const UID &uid,
774  uint16_t sub_device,
775  uint32_t power_cycles,
777  std::string *error);
778 
779  bool GetDisplayInvert(
780  unsigned int universe,
781  const UID &uid,
782  uint16_t sub_device,
784  std::string *error);
785 
786  bool SetDisplayInvert(
787  unsigned int universe,
788  const UID &uid,
789  uint16_t sub_device,
790  uint8_t display_invert,
792  std::string *error);
793 
794  bool GetDisplayLevel(
795  unsigned int universe,
796  const UID &uid,
797  uint16_t sub_device,
799  std::string *error);
800 
801  bool SetDisplayLevel(
802  unsigned int universe,
803  const UID &uid,
804  uint16_t sub_device,
805  uint8_t display_level,
807  std::string *error);
808 
809  bool GetPanInvert(
810  unsigned int universe,
811  const UID &uid,
812  uint16_t sub_device,
814  std::string *error);
815 
816  bool SetPanInvert(
817  unsigned int universe,
818  const UID &uid,
819  uint16_t sub_device,
820  uint8_t invert,
822  std::string *error);
823 
824  bool GetTiltInvert(
825  unsigned int universe,
826  const UID &uid,
827  uint16_t sub_device,
829  std::string *error);
830 
831  bool SetTiltInvert(
832  unsigned int universe,
833  const UID &uid,
834  uint16_t sub_device,
835  uint8_t invert,
837  std::string *error);
838 
839  bool GetPanTiltSwap(
840  unsigned int universe,
841  const UID &uid,
842  uint16_t sub_device,
844  std::string *error);
845 
846  bool SetPanTiltSwap(
847  unsigned int universe,
848  const UID &uid,
849  uint16_t sub_device,
850  uint8_t swap,
852  std::string *error);
853 
854  bool GetClock(
855  unsigned int universe,
856  const UID &uid,
857  uint16_t sub_device,
859  const ResponseStatus&,
860  const ClockValue&> *callback,
861  std::string *error);
862 
863  bool SetClock(
864  unsigned int universe,
865  const UID &uid,
866  uint16_t sub_device,
867  const ClockValue &clock,
869  std::string *error);
870 
871  bool GetIdentifyDevice(
872  unsigned int universe,
873  const UID &uid,
874  uint16_t sub_device,
876  std::string *error);
877 
878  bool IdentifyDevice(
879  unsigned int universe,
880  const UID &uid,
881  uint16_t sub_device,
882  bool mode,
884  std::string *error);
885 
886  bool ResetDevice(
887  unsigned int universe,
888  const UID &uid,
889  uint16_t sub_device,
890  bool warm_reset,
892  std::string *error);
893 
894  bool GetPowerState(
895  unsigned int universe,
896  const UID &uid,
897  uint16_t sub_device,
899  std::string *error);
900 
901  bool SetPowerState(
902  unsigned int universe,
903  const UID &uid,
904  uint16_t sub_device,
905  rdm_power_state power_state,
907  std::string *error);
908 
909  bool SetResetDevice(
910  unsigned int universe,
911  const UID &uid,
912  uint16_t sub_device,
913  rdm_reset_device_mode reset_device,
915  std::string *error);
916 
917  bool GetDnsHostname(
918  unsigned int universe,
919  const UID &uid,
920  uint16_t sub_device,
922  const ResponseStatus&,
923  const std::string&> *callback,
924  std::string *error);
925 
926  bool SetDnsHostname(
927  unsigned int universe,
928  const UID &uid,
929  uint16_t sub_device,
930  const std::string &label,
932  std::string *error);
933 
934  bool GetDnsDomainName(
935  unsigned int universe,
936  const UID &uid,
937  uint16_t sub_device,
939  const ResponseStatus&,
940  const std::string&> *callback,
941  std::string *error);
942 
943  bool SetDnsDomainName(
944  unsigned int universe,
945  const UID &uid,
946  uint16_t sub_device,
947  const std::string &label,
949  std::string *error);
950 
951  bool GetCurve(
952  unsigned int universe,
953  const UID &uid,
954  uint16_t sub_device,
956  const ResponseStatus&,
957  uint8_t,
958  uint8_t> *callback,
959  std::string *error);
960 
961  bool SetCurve(
962  unsigned int universe,
963  const UID &uid,
964  uint16_t sub_device,
965  uint8_t curve,
967  std::string *error);
968 
969  bool GetCurveDescription(
970  unsigned int universe,
971  const UID &uid,
972  uint16_t sub_device,
973  uint8_t curve,
975  const ResponseStatus&,
976  uint8_t,
977  const std::string&> *callback,
978  std::string *error);
979 
980  bool GetDimmerInfo(
981  unsigned int universe,
982  const UID &uid,
983  uint16_t sub_device,
985  const ResponseStatus&,
986  const DimmerInfoDescriptor&> *callback,
987  std::string *error);
988 
989  bool GetDimmerMinimumLevels(
990  unsigned int universe,
991  const UID &uid,
992  uint16_t sub_device,
994  const ResponseStatus&,
995  const DimmerMinimumDescriptor&> *callback,
996  std::string *error);
997 
998  bool SetDimmerMinimumLevels(
999  unsigned int universe,
1000  const UID &uid,
1001  uint16_t sub_device,
1002  uint16_t min_increasing,
1003  uint16_t min_decreasing,
1004  bool on_below_min,
1006  std::string *error);
1007 
1008  bool GetDimmerMaximumLevel(
1009  unsigned int universe,
1010  const UID &uid,
1011  uint16_t pid,
1013  const ResponseStatus&,
1014  uint16_t> *callback,
1015  std::string *error);
1016 
1017  bool SetDimmerMaximumLevel(
1018  unsigned int universe,
1019  const UID &uid,
1020  uint16_t sub_device,
1021  uint16_t maximum_level,
1023  std::string *error);
1024 
1025  bool SelfTestEnabled(
1026  unsigned int universe,
1027  const UID &uid,
1028  uint16_t sub_device,
1030  std::string *error);
1031 
1032  bool PerformSelfTest(
1033  unsigned int universe,
1034  const UID &uid,
1035  uint16_t sub_device,
1036  uint8_t self_test_number,
1038  std::string *error);
1039 
1040  bool SelfTestDescription(
1041  unsigned int universe,
1042  const UID &uid,
1043  uint16_t sub_device,
1044  uint8_t self_test_number,
1046  const ResponseStatus&,
1047  uint8_t,
1048  const std::string&> *callback,
1049  std::string *error);
1050 
1051  bool CapturePreset(
1052  unsigned int universe,
1053  const UID &uid,
1054  uint16_t sub_device,
1055  uint16_t scene,
1056  uint16_t fade_up_time,
1057  uint16_t fade_down_time,
1058  uint16_t wait_time,
1060  std::string *error);
1061 
1062  bool PresetPlaybackMode(
1063  unsigned int universe,
1064  const UID &uid,
1065  uint16_t sub_device,
1067  const ResponseStatus&,
1068  uint16_t,
1069  uint8_t> *callback,
1070  std::string *error);
1071 
1072  bool SetPresetPlaybackMode(
1073  unsigned int universe,
1074  const UID &uid,
1075  uint16_t sub_device,
1076  uint16_t playback_mode,
1077  uint8_t level,
1079  std::string *error);
1080 
1081  // Handlers, these are called by the RDMAPIImpl.
1082 
1083  // Generic handlers
1084  void _HandleCustomLengthLabelResponse(
1086  const ResponseStatus&,
1087  const std::string&> *callback,
1088  uint8_t length,
1089  const ResponseStatus &status,
1090  const std::string &data);
1091 
1092  void _HandleLabelResponse(
1094  const ResponseStatus&,
1095  const std::string&> *callback,
1096  const ResponseStatus &status,
1097  const std::string &data);
1098 
1099  void _HandleBoolResponse(
1101  const ResponseStatus&,
1102  bool> *callback,
1103  const ResponseStatus &status,
1104  const std::string &data);
1105 
1106  void _HandleU8Response(
1108  const ResponseStatus&,
1109  uint8_t> *callback,
1110  const ResponseStatus &status,
1111  const std::string &data);
1112 
1113  void _HandleU16Response(
1115  const ResponseStatus&,
1116  uint16_t> *callback,
1117  const ResponseStatus &status,
1118  const std::string &data);
1119 
1120  void _HandleU32Response(
1122  const ResponseStatus&,
1123  uint32_t> *callback,
1124  const ResponseStatus &status,
1125  const std::string &data);
1126 
1127  void _HandleEmptyResponse(
1129  const ResponseStatus &status,
1130  const std::string &data);
1131 
1132  // specific handlers follow
1133  void _HandleGetProxiedDeviceCount(
1135  const ResponseStatus&,
1136  uint16_t,
1137  bool> *callback,
1138  const ResponseStatus &status,
1139  const std::string &data);
1140 
1141  void _HandleGetProxiedDevices(
1143  const ResponseStatus&,
1144  const std::vector<UID>&> *callback,
1145  const ResponseStatus &status,
1146  const std::string &data);
1147 
1148  void _HandleGetCommStatus(
1150  const ResponseStatus&,
1151  uint16_t,
1152  uint16_t,
1153  uint16_t> *callback,
1154  const ResponseStatus &status,
1155  const std::string &data);
1156 
1157  void _HandleQueuedMessage(
1158  QueuedMessageHandler *handler,
1159  const ResponseStatus &status,
1160  uint16_t pid,
1161  const std::string &data);
1162 
1163  void _HandleGetStatusMessage(
1165  const ResponseStatus&,
1166  const std::vector<StatusMessage>&> *callback,
1167  const ResponseStatus &status,
1168  const std::string &data);
1169 
1170  void _HandleGetSubDeviceReporting(
1172  const ResponseStatus&,
1173  uint8_t> *callback,
1174  const ResponseStatus &status,
1175  const std::string &data);
1176 
1177  void _HandleGetSupportedParameters(
1179  const ResponseStatus&,
1180  const std::vector<uint16_t>&> *callback,
1181  const ResponseStatus &status,
1182  const std::string &data);
1183 
1184  void _HandleGetParameterDescriptor(
1186  const ResponseStatus&,
1187  const ParameterDescriptor&> *callback,
1188  const ResponseStatus &status,
1189  const std::string &data);
1190 
1191  void _HandleGetDeviceDescriptor(
1193  const ResponseStatus&,
1194  const DeviceDescriptor&> *callback,
1195  const ResponseStatus &status,
1196  const std::string &data);
1197 
1198  void _HandleGetProductDetailIdList(
1200  const ResponseStatus&,
1201  const std::vector<uint16_t>&> *callback,
1202  const ResponseStatus &status,
1203  const std::string &data);
1204 
1205  void _HandleGetLanguageCapabilities(
1207  const ResponseStatus&,
1208  const std::vector<std::string>&> *callback,
1209  const ResponseStatus &status,
1210  const std::string &data);
1211 
1212  void _HandleGetLanguage(
1214  const ResponseStatus&,
1215  const std::string&> *callback,
1216  const ResponseStatus &status,
1217  const std::string &data);
1218 
1219  void _HandleGetBootSoftwareVersion(
1221  const ResponseStatus&,
1222  uint32_t> *callback,
1223  const ResponseStatus &status,
1224  const std::string &data);
1225 
1226  void _HandleGetDMXPersonality(
1228  const ResponseStatus&,
1229  uint8_t,
1230  uint8_t> *callback,
1231  const ResponseStatus &status,
1232  const std::string &data);
1233 
1234  void _HandleGetDMXPersonalityDescription(
1236  const ResponseStatus&,
1237  uint8_t,
1238  uint16_t,
1239  const std::string&> *callback,
1240  const ResponseStatus &status,
1241  const std::string &data);
1242 
1243  void _HandleGetSlotInfo(
1245  const ResponseStatus&,
1246  const std::vector<SlotDescriptor>&> *callback,
1247  const ResponseStatus &status,
1248  const std::string &data);
1249 
1250  void _HandleGetSlotDescription(
1252  const ResponseStatus&,
1253  uint16_t,
1254  const std::string&> *callback,
1255  const ResponseStatus &status,
1256  const std::string &data);
1257 
1258  void _HandleGetSlotDefaultValues(
1260  const ResponseStatus&,
1261  const std::vector<SlotDefault>&> *callback,
1262  const ResponseStatus &status,
1263  const std::string &data);
1264 
1265  void _HandleGetSensorDefinition(
1267  const ResponseStatus&,
1268  const SensorDescriptor&> *callback,
1269  const ResponseStatus &status,
1270  const std::string &data);
1271 
1272  void _HandleSensorValue(
1274  const ResponseStatus&,
1275  const SensorValueDescriptor&> *callback,
1276  const ResponseStatus &status,
1277  const std::string &data);
1278 
1279  void _HandleClock(
1281  const ResponseStatus&,
1282  const ClockValue&> *callback,
1283  const ResponseStatus &status,
1284  const std::string &data);
1285 
1286  void _HandleSelfTestDescription(
1288  const ResponseStatus&,
1289  uint8_t,
1290  const std::string&> *callback,
1291  const ResponseStatus &status,
1292  const std::string &data);
1293 
1294  void _HandlePlaybackMode(
1296  const ResponseStatus&,
1297  uint16_t,
1298  uint8_t> *callback,
1299  const ResponseStatus &status,
1300  const std::string &data);
1301 
1302  void _HandleGetCurve(
1304  const ResponseStatus&,
1305  uint8_t,
1306  uint8_t> *callback,
1307  const ResponseStatus &status,
1308  const std::string &data);
1309 
1310  void _HandleGetCurveDescription(
1312  const ResponseStatus&,
1313  uint8_t,
1314  const std::string&> *callback,
1315  const ResponseStatus &status,
1316  const std::string &data);
1317 
1318  void _HandleGetDimmerInfo(
1320  const ResponseStatus&,
1321  const DimmerInfoDescriptor&> *callback,
1322  const ResponseStatus &status,
1323  const std::string &data);
1324 
1325  void _HandleGetDimmerMinimumLevels(
1327  const ResponseStatus&,
1328  const DimmerMinimumDescriptor&> *callback,
1329  const ResponseStatus &status,
1330  const std::string &data);
1331 
1332  private:
1333  class RDMAPIImplInterface *m_impl;
1334  std::map<UID, uint8_t> m_outstanding_messages;
1335 
1336  bool GenericGetU8(
1337  unsigned int universe,
1338  const UID &uid,
1339  uint8_t sub_device,
1341  uint16_t pid,
1342  std::string *error);
1343 
1344  bool GenericSetU8(
1345  unsigned int universe,
1346  const UID &uid,
1347  uint16_t sub_device,
1348  uint8_t value,
1350  uint16_t pid,
1351  std::string *error);
1352 
1353  bool GenericGetU16(
1354  unsigned int universe,
1355  const UID &uid,
1356  uint16_t sub_device,
1358  const ResponseStatus&,
1359  uint16_t> *callback,
1360  uint16_t pid,
1361  std::string *error);
1362 
1363  bool GenericSetU16(
1364  unsigned int universe,
1365  const UID &uid,
1366  uint16_t sub_device,
1367  uint16_t value,
1369  uint16_t pid,
1370  std::string *error);
1371 
1372  bool GenericGetU32(
1373  unsigned int universe,
1374  const UID &uid,
1375  uint16_t sub_device,
1377  const ResponseStatus&,
1378  uint32_t> *callback,
1379  uint16_t pid,
1380  std::string *error);
1381 
1382  bool GenericSetU32(
1383  unsigned int universe,
1384  const UID &uid,
1385  uint16_t sub_device,
1386  uint32_t value,
1388  uint16_t pid,
1389  std::string *error);
1390 
1391  // Check that a callback is not null
1392  template <typename callback_type>
1393  bool CheckCallback(std::string *error, const callback_type *cb) {
1394  if (cb == NULL) {
1395  if (error)
1396  *error = "Callback is null, this is a programming error";
1397  return true;
1398  }
1399  return false;
1400  }
1401 
1402  // Check that a UID is not a broadcast address
1403  template <typename callback_type>
1404  bool CheckNotBroadcast(const UID &uid, std::string *error,
1405  const callback_type *cb) {
1406  if (uid.IsBroadcast()) {
1407  if (error)
1408  *error = "Cannot send to broadcast address";
1409  delete cb;
1410  return true;
1411  }
1412  return false;
1413  }
1414 
1415  // Check the subdevice value is valid
1416  template <typename callback_type>
1417  bool CheckValidSubDevice(uint16_t sub_device,
1418  bool broadcast_allowed,
1419  std::string *error,
1420  const callback_type *cb) {
1421  if (sub_device <= 0x0200)
1422  return false;
1423 
1424  if (broadcast_allowed && sub_device == ALL_RDM_SUBDEVICES)
1425  return false;
1426 
1427  if (error) {
1428  *error = "Sub device must be <= 0x0200";
1429  if (broadcast_allowed)
1430  *error += " or 0xffff";
1431  }
1432  delete cb;
1433  return true;
1434  }
1435 
1436  bool CheckReturnStatus(bool status, std::string *error);
1437  void SetIncorrectPDL(ResponseStatus *status,
1438  unsigned int actual,
1439  unsigned int expected);
1440 };
1441 } // namespace rdm
1442 } // namespace ola
1443 #endif // INCLUDE_OLA_RDM_RDMAPI_H_
#define PACK(__Declaration__)
Pack structures.
Definition: Macro.h:170
Definition: RDMAPI.h:317
Definition: RDMAPI.h:58
A RDM unique identifier (UID).
bool IsBroadcast() const
Check if this UID is a broadcast or vendorcast UID.
Definition: UID.h:175
The interface for an RDM API Implementation.
Represents the state of a response and/or any error codes.
Definition: RDMAPIImplInterface.h:51
Used to get the current time.
Definition: Clock.h:242
Definition: RDMAPI.h:132
Definition: RDMAPI.h:191
Definition: RDMAPI.h:200
This is the interface for an RDMAPI implementation.
Definition: RDMAPIImplInterface.h:83
Definition: RDMAPI.h:178
Helper macros.
A 1 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:1004
Various constants used in RDM.
A 3 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:2850
Represents a RDM UID.
Definition: UID.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: RDMAPI.h:70
A 2 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:1907
A 4 argument callback which deletes itself after it&#39;s run.
Definition: Callback.h:3833