Open Lighting Architecture
 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 <string>
25 #include <map>
26 #include <vector>
27 #include "ola/BaseTypes.h"
28 #include "ola/DmxBuffer.h"
30 #include "ola/rdm/RDMEnums.h"
31 #include "ola/rdm/UID.h"
32 #include "olad/Port.h"
33 
34 using ola::rdm::UID;
35 
36 namespace ola {
37 namespace plugin {
38 namespace dummy {
39 
40 class DummyPort: public BasicOutputPort {
41  public:
42  struct Options {
43  public:
44  Options()
45  : number_of_dimmers(1),
46  dimmer_sub_device_count(4),
47  number_of_moving_lights(1),
48  number_of_dummy_responders(1),
49  number_of_ack_timer_responders(0),
50  number_of_advanced_dimmers(0),
51  number_of_sensor_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  };
62 
63  DummyPort(class DummyDevice *parent,
64  const Options &options,
65  unsigned int id);
66  virtual ~DummyPort();
67  bool WriteDMX(const DmxBuffer &buffer, uint8_t priority);
68  string Description() const { return "Dummy Port"; }
69  void RunFullDiscovery(RDMDiscoveryCallback *callback);
70  void RunIncrementalDiscovery(RDMDiscoveryCallback *callback);
71  void SendRDMRequest(const ola::rdm::RDMRequest *request,
72  ola::rdm::RDMCallback *callback);
73 
74  private:
75  typedef struct {
76  unsigned int expected_count;
77  unsigned int current_count;
78  bool failed;
79  ola::rdm::RDMCallback *callback;
80  } broadcast_request_tracker;
81 
82  typedef map<UID, ola::rdm::RDMControllerInterface*> ResponderMap;
83 
84  DmxBuffer m_buffer;
85  ResponderMap m_responders;
86 
87  void RunDiscovery(RDMDiscoveryCallback *callback);
88  void HandleBroadcastAck(broadcast_request_tracker *tracker,
89  ola::rdm::rdm_response_code code,
90  const ola::rdm::RDMResponse *response,
91  const std::vector<std::string> &packets);
92 
93  // See http://www.opendmx.net/index.php/Open_Lighting_Allocations
94  // Do not change.
95  static const unsigned int kStartAddress = 0xffffff00;
96 };
97 } // namespace dummy
98 } // namespace plugin
99 } // namespace ola
100 #endif // PLUGINS_DUMMY_DUMMYPORT_H_