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

View File

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

View File

@ -58,7 +58,7 @@ class HasActionsIF {
* -@c EXECUTION_FINISHED Finish reply will be generated * -@c EXECUTION_FINISHED Finish reply will be generated
* -@c Not RETURN_OK Step failure 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_ */ #endif /* FSFW_ACTION_HASACTIONSIF_H_ */

View File

@ -8,7 +8,7 @@ ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t
ExtendedControllerBase::~ExtendedControllerBase() {} 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. */ /* Needs to be overriden and implemented by child class. */
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -50,7 +50,7 @@ class ExtendedControllerBase : public ControllerBase,
void handleQueue() override; void handleQueue() override;
/* HasActionsIF overrides */ /* HasActionsIF overrides */
virtual ReturnValue_t executeAction(Action* actionId, MessageQueueId_t commandedBy) override; virtual ReturnValue_t executeAction(Action* actionId) override;
/* HasLocalDatapoolIF overrides */ /* HasLocalDatapoolIF overrides */
virtual LocalDataPoolManager* getHkManagerHandle() override; 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(); ReturnValue_t result = acceptExternalDeviceCommands();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
@ -1277,7 +1277,7 @@ ReturnValue_t DeviceHandlerBase::executeAction(Action *action, MessageQueueId_t
result = action->handle(); result = action->handle();
} }
if (result == RETURN_OK) { if (result == RETURN_OK) {
iter->second.sendReplyTo = commandedBy; iter->second.sendReplyTo = action->commandedBy;
iter->second.isExecuting = true; iter->second.isExecuting = true;
cookieInfo.pendingCommand = iter; cookieInfo.pendingCommand = iter;
cookieInfo.state = COOKIE_WRITE_READY; cookieInfo.state = COOKIE_WRITE_READY;

View File

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

View File

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