WIP: Power Controller for SoC Calculation #668

Closed
meggert wants to merge 4 commits from soc-calculator into v4.0.0-dev
8 changed files with 137 additions and 1 deletions

View File

@ -155,5 +155,6 @@ void ObjectFactory::produce(void* args) {
HeaterHandler* heaterHandler;
createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler);
createThermalController(*heaterHandler);
createPowerController(enableHkSets);
satsystem::init();
}

View File

@ -113,5 +113,6 @@ void ObjectFactory::produce(void* args) {
createMiscComponents();
createThermalController(*heaterHandler);
createAcsController(true, enableHkSets);
createPowerController(enableHkSets);
satsystem::init();
}

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

@ -16,6 +16,7 @@ class GpioIF;
class SpiComIF;
class PowerSwitchIF;
class AcsController;
class PowerController;
namespace ObjectFactory {
@ -31,5 +32,6 @@ void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher,
void gpioChecker(ReturnValue_t result, std::string output);
AcsController* createAcsController(bool connectSubsystem, bool enableHkSets);
PowerController* createPowerController(bool enableHkSets);
} // namespace ObjectFactory

View File

@ -1,6 +1,7 @@
if(TGT_BSP MATCHES "arm/q7s" OR TGT_BSP MATCHES "")
target_sources(${LIB_EIVE_MISSION} PRIVATE ThermalController.cpp
AcsController.cpp)
AcsController.cpp
PowerController.cpp)
endif()
add_subdirectory(acs)

View File

@ -0,0 +1,84 @@
#include <fsfw/datapool/PoolReadGuard.h>
#include <mission/controller/PowerController.h>
PowerController::PowerController(object_id_t objectId, bool enableHkSets)
: ExtendedControllerBase(objectId), enableHkSets(enableHkSets), parameterHelper(this) {}
ReturnValue_t PowerController::initialize() {
ReturnValue_t result = parameterHelper.initialize();
if (result != returnvalue::OK) {
return result;
}
sif::debug << "fuck you" << std::endl;
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;
}
MessageQueueId_t PowerController::getCommandQueue() const { return commandQueue->getId(); }
ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterId,
ParameterWrapper *parameterWrapper,
const ParameterWrapper *newValues,
uint16_t startAtIndex) {
return returnvalue::FAILED;
}
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;
}
LocalPoolDataSetBase *PowerController::getDataSetHandle(sid_t sid) {
switch (sid.ownerSetId) {
default:
return nullptr;
}
return nullptr;
}
ReturnValue_t PowerController::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) {
if (mode == MODE_OFF) {
if (submode == SUBMODE_NONE) {
return returnvalue::OK;
} else {
return INVALID_SUBMODE;
}
}
return INVALID_MODE;
}

View File

@ -0,0 +1,40 @@
#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;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t* msToReachTheMode) override;
void performControlOperation() override;
};
#endif /* MISSION_CONTROLLER_POWERCONTROLLER_H_ */