29 #ifndef INCLUDE_OLA_RDM_RESPONDEROPSPRIVATE_H_ 30 #define INCLUDE_OLA_RDM_RESPONDEROPSPRIVATE_H_ 33 #include <ola/network/NetworkUtils.h> 48 template <
class Target>
50 bool include_required_pids)
51 : m_include_required_pids(include_required_pids) {
53 struct InternalParamHandler placeholder = {NULL, NULL};
54 STLReplace(&m_handlers, PID_SUPPORTED_PARAMETERS, placeholder);
56 const ParamHandler *handler = param_handlers;
57 while (handler->pid && (handler->get_handler || handler->set_handler)) {
58 struct InternalParamHandler pid_handler = {
62 STLReplace(&m_handlers, handler->pid, pid_handler);
67 template <
class Target>
69 const UID &target_uid,
74 std::auto_ptr<const RDMRequest> request(raw_request);
83 if (!request->DestinationUID().DirectedToUID(target_uid)) {
84 if (!request->DestinationUID().IsBroadcast()) {
85 OLA_WARN <<
"Received request for the wrong UID, " 86 <<
"expected " << target_uid <<
", got " 87 << request->DestinationUID();
92 request->DestinationUID().IsBroadcast() ? RDM_WAS_BROADCAST :
105 request->DestinationUID().IsBroadcast()) {
106 OLA_WARN <<
"Received broadcast GET command";
115 bool for_our_subdevice = request->SubDevice() == sub_device ||
116 request->SubDevice() == ALL_RDM_SUBDEVICES;
118 if (!for_our_subdevice) {
119 if (request->DestinationUID().IsBroadcast()) {
124 on_complete->Run(&reply);
130 if (request->SubDevice() == ALL_RDM_SUBDEVICES &&
135 on_complete->Run(&reply);
139 InternalParamHandler *handler =
STLFind(&m_handlers, request->ParamId());
141 if (request->DestinationUID().IsBroadcast()) {
146 on_complete->Run(&reply);
152 if (request->DestinationUID().IsBroadcast()) {
154 status_code = RDM_WAS_BROADCAST;
156 if (handler->get_handler) {
157 response = (target->*(handler->get_handler))(request.get());
159 switch (request->ParamId()) {
160 case PID_SUPPORTED_PARAMETERS:
161 response = HandleSupportedParams(request.get());
165 NR_UNSUPPORTED_COMMAND_CLASS);
170 if (handler->set_handler) {
171 response = (target->*(handler->set_handler))(request.get());
173 response =
NackWithReason(request.get(), NR_UNSUPPORTED_COMMAND_CLASS);
177 if (request->DestinationUID().IsBroadcast()) {
183 RDMReply reply(status_code, response);
184 on_complete->Run(&reply);
188 template <
class Target>
194 std::vector<uint16_t> params;
195 params.reserve(m_handlers.size());
196 typename RDMHandlers::const_iterator iter = m_handlers.begin();
197 for (; iter != m_handlers.end(); ++iter) {
198 uint16_t pid = iter->first;
200 if (m_include_required_pids || (
201 pid != PID_SUPPORTED_PARAMETERS &&
202 pid != PID_PARAMETER_DESCRIPTION &&
203 pid != PID_DEVICE_INFO &&
204 pid != PID_SOFTWARE_VERSION_LABEL &&
205 pid != PID_DMX_START_ADDRESS &&
206 pid != PID_IDENTIFY_DEVICE)) {
207 params.push_back(iter->first);
210 sort(params.begin(), params.end());
212 std::vector<uint16_t>::iterator param_iter = params.begin();
213 for (; param_iter != params.end(); ++param_iter) {
219 reinterpret_cast<uint8_t*>(¶ms[0]),
220 params.size() *
sizeof(uint16_t));
224 #endif // INCLUDE_OLA_RDM_RESPONDEROPSPRIVATE_H_ Definitions and Interfaces to implement an RDMController that sends a single message at a time...
unsigned int ParamDataSize() const
Returns the Size of the Parameter Data of the RDMCommand.
Definition: RDMCommand.h:140
RDMStatusCode
RDM Status Codes.
Definition: RDMResponseCodes.h:45
uint16_t HostToNetwork(uint16_t value)
16-bit unsigned host to network conversion.
Definition: NetworkUtils.cpp:159
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition: RDMCommand.h:457
RDMResponse * GetResponseFromData(const RDMRequest *request, const uint8_t *data, unsigned int length, rdm_response_type type, uint8_t outstanding_messages)
Generate an ACK Response with some data.
Definition: RDMCommand.cpp:595
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:234
RDMResponse * NackWithReason(const RDMRequest *request, rdm_nack_reason reason_enum, uint8_t outstanding_messages)
Generate a NACK response with a reason code.
Definition: RDMCommand.cpp:583
#define OLA_WARN
Definition: Logging.h:75
Definition: RDMEnums.h:58
Definition: RDMEnums.h:56
Enums representing the states of a response. This is generated from the proto file.
A class which dispatches RDM requests to registered PID handlers.
Definition: ResponderOps.h:60
ResponderOps(const ParamHandler param_handlers[], bool include_required_pids=false)
Construct a new ResponderOps object.
Definition: ResponderOpsPrivate.h:49
The base class for all 1 argument callbacks.
Definition: Callback.h:982
Helper functions for STL classes.
Holds the final state of an RDM request.
Definition: RDMReply.h:43
Definition: RDMEnums.h:60
void RunRDMCallback(RDMCallback *callback, RDMStatusCode status_code)
A helper message to run a RDMCallback with the given status code.
Definition: RDMControllerInterface.h:59
Represents a RDM UID.
Definition: UID.h:57
bool STLReplace(T1 *container, const typename T1::key_type &key, const typename T1::mapped_type &value)
Replace a value in a pair associative container, inserting the key, value if it doesn't already exist...
Definition: STLUtils.h:258
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
T1::mapped_type * STLFind(T1 *container, const typename T1::key_type &key)
Lookup a value by key in a associative container.
Definition: STLUtils.h:193
Header file for OLA Logging.
Classes that represent RDM commands.