refactor dmp header component names
This commit is contained in:
parent
54df9ae8f6
commit
6a9247ccea
|
@ -77,7 +77,7 @@ size_t range::streamSize() const
|
|||
return 3;
|
||||
}
|
||||
};
|
||||
return count() * address_width(length_);
|
||||
return count() * element_length(length_);
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,7 +131,7 @@ void address_pair_list::iStream(PDU::Stream stream)
|
|||
{
|
||||
while(stream->good()) {
|
||||
// Property Address
|
||||
range pr(type_->type, type_->width);
|
||||
range pr(type_->data_type, type_->address_length);
|
||||
pr.iStream(stream);
|
||||
|
||||
if (!stream->good() || pr.count * pr.incriment > stream->available()) {
|
||||
|
@ -149,8 +149,8 @@ void address_pair_list::iStream(PDU::Stream stream)
|
|||
properties.push_back(address_data_pair(pr, pd));
|
||||
|
||||
//set EOF if buffer insufficient for another property range
|
||||
if (stream->available() < address_width(type_->width) *
|
||||
(type_->type == SINGLE? 1 : 3))
|
||||
if (stream->available() < element_size(type_->address_length) *
|
||||
(type_->data_type == SINGLE? 1 : 3))
|
||||
stream->setstate(std::ios_base::eofbit);
|
||||
}
|
||||
}
|
||||
|
@ -193,12 +193,12 @@ void address_list::iStream(PDU::Stream stream)
|
|||
while(stream->good())
|
||||
{
|
||||
// Property Address
|
||||
addresses.emplace_back(range(type_->type, type_->width));
|
||||
addresses.emplace_back(range(type_->data_type, type_->address_length));
|
||||
*stream >> addresses.back();
|
||||
|
||||
//set EOF if buffer insufficient for another property range
|
||||
if (stream->available() < address_width(type_->width) *
|
||||
(type_->type == SINGLE? 1 : 3))
|
||||
if (stream->available() < element_size(type_->address_length) *
|
||||
(type_->data_type == SINGLE? 1 : 3))
|
||||
stream->setstate(std::ios_base::eofbit);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,9 +32,13 @@
|
|||
namespace ACN::DMP {
|
||||
|
||||
/**
|
||||
* @brief 5.1.4 Address and Data Types
|
||||
* @brief The data_type_t enum
|
||||
*
|
||||
* @cite DMP 5.1.4 Address and Data Types
|
||||
* D1, D0 = Specify non-range or range address, single data, equal size or
|
||||
* mixed size data array
|
||||
*/
|
||||
enum data_type {
|
||||
enum data_type_t {
|
||||
SINGLE = 0b00, //!< Non-range address, Single data item
|
||||
RANGE = 0b01, //!< Range address, Single data item
|
||||
ARRAY = 0b10, //!< Range address, Array of equal size data items
|
||||
|
@ -43,9 +47,9 @@ enum data_type {
|
|||
|
||||
|
||||
/**
|
||||
* @brief The address_length enum
|
||||
* @brief The address_element_length enum
|
||||
*/
|
||||
enum address_length {
|
||||
enum element_length {
|
||||
ONE = 0b00, // 0
|
||||
TWO = 0b01, // 1
|
||||
FOUR = 0b10, // 2
|
||||
|
@ -58,13 +62,13 @@ enum address_length {
|
|||
* @param l
|
||||
* @return
|
||||
*/
|
||||
inline unsigned int address_width(const address_length& l)
|
||||
inline unsigned int element_size(const element_length& l)
|
||||
{
|
||||
switch (l) {
|
||||
case ZERO: return 0;
|
||||
case ONE: return 1;
|
||||
case TWO: return 2;
|
||||
case FOUR: return 4;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,11 +82,11 @@ struct address_type
|
|||
union {
|
||||
uint8_t byte = 0;
|
||||
struct __attribute__((packed)) {
|
||||
address_length width : 2; // A1, A0
|
||||
uint8_t x_reserved : 2; // X1, X0
|
||||
data_type type : 2; // D1, D0
|
||||
bool relative : 1; // R
|
||||
bool z_reserved : 1; // Z
|
||||
element_length address_length : 2; //!< A1, A0 = Size of Address elements
|
||||
uint8_t x_reserved : 2; //!< X1, X0
|
||||
data_type_t data_type : 2; //!< D1, D0
|
||||
bool relative : 1; //!< R = Specifies whether address is relative or not.
|
||||
bool z_reserved : 1; //!< Z
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -104,7 +108,7 @@ struct range
|
|||
* @param t
|
||||
* @param l
|
||||
*/
|
||||
range(const data_type t, const address_length l)
|
||||
range(const data_type_t t, const element_length l)
|
||||
: type_(t)
|
||||
, length_(l)
|
||||
{};
|
||||
|
@ -117,8 +121,8 @@ struct range
|
|||
void oStream(PDU::Stream) const override;
|
||||
|
||||
private:
|
||||
const data_type type_;
|
||||
const address_length length_;
|
||||
const data_type_t type_;
|
||||
const element_length length_;
|
||||
uint32_t read_(PDU::Stream);
|
||||
void write_(PDU::Stream, const uint32_t&) const;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue