fsfw/src/fsfw/action/HasActionsIF.h

66 lines
2.5 KiB
C
Raw Normal View History

2020-10-29 13:55:49 +01:00
#ifndef FSFW_ACTION_HASACTIONSIF_H_
#define FSFW_ACTION_HASACTIONSIF_H_
2020-08-13 20:53:35 +02:00
#include "ActionHelper.h"
#include "ActionMessage.h"
#include "SimpleActionHelper.h"
2022-07-04 11:44:26 +02:00
#include "fsfw/ipc/MessageQueueIF.h"
2022-08-16 12:48:22 +02:00
#include "fsfw/returnvalues/returnvalue.h"
2020-10-29 13:55:49 +01:00
2018-07-13 18:28:26 +02:00
/**
* @brief
* Interface for component which uses actions
2018-07-13 18:28:26 +02:00
*
* @details
* This interface is used to execute actions in the component. Actions, in the
* sense of this interface, are activities with a well-defined beginning and
* end in time. They may adjust sub-states of components, but are not supposed
* to change the main mode of operation, which is handled with the HasModesIF
* described below.
2018-07-13 18:28:26 +02:00
*
* The HasActionsIF allows components to define such actions and make them
* available for other components to use. Implementing the interface is
* straightforward: Theres a single executeAction call, which provides an
* identifier for the action to execute, as well as arbitrary parameters for
* input.
* Aside from direct, software-based actions, it is used in device handler
* components as an interface to forward commands to devices.
* Implementing components of the interface are supposed to check identifier
* (ID) and parameters and immediately start execution of the action.
* It is, however, not required to immediately finish execution.
* Instead, this may be deferred to a later point in time, at which the
* component needs to inform the caller about finished or failed execution.
*
* @ingroup interfaces
2018-07-13 18:28:26 +02:00
*/
class HasActionsIF {
2022-02-02 10:29:30 +01:00
public:
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_ACTIONS_IF;
static const ReturnValue_t IS_BUSY = MAKE_RETURN_CODE(1);
static const ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2);
static const ReturnValue_t EXECUTION_FINISHED = MAKE_RETURN_CODE(3);
static const ReturnValue_t INVALID_ACTION_ID = MAKE_RETURN_CODE(4);
2022-07-04 11:44:26 +02:00
virtual ~HasActionsIF() = default;
2022-02-02 10:29:30 +01:00
/**
* Function to get the MessageQueueId_t of the implementing object
* @return MessageQueueId_t of the object
2022-06-29 23:36:45 +02:00
*
2022-02-02 10:29:30 +01:00
*/
2022-07-04 11:44:26 +02:00
[[nodiscard]] virtual MessageQueueId_t getCommandQueue() const = 0;
[[nodiscard]] virtual ActionHelper* getActionHelper() = 0;
2022-06-29 23:36:45 +02:00
2022-02-02 10:29:30 +01:00
/**
* Execute or initialize the execution of a certain function.
* The ActionHelpers will execute this function and behave differently
* depending on the returnvalue.
*
* @return
* -@c EXECUTION_FINISHED Finish reply will be generated
2022-08-16 12:12:21 +02:00
* -@c Not returnvalue::OK Step failure reply will be generated
2022-02-02 10:29:30 +01:00
*/
2022-07-20 16:59:42 +02:00
virtual ReturnValue_t executeAction(Action* action) = 0;
};
2020-10-29 13:55:49 +01:00
#endif /* FSFW_ACTION_HASACTIONSIF_H_ */