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>
29#include <ola/rdm/RDMCommand.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
48 public:
52 JaRulePortHandleImpl(class JaRuleWidgetPort *parent_port,
53 const ola::rdm::UID &uid,
54 uint8_t physical_port);
55
57
58 // From DiscoverableRDMControllerInterface
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
149 const JaRulePortHandleImpl &operator=(const JaRulePortHandleImpl &) = delete;
150};
151} // namespace usb
152} // namespace ola
153#endif // LIBS_USB_JARULEPORTHANDLEIMPL_H_
A class used to hold a single universe of DMX data.
Helper macros.
#define OLA_UNUSED
Mark unused arguments & types.
Definition Macro.h:63
#define PACK(__Declaration__)
Pack structures.
Definition Macro.h:171
An RDM Controller that queues messages and only sends a single message at a time.
Classes that represent RDM commands.
Definitions and Interfaces to implement an RDMController that sends a single message at a time.
A RDM unique identifier (UID).
The base class for all 1 argument callbacks.
Definition Callback.h:982
The base class for all 2 argument callbacks.
Definition Callback.h:1885
The base class for all 4 argument callbacks.
Definition Callback.h:3811
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
SequenceNumber, this ensures that we increment the sequence number whenever we go to use it.
Definition SequenceNumber.h:30
The interface that can send RDM commands, as well as perform discovery operations.
Definition RDMControllerInterface.h:104
An asynchronous RDM Discovery algorithm.
Definition DiscoveryAgent.h:135
The interface used by the DiscoveryTarget to send RDM commands.
Definition DiscoveryAgent.h:53
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition RDMCommand.h:234
An RDM Command that represents responses (GET, SET or DISCOVER).
Definition RDMCommand.h:457
Represents a RDM UID.
Definition UID.h:57
Represents a set of RDM UIDs.
Definition UIDSet.h:48
The internal implementation of a Ja Rule Port Handle.
Definition JaRulePortHandleImpl.h:47
void UnMuteAll(UnMuteDeviceCallback *unmute_complete)
Unmute all devices.
Definition JaRulePortHandleImpl.cpp:135
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition JaRulePortHandleImpl.cpp:86
bool SetPortMode(JaRulePortMode new_mode)
Change the mode of this port.
Definition JaRulePortHandleImpl.cpp:177
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition JaRulePortHandleImpl.cpp:93
bool SendDMX(const DmxBuffer &buffer)
Send DMX data from this widget.
Definition JaRulePortHandleImpl.cpp:165
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition JaRulePortHandleImpl.cpp:101
void Branch(const ola::rdm::UID &lower, const ola::rdm::UID &upper, BranchCallback *branch_complete)
Send a DUB command.
Definition JaRulePortHandleImpl.cpp:149
void MuteDevice(const ola::rdm::UID &target, MuteDeviceCallback *mute_complete)
Mute a device.
Definition JaRulePortHandleImpl.cpp:120
JaRulePortHandleImpl(class JaRuleWidgetPort *parent_port, const ola::rdm::UID &uid, uint8_t physical_port)
Create a new JaRulePortHandleImpl.
Definition JaRulePortHandleImpl.cpp:66
The internal model of a port on a JaRule device.
Definition JaRuleWidgetPort.h:47
Implements the RDM Discovery algorithm.
RDMStatusCode
RDM Status Codes.
Definition RDMResponseCodes.h:45
CommandClass
The Ja Rule command set.
Definition JaRuleConstants.h:101
USBCommandResult
Indicates the eventual state of a Ja Rule command.
Definition JaRuleConstants.h:53
JaRuleReturnCode
JaRule command return codes.
Definition JaRuleConstants.h:133
JaRulePortMode
Ja Rule Port modes.
Definition JaRuleConstants.h:42
The namespace containing all OLA symbols.
Definition Credentials.cpp:44