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"
41 #include "ola/timecode/TimeCode.h"
42 #include "plugins/artnet/ArtNetPackets.h"
62 static const uint8_t ARTNET_DISABLE_PORT = 0xf0;
67 : always_broadcast(
false),
68 use_limited_broadcast_address(
false),
70 broadcast_threshold(30),
74 bool always_broadcast;
75 bool use_limited_broadcast_address;
76 unsigned int rdm_queue_size;
77 unsigned int broadcast_threshold;
78 uint8_t input_port_count;
143 std::string ShortName()
const {
return m_short_name; }
150 std::string LongName()
const {
return m_long_name; }
157 uint8_t NetAddress()
const {
return m_net_address; }
164 uint8_t SubnetAddress()
const {
165 return m_output_ports[0].universe_address >> 4;
231 void SetBroadcastThreshold(
unsigned int threshold) {
232 m_broadcast_threshold = threshold;
240 bool SetMergeMode(uint8_t port_id, artnet_merge_mode merge_mode);
317 std::vector<ola::network::IPV4Address> *node_addresses);
356 typedef std::vector<InputPort*> InputPorts;
361 std::pair<ola::network::IPV4Address, uint8_t> > uid_map;
363 enum { MAX_MERGE_SOURCES = 2 };
373 uint8_t universe_address;
374 uint8_t sequence_number;
376 artnet_merge_mode merge_mode;
378 DMXSource sources[MAX_MERGE_SOURCES];
380 std::map<ola::rdm::UID, ola::network::IPV4Address> uid_map;
390 uint8_t m_net_address;
391 bool m_send_reply_on_change;
392 std::string m_short_name;
393 std::string m_long_name;
394 unsigned int m_broadcast_threshold;
395 unsigned int m_unsolicited_replies;
397 bool m_always_broadcast;
398 bool m_use_limited_broadcast_address;
401 bool m_in_configuration_mode;
402 bool m_artpoll_required;
403 bool m_artpollreply_required;
405 InputPorts m_input_ports;
406 OutputPort m_output_ports[ARTNET_MAX_PORTS];
408 std::auto_ptr<ola::network::UDPSocketInterface> m_socket;
423 bool SendPollIfAllowed();
432 bool SendPollReplyIfRequired();
449 unsigned int packet_size);
455 const artnet_poll_t &packet,
456 unsigned int packet_size);
462 const artnet_reply_t &packet,
463 unsigned int packet_size);
469 const artnet_dmx_t &packet,
470 unsigned int packet_size);
476 const artnet_todrequest_t &packet,
477 unsigned int packet_size);
483 const artnet_toddata_t &packet,
484 unsigned int packet_size);
490 const artnet_todcontrol_t &packet,
491 unsigned int packet_size);
497 const artnet_rdm_t &packet,
498 unsigned int packet_size);
505 uint8_t universe_address,
506 ola::rdm::rdm_response_code code,
508 const std::vector<std::string> &packets);
520 const std::string &rdm_data,
527 const artnet_ip_prog_t &packet,
528 unsigned int packet_size);
533 void PopulatePacketHeader(
artnet_packet *packet, uint16_t op_code);
561 void UpdatePortFromSource(OutputPort *port,
const DMXSource &source);
567 const std::string &packet_type,
574 const std::string &packet_type,
575 unsigned int actual_size,
576 unsigned int expected_size);
582 InputPort *GetInputPort(uint8_t port_id,
bool warn =
true);
587 const InputPort *GetInputPort(uint8_t port_id)
const;
592 InputPort *GetEnabledInputPort(uint8_t port_id,
const std::string &action);
597 OutputPort *GetOutputPort(uint8_t port_id);
602 const OutputPort *GetOutputPort(uint8_t port_id)
const;
607 OutputPort *GetEnabledOutputPort(uint8_t port_id,
const std::string &action);
612 void UpdatePortFromTodPacket(
InputPort *port,
614 const artnet_toddata_t &packet,
615 unsigned int packet_size);
620 void ReleaseDiscoveryLock(
InputPort *port);
628 bool StartDiscoveryProcess(
InputPort *port,
636 static const char ARTNET_ID[];
637 static const uint16_t ARTNET_PORT = 6454;
638 static const uint16_t OEM_CODE = 0x0431;
639 static const uint16_t ARTNET_VERSION = 14;
642 static const uint8_t NODE_CODE = 0x00;
643 static const uint16_t MAX_UIDS_PER_UNIVERSE = 0xffff;
644 static const uint8_t RDM_VERSION = 0x01;
645 static const uint8_t TOD_FLUSH_COMMAND = 0x01;
646 static const unsigned int MERGE_TIMEOUT = 10;
648 static const unsigned int NODE_TIMEOUT = 31;
650 static const unsigned int RDM_TOD_TIMEOUT_MS = 4000;
652 static const unsigned int RDM_MISSED_TODDATA_LIMIT = 3;
655 static const unsigned int RDM_REQUEST_QUEUE_LIMIT = 100;
657 static const unsigned int RDM_REQUEST_TIMEOUT_MS = 2000;
688 ArtNetNodeImpl *m_impl;
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);
860 #endif // PLUGINS_ARTNET_ARTNETNODE_H_