Open Lighting Architecture  0.9.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/io/BigEndianStream.h"
28 #include "ola/io/IOQueue.h"
29 #include "ola/io/SelectServerInterface.h"
31 #include "ola/network/Socket.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace kinet {
36 
37 class KiNetNode {
38  public:
40  ola::network::UDPSocketInterface *socket = NULL);
41  virtual ~KiNetNode();
42 
43  bool Start();
44  bool Stop();
45 
46  // The following apply to Input Ports (those which send data)
47  bool SendDMX(const ola::network::IPV4Address &target,
48  const ola::DmxBuffer &buffer);
49 
50  private:
51  bool m_running;
53  ola::io::IOQueue m_output_queue;
54  ola::io::BigEndianOutputStream m_output_stream;
55  ola::network::Interface m_interface;
56  std::auto_ptr<ola::network::UDPSocketInterface> m_socket;
57 
58  KiNetNode(const KiNetNode&);
59  KiNetNode& operator=(const KiNetNode&);
60 
61  void SocketReady();
62  void PopulatePacketHeader(uint16_t msg_type);
63  bool InitNetwork();
64 
65  static const uint16_t KINET_PORT = 6038;
66  static const uint32_t KINET_MAGIC_NUMBER = 0x0401dc4a;
67  static const uint16_t KINET_VERSION_ONE = 0x0100;
68  static const uint16_t KINET_DMX_MSG = 0x0101;
69 };
70 } // namespace kinet
71 } // namespace plugin
72 } // namespace ola
73 #endif // PLUGINS_KINET_KINETNODE_H_