Merge remote-tracking branch 'sidestream/mohr_introspection' into mohr/introspection

This commit is contained in:
Ulrich Mohr 2022-07-28 16:32:24 +02:00
commit cfdbe0f6cb
8 changed files with 30 additions and 16 deletions

View File

@ -24,7 +24,9 @@ class Action: public SerializeIF {
#endif
ActionId_t getId();
virtual ReturnValue_t handle() = 0;
MessageQueueId_t commandedBy;
[[nodiscard]] 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,9 +8,12 @@ ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t
ExtendedControllerBase::~ExtendedControllerBase() {}
ReturnValue_t ExtendedControllerBase::executeAction(Action *action, MessageQueueId_t commandedBy) {
/* Needs to be overriden and implemented by child class. */
return HasReturnvaluesIF::RETURN_OK;
ActionHelper *ExtendedControllerBase::getActionHelper() {
return &actionHelper;
}
ReturnValue_t ExtendedControllerBase::executeAction(Action *action) {
return action->handle();
}
object_id_t ExtendedControllerBase::getObjectId() const { return SystemObject::getObjectId(); }

View File

@ -29,6 +29,10 @@ class ExtendedControllerBase : public ControllerBase,
virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual ReturnValue_t initializeAfterTaskCreation() override;
/* HasActionsIF overrides */
ActionHelper* getActionHelper() override;
ReturnValue_t executeAction(Action* actionId) override;
protected:
LocalDataPoolManager poolManager;
ActionHelper actionHelper;
@ -49,9 +53,6 @@ class ExtendedControllerBase : public ControllerBase,
/* Handle the four messages mentioned above */
void handleQueue() override;
/* HasActionsIF overrides */
virtual ReturnValue_t executeAction(Action* actionId, MessageQueueId_t commandedBy) override;
/* HasLocalDatapoolIF overrides */
virtual LocalDataPoolManager* getHkManagerHandle() override;
virtual object_id_t getObjectId() const override;

View File

@ -1316,7 +1316,11 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r
}
}
ReturnValue_t DeviceHandlerBase::executeAction(Action *action, MessageQueueId_t commandedBy) {
ActionHelper *DeviceHandlerBase::getActionHelper() {
return &actionHelper;
}
ReturnValue_t DeviceHandlerBase::executeAction(Action *action) {
ReturnValue_t result = acceptExternalDeviceCommands();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
@ -1330,7 +1334,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

@ -204,8 +204,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
*/
virtual void setParentQueue(MessageQueueId_t parentQueueId);
/** @brief Implementation required for HasActionIF */
ReturnValue_t executeAction(Action *action, MessageQueueId_t commandedBy) override;
/** @brief Implementations required for HasActionIF */
ActionHelper* getActionHelper() override;
ReturnValue_t executeAction(Action *action) override;
Mode_t getTransitionSourceMode() const;
Submode_t getTransitionSourceSubMode() const;
@ -313,6 +314,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
* - Anything else triggers an even with the returnvalue as a parameter
*/
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t *id) = 0;
//TODO Remove and update documentation
/**
* @brief Build a device command packet from data supplied by a direct
* command (PUS Service 8)

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;