![]() |
Open Lighting Architecture 0.10.9
|
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 |
| ola::plugin::osc::OSCNode::OSCNode | ( | ola::io::SelectServerInterface * | ss, |
| ola::ExportMap * | export_map, | ||
| const OSCNodeOptions & | options ) |
Create a new OSCNode.
| ss | the SelectServer to use |
| export_map | a pointer to an ExportMap (may be NULL) |
| options | the OSCNodeOptions |
| ola::plugin::osc::OSCNode::~OSCNode | ( | ) |
Cleanup
| void ola::plugin::osc::OSCNode::AddTarget | ( | unsigned int | group, |
| const OSCTarget & | target ) |
Add a target for a particular group.
| group | the group to add this target to |
| target | the 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.
| osc_address | the OSC address to register. |
| callback | the callback to run, ownership is transferred. The callback can be set to NULL to de-register. |
| bool ola::plugin::osc::OSCNode::RemoveTarget | ( | unsigned int | group, |
| const OSCTarget & | target ) |
De-Register a target from this group.
| group | the group to remove the target from |
| target | the OSCTarget to remove |
| 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.
| group | the group to send the data to |
| data_format | the format of data to send |
| dmx_data | the DmxBuffer to send |
| 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.
| osc_address | the OSC address this data arrived on |
| slot | the slot offset to set. |
| value | the 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.
| osc_address | the OSC address this data arrived on |
| data | the DmxBuffer containing the data. |
| size | the number of slots. |
| void ola::plugin::osc::OSCNode::Stop | ( | ) |
Stop this node. This removes all registrations and targets.