Merge branch 'development' into mueller/tcpip-updates
This commit is contained in:
commit
5271375063
@ -96,15 +96,22 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer
|
|||||||
SerializeIF::Endianness streamEndianness) const {
|
SerializeIF::Endianness streamEndianness) const {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
const uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
const uint8_t validityMaskSize = std::ceil(static_cast<float>(fillCount)/8.0);
|
||||||
|
uint8_t* validityPtr = nullptr;
|
||||||
|
#ifdef _MSC_VER
|
||||||
/* Use a std::vector here because MSVC will (rightly) not create a fixed size array
|
/* Use a std::vector here because MSVC will (rightly) not create a fixed size array
|
||||||
with a non constant size specifier */
|
with a non constant size specifier */
|
||||||
std::vector<uint8_t> validityMask(validityMaskSize);
|
std::vector<uint8_t> validityMask(validityMaskSize);
|
||||||
|
validityPtr = validityMask.data();
|
||||||
|
#else
|
||||||
|
uint8_t validityMask[validityMaskSize];
|
||||||
|
validityPtr = validityMask;
|
||||||
|
#endif
|
||||||
uint8_t validBufferIndex = 0;
|
uint8_t validBufferIndex = 0;
|
||||||
uint8_t validBufferIndexBit = 0;
|
uint8_t validBufferIndexBit = 0;
|
||||||
for (uint16_t count = 0; count < fillCount; count++) {
|
for (uint16_t count = 0; count < fillCount; count++) {
|
||||||
if(registeredVariables[count]->isValid()) {
|
if(registeredVariables[count]->isValid()) {
|
||||||
/* Set bit at correct position */
|
/* Set bit at correct position */
|
||||||
bitutil::bitSet(validityMask.data() + validBufferIndex, validBufferIndexBit);
|
bitutil::bitSet(validityMask + validBufferIndex, validBufferIndexBit);
|
||||||
}
|
}
|
||||||
if(validBufferIndexBit == 7) {
|
if(validBufferIndexBit == 7) {
|
||||||
validBufferIndex ++;
|
validBufferIndex ++;
|
||||||
@ -125,7 +132,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeWithValidityBuffer(uint8_t **buffer
|
|||||||
return SerializeIF::BUFFER_TOO_SHORT;
|
return SerializeIF::BUFFER_TOO_SHORT;
|
||||||
}
|
}
|
||||||
// copy validity buffer to end
|
// copy validity buffer to end
|
||||||
std::memcpy(*buffer, validityMask.data(), validityMaskSize);
|
std::memcpy(*buffer, validityPtr, validityMaskSize);
|
||||||
*size += validityMaskSize;
|
*size += validityMaskSize;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -9,23 +9,23 @@ PowerComponent::PowerComponent(): switchId1(0xFF), switchId2(0xFF),
|
|||||||
PowerComponent::PowerComponent(object_id_t setId, uint8_t moduleId, float min,
|
PowerComponent::PowerComponent(object_id_t setId, uint8_t moduleId, float min,
|
||||||
float max, uint8_t switchId1, bool twoSwitches, uint8_t switchId2) :
|
float max, uint8_t switchId1, bool twoSwitches, uint8_t switchId2) :
|
||||||
deviceObjectId(setId), switchId1(switchId1), switchId2(switchId2),
|
deviceObjectId(setId), switchId1(switchId1), switchId2(switchId2),
|
||||||
doIHaveTwoSwitches(twoSwitches), minVoltage(min), maxVoltage(max),
|
doIHaveTwoSwitches(twoSwitches), minPower(min), maxPower(max),
|
||||||
moduleId(moduleId) {
|
moduleId(moduleId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PowerComponent::serialize(uint8_t** buffer, size_t* size,
|
ReturnValue_t PowerComponent::serialize(uint8_t** buffer, size_t* size,
|
||||||
size_t maxSize, Endianness streamEndianness) const {
|
size_t maxSize, Endianness streamEndianness) const {
|
||||||
ReturnValue_t result = SerializeAdapter::serialize(&minVoltage, buffer,
|
ReturnValue_t result = SerializeAdapter::serialize(&minPower, buffer,
|
||||||
size, maxSize, streamEndianness);
|
size, maxSize, streamEndianness);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return SerializeAdapter::serialize(&maxVoltage, buffer, size, maxSize,
|
return SerializeAdapter::serialize(&maxPower, buffer, size, maxSize,
|
||||||
streamEndianness);
|
streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t PowerComponent::getSerializedSize() const {
|
size_t PowerComponent::getSerializedSize() const {
|
||||||
return sizeof(minVoltage) + sizeof(maxVoltage);
|
return sizeof(minPower) + sizeof(maxPower);
|
||||||
}
|
}
|
||||||
|
|
||||||
object_id_t PowerComponent::getDeviceObjectId() {
|
object_id_t PowerComponent::getDeviceObjectId() {
|
||||||
@ -45,21 +45,21 @@ bool PowerComponent::hasTwoSwitches() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float PowerComponent::getMin() {
|
float PowerComponent::getMin() {
|
||||||
return minVoltage;
|
return minPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PowerComponent::getMax() {
|
float PowerComponent::getMax() {
|
||||||
return maxVoltage;
|
return maxPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t PowerComponent::deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) {
|
||||||
ReturnValue_t result = SerializeAdapter::deSerialize(&minVoltage, buffer,
|
ReturnValue_t result = SerializeAdapter::deSerialize(&minPower, buffer,
|
||||||
size, streamEndianness);
|
size, streamEndianness);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return SerializeAdapter::deSerialize(&maxVoltage, buffer, size, streamEndianness);
|
return SerializeAdapter::deSerialize(&maxPower, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PowerComponent::getParameter(uint8_t domainId, uint8_t uniqueId,
|
ReturnValue_t PowerComponent::getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||||
@ -70,10 +70,10 @@ ReturnValue_t PowerComponent::getParameter(uint8_t domainId, uint8_t uniqueId,
|
|||||||
}
|
}
|
||||||
switch (uniqueId) {
|
switch (uniqueId) {
|
||||||
case 0:
|
case 0:
|
||||||
parameterWrapper->set<>(minVoltage);
|
parameterWrapper->set<>(minPower);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
parameterWrapper->set<>(maxVoltage);
|
parameterWrapper->set<>(maxPower);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return INVALID_IDENTIFIER_ID;
|
return INVALID_IDENTIFIER_ID;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
class PowerComponent: public PowerComponentIF {
|
class PowerComponent: public PowerComponentIF {
|
||||||
public:
|
public:
|
||||||
PowerComponent(object_id_t setId, uint8_t moduleId, float minVoltage, float maxVoltage,
|
PowerComponent(object_id_t setId, uint8_t moduleId, float minPower, float maxPower,
|
||||||
uint8_t switchId1, bool twoSwitches = false,
|
uint8_t switchId1, bool twoSwitches = false,
|
||||||
uint8_t switchId2 = 0xFF);
|
uint8_t switchId2 = 0xFF);
|
||||||
|
|
||||||
@ -41,8 +41,8 @@ private:
|
|||||||
|
|
||||||
const bool doIHaveTwoSwitches;
|
const bool doIHaveTwoSwitches;
|
||||||
|
|
||||||
float minVoltage = 0.0;
|
float minPower = 0.0;
|
||||||
float maxVoltage = 0.0;
|
float maxPower = 0.0;
|
||||||
|
|
||||||
uint8_t moduleId = 0;
|
uint8_t moduleId = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user