Merge pull request 'Enhanced Controller Base' (#276) from KSat/fsfw:mueller/enhanced-controller into development
Reviewed-on: fsfw/fsfw#276
This commit is contained in:
commit
3c316218f7
@ -15,6 +15,11 @@ a C file without issues
|
|||||||
- The same is possible for the event reporting service (PUS5)
|
- The same is possible for the event reporting service (PUS5)
|
||||||
- PUS Health Service added, which allows to command and retrieve health via PUS packets
|
- PUS Health Service added, which allows to command and retrieve health via PUS packets
|
||||||
|
|
||||||
|
|
||||||
|
### EnhancedControllerBase
|
||||||
|
|
||||||
|
- New base class for a controller which also implements HasActionsIF and HasLocalDataPoolIF
|
||||||
|
|
||||||
### Local Pool
|
### Local Pool
|
||||||
|
|
||||||
- Interface of LocalPools has changed. LocalPool is not a template anymore. Instead the size and bucket number of the pools per page and the number of pages are passed to the ctor instead of two ctor arguments and a template parameter
|
- Interface of LocalPools has changed. LocalPool is not a template anymore. Instead the size and bucket number of the pools per page and the number of pages are passed to the ctor instead of two ctor arguments and a template parameter
|
||||||
|
114
controller/ExtendedControllerBase.cpp
Normal file
114
controller/ExtendedControllerBase.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
#include "ExtendedControllerBase.h"
|
||||||
|
|
||||||
|
|
||||||
|
ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId,
|
||||||
|
object_id_t parentId, size_t commandQueueDepth):
|
||||||
|
ControllerBase(objectId, parentId, commandQueueDepth),
|
||||||
|
localPoolManager(this, commandQueue),
|
||||||
|
actionHelper(this, commandQueue) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t ExtendedControllerBase::executeAction(ActionId_t actionId,
|
||||||
|
MessageQueueId_t commandedBy, const uint8_t *data, size_t size) {
|
||||||
|
// needs to be overriden and implemented by child class.
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ReturnValue_t ExtendedControllerBase::initializeLocalDataPool(
|
||||||
|
LocalDataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
|
||||||
|
// needs to be overriden and implemented by child class.
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
object_id_t ExtendedControllerBase::getObjectId() const {
|
||||||
|
return SystemObject::getObjectId();
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalDataPoolManager* ExtendedControllerBase::getHkManagerHandle() {
|
||||||
|
return &localPoolManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t ExtendedControllerBase::getPeriodicOperationFrequency() const {
|
||||||
|
return this->executingTask->getPeriodMs();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t ExtendedControllerBase::handleCommandMessage(
|
||||||
|
CommandMessage *message) {
|
||||||
|
ReturnValue_t result = actionHelper.handleActionMessage(message);
|
||||||
|
if(result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return localPoolManager.handleHousekeepingMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ExtendedControllerBase::handleQueue() {
|
||||||
|
CommandMessage command;
|
||||||
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
|
for (result = commandQueue->receiveMessage(&command);
|
||||||
|
result == RETURN_OK;
|
||||||
|
result = commandQueue->receiveMessage(&command)) {
|
||||||
|
result = actionHelper.handleActionMessage(&command);
|
||||||
|
if (result == RETURN_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = modeHelper.handleModeCommand(&command);
|
||||||
|
if (result == RETURN_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
|
if (result == RETURN_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = localPoolManager.handleHousekeepingMessage(&command);
|
||||||
|
if (result == RETURN_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = handleCommandMessage(&command);
|
||||||
|
if (result == RETURN_OK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
command.setToUnknownCommand();
|
||||||
|
commandQueue->reply(&command);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t ExtendedControllerBase::initialize() {
|
||||||
|
ReturnValue_t result = ControllerBase::initialize();
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = actionHelper.initialize(commandQueue);
|
||||||
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return localPoolManager.initialize(commandQueue);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t ExtendedControllerBase::initializeAfterTaskCreation() {
|
||||||
|
return localPoolManager.initializeAfterTaskCreation();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) {
|
||||||
|
handleQueue();
|
||||||
|
hkSwitcher.performOperation();
|
||||||
|
localPoolManager.performHkOperation();
|
||||||
|
performControlOperation();
|
||||||
|
return RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageQueueId_t ExtendedControllerBase::getCommandQueue() const {
|
||||||
|
return commandQueue->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) {
|
||||||
|
sif::warning << "ExtendedControllerBase::getDataSetHandle: No child "
|
||||||
|
<< " implementation provided, returning nullptr!" << std::endl;
|
||||||
|
return nullptr;
|
||||||
|
}
|
72
controller/ExtendedControllerBase.h
Normal file
72
controller/ExtendedControllerBase.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#ifndef FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_
|
||||||
|
#define FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_
|
||||||
|
|
||||||
|
#include "ControllerBase.h"
|
||||||
|
|
||||||
|
#include "../action/HasActionsIF.h"
|
||||||
|
#include "../datapoollocal/HasLocalDataPoolIF.h"
|
||||||
|
#include "../action/ActionHelper.h"
|
||||||
|
#include "../datapoollocal/LocalDataPoolManager.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Extendes the basic ControllerBase with the common components
|
||||||
|
* HasActionsIF for commandability and HasLocalDataPoolIF to keep
|
||||||
|
* a pool of local data pool variables.
|
||||||
|
* @details
|
||||||
|
* Default implementations required for the interfaces will be empty and have
|
||||||
|
* to be implemented by child class.
|
||||||
|
*/
|
||||||
|
class ExtendedControllerBase: public ControllerBase,
|
||||||
|
public HasActionsIF,
|
||||||
|
public HasLocalDataPoolIF {
|
||||||
|
public:
|
||||||
|
ExtendedControllerBase(object_id_t objectId, object_id_t parentId,
|
||||||
|
size_t commandQueueDepth = 3);
|
||||||
|
|
||||||
|
/** SystemObjectIF overrides */
|
||||||
|
virtual ReturnValue_t initialize() override;
|
||||||
|
|
||||||
|
virtual MessageQueueId_t getCommandQueue() const override;
|
||||||
|
|
||||||
|
/** ExecutableObjectIF overrides */
|
||||||
|
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||||
|
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LocalDataPoolManager localPoolManager;
|
||||||
|
ActionHelper actionHelper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implemented by child class. Handle all command messages which are
|
||||||
|
* not health, mode, action or housekeeping messages.
|
||||||
|
* @param message
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t handleCommandMessage(CommandMessage *message) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Periodic helper from ControllerBase, implemented by child class.
|
||||||
|
*/
|
||||||
|
virtual void performControlOperation() = 0;
|
||||||
|
|
||||||
|
/** Handle the four messages mentioned above */
|
||||||
|
void handleQueue() override;
|
||||||
|
|
||||||
|
/** HasActionsIF overrides */
|
||||||
|
virtual ReturnValue_t executeAction(ActionId_t actionId,
|
||||||
|
MessageQueueId_t commandedBy, const uint8_t* data,
|
||||||
|
size_t size) override;
|
||||||
|
|
||||||
|
/** HasLocalDatapoolIF overrides */
|
||||||
|
virtual object_id_t getObjectId() const override;
|
||||||
|
virtual ReturnValue_t initializeLocalDataPool(
|
||||||
|
LocalDataPool& localDataPoolMap,
|
||||||
|
LocalDataPoolManager& poolManager) override;
|
||||||
|
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
||||||
|
virtual uint32_t getPeriodicOperationFrequency() const override;
|
||||||
|
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* FSFW_CONTROLLER_EXTENDEDCONTROLLERBASE_H_ */
|
Loading…
Reference in New Issue
Block a user