OpenLCP/protocol/artistic/artnet/device.h

114 lines
4.4 KiB
C++

/*
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
#include "packet.h"
#include <functional>
#include <udp.h>
namespace ARTNET {
using ACN::SDT::UDP::ipAddress;
/**
* @brief The Device class is the base class for ARTNET::Controller
* and ARTNET::Node
*/
class Device
{
public:
explicit Device();
void receive(ACN::PDU::Stream);
void receive(std::shared_ptr<Packet>);
std::shared_ptr<void> setSender(const std::function<void(std::shared_ptr<bufferstream>,
ipAddress)>);
protected:
TalkToMe diagnostic_reporting_behavior; //!< behavior flags
Priority diagnostic_reporting_threshold; //!< lowest priority dignostic message to send
void send(const std::shared_ptr<Packet> packet, const ipAddress &) const;
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 rxArtVideoSetup(std::shared_ptr<ArtVideoSetup>);
virtual void rxArtVideoPalette(std::shared_ptr<ArtVideoPalette>);
virtual void rxArtVideoData(std::shared_ptr<ArtVideoData>);
virtual void rxArtFirmwareMaster(std::shared_ptr<ArtFirmwareMaster>);
virtual void rxArtFirmwareReply(std::shared_ptr<ArtFirmwareReply>);
virtual void rxArtFileTnMaster(std::shared_ptr<ArtFileTnMaster>);
virtual void rxArtFileFnMaster(std::shared_ptr<ArtFileFnMaster>);
virtual void rxArtFileFnReply(std::shared_ptr<ArtFileFnReply>);
virtual void rxArtIpProg(std::shared_ptr<ArtIpProg>);
virtual void rxArtIpProgReply(std::shared_ptr<ArtIpProgReply>);
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>);
virtual void rxArtTimeCode(std::shared_ptr<ArtTimeCode>);
virtual void rxArtTimeSync(std::shared_ptr<ArtTimeSync>);
virtual void rxArtTrigger(std::shared_ptr<ArtTrigger>);
virtual void rxArtDirectory(std::shared_ptr<ArtDirectory>);
virtual void rxArtDirectoryReply(std::shared_ptr<ArtDirectoryReply>);
void txArtPollReply();
virtual void txArtDiagData();
/**
* @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;
private:
std::weak_ptr<const std::function<void(std::shared_ptr<bufferstream>, ipAddress)>> _sender;
};
} // namespace ARTNET