Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
RDMAPIImplInterface.h
Go to the documentation of this file.
1/*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
6 *
7 * This library 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 GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 *
16 * RDMAPIImplInterface.h
17 * The interface for an RDM API Implementation
18 * Copyright (C) 2010 Simon Newton
19 */
20
29#ifndef INCLUDE_OLA_RDM_RDMAPIIMPLINTERFACE_H_
30#define INCLUDE_OLA_RDM_RDMAPIIMPLINTERFACE_H_
31
32#include <stdint.h>
33#include <ola/rdm/UID.h>
34#include <ola/Callback.h>
35#include <ola/rdm/RDMEnums.h>
37#include <string>
38
39namespace ola {
40namespace rdm {
41
52 public:
53 std::string error; // Non empty if the RPC failed
54 RDMStatusCode response_code;
55 uint8_t response_type;
56 uint8_t message_count;
57 uint16_t m_param;
58 bool set_command;
59 uint16_t pid_value;
60
61 // helper methods
62 bool WasAcked() const {
63 return (error.empty() && response_code == RDM_COMPLETED_OK &&
64 response_type == RDM_ACK);
65 }
66
67 bool WasNacked() const {
68 return (error.empty() && response_code == RDM_COMPLETED_OK &&
69 response_type == RDM_NACK_REASON);
70 }
71
72 // Returns the NACK Reason code
73 uint16_t NackReason() const { return m_param; }
74
75 // Returns the time (in ms) to wait before re-trying
76 unsigned int AckTimer() const { return 100 * m_param; }
77};
78
79
84 public:
85 virtual ~RDMAPIImplInterface() {}
86
87 // args are the response type the param data
88 typedef ola::SingleUseCallback2<void,
89 const ResponseStatus&,
90 const std::string&> rdm_callback;
91
92 // args are response type, pid & param data
93 typedef ola::SingleUseCallback3<void,
94 const ResponseStatus&,
95 uint16_t,
96 const std::string&> rdm_pid_callback;
97
98 // get command
99 virtual bool RDMGet(rdm_callback *callback,
100 unsigned int universe,
101 const UID &uid,
102 uint16_t sub_device,
103 uint16_t pid,
104 const uint8_t *data = NULL,
105 unsigned int data_length = 0) = 0;
106
107 // A version of Get that also returns the pid. This is used to deal with
108 // queued messages
109 virtual bool RDMGet(rdm_pid_callback *callback,
110 unsigned int universe,
111 const UID &uid,
112 uint16_t sub_device,
113 uint16_t pid,
114 const uint8_t *data = NULL,
115 unsigned int data_length = 0) = 0;
116
117 // set command
118 virtual bool RDMSet(rdm_callback *callback,
119 unsigned int universe,
120 const UID &uid,
121 uint16_t sub_device,
122 uint16_t pid,
123 const uint8_t *data = NULL,
124 unsigned int data_length = 0) = 0;
125};
126} // namespace rdm
127} // namespace ola
128#endif // INCLUDE_OLA_RDM_RDMAPIIMPLINTERFACE_H_
Various constants used in RDM.
Enums representing the states of a response. This is generated from the proto file.
A RDM unique identifier (UID).
A 2 argument callback which deletes itself after it's run.
Definition Callback.h:1907
A 3 argument callback which deletes itself after it's run.
Definition Callback.h:2850
This is the interface for an RDMAPI implementation.
Definition RDMAPIImplInterface.h:83
Represents the state of a response and/or any error codes.
Definition RDMAPIImplInterface.h:51
uint8_t message_count
Definition RDMAPIImplInterface.h:56
uint16_t m_param
Definition RDMAPIImplInterface.h:57
Represents a RDM UID.
Definition UID.h:57
RDMStatusCode
RDM Status Codes.
Definition RDMResponseCodes.h:45
The namespace containing all OLA symbols.
Definition Credentials.cpp:44