Open Lighting Architecture: include/ola/e133/E133Receiver.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
E133Receiver.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 * E133Receiver.h
17 * Handles E1.33 UDP packets and executes RDM and Status message callbacks.
18 * Copyright (C) 2013 Simon Newton
19 */
20
21#ifndef INCLUDE_OLA_E133_E133RECEIVER_H_
22#define INCLUDE_OLA_E133_E133RECEIVER_H_
23
24#include <ola/Callback.h>
25#include <ola/base/Macro.h>
26#include <ola/network/IPV4Address.h>
27#include <ola/network/Socket.h>
28#include <ola/rdm/RDMCommand.h>
29
30#include <memory>
31#include <string>
32
33using std::string;
34using std::auto_ptr;
35using ola::network::IPV4Address;
36
37namespace ola {
38// We don't want to suck in all the ACN headers, so we forward declare these
39// and allocate the members on the heap.
40namespace acn {
41class E133Header;
42class E133Inflator;
43class E133StatusInflator;
44class IncomingUDPTransport;
45class RDMInflator;
46class RootInflator;
47class TransportHeader;
48} // namespace acn
49
50namespace e133 {
51
52 class E133Message {
53 public:
54 E133Message(const IPV4Address &ip,
55 uint16_t endpoint,
56 uint32_t sequence_number)
57 : ip(ip),
58 endpoint(endpoint),
59 sequence_number(sequence_number) {
60 }
61 virtual ~E133Message() {}
62
63 IPV4Address ip;
64 uint16_t endpoint;
65 uint32_t sequence_number;
66};
67
68
72 class E133StatusMessage : public E133Message {
73 public:
74 E133StatusMessage(const IPV4Address &ip,
75 uint16_t endpoint,
76 uint32_t sequence_number,
77 uint16_t status_code,
78 string status_message)
79 : E133Message(ip, endpoint, sequence_number),
80 status_code(status_code),
81 status_message(status_message) {
82 }
83
84 uint16_t status_code;
85 string status_message;
86};
87
88
93 class E133RDMMessage : public E133Message {
94 public:
95 E133RDMMessage(const IPV4Address &ip,
96 uint16_t endpoint,
97 uint32_t sequence_number,
98 ola::rdm::RDMStatusCode status_code,
99 const ola::rdm::RDMResponse *response)
100 : E133Message(ip, endpoint, sequence_number),
101 status_code(status_code),
102 response(response) {
103 }
104
105 ola::rdm::RDMStatusCode status_code;
106 const ola::rdm::RDMResponse *response;
107};
108
109
113 class E133Receiver {
114 public:
115 typedef ola::Callback1<void, const E133StatusMessage&> StatusCallback;
116 typedef ola::Callback1<void, const E133RDMMessage&> RDMCallback;
117
118 explicit E133Receiver(ola::network::UDPSocket *socket,
119 StatusCallback *status_callback,
120 RDMCallback *rdm_callback);
121 ~E133Receiver();
122
123 private:
124 ola::network::UDPSocket *m_udp_socket;
125 StatusCallback *m_status_callback;
126 RDMCallback *m_rdm_callback;
127
128 auto_ptr<ola::acn::RootInflator> m_root_inflator;
129 auto_ptr<ola::acn::E133Inflator> m_e133_inflator;
130 auto_ptr<ola::acn::RDMInflator> m_rdm_inflator;
131 auto_ptr<ola::acn::E133StatusInflator> m_e133_status_inflator;
132 auto_ptr<ola::acn::IncomingUDPTransport> m_incoming_udp_transport;
133
134 void HandleStatusMessage(
135 const ola::acn::TransportHeader *transport_header,
136 const ola::acn::E133Header *e133_header,
137 uint16_t status_code,
138 const string &description);
139
140 void HandlePacket(
141 const ola::acn::TransportHeader *transport_header,
142 const ola::acn::E133Header *e133_header,
143 const std::string &raw_response);
144
145 E133Receiver(const E133Receiver &) = delete;
146 const E133Receiver &operator=(const E133Receiver &) = delete;
147};
148} // namespace e133
149} // namespace ola
150#endif // INCLUDE_OLA_E133_E133RECEIVER_H_
Callback.h
IPV4Address.h
Represents an IPv4 Address.
Macro.h
Helper macros.
RDMCommand.h
Classes that represent RDM commands.
ola::Callback1
A 1 argument callback which can be called multiple times.
Definition Callback.h:992
ola::acn::E133Header
Definition E133Header.h:35
ola::acn::E133Inflator
Definition E133Inflator.h:31
ola::acn::E133StatusInflator
Definition E133StatusInflator.h:35
ola::acn::IncomingUDPTransport
Definition UDPTransport.h:94
ola::acn::RDMInflator
Definition RDMInflator.h:33
ola::acn::RootInflator
Definition RootInflator.h:48
ola::acn::TransportHeader
Definition TransportHeader.h:35
ola::network::IPV4Address
Represents a IPv4 Address.
Definition IPV4Address.h:55
ola::network::UDPSocket
Definition Socket.h:239
ola::rdm::RDMResponse
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
ola::acn
ACN related code.
ola::e133
E1.33 (RDMNet).
ola::rdm::RDMStatusCode
RDMStatusCode
RDM Status Codes.
Definition RDMResponseCodes.h:45
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44