/* 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 #include 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(Style); const Style styleCode; //!< \cite ARTNET The Style code defines the equipment style of the device. void receive(ACN::PDU::Stream, ipAddress&); void receive(std::shared_ptr); std::shared_ptr setSender(const std::function, ipAddress)>); std::string shortName() const; void setShortName(const std::string &newShortName); std::string longName() const; void setLongName(const std::string &newLongName); protected: TalkToMe diagnostic_reporting_behavior; //!< behavior flags Priority diagnostic_reporting_threshold; //!< lowest priority dignostic message to send GeneralStatus device_status; //!< general status register void send(const std::shared_ptr packet, const ipAddress &) const; void setReport(const NodeReport, const std::string &); void rxArtPoll(std::shared_ptr); virtual void rxArtPollReply(std::shared_ptr); virtual void rxArtDiagData(std::shared_ptr); virtual void rxArtCommand(std::shared_ptr); virtual void rxArtDmx(std::shared_ptr); virtual void rxArtNzs(std::shared_ptr); virtual void rxArtVlc(std::shared_ptr); virtual void rxArtSync(std::shared_ptr); virtual void rxArtAddress(std::shared_ptr); virtual void rxArtInput(std::shared_ptr); virtual void rxArtTodRequest(std::shared_ptr); virtual void rxArtTodData(std::shared_ptr); virtual void rxArtTodControl(std::shared_ptr); virtual void rxArtRdm(std::shared_ptr); virtual void rxArtRdmSub(std::shared_ptr); virtual void rxArtFirmwareMaster(std::shared_ptr); virtual void rxArtFirmwareReply(std::shared_ptr); virtual void rxArtIpProg(std::shared_ptr); virtual void rxArtIpProgReply(std::shared_ptr); virtual void rxArtTimeCode(std::shared_ptr); virtual void rxArtTrigger(std::shared_ptr); virtual void txArtPollReply(std::shared_ptr = nullptr); virtual void txArtDiagData(); virtual std::array deviceMac() const; virtual ipAddress deviceIp() const; virtual ipAddress broadcastIp() const; private: std::weak_ptr, ipAddress)>> _sender; std::string _shortName; std::string _longName; NodeReport _report_code; uint _poll_reply_count; std::string _report_text; }; } // namespace ARTNET