2022-06-09 16:41:55 -04:00
|
|
|
/*
|
|
|
|
device.h
|
|
|
|
|
|
|
|
Copyright (c) 2022 Kevin Matz (kevin.matz@gmail.com)
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2022-11-15 11:42:27 -05:00
|
|
|
#include "packet.h"
|
2023-05-20 13:39:03 -04:00
|
|
|
#include <functional>
|
2023-05-20 13:29:25 -04:00
|
|
|
#include <udp.h>
|
2022-11-15 11:42:27 -05:00
|
|
|
|
2022-06-09 16:41:55 -04:00
|
|
|
namespace ARTNET {
|
|
|
|
|
2023-05-20 13:29:25 -04:00
|
|
|
using ACN::SDT::UDP::ipAddress;
|
|
|
|
|
2022-06-09 16:41:55 -04:00
|
|
|
/**
|
|
|
|
* @brief The Device class is the base class for ARTNET::Controller
|
|
|
|
* and ARTNET::Node
|
|
|
|
*/
|
|
|
|
class Device
|
|
|
|
{
|
|
|
|
public:
|
2023-05-21 12:41:39 -04:00
|
|
|
explicit Device(Style);
|
|
|
|
|
|
|
|
const Style styleCode; //!< \cite ARTNET The Style code defines the equipment style of the device.
|
2022-11-15 11:42:27 -05:00
|
|
|
|
2023-05-22 09:01:47 -04:00
|
|
|
void receive(ACN::PDU::Stream, ipAddress&);
|
2023-05-20 13:40:10 -04:00
|
|
|
void receive(std::shared_ptr<Packet>);
|
|
|
|
|
2023-05-20 13:39:03 -04:00
|
|
|
std::shared_ptr<void> setSender(const std::function<void(std::shared_ptr<bufferstream>,
|
|
|
|
ipAddress)>);
|
2022-11-15 11:42:27 -05:00
|
|
|
|
2023-05-21 11:12:41 -04:00
|
|
|
std::string shortName() const;
|
|
|
|
void setShortName(const std::string &newShortName);
|
|
|
|
|
|
|
|
std::string longName() const;
|
|
|
|
void setLongName(const std::string &newLongName);
|
|
|
|
|
2022-11-15 11:42:27 -05:00
|
|
|
protected:
|
2023-05-20 13:37:40 -04:00
|
|
|
TalkToMe diagnostic_reporting_behavior; //!< behavior flags
|
|
|
|
Priority diagnostic_reporting_threshold; //!< lowest priority dignostic message to send
|
2023-05-21 13:58:16 -04:00
|
|
|
GeneralStatus device_status; //!< general status register
|
2023-05-20 13:37:40 -04:00
|
|
|
|
2023-05-20 13:39:03 -04:00
|
|
|
void send(const std::shared_ptr<Packet> packet, const ipAddress &) const;
|
2023-05-21 13:46:35 -04:00
|
|
|
void setReport(const NodeReport, const std::string &);
|
2023-05-20 13:39:03 -04:00
|
|
|
|
2023-05-20 13:34:46 -04:00
|
|
|
void rxArtPoll(std::shared_ptr<ArtPoll>);
|
|
|
|
virtual void rxArtPollReply(std::shared_ptr<ArtPollReply>);
|
|
|
|
virtual void rxArtDiagData(std::shared_ptr<ArtDiagData>);
|
|
|
|
virtual void rxArtCommand(std::shared_ptr<ArtCommand>);
|
|
|
|
virtual void rxArtDmx(std::shared_ptr<ArtDmx>);
|
|
|
|
virtual void rxArtNzs(std::shared_ptr<ArtNzs>);
|
|
|
|
virtual void rxArtVlc(std::shared_ptr<ArtNzs>);
|
|
|
|
virtual void rxArtSync(std::shared_ptr<ArtSync>);
|
|
|
|
virtual void rxArtAddress(std::shared_ptr<ArtAddress>);
|
|
|
|
virtual void rxArtInput(std::shared_ptr<ArtInput>);
|
|
|
|
virtual void rxArtTodRequest(std::shared_ptr<ArtTodRequest>);
|
|
|
|
virtual void rxArtTodData(std::shared_ptr<ArtTodData>);
|
|
|
|
virtual void rxArtTodControl(std::shared_ptr<ArtTodControl>);
|
|
|
|
virtual void rxArtRdm(std::shared_ptr<ArtRdm>);
|
|
|
|
virtual void rxArtRdmSub(std::shared_ptr<ArtRdmSub>);
|
|
|
|
virtual void rxArtFirmwareMaster(std::shared_ptr<ArtFirmwareMaster>);
|
|
|
|
virtual void rxArtFirmwareReply(std::shared_ptr<ArtFirmwareReply>);
|
|
|
|
virtual void rxArtIpProg(std::shared_ptr<ArtIpProg>);
|
|
|
|
virtual void rxArtIpProgReply(std::shared_ptr<ArtIpProgReply>);
|
|
|
|
virtual void rxArtTimeCode(std::shared_ptr<ArtTimeCode>);
|
|
|
|
virtual void rxArtTrigger(std::shared_ptr<ArtTrigger>);
|
2022-11-15 11:42:27 -05:00
|
|
|
|
2023-05-21 14:05:19 -04:00
|
|
|
virtual void txArtPollReply(std::shared_ptr<pollreply_data> = nullptr);
|
2022-11-15 11:42:27 -05:00
|
|
|
virtual void txArtDiagData();
|
2023-05-20 13:29:25 -04:00
|
|
|
|
2023-05-22 09:13:03 -04:00
|
|
|
// OSI layer 2
|
2023-05-21 12:48:16 -04:00
|
|
|
virtual std::array<uint8_t, 6> deviceMac() const;
|
2023-05-22 09:13:03 -04:00
|
|
|
// OSI layer 3
|
2023-05-21 12:47:47 -04:00
|
|
|
virtual ipAddress deviceIp() const;
|
|
|
|
virtual ipAddress broadcastIp() const;
|
2023-05-22 10:14:38 -04:00
|
|
|
virtual uint32_t deviceSubnetMask() const;
|
2023-05-22 09:13:03 -04:00
|
|
|
virtual bool deviceHasDHCP() const;
|
2023-05-20 13:29:25 -04:00
|
|
|
|
2023-05-20 13:39:03 -04:00
|
|
|
private:
|
|
|
|
std::weak_ptr<const std::function<void(std::shared_ptr<bufferstream>, ipAddress)>> _sender;
|
2023-05-21 11:12:41 -04:00
|
|
|
|
|
|
|
std::string _shortName;
|
|
|
|
std::string _longName;
|
2023-05-21 13:46:35 -04:00
|
|
|
NodeReport _report_code;
|
|
|
|
uint _poll_reply_count;
|
|
|
|
std::string _report_text;
|
2022-06-09 16:41:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ARTNET
|