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

| 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
57 class JaRuleWidget {
58 public:
65 JaRuleWidget(ola::thread::ExecutorInterface *executor,
66 AsyncronousLibUsbAdaptor *adaptor,
67 libusb_device *usb_device);
68
72 ~JaRuleWidget();
73
79 bool Init();
80
85 USBDeviceID GetDeviceId() const;
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
160 ola::thread::ExecutorInterface *m_executor;
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_
UID.h
A RDM unique identifier (UID).
ola::plugin::usbdmx::JaRuleWidget::JaRuleWidget
JaRuleWidget(ola::thread::ExecutorInterface *executor, AsyncronousLibUsbAdaptor *adaptor, libusb_device *usb_device)
Create a new Ja Rule widget.
Definition JaRuleWidget.cpp:66
ola::rdm::UID
Represents a RDM UID.
Definition UID.h:57
ola::thread::ExecutorInterface
Defer execution of a callback.
Definition ExecutorInterface.h:35
ola::usb::JaRulePortHandle
Represents a DMX/RDM port on a Ja Rule device.
Definition JaRulePortHandle.h:41
ola::usb::JaRuleWidget::GetUID
ola::rdm::UID GetUID() const
The UID of the widget.
Definition JaRuleWidget.cpp:115
ola::usb::JaRuleWidget::ReleasePort
void ReleasePort(uint8_t port_index)
Release a handle to a port.
Definition JaRuleWidget.cpp:134
ola::usb::JaRuleWidget::ClaimPort
class JaRulePortHandle * ClaimPort(uint8_t port_index)
Claim a handle to a port.
Definition JaRuleWidget.cpp:127
ola::usb::JaRuleWidget::PortCount
uint8_t PortCount() const
The number of ports on the widget.
Definition JaRuleWidget.cpp:111
ola::usb::JaRuleWidget::JaRuleWidget
JaRuleWidget(ola::thread::ExecutorInterface *executor, AsyncronousLibUsbAdaptor *adaptor, libusb_device *usb_device)
Create a new Ja Rule widget.
Definition JaRuleWidget.cpp:66
ola::usb::JaRuleWidget::~JaRuleWidget
~JaRuleWidget()
Destructor.
Definition JaRuleWidget.cpp:77
ola::usb::JaRuleWidget::GetDeviceId
USBDeviceID GetDeviceId() const
The device ID of this widget.
Definition JaRuleWidget.cpp:99
ola::usb::JaRuleWidget::ManufacturerString
std::string ManufacturerString() const
Get the manufacturer string.
Definition JaRuleWidget.cpp:119
ola::usb::JaRuleWidget::CancelAll
void CancelAll(uint8_t port_id)
Cancel all queued and inflight commands.
Definition JaRuleWidget.cpp:103
ola::usb::JaRuleWidget::SendCommand
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
ola::usb::JaRuleWidget::Init
bool Init()
Initialize the Ja Rule widget.
Definition JaRuleWidget.cpp:87
ola::usb::JaRuleWidget::ProductString
std::string ProductString() const
Get the product string.
Definition JaRuleWidget.cpp:123
ola::usb::LibUsbAdaptor
Wraps calls to libusb so we can test the code.
Definition LibUsbAdaptor.h:36
ola::usb::USBDeviceID
Definition Types.h:30
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
The namespace containing all OLA symbols.
Definition Credentials.cpp:44