Open Lighting Architecture: include/ola/rdm/SubDeviceDispatcher.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
SubDeviceDispatcher.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 * SubDeviceDispatcher.h
17 * Handles dispatching RDM requests to the correct sub device.
18 * Copyright (C) 2013 Simon Newton
19 */
20
28
29#ifndef INCLUDE_OLA_RDM_SUBDEVICEDISPATCHER_H_
30#define INCLUDE_OLA_RDM_SUBDEVICEDISPATCHER_H_
31
32#include <ola/rdm/RDMControllerInterface.h>
33
34#include <map>
35#include <string>
36#include <vector>
37
38namespace ola {
39namespace rdm {
40
41 class SubDeviceDispatcher: public ola::rdm::RDMControllerInterface {
42 public:
43 SubDeviceDispatcher() {}
44 ~SubDeviceDispatcher() {}
45
46 void AddSubDevice(uint16_t sub_device_number,
47 ola::rdm::RDMControllerInterface *device);
48
49 void SendRDMRequest(ola::rdm::RDMRequest *request,
50 ola::rdm::RDMCallback *callback);
51
52 private:
53 struct FanOutTracker {
54 public:
55 FanOutTracker(uint16_t number_of_subdevices,
56 ola::rdm::RDMCallback *callback);
57
58 bool IncrementAndCheckIfComplete() {
59 return ++m_responses_so_far == m_number_of_subdevices;
60 }
61
62 void SetResponse(ola::rdm::RDMStatusCode code,
63 ola::rdm::RDMResponse *response);
64
65 void RunCallback();
66
67 uint16_t NumResponses() const {
68 return m_responses_so_far;
69 }
70
71 private:
72 uint16_t m_number_of_subdevices;
73 uint16_t m_responses_so_far;
74 ola::rdm::RDMCallback *m_callback;
75
76 ola::rdm::RDMStatusCode m_status_code;
77 ola::rdm::RDMResponse *m_response;
78 };
79
80 typedef std::map<uint16_t, ola::rdm::RDMControllerInterface*> SubDeviceMap;
81
82 SubDeviceMap m_subdevices;
83
84 void FanOutToSubDevices(const ola::rdm::RDMRequest *request,
85 ola::rdm::RDMCallback *callback);
86
87 void NackIfNotBroadcast(const ola::rdm::RDMRequest *request,
88 ola::rdm::RDMCallback *callback,
89 ola::rdm::rdm_nack_reason nack_reason);
90
91 void HandleSubDeviceResponse(FanOutTracker *tracker,
92 ola::rdm::RDMReply *reply);
93};
94} // namespace rdm
95} // namespace ola
96#endif // INCLUDE_OLA_RDM_SUBDEVICEDISPATCHER_H_
RDMControllerInterface.h
Definitions and Interfaces to implement an RDMController that sends a single message at a time.
ola::rdm::RDMControllerInterface
The interface that can send RDMRequest.
Definition RDMControllerInterface.h:73
ola::rdm::RDMRequest
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
ola::rdm::RDMResponse
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
ola::rdm::SubDeviceDispatcher::AddSubDevice
void AddSubDevice(uint16_t sub_device_number, ola::rdm::RDMControllerInterface *device)
Definition SubDeviceDispatcher.cpp:38
ola::rdm::SubDeviceDispatcher::SendRDMRequest
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *callback)
Send a RDM command.
Definition SubDeviceDispatcher.cpp:50
ola::rdm
PLASA E1.20 Remote Device Management.
Definition AckTimerResponder.cpp:38
ola::rdm::RDMStatusCode
RDMStatusCode
RDM Status Codes.
Definition RDMResponseCodes.h:45
ola::rdm::RDMCallback
ola::BaseCallback1< void, RDMReply * > RDMCallback
The callback run when a RDM request completes.
Definition RDMControllerInterface.h:52
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44
ola::rdm::RDMReply
Holds the final state of an RDM request.
Definition RDMReply.h:43