Open Lighting Architecture  0.9.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ola::plugin::usbdmx::AsyncUsbSender Class Reference

Detailed Description

A base class that send DMX data asynchronously to a libusb_device.

This encapsulates much of the asynchronous libusb logic. Subclasses should implement the SetupHandle() and PerformTransfer() methods.

Inheritance diagram for ola::plugin::usbdmx::AsyncUsbSender:
Inheritance graph
[legend]
Collaboration diagram for ola::plugin::usbdmx::AsyncUsbSender:
Collaboration graph
[legend]

Public Member Functions

 AsyncUsbSender (class LibUsbAdaptor *const adaptor, libusb_device *usb_device)
 Create a new AsyncUsbSender.
virtual ~AsyncUsbSender ()
 Destructor.
bool Init ()
 Initialize the sender.
bool SendDMX (const DmxBuffer &buffer)
 Send one frame of DMX data.
void TransferComplete (struct libusb_transfer *transfer)
 Called from the libusb callback when the asynchronous transfer completes.

Protected Member Functions

virtual libusb_device_handle * SetupHandle ()=0
 Open the device handle.
virtual bool PerformTransfer (const DmxBuffer &buffer)=0
 Perform the DMX transfer.
virtual void PostTransferHook ()
 Called when the transfer completes.
void CancelTransfer ()
 Cancel any pending transfers.
void FillControlTransfer (unsigned char *buffer, unsigned int timeout)
 Fill a control transfer.
void FillBulkTransfer (unsigned char endpoint, unsigned char *buffer, int length, unsigned int timeout)
 Fill a bulk transfer.
void FillInterruptTransfer (unsigned char endpoint, unsigned char *buffer, int length, unsigned int timeout)
 Fill an interrupt transfer.
int SubmitTransfer ()
 Submit the transfer for tx.
bool TransferPending () const
 Check if there is a pending transfer.

Protected Attributes

class LibUsbAdaptor *const m_adaptor
 The LibUsbAdaptor passed in the constructor.
libusb_device *const m_usb_device
 The libusb_device passed in the constructor.

Constructor & Destructor Documentation

ola::plugin::usbdmx::AsyncUsbSender::AsyncUsbSender ( class LibUsbAdaptor *const  adaptor,
libusb_device *  usb_device 
)

Create a new AsyncUsbSender.

Parameters
adaptorthe LibUsbAdaptor to use.
usb_devicethe libusb_device to use for the widget.

Member Function Documentation

void ola::plugin::usbdmx::AsyncUsbSender::FillControlTransfer ( unsigned char *  buffer,
unsigned int  timeout 
)
protected

Fill a control transfer.

Parameters
bufferpassed to libusb_fill_control_transfer.
timeoutpassed to libusb_fill_control_transfer.
bool ola::plugin::usbdmx::AsyncUsbSender::Init ( )

Initialize the sender.

Returns
true if SetupHandle() returned a valid handle, false otherwise.
virtual bool ola::plugin::usbdmx::AsyncUsbSender::PerformTransfer ( const DmxBuffer buffer)
protectedpure virtual

Perform the DMX transfer.

Parameters
bufferthe DMX buffer to send.
Returns
true if the transfer was scheduled, false otherwise.

This method is implemented by the subclass. The subclass should call FillControlTransfer() / FillBulkTransfer() as appropriate and then call SubmitTransfer().

Implemented in ola::plugin::usbdmx::VellemanAsyncUsbSender, ola::plugin::usbdmx::FadecandyAsyncUsbSender, ola::plugin::usbdmx::EuroliteProAsyncUsbSender, ola::plugin::usbdmx::SunliteAsyncUsbSender, and ola::plugin::usbdmx::AnymaAsyncUsbSender.

virtual void ola::plugin::usbdmx::AsyncUsbSender::PostTransferHook ( )
inlineprotectedvirtual

Called when the transfer completes.

Some devices require multiple transfers per DMX frame. This provides a hook for continuation.

Reimplemented in ola::plugin::usbdmx::VellemanAsyncUsbSender.

bool ola::plugin::usbdmx::AsyncUsbSender::SendDMX ( const DmxBuffer buffer)

Send one frame of DMX data.

Parameters
bufferthe DMX data to send.
Returns
the value of PerformTransfer().
virtual libusb_device_handle* ola::plugin::usbdmx::AsyncUsbSender::SetupHandle ( )
protectedpure virtual
int ola::plugin::usbdmx::AsyncUsbSender::SubmitTransfer ( )
protected

Submit the transfer for tx.

Returns
the result of libusb_submit_transfer().
void ola::plugin::usbdmx::AsyncUsbSender::TransferComplete ( struct libusb_transfer *  transfer)

Called from the libusb callback when the asynchronous transfer completes.

Parameters
transferthe completed transfer.
bool ola::plugin::usbdmx::AsyncUsbSender::TransferPending ( ) const
inlineprotected

Check if there is a pending transfer.

Returns
true if there is a transfer in progress, false otherwise.

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