Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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>
45 #include <ola/rdm/RDMEnums.h>
46 #include <ola/rdm/UID.h>
47 #include <map>
48 #include <string>
49 #include <vector>
50 
51 namespace ola {
52 namespace rdm {
53 
54 using std::string;
55 using std::vector;
60 
61 
62 /*
63  * Represents a Status Message
64  */
65 typedef struct {
66  uint16_t sub_device;
67  uint16_t status_message_id;
68  int16_t value1;
69  int16_t value2;
70  uint8_t status_type;
72 
73 
74 /*
75  * Represents the description for a parameter
76  */
77 typedef struct {
78  uint16_t pid;
79  uint8_t pdl_size;
80  uint8_t data_type;
81  uint8_t command_class;
82  uint8_t unit;
83  uint8_t prefix;
84  uint32_t min_value;
85  uint32_t default_value;
86  uint32_t max_value;
87  string description;
89 
90 
91 /*
92  * Represents a DeviceDescriptor reply
93  */
94 struct device_info_s {
95  uint8_t protocol_version_high;
96  uint8_t protocol_version_low;
97  uint16_t device_model;
98  uint16_t product_category;
99  uint32_t software_version;
100  uint16_t dmx_footprint;
101  uint8_t current_personality;
102  uint8_t personaility_count;
103  uint16_t dmx_start_address;
104  uint16_t sub_device_count;
105  uint8_t sensor_count;
106 } __attribute__((packed));
107 
108 typedef struct device_info_s DeviceDescriptor;
109 
110 
111 /*
112  * Information about a DMX slot
113  */
114 struct slot_info_s {
115  uint16_t slot_offset;
116  uint8_t slot_type;
117  uint16_t slot_label;
118 } __attribute__((packed));
119 
120 typedef struct slot_info_s SlotDescriptor;
121 
122 /*
123  * The default values for a slot
124  */
126  uint16_t slot_offset;
127  uint8_t default_value;
128 } __attribute__((packed));
129 
130 typedef struct slot_default_s SlotDefault;
131 
132 
133 /*
134  * Sensor definition
135  */
136 typedef struct {
137  uint8_t sensor_number;
138  uint8_t type;
139  uint8_t unit;
140  uint8_t prefix;
141  int16_t range_min;
142  int16_t range_max;
143  int16_t normal_min;
144  int16_t normal_max;
145  uint8_t recorded_value_support;
146  string description;
148 
149 
150 /*
151  * Sensor values
152  */
154  uint8_t sensor_number;
155  int16_t present_value;
156  int16_t lowest;
157  int16_t highest;
158  int16_t recorded;
159 } __attribute__((packed));
160 
162 
163 /*
164  * Clock structure
165  */
167  uint16_t year;
168  uint8_t month;
169  uint8_t day;
170  uint8_t hour;
171  uint8_t minute;
172  uint8_t second;
173 } __attribute__((packed));
174 
175 typedef struct clock_value_s ClockValue;
176 
177 /*
178  * The interface for objects which deal with queued messages
179  */
181  public:
182  virtual ~QueuedMessageHandler() {}
183 
184  virtual void ProxiedDeviceCount(const ResponseStatus &status,
185  uint16_t device_count,
186  bool list_changed) = 0;
187  virtual void ProxiedDevices(const ResponseStatus &status,
188  const vector<UID> &uids) = 0;
189  virtual void CommStatus(const ResponseStatus &status,
190  uint16_t short_message,
191  uint16_t length_mismatch,
192  uint16_t checksum_fail) = 0;
193  virtual void StatusMessages(const ResponseStatus &status,
194  const vector<StatusMessage> &messages) = 0;
195  virtual void StatusIdDescription(const ResponseStatus &status,
196  const string &status_id) = 0;
197  virtual void SubDeviceReporting(const ResponseStatus &status,
198  uint8_t status_type) = 0;
199  virtual void SupportedParameters(const ResponseStatus &status,
200  const vector<uint16_t> &parameters) = 0;
201  virtual void ParameterDescription(
202  const ResponseStatus &status,
203  const ParameterDescriptor &description) = 0;
204  virtual void DeviceInfo(const ResponseStatus &status,
205  const DeviceDescriptor &device_info) = 0;
206  virtual void ProductDetailIdList(const ResponseStatus &status,
207  const vector<uint16_t> &ids) = 0;
208  virtual void DeviceModelDescription(const ResponseStatus &status,
209  const string &description) = 0;
210  virtual void ManufacturerLabel(const ResponseStatus &status,
211  const string &label) = 0;
212  virtual void DeviceLabel(const ResponseStatus &status,
213  const string &label) = 0;
214  virtual void FactoryDefaults(const ResponseStatus &status,
215  bool using_defaults) = 0;
216  virtual void LanguageCapabilities(const ResponseStatus &status,
217  const vector<string> &langs) = 0;
218  virtual void Language(const ResponseStatus &status,
219  const string &language) = 0;
220  virtual void SoftwareVersionLabel(const ResponseStatus &status,
221  const string &label) = 0;
222  virtual void BootSoftwareVersion(const ResponseStatus &status,
223  uint32_t version) = 0;
224  virtual void BootSoftwareVersionLabel(const ResponseStatus &status,
225  const string &label) = 0;
226  virtual void DMXPersonality(const ResponseStatus &status,
227  uint8_t current_personality,
228  uint8_t personality_count) = 0;
229  virtual void DMXPersonalityDescription(const ResponseStatus &status,
230  uint8_t personality,
231  uint16_t slots_requires,
232  const string &label) = 0;
233  virtual void DMXAddress(const ResponseStatus &status,
234  uint16_t start_address) = 0;
235  virtual void SlotInfo(const ResponseStatus &status,
236  const vector<SlotDescriptor> &slots) = 0;
237  virtual void SlotDescription(const ResponseStatus &status,
238  uint16_t slot_offset,
239  const string &description) = 0;
240  virtual void SlotDefaultValues(const ResponseStatus &status,
241  const vector<SlotDefault> &defaults) = 0;
242  virtual void SensorDefinition(const ResponseStatus &status,
243  const SensorDescriptor &descriptor) = 0;
244  virtual void SensorValue(const ResponseStatus &status,
245  const SensorValueDescriptor &descriptor) = 0;
246  virtual void DeviceHours(const ResponseStatus &status,
247  uint32_t hours) = 0;
248  virtual void LampHours(const ResponseStatus &status,
249  uint32_t hours) = 0;
250  virtual void LampStrikes(const ResponseStatus &status,
251  uint32_t hours) = 0;
252  virtual void LampState(const ResponseStatus &status,
253  uint8_t state) = 0;
254  virtual void LampMode(const ResponseStatus &status,
255  uint8_t mode) = 0;
256  virtual void DevicePowerCycles(const ResponseStatus &status,
257  uint32_t hours) = 0;
258  virtual void DisplayInvert(const ResponseStatus &status,
259  uint8_t invert_mode) = 0;
260  virtual void DisplayLevel(const ResponseStatus &status,
261  uint8_t level) = 0;
262  virtual void PanInvert(const ResponseStatus &status,
263  uint8_t inverted) = 0;
264  virtual void TiltInvert(const ResponseStatus &status,
265  uint8_t inverted) = 0;
266  virtual void PanTiltSwap(const ResponseStatus &status,
267  uint8_t inverted) = 0;
268  virtual void IdentifyMode(const ResponseStatus &status,
269  bool mode) = 0;
270  virtual void Clock(const ResponseStatus &status,
271  const ClockValue &clock) = 0;
272  virtual void PowerState(const ResponseStatus &status,
273  uint8_t power_state) = 0;
274  virtual void ResetDevice(const ResponseStatus &status,
275  uint8_t reset_device) = 0;
276  virtual void SelfTestEnabled(const ResponseStatus &status,
277  bool is_enabled) = 0;
278  virtual void SelfTestDescription(const ResponseStatus &status,
279  uint8_t self_test_number,
280  const string &description) = 0;
281  virtual void PresetPlaybackMode(const ResponseStatus &status,
282  uint16_t preset_mode,
283  uint8_t level) = 0;
284 
285  virtual void DefaultHandler(const ResponseStatus &status,
286  uint16_t pid,
287  const string &data) = 0;
288 };
289 
290 
291 /*
292  * The high level RDM API.
293  */
294 class RDMAPI {
295  public:
296  explicit RDMAPI(class RDMAPIImplInterface *impl):
297  m_impl(impl) {
298  }
299  ~RDMAPI() {}
300 
301  // This is used to check for queued messages
302  uint8_t OutstandingMessagesCount(const UID &uid);
303 
304  // Proxy methods
305  bool GetProxiedDeviceCount(
306  unsigned int universe,
307  const UID &uid,
308  SingleUseCallback3<void,
309  const ResponseStatus&,
310  uint16_t,
311  bool> *callback,
312  string *error);
313 
314  bool GetProxiedDevices(
315  unsigned int universe,
316  const UID &uid,
317  SingleUseCallback2<void,
318  const ResponseStatus&,
319  const vector<UID>&> *callback,
320  string *error);
321 
322  // Network Managment Methods
323  bool GetCommStatus(
324  unsigned int universe,
325  const UID &uid,
326  SingleUseCallback4<void,
327  const ResponseStatus&,
328  uint16_t,
329  uint16_t,
330  uint16_t> *callback,
331  string *error);
332 
333  bool ClearCommStatus(
334  unsigned int universe,
335  const UID &uid,
337  string *error);
338 
339  // There are two types of queued message calls, one that takes a
340  // QueuedMessageHandler and the other than just takes a callback.
341 
342  // When complete, the appropriate method will be called on the handler.
343  bool GetQueuedMessage(
344  unsigned int universe,
345  const UID &uid,
346  rdm_status_type status_type,
347  QueuedMessageHandler *handler,
348  string *error);
349 
350  // When complete, the callback will be run. It's up to the caller to unpack
351  // the message.
352  bool GetQueuedMessage(
353  unsigned int universe,
354  const UID &uid,
355  rdm_status_type status_type,
356  SingleUseCallback3<void,
357  const ResponseStatus&,
358  uint16_t,
359  const string&> *callback,
360  string *error);
361 
362  bool GetStatusMessage(
363  unsigned int universe,
364  const UID &uid,
365  rdm_status_type status_type,
366  SingleUseCallback2<void,
367  const ResponseStatus&,
368  const vector<StatusMessage>&> *callback,
369  string *error);
370 
371  bool GetStatusIdDescription(
372  unsigned int universe,
373  const UID &uid,
374  uint16_t status_id,
375  SingleUseCallback2<void, const ResponseStatus&,
376  const string&> *callback,
377  string *error);
378 
379  bool ClearStatusId(
380  unsigned int universe,
381  const UID &uid,
382  uint16_t sub_device,
384  string *error);
385 
386  bool GetSubDeviceReporting(
387  unsigned int universe,
388  const UID &uid,
389  uint16_t sub_device,
390  SingleUseCallback2<void,
391  const ResponseStatus&,
392  uint8_t> *callback,
393  string *error);
394 
395  bool SetSubDeviceReporting(
396  unsigned int universe,
397  const UID &uid,
398  uint16_t sub_device,
399  rdm_status_type status_type,
401  string *error);
402 
403  // Information Methods
404  bool GetSupportedParameters(
405  unsigned int universe,
406  const UID &uid,
407  uint16_t sub_device,
408  SingleUseCallback2<void,
409  const ResponseStatus&,
410  const vector<uint16_t> &> *callback,
411  string *error);
412 
413  bool GetParameterDescription(
414  unsigned int universe,
415  const UID &uid,
416  uint16_t pid,
417  SingleUseCallback2<void,
418  const ResponseStatus&,
419  const ParameterDescriptor&> *callback,
420  string *error);
421 
422  bool GetDeviceInfo(
423  unsigned int universe,
424  const UID &uid,
425  uint16_t sub_device,
426  SingleUseCallback2<void,
427  const ResponseStatus&,
428  const DeviceDescriptor&> *callback,
429  string *error);
430 
431  bool GetProductDetailIdList(
432  unsigned int universe,
433  const UID &uid,
434  uint16_t sub_device,
435  SingleUseCallback2<void,
436  const ResponseStatus&,
437  const vector<uint16_t> &> *callback,
438  string *error);
439 
440  bool GetDeviceModelDescription(
441  unsigned int universe,
442  const UID &uid,
443  uint16_t sub_device,
444  SingleUseCallback2<void,
445  const ResponseStatus&,
446  const string&> *callback,
447  string *error);
448 
449  bool GetManufacturerLabel(
450  unsigned int universe,
451  const UID &uid,
452  uint16_t sub_device,
453  SingleUseCallback2<void,
454  const ResponseStatus&,
455  const string&> *callback,
456  string *error);
457 
458  bool GetDeviceLabel(
459  unsigned int universe,
460  const UID &uid,
461  uint16_t sub_device,
462  SingleUseCallback2<void,
463  const ResponseStatus&,
464  const string&> *callback,
465  string *error);
466 
467  bool SetDeviceLabel(
468  unsigned int universe,
469  const UID &uid,
470  uint16_t sub_device,
471  const string &label,
473  string *error);
474 
475  bool GetFactoryDefaults(
476  unsigned int universe,
477  const UID &uid,
478  uint16_t sub_device,
479  SingleUseCallback2<void,
480  const ResponseStatus&,
481  bool> *callback,
482  string *error);
483 
484  bool ResetToFactoryDefaults(
485  unsigned int universe,
486  const UID &uid,
487  uint16_t sub_device,
489  string *error);
490 
491  bool GetLanguageCapabilities(
492  unsigned int universe,
493  const UID &uid,
494  uint16_t sub_device,
495  SingleUseCallback2<void,
496  const ResponseStatus&,
497  const vector<string>&> *callback,
498  string *error);
499 
500  bool GetLanguage(
501  unsigned int universe,
502  const UID &uid,
503  uint16_t sub_device,
504  SingleUseCallback2<void,
505  const ResponseStatus&,
506  const string&> *callback,
507  string *error);
508 
509  bool SetLanguage(
510  unsigned int universe,
511  const UID &uid,
512  uint16_t sub_device,
513  const string &language,
515  string *error);
516 
517  bool GetSoftwareVersionLabel(
518  unsigned int universe,
519  const UID &uid,
520  uint16_t sub_device,
521  SingleUseCallback2<void,
522  const ResponseStatus&,
523  const string&> *callback,
524  string *error);
525 
526  bool GetBootSoftwareVersion(
527  unsigned int universe,
528  const UID &uid,
529  uint16_t sub_device,
530  SingleUseCallback2<void,
531  const ResponseStatus&,
532  uint32_t> *callback,
533  string *error);
534 
535  bool GetBootSoftwareVersionLabel(
536  unsigned int universe,
537  const UID &uid,
538  uint16_t sub_device,
539  SingleUseCallback2<void,
540  const ResponseStatus&,
541  const string&> *callback,
542  string *error);
543 
544  bool GetDMXPersonality(
545  unsigned int universe,
546  const UID &uid,
547  uint16_t sub_device,
548  SingleUseCallback3<void,
549  const ResponseStatus&,
550  uint8_t,
551  uint8_t> *callback,
552  string *error);
553 
554  bool SetDMXPersonality(
555  unsigned int universe,
556  const UID &uid,
557  uint16_t sub_device,
558  uint8_t personality,
560  string *error);
561 
562  bool GetDMXPersonalityDescription(
563  unsigned int universe,
564  const UID &uid,
565  uint16_t sub_device,
566  uint8_t personality,
567  SingleUseCallback4<void,
568  const ResponseStatus&,
569  uint8_t,
570  uint16_t,
571  const string&> *callback,
572  string *error);
573 
574  bool GetDMXAddress(
575  unsigned int universe,
576  const UID &uid,
577  uint16_t sub_device,
578  SingleUseCallback2<void,
579  const ResponseStatus&,
580  uint16_t> *callback,
581  string *error);
582 
583  bool SetDMXAddress(
584  unsigned int universe,
585  const UID &uid,
586  uint16_t sub_device,
587  uint16_t start_address,
589  string *error);
590 
591  bool GetSlotInfo(
592  unsigned int universe,
593  const UID &uid,
594  uint16_t sub_device,
595  SingleUseCallback2<void,
596  const ResponseStatus&,
597  const vector<SlotDescriptor>&> *callback,
598  string *error);
599 
600  bool GetSlotDescription(
601  unsigned int universe,
602  const UID &uid,
603  uint16_t sub_device,
604  uint16_t slot_offset,
605  SingleUseCallback3<void,
606  const ResponseStatus&,
607  uint16_t,
608  const string&> *callback,
609  string *error);
610 
611  bool GetSlotDefaultValues(
612  unsigned int universe,
613  const UID &uid,
614  uint16_t sub_device,
615  SingleUseCallback2<void,
616  const ResponseStatus&,
617  const vector<SlotDefault>&> *callback,
618  string *error);
619 
620  bool GetSensorDefinition(
621  unsigned int universe,
622  const UID &uid,
623  uint16_t sub_device,
624  uint8_t sensor_number,
625  SingleUseCallback2<void,
626  const ResponseStatus&,
627  const SensorDescriptor&> *callback,
628  string *error);
629 
630  bool GetSensorValue(
631  unsigned int universe,
632  const UID &uid,
633  uint16_t sub_device,
634  uint8_t sensor_number,
635  SingleUseCallback2<void,
636  const ResponseStatus&,
637  const SensorValueDescriptor&> *callback,
638  string *error);
639 
640  bool SetSensorValue(
641  unsigned int universe,
642  const UID &uid,
643  uint16_t sub_device,
644  uint8_t sensor_number,
645  SingleUseCallback2<void,
646  const ResponseStatus&,
647  const SensorValueDescriptor&> *callback,
648  string *error);
649 
650  bool RecordSensors(
651  unsigned int universe,
652  const UID &uid,
653  uint16_t sub_device,
654  uint8_t sensor_number,
656  string *error);
657 
658  bool GetDeviceHours(
659  unsigned int universe,
660  const UID &uid,
661  uint16_t sub_device,
663  string *error);
664 
665  bool SetDeviceHours(
666  unsigned int universe,
667  const UID &uid,
668  uint16_t sub_device,
669  uint32_t device_hours,
671  string *error);
672 
673  bool GetLampHours(
674  unsigned int universe,
675  const UID &uid,
676  uint16_t sub_device,
678  string *error);
679 
680  bool SetLampHours(
681  unsigned int universe,
682  const UID &uid,
683  uint16_t sub_device,
684  uint32_t lamp_hours,
686  string *error);
687 
688  bool GetLampStrikes(
689  unsigned int universe,
690  const UID &uid,
691  uint16_t sub_device,
693  string *error);
694 
695  bool SetLampStrikes(
696  unsigned int universe,
697  const UID &uid,
698  uint16_t sub_device,
699  uint32_t lamp_strikes,
701  string *error);
702 
703  bool GetLampState(
704  unsigned int universe,
705  const UID &uid,
706  uint16_t sub_device,
708  string *error);
709 
710  bool SetLampState(
711  unsigned int universe,
712  const UID &uid,
713  uint16_t sub_device,
714  uint8_t lamp_state,
716  string *error);
717 
718  bool GetLampMode(
719  unsigned int universe,
720  const UID &uid,
721  uint16_t sub_device,
723  string *error);
724 
725  bool SetLampMode(
726  unsigned int universe,
727  const UID &uid,
728  uint16_t sub_device,
729  uint8_t lamp_mode,
731  string *error);
732 
733  bool GetDevicePowerCycles(
734  unsigned int universe,
735  const UID &uid,
736  uint16_t sub_device,
738  string *error);
739 
740  bool SetDevicePowerCycles(
741  unsigned int universe,
742  const UID &uid,
743  uint16_t sub_device,
744  uint32_t power_cycles,
746  string *error);
747 
748  bool GetDisplayInvert(
749  unsigned int universe,
750  const UID &uid,
751  uint16_t sub_device,
753  string *error);
754 
755  bool SetDisplayInvert(
756  unsigned int universe,
757  const UID &uid,
758  uint16_t sub_device,
759  uint8_t display_invert,
761  string *error);
762 
763  bool GetDisplayLevel(
764  unsigned int universe,
765  const UID &uid,
766  uint16_t sub_device,
768  string *error);
769 
770  bool SetDisplayLevel(
771  unsigned int universe,
772  const UID &uid,
773  uint16_t sub_device,
774  uint8_t display_level,
776  string *error);
777 
778  bool GetPanInvert(
779  unsigned int universe,
780  const UID &uid,
781  uint16_t sub_device,
783  string *error);
784 
785  bool SetPanInvert(
786  unsigned int universe,
787  const UID &uid,
788  uint16_t sub_device,
789  uint8_t invert,
791  string *error);
792 
793  bool GetTiltInvert(
794  unsigned int universe,
795  const UID &uid,
796  uint16_t sub_device,
798  string *error);
799 
800  bool SetTiltInvert(
801  unsigned int universe,
802  const UID &uid,
803  uint16_t sub_device,
804  uint8_t invert,
806  string *error);
807 
808  bool GetPanTiltSwap(
809  unsigned int universe,
810  const UID &uid,
811  uint16_t sub_device,
813  string *error);
814 
815  bool SetPanTiltSwap(
816  unsigned int universe,
817  const UID &uid,
818  uint16_t sub_device,
819  uint8_t swap,
821  string *error);
822 
823  bool GetClock(
824  unsigned int universe,
825  const UID &uid,
826  uint16_t sub_device,
827  SingleUseCallback2<void,
828  const ResponseStatus&,
829  const ClockValue&> *callback,
830  string *error);
831 
832  bool SetClock(
833  unsigned int universe,
834  const UID &uid,
835  uint16_t sub_device,
836  const ClockValue &clock,
838  string *error);
839 
840  bool GetIdentifyMode(
841  unsigned int universe,
842  const UID &uid,
843  uint16_t sub_device,
845  string *error);
846 
847  bool IdentifyDevice(
848  unsigned int universe,
849  const UID &uid,
850  uint16_t sub_device,
851  bool mode,
853  string *error);
854 
855  bool ResetDevice(
856  unsigned int universe,
857  const UID &uid,
858  uint16_t sub_device,
859  bool warm_reset,
861  string *error);
862 
863  bool GetPowerState(
864  unsigned int universe,
865  const UID &uid,
866  uint16_t sub_device,
868  string *error);
869 
870  bool SetPowerState(
871  unsigned int universe,
872  const UID &uid,
873  uint16_t sub_device,
874  rdm_power_state power_state,
876  string *error);
877 
878  bool SetResetDevice(
879  unsigned int universe,
880  const UID &uid,
881  uint16_t sub_device,
882  rdm_reset_device_mode reset_device,
884  string *error);
885 
886  bool SelfTestEnabled(
887  unsigned int universe,
888  const UID &uid,
889  uint16_t sub_device,
891  string *error);
892 
893  bool PerformSelfTest(
894  unsigned int universe,
895  const UID &uid,
896  uint16_t sub_device,
897  uint8_t self_test_number,
899  string *error);
900 
901  bool SelfTestDescription(
902  unsigned int universe,
903  const UID &uid,
904  uint16_t sub_device,
905  uint8_t self_test_number,
906  SingleUseCallback3<void,
907  const ResponseStatus&,
908  uint8_t,
909  const string&> *callback,
910  string *error);
911 
912  bool CapturePreset(
913  unsigned int universe,
914  const UID &uid,
915  uint16_t sub_device,
916  uint16_t scene,
917  uint16_t fade_up_time,
918  uint16_t fade_down_time,
919  uint16_t wait_time,
921  string *error);
922 
923  bool PresetPlaybackMode(
924  unsigned int universe,
925  const UID &uid,
926  uint16_t sub_device,
927  SingleUseCallback3<void,
928  const ResponseStatus&,
929  uint16_t,
930  uint8_t> *callback,
931  string *error);
932 
933  bool SetPresetPlaybackMode(
934  unsigned int universe,
935  const UID &uid,
936  uint16_t sub_device,
937  uint16_t playback_mode,
938  uint8_t level,
940  string *error);
941 
942  // Handlers, these are called by the RDMAPIImpl.
943 
944  // Generic handlers
945  void _HandleLabelResponse(
946  SingleUseCallback2<void,
947  const ResponseStatus&,
948  const string&> *callback,
949  const ResponseStatus &status,
950  const string &data);
951 
952  void _HandleBoolResponse(
953  SingleUseCallback2<void,
954  const ResponseStatus&,
955  bool> *callback,
956  const ResponseStatus &status,
957  const string &data);
958 
959  void _HandleU8Response(
960  SingleUseCallback2<void,
961  const ResponseStatus&,
962  uint8_t> *callback,
963  const ResponseStatus &status,
964  const string &data);
965 
966  void _HandleU32Response(
967  SingleUseCallback2<void,
968  const ResponseStatus&,
969  uint32_t> *callback,
970  const ResponseStatus &status,
971  const string &data);
972 
973  void _HandleEmptyResponse(
975  const ResponseStatus &status,
976  const string &data);
977 
978  // specific handlers follow
979  void _HandleGetProxiedDeviceCount(
980  SingleUseCallback3<void,
981  const ResponseStatus&,
982  uint16_t,
983  bool> *callback,
984  const ResponseStatus &status,
985  const string &data);
986 
987  void _HandleGetProxiedDevices(
988  SingleUseCallback2<void,
989  const ResponseStatus&,
990  const vector<UID>&> *callback,
991  const ResponseStatus &status,
992  const string &data);
993 
994  void _HandleGetCommStatus(
995  SingleUseCallback4<void,
996  const ResponseStatus&,
997  uint16_t,
998  uint16_t,
999  uint16_t> *callback,
1000  const ResponseStatus &status,
1001  const string &data);
1002 
1003  void _HandleQueuedMessage(
1004  QueuedMessageHandler *handler,
1005  const ResponseStatus &status,
1006  uint16_t pid,
1007  const string &data);
1008 
1009  void _HandleGetStatusMessage(
1010  SingleUseCallback2<void,
1011  const ResponseStatus&,
1012  const vector<StatusMessage>&> *callback,
1013  const ResponseStatus &status,
1014  const string &data);
1015 
1016  void _HandleGetSubDeviceReporting(
1017  SingleUseCallback2<void,
1018  const ResponseStatus&,
1019  uint8_t> *callback,
1020  const ResponseStatus &status,
1021  const string &data);
1022 
1023  void _HandleGetSupportedParameters(
1024  SingleUseCallback2<void,
1025  const ResponseStatus&,
1026  const vector<uint16_t>&> *callback,
1027  const ResponseStatus &status,
1028  const string &data);
1029 
1030  void _HandleGetParameterDescriptor(
1031  SingleUseCallback2<void,
1032  const ResponseStatus&,
1033  const ParameterDescriptor&> *callback,
1034  const ResponseStatus &status,
1035  const string &data);
1036 
1037  void _HandleGetDeviceDescriptor(
1038  SingleUseCallback2<void,
1039  const ResponseStatus&,
1040  const DeviceDescriptor&> *callback,
1041  const ResponseStatus &status,
1042  const string &data);
1043 
1044  void _HandleGetProductDetailIdList(
1045  SingleUseCallback2<void,
1046  const ResponseStatus&,
1047  const vector<uint16_t>&> *callback,
1048  const ResponseStatus &status,
1049  const string &data);
1050 
1051  void _HandleGetLanguageCapabilities(
1052  SingleUseCallback2<void,
1053  const ResponseStatus&,
1054  const vector<string>&> *callback,
1055  const ResponseStatus &status,
1056  const string &data);
1057 
1058  void _HandleGetLanguage(
1059  SingleUseCallback2<void,
1060  const ResponseStatus&,
1061  const string&> *callback,
1062  const ResponseStatus &status,
1063  const string &data);
1064 
1065  void _HandleGetBootSoftwareVersion(
1066  SingleUseCallback2<void,
1067  const ResponseStatus&,
1068  uint32_t> *callback,
1069  const ResponseStatus &status,
1070  const string &data);
1071 
1072  void _HandleGetDMXPersonality(
1073  SingleUseCallback3<void,
1074  const ResponseStatus&,
1075  uint8_t,
1076  uint8_t> *callback,
1077  const ResponseStatus &status,
1078  const string &data);
1079 
1080  void _HandleGetDMXPersonalityDescription(
1081  SingleUseCallback4<void,
1082  const ResponseStatus&,
1083  uint8_t,
1084  uint16_t,
1085  const string&> *callback,
1086  const ResponseStatus &status,
1087  const string &data);
1088 
1089  void _HandleGetDMXAddress(
1090  SingleUseCallback2<void,
1091  const ResponseStatus&,
1092  uint16_t> *callback,
1093  const ResponseStatus &status,
1094  const string &data);
1095 
1096  void _HandleGetSlotInfo(
1097  SingleUseCallback2<void,
1098  const ResponseStatus&,
1099  const vector<SlotDescriptor>&> *callback,
1100  const ResponseStatus &status,
1101  const string &data);
1102 
1103  void _HandleGetSlotDescription(
1104  SingleUseCallback3<void,
1105  const ResponseStatus&,
1106  uint16_t,
1107  const string&> *callback,
1108  const ResponseStatus &status,
1109  const string &data);
1110 
1111  void _HandleGetSlotDefaultValues(
1112  SingleUseCallback2<void,
1113  const ResponseStatus&,
1114  const vector<SlotDefault>&> *callback,
1115  const ResponseStatus &status,
1116  const string &data);
1117 
1118  void _HandleGetSensorDefinition(
1119  SingleUseCallback2<void,
1120  const ResponseStatus&,
1121  const SensorDescriptor&> *callback,
1122  const ResponseStatus &status,
1123  const string &data);
1124 
1125  void _HandleSensorValue(
1126  SingleUseCallback2<void,
1127  const ResponseStatus&,
1128  const SensorValueDescriptor&> *callback,
1129  const ResponseStatus &status,
1130  const string &data);
1131 
1132  void _HandleClock(
1133  SingleUseCallback2<void,
1134  const ResponseStatus&,
1135  const ClockValue&> *callback,
1136  const ResponseStatus &status,
1137  const string &data);
1138 
1140  SingleUseCallback3<void,
1141  const ResponseStatus&,
1142  uint8_t,
1143  const string&> *callback,
1144  const ResponseStatus &status,
1145  const string &data);
1146 
1147  void _HandlePlaybackMode(
1148  SingleUseCallback3<void,
1149  const ResponseStatus&,
1150  uint16_t,
1151  uint8_t> *callback,
1152  const ResponseStatus &status,
1153  const string &data);
1154 
1155  private:
1156  class RDMAPIImplInterface *m_impl;
1157  std::map<UID, uint8_t> m_outstanding_messages;
1158 
1159  enum {LABEL_SIZE = 32};
1160 
1161  bool GenericGetU8(
1162  unsigned int universe,
1163  const UID &uid,
1164  uint8_t sub_device,
1166  uint16_t pid,
1167  string *error);
1168 
1169  bool GenericSetU8(
1170  unsigned int universe,
1171  const UID &uid,
1172  uint16_t sub_device,
1173  uint8_t value,
1175  uint16_t pid,
1176  string *error);
1177 
1178  bool GenericGetU32(
1179  unsigned int universe,
1180  const UID &uid,
1181  uint16_t sub_device,
1183  uint16_t pid,
1184  string *error);
1185 
1186  bool GenericSetU32(
1187  unsigned int universe,
1188  const UID &uid,
1189  uint16_t sub_device,
1190  uint32_t value,
1192  uint16_t pid,
1193  string *error);
1194 
1195  // Check that a callback is not null
1196  template <typename callback_type>
1197  bool CheckCallback(string *error, const callback_type *cb) {
1198  if (cb == NULL) {
1199  if (error)
1200  *error = "Callback is null, this is a programming error";
1201  return true;
1202  }
1203  return false;
1204  }
1205 
1206  // Check that a UID is not a broadcast address
1207  template <typename callback_type>
1208  bool CheckNotBroadcast(const UID &uid, string *error,
1209  const callback_type *cb) {
1210  if (uid.IsBroadcast()) {
1211  if (error)
1212  *error = "Cannot send to broadcast address";
1213  delete cb;
1214  return true;
1215  }
1216  return false;
1217  }
1218 
1219  // Check the subdevice value is valid
1220  template <typename callback_type>
1221  bool CheckValidSubDevice(uint16_t sub_device,
1222  bool broadcast_allowed,
1223  string *error,
1224  const callback_type *cb) {
1225  if (sub_device <= 0x0200)
1226  return false;
1227 
1228  if (broadcast_allowed && sub_device == ALL_RDM_SUBDEVICES)
1229  return false;
1230 
1231  if (error) {
1232  *error = "Sub device must be <= 0x0200";
1233  if (broadcast_allowed)
1234  *error += " or 0xffff";
1235  }
1236  delete cb;
1237  return true;
1238  }
1239 
1240  bool CheckReturnStatus(bool status, string *error);
1241  void SetIncorrectPDL(ResponseStatus *status,
1242  unsigned int actual,
1243  unsigned int expected);
1244 };
1245 } // namespace rdm
1246 } // namespace ola
1247 #endif // INCLUDE_OLA_RDM_RDMAPI_H_