Open Lighting Architecture  0.9.0
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * DummyPort.h
17  * The interface to the Dummy port
18  * Copyright (C) 2005-2009 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/BaseTypes.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  DummyPort(class DummyDevice *parent,
65  const Options &options,
66  unsigned int id);
67  virtual ~DummyPort();
68  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
69  std::string Description() const { return "Dummy Port"; }
70  void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
71  void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
72  void SendRDMRequest(const ola::rdm::RDMRequest *request,
73  ola::rdm::RDMCallback *callback);
74 
75  private:
76  typedef struct {
77  unsigned int expected_count;
78  unsigned int current_count;
79  bool failed;
80  ola::rdm::RDMCallback *callback;
81  } broadcast_request_tracker;
82 
83  typedef std::map<ola::rdm::UID,
84  ola::rdm::RDMControllerInterface*> ResponderMap;
85 
86  DmxBuffer m_buffer;
87  ResponderMap m_responders;
88 
89  void RunDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
90  void HandleBroadcastAck(broadcast_request_tracker *tracker,
91  ola::rdm::rdm_response_code code,
92  const ola::rdm::RDMResponse *response,
93  const std::vector<std::string> &packets);
94 
95  // See http://www.opendmx.net/index.php/Open_Lighting_Allocations
96  // Do not change.
97  static const unsigned int kStartAddress = 0xffffff00;
98 };
99 } // namespace dummy
100 } // namespace plugin
101 } // namespace ola
102 #endif // PLUGINS_DUMMY_DUMMYPORT_H_