Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DummyPort.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program 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
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * DummyPort.h
17  * The interface to the Dummy port
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef PLUGINS_DUMMY_DUMMYPORT_H_
22 #define PLUGINS_DUMMY_DUMMYPORT_H_
23 
24 #include <stdint.h>
25 #include <string>
26 #include <map>
27 #include <vector>
28 #include "ola/Constants.h"
29 #include "ola/DmxBuffer.h"
31 #include "ola/rdm/RDMEnums.h"
32 #include "ola/rdm/UID.h"
33 #include "olad/Port.h"
34 
35 namespace ola {
36 namespace plugin {
37 namespace dummy {
38 
39 class DummyPort: public BasicOutputPort {
40  public:
41  struct Options {
42  public:
43  Options()
44  : number_of_dimmers(1),
45  dimmer_sub_device_count(4),
46  number_of_moving_lights(1),
47  number_of_dummy_responders(1),
48  number_of_ack_timer_responders(0),
49  number_of_advanced_dimmers(1),
50  number_of_sensor_responders(1),
51  number_of_network_responders(1) {
52  }
53 
54  uint8_t number_of_dimmers;
55  uint16_t dimmer_sub_device_count;
56  uint8_t number_of_moving_lights;
57  uint8_t number_of_dummy_responders;
58  uint8_t number_of_ack_timer_responders;
59  uint8_t number_of_advanced_dimmers;
60  uint8_t number_of_sensor_responders;
61  uint8_t number_of_network_responders;
62  };
63 
64 
72  DummyPort(class DummyDevice *parent,
73  const Options &options,
74  unsigned int id);
75  virtual ~DummyPort();
76  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
77  std::string Description() const { return "Dummy Port"; }
80 
81  /*
82  * Handle an RDM Request
83  */
85  ola::rdm::RDMCallback *callback);
86 
87  private:
88  typedef struct {
89  unsigned int expected_count;
90  unsigned int current_count;
91  bool failed;
92  ola::rdm::RDMCallback *callback;
93  } broadcast_request_tracker;
94 
95  typedef std::map<ola::rdm::UID,
96  ola::rdm::RDMControllerInterface*> ResponderMap;
97 
98  DmxBuffer m_buffer;
99  ResponderMap m_responders;
100 
101  void RunDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
102  void HandleBroadcastAck(broadcast_request_tracker *tracker,
103  ola::rdm::RDMReply *reply);
104 
105  // See http://www.opendmx.net/index.php/Open_Lighting_Allocations
106  // Do not change.
107  static const unsigned int kStartAddress = 0xffffff00;
108 };
109 } // namespace dummy
110 } // namespace plugin
111 } // namespace ola
112 #endif // PLUGINS_DUMMY_DUMMYPORT_H_