init
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
EIVE/eive-obsw/pipeline/pr-v4.0.0-dev There was a failure building this commit

This commit is contained in:
Marius Eggert 2023-06-07 11:33:09 +02:00
parent caa2800a7a
commit 809d25890e
4 changed files with 99 additions and 0 deletions

View File

@ -26,6 +26,7 @@ enum commonObjects : uint32_t {
THERMAL_CONTROLLER = 0x43400001,
ACS_CONTROLLER = 0x43000002,
CORE_CONTROLLER = 0x43000003,
POWER_CONTROLLER = 0x43000004,
GLOBAL_JSON_CFG = 0x43000006,
/* 0x44 ('D') for device handlers */

View File

@ -13,6 +13,7 @@
#include <linux/tcs/Max31865RtdPolling.h>
#include <mission/acs/SusHandler.h>
#include <mission/controller/AcsController.h>
#include <mission/controller/PowerController.h>
#include <mission/genericFactory.h>
#include <mission/payload/ScexDeviceHandler.h>
#include <mission/system/acs/SusAssembly.h>
@ -337,6 +338,11 @@ AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool en
return acsCtrl;
}
PowerController* ObjectFactory::createPowerController(bool enableHkSets) {
auto pwrCtrl = new PowerController(objects::POWER_CONTROLLER, enableHkSets);
return pwrCtrl;
}
void ObjectFactory::gpioChecker(ReturnValue_t result, std::string output) {
if (result != returnvalue::OK) {
sif::error << "ObjectFactory: Adding GPIOs failed for " << output << std::endl;

View File

@ -0,0 +1,54 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/controller/PowerController.h>
PowerController::PowerController(object_id_t objectId, bool enableHkSets)
: ExtendedControllerBase(objectId), enableHkSets(enableHkSets) {}
ReturnValue_t PowerController::initialize() {
ReturnValue_t result = parameterHelper.initialize();
if (result != returnvalue::OK) {
return result;
}
return ExtendedControllerBase::initialize();
}
ReturnValue_t PowerController::handleCommandMessage(CommandMessage *message) {
ReturnValue_t result = actionHelper.handleActionMessage(message);
if (result == returnvalue::OK) {
return result;
}
result = parameterHelper.handleParameterMessage(message);
if (result == returnvalue::OK) {
return result;
}
return result;
}
void PowerController::performControlOperation() {
switch (internalState) {
case InternalState::STARTUP: {
initialCountdown.resetTimer();
internalState = InternalState::INITIAL_DELAY;
return;
}
case InternalState::INITIAL_DELAY: {
if (initialCountdown.hasTimedOut()) {
internalState = InternalState::READY;
}
return;
}
case InternalState::READY: {
if (mode != MODE_OFF) {
// do something
}
break;
}
default:
break;
}
}
ReturnValue_t PowerController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
return returnvalue::OK;
}

View File

@ -0,0 +1,38 @@
#ifndef MISSION_CONTROLLER_POWERCONTROLLER_H_
#define MISSION_CONTROLLER_POWERCONTROLLER_H_
#include <eive/objects.h>
#include <fsfw/controller/ExtendedControllerBase.h>
#include <fsfw/parameters/ParameterHelper.h>
#include <fsfw/parameters/ReceivesParameterMessagesIF.h>
class PowerController : public ExtendedControllerBase, public ReceivesParameterMessagesIF {
public:
static constexpr dur_millis_t INIT_DELAY = 500;
PowerController(object_id_t objectId, bool enableHkSets);
MessageQueueId_t getCommandQueue() const;
ReturnValue_t getParameter(uint8_t domainId, uint8_t parameterId,
ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues,
uint16_t startAtIndex) override;
private:
bool enableHkSets = false;
ParameterHelper parameterHelper;
enum class InternalState { STARTUP, INITIAL_DELAY, READY };
InternalState internalState = InternalState::STARTUP;
// Initial delay to make sure all pool variables have been initialized their owners
Countdown initialCountdown = Countdown(INIT_DELAY);
ReturnValue_t initialize() override;
ReturnValue_t handleCommandMessage(CommandMessage* message) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
void performControlOperation() override;
};
#endif /* MISSION_CONTROLLER_POWERCONTROLLER_H_ */