DMP property get/set
This commit is contained in:
parent
8d6a765c3a
commit
f40ac836ce
|
@ -34,4 +34,69 @@ Device::Device()
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Device::~Device
|
||||
*/
|
||||
Device::~Device()
|
||||
{
|
||||
delete properties;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Device::DmpReceiver
|
||||
* @param block
|
||||
*/
|
||||
void Device::dmpReceiver(PDU::Block<DMP::Pdu> block)
|
||||
{
|
||||
/// \cite DMP 5.1.2 Relative Addresses
|
||||
/// Relative addresses are used to specify an address as an offset from the
|
||||
/// most recently used address within the same PDU Block.
|
||||
last_address_used = 0;
|
||||
|
||||
for(const auto& dmp : *block.pdu)
|
||||
{
|
||||
switch (dmp->vector()) {
|
||||
case GET_PROPERTY:
|
||||
dmpGet(dmp);
|
||||
break;
|
||||
case SET_PROPERTY:
|
||||
dmpSet(dmp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Device::getProperty
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
uint32_t Device::getProperty(const unsigned int address) const
|
||||
{
|
||||
if (!properties)
|
||||
return 0;
|
||||
if (properties->size() < address)
|
||||
return 0;
|
||||
return properties->at(address);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Device::setProperty
|
||||
* @param address
|
||||
* @param value
|
||||
*/
|
||||
void Device::setProperty(const unsigned int address, const int value)
|
||||
{
|
||||
if (!properties)
|
||||
return;
|
||||
if (properties->size() < address)
|
||||
return;
|
||||
properties->at(address) = value;
|
||||
}
|
||||
|
||||
} // namespace ACN::DMP
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dmp.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace ACN::DMP {
|
||||
|
||||
/**
|
||||
|
@ -32,6 +37,24 @@ class Device
|
|||
{
|
||||
public:
|
||||
Device();
|
||||
~Device();
|
||||
|
||||
virtual void dmpReceiver(PDU::Block<DMP::Pdu>);
|
||||
|
||||
protected:
|
||||
|
||||
virtual uint32_t getProperty(const unsigned int address) const;
|
||||
virtual void setProperty(const unsigned int address, const int value);
|
||||
|
||||
/// \cite DMP 5.1.1 Property addresses
|
||||
/// Within a component, properties are addressed in a one dimensional
|
||||
/// property array.
|
||||
std::vector<uint32_t> * properties = nullptr;
|
||||
|
||||
/// \cite DMP 5.1.2 Relative Addresses
|
||||
/// Devices shall maintain a record of the last address used
|
||||
uint32_t last_address_used = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ACN::DMP
|
||||
|
|
|
@ -169,9 +169,24 @@ void Universe::synchronize()
|
|||
|
||||
|
||||
/**
|
||||
* @brief Universe::getProperty
|
||||
* @param address
|
||||
* @return
|
||||
*/
|
||||
uint32_t Universe::getProperty(const unsigned int address) const
|
||||
{
|
||||
return DMX::Universe::slot(address);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Universe::setProperty
|
||||
* @param address
|
||||
* @param value
|
||||
*/
|
||||
void Universe::setProperty(const unsigned int address, const int value)
|
||||
{
|
||||
DMX::Universe::setValue(address, value);
|
||||
}
|
||||
|
||||
}; // namespace SACN
|
||||
|
|
|
@ -52,6 +52,10 @@ public:
|
|||
|
||||
virtual void synchronize();
|
||||
|
||||
// DMP::Device override
|
||||
uint32_t getProperty(const unsigned int address) const override;
|
||||
void setProperty(const unsigned int address, const int value) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Provenance> provenance_;
|
||||
std::vector<uint8_t> * sync_data_ = nullptr;
|
||||
|
|
Loading…
Reference in New Issue