2021-08-08 17:25:41 -04:00
|
|
|
/*
|
|
|
|
device.h
|
|
|
|
|
|
|
|
Copyright (c) 2021 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-28 16:37:38 -05:00
|
|
|
#include "../dmx/device.h"
|
2023-05-02 13:00:19 -04:00
|
|
|
#include "basicdevice.h"
|
|
|
|
#include "subdevice.h"
|
2021-08-08 17:25:41 -04:00
|
|
|
#include "uid.h"
|
|
|
|
|
2021-08-09 15:04:49 -04:00
|
|
|
#include <list>
|
2021-08-12 00:31:00 -04:00
|
|
|
#include <queue>
|
2021-08-09 15:04:49 -04:00
|
|
|
#include <string>
|
2021-08-08 17:25:41 -04:00
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace RDM {
|
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
/**
|
|
|
|
* @brief The RDM::Device class
|
|
|
|
*/
|
2021-08-08 17:25:41 -04:00
|
|
|
class Device
|
2023-05-02 13:00:19 -04:00
|
|
|
: public RDM::BasicDevice
|
|
|
|
, public DMX::Device
|
2021-08-08 17:25:41 -04:00
|
|
|
{
|
|
|
|
public:
|
2023-05-02 13:00:19 -04:00
|
|
|
explicit Device(UID id = UID());
|
2021-08-08 17:25:41 -04:00
|
|
|
virtual ~Device();
|
|
|
|
|
2023-04-28 21:02:35 -04:00
|
|
|
const UID uid; //!< This devices UID
|
|
|
|
|
2023-05-02 13:00:19 -04:00
|
|
|
std::shared_ptr<SubDevice> subDevice(uint16_t number);
|
|
|
|
virtual uint16_t subDeviceCount() const;
|
2021-08-09 15:04:49 -04:00
|
|
|
|
2023-05-02 13:00:19 -04:00
|
|
|
void addProductDetail(uint16_t id);
|
2021-08-08 17:25:41 -04:00
|
|
|
|
|
|
|
protected:
|
2021-08-12 00:31:00 -04:00
|
|
|
friend class Responder;
|
2021-08-09 15:04:49 -04:00
|
|
|
|
2023-05-02 13:00:19 -04:00
|
|
|
virtual void dispatch(MsgPair msg) override;
|
|
|
|
|
|
|
|
void addSubDevice(uint16_t number, std::shared_ptr<SubDevice> dev);
|
|
|
|
void deleteSubDevice(uint16_t number);
|
|
|
|
|
2021-08-12 00:31:00 -04:00
|
|
|
void enqueueMessage(MsgPtr message, bool urgent = false);
|
2021-08-08 17:25:41 -04:00
|
|
|
|
2023-05-02 13:00:19 -04:00
|
|
|
virtual void actionSetClearStatusId(MsgPair msg);
|
|
|
|
virtual void actionGetSubdeviceThreshold(MsgPair msg);
|
|
|
|
virtual void actionSetSubdeviceThreshold(MsgPair msg);
|
|
|
|
virtual void actionGetDeviceInfo(MsgPair msg) override;
|
|
|
|
virtual void actionGetProductDetailIdList(MsgPair msg);
|
|
|
|
virtual void actionGetDevModelDescription(MsgPair msg);
|
|
|
|
virtual void actionGetManufacturerLabel(MsgPair msg);
|
|
|
|
virtual void actionGetLanguage(MsgPair msg);
|
|
|
|
virtual void actionSetLanguage(MsgPair msg);
|
|
|
|
virtual void actionGetDmxPersonality(MsgPair msg);
|
|
|
|
virtual void actionSetDmxPersonality(MsgPair msg);
|
|
|
|
virtual void actionGetDmxPersonalityDesc(MsgPair msg);
|
|
|
|
virtual void actionGetDmxStartAddress(MsgPair msg);
|
|
|
|
virtual void actionSetDmxStartAddress(MsgPair msg);
|
|
|
|
virtual void actionSensorDispatch(MsgPair msg);
|
2021-08-08 17:25:41 -04:00
|
|
|
|
2023-05-02 13:00:19 -04:00
|
|
|
private:
|
|
|
|
std::list<uint16_t> product_detail_list_; //!< product detail list
|
|
|
|
std::unordered_map<uint16_t, std::shared_ptr<SubDevice>> sub_devices_; //!< sub devices
|
|
|
|
std::deque<MsgPtr> queued_messages_; //!< outbound message queue
|
|
|
|
UID controller_uid_; //!< controller UID
|
2021-08-08 17:25:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace RDM
|
|
|
|
|