Open Lighting Architecture: libs/usb/JaRulePortHandleImpl.h Source File

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
JaRulePortHandleImpl.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 * JaRulePortHandleImpl.h
17 * The implementation of the Ja Rule Port Handle.
18 * Copyright (C) 2015 Simon Newton
19 */
20
21#ifndef LIBS_USB_JARULEPORTHANDLEIMPL_H_
22#define LIBS_USB_JARULEPORTHANDLEIMPL_H_
23
24#include <ola/base/Macro.h>
25#include <ola/DmxBuffer.h>
26#include <ola/io/ByteString.h>
27#include <ola/rdm/DiscoveryAgent.h>
28#include <ola/rdm/QueueingRDMController.h>
29#include <ola/rdm/RDMCommand.h>
30#include <ola/rdm/RDMControllerInterface.h>
31#include <ola/rdm/UID.h>
32#include <ola/util/SequenceNumber.h>
33
34#include "libs/usb/JaRuleConstants.h"
35
36namespace ola {
37namespace usb {
38
45 class JaRulePortHandleImpl
46 : public ola::rdm::DiscoveryTargetInterface,
47 public ola::rdm::DiscoverableRDMControllerInterface {
48 public:
52 JaRulePortHandleImpl(class JaRuleWidgetPort *parent_port,
53 const ola::rdm::UID &uid,
54 uint8_t physical_port);
55
56 ~JaRulePortHandleImpl();
57
58 // From DiscoverableRDMControllerInterface
59 void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
60 void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback);
61 void SendRDMRequest(ola::rdm::RDMRequest *request,
62 ola::rdm::RDMCallback *on_complete);
63
64 // From DiscoveryTargetInterface
65 void MuteDevice(const ola::rdm::UID &target,
66 MuteDeviceCallback *mute_complete);
67 void UnMuteAll(UnMuteDeviceCallback *unmute_complete);
68 void Branch(const ola::rdm::UID &lower,
69 const ola::rdm::UID &upper,
70 BranchCallback *branch_complete);
71
77 bool SendDMX(const DmxBuffer &buffer);
78
82 bool SetPortMode(JaRulePortMode new_mode);
83
84 private:
85 PACK(
86 struct DUBTiming {
87 uint16_t start;
88 uint16_t end;
89 });
90
91 PACK(
92 struct GetSetTiming {
93 uint16_t break_start;
94 uint16_t mark_start;
95 uint16_t mark_end;
96 });
97
98 class JaRuleWidgetPort* const m_port; // not owned
99 const ola::rdm::UID m_uid;
100 const uint8_t m_physical_port;
101
102 bool m_in_shutdown;
103
104 // DMX members
105 DmxBuffer m_dmx;
106 bool m_dmx_in_progress;
107 bool m_dmx_queued;
108 CommandCompleteCallback *m_dmx_callback;
109
110 // RDM members
111 ola::rdm::DiscoveryAgent m_discovery_agent;
112 ola::SequenceNumber<uint8_t> m_transaction_number;
113 ola::rdm::UIDSet m_uids;
114
115 void CheckStatusFlags(uint8_t flags);
116 void DMXComplete(USBCommandResult result, JaRuleReturnCode return_code,
117 uint8_t status_flags, const ola::io::ByteString &payload);
118 void MuteDeviceComplete(MuteDeviceCallback *mute_complete,
119 USBCommandResult result,
120 JaRuleReturnCode return_code,
121 uint8_t status_flags,
122 const ola::io::ByteString &payload);
123 void UnMuteDeviceComplete(UnMuteDeviceCallback *unmute_complete,
124 USBCommandResult result,
125 JaRuleReturnCode return_code,
126 uint8_t status_flags,
127 const ola::io::ByteString &payload);
128 void DUBComplete(BranchCallback *callback,
129 USBCommandResult status,
130 JaRuleReturnCode return_code,
131 uint8_t status_flags,
132 const ola::io::ByteString &payload);
133 void RDMComplete(const ola::rdm::RDMRequest *request,
134 ola::rdm::RDMCallback *m_rdm_callback,
135 USBCommandResult result,
136 JaRuleReturnCode return_code,
137 uint8_t status_flags,
138 const ola::io::ByteString &payload);
139 ola::rdm::RDMResponse* UnpackRDMResponse(
140 const ola::rdm::RDMRequest *request,
141 const ola::io::ByteString &payload,
142 ola::rdm::RDMStatusCode *status_code);
143 void DiscoveryComplete(ola::rdm::RDMDiscoveryCallback *callback,
144 OLA_UNUSED bool ok,
145 const ola::rdm::UIDSet &uids);
146 CommandClass GetCommandFromRequest(const ola::rdm::RDMRequest *request);
147
148 JaRulePortHandleImpl(const JaRulePortHandleImpl &) = delete;
149 const JaRulePortHandleImpl &operator=(const JaRulePortHandleImpl &) = delete;
150};
151} // namespace usb
152} // namespace ola
153#endif // LIBS_USB_JARULEPORTHANDLEIMPL_H_
DmxBuffer.h
A class used to hold a single universe of DMX data.
Macro.h
Helper macros.
OLA_UNUSED
#define OLA_UNUSED
Mark unused arguments & types.
Definition Macro.h:63
PACK
#define PACK(__Declaration__)
Pack structures.
Definition Macro.h:171
QueueingRDMController.h
An RDM Controller that queues messages and only sends a single message at a time.
RDMCommand.h
Classes that represent RDM commands.
RDMControllerInterface.h
Definitions and Interfaces to implement an RDMController that sends a single message at a time.
UID.h
A RDM unique identifier (UID).
ola::DmxBuffer
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
ola::SequenceNumber
SequenceNumber, this ensures that we increment the sequence number whenever we go to use it.
Definition SequenceNumber.h:30
ola::rdm::DiscoverableRDMControllerInterface
The interface that can send RDM commands, as well as perform discovery operations.
Definition RDMControllerInterface.h:104
ola::rdm::DiscoveryAgent
An asynchronous RDM Discovery algorithm.
Definition DiscoveryAgent.h:135
ola::rdm::DiscoveryTargetInterface
The interface used by the DiscoveryTarget to send RDM commands.
Definition DiscoveryAgent.h:53
ola::rdm::DiscoveryTargetInterface::MuteDeviceCallback
ola::BaseCallback1< void, bool > MuteDeviceCallback
The callback run when a mute command completes.
Definition DiscoveryAgent.h:60
ola::rdm::DiscoveryTargetInterface::BranchCallback
ola::BaseCallback2< void, const uint8_t *, unsigned int > BranchCallback
The callback run when a DUB command completes.
Definition DiscoveryAgent.h:73
ola::rdm::DiscoveryTargetInterface::UnMuteDeviceCallback
ola::BaseCallback0< void > UnMuteDeviceCallback
The callback run when an unmute command completes.
Definition DiscoveryAgent.h:65
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::UID
Represents a RDM UID.
Definition UID.h:57
ola::rdm::UIDSet
Represents a set of RDM UIDs.
Definition UIDSet.h:48
ola::usb::JaRulePortHandleImpl::UnMuteAll
void UnMuteAll(UnMuteDeviceCallback *unmute_complete)
Unmute all devices.
Definition JaRulePortHandleImpl.cpp:135
ola::usb::JaRulePortHandleImpl::RunFullDiscovery
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition JaRulePortHandleImpl.cpp:86
ola::usb::JaRulePortHandleImpl::SetPortMode
bool SetPortMode(JaRulePortMode new_mode)
Change the mode of this port.
Definition JaRulePortHandleImpl.cpp:177
ola::usb::JaRulePortHandleImpl::RunIncrementalDiscovery
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition JaRulePortHandleImpl.cpp:93
ola::usb::JaRulePortHandleImpl::SendDMX
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition JaRulePortHandleImpl.cpp:165
ola::usb::JaRulePortHandleImpl::SendRDMRequest
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition JaRulePortHandleImpl.cpp:101
ola::usb::JaRulePortHandleImpl::Branch
void Branch(const ola::rdm::UID &lower, const ola::rdm::UID &upper, BranchCallback *branch_complete)
Send a DUB command.
Definition JaRulePortHandleImpl.cpp:149
ola::usb::JaRulePortHandleImpl::MuteDevice
void MuteDevice(const ola::rdm::UID &target, MuteDeviceCallback *mute_complete)
Mute a device.
Definition JaRulePortHandleImpl.cpp:120
ola::usb::JaRulePortHandleImpl::JaRulePortHandleImpl
JaRulePortHandleImpl(class JaRuleWidgetPort *parent_port, const ola::rdm::UID &uid, uint8_t physical_port)
Create a new JaRulePortHandleImpl.
Definition JaRulePortHandleImpl.cpp:66
ola::usb::JaRuleWidgetPort
The internal model of a port on a JaRule device.
Definition JaRuleWidgetPort.h:47
DiscoveryAgent.h
Implements the RDM Discovery algorithm.
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::rdm::RDMDiscoveryCallback
ola::BaseCallback1< void, const ola::rdm::UIDSet & > RDMDiscoveryCallback
The callback run when a discovery operation completes.
Definition RDMControllerInterface.h:68
ola::usb
USB Device drivers.
ola::usb::CommandCompleteCallback
ola::BaseCallback4< void, USBCommandResult, JaRuleReturnCode, uint8_t, const ola::io::ByteString & > CommandCompleteCallback
A command completion callback.
Definition JaRuleConstants.h:167
ola::usb::CommandClass
CommandClass
The Ja Rule command set.
Definition JaRuleConstants.h:101
ola::usb::USBCommandResult
USBCommandResult
Indicates the eventual state of a Ja Rule command.
Definition JaRuleConstants.h:53
ola::usb::JaRuleReturnCode
JaRuleReturnCode
JaRule command return codes.
Definition JaRuleConstants.h:133
ola::usb::JaRulePortMode
JaRulePortMode
Ja Rule Port modes.
Definition JaRuleConstants.h:42
ola
The namespace containing all OLA symbols.
Definition Credentials.cpp:44