Open Lighting Architecture  Latest Git
KiNetNode.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  * KiNetNode.h
17  * Header file for the KiNetNode class.
18  * Copyright (C) 2013 Simon Newton
19  */
20 
21 #ifndef PLUGINS_KINET_KINETNODE_H_
22 #define PLUGINS_KINET_KINETNODE_H_
23 
24 #include <memory>
25 
26 #include "ola/DmxBuffer.h"
27 #include "ola/base/Macro.h"
28 #include "ola/io/BigEndianStream.h"
29 #include "ola/io/IOQueue.h"
30 #include "ola/io/SelectServerInterface.h"
31 #include "ola/network/Interface.h"
33 #include "ola/network/Socket.h"
34 
35 namespace ola {
36 namespace plugin {
37 namespace kinet {
38 
39 class KiNetNode {
40  public:
42  ola::network::UDPSocketInterface *socket = NULL);
43  virtual ~KiNetNode();
44 
45  bool Start();
46  bool Stop();
47 
48  // The following apply to Input Ports (those which send data)
49  bool SendDMX(const ola::network::IPV4Address &target,
50  const ola::DmxBuffer &buffer);
51 
52  private:
53  bool m_running;
55  ola::io::IOQueue m_output_queue;
56  ola::io::BigEndianOutputStream m_output_stream;
57  ola::network::Interface m_interface;
58  std::auto_ptr<ola::network::UDPSocketInterface> m_socket;
59 
60  void SocketReady();
61  void PopulatePacketHeader(uint16_t msg_type);
62  bool InitNetwork();
63 
64  static const uint16_t KINET_PORT = 6038;
65  static const uint32_t KINET_MAGIC_NUMBER = 0x0401dc4a;
66  static const uint16_t KINET_VERSION_ONE = 0x0100;
67  static const uint16_t KINET_DMX_MSG = 0x0101;
68 
69  DISALLOW_COPY_AND_ASSIGN(KiNetNode);
70 };
71 } // namespace kinet
72 } // namespace plugin
73 } // namespace ola
74 #endif // PLUGINS_KINET_KINETNODE_H_
Definition: BigEndianStream.h:166
The interface for UDPSockets.
Definition: Socket.h:48
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
A class used to hold a single universe of DMX data.
The interface for the SelectServer.
Definition: SelectServerInterface.h:42
Represents a IPv4 Address.
Definition: IPV4Address.h:55
Definition: Interface.h:35
Definition: IOQueue.h:40
Represents an IPv4 Address.
Helper macros.
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Definition: KiNetNode.h:39