Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
JaRuleWidget.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 * JaRuleWidget.h
17 * A Ja Rule widget.
18 * Copyright (C) 2015 Simon Newton
19 */
20
21#ifndef LIBS_USB_JARULEWIDGET_H_
22#define LIBS_USB_JARULEWIDGET_H_
23
24#include <libusb.h>
25#include <stdint.h>
26
27#include <ola/io/ByteString.h>
28#include <ola/rdm/UID.h>
29#include <ola/thread/ExecutorInterface.h>
30
31#include <string>
32#include <vector>
33
34#include "libs/usb/LibUsbAdaptor.h"
35#include "libs/usb/JaRuleConstants.h"
36#include "libs/usb/Types.h"
37
38namespace ola {
39namespace usb {
40
58 public:
67 libusb_device *usb_device);
68
73
79 bool Init();
80
86
94 void CancelAll(uint8_t port_id);
95
103 uint8_t PortCount() const;
104
110 ola::rdm::UID GetUID() const;
111
117 std::string ManufacturerString() const;
118
124 std::string ProductString() const;
125
132 class JaRulePortHandle* ClaimPort(uint8_t port_index);
133
139 void ReleasePort(uint8_t port_index);
140
153 void SendCommand(uint8_t port_index, CommandClass command,
154 const uint8_t *data, unsigned int size,
155 CommandCompleteCallback *callback);
156
157 private:
158 typedef std::vector<class JaRuleWidgetPort*> PortHandles;
159
161 LibUsbAdaptor *m_adaptor;
162 libusb_device *m_device;
163 libusb_device_handle *m_usb_handle;
164 ola::rdm::UID m_uid; // The UID of the device, or 0000:00000000 if unset
165 std::string m_manufacturer;
166 std::string m_product;
167 PortHandles m_ports; // The list of port handles.
168
169 bool InternalInit();
170
171 static const uint8_t SUBCLASS_VALUE = 0xff;
172 static const uint8_t PROTOCOL_VALUE = 0xff;
173
174 JaRuleWidget(const JaRuleWidget &) = delete;
175 const JaRuleWidget &operator=(const JaRuleWidget &) = delete;
176};
177} // namespace usb
178} // namespace ola
179#endif // LIBS_USB_JARULEWIDGET_H_
A RDM unique identifier (UID).
The base class for all 4 argument callbacks.
Definition Callback.h:3811
Represents a RDM UID.
Definition UID.h:57
Defer execution of a callback.
Definition ExecutorInterface.h:35
A LibUsbAdaptor for use with Asyncronous widgets.
Definition LibUsbAdaptor.h:564
Represents a DMX/RDM port on a Ja Rule device.
Definition JaRulePortHandle.h:41
A Ja Rule hardware device (widget).
Definition JaRuleWidget.h:57
ola::rdm::UID GetUID() const
The UID of the widget.
Definition JaRuleWidget.cpp:115
void ReleasePort(uint8_t port_index)
Release a handle to a port.
Definition JaRuleWidget.cpp:134
class JaRulePortHandle * ClaimPort(uint8_t port_index)
Claim a handle to a port.
Definition JaRuleWidget.cpp:127
uint8_t PortCount() const
The number of ports on the widget.
Definition JaRuleWidget.cpp:111
JaRuleWidget(ola::thread::ExecutorInterface *executor, AsyncronousLibUsbAdaptor *adaptor, libusb_device *usb_device)
Create a new Ja Rule widget.
Definition JaRuleWidget.cpp:66
~JaRuleWidget()
Destructor.
Definition JaRuleWidget.cpp:77
USBDeviceID GetDeviceId() const
The device ID of this widget.
Definition JaRuleWidget.cpp:99
std::string ManufacturerString() const
Get the manufacturer string.
Definition JaRuleWidget.cpp:119
void CancelAll(uint8_t port_id)
Cancel all queued and inflight commands.
Definition JaRuleWidget.cpp:103
void SendCommand(uint8_t port_index, CommandClass command, const uint8_t *data, unsigned int size, CommandCompleteCallback *callback)
The low level API to send a command to the widget.
Definition JaRuleWidget.cpp:141
bool Init()
Initialize the Ja Rule widget.
Definition JaRuleWidget.cpp:87
std::string ProductString() const
Get the product string.
Definition JaRuleWidget.cpp:123
Wraps calls to libusb so we can test the code.
Definition LibUsbAdaptor.h:36
Definition Types.h:30
CommandClass
The Ja Rule command set.
Definition JaRuleConstants.h:101
The namespace containing all OLA symbols.
Definition Credentials.cpp:44