range element width has only one user
This commit is contained in:
parent
b356d052b3
commit
535cc66cd1
|
@ -72,7 +72,7 @@ void range::write_(PDU::Stream stream, const uint32_t& val) const
|
|||
|
||||
size_t range::streamSize() const
|
||||
{
|
||||
auto count = [this] () {
|
||||
auto count = [&] () {
|
||||
switch (type_.data_type) {
|
||||
case SINGLE:
|
||||
return 1;
|
||||
|
@ -80,7 +80,17 @@ size_t range::streamSize() const
|
|||
return 3;
|
||||
}
|
||||
};
|
||||
return count() * element_length(type_.address_length);
|
||||
|
||||
auto width = [&] () {
|
||||
switch (type_.address_length) {
|
||||
case ZERO: return 0;
|
||||
case ONE: return 1;
|
||||
case TWO: return 2;
|
||||
case FOUR: return 4;
|
||||
}
|
||||
};
|
||||
|
||||
return count() * width();
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,7 +101,8 @@ size_t range::streamSize() const
|
|||
void range::iStream(PDU::Stream stream)
|
||||
{
|
||||
address = read_(stream);
|
||||
if (type_.data_type == SINGLE) return;
|
||||
if (type_.data_type == SINGLE)
|
||||
return;
|
||||
incriment = read_(stream);
|
||||
count = read_(stream);
|
||||
}
|
||||
|
@ -104,7 +115,8 @@ void range::iStream(PDU::Stream stream)
|
|||
void range::oStream(PDU::Stream stream) const
|
||||
{
|
||||
write_(stream, address);
|
||||
if (type_.data_type == SINGLE) return;
|
||||
if (type_.data_type == SINGLE)
|
||||
return;
|
||||
write_(stream, incriment);
|
||||
write_(stream, count);
|
||||
}
|
||||
|
|
|
@ -57,22 +57,6 @@ enum element_length {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief address_width
|
||||
* @param l
|
||||
* @return
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief The address_type struct
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue