Open Lighting Architecture: ola::plugin::usbdmx::JaRuleWidget Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | List of all members
ola::plugin::usbdmx::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:

- The low level SendCommand() method, which sends a single request and invokes a callback when the response is received.
- The high level API where the port is accessed via a JaRulePortHandle. Since the JaRulePortHandle implements the ola::rdm::DiscoverableRDMControllerInterface, the usual RDM methods can be used.

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

## Constructor & Destructor Documentation

## ◆ JaRuleWidget()

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

Create a new Ja Rule widget.

Parameters

  executor | The Executor to run the callbacks on.
  adaptor | The LibUsbAdaptor to use.
  usb_device | the libusb_device for the Ja Rule widget.

## Member Function Documentation

## ◆ CancelAll()

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

Cancel all queued and inflight commands.

Parameters

  port_id | The port id of the commands to cancel

This will immediately run all CommandCompleteCallbacks with the COMMAND_CANCELLED code.

## ◆ ClaimPort()

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

Claim a handle to a port.

Parameters

  port_index | The port to claim.

Returns
  a port handle, ownership is not transferred. Will return NULL if the port id is invalid, or already claimed.

## ◆ GetDeviceId()

USBDeviceID ola::usb::JaRuleWidget::GetDeviceId | ( |  | ) | const

The device ID of this widget.

Returns
  The USBDeviceID.

## ◆ GetUID()

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.

## ◆ Init()

bool ola::usb::JaRuleWidget::Init | ( |  | ) |

Initialize the Ja Rule widget.

Returns
  true if the USB device was opened and claimed correctly, false otherwise.

## ◆ ManufacturerString()

string ola::usb::JaRuleWidget::ManufacturerString | ( |  | ) | const

Get the manufacturer string.

Precondition
  Init() has been called and returned true;

Returns
  The manufacturer string.

## ◆ PortCount()

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.

## ◆ ProductString()

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

Get the product string.

Precondition
  Init() has been called and returned true;

Returns
  The product string.

## ◆ ReleasePort()

void ola::usb::JaRuleWidget::ReleasePort | ( | uint8_t | port_index | ) |

Release a handle to a port.

Parameters

  port_index | The port to claim

Returns
  a port handle, ownership is not transferred.

## ◆ SendCommand()

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_index | The port on which to send the command.
  command | the Command type.
  data | the payload data. The data is copied and can be freed once the method returns.
  size | the payload size.
  callback | The 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:

- libs/usb/JaRuleWidget.h
- libs/usb/JaRuleWidget.cpp