Open Lighting Architecture  Latest Git
PathportNode.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  * PathportNode.h
17  * Header file for the PathportNode class
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef PLUGINS_PATHPORT_PATHPORTNODE_H_
22 #define PLUGINS_PATHPORT_PATHPORTNODE_H_
23 
24 #include <map>
25 #include <string>
26 #include "ola/Callback.h"
27 #include "ola/DmxBuffer.h"
29 #include "ola/network/InterfacePicker.h"
30 #include "ola/network/Socket.h"
31 #include "plugins/pathport/PathportPackets.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace pathport {
36 
37 class PathportNode {
38  public:
39  explicit PathportNode(const std::string &preferred_ip, uint32_t device_id,
40  uint8_t dscp);
41  ~PathportNode();
42 
43  bool Start();
44  bool Stop();
45  const ola::network::Interface &GetInterface() const {
46  return m_interface;
47  }
48  ola::network::UDPSocket *GetSocket() { return &m_socket; }
49  void SocketReady(ola::network::UDPSocket *socket);
50 
51  bool SetHandler(uint8_t universe,
52  DmxBuffer *buffer,
53  Callback0<void> *closure);
54  bool RemoveHandler(uint8_t universe);
55 
56  bool SendArpReply();
57  bool SendDMX(unsigned int universe, const DmxBuffer &buffer);
58 
59  // apparently pathport supports up to 128 universes, the spec only says 64
60  static const uint8_t MAX_UNIVERSES = 127;
61 
62  private:
63  typedef struct {
64  DmxBuffer *buffer;
65  Callback0<void> *closure;
66  } universe_handler;
67 
68  enum {
69  XDMX_DATA_FLAT = 0x0101,
70  XDMX_DATA_RELEASE = 0x0103
71  };
72 
73  enum {
74  NODE_MANUF_PATHWAY_CONNECTIVITY = 0,
75  NODE_MANUF_INTERACTIVE_TECH = 0x10,
76  NODE_MANUF_ENTERTAINMENT_TECH = 0x11,
77  NODE_MANUF_MA_LIGHTING = 0x12,
78  NODE_MANUF_HIGH_END_SYSTEMS = 0x13,
79  NODE_MANUF_CRESTRON_ELECTRONICS = 0x14,
80  NODE_MANUF_LEVITON = 0x15,
81  NODE_MANUF_FLYING_PIG = 0x16,
82  NODE_MANUF_HORIZON = 0x17,
83  NODE_MANUF_ZP_TECH = 0x28, // ola
84  };
85 
86  enum {
87  NODE_CLASS_DMX_NODE = 0,
88  NODE_CLASS_MANAGER = 1,
89  NODE_CLASS_DIMMER = 2,
90  NODE_CLASS_CONTROLLER = 3,
91  NODE_CLASS_FIXTURE = 4,
92  NODE_CLASS_EFFECTS_UNIT = 5,
93  };
94 
95  enum {
96  NODE_DEVICE_PATHPORT = 0,
97  NODE_DEVICE_DMX_MANAGER_PLUS = 1,
98  NODE_DEVICE_ONEPORT = 2,
99  };
100 
101  typedef std::map<uint8_t, universe_handler> universe_handlers;
102 
103  bool InitNetwork();
104  void PopulateHeader(pathport_packet_header *header, uint32_t destination);
105  bool ValidateHeader(const pathport_packet_header &header);
106  void HandleDmxData(const pathport_pdu_data &packet,
107  unsigned int size);
108  bool SendArpRequest(uint32_t destination = PATHPORT_ID_BROADCAST);
109  bool SendPacket(const pathport_packet_s &packet,
110  unsigned int size,
112 
113  bool m_running;
114  uint8_t m_dscp;
115  std::string m_preferred_ip;
116  uint32_t m_device_id; // the pathport device id
117  uint16_t m_sequence_number;
118 
119  universe_handlers m_handlers;
120  ola::network::Interface m_interface;
121  ola::network::UDPSocket m_socket;
122  ola::network::IPV4Address m_config_addr;
123  ola::network::IPV4Address m_status_addr;
124  ola::network::IPV4Address m_data_addr;
125 
126  static const uint16_t PATHPORT_PORT = 0xed0;
127  static const uint16_t PATHPORT_PROTOCOL = 0xed01;
128  static const uint32_t PATHPORT_CONFIG_GROUP = 0xefffed02;
129  static const uint32_t PATHPORT_DATA_GROUP = 0xefffed01;
130  static const uint32_t PATHPORT_ID_BROADCAST = 0xffffffff;
131  static const uint32_t PATHPORT_STATUS_GROUP = 0xefffedff;
132  static const uint8_t MAJOR_VERSION = 2;
133  static const uint8_t MINOR_VERSION = 0;
134 };
135 } // namespace pathport
136 } // namespace plugin
137 } // namespace ola
138 #endif // PLUGINS_PATHPORT_PATHPORTNODE_H_
Definition: Socket.h:238
Definition: PathportNode.h:37
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
A class used to hold a single universe of DMX data.
Represents a IPv4 Address.
Definition: IPV4Address.h:55
Definition: Interface.h:35
Represents an IPv4 Address.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44