2020-10-12 15:40:27 +02:00
|
|
|
#include "ExtendedControllerBase.h"
|
|
|
|
|
|
|
|
|
|
|
|
ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId,
|
|
|
|
object_id_t parentId, size_t commandQueueDepth):
|
|
|
|
ControllerBase(objectId, parentId, commandQueueDepth),
|
2021-01-12 21:01:55 +01:00
|
|
|
poolManager(this, commandQueue),
|
2020-10-12 15:40:27 +02:00
|
|
|
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(
|
2021-01-12 19:58:29 +01:00
|
|
|
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
|
2020-10-12 15:40:27 +02:00
|
|
|
// needs to be overriden and implemented by child class.
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
object_id_t ExtendedControllerBase::getObjectId() const {
|
|
|
|
return SystemObject::getObjectId();
|
|
|
|
}
|
|
|
|
|
2021-01-12 14:08:51 +01:00
|
|
|
AccessPoolManagerIF* ExtendedControllerBase::getAccessorHandle() {
|
2021-01-12 21:01:55 +01:00
|
|
|
return &poolManager;
|
2020-10-12 15:40:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2021-01-12 21:01:55 +01:00
|
|
|
return poolManager.handleHousekeepingMessage(message);
|
2020-10-12 15:40:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-12 21:01:55 +01:00
|
|
|
result = poolManager.handleHousekeepingMessage(&command);
|
2020-10-12 15:40:27 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-01-12 21:01:55 +01:00
|
|
|
return poolManager.initialize(commandQueue);
|
2020-10-12 15:40:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t ExtendedControllerBase::initializeAfterTaskCreation() {
|
2021-01-12 21:01:55 +01:00
|
|
|
return poolManager.initializeAfterTaskCreation();
|
2020-10-12 15:40:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t ExtendedControllerBase::performOperation(uint8_t opCode) {
|
|
|
|
handleQueue();
|
2021-01-12 21:01:55 +01:00
|
|
|
poolManager.performHkOperation();
|
2020-10-12 15:40:27 +02:00
|
|
|
performControlOperation();
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueueId_t ExtendedControllerBase::getCommandQueue() const {
|
|
|
|
return commandQueue->getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) {
|
2021-01-03 14:16:52 +01:00
|
|
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
2020-10-12 15:40:27 +02:00
|
|
|
sif::warning << "ExtendedControllerBase::getDataSetHandle: No child "
|
|
|
|
<< " implementation provided, returning nullptr!" << std::endl;
|
2021-01-03 13:58:18 +01:00
|
|
|
#endif
|
2020-10-12 15:40:27 +02:00
|
|
|
return nullptr;
|
|
|
|
}
|
2021-01-11 21:31:03 +01:00
|
|
|
|
2021-01-11 22:25:39 +01:00
|
|
|
ProvidesDataPoolSubscriptionIF* ExtendedControllerBase::getSubscriptionInterface() {
|
2021-01-12 21:01:55 +01:00
|
|
|
return &poolManager;
|
2021-01-11 21:31:03 +01:00
|
|
|
}
|