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:
|
2022-11-15 11:39:54 -05:00
|
|
|
explicit Device();
|
2022-11-15 11:42:27 -05:00
|
|
|
|
2023-05-20 13:40:10 -04:00
|
|
|
void receive(ACN::PDU::Stream);
|
|
|
|
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
|
|
|
|
|
|
|
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-20 13:39:03 -04:00
|
|
|
void send(const std::shared_ptr<Packet> packet, const ipAddress &) const;
|
|
|
|
|
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>);
|
2023-05-20 14:14:59 -04:00
|
|
|
virtual void rxArtVideoSetup(std::shared_ptr<ArtVideoSetup>);
|
|
|
|
virtual void rxArtVideoPalette(std::shared_ptr<ArtVideoPalette>);
|
|
|
|
virtual void rxArtVideoData(std::shared_ptr<ArtVideoData>);
|
2023-05-20 13:34:46 -04:00
|
|
|
virtual void rxArtFirmwareMaster(std::shared_ptr<ArtFirmwareMaster>);
|
|
|
|
virtual void rxArtFirmwareReply(std::shared_ptr<ArtFirmwareReply>);
|
2023-05-20 14:14:59 -04:00
|
|
|
virtual void rxArtFileTnMaster(std::shared_ptr<ArtFileTnMaster>);
|
|
|
|
virtual void rxArtFileFnMaster(std::shared_ptr<ArtFileFnMaster>);
|
|
|
|
virtual void rxArtFileFnReply(std::shared_ptr<ArtFileFnReply>);
|
2023-05-20 13:34:46 -04:00
|
|
|
virtual void rxArtIpProg(std::shared_ptr<ArtIpProg>);
|
|
|
|
virtual void rxArtIpProgReply(std::shared_ptr<ArtIpProgReply>);
|
2023-05-20 14:14:59 -04:00
|
|
|
virtual void rxArtMedia(std::shared_ptr<ArtMedia>);
|
|
|
|
virtual void rxArtMediaPatch(std::shared_ptr<ArtMediaPatch>);
|
|
|
|
virtual void rxArtMediaControl(std::shared_ptr<ArtMediaControl>);
|
|
|
|
virtual void rxArtMediaControlReply(std::shared_ptr<ArtMediaControlReply>);
|
2023-05-20 13:34:46 -04:00
|
|
|
virtual void rxArtTimeCode(std::shared_ptr<ArtTimeCode>);
|
2023-05-20 14:14:59 -04:00
|
|
|
virtual void rxArtTimeSync(std::shared_ptr<ArtTimeSync>);
|
2023-05-20 13:34:46 -04:00
|
|
|
virtual void rxArtTrigger(std::shared_ptr<ArtTrigger>);
|
2023-05-20 14:14:59 -04:00
|
|
|
virtual void rxArtDirectory(std::shared_ptr<ArtDirectory>);
|
|
|
|
virtual void rxArtDirectoryReply(std::shared_ptr<ArtDirectoryReply>);
|
2022-11-15 11:42:27 -05:00
|
|
|
|
2023-05-20 13:34:46 -04:00
|
|
|
void txArtPollReply();
|
2022-11-15 11:42:27 -05:00
|
|
|
virtual void txArtDiagData();
|
2023-05-20 13:29:25 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief deviceIp
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
* \note Platform aware device types must return a valid IP address.
|
|
|
|
*/
|
|
|
|
virtual ipAddress deviceIp() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief broadcastIp
|
|
|
|
* @return
|
|
|
|
*
|
|
|
|
* \note Platform aware device types must return their directed broadcast address.
|
|
|
|
*/
|
|
|
|
virtual ipAddress broadcastIp() const = 0;
|
|
|
|
|
2023-05-20 13:39:03 -04:00
|
|
|
private:
|
|
|
|
std::weak_ptr<const std::function<void(std::shared_ptr<bufferstream>, ipAddress)>> _sender;
|
2022-06-09 16:41:55 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ARTNET
|