changed action handling slightly

This commit is contained in:
Ulrich Mohr 2022-07-20 16:59:42 +02:00
parent ef18377cef
commit f56646d2c3
8 changed files with 13 additions and 10 deletions

View File

@ -24,6 +24,8 @@ class Action: public SerializeIF {
#endif
ActionId_t getId();
MessageQueueId_t commandedBy;
virtual ReturnValue_t handle() = 0;
void registerParameter(ParameterIF *parameter);
@ -40,6 +42,7 @@ class Action: public SerializeIF {
private:
ActionId_t id;
#ifdef FSFW_INTROSPECTION
const char *name;
#endif

View File

@ -73,7 +73,6 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
}
auto actionIter = actionMap.find(actionId);
if (actionIter == actionMap.end()){
puts("end");
CommandMessage reply;
ActionMessage::setStepReply(&reply, actionId, 0, HasActionsIF::INVALID_ACTION_ID);
queueToUse->sendMessage(commandedBy, &reply);
@ -83,14 +82,15 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
Action* action = actionIter->second;
result = action->deSerialize(&dataPtr, &size, SerializeIF::Endianness::NETWORK);
if ((result != HasReturnvaluesIF::RETURN_OK) || (size != 0)){ //TODO write unittest for second condition
printf("serialze %i, %x\n", size, result);
CommandMessage reply;
ActionMessage::setStepReply(&reply, actionId, 0, HasActionsIF::INVALID_PARAMETERS);
queueToUse->sendMessage(commandedBy, &reply);
ipcStore->deleteData(dataAddress);
return;
}
result = action->handle();
//TODO call action->check()
action->commandedBy = commandedBy;
result = owner->executeAction(action);
ipcStore->deleteData(dataAddress);
if (result == HasActionsIF::EXECUTION_FINISHED) {
CommandMessage reply;

View File

@ -58,7 +58,7 @@ class HasActionsIF {
* -@c EXECUTION_FINISHED Finish reply will be generated
* -@c Not RETURN_OK Step failure reply will be generated
*/
virtual ReturnValue_t executeAction(Action* action, MessageQueueId_t commandedBy) = 0;
virtual ReturnValue_t executeAction(Action* action) = 0;
};
#endif /* FSFW_ACTION_HASACTIONSIF_H_ */

View File

@ -8,7 +8,7 @@ ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t
ExtendedControllerBase::~ExtendedControllerBase() {}
ReturnValue_t ExtendedControllerBase::executeAction(Action *action, MessageQueueId_t commandedBy) {
ReturnValue_t ExtendedControllerBase::executeAction(Action *action) {
/* Needs to be overriden and implemented by child class. */
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -50,7 +50,7 @@ class ExtendedControllerBase : public ControllerBase,
void handleQueue() override;
/* HasActionsIF overrides */
virtual ReturnValue_t executeAction(Action* actionId, MessageQueueId_t commandedBy) override;
virtual ReturnValue_t executeAction(Action* actionId) override;
/* HasLocalDatapoolIF overrides */
virtual LocalDataPoolManager* getHkManagerHandle() override;

View File

@ -1263,7 +1263,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r
}
}
ReturnValue_t DeviceHandlerBase::executeAction(Action *action, MessageQueueId_t commandedBy) {
ReturnValue_t DeviceHandlerBase::executeAction(Action *action) {
ReturnValue_t result = acceptExternalDeviceCommands();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
@ -1277,7 +1277,7 @@ ReturnValue_t DeviceHandlerBase::executeAction(Action *action, MessageQueueId_t
result = action->handle();
}
if (result == RETURN_OK) {
iter->second.sendReplyTo = commandedBy;
iter->second.sendReplyTo = action->commandedBy;
iter->second.isExecuting = true;
cookieInfo.pendingCommand = iter;
cookieInfo.state = COOKIE_WRITE_READY;

View File

@ -202,7 +202,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
virtual void setParentQueue(MessageQueueId_t parentQueueId);
/** @brief Implementation required for HasActionIF */
ReturnValue_t executeAction(Action *action, MessageQueueId_t commandedBy) override;
ReturnValue_t executeAction(Action *action) override;
Mode_t getTransitionSourceMode() const;
Submode_t getTransitionSourceSubMode() const;

View File

@ -37,7 +37,7 @@ class ActionHelperOwnerMockBase : public HasActionsIF {
ActionHelper* getActionHelper() override { return &actionHelper; }
ReturnValue_t executeAction(Action* action, MessageQueueId_t commandedBy) override {
ReturnValue_t executeAction(Action* action) override {
executeActionCalled = true;
if (size > MAX_SIZE) {
return 0xAFFE;