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