NAP
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
ArtNetController Class Reference

#include <artnetcontroller.h>

Public Types

using ByteChannelData = std::vector< uint8 >
 
using FloatChannelData = std::vector< float >
 
using Address = uint8
 

Public Member Functions

 ArtNetController ()=default
 
 ArtNetController (ArtNetService &service)
 
virtual bool start (nap::utility::ErrorState &errorState) override
 
virtual void stop () override
 
void send (const FloatChannelData &channelData, int channelOffset=0)
 
void send (float channelData, int channel)
 
void send (const ByteChannelData &channelData, int channelOffset=0)
 
void send (uint8 channelData, int channel)
 
void clear ()
 
Address getAddress () const
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual bool init (utility::ErrorState &errorState)
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Static Public Member Functions

static Address createAddress (uint8 subnet, uint8 universe)
 
static void convertAddress (Address address, uint8 &subnet, uint8 &universe)
 
- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Public Attributes

uint8 mSubnet = 0
 Property: 'Subnet' range from 0 - 15. More...
 
uint8 mUniverse = 0
 Property: 'Universe' range from 0 - 15. More...
 
int mUpdateFrequency = artnet::refreshRate
 Property: 'Frequency' artnet refresh rate, the default is the maximum refresh rate. More...
 
float mWaitTime = 2.0f
 Property: 'WaitTime' number of seconds before the control data is sent regardless of changes. More...
 
EArtnetMode mMode = EArtnetMode::Broadcast
 Property: 'Mode' artnet message mode, Broadcast or Unicast. More...
 
int mUnicastLimit = 10
 Property: 'UnicastLimit' allowed number of unicast nodes before switching to broadcast mode. Only has effect when mode = Unicast. More...
 
bool mVerbose = false
 Property: 'Verbose' prints artnet network traffic information to the console. More...
 
float mReadTimeout = 2.0f
 Property: 'Timeout' poll network node read timeout, only used when mode is set to Unicast. More...
 
std::string mIpAddress = ""
 Property: 'IP Address' this controller's IP Address, when left empty the first available ethernet adapter is chosen. More...
 
uint16 mChannelCount = 512
 Property: 'ChannelCount' the amount of channels included in each packet, must be between 2 and 512. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Description

Creates an ArtNet controller node. A controller node is used to convert dmx data into artnet data that is sent over the network. Every controller node has a subnet and universe associated with it. See comments in ArtNetService on addressing on how data is eventually sent over the network.

Inheritance diagram for ArtNetController:
[legend]
Collaboration diagram for ArtNetController:
[legend]

Member Typedef Documentation

◆ Address

using Address = uint8

◆ ByteChannelData

using ByteChannelData = std::vector<uint8>

◆ FloatChannelData

using FloatChannelData = std::vector<float>

Constructor & Destructor Documentation

◆ ArtNetController() [1/2]

ArtNetController ( )
default

◆ ArtNetController() [2/2]

Member Function Documentation

◆ clear()

void clear ( )

Clears all the data associated with this controller, ie: sets their values to 0

◆ convertAddress()

static void convertAddress ( Address  address,
uint8 subnet,
uint8 universe 
)
static

Converts a nap artnet address in to a subnet and universe

Parameters
addressthe artnet address to convert
subnetthe subnet part of the address
universethe universe part of the address;

◆ createAddress()

static Address createAddress ( uint8  subnet,
uint8  universe 
)
static

Creates a unique artnet address based on a subnet and universe

Parameters
subnetthe artnet subnet address
universethe artnet universe address

◆ getAddress()

Address getAddress ( ) const
Returns
Address where this controllers maps to. Upper 4 bits contain subnet, lower 4 bits contain universe.

◆ send() [1/4]

void send ( const ByteChannelData channelData,
int  channelOffset = 0 
)

Sends byte channel data over the artnet network. The actual sending is deferred until the update of the service, where data is sent when needed.

Parameters
channelDatadata in unsigned bytes (0 - 255)
channelOffsetdefines where to insert the data in the array. If the channel offset plus the size of the channelData exceeds the maximum amount of channels per universe (mChannelCount), the function will assert.

◆ send() [2/4]

void send ( const FloatChannelData channelData,
int  channelOffset = 0 
)

Sends normalized float channel data (ranging from 0.0 to 1.0) over the artnet network. Internally, the float data is converted to bytes. The actual sending is deferred until the update within the service, where data is sent when needed.

Parameters
channelDatadata to send in normalized floats (0.0 to 1.0)
channelOffsetdefines where to insert the data in the array. If the channel offset plus the size of the channelData exceeds the maximum amount of channels per universe (mChannelCount), the function will assert.

◆ send() [3/4]

void send ( float  channelData,
int  channel 
)

Sends normalized float channel data (ranging from 0.0 to 1.0) over the artnet network. Internally, the float data is converted to bytes. The actual sending is deferred until the update, where data is sent when needed.

Parameters
channelDataChannel data in normalized floats (0.0 to 1.0)
channelThe target channel where channelData should be applied to. Must be between 0 and 511.

◆ send() [4/4]

void send ( uint8  channelData,
int  channel 
)

Sends byte channel data over the artnet network. The actual sending is deferred until the update, where data is sent when needed.

Parameters
channelDataChannel data in unsigned bytes (0 - 255)
channelThe target channel where channelData should be applied to. Must be between 0 and 511.

◆ start()

virtual bool start ( nap::utility::ErrorState errorState)
overridevirtual

Creates a mapping to the subnet and address.

Parameters
errorStateContains error information in case the function returns false.
Returns
true on success, false otherwise. In case of an error, errorState contains error information.

Reimplemented from Device.

◆ stop()

virtual void stop ( )
overridevirtual

Removes the controller from the service and destroys the managed artnet node

Reimplemented from Device.

Member Data Documentation

◆ mChannelCount

uint16 mChannelCount = 512

Property: 'ChannelCount' the amount of channels included in each packet, must be between 2 and 512.

◆ mIpAddress

std::string mIpAddress = ""

Property: 'IP Address' this controller's IP Address, when left empty the first available ethernet adapter is chosen.

◆ mMode

Property: 'Mode' artnet message mode, Broadcast or Unicast.

◆ mReadTimeout

float mReadTimeout = 2.0f

Property: 'Timeout' poll network node read timeout, only used when mode is set to Unicast.

◆ mSubnet

uint8 mSubnet = 0

Property: 'Subnet' range from 0 - 15.

◆ mUnicastLimit

int mUnicastLimit = 10

Property: 'UnicastLimit' allowed number of unicast nodes before switching to broadcast mode. Only has effect when mode = Unicast.

◆ mUniverse

uint8 mUniverse = 0

Property: 'Universe' range from 0 - 15.

◆ mUpdateFrequency

int mUpdateFrequency = artnet::refreshRate

Property: 'Frequency' artnet refresh rate, the default is the maximum refresh rate.

◆ mVerbose

bool mVerbose = false

Property: 'Verbose' prints artnet network traffic information to the console.

◆ mWaitTime

float mWaitTime = 2.0f

Property: 'WaitTime' number of seconds before the control data is sent regardless of changes.