From 809d25890e8f24c4e7746669e30b13cecba6aa7f Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 11:33:09 +0200 Subject: [PATCH 1/4] init --- common/config/eive/objects.h | 1 + linux/ObjectFactory.cpp | 6 +++ mission/controller/PowerController.cpp | 54 ++++++++++++++++++++++++++ mission/controller/PowerController.h | 38 ++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 mission/controller/PowerController.cpp create mode 100644 mission/controller/PowerController.h diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index 0cc4b9d9..ca741c77 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -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 */ diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 766b5ca2..b74057c1 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp new file mode 100644 index 00000000..84a6a33f --- /dev/null +++ b/mission/controller/PowerController.cpp @@ -0,0 +1,54 @@ +#include +#include + +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; +} diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h new file mode 100644 index 00000000..70d13401 --- /dev/null +++ b/mission/controller/PowerController.h @@ -0,0 +1,38 @@ +#ifndef MISSION_CONTROLLER_POWERCONTROLLER_H_ +#define MISSION_CONTROLLER_POWERCONTROLLER_H_ + +#include +#include +#include +#include + +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_ */ -- 2.43.0 From 1dd38acee4d103be9dfc8657d2d39e3cc7fc7848 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 14:30:58 +0200 Subject: [PATCH 2/4] object factory stuff --- bsp_q7s/em/emObjectFactory.cpp | 1 + bsp_q7s/fmObjectFactory.cpp | 1 + linux/ObjectFactory.h | 2 ++ mission/controller/CMakeLists.txt | 3 ++- mission/controller/PowerController.cpp | 3 ++- mission/controller/PowerController.h | 2 ++ 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 5b2935b7..cbf1d34a 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -155,5 +155,6 @@ void ObjectFactory::produce(void* args) { HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); createThermalController(*heaterHandler); + createPowerController(enableHkSets); satsystem::init(); } diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index df0bbc91..fa94aeec 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -113,5 +113,6 @@ void ObjectFactory::produce(void* args) { createMiscComponents(); createThermalController(*heaterHandler); createAcsController(true, enableHkSets); + createPowerC satsystem::init(); } diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index 16801ba9..d8605f48 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -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 diff --git a/mission/controller/CMakeLists.txt b/mission/controller/CMakeLists.txt index 6177a14b..901decc0 100644 --- a/mission/controller/CMakeLists.txt +++ b/mission/controller/CMakeLists.txt @@ -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) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 84a6a33f..9264deeb 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -2,13 +2,14 @@ #include PowerController::PowerController(object_id_t objectId, bool enableHkSets) - : ExtendedControllerBase(objectId), enableHkSets(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(); } diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 70d13401..8e2f6339 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -32,6 +32,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM 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; }; -- 2.43.0 From 824f445ee1a60ddcc2dcbb674888730fcd440042 Mon Sep 17 00:00:00 2001 From: meggert Date: Sat, 10 Jun 2023 15:14:20 +0200 Subject: [PATCH 3/4] boop --- bsp_q7s/fmObjectFactory.cpp | 2 +- mission/controller/PowerController.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index fa94aeec..b040810c 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -113,6 +113,6 @@ void ObjectFactory::produce(void* args) { createMiscComponents(); createThermalController(*heaterHandler); createAcsController(true, enableHkSets); - createPowerC + createPowerController(enableHkSets); satsystem::init(); } diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 9264deeb..c817eb21 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -53,3 +53,23 @@ ReturnValue_t PowerController::initializeLocalDataPool(localpool::DataPool &loca 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; +} -- 2.43.0 From a53f1be7105b57a1cf15b788a6bbc2a2019c613a Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 15 Jun 2023 17:51:32 +0200 Subject: [PATCH 4/4] guess i never pushed this --- mission/controller/PowerController.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index c817eb21..1b22bbb2 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -25,6 +25,15 @@ ReturnValue_t PowerController::handleCommandMessage(CommandMessage *message) { 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: { -- 2.43.0