2020-08-13 20:53:35 +02:00
|
|
|
#include "ActionMessage.h"
|
2021-01-18 19:49:15 +01:00
|
|
|
#include "HasActionsIF.h"
|
|
|
|
|
2021-06-05 19:52:38 +02:00
|
|
|
#include "../objectmanager/ObjectManager.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../storagemanager/StorageManagerIF.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
ActionMessage::ActionMessage() {
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionMessage::~ActionMessage() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionMessage::setCommand(CommandMessage* message, ActionId_t fid,
|
2021-01-28 11:50:33 +01:00
|
|
|
store_address_t parameters) {
|
|
|
|
message->setCommand(EXECUTE_ACTION);
|
|
|
|
message->setParameter(fid);
|
|
|
|
message->setParameter2(parameters.raw);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ActionId_t ActionMessage::getActionId(const CommandMessage* message) {
|
2021-01-28 11:50:33 +01:00
|
|
|
return ActionId_t(message->getParameter());
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
store_address_t ActionMessage::getStoreId(const CommandMessage* message) {
|
2021-01-28 11:50:33 +01:00
|
|
|
store_address_t temp;
|
|
|
|
temp.raw = message->getParameter2();
|
|
|
|
return temp;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionMessage::setStepReply(CommandMessage* message, ActionId_t fid, uint8_t step,
|
2021-01-28 11:50:33 +01:00
|
|
|
ReturnValue_t result) {
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
message->setCommand(STEP_SUCCESS);
|
|
|
|
} else {
|
|
|
|
message->setCommand(STEP_FAILED);
|
|
|
|
}
|
|
|
|
message->setParameter(fid);
|
|
|
|
message->setParameter2((step << 16) + result);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t ActionMessage::getStep(const CommandMessage* message) {
|
2021-01-28 11:50:33 +01:00
|
|
|
return uint8_t((message->getParameter2() >> 16) & 0xFF);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t ActionMessage::getReturnCode(const CommandMessage* message) {
|
2021-01-28 11:50:33 +01:00
|
|
|
return message->getParameter2() & 0xFFFF;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionMessage::setDataReply(CommandMessage* message, ActionId_t actionId,
|
2021-01-28 11:50:33 +01:00
|
|
|
store_address_t data) {
|
|
|
|
message->setCommand(DATA_REPLY);
|
|
|
|
message->setParameter(actionId);
|
|
|
|
message->setParameter2(data.raw);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 09:51:08 +01:00
|
|
|
void ActionMessage::setCompletionReply(CommandMessage* message,
|
|
|
|
ActionId_t fid, bool success, ReturnValue_t result) {
|
2021-03-03 15:13:03 +01:00
|
|
|
if (success) {
|
2021-01-28 11:50:33 +01:00
|
|
|
message->setCommand(COMPLETION_SUCCESS);
|
2021-03-03 15:13:03 +01:00
|
|
|
}
|
|
|
|
else {
|
2021-01-28 11:50:33 +01:00
|
|
|
message->setCommand(COMPLETION_FAILED);
|
|
|
|
}
|
|
|
|
message->setParameter(fid);
|
|
|
|
message->setParameter2(result);
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ActionMessage::clear(CommandMessage* message) {
|
2021-01-28 11:50:33 +01:00
|
|
|
switch(message->getCommand()) {
|
|
|
|
case EXECUTE_ACTION:
|
|
|
|
case DATA_REPLY: {
|
2021-06-05 19:52:38 +02:00
|
|
|
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
2021-01-28 11:50:33 +01:00
|
|
|
objects::IPC_STORE);
|
|
|
|
if (ipcStore != NULL) {
|
|
|
|
ipcStore->deleteData(getStoreId(message));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|