parameter helper update
This commit is contained in:
parent
0304f61bde
commit
7c75c6e8cc
@ -3,7 +3,7 @@
|
|||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
|
|
||||||
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) :
|
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) :
|
||||||
owner(owner) {}
|
owner(owner) {}
|
||||||
|
|
||||||
ParameterHelper::~ParameterHelper() {
|
ParameterHelper::~ParameterHelper() {
|
||||||
}
|
}
|
||||||
@ -14,106 +14,106 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
|
||||||
switch (message->getCommand()) {
|
switch (message->getCommand()) {
|
||||||
case ParameterMessage::CMD_PARAMETER_DUMP: {
|
case ParameterMessage::CMD_PARAMETER_DUMP: {
|
||||||
ParameterWrapper description;
|
ParameterWrapper description;
|
||||||
uint8_t domain = HasParametersIF::getDomain(
|
uint8_t domain = HasParametersIF::getDomain(
|
||||||
ParameterMessage::getParameterId(message));
|
ParameterMessage::getParameterId(message));
|
||||||
uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(
|
uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(
|
||||||
ParameterMessage::getParameterId(message));
|
ParameterMessage::getParameterId(message));
|
||||||
result = owner->getParameter(domain, uniqueIdentifier,
|
result = owner->getParameter(domain, uniqueIdentifier,
|
||||||
&description, &description, 0);
|
&description, &description, 0);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
result = sendParameter(message->getSender(),
|
result = sendParameter(message->getSender(),
|
||||||
ParameterMessage::getParameterId(message), &description);
|
ParameterMessage::getParameterId(message), &description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ParameterMessage::CMD_PARAMETER_LOAD: {
|
case ParameterMessage::CMD_PARAMETER_LOAD: {
|
||||||
ParameterId_t parameterId = 0;
|
ParameterId_t parameterId = 0;
|
||||||
uint8_t ptc = 0;
|
uint8_t ptc = 0;
|
||||||
uint8_t pfc = 0;
|
uint8_t pfc = 0;
|
||||||
uint8_t rows = 0;
|
uint8_t rows = 0;
|
||||||
uint8_t columns = 0;
|
uint8_t columns = 0;
|
||||||
store_address_t storeId = ParameterMessage::getParameterLoadCommand(
|
store_address_t storeId = ParameterMessage::getParameterLoadCommand(
|
||||||
message, ¶meterId, &ptc, &pfc, &rows, &columns);
|
message, ¶meterId, &ptc, &pfc, &rows, &columns);
|
||||||
Type type(Type::getActualType(ptc, pfc));
|
Type type(Type::getActualType(ptc, pfc));
|
||||||
|
|
||||||
uint8_t domain = HasParametersIF::getDomain(parameterId);
|
uint8_t domain = HasParametersIF::getDomain(parameterId);
|
||||||
uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(
|
uint8_t uniqueIdentifier = HasParametersIF::getUniqueIdentifierId(
|
||||||
parameterId);
|
parameterId);
|
||||||
uint16_t linearIndex = HasParametersIF::getIndex(parameterId);
|
uint16_t linearIndex = HasParametersIF::getIndex(parameterId);
|
||||||
|
|
||||||
ConstStorageAccessor accessor(storeId);
|
ConstStorageAccessor accessor(storeId);
|
||||||
result = storage->getData(storeId, accessor);
|
result = storage->getData(storeId, accessor);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
sif::error << "ParameterHelper::handleParameterMessage: Getting"
|
sif::error << "ParameterHelper::handleParameterMessage: Getting"
|
||||||
<< " store data failed for load command." << std::endl;
|
<< " store data failed for load command." << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterWrapper streamWrapper;
|
ParameterWrapper streamWrapper;
|
||||||
result = streamWrapper.set(type, rows, columns, accessor.data(),
|
result = streamWrapper.set(type, rows, columns, accessor.data(),
|
||||||
accessor.size());
|
accessor.size());
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterWrapper ownerWrapper;
|
ParameterWrapper ownerWrapper;
|
||||||
result = owner->getParameter(domain, uniqueIdentifier, &ownerWrapper,
|
result = owner->getParameter(domain, uniqueIdentifier, &ownerWrapper,
|
||||||
&streamWrapper, linearIndex);
|
&streamWrapper, linearIndex);
|
||||||
|
|
||||||
result = ownerWrapper.copyFrom(&streamWrapper, linearIndex);
|
result = ownerWrapper.copyFrom(&streamWrapper, linearIndex);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = sendParameter(message->getSender(),
|
result = sendParameter(message->getSender(),
|
||||||
ParameterMessage::getParameterId(message), &ownerWrapper);
|
ParameterMessage::getParameterId(message), &ownerWrapper);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
rejectCommand(message->getSender(), result, message->getCommand());
|
rejectCommand(message->getSender(), result, message->getCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
|
ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
|
||||||
const ParameterWrapper* description) {
|
const ParameterWrapper* description) {
|
||||||
size_t serializedSize = description->getSerializedSize();
|
size_t serializedSize = description->getSerializedSize();
|
||||||
|
|
||||||
uint8_t *storeElement;
|
uint8_t *storeElement;
|
||||||
store_address_t address;
|
store_address_t address;
|
||||||
|
|
||||||
ReturnValue_t result = storage->getFreeElement(&address, serializedSize,
|
ReturnValue_t result = storage->getFreeElement(&address, serializedSize,
|
||||||
&storeElement);
|
&storeElement);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t storeElementSize = 0;
|
size_t storeElementSize = 0;
|
||||||
|
|
||||||
result = description->serialize(&storeElement, &storeElementSize,
|
result = description->serialize(&storeElement, &storeElementSize,
|
||||||
serializedSize, SerializeIF::Endianness::BIG);
|
serializedSize, SerializeIF::Endianness::BIG);
|
||||||
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
storage->deleteData(address);
|
storage->deleteData(address);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandMessage reply;
|
CommandMessage reply;
|
||||||
|
|
||||||
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
||||||
|
|
||||||
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
||||||
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t ParameterHelper::initialize() {
|
ReturnValue_t ParameterHelper::initialize() {
|
||||||
@ -127,8 +127,8 @@ ReturnValue_t ParameterHelper::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
||||||
Command_t initialCommand) {
|
Command_t initialCommand) {
|
||||||
CommandMessage reply;
|
CommandMessage reply;
|
||||||
reply.setReplyRejected(reason, initialCommand);
|
reply.setReplyRejected(reason, initialCommand);
|
||||||
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user