Open Lighting Architecture  0.9.5
 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., 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  * The interface for objects which deal with queued messages
177  */
179  public:
180  virtual ~QueuedMessageHandler() {}
181 
182  virtual void ProxiedDeviceCount(const ResponseStatus &status,
183  uint16_t device_count,
184  bool list_changed) = 0;
185  virtual void ProxiedDevices(const ResponseStatus &status,
186  const std::vector<UID> &uids) = 0;
187  virtual void CommStatus(const ResponseStatus &status,
188  uint16_t short_message,
189  uint16_t length_mismatch,
190  uint16_t checksum_fail) = 0;
191  virtual void StatusMessages(const ResponseStatus &status,
192  const std::vector<StatusMessage> &messages) = 0;
193  virtual void StatusIdDescription(const ResponseStatus &status,
194  const std::string &status_id) = 0;
195  virtual void SubDeviceReporting(const ResponseStatus &status,
196  uint8_t status_type) = 0;
197  virtual void SupportedParameters(
198  const ResponseStatus &status,
199  const std::vector<uint16_t> &parameters) = 0;
200  virtual void ParameterDescription(
201  const ResponseStatus &status,
202  const ParameterDescriptor &description) = 0;
203  virtual void DeviceInfo(const ResponseStatus &status,
204  const DeviceDescriptor &device_info) = 0;
205  virtual void ProductDetailIdList(const ResponseStatus &status,
206  const std::vector<uint16_t> &ids) = 0;
207  virtual void DeviceModelDescription(const ResponseStatus &status,
208  const std::string &description) = 0;
209  virtual void ManufacturerLabel(const ResponseStatus &status,
210  const std::string &label) = 0;
211  virtual void DeviceLabel(const ResponseStatus &status,
212  const std::string &label) = 0;
213  virtual void FactoryDefaults(const ResponseStatus &status,
214  bool using_defaults) = 0;
215  virtual void LanguageCapabilities(
216  const ResponseStatus &status,
217  const std::vector<std::string> &langs) = 0;
218  virtual void Language(const ResponseStatus &status,
219  const std::string &language) = 0;
220  virtual void SoftwareVersionLabel(const ResponseStatus &status,
221  const std::string &label) = 0;
222  virtual void BootSoftwareVersion(const ResponseStatus &status,
223  uint32_t version) = 0;
224  virtual void BootSoftwareVersionLabel(const ResponseStatus &status,
225  const std::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 std::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 std::vector<SlotDescriptor> &slots) = 0;
237  virtual void SlotDescription(const ResponseStatus &status,
238  uint16_t slot_offset,
239  const std::string &description) = 0;
240  virtual void SlotDefaultValues(
241  const ResponseStatus &status,
242  const std::vector<SlotDefault> &defaults) = 0;
243  virtual void SensorDefinition(const ResponseStatus &status,
244  const SensorDescriptor &descriptor) = 0;
245  virtual void SensorValue(const ResponseStatus &status,
246  const SensorValueDescriptor &descriptor) = 0;
247  virtual void DeviceHours(const ResponseStatus &status,
248  uint32_t hours) = 0;
249  virtual void LampHours(const ResponseStatus &status,
250  uint32_t hours) = 0;
251  virtual void LampStrikes(const ResponseStatus &status,
252  uint32_t hours) = 0;
253  virtual void LampState(const ResponseStatus &status,
254  uint8_t state) = 0;
255  virtual void LampMode(const ResponseStatus &status,
256  uint8_t mode) = 0;
257  virtual void DevicePowerCycles(const ResponseStatus &status,
258  uint32_t hours) = 0;
259  virtual void DisplayInvert(const ResponseStatus &status,
260  uint8_t invert_mode) = 0;
261  virtual void DisplayLevel(const ResponseStatus &status,
262  uint8_t level) = 0;
263  virtual void PanInvert(const ResponseStatus &status,
264  uint8_t inverted) = 0;
265  virtual void TiltInvert(const ResponseStatus &status,
266  uint8_t inverted) = 0;
267  virtual void PanTiltSwap(const ResponseStatus &status,
268  uint8_t inverted) = 0;
269  virtual void IdentifyDevice(const ResponseStatus &status,
270  bool mode) = 0;
271  virtual void Clock(const ResponseStatus &status,
272  const ClockValue &clock) = 0;
273  virtual void PowerState(const ResponseStatus &status,
274  uint8_t power_state) = 0;
275  virtual void ResetDevice(const ResponseStatus &status,
276  uint8_t reset_device) = 0;
277  virtual void SelfTestEnabled(const ResponseStatus &status,
278  bool is_enabled) = 0;
279  virtual void SelfTestDescription(const ResponseStatus &status,
280  uint8_t self_test_number,
281  const std::string &description) = 0;
282  virtual void PresetPlaybackMode(const ResponseStatus &status,
283  uint16_t preset_mode,
284  uint8_t level) = 0;
285 
286  virtual void DefaultHandler(const ResponseStatus &status,
287  uint16_t pid,
288  const std::string &data) = 0;
289 };
290 
291 
292 /*
293  * The high level RDM API.
294  */
295 class RDMAPI {
296  public:
297  explicit RDMAPI(class RDMAPIImplInterface *impl):
298  m_impl(impl) {
299  }
300  ~RDMAPI() {}
301 
302  // This is used to check for queued messages
303  uint8_t OutstandingMessagesCount(const UID &uid);
304 
305  // Proxy methods
306  bool GetProxiedDeviceCount(
307  unsigned int universe,
308  const UID &uid,
310  const ResponseStatus&,
311  uint16_t,
312  bool> *callback,
313  std::string *error);
314 
315  bool GetProxiedDevices(
316  unsigned int universe,
317  const UID &uid,
319  const ResponseStatus&,
320  const std::vector<UID>&> *callback,
321  std::string *error);
322 
323  // Network Managment Methods
324  bool GetCommStatus(
325  unsigned int universe,
326  const UID &uid,
328  const ResponseStatus&,
329  uint16_t,
330  uint16_t,
331  uint16_t> *callback,
332  std::string *error);
333 
334  bool ClearCommStatus(
335  unsigned int universe,
336  const UID &uid,
338  std::string *error);
339 
340  // There are two types of queued message calls, one that takes a
341  // QueuedMessageHandler and the other than just takes a callback.
342 
343  // When complete, the appropriate method will be called on the handler.
344  bool GetQueuedMessage(
345  unsigned int universe,
346  const UID &uid,
347  rdm_status_type status_type,
348  QueuedMessageHandler *handler,
349  std::string *error);
350 
351  // When complete, the callback will be run. It's up to the caller to unpack
352  // the message.
353  bool GetQueuedMessage(
354  unsigned int universe,
355  const UID &uid,
356  rdm_status_type status_type,
358  const ResponseStatus&,
359  uint16_t,
360  const std::string&> *callback,
361  std::string *error);
362 
363  bool GetStatusMessage(
364  unsigned int universe,
365  const UID &uid,
366  rdm_status_type status_type,
368  const ResponseStatus&,
369  const std::vector<StatusMessage>&> *callback,
370  std::string *error);
371 
372  bool GetStatusIdDescription(
373  unsigned int universe,
374  const UID &uid,
375  uint16_t status_id,
377  const std::string&> *callback,
378  std::string *error);
379 
380  bool ClearStatusId(
381  unsigned int universe,
382  const UID &uid,
383  uint16_t sub_device,
385  std::string *error);
386 
387  bool GetSubDeviceReporting(
388  unsigned int universe,
389  const UID &uid,
390  uint16_t sub_device,
392  const ResponseStatus&,
393  uint8_t> *callback,
394  std::string *error);
395 
396  bool SetSubDeviceReporting(
397  unsigned int universe,
398  const UID &uid,
399  uint16_t sub_device,
400  rdm_status_type status_type,
402  std::string *error);
403 
404  // Information Methods
405  bool GetSupportedParameters(
406  unsigned int universe,
407  const UID &uid,
408  uint16_t sub_device,
410  const ResponseStatus&,
411  const std::vector<uint16_t> &> *callback,
412  std::string *error);
413 
414  bool GetParameterDescription(
415  unsigned int universe,
416  const UID &uid,
417  uint16_t pid,
419  const ResponseStatus&,
420  const ParameterDescriptor&> *callback,
421  std::string *error);
422 
423  bool GetDeviceInfo(
424  unsigned int universe,
425  const UID &uid,
426  uint16_t sub_device,
428  const ResponseStatus&,
429  const DeviceDescriptor&> *callback,
430  std::string *error);
431 
432  bool GetProductDetailIdList(
433  unsigned int universe,
434  const UID &uid,
435  uint16_t sub_device,
437  const ResponseStatus&,
438  const std::vector<uint16_t> &> *callback,
439  std::string *error);
440 
441  bool GetDeviceModelDescription(
442  unsigned int universe,
443  const UID &uid,
444  uint16_t sub_device,
446  const ResponseStatus&,
447  const std::string&> *callback,
448  std::string *error);
449 
450  bool GetManufacturerLabel(
451  unsigned int universe,
452  const UID &uid,
453  uint16_t sub_device,
455  const ResponseStatus&,
456  const std::string&> *callback,
457  std::string *error);
458 
459  bool GetDeviceLabel(
460  unsigned int universe,
461  const UID &uid,
462  uint16_t sub_device,
464  const ResponseStatus&,
465  const std::string&> *callback,
466  std::string *error);
467 
468  bool SetDeviceLabel(
469  unsigned int universe,
470  const UID &uid,
471  uint16_t sub_device,
472  const std::string &label,
474  std::string *error);
475 
476  bool GetFactoryDefaults(
477  unsigned int universe,
478  const UID &uid,
479  uint16_t sub_device,
481  const ResponseStatus&,
482  bool> *callback,
483  std::string *error);
484 
485  bool ResetToFactoryDefaults(
486  unsigned int universe,
487  const UID &uid,
488  uint16_t sub_device,
490  std::string *error);
491 
492  bool GetLanguageCapabilities(
493  unsigned int universe,
494  const UID &uid,
495  uint16_t sub_device,
497  const ResponseStatus&,
498  const std::vector<std::string>&> *callback,
499  std::string *error);
500 
501  bool GetLanguage(
502  unsigned int universe,
503  const UID &uid,
504  uint16_t sub_device,
506  const ResponseStatus&,
507  const std::string&> *callback,
508  std::string *error);
509 
510  bool SetLanguage(
511  unsigned int universe,
512  const UID &uid,
513  uint16_t sub_device,
514  const std::string &language,
516  std::string *error);
517 
518  bool GetSoftwareVersionLabel(
519  unsigned int universe,
520  const UID &uid,
521  uint16_t sub_device,
523  const ResponseStatus&,
524  const std::string&> *callback,
525  std::string *error);
526 
527  bool GetBootSoftwareVersion(
528  unsigned int universe,
529  const UID &uid,
530  uint16_t sub_device,
532  const ResponseStatus&,
533  uint32_t> *callback,
534  std::string *error);
535 
536  bool GetBootSoftwareVersionLabel(
537  unsigned int universe,
538  const UID &uid,
539  uint16_t sub_device,
541  const ResponseStatus&,
542  const std::string&> *callback,
543  std::string *error);
544 
545  bool GetDMXPersonality(
546  unsigned int universe,
547  const UID &uid,
548  uint16_t sub_device,
550  const ResponseStatus&,
551  uint8_t,
552  uint8_t> *callback,
553  std::string *error);
554 
555  bool SetDMXPersonality(
556  unsigned int universe,
557  const UID &uid,
558  uint16_t sub_device,
559  uint8_t personality,
561  std::string *error);
562 
563  bool GetDMXPersonalityDescription(
564  unsigned int universe,
565  const UID &uid,
566  uint16_t sub_device,
567  uint8_t personality,
569  const ResponseStatus&,
570  uint8_t,
571  uint16_t,
572  const std::string&> *callback,
573  std::string *error);
574 
575  bool GetDMXAddress(
576  unsigned int universe,
577  const UID &uid,
578  uint16_t sub_device,
580  const ResponseStatus&,
581  uint16_t> *callback,
582  std::string *error);
583 
584  bool SetDMXAddress(
585  unsigned int universe,
586  const UID &uid,
587  uint16_t sub_device,
588  uint16_t start_address,
590  std::string *error);
591 
592  bool GetSlotInfo(
593  unsigned int universe,
594  const UID &uid,
595  uint16_t sub_device,
597  const ResponseStatus&,
598  const std::vector<SlotDescriptor>&> *callback,
599  std::string *error);
600 
601  bool GetSlotDescription(
602  unsigned int universe,
603  const UID &uid,
604  uint16_t sub_device,
605  uint16_t slot_offset,
607  const ResponseStatus&,
608  uint16_t,
609  const std::string&> *callback,
610  std::string *error);
611 
612  bool GetSlotDefaultValues(
613  unsigned int universe,
614  const UID &uid,
615  uint16_t sub_device,
617  const ResponseStatus&,
618  const std::vector<SlotDefault>&> *callback,
619  std::string *error);
620 
621  bool GetSensorDefinition(
622  unsigned int universe,
623  const UID &uid,
624  uint16_t sub_device,
625  uint8_t sensor_number,
627  const ResponseStatus&,
628  const SensorDescriptor&> *callback,
629  std::string *error);
630 
631  bool GetSensorValue(
632  unsigned int universe,
633  const UID &uid,
634  uint16_t sub_device,
635  uint8_t sensor_number,
637  const ResponseStatus&,
638  const SensorValueDescriptor&> *callback,
639  std::string *error);
640 
641  bool SetSensorValue(
642  unsigned int universe,
643  const UID &uid,
644  uint16_t sub_device,
645  uint8_t sensor_number,
647  const ResponseStatus&,
648  const SensorValueDescriptor&> *callback,
649  std::string *error);
650 
651  bool RecordSensors(
652  unsigned int universe,
653  const UID &uid,
654  uint16_t sub_device,
655  uint8_t sensor_number,
657  std::string *error);
658 
659  bool GetDeviceHours(
660  unsigned int universe,
661  const UID &uid,
662  uint16_t sub_device,
664  const ResponseStatus&,
665  uint32_t> *callback,
666  std::string *error);
667 
668  bool SetDeviceHours(
669  unsigned int universe,
670  const UID &uid,
671  uint16_t sub_device,
672  uint32_t device_hours,
674  std::string *error);
675 
676  bool GetLampHours(
677  unsigned int universe,
678  const UID &uid,
679  uint16_t sub_device,
681  const ResponseStatus&,
682  uint32_t> *callback,
683  std::string *error);
684 
685  bool SetLampHours(
686  unsigned int universe,
687  const UID &uid,
688  uint16_t sub_device,
689  uint32_t lamp_hours,
691  std::string *error);
692 
693  bool GetLampStrikes(
694  unsigned int universe,
695  const UID &uid,
696  uint16_t sub_device,
698  const ResponseStatus&,
699  uint32_t> *callback,
700  std::string *error);
701 
702  bool SetLampStrikes(
703  unsigned int universe,
704  const UID &uid,
705  uint16_t sub_device,
706  uint32_t lamp_strikes,
708  std::string *error);
709 
710  bool GetLampState(
711  unsigned int universe,
712  const UID &uid,
713  uint16_t sub_device,
715  std::string *error);
716 
717  bool SetLampState(
718  unsigned int universe,
719  const UID &uid,
720  uint16_t sub_device,
721  uint8_t lamp_state,
723  std::string *error);
724 
725  bool GetLampMode(
726  unsigned int universe,
727  const UID &uid,
728  uint16_t sub_device,
730  std::string *error);
731 
732  bool SetLampMode(
733  unsigned int universe,
734  const UID &uid,
735  uint16_t sub_device,
736  uint8_t lamp_mode,
738  std::string *error);
739 
740  bool GetDevicePowerCycles(
741  unsigned int universe,
742  const UID &uid,
743  uint16_t sub_device,
745  const ResponseStatus&,
746  uint32_t> *callback,
747  std::string *error);
748 
749  bool SetDevicePowerCycles(
750  unsigned int universe,
751  const UID &uid,
752  uint16_t sub_device,
753  uint32_t power_cycles,
755  std::string *error);
756 
757  bool GetDisplayInvert(
758  unsigned int universe,
759  const UID &uid,
760  uint16_t sub_device,
762  std::string *error);
763 
764  bool SetDisplayInvert(
765  unsigned int universe,
766  const UID &uid,
767  uint16_t sub_device,
768  uint8_t display_invert,
770  std::string *error);
771 
772  bool GetDisplayLevel(
773  unsigned int universe,
774  const UID &uid,
775  uint16_t sub_device,
777  std::string *error);
778 
779  bool SetDisplayLevel(
780  unsigned int universe,
781  const UID &uid,
782  uint16_t sub_device,
783  uint8_t display_level,
785  std::string *error);
786 
787  bool GetPanInvert(
788  unsigned int universe,
789  const UID &uid,
790  uint16_t sub_device,
792  std::string *error);
793 
794  bool SetPanInvert(
795  unsigned int universe,
796  const UID &uid,
797  uint16_t sub_device,
798  uint8_t invert,
800  std::string *error);
801 
802  bool GetTiltInvert(
803  unsigned int universe,
804  const UID &uid,
805  uint16_t sub_device,
807  std::string *error);
808 
809  bool SetTiltInvert(
810  unsigned int universe,
811  const UID &uid,
812  uint16_t sub_device,
813  uint8_t invert,
815  std::string *error);
816 
817  bool GetPanTiltSwap(
818  unsigned int universe,
819  const UID &uid,
820  uint16_t sub_device,
822  std::string *error);
823 
824  bool SetPanTiltSwap(
825  unsigned int universe,
826  const UID &uid,
827  uint16_t sub_device,
828  uint8_t swap,
830  std::string *error);
831 
832  bool GetClock(
833  unsigned int universe,
834  const UID &uid,
835  uint16_t sub_device,
837  const ResponseStatus&,
838  const ClockValue&> *callback,
839  std::string *error);
840 
841  bool SetClock(
842  unsigned int universe,
843  const UID &uid,
844  uint16_t sub_device,
845  const ClockValue &clock,
847  std::string *error);
848 
849  bool GetIdentifyDevice(
850  unsigned int universe,
851  const UID &uid,
852  uint16_t sub_device,
854  std::string *error);
855 
856  bool IdentifyDevice(
857  unsigned int universe,
858  const UID &uid,
859  uint16_t sub_device,
860  bool mode,
862  std::string *error);
863 
864  bool ResetDevice(
865  unsigned int universe,
866  const UID &uid,
867  uint16_t sub_device,
868  bool warm_reset,
870  std::string *error);
871 
872  bool GetPowerState(
873  unsigned int universe,
874  const UID &uid,
875  uint16_t sub_device,
877  std::string *error);
878 
879  bool SetPowerState(
880  unsigned int universe,
881  const UID &uid,
882  uint16_t sub_device,
883  rdm_power_state power_state,
885  std::string *error);
886 
887  bool SetResetDevice(
888  unsigned int universe,
889  const UID &uid,
890  uint16_t sub_device,
891  rdm_reset_device_mode reset_device,
893  std::string *error);
894 
895  bool SelfTestEnabled(
896  unsigned int universe,
897  const UID &uid,
898  uint16_t sub_device,
900  std::string *error);
901 
902  bool PerformSelfTest(
903  unsigned int universe,
904  const UID &uid,
905  uint16_t sub_device,
906  uint8_t self_test_number,
908  std::string *error);
909 
910  bool SelfTestDescription(
911  unsigned int universe,
912  const UID &uid,
913  uint16_t sub_device,
914  uint8_t self_test_number,
916  const ResponseStatus&,
917  uint8_t,
918  const std::string&> *callback,
919  std::string *error);
920 
921  bool CapturePreset(
922  unsigned int universe,
923  const UID &uid,
924  uint16_t sub_device,
925  uint16_t scene,
926  uint16_t fade_up_time,
927  uint16_t fade_down_time,
928  uint16_t wait_time,
930  std::string *error);
931 
932  bool PresetPlaybackMode(
933  unsigned int universe,
934  const UID &uid,
935  uint16_t sub_device,
937  const ResponseStatus&,
938  uint16_t,
939  uint8_t> *callback,
940  std::string *error);
941 
942  bool SetPresetPlaybackMode(
943  unsigned int universe,
944  const UID &uid,
945  uint16_t sub_device,
946  uint16_t playback_mode,
947  uint8_t level,
949  std::string *error);
950 
951  // Handlers, these are called by the RDMAPIImpl.
952 
953  // Generic handlers
954  void _HandleLabelResponse(
956  const ResponseStatus&,
957  const std::string&> *callback,
958  const ResponseStatus &status,
959  const std::string &data);
960 
961  void _HandleBoolResponse(
963  const ResponseStatus&,
964  bool> *callback,
965  const ResponseStatus &status,
966  const std::string &data);
967 
968  void _HandleU8Response(
970  const ResponseStatus&,
971  uint8_t> *callback,
972  const ResponseStatus &status,
973  const std::string &data);
974 
975  void _HandleU32Response(
977  const ResponseStatus&,
978  uint32_t> *callback,
979  const ResponseStatus &status,
980  const std::string &data);
981 
982  void _HandleEmptyResponse(
984  const ResponseStatus &status,
985  const std::string &data);
986 
987  // specific handlers follow
988  void _HandleGetProxiedDeviceCount(
990  const ResponseStatus&,
991  uint16_t,
992  bool> *callback,
993  const ResponseStatus &status,
994  const std::string &data);
995 
996  void _HandleGetProxiedDevices(
998  const ResponseStatus&,
999  const std::vector<UID>&> *callback,
1000  const ResponseStatus &status,
1001  const std::string &data);
1002 
1003  void _HandleGetCommStatus(
1005  const ResponseStatus&,
1006  uint16_t,
1007  uint16_t,
1008  uint16_t> *callback,
1009  const ResponseStatus &status,
1010  const std::string &data);
1011 
1012  void _HandleQueuedMessage(
1013  QueuedMessageHandler *handler,
1014  const ResponseStatus &status,
1015  uint16_t pid,
1016  const std::string &data);
1017 
1018  void _HandleGetStatusMessage(
1020  const ResponseStatus&,
1021  const std::vector<StatusMessage>&> *callback,
1022  const ResponseStatus &status,
1023  const std::string &data);
1024 
1025  void _HandleGetSubDeviceReporting(
1027  const ResponseStatus&,
1028  uint8_t> *callback,
1029  const ResponseStatus &status,
1030  const std::string &data);
1031 
1032  void _HandleGetSupportedParameters(
1034  const ResponseStatus&,
1035  const std::vector<uint16_t>&> *callback,
1036  const ResponseStatus &status,
1037  const std::string &data);
1038 
1039  void _HandleGetParameterDescriptor(
1041  const ResponseStatus&,
1042  const ParameterDescriptor&> *callback,
1043  const ResponseStatus &status,
1044  const std::string &data);
1045 
1046  void _HandleGetDeviceDescriptor(
1048  const ResponseStatus&,
1049  const DeviceDescriptor&> *callback,
1050  const ResponseStatus &status,
1051  const std::string &data);
1052 
1053  void _HandleGetProductDetailIdList(
1055  const ResponseStatus&,
1056  const std::vector<uint16_t>&> *callback,
1057  const ResponseStatus &status,
1058  const std::string &data);
1059 
1060  void _HandleGetLanguageCapabilities(
1062  const ResponseStatus&,
1063  const std::vector<std::string>&> *callback,
1064  const ResponseStatus &status,
1065  const std::string &data);
1066 
1067  void _HandleGetLanguage(
1069  const ResponseStatus&,
1070  const std::string&> *callback,
1071  const ResponseStatus &status,
1072  const std::string &data);
1073 
1074  void _HandleGetBootSoftwareVersion(
1076  const ResponseStatus&,
1077  uint32_t> *callback,
1078  const ResponseStatus &status,
1079  const std::string &data);
1080 
1081  void _HandleGetDMXPersonality(
1083  const ResponseStatus&,
1084  uint8_t,
1085  uint8_t> *callback,
1086  const ResponseStatus &status,
1087  const std::string &data);
1088 
1089  void _HandleGetDMXPersonalityDescription(
1091  const ResponseStatus&,
1092  uint8_t,
1093  uint16_t,
1094  const std::string&> *callback,
1095  const ResponseStatus &status,
1096  const std::string &data);
1097 
1098  void _HandleGetDMXAddress(
1100  const ResponseStatus&,
1101  uint16_t> *callback,
1102  const ResponseStatus &status,
1103  const std::string &data);
1104 
1105  void _HandleGetSlotInfo(
1107  const ResponseStatus&,
1108  const std::vector<SlotDescriptor>&> *callback,
1109  const ResponseStatus &status,
1110  const std::string &data);
1111 
1112  void _HandleGetSlotDescription(
1114  const ResponseStatus&,
1115  uint16_t,
1116  const std::string&> *callback,
1117  const ResponseStatus &status,
1118  const std::string &data);
1119 
1120  void _HandleGetSlotDefaultValues(
1122  const ResponseStatus&,
1123  const std::vector<SlotDefault>&> *callback,
1124  const ResponseStatus &status,
1125  const std::string &data);
1126 
1127  void _HandleGetSensorDefinition(
1129  const ResponseStatus&,
1130  const SensorDescriptor&> *callback,
1131  const ResponseStatus &status,
1132  const std::string &data);
1133 
1134  void _HandleSensorValue(
1136  const ResponseStatus&,
1137  const SensorValueDescriptor&> *callback,
1138  const ResponseStatus &status,
1139  const std::string &data);
1140 
1141  void _HandleClock(
1143  const ResponseStatus&,
1144  const ClockValue&> *callback,
1145  const ResponseStatus &status,
1146  const std::string &data);
1147 
1150  const ResponseStatus&,
1151  uint8_t,
1152  const std::string&> *callback,
1153  const ResponseStatus &status,
1154  const std::string &data);
1155 
1156  void _HandlePlaybackMode(
1158  const ResponseStatus&,
1159  uint16_t,
1160  uint8_t> *callback,
1161  const ResponseStatus &status,
1162  const std::string &data);
1163 
1164  private:
1165  class RDMAPIImplInterface *m_impl;
1166  std::map<UID, uint8_t> m_outstanding_messages;
1167 
1168  enum {LABEL_SIZE = 32};
1169 
1170  bool GenericGetU8(
1171  unsigned int universe,
1172  const UID &uid,
1173  uint8_t sub_device,
1175  uint16_t pid,
1176  std::string *error);
1177 
1178  bool GenericSetU8(
1179  unsigned int universe,
1180  const UID &uid,
1181  uint16_t sub_device,
1182  uint8_t value,
1184  uint16_t pid,
1185  std::string *error);
1186 
1187  bool GenericGetU32(
1188  unsigned int universe,
1189  const UID &uid,
1190  uint16_t sub_device,
1192  const ResponseStatus&,
1193  uint32_t> *callback,
1194  uint16_t pid,
1195  std::string *error);
1196 
1197  bool GenericSetU32(
1198  unsigned int universe,
1199  const UID &uid,
1200  uint16_t sub_device,
1201  uint32_t value,
1203  uint16_t pid,
1204  std::string *error);
1205 
1206  // Check that a callback is not null
1207  template <typename callback_type>
1208  bool CheckCallback(std::string *error, const callback_type *cb) {
1209  if (cb == NULL) {
1210  if (error)
1211  *error = "Callback is null, this is a programming error";
1212  return true;
1213  }
1214  return false;
1215  }
1216 
1217  // Check that a UID is not a broadcast address
1218  template <typename callback_type>
1219  bool CheckNotBroadcast(const UID &uid, std::string *error,
1220  const callback_type *cb) {
1221  if (uid.IsBroadcast()) {
1222  if (error)
1223  *error = "Cannot send to broadcast address";
1224  delete cb;
1225  return true;
1226  }
1227  return false;
1228  }
1229 
1230  // Check the subdevice value is valid
1231  template <typename callback_type>
1232  bool CheckValidSubDevice(uint16_t sub_device,
1233  bool broadcast_allowed,
1234  std::string *error,
1235  const callback_type *cb) {
1236  if (sub_device <= 0x0200)
1237  return false;
1238 
1239  if (broadcast_allowed && sub_device == ALL_RDM_SUBDEVICES)
1240  return false;
1241 
1242  if (error) {
1243  *error = "Sub device must be <= 0x0200";
1244  if (broadcast_allowed)
1245  *error += " or 0xffff";
1246  }
1247  delete cb;
1248  return true;
1249  }
1250 
1251  bool CheckReturnStatus(bool status, std::string *error);
1252  void SetIncorrectPDL(ResponseStatus *status,
1253  unsigned int actual,
1254  unsigned int expected);
1255 };
1256 } // namespace rdm
1257 } // namespace ola
1258 #endif // INCLUDE_OLA_RDM_RDMAPI_H_