Open Lighting Architecture
 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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"
30 #include "ola/network/IPV4Address.h"
31 #include "ola/network/Socket.h"
32 
33 namespace ola {
34 namespace plugin {
35 namespace kinet {
36 
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 IPV4Address &target, const ola::DmxBuffer &buffer);
50 
51  private:
52  bool m_running;
54  ola::io::IOQueue m_output_queue;
55  ola::io::BigEndianOutputStream m_output_stream;
56  ola::network::Interface m_interface;
57  std::auto_ptr<ola::network::UDPSocketInterface> m_socket;
58 
59  KiNetNode(const KiNetNode&);
60  KiNetNode& operator=(const KiNetNode&);
61 
62  void SocketReady();
63  void PopulatePacketHeader(uint16_t msg_type);
64  bool InitNetwork();
65 
66  static const uint16_t KINET_PORT = 6038;
67  static const uint32_t KINET_MAGIC_NUMBER = 0x0401dc4a;
68  static const uint16_t KINET_VERSION_ONE = 0x0100;
69  static const uint16_t KINET_DMX_MSG = 0x0101;
70 };
71 } // namespace kinet
72 } // namespace plugin
73 } // namespace ola
74 #endif // PLUGINS_KINET_KINETNODE_H_