Open Lighting Architecture  0.9.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | List of all members
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 arbitary 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

class  NodeOSCTarget
struct  OSCInputGroup
struct  OSCNodeOptions
struct  OSCOutputGroup
struct  SlotMessage

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

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
ola::plugin::osc::OSCNode::~OSCNode ( )

Cleanup

Member Function Documentation

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
uint16_t ola::plugin::osc::OSCNode::ListeningPort ( ) const

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

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.
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
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 sucesfully sent, false if any error occured.
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
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.
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: