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;
128 bool EnterConfigurationMode();
135 bool ExitConfigurationMode();
143 bool SetShortName(
const std::string &name);
144 std::string ShortName()
const {
return m_short_name; }
150 bool SetLongName(
const std::string &name);
151 std::string LongName()
const {
return m_long_name; }
157 bool SetNetAddress(uint8_t net_address);
158 uint8_t NetAddress()
const {
return m_net_address; }
164 bool SetSubnetAddress(uint8_t subnet_address);
165 uint8_t SubnetAddress()
const {
166 return m_output_ports[0].universe_address >> 4;
173 uint8_t InputPortCount()
const;
178 bool SetInputPortUniverse(uint8_t port_id, uint8_t universe_id);
188 uint8_t GetInputPortUniverse(uint8_t port_id)
const;
194 void DisableInputPort(uint8_t port_id);
202 bool InputPortState(uint8_t port_id)
const;
209 bool SetOutputPortUniverse(uint8_t port_id, uint8_t universe_id);
216 uint8_t GetOutputPortUniverse(uint8_t port_id);
222 void DisableOutputPort(uint8_t port_id);
230 bool OutputPortState(uint8_t port_id)
const;
232 void SetBroadcastThreshold(
unsigned int threshold) {
233 m_broadcast_threshold = threshold;
241 bool SetMergeMode(uint8_t port_id, artnet_merge_mode merge_mode);
267 void RunFullDiscovery(uint8_t port_id,
279 void RunIncrementalDiscovery(uint8_t port_id,
294 void SendRDMRequest(uint8_t port_id,
304 bool SetUnsolicitedUIDSetHandler(
316 void GetSubscribedNodes(
318 std::vector<ola::network::IPV4Address> *node_addresses);
328 bool SetDMXHandler(uint8_t port_id,
342 bool SetOutputPortRDMHandlers(
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,
524 const artnet_ip_prog_t &packet,
525 unsigned int packet_size);
530 void PopulatePacketHeader(
artnet_packet *packet, uint16_t op_code);
558 void UpdatePortFromSource(OutputPort *port,
const DMXSource &source);
564 const std::string &packet_type,
571 const std::string &packet_type,
572 unsigned int actual_size,
573 unsigned int expected_size);
579 InputPort *GetInputPort(uint8_t port_id,
bool warn =
true);
584 const InputPort *GetInputPort(uint8_t port_id)
const;
589 InputPort *GetEnabledInputPort(uint8_t port_id,
const std::string &action);
594 OutputPort *GetOutputPort(uint8_t port_id);
599 const OutputPort *GetOutputPort(uint8_t port_id)
const;
604 OutputPort *GetEnabledOutputPort(uint8_t port_id,
const std::string &action);
609 void UpdatePortFromTodPacket(
InputPort *port,
611 const artnet_toddata_t &packet,
612 unsigned int packet_size);
617 void ReleaseDiscoveryLock(
InputPort *port);
625 bool StartDiscoveryProcess(
InputPort *port,
633 static const char ARTNET_ID[];
634 static const uint16_t ARTNET_PORT = 6454;
635 static const uint16_t OEM_CODE = 0x0431;
636 static const uint16_t ARTNET_VERSION = 14;
639 static const uint8_t NODE_CODE = 0x00;
640 static const uint16_t MAX_UIDS_PER_UNIVERSE = 0xffff;
641 static const uint8_t RDM_VERSION = 0x01;
642 static const uint8_t TOD_FLUSH_COMMAND = 0x01;
643 static const unsigned int MERGE_TIMEOUT = 10;
645 static const unsigned int NODE_TIMEOUT = 31;
647 static const unsigned int RDM_TOD_TIMEOUT_MS = 4000;
649 static const unsigned int RDM_MISSED_TODDATA_LIMIT = 3;
652 static const unsigned int RDM_REQUEST_QUEUE_LIMIT = 100;
654 static const unsigned int RDM_REQUEST_TIMEOUT_MS = 2000;
675 m_impl->SendRDMRequest(m_port_id, request, on_complete);
679 m_impl->RunFullDiscovery(m_port_id, callback);
683 m_impl->RunIncrementalDiscovery(m_port_id, callback);
705 bool Start() {
return m_impl.Start(); }
706 bool Stop() {
return m_impl.Stop(); }
708 bool EnterConfigurationMode() {
709 return m_impl.EnterConfigurationMode();
711 bool ExitConfigurationMode() {
712 return m_impl.ExitConfigurationMode();
716 bool SetShortName(
const std::string &name) {
717 return m_impl.SetShortName(name);
720 std::string ShortName()
const {
return m_impl.ShortName(); }
721 bool SetLongName(
const std::string &name) {
722 return m_impl.SetLongName(name);
725 std::string LongName()
const {
return m_impl.LongName(); }
727 uint8_t NetAddress()
const {
return m_impl.NetAddress(); }
728 bool SetNetAddress(uint8_t net_address) {
729 return m_impl.SetNetAddress(net_address);
731 bool SetSubnetAddress(uint8_t subnet_address) {
732 return m_impl.SetSubnetAddress(subnet_address);
734 uint8_t SubnetAddress()
const {
735 return m_impl.SubnetAddress();
738 uint8_t InputPortCount()
const {
739 return m_impl.InputPortCount();
742 bool SetInputPortUniverse(uint8_t port_id, uint8_t universe_id) {
743 return m_impl.SetInputPortUniverse(port_id, universe_id);
745 uint8_t GetInputPortUniverse(uint8_t port_id)
const {
746 return m_impl.GetInputPortUniverse(port_id);
748 void DisableInputPort(uint8_t port_id) {
749 m_impl.DisableInputPort(port_id);
751 bool InputPortState(uint8_t port_id)
const {
752 return m_impl.InputPortState(port_id);
755 bool SetOutputPortUniverse(uint8_t port_id, uint8_t universe_id) {
756 return m_impl.SetOutputPortUniverse(port_id, universe_id);
758 uint8_t GetOutputPortUniverse(uint8_t port_id) {
759 return m_impl.GetOutputPortUniverse(port_id);
761 void DisableOutputPort(uint8_t port_id) {
762 m_impl.DisableOutputPort(port_id);
764 bool OutputPortState(uint8_t port_id)
const {
765 return m_impl.OutputPortState(port_id);
768 void SetBroadcastThreshold(
unsigned int threshold) {
769 m_impl.SetBroadcastThreshold(threshold);
772 bool SetMergeMode(uint8_t port_id, artnet_merge_mode merge_mode) {
773 return m_impl.SetMergeMode(port_id, merge_mode);
778 return m_impl.SendPoll();
783 return m_impl.SendDMX(port_id, buffer);
789 void RunFullDiscovery(uint8_t port_id,
795 void RunIncrementalDiscovery(uint8_t port_id,
801 void SendRDMRequest(uint8_t port_id,
809 bool SetUnsolicitedUIDSetHandler(
812 return m_impl.SetUnsolicitedUIDSetHandler(port_id, on_tod);
814 void GetSubscribedNodes(
816 std::vector<ola::network::IPV4Address> *node_addresses) {
817 m_impl.GetSubscribedNodes(port_id, node_addresses);
821 bool SetDMXHandler(uint8_t port_id,
824 return m_impl.SetDMXHandler(port_id, buffer, handler);
827 return m_impl.SendTod(port_id, uid_set);
829 bool SetOutputPortRDMHandlers(
836 return m_impl.SetOutputPortRDMHandlers(port_id,
844 return m_impl.SendTimeCode(timecode);
849 std::vector<ArtNetNodeImplRDMWrapper*> m_wrappers;
850 std::vector<ola::rdm::DiscoverableQueueingRDMController*> m_controllers;
856 bool CheckInputPortId(uint8_t port_id);
863 #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:682
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
The interface for UDPSockets.
Definition: Socket.h:48
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:234
Used to hold a single universe of DMX data.
Definition: DmxBuffer.h:49
Definition: ArtNetPackets.h:252
A class used to hold a single universe of DMX data.
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
The actual Art-Net Node.
Definition: ArtNetNode.h:697
Definition: Interface.h:35
An RDM Controller that queues messages and only sends a single message at a time. ...
Definition: ArtNetNode.h:664
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:678
void SendRDMRequest(ola::rdm::RDMRequest *request, ola::rdm::RDMCallback *on_complete)
Send a RDM command.
Definition: ArtNetNode.h:673
A 2 argument callback which can be called multiple times.
Definition: Callback.h:1895
Represents a RDM UID.
Definition: UID.h:57
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
Represents a point in time with microsecond accuracy.
Definition: Clock.h:191
A 1 argument callback which can be called multiple times.
Definition: Callback.h:992
Classes that represent RDM commands.