Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
ola::plugin::osc::OSCNode Class Reference

Detailed Description

The OSCNode object handles sending and receiving DMX data using OSC.

Sending: For sending, OSC Targets are assigned to groups. A group ID is just an arbitrary integer used to identify the group. It's not sent in the OSC packets. For example:

OSCNode node(OSCNode::OSCNodeOptions(), ...); node.Init();

node.AddTarget(1, OSCTarget(...)); node.AddTarget(1, OSCTarget(...)); node.SendData(1, FORMAT_BLOB, dmx);

Receiving: To receive DMX data, register a Callback for a specific OSC Address. For example:

OSCNode node(OSCNode::OSCNodeOptions(), ...); node.Init();

node.RegisterAddress("/dmx/1", NewCallback(...)); // run the SelectServer

// once it's time to stop, de-register this address node.RegisterAddress("/dmx/1", NULL);

Classes

struct  OSCNodeOptions
 

Public Types

enum  DataFormat {
  FORMAT_BLOB , FORMAT_INT_ARRAY , FORMAT_INT_INDIVIDUAL , FORMAT_FLOAT_ARRAY ,
  FORMAT_FLOAT_INDIVIDUAL
}
 
typedef Callback1< void, const DmxBuffer & > DMXCallback
 

Public Member Functions

 OSCNode (ola::io::SelectServerInterface *ss, ola::ExportMap *export_map, const OSCNodeOptions &options)
 
 ~OSCNode ()
 
bool Init ()
 
void Stop ()
 
void AddTarget (unsigned int group, const OSCTarget &target)
 
bool RemoveTarget (unsigned int group, const OSCTarget &target)
 
bool SendData (unsigned int group, DataFormat data_format, const ola::DmxBuffer &data)
 
bool RegisterAddress (const std::string &osc_address, DMXCallback *callback)
 
void SetUniverse (const std::string &osc_address, const uint8_t *data, unsigned int size)
 
void SetSlot (const std::string &osc_address, uint16_t slot, uint8_t value)
 
uint16_t ListeningPort () const
 

Constructor & Destructor Documentation

◆ OSCNode()

ola::plugin::osc::OSCNode::OSCNode ( ola::io::SelectServerInterface * ss,
ola::ExportMap * export_map,
const OSCNodeOptions & options )

Create a new OSCNode.

Parameters
ssthe SelectServer to use
export_mapa pointer to an ExportMap (may be NULL)
optionsthe OSCNodeOptions

◆ ~OSCNode()

ola::plugin::osc::OSCNode::~OSCNode ( )

Cleanup

Member Function Documentation

◆ AddTarget()

void ola::plugin::osc::OSCNode::AddTarget ( unsigned int group,
const OSCTarget & target )

Add a target for a particular group.

Parameters
groupthe group to add this target to
targetthe OSC address for the target

◆ ListeningPort()

uint16_t ola::plugin::osc::OSCNode::ListeningPort ( ) const

Return the listening port. Will be 0 if the node isn't setup.

◆ RegisterAddress()

bool ola::plugin::osc::OSCNode::RegisterAddress ( const std::string & osc_address,
DMXCallback * callback )

Register a callback to be run when we receive data for an address. De-registration can be performed by passing NULL as a callback. Attempting to register more than once on the same address will return false.

Parameters
osc_addressthe OSC address to register.
callbackthe callback to run, ownership is transferred. The callback can be set to NULL to de-register.
Returns
false if callback was non-NULL, but the address was already registered. true otherwise.

◆ RemoveTarget()

bool ola::plugin::osc::OSCNode::RemoveTarget ( unsigned int group,
const OSCTarget & target )

De-Register a target from this group.

Parameters
groupthe group to remove the target from
targetthe OSCTarget to remove
Returns
true if the target was removed, false if it wasn't in the group

◆ SendData()

bool ola::plugin::osc::OSCNode::SendData ( unsigned int group,
DataFormat data_format,
const ola::DmxBuffer & dmx_data )

Send the DMX data to all targets registered for this group.

Parameters
groupthe group to send the data to
data_formatthe format of data to send
dmx_datathe DmxBuffer to send
Returns
true if successfully sent, false if any error occurred.

◆ SetSlot()

void ola::plugin::osc::OSCNode::SetSlot ( const std::string & osc_address,
uint16_t slot,
uint8_t value )

Called by OSCDataHandler when there is new data.

Parameters
osc_addressthe OSC address this data arrived on
slotthe slot offset to set.
valuethe DMX value for the slot

◆ SetUniverse()

void ola::plugin::osc::OSCNode::SetUniverse ( const std::string & osc_address,
const uint8_t * data,
unsigned int size )

Called by OSCDataHandler when there is new data.

Parameters
osc_addressthe OSC address this data arrived on
datathe DmxBuffer containing the data.
sizethe number of slots.

◆ Stop()

void ola::plugin::osc::OSCNode::Stop ( )

Stop this node. This removes all registrations and targets.


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