21 #ifndef PLUGINS_ARTNET_ARTNETNODE_H_
22 #define PLUGINS_ARTNET_ARTNETNODE_H_
31 #include "ola/Clock.h"
34 #include "ola/network/Interface.h"
35 #include "ola/io/SelectServerInterface.h"
36 #include "ola/network/Socket.h"
39 #include "ola/rdm/RDMFrame.h"
42 #include "ola/timecode/TimeCode.h"
43 #include "plugins/artnet/ArtNetPackets.h"
63 static const uint8_t ARTNET_DISABLE_PORT = 0xf0;
68 : always_broadcast(
false),
69 use_limited_broadcast_address(
false),
71 broadcast_threshold(30),
75 bool always_broadcast;
76 bool use_limited_broadcast_address;
77 unsigned int rdm_queue_size;
78 unsigned int broadcast_threshold;
79 uint8_t input_port_count;
144 std::string ShortName()
const {
return m_short_name; }
151 std::string LongName()
const {
return m_long_name; }
158 uint8_t NetAddress()
const {
return m_net_address; }
165 uint8_t SubnetAddress()
const {
166 return m_output_ports[0].universe_address >> 4;
232 void SetBroadcastThreshold(
unsigned int threshold) {
233 m_broadcast_threshold = threshold;
241 bool SetMergeMode(uint8_t port_id, artnet_merge_mode merge_mode);
318 std::vector<ola::network::IPV4Address> *node_addresses);
357 typedef std::vector<InputPort*> InputPorts;
362 std::pair<ola::network::IPV4Address, uint8_t> > uid_map;
364 enum { MAX_MERGE_SOURCES = 2 };
374 uint8_t universe_address;
375 uint8_t sequence_number;
377 artnet_merge_mode merge_mode;
379 DMXSource sources[MAX_MERGE_SOURCES];
381 std::map<ola::rdm::UID, ola::network::IPV4Address> uid_map;
391 uint8_t m_net_address;
392 bool m_send_reply_on_change;
393 std::string m_short_name;
394 std::string m_long_name;
395 unsigned int m_broadcast_threshold;
396 unsigned int m_unsolicited_replies;
398 bool m_always_broadcast;
399 bool m_use_limited_broadcast_address;
402 bool m_in_configuration_mode;
403 bool m_artpoll_required;
404 bool m_artpollreply_required;
406 InputPorts m_input_ports;
407 OutputPort m_output_ports[ARTNET_MAX_PORTS];
409 std::auto_ptr<ola::network::UDPSocketInterface> m_socket;
421 bool SendPollIfAllowed();
430 bool SendPollReplyIfRequired();
447 unsigned int packet_size);
453 const artnet_poll_t &packet,
454 unsigned int packet_size);
460 const artnet_reply_t &packet,
461 unsigned int packet_size);
467 const artnet_dmx_t &packet,
468 unsigned int packet_size);
474 const artnet_todrequest_t &packet,
475 unsigned int packet_size);
481 const artnet_toddata_t &packet,
482 unsigned int packet_size);
488 const artnet_todcontrol_t &packet,
489 unsigned int packet_size);
495 const artnet_rdm_t &packet,
496 unsigned int packet_size);
503 uint8_t universe_address,
523 const artnet_ip_prog_t &packet,
524 unsigned int packet_size);
529 void PopulatePacketHeader(
artnet_packet *packet, uint16_t op_code);
557 void UpdatePortFromSource(OutputPort *port,
const DMXSource &source);
563 const std::string &packet_type,
570 const std::string &packet_type,
571 unsigned int actual_size,
572 unsigned int expected_size);
578 InputPort *GetInputPort(uint8_t port_id,
bool warn =
true);
583 const InputPort *GetInputPort(uint8_t port_id)
const;
588 InputPort *GetEnabledInputPort(uint8_t port_id,
const std::string &action);
593 OutputPort *GetOutputPort(uint8_t port_id);
598 const OutputPort *GetOutputPort(uint8_t port_id)
const;
603 OutputPort *GetEnabledOutputPort(uint8_t port_id,
const std::string &action);
608 void UpdatePortFromTodPacket(
InputPort *port,
610 const artnet_toddata_t &packet,
611 unsigned int packet_size);
616 void ReleaseDiscoveryLock(
InputPort *port);
624 bool StartDiscoveryProcess(
InputPort *port,
632 static const char ARTNET_ID[];
633 static const uint16_t ARTNET_PORT = 6454;
634 static const uint16_t OEM_CODE = 0x0431;
635 static const uint16_t ARTNET_VERSION = 14;
638 static const uint8_t NODE_CODE = 0x00;
639 static const uint16_t MAX_UIDS_PER_UNIVERSE = 0xffff;
640 static const uint8_t RDM_VERSION = 0x01;
641 static const uint8_t TOD_FLUSH_COMMAND = 0x01;
642 static const unsigned int MERGE_TIMEOUT = 10;
644 static const unsigned int NODE_TIMEOUT = 31;
646 static const unsigned int RDM_TOD_TIMEOUT_MS = 4000;
648 static const unsigned int RDM_MISSED_TODDATA_LIMIT = 3;
651 static const unsigned int RDM_REQUEST_QUEUE_LIMIT = 100;
653 static const unsigned int RDM_REQUEST_TIMEOUT_MS = 2000;
704 bool Start() {
return m_impl.
Start(); }
705 bool Stop() {
return m_impl.
Stop(); }
707 bool EnterConfigurationMode() {
710 bool ExitConfigurationMode() {
715 bool SetShortName(
const std::string &name) {
719 std::string ShortName()
const {
return m_impl.ShortName(); }
720 bool SetLongName(
const std::string &name) {
724 std::string LongName()
const {
return m_impl.LongName(); }
726 uint8_t NetAddress()
const {
return m_impl.NetAddress(); }
727 bool SetNetAddress(uint8_t net_address) {
730 bool SetSubnetAddress(uint8_t subnet_address) {
733 uint8_t SubnetAddress()
const {
734 return m_impl.SubnetAddress();
737 uint8_t InputPortCount()
const {
741 bool SetInputPortUniverse(uint8_t port_id, uint8_t universe_id) {
744 uint8_t GetInputPortUniverse(uint8_t port_id)
const {
747 void DisableInputPort(uint8_t port_id) {
750 bool InputPortState(uint8_t port_id)
const {
754 bool SetOutputPortUniverse(uint8_t port_id, uint8_t universe_id) {
757 uint8_t GetOutputPortUniverse(uint8_t port_id) {
760 void DisableOutputPort(uint8_t port_id) {
763 bool OutputPortState(uint8_t port_id)
const {
767 void SetBroadcastThreshold(
unsigned int threshold) {
768 m_impl.SetBroadcastThreshold(threshold);
771 bool SetMergeMode(uint8_t port_id, artnet_merge_mode merge_mode) {
782 return m_impl.
SendDMX(port_id, buffer);
808 bool SetUnsolicitedUIDSetHandler(
813 void GetSubscribedNodes(
815 std::vector<ola::network::IPV4Address> *node_addresses) {
820 bool SetDMXHandler(uint8_t port_id,
826 return m_impl.
SendTod(port_id, uid_set);
828 bool SetOutputPortRDMHandlers(
848 std::vector<ArtNetNodeImplRDMWrapper*> m_wrappers;
849 std::vector<ola::rdm::DiscoverableQueueingRDMController*> m_controllers;
855 bool CheckInputPortId(uint8_t port_id);
862 #endif // PLUGINS_ARTNET_ARTNETNODE_H_
Represents a set of RDM UIDs.
Definition: UIDSet.h:48
Definitions and Interfaces to implement an RDMController that sends a single message at a time...
Definition: ArtNetNode.h:65
void RunIncrementalDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start an incremental discovery operation.
Definition: ArtNetNode.h:681
bool SetUnsolicitedUIDSetHandler(uint8_t port_id, ola::Callback1< void, const ola::rdm::UIDSet & > *on_tod)
Set the RDM handlers for an Input port.
Definition: ArtNetNode.cpp:713
bool SetOutputPortRDMHandlers(uint8_t port_id, ola::Callback0< void > *on_discover, ola::Callback0< void > *on_flush, ola::Callback2< void, ola::rdm::RDMRequest *, ola::rdm::RDMCallback * > *on_rdm_request)
Set the RDM handlers for an Output port.
Definition: ArtNetNode.cpp:808
bool SetMergeMode(uint8_t port_id, artnet_merge_mode merge_mode)
Set the merge mode for an output port.
Definition: ArtNetNode.cpp:490
void GetSubscribedNodes(uint8_t port_id, std::vector< ola::network::IPV4Address > *node_addresses)
Get the nodes listening to the universe a port is sending.
Definition: ArtNetNode.cpp:723
bool Start()
Start this node. The port modifying functions can be called before this.
Definition: ArtNetNode.cpp:260
The interface for UDPSockets.
Definition: Socket.h:45
bool SetOutputPortUniverse(uint8_t port_id, uint8_t universe_id)
Set the universe for an output port.
Definition: ArtNetNode.cpp:450
The interface that can send RDM commands, as well as perform discovery operations.
Definition: RDMControllerInterface.h:104
RDM Commands that represent requests (GET, SET or DISCOVER).
Definition: RDMCommand.h:233
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
void RunFullDiscovery(uint8_t port_id, ola::rdm::RDMDiscoveryCallback *callback)
Flush the TOD and force a full discovery.
Definition: ArtNetNode.cpp:603
bool SetDMXHandler(uint8_t port_id, DmxBuffer *buffer, ola::Callback0< void > *handler)
Set the closure to be called when we receive data for this universe.
Definition: ArtNetNode.cpp:742
Definition: ArtNetPackets.h:251
A class used to hold a single universe of DMX data.
void SendRDMRequest(uint8_t port_id, ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send an RDMRequest on this port.
Definition: ArtNetNode.cpp:659
Definition: ArtNetNode.h:83
Definition: TimeCode.h:33
The base class that all RDM requests & responses inherit from.
Definition: RDMCommand.h:59
The interface for the SelectServer.
Definition: SelectServerInterface.h:42
Represents a IPv4 Address.
Definition: IPV4Address.h:55
bool InputPortState(uint8_t port_id) const
Check the state of an input port.
Definition: ArtNetNode.cpp:445
bool OutputPortState(uint8_t port_id) const
Check the state of an output port.
Definition: ArtNetNode.cpp:485
uint8_t GetOutputPortUniverse(uint8_t port_id)
Definition: ArtNetNode.cpp:467
The actual ArtNet Node.
Definition: ArtNetNode.h:696
Definition: Interface.h:35
bool SendDMX(uint8_t port_id, const ola::DmxBuffer &buffer)
Send some DMX data.
Definition: ArtNetNode.cpp:528
An RDM Controller that queues messages and only sends a single message at a time. ...
bool Stop()
Stop this node.
Definition: ArtNetNode.cpp:269
void DisableInputPort(uint8_t port_id)
Disable an input port.
Definition: ArtNetNode.cpp:432
Definition: ArtNetNode.h:663
The base class for all 1 argument callbacks.
Definition: Callback.h:982
The raw data for a RDM message and its associated timing information.
Definition: RDMFrame.h:40
Represents an IPv4 Address.
Holds the final state of an RDM request.
Definition: RDMReply.h:43
void RunFullDiscovery(ola::rdm::RDMDiscoveryCallback *callback)
Start a full discovery operation.
Definition: ArtNetNode.h:677
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition: ArtNetNode.h:672
void RunFullDiscovery(uint8_t port_id, ola::rdm::RDMDiscoveryCallback *callback)
Trigger full discovery for a port.
Definition: ArtNetNode.cpp:1815
A 2 argument callback which can be called multiple times.
Definition: Callback.h:1895
virtual ~ArtNetNodeImpl()
Cleanup.
Definition: ArtNetNode.cpp:239
uint8_t GetInputPortUniverse(uint8_t port_id) const
Get an input port universe address.
Definition: ArtNetNode.cpp:427
bool SendPoll()
Send an ArtPoll if any of the ports are sending data.
Definition: ArtNetNode.cpp:501
Represents a RDM UID.
Definition: UID.h:57
void DisableOutputPort(uint8_t port_id)
Disable an output port.
Definition: ArtNetNode.cpp:472
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
bool SendTimeCode(const ola::timecode::TimeCode &timecode)
Send a timecode packet.
Definition: ArtNetNode.cpp:833
bool SetLongName(const std::string &name)
Set the long name.
Definition: ArtNetNode.cpp:347
void RunIncrementalDiscovery(uint8_t port_id, ola::rdm::RDMDiscoveryCallback *callback)
Trigger incremental discovery for a port.
Definition: ArtNetNode.cpp:1825
bool SendTod(uint8_t port_id, const ola::rdm::UIDSet &uid_set)
Send an set of UIDs in one of more ArtTod packets.
Definition: ArtNetNode.cpp:758
bool SetShortName(const std::string &name)
Set the short name.
Definition: ArtNetNode.cpp:338
bool EnterConfigurationMode()
Start the configuration transaction.
Definition: ArtNetNode.cpp:311
bool SetSubnetAddress(uint8_t subnet_address)
Set the the subnet address for this node.
Definition: ArtNetNode.cpp:379
uint8_t InputPortCount() const
Definition: ArtNetNode.cpp:408
bool ExitConfigurationMode()
End the configuration transaction.
Definition: ArtNetNode.cpp:321
void RunIncrementalDiscovery(uint8_t port_id, ola::rdm::RDMDiscoveryCallback *callback)
Run an 'incremental' discovery. This just involves fetching the TOD from all nodes.
Definition: ArtNetNode.cpp:630
A 1 argument callback which can be called multiple times.
Definition: Callback.h:992
bool SetNetAddress(uint8_t net_address)
Set the the net address for this node.
Definition: ArtNetNode.cpp:355
void SendRDMRequest(uint8_t port_id, ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM request by passing it though the Queuing Controller.
Definition: ArtNetNode.cpp:1835
bool SetInputPortUniverse(uint8_t port_id, uint8_t universe_id)
Definition: ArtNetNode.cpp:412
ArtNetNodeImpl(const ola::network::Interface &iface, ola::io::SelectServerInterface *ss, const ArtNetNodeOptions &options, ola::network::UDPSocketInterface *socket=NULL)
Create a new node.
Definition: ArtNetNode.cpp:196
Classes that represent RDM commands.