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
|
|
|
|
|
2021-08-09 15:04:49 -04:00
|
|
|
#include "dmx/device.h"
|
2021-08-08 17:25:41 -04:00
|
|
|
#include "parameter.h"
|
|
|
|
#include "rdm.h"
|
2021-08-09 15:04:49 -04:00
|
|
|
#include "sensor.h"
|
2021-08-12 00:31:00 -04:00
|
|
|
#include "status.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
|
2021-08-09 15:04:49 -04:00
|
|
|
: public DMX::Device
|
2021-08-08 17:25:41 -04:00
|
|
|
{
|
|
|
|
public:
|
2021-08-13 10:04:30 -04:00
|
|
|
Device(UID id = UID(), Device* parent = nullptr);
|
2021-08-08 17:25:41 -04:00
|
|
|
virtual ~Device();
|
|
|
|
|
2021-08-09 15:04:49 -04:00
|
|
|
void addSubDevice(uint16_t number, Device* dev);
|
|
|
|
Device* subDevice(uint16_t number);
|
|
|
|
uint16_t subDeviceCount() const;
|
|
|
|
void addProductDetailId(uint16_t);
|
|
|
|
|
2021-08-11 10:28:03 -04:00
|
|
|
void get(const MsgPtr message, MsgPtr response);
|
|
|
|
void set(const MsgPtr message, MsgPtr response);
|
2021-08-08 17:25:41 -04:00
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
virtual void identify(bool state);
|
|
|
|
virtual void reset(bool hard);
|
2021-08-08 17:25:41 -04:00
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
uint16_t deviceModelID; //!< model ID number
|
|
|
|
std::string deviceModelDescription; //!< model description
|
|
|
|
uint16_t deviceProductCategory; //!< device category
|
2021-08-08 17:25:41 -04:00
|
|
|
|
|
|
|
protected:
|
2021-08-12 00:31:00 -04:00
|
|
|
friend class Responder;
|
2021-08-25 17:20:33 -04:00
|
|
|
UID id_; //!< device UID
|
|
|
|
std::unordered_map<uint16_t, Device*> sub_devices_; //!< sub devices
|
|
|
|
std::unordered_map<PID, Parameter*> parameters_; //!< parameters
|
|
|
|
std::vector<Sensor*> sensors_; //!< sensors
|
|
|
|
std::list<uint16_t> product_detail_list_; //!< product detail list
|
2021-08-09 15:04:49 -04:00
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
std::deque<MsgPtr> queued_messages_; //!< outbound message queue
|
2021-08-12 00:31:00 -04:00
|
|
|
void enqueueMessage(MsgPtr message, bool urgent = false);
|
2021-08-25 17:20:33 -04:00
|
|
|
UID controller_uid_; //!< controller UID
|
2021-08-12 00:31:00 -04:00
|
|
|
|
2021-08-25 17:20:33 -04:00
|
|
|
std::unordered_map<uint8_t, std::queue<StatusPtr>> queued_statuses_; //!< outbound status queue
|
2021-08-12 00:31:00 -04:00
|
|
|
void enqueueStatus(StatusPtr status);
|
|
|
|
|
2021-08-11 10:28:03 -04:00
|
|
|
bool actionPrep_(const MsgPtr message, MsgPtr response);
|
|
|
|
|
|
|
|
void actionGetSupportedParameters (const MsgPtr message, MsgPtr response);
|
2021-08-12 00:31:00 -04:00
|
|
|
void actionSetClearStatusId (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetSubdeviceThreshold (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionSetSubdeviceThreshold (const MsgPtr message, MsgPtr response);
|
2021-08-11 10:28:03 -04:00
|
|
|
void actionGetDeviceInfo (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetProductDetailIdList (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetDevModelDescription (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetManufacturerLabel (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetLanguage (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionSetLanguage (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetSoftwareVersionLabel(const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetDmxPersonality (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionSetDmxPersonality (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetDmxPersonalityDesc (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetDmxStartAddress (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionSetDmxStartAddress (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionSensorDispatch (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionGetIdentifyDevice (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionSetIdentifyDevice (const MsgPtr message, MsgPtr response);
|
|
|
|
void actionSetResetDevice (const MsgPtr message, MsgPtr response);
|
2021-08-08 17:25:41 -04:00
|
|
|
|
|
|
|
private:
|
2021-08-09 15:04:49 -04:00
|
|
|
Device* parent_;
|
|
|
|
PID last_rx_pid_ = 0;
|
2021-09-11 13:54:32 -04:00
|
|
|
unsigned int ack_overflow_page = 0;
|
2021-08-12 00:31:00 -04:00
|
|
|
uint8_t status_reporting_threshold_;
|
2021-08-09 15:04:49 -04:00
|
|
|
bool identifying_ = false;
|
2021-08-08 17:25:41 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace RDM
|
|
|
|
|