Open Lighting Architecture  Latest Git
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | List of all members
ola::usb::JaRuleWidget Class Reference

Detailed Description

A Ja Rule hardware device (widget).

Ja Rule devices may have more than one DMX/RDM port.

This class provides two ways to control the ports on the device:

To obtain a JaRulePortHandle, call ClaimPort(), when you're finished with the JaRulePortHandle you must call ReleasePort().

Public Member Functions

 JaRuleWidget (ola::thread::ExecutorInterface *executor, AsynchronousLibUsbAdaptor *adaptor, libusb_device *usb_device)
 Create a new Ja Rule widget. More...
 
 ~JaRuleWidget ()
 Destructor.
 
bool Init ()
 Initialize the Ja Rule widget. More...
 
USBDeviceID GetDeviceId () const
 The device ID of this widget. More...
 
void CancelAll (uint8_t port_id)
 Cancel all queued and inflight commands. More...
 
uint8_t PortCount () const
 The number of ports on the widget. More...
 
ola::rdm::UID GetUID () const
 The UID of the widget. More...
 
std::string ManufacturerString () const
 Get the manufacturer string. More...
 
std::string ProductString () const
 Get the product string. More...
 
class JaRulePortHandleClaimPort (uint8_t port_index)
 Claim a handle to a port. More...
 
void ReleasePort (uint8_t port_index)
 Release a handle to a port. More...
 
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. More...
 

Constructor & Destructor Documentation

ola::usb::JaRuleWidget::JaRuleWidget ( ola::thread::ExecutorInterface executor,
AsynchronousLibUsbAdaptor adaptor,
libusb_device *  usb_device 
)

Create a new Ja Rule widget.

Parameters
executorThe Executor to run the callbacks on.
adaptorThe LibUsbAdaptor to use.
usb_devicethe libusb_device for the Ja Rule widget.

Member Function Documentation

void ola::usb::JaRuleWidget::CancelAll ( uint8_t  port_id)

Cancel all queued and inflight commands.

Parameters
port_idThe port id of the commands to cancel

This will immediately run all CommandCompleteCallbacks with the COMMAND_CANCELLED code.

JaRulePortHandle * ola::usb::JaRuleWidget::ClaimPort ( uint8_t  port_index)

Claim a handle to a port.

Parameters
port_indexThe port to claim.
Returns
a port handle, ownership is not transferred. Will return NULL if the port id is invalid, or already claimed.
USBDeviceID ola::usb::JaRuleWidget::GetDeviceId ( ) const

The device ID of this widget.

Returns
The USBDeviceID.
UID ola::usb::JaRuleWidget::GetUID ( ) const

The UID of the widget.

Precondition
Init() has been called and returned true;
Returns
The UID for the device.
bool ola::usb::JaRuleWidget::Init ( )

Initialize the Ja Rule widget.

Returns
true if the USB device was opened and claimed correctly, false otherwise.
string ola::usb::JaRuleWidget::ManufacturerString ( ) const

Get the manufacturer string.

Precondition
Init() has been called and returned true;
Returns
The manufacturer string.
uint8_t ola::usb::JaRuleWidget::PortCount ( ) const

The number of ports on the widget.

Precondition
Init() has been called and returned true;
Returns
The number of ports.

Ports are numbered consecutively from 0.

string ola::usb::JaRuleWidget::ProductString ( ) const

Get the product string.

Precondition
Init() has been called and returned true;
Returns
The product string.
void ola::usb::JaRuleWidget::ReleasePort ( uint8_t  port_index)

Release a handle to a port.

Parameters
port_indexThe port to claim
Returns
a port handle, ownership is not transferred.
void ola::usb::JaRuleWidget::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.

Parameters
port_indexThe port on which to send the command.
commandthe Command type.
datathe payload data. The data is copied and can be freed once the method returns.
sizethe payload size.
callbackThe callback to run when the command completes. This may be run immediately in some conditions.

SendCommand() can be called from any thread, and messages will be queued.


The documentation for this class was generated from the following files: