From 809d25890e8f24c4e7746669e30b13cecba6aa7f Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 11:33:09 +0200 Subject: [PATCH 01/67] 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_ */ From 1dd38acee4d103be9dfc8657d2d39e3cc7fc7848 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 7 Jun 2023 14:30:58 +0200 Subject: [PATCH 02/67] 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; }; From 824f445ee1a60ddcc2dcbb674888730fcd440042 Mon Sep 17 00:00:00 2001 From: meggert Date: Sat, 10 Jun 2023 15:14:20 +0200 Subject: [PATCH 03/67] 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; +} From a53f1be7105b57a1cf15b788a6bbc2a2019c613a Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 15 Jun 2023 17:51:32 +0200 Subject: [PATCH 04/67] 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: { From 72ca1be6e2856049d65b90c1e78adcb9526ec3a6 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 26 Jul 2023 10:08:40 +0200 Subject: [PATCH 05/67] I was told this was not nice --- mission/controller/PowerController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 1b22bbb2..bfecc67c 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -9,7 +9,7 @@ ReturnValue_t PowerController::initialize() { if (result != returnvalue::OK) { return result; } - sif::debug << "fuck you" << std::endl; + sif::debug << "Rush B, no stop" << std::endl; return ExtendedControllerBase::initialize(); } From 2480229dcb3228fecf1ccf8b41ded0e373733e61 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 26 Jul 2023 10:37:41 +0200 Subject: [PATCH 06/67] objectFactory and scheduling --- bsp_q7s/em/emObjectFactory.cpp | 1 + bsp_q7s/fmObjectFactory.cpp | 1 + common/config/eive/definitions.h | 3 +++ mission/pollingSeqTables.cpp | 3 +++ 4 files changed, 8 insertions(+) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 3a1f7ac5..f887ad6f 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -167,6 +167,7 @@ void ObjectFactory::produce(void* args) { power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); #endif createAcsController(true, enableHkSets); + createPowerController(enableHkSets); HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); createThermalController(*heaterHandler, true); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index e43e3551..718f9bcd 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -130,5 +130,6 @@ void ObjectFactory::produce(void* args) { createMiscComponents(); createThermalController(*heaterHandler, false); createAcsController(true, enableHkSets); + createPowerController(enableHkSets); satsystem::init(false); } diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index b369f512..2653ee74 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -79,6 +79,7 @@ static constexpr uint32_t SCHED_BLOCK_RTD = 150; static constexpr uint32_t SCHED_BLOCK_7_RW_READ_MS = 300; static constexpr uint32_t SCHED_BLOCK_8_PLPCDU_MS = 320; static constexpr uint32_t SCHED_BLOCK_9_RAD_SENS_MS = 340; +static constexpr uint32_t SCHED_BLOCK_10_EPS_CTRL_MS = 350; // 15 ms for FM static constexpr float SCHED_BLOCK_1_PERIOD = static_cast(SCHED_BLOCK_1_SUS_READ_MS) / 400.0; @@ -94,6 +95,8 @@ static constexpr float SCHED_BLOCK_RTD_PERIOD = static_cast(SCHED_BLOCK_R static constexpr float SCHED_BLOCK_7_PERIOD = static_cast(SCHED_BLOCK_7_RW_READ_MS) / 400.0; static constexpr float SCHED_BLOCK_8_PERIOD = static_cast(SCHED_BLOCK_8_PLPCDU_MS) / 400.0; static constexpr float SCHED_BLOCK_9_PERIOD = static_cast(SCHED_BLOCK_9_RAD_SENS_MS) / 400.0; +static constexpr float SCHED_BLOCK_10_PERIOD = + static_cast(SCHED_BLOCK_10_EPS_CTRL_MS) / 400.0; } // namespace spiSched diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index 4896d8db..8f052e77 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -591,6 +591,9 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::POWER_CONTROLLER, length * config::spiSched::SCHED_BLOCK_10_PERIOD, + 0); + /* Radiation sensor */ thisSequence->addSlot(objects::RAD_SENSOR, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); From 5a69b52b20f296847fb04091a8ac6e583626900b Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 26 Jul 2023 11:18:15 +0200 Subject: [PATCH 07/67] datasets --- mission/controller/PowerController.cpp | 12 +++++--- mission/controller/PowerController.h | 12 ++++++++ .../PowerCtrlDefinitions.h | 29 +++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 mission/controller/controllerdefinitions/PowerCtrlDefinitions.h diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index bfecc67c..595a74f2 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -2,7 +2,10 @@ #include PowerController::PowerController(object_id_t objectId, bool enableHkSets) - : ExtendedControllerBase(objectId), enableHkSets(enableHkSets), parameterHelper(this) {} + : ExtendedControllerBase(objectId), + enableHkSets(enableHkSets), + parameterHelper(this), + stateOfChargeData(this) {} ReturnValue_t PowerController::initialize() { ReturnValue_t result = parameterHelper.initialize(); @@ -48,9 +51,10 @@ void PowerController::performControlOperation() { return; } case InternalState::READY: { - if (mode != MODE_OFF) { - // do something - } + // if (mode != MODE_OFF) { + sif::debug << "oh shit, now i gotta do something" << std::endl; + // do something + //} break; } default: diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 8e2f6339..70a7b297 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -5,6 +5,9 @@ #include #include #include +#include +#include +#include class PowerController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: @@ -35,6 +38,15 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode) override; void performControlOperation() override; + + // HK Datasets for Calculation + BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); + P60Dock::CoreHkSet p60CoreHk = P60Dock::CoreHkSet(objects::P60DOCK_HANDLER); + PDU1::Pdu1CoreHk pdu1CoreHk = PDU1::Pdu1CoreHk(objects::PDU1_HANDLER); + PDU2::Pdu2CoreHk pdu2CoreHk = PDU2::Pdu2CoreHk(objects::PDU2_HANDLER); + ACU::CoreHk acuCoreHk = ACU::CoreHk(objects::ACU_HANDLER); + // Output Dataset + pwrctrl::StateOfChargedData stateOfChargeData; }; #endif /* MISSION_CONTROLLER_POWERCONTROLLER_H_ */ diff --git a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h new file mode 100644 index 00000000..d4eeeed0 --- /dev/null +++ b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h @@ -0,0 +1,29 @@ +#ifndef MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ +#define MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ + +#include +#include + +#include + +namespace pwrctrl { + +enum SetIds : uint32_t { STATE_OF_CHARGE_DATA }; + +enum PoolIds : lp_id_t { + +}; + +static constexpr uint8_t STATE_OF_CHARGE_ENTRIES = 6; + +class StateOfChargedData : public StaticLocalDataSet { + public: + StateOfChargedData(HasLocalDataPoolIF* hkOwner) + : StaticLocalDataSet(hkOwner, STATE_OF_CHARGE_DATA) {} + + private: +}; + +} // namespace pwrctrl + +#endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ */ From 88a89691425d4b5ce563a3179e1f7391c550593b Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 26 Jul 2023 17:01:48 +0200 Subject: [PATCH 08/67] basics --- mission/controller/PowerController.cpp | 101 +++++++++++++++++- mission/controller/PowerController.h | 52 +++++++++ .../PowerCtrlDefinitions.h | 10 +- mission/pollingSeqTables.cpp | 6 +- 4 files changed, 163 insertions(+), 6 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 595a74f2..38db8847 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -34,7 +34,20 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex) { - return returnvalue::FAILED; + switch (domainId) { + case 0x0: // direct members + switch (parameterId) { + case 0x0: + parameterWrapper->set(batteryInternalResistance); + break; + default: + return INVALID_IDENTIFIER_ID; + } + break; + default: + return INVALID_DOMAIN_ID; + }; + return returnvalue::OK; } void PowerController::performControlOperation() { @@ -53,6 +66,7 @@ void PowerController::performControlOperation() { case InternalState::READY: { // if (mode != MODE_OFF) { sif::debug << "oh shit, now i gotta do something" << std::endl; + calculateStateOfCharge(); // do something //} break; @@ -69,6 +83,8 @@ ReturnValue_t PowerController::initializeLocalDataPool(localpool::DataPool &loca LocalPoolDataSetBase *PowerController::getDataSetHandle(sid_t sid) { switch (sid.ownerSetId) { + case pwrctrl::STATE_OF_CHARGE_DATA: + return &stateOfChargeData; default: return nullptr; } @@ -86,3 +102,86 @@ ReturnValue_t PowerController::checkModeCommand(Mode_t mode, Submode_t submode, } return INVALID_MODE; } + +void PowerController::calculateStateOfCharge() { + // get time + timeval now; + Clock::getClock_timeval(&now); + + // update EPS hk values + ReturnValue_t result = updateEpsData(); + + float iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.heaterCurrent.value + + bpxBatteryHk.dischargeCurrent.value; + + // Open Circuit Voltage Charge + // ToDo: battery heater and battery discharge currents missing + float vBatCorrected = p60CoreHk.batteryVoltage.value - iBat * batteryInternalResistance; + uint8_t lookUpTableIdx; + for (lookUpTableIdx = 24; lookUpTableIdx > 0; lookUpTableIdx--) { + if (lookUpTableOcv[1][lookUpTableIdx] < vBatCorrected) { + break; + } + } + // ToDo: check indexing + float openCircuitVoltageCharge = + lookUpTableOcv[0][lookUpTableIdx] + + (vBatCorrected - lookUpTableOcv[1][lookUpTableIdx]) * + (lookUpTableOcv[1][lookUpTableIdx + 1] - lookUpTableOcv[1][lookUpTableIdx]) / + (lookUpTableOcv[0][lookUpTableIdx + 1] - lookUpTableOcv[0][lookUpTableIdx]); + + // Coulomb Counter + float coulombCounterCharge = 0; + if (stateOfChargeData.coulombCounterCharge.value == 0) + coulombCounterCharge = openCircuitVoltageCharge; + else { + double timeDiff = timevalOperations::toDouble(now - oldTime); + coulombCounterCharge = stateOfChargeData.coulombCounterCharge.value + iBat * timeDiff; + } + + // commit TM + { + PoolReadGuard pg(&stateOfChargeData); + stateOfChargeData.openCircuitVoltageCharge.value = + charge2stateOfCharge(openCircuitVoltageCharge); + stateOfChargeData.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge); + stateOfChargeData.setValidity(true, true); + } + + // store time for next run + oldTime = now; +} + +ReturnValue_t PowerController::updateEpsData() { + std::vector results; + { + PoolReadGuard pgBat(&bpxBatteryHk); + results.push_back(pgBat.getReadResult()); + } + { + PoolReadGuard pgP60(&p60CoreHk); + results.push_back(pgP60.getReadResult()); + } + { + PoolReadGuard pgPdu1(&pdu1CoreHk); + results.push_back(pgPdu1.getReadResult()); + } + { + PoolReadGuard pgPdu2(&pdu2CoreHk); + results.push_back(pgPdu2.getReadResult()); + } + { + PoolReadGuard pgAcu(&acuCoreHk); + results.push_back(pgAcu.getReadResult()); + } + for (const auto &result : results) { + if (result != returnvalue::OK) { + return result; + } + } + return returnvalue::OK; +} + +float PowerController::charge2stateOfCharge(float capacity) { + return capacity / batteryMaximumCapacity; +} diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 70a7b297..e49e6b71 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -3,12 +3,15 @@ #include #include +#include #include #include #include #include #include +#include + class PowerController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: static constexpr dur_millis_t INIT_DELAY = 500; @@ -39,6 +42,55 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM uint32_t* msToReachTheMode) override; void performControlOperation() override; + void calculateStateOfCharge(); + ReturnValue_t updateEpsData(); + float charge2stateOfCharge(float capacity); + + // Parameters + float batteryInternalResistance = 70 / 2 / 1000; // [Ohm] + float batteryMaximumCapacity = 2.6 * 2; // [Ah] + + // OCV Look-up-Table + float lookUpTableOcv[2][25] = { + {0.00000000e+00, 3.16227766e-04, 4.52809661e-04, 6.48382625e-04, 9.28425483e-04, + 1.32942162e-03, 1.90361194e-03, 2.72580074e-03, 3.90310099e-03, 5.58888885e-03, + 8.00278514e-03, 1.14592671e-02, 1.64086377e-02, 2.34956903e-02, 3.36437110e-02, + 4.81747620e-02, 6.89819174e-02, 9.87758887e-02, 1.41438170e-01, 2.02526713e-01, + 2.90000000e-01, 3.00000000e-01, 3.62820513e-01, 4.25641026e-01, 4.88461538e-01, + 5.51282051e-01, 6.14102564e-01, 6.76923077e-01, 7.39743590e-01, 8.02564103e-01, + 8.65384615e-01, 9.28205128e-01, 9.91025641e-01, 1.05384615e+00, 1.11666667e+00, + 1.17948718e+00, 1.24230769e+00, 1.30512821e+00, 1.36794872e+00, 1.43076923e+00, + 1.49358974e+00, 1.55641026e+00, 1.61923077e+00, 1.68205128e+00, 1.74487179e+00, + 1.80769231e+00, 1.87051282e+00, 1.93333333e+00, 1.99615385e+00, 2.05897436e+00, + 2.12179487e+00, 2.18461538e+00, 2.24743590e+00, 2.31025641e+00, 2.37307692e+00, + 2.43589744e+00, 2.49871795e+00, 2.56153846e+00, 2.62435897e+00, 2.68717949e+00, + 2.75000000e+00, 2.81282051e+00, 2.87564103e+00, 2.93846154e+00, 3.00128205e+00, + 3.06410256e+00, 3.12692308e+00, 3.18974359e+00, 3.25256410e+00, 3.31538462e+00, + 3.37820513e+00, 3.44102564e+00, 3.50384615e+00, 3.56666667e+00, 3.62948718e+00, + 3.69230769e+00, 3.75512821e+00, 3.81794872e+00, 3.88076923e+00, 3.94358974e+00, + 4.00641026e+00, 4.06923077e+00, 4.13205128e+00, 4.19487179e+00, 4.25769231e+00, + 4.32051282e+00, 4.38333333e+00, 4.44615385e+00, 4.50897436e+00, 4.57179487e+00, + 4.63461538e+00, 4.69743590e+00, 4.76025641e+00, 4.82307692e+00, 4.88589744e+00, + 4.94871795e+00, 5.01153846e+00, 5.07435897e+00, 5.13717949e+00, 5.20000000e+00}, + {12.52033533, 12.58720948, 12.61609309, 12.65612591, 12.67105282, 12.69242681, 12.72303245, + 12.76685696, 12.80313768, 12.83600741, 12.8830739, 12.94720576, 13.00112629, 13.07833563, + 13.17486308, 13.27128842, 13.37713879, 13.49275604, 13.60395193, 13.68708863, 13.75196335, + 13.7582376, 13.79298643, 13.82885799, 13.87028849, 13.91585718, 13.96701874, 14.02343574, + 14.07665641, 14.12626342, 14.1675095, 14.20582917, 14.23342159, 14.25724476, 14.27264301, + 14.28922389, 14.30898535, 14.32750837, 14.34358057, 14.35965277, 14.37698366, 14.3943261, + 14.41079196, 14.42679817, 14.44261008, 14.45771025, 14.47281042, 14.48751461, 14.50193089, + 14.5164887, 14.53193477, 14.54738084, 14.56341235, 14.58054578, 14.59799552, 14.61632769, + 14.63716465, 14.66935073, 14.70511347, 14.74315094, 14.77251031, 14.80005585, 14.8315427, + 14.86078285, 14.89444687, 14.93495892, 14.97114013, 15.01055751, 15.0538516, 15.09698825, + 15.14850029, 15.18947994, 15.24249483, 15.28521713, 15.335695, 15.37950723, 15.43241224, + 15.48082213, 15.53314287, 15.58907248, 15.64030253, 15.68385331, 15.74149122, 15.80051882, + 15.84959348, 15.90443241, 15.95743724, 16.01283068, 16.07629253, 16.13470801, 16.1890518, + 16.24200781, 16.30521118, 16.37368429, 16.43661267, 16.49604875, 16.56223813, 16.62741412, + 16.67249918, 16.74926904}}; + + // Variables + timeval oldTime; + // HK Datasets for Calculation BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); P60Dock::CoreHkSet p60CoreHk = P60Dock::CoreHkSet(objects::P60DOCK_HANDLER); diff --git a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h index d4eeeed0..770889c1 100644 --- a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h +++ b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h @@ -11,16 +11,22 @@ namespace pwrctrl { enum SetIds : uint32_t { STATE_OF_CHARGE_DATA }; enum PoolIds : lp_id_t { - + OPEN_CIRCUIT_VOLTAGE_CHARGE, + COULOMB_COUNTER_CHARGE, }; -static constexpr uint8_t STATE_OF_CHARGE_ENTRIES = 6; +static constexpr uint8_t STATE_OF_CHARGE_ENTRIES = 2; class StateOfChargedData : public StaticLocalDataSet { public: StateOfChargedData(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, STATE_OF_CHARGE_DATA) {} + lp_var_t openCircuitVoltageCharge = + lp_var_t(sid.objectId, OPEN_CIRCUIT_VOLTAGE_CHARGE, this); + lp_var_t coulombCounterCharge = + lp_var_t(sid.objectId, COULOMB_COUNTER_CHARGE, this); + private: }; diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index 8f052e77..e2517abd 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -133,6 +133,9 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PDU1_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::POWER_CONTROLLER, length * 0.6, 0); + if (thisSequence->checkSequence() != returnvalue::OK) { sif::error << "GomSpace PST initialization failed" << std::endl; return returnvalue::FAILED; @@ -591,9 +594,6 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg thisSequence->addSlot(objects::BPX_BATT_HANDLER, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::POWER_CONTROLLER, length * config::spiSched::SCHED_BLOCK_10_PERIOD, - 0); - /* Radiation sensor */ thisSequence->addSlot(objects::RAD_SENSOR, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::PERFORM_OPERATION); From a0025030f103c6998984c909cc9c2fa81a5b1ca5 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 28 Jul 2023 11:36:20 +0200 Subject: [PATCH 09/67] first bits of cleanup --- mission/controller/PowerController.cpp | 109 +++++++++++------- mission/controller/PowerController.h | 17 ++- .../PowerCtrlDefinitions.h | 14 ++- mission/power/defs.h | 7 ++ 4 files changed, 99 insertions(+), 48 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 38db8847..fa6ab403 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -1,11 +1,11 @@ -#include + #include PowerController::PowerController(object_id_t objectId, bool enableHkSets) : ExtendedControllerBase(objectId), enableHkSets(enableHkSets), parameterHelper(this), - stateOfChargeData(this) {} + pwrCtrlCoreHk(this) {} ReturnValue_t PowerController::initialize() { ReturnValue_t result = parameterHelper.initialize(); @@ -40,6 +40,9 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI case 0x0: parameterWrapper->set(batteryInternalResistance); break; + case 0x1: + parameterWrapper->set(batteryMaximumCapacity); + break; default: return INVALID_IDENTIFIER_ID; } @@ -78,13 +81,18 @@ void PowerController::performControlOperation() { ReturnValue_t PowerController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { + localDataPoolMap.emplace(pwrctrl::PoolIds::TOTAL_BATTERY_CURRENT, new PoolEntry({0})); + localDataPoolMap.emplace(pwrctrl::PoolIds::OPEN_CIRCUIT_VOLTAGE_CHARGE, + new PoolEntry({0.0})); + localDataPoolMap.emplace(pwrctrl::PoolIds::COULOMB_COUNTER_CHARGE, new PoolEntry({0.0})); + poolManager.subscribeForRegularPeriodicPacket({pwrCtrlCoreHk.getSid(), enableHkSets, 60.0}); return returnvalue::OK; } LocalPoolDataSetBase *PowerController::getDataSetHandle(sid_t sid) { switch (sid.ownerSetId) { - case pwrctrl::STATE_OF_CHARGE_DATA: - return &stateOfChargeData; + case pwrctrl::CORE_HK: + return &pwrCtrlCoreHk; default: return nullptr; } @@ -105,53 +113,72 @@ ReturnValue_t PowerController::checkModeCommand(Mode_t mode, Submode_t submode, void PowerController::calculateStateOfCharge() { // get time - timeval now; Clock::getClock_timeval(&now); - // update EPS hk values + // update EPS HK values ReturnValue_t result = updateEpsData(); - - float iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.heaterCurrent.value + - bpxBatteryHk.dischargeCurrent.value; - - // Open Circuit Voltage Charge - // ToDo: battery heater and battery discharge currents missing - float vBatCorrected = p60CoreHk.batteryVoltage.value - iBat * batteryInternalResistance; - uint8_t lookUpTableIdx; - for (lookUpTableIdx = 24; lookUpTableIdx > 0; lookUpTableIdx--) { - if (lookUpTableOcv[1][lookUpTableIdx] < vBatCorrected) { - break; - } - } - // ToDo: check indexing - float openCircuitVoltageCharge = - lookUpTableOcv[0][lookUpTableIdx] + - (vBatCorrected - lookUpTableOcv[1][lookUpTableIdx]) * - (lookUpTableOcv[1][lookUpTableIdx + 1] - lookUpTableOcv[1][lookUpTableIdx]) / - (lookUpTableOcv[0][lookUpTableIdx + 1] - lookUpTableOcv[0][lookUpTableIdx]); - - // Coulomb Counter - float coulombCounterCharge = 0; - if (stateOfChargeData.coulombCounterCharge.value == 0) - coulombCounterCharge = openCircuitVoltageCharge; - else { - double timeDiff = timevalOperations::toDouble(now - oldTime); - coulombCounterCharge = stateOfChargeData.coulombCounterCharge.value + iBat * timeDiff; + if (result != returnvalue::OK) { + triggerEvent(power::DATASET_READ_FAILED); + sif::info << "Power Controller::Reading of Datasets has failed" << std::endl; + return; } - // commit TM + // calculate total battery current + iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.heaterCurrent.value + + bpxBatteryHk.dischargeCurrent.value; + + calculateOpenCircuitVoltageCharge(); + calculateCoulombCounterCharge(); + + // commit to dataset { - PoolReadGuard pg(&stateOfChargeData); - stateOfChargeData.openCircuitVoltageCharge.value = - charge2stateOfCharge(openCircuitVoltageCharge); - stateOfChargeData.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge); - stateOfChargeData.setValidity(true, true); + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; + pwrCtrlCoreHk.openCircuitVoltageCharge.value = charge2stateOfCharge(openCircuitVoltageCharge); + pwrCtrlCoreHk.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge); + pwrCtrlCoreHk.setValidity(true, true); + } } // store time for next run oldTime = now; } +void PowerController::calculateOpenCircuitVoltageCharge() { + float vBatCorrected = p60CoreHk.batteryVoltage.value - iBat * batteryInternalResistance; + if (vBatCorrected >= lookUpTableOcv[1][100]) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0); + sif::error << "Power Controller::Voltage is too high" << std::endl; + return; + } else if (vBatCorrected <= lookUpTableOcv[1][0]) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1); + sif::error << "Power Controller::Voltage is too low" << std::endl; + return; + } + uint8_t lookUpTableIdx = 99; + while (lookUpTableOcv[1][lookUpTableIdx] > vBatCorrected) { + lookUpTableIdx--; + } + + openCircuitVoltageCharge = linearInterpolation( + vBatCorrected, lookUpTableOcv[1][lookUpTableIdx], lookUpTableOcv[1][lookUpTableIdx + 1], + lookUpTableOcv[0][lookUpTableIdx], lookUpTableOcv[0][lookUpTableIdx + 1]); +} + +void PowerController::calculateCoulombCounterCharge() { + if ((pwrCtrlCoreHk.coulombCounterCharge.value == 0) or + (p60CoreHk.batteryVoltage.value > coulombCounterVoltageUpperThreshold and + pwrCtrlCoreHk.coulombCounterCharge.value >= )) { + coulombCounterCharge = openCircuitVoltageCharge; + } + + else { + double timeDiff = timevalOperations::toDouble(now - oldTime); + coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff; + } +} + ReturnValue_t PowerController::updateEpsData() { std::vector results; { @@ -185,3 +212,7 @@ ReturnValue_t PowerController::updateEpsData() { float PowerController::charge2stateOfCharge(float capacity) { return capacity / batteryMaximumCapacity; } + +float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); +} diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index e49e6b71..d255af7b 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -43,15 +43,19 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM void performControlOperation() override; void calculateStateOfCharge(); + void calculateOpenCircuitVoltageCharge(); + void calculateCoulombCounterCharge(); ReturnValue_t updateEpsData(); float charge2stateOfCharge(float capacity); + float linearInterpolation(float x, float x0, float x1, float y0, float y1); // Parameters - float batteryInternalResistance = 70 / 2 / 1000; // [Ohm] - float batteryMaximumCapacity = 2.6 * 2; // [Ah] + float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm] + float batteryMaximumCapacity = 2.6 * 2; // [Ah] + float coulombCounterVoltageUpperThreshold = 16.2e3; // [mV] // OCV Look-up-Table - float lookUpTableOcv[2][25] = { + float lookUpTableOcv[2][100] = { {0.00000000e+00, 3.16227766e-04, 4.52809661e-04, 6.48382625e-04, 9.28425483e-04, 1.32942162e-03, 1.90361194e-03, 2.72580074e-03, 3.90310099e-03, 5.58888885e-03, 8.00278514e-03, 1.14592671e-02, 1.64086377e-02, 2.34956903e-02, 3.36437110e-02, @@ -89,7 +93,12 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM 16.67249918, 16.74926904}}; // Variables + timeval now; timeval oldTime; + int16_t iBat = 0.0; // [mA] + float openCircuitVoltageCharge = 0.0; // [mC] + float coulombCounterCharge = 0; // [mC] + float coulombCounterChargeUpperThreshold = 0.0; // [mC] // HK Datasets for Calculation BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); @@ -98,7 +107,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM PDU2::Pdu2CoreHk pdu2CoreHk = PDU2::Pdu2CoreHk(objects::PDU2_HANDLER); ACU::CoreHk acuCoreHk = ACU::CoreHk(objects::ACU_HANDLER); // Output Dataset - pwrctrl::StateOfChargedData stateOfChargeData; + pwrctrl::CoreHk pwrCtrlCoreHk; }; #endif /* MISSION_CONTROLLER_POWERCONTROLLER_H_ */ diff --git a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h index 770889c1..f7cce708 100644 --- a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h +++ b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h @@ -1,27 +1,31 @@ #ifndef MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ #define MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ +#include #include #include +#include #include namespace pwrctrl { -enum SetIds : uint32_t { STATE_OF_CHARGE_DATA }; +enum SetIds : uint32_t { CORE_HK }; enum PoolIds : lp_id_t { + TOTAL_BATTERY_CURRENT, OPEN_CIRCUIT_VOLTAGE_CHARGE, COULOMB_COUNTER_CHARGE, }; -static constexpr uint8_t STATE_OF_CHARGE_ENTRIES = 2; +static constexpr uint8_t CORE_HK_ENTRIES = 3; -class StateOfChargedData : public StaticLocalDataSet { +class CoreHk : public StaticLocalDataSet { public: - StateOfChargedData(HasLocalDataPoolIF* hkOwner) - : StaticLocalDataSet(hkOwner, STATE_OF_CHARGE_DATA) {} + CoreHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, CORE_HK) {} + lp_var_t totalBatteryCurrent = + lp_var_t(sid.objectId, TOTAL_BATTERY_CURRENT, this); lp_var_t openCircuitVoltageCharge = lp_var_t(sid.objectId, OPEN_CIRCUIT_VOLTAGE_CHARGE, this); lp_var_t coulombCounterCharge = diff --git a/mission/power/defs.h b/mission/power/defs.h index 13e5e63f..682be614 100644 --- a/mission/power/defs.h +++ b/mission/power/defs.h @@ -47,6 +47,13 @@ static constexpr Event SWITCHING_Q7S_DENIED = event::makeEvent(SUBSYSTEM_ID, 2, static constexpr Event FDIR_REACTION_IGNORED = event::makeEvent(SUBSYSTEM_ID, 3, severity::MEDIUM); +//! [EXPORT] : [COMMENT] The dataset read for the inputs of the Power Controller has failed. +static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, severity::INFO); +//! [EXPORT] : [COMMENT] The battery voltage read is out of the bounds in which it is supposed to +//! be. +//! P1: 1 too high, 0 too low +static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH); + enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING }; enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED }; From 0bfd31bc7e54a5f6817ec5f96dc17e8f9d191526 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 28 Jul 2023 11:38:35 +0200 Subject: [PATCH 10/67] missed that one --- mission/controller/PowerController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index fa6ab403..eea251e0 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -169,7 +169,7 @@ void PowerController::calculateOpenCircuitVoltageCharge() { void PowerController::calculateCoulombCounterCharge() { if ((pwrCtrlCoreHk.coulombCounterCharge.value == 0) or (p60CoreHk.batteryVoltage.value > coulombCounterVoltageUpperThreshold and - pwrCtrlCoreHk.coulombCounterCharge.value >= )) { + pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) { coulombCounterCharge = openCircuitVoltageCharge; } From bc9bb06f2d741e590a4526ed279def6acad93507 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 31 Jul 2023 11:51:03 +0200 Subject: [PATCH 11/67] further improvements --- mission/controller/PowerController.cpp | 77 ++++++++++++++++++++------ mission/controller/PowerController.h | 9 ++- 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index eea251e0..289e70b8 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -43,6 +43,12 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI case 0x1: parameterWrapper->set(batteryMaximumCapacity); break; + case 0x2: + parameterWrapper->set(coulombCounterVoltageUpperThreshold); + break; + case 0x3: + parameterWrapper->set(maxAllowedTimeDiff); + break; default: return INVALID_IDENTIFIER_ID; } @@ -119,7 +125,16 @@ void PowerController::calculateStateOfCharge() { ReturnValue_t result = updateEpsData(); if (result != returnvalue::OK) { triggerEvent(power::DATASET_READ_FAILED); - sif::info << "Power Controller::Reading of Datasets has failed" << std::endl; + sif::error << "Power Controller::Reading of Datasets has failed" << std::endl; + { + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = INVALID_TOTAL_BATTERY_CURRENT; + pwrCtrlCoreHk.openCircuitVoltageCharge.value = INVALID_SOC; + pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; + pwrCtrlCoreHk.setValidity(false, true); + } + } return; } @@ -127,7 +142,22 @@ void PowerController::calculateStateOfCharge() { iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.heaterCurrent.value + bpxBatteryHk.dischargeCurrent.value; - calculateOpenCircuitVoltageCharge(); + result = calculateOpenCircuitVoltageCharge(); + if (result != returnvalue::OK) { + // notifying events have already been triggered + { + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; + pwrCtrlCoreHk.totalBatteryCurrent.setValid(true); + pwrCtrlCoreHk.openCircuitVoltageCharge.value = INVALID_SOC; + pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(false); + pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; + pwrCtrlCoreHk.coulombCounterCharge.setValid(false); + } + } + return; + } calculateCoulombCounterCharge(); // commit to dataset @@ -145,38 +175,35 @@ void PowerController::calculateStateOfCharge() { oldTime = now; } -void PowerController::calculateOpenCircuitVoltageCharge() { +ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { float vBatCorrected = p60CoreHk.batteryVoltage.value - iBat * batteryInternalResistance; - if (vBatCorrected >= lookUpTableOcv[1][100]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0); - sif::error << "Power Controller::Voltage is too high" << std::endl; - return; - } else if (vBatCorrected <= lookUpTableOcv[1][0]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1); - sif::error << "Power Controller::Voltage is too low" << std::endl; - return; - } uint8_t lookUpTableIdx = 99; - while (lookUpTableOcv[1][lookUpTableIdx] > vBatCorrected) { - lookUpTableIdx--; + ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); + if (result != returnvalue::OK) { + return result; } - openCircuitVoltageCharge = linearInterpolation( vBatCorrected, lookUpTableOcv[1][lookUpTableIdx], lookUpTableOcv[1][lookUpTableIdx + 1], lookUpTableOcv[0][lookUpTableIdx], lookUpTableOcv[0][lookUpTableIdx + 1]); + return returnvalue::OK; } -void PowerController::calculateCoulombCounterCharge() { +ReturnValue_t PowerController::calculateCoulombCounterCharge() { if ((pwrCtrlCoreHk.coulombCounterCharge.value == 0) or (p60CoreHk.batteryVoltage.value > coulombCounterVoltageUpperThreshold and pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) { coulombCounterCharge = openCircuitVoltageCharge; + return returnvalue::OK; } else { double timeDiff = timevalOperations::toDouble(now - oldTime); - coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff; + if (timeDiff < maxAllowedTimeDiff) { + coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff; + return returnvalue::OK; + } } + return returnvalue::FAILED; } ReturnValue_t PowerController::updateEpsData() { @@ -216,3 +243,19 @@ float PowerController::charge2stateOfCharge(float capacity) { float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) { return y0 + (x - x0) * (y1 - y0) / (x1 - x0); } + +ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) { + if (voltage >= lookUpTableOcv[1][100]) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0); + sif::error << "Power Controller::Voltage is too high" << std::endl; + return returnvalue::FAILED; + } else if (voltage <= lookUpTableOcv[1][0]) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1); + sif::error << "Power Controller::Voltage is too low" << std::endl; + return returnvalue::FAILED; + } + while (lookUpTableOcv[1][idx] > voltage) { + idx--; + } + return returnvalue::OK; +} diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index d255af7b..971bc0af 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -43,16 +43,18 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM void performControlOperation() override; void calculateStateOfCharge(); - void calculateOpenCircuitVoltageCharge(); - void calculateCoulombCounterCharge(); + ReturnValue_t calculateOpenCircuitVoltageCharge(); + ReturnValue_t calculateCoulombCounterCharge(); ReturnValue_t updateEpsData(); float charge2stateOfCharge(float capacity); + ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx); float linearInterpolation(float x, float x0, float x1, float y0, float y1); // Parameters float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm] float batteryMaximumCapacity = 2.6 * 2; // [Ah] float coulombCounterVoltageUpperThreshold = 16.2e3; // [mV] + double maxAllowedTimeDiff = 0.5; // [s] // OCV Look-up-Table float lookUpTableOcv[2][100] = { @@ -100,6 +102,9 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float coulombCounterCharge = 0; // [mC] float coulombCounterChargeUpperThreshold = 0.0; // [mC] + static constexpr float INVALID_TOTAL_BATTERY_CURRENT = 0; + static constexpr float INVALID_SOC = -1; + // HK Datasets for Calculation BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); P60Dock::CoreHkSet p60CoreHk = P60Dock::CoreHkSet(objects::P60DOCK_HANDLER); From 40ee5ddade994b8e475dc2e51f63c7d1e63c219c Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 31 Jul 2023 13:14:04 +0200 Subject: [PATCH 12/67] what if everyone was a returnvalue --- mission/controller/PowerController.cpp | 59 +++++++++++++++++++------- mission/controller/PowerController.h | 1 + mission/power/defs.h | 3 ++ 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 289e70b8..21e3ad3d 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -158,7 +158,26 @@ void PowerController::calculateStateOfCharge() { } return; } - calculateCoulombCounterCharge(); + + result = calculateCoulombCounterCharge(); + // store time for next run + oldTime = now; + if (result != returnvalue::OK) { + // notifying events have already been triggered + { + PoolReadGuard pg(&pwrCtrlCoreHk); + if (pg.getReadResult() == returnvalue::OK) { + pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; + pwrCtrlCoreHk.totalBatteryCurrent.setValid(true); + pwrCtrlCoreHk.openCircuitVoltageCharge.value = + charge2stateOfCharge(openCircuitVoltageCharge); + pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(true); + pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; + pwrCtrlCoreHk.coulombCounterCharge.setValid(false); + } + } + return; + } // commit to dataset { @@ -170,9 +189,6 @@ void PowerController::calculateStateOfCharge() { pwrCtrlCoreHk.setValidity(true, true); } } - - // store time for next run - oldTime = now; } ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { @@ -189,21 +205,20 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { } ReturnValue_t PowerController::calculateCoulombCounterCharge() { - if ((pwrCtrlCoreHk.coulombCounterCharge.value == 0) or + double timeDiff = timevalOperations::toDouble(now - oldTime); + if (timeDiff > maxAllowedTimeDiff) { + triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS); + sif::error << "Power Controller::Time delta too large for Coulomb Counter" << std::endl; + return returnvalue::FAILED; + } + if ((not pwrCtrlCoreHk.coulombCounterCharge.isValid()) or (p60CoreHk.batteryVoltage.value > coulombCounterVoltageUpperThreshold and pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) { coulombCounterCharge = openCircuitVoltageCharge; - return returnvalue::OK; + } else { + coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff; } - - else { - double timeDiff = timevalOperations::toDouble(now - oldTime); - if (timeDiff < maxAllowedTimeDiff) { - coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff; - return returnvalue::OK; - } - } - return returnvalue::FAILED; + return returnvalue::OK; } ReturnValue_t PowerController::updateEpsData() { @@ -259,3 +274,17 @@ ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &i } return returnvalue::OK; } + +ReturnValue_t PowerController::calculateCoulombCounterChargeUpperThreshold() { + uint8_t lookUpTableIdx = 99; + ReturnValue_t result = + lookUpTableOcvIdxFinder(coulombCounterVoltageUpperThreshold, lookUpTableIdx); + if (result != returnvalue::OK) { + return result; + } + coulombCounterChargeUpperThreshold = + linearInterpolation(coulombCounterVoltageUpperThreshold, lookUpTableOcv[1][lookUpTableIdx], + lookUpTableOcv[1][lookUpTableIdx + 1], lookUpTableOcv[0][lookUpTableIdx], + lookUpTableOcv[0][lookUpTableIdx + 1]); + return returnvalue::OK; +} diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 971bc0af..0f15363b 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -49,6 +49,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float charge2stateOfCharge(float capacity); ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx); float linearInterpolation(float x, float x0, float x1, float y0, float y1); + ReturnValue_t calculateCoulombCounterChargeUpperThreshold(); // Parameters float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm] diff --git a/mission/power/defs.h b/mission/power/defs.h index 682be614..87fc3f08 100644 --- a/mission/power/defs.h +++ b/mission/power/defs.h @@ -53,6 +53,9 @@ static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, s //! be. //! P1: 1 too high, 0 too low static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH); +//! [EXPORT] : [COMMENT] Time difference for Coulomb Counter was too large. +static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = + event::makeEvent(SUBSYSTEM_ID, 6, severity::MEDIUM); enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING }; enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED }; From f8a7179de634a96606d0b898d6b83f196d6b3a80 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 31 Jul 2023 13:27:14 +0200 Subject: [PATCH 13/67] this is overengineered af --- mission/controller/PowerController.cpp | 12 ++++++++++++ mission/controller/PowerController.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 21e3ad3d..e08fc9eb 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -44,7 +44,12 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI parameterWrapper->set(batteryMaximumCapacity); break; case 0x2: + float oldCoulombCounterVoltageUpperThreshold = coulombCounterVoltageUpperThreshold; parameterWrapper->set(coulombCounterVoltageUpperThreshold); + ReturnValue_t result = calculateCoulombCounterChargeUpperThreshold(); + if (result != returnvalue::OK) { + coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; + } break; case 0x3: parameterWrapper->set(maxAllowedTimeDiff); @@ -68,6 +73,13 @@ void PowerController::performControlOperation() { } case InternalState::INITIAL_DELAY: { if (initialCountdown.hasTimedOut()) { + internalState = InternalState::INIT; + } + return; + } + case InternalState::INIT: { + ReturnValue_t result = calculateCoulombCounterChargeUpperThreshold(); + if (result == returnvalue::OK) { internalState = InternalState::READY; } return; diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 0f15363b..e7f9383c 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -27,7 +27,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM bool enableHkSets = false; ParameterHelper parameterHelper; - enum class InternalState { STARTUP, INITIAL_DELAY, READY }; + enum class InternalState { STARTUP, INITIAL_DELAY, INIT, READY }; InternalState internalState = InternalState::STARTUP; // Initial delay to make sure all pool variables have been initialized their owners From 2eba5d52da86c2d423e49400f34cef21fabbe8b6 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 31 Jul 2023 13:28:54 +0200 Subject: [PATCH 14/67] don't need those anymore --- common/config/eive/definitions.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index 2653ee74..b369f512 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -79,7 +79,6 @@ static constexpr uint32_t SCHED_BLOCK_RTD = 150; static constexpr uint32_t SCHED_BLOCK_7_RW_READ_MS = 300; static constexpr uint32_t SCHED_BLOCK_8_PLPCDU_MS = 320; static constexpr uint32_t SCHED_BLOCK_9_RAD_SENS_MS = 340; -static constexpr uint32_t SCHED_BLOCK_10_EPS_CTRL_MS = 350; // 15 ms for FM static constexpr float SCHED_BLOCK_1_PERIOD = static_cast(SCHED_BLOCK_1_SUS_READ_MS) / 400.0; @@ -95,8 +94,6 @@ static constexpr float SCHED_BLOCK_RTD_PERIOD = static_cast(SCHED_BLOCK_R static constexpr float SCHED_BLOCK_7_PERIOD = static_cast(SCHED_BLOCK_7_RW_READ_MS) / 400.0; static constexpr float SCHED_BLOCK_8_PERIOD = static_cast(SCHED_BLOCK_8_PLPCDU_MS) / 400.0; static constexpr float SCHED_BLOCK_9_PERIOD = static_cast(SCHED_BLOCK_9_RAD_SENS_MS) / 400.0; -static constexpr float SCHED_BLOCK_10_PERIOD = - static_cast(SCHED_BLOCK_10_EPS_CTRL_MS) / 400.0; } // namespace spiSched From f1cb2caa3a96cf0a64ae44ab4403e7396de0042d Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 31 Jul 2023 13:32:40 +0200 Subject: [PATCH 15/67] cool --- mission/controller/PowerController.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index e08fc9eb..58177313 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -43,7 +43,7 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI case 0x1: parameterWrapper->set(batteryMaximumCapacity); break; - case 0x2: + case 0x2: { float oldCoulombCounterVoltageUpperThreshold = coulombCounterVoltageUpperThreshold; parameterWrapper->set(coulombCounterVoltageUpperThreshold); ReturnValue_t result = calculateCoulombCounterChargeUpperThreshold(); @@ -51,6 +51,7 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; } break; + } case 0x3: parameterWrapper->set(maxAllowedTimeDiff); break; From 634f6c60019c7836cb1bd1394868d31942a230c8 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 13 Sep 2023 14:34:10 +0200 Subject: [PATCH 16/67] introduction of eps subsystem object --- common/config/eive/objects.h | 1 + mission/system/power/EpsSubsystem.cpp | 27 +++++++++++++++++ mission/system/power/EpsSubsystem.h | 13 +++++++++ mission/system/power/epsModeTree.cpp | 42 +++++++++++++++++++++++++++ mission/system/power/epsModeTree.h | 15 ++++++++++ mission/system/systemTree.cpp | 3 ++ 6 files changed, 101 insertions(+) create mode 100644 mission/system/power/EpsSubsystem.cpp create mode 100644 mission/system/power/EpsSubsystem.h create mode 100644 mission/system/power/epsModeTree.cpp create mode 100644 mission/system/power/epsModeTree.h diff --git a/common/config/eive/objects.h b/common/config/eive/objects.h index ca741c77..5d93dffc 100644 --- a/common/config/eive/objects.h +++ b/common/config/eive/objects.h @@ -158,6 +158,7 @@ enum commonObjects : uint32_t { PL_SUBSYSTEM = 0x73010002, TCS_SUBSYSTEM = 0x73010003, COM_SUBSYSTEM = 0x73010004, + EPS_SUBSYSTEM = 0x73010005, TM_FUNNEL = 0x73000100, PUS_TM_FUNNEL = 0x73000101, diff --git a/mission/system/power/EpsSubsystem.cpp b/mission/system/power/EpsSubsystem.cpp new file mode 100644 index 00000000..8d402553 --- /dev/null +++ b/mission/system/power/EpsSubsystem.cpp @@ -0,0 +1,27 @@ +#include + +#include "fsfw/devicehandlers/DeviceHandlerIF.h" + +EpsSubsystem::EpsSubsystem(object_id_t objectId, uint32_t maxNumberOfSequences, + uint32_t maxNumberOfTables) + : Subsystem(objectId, maxNumberOfSequences, maxNumberOfTables) {} + +void EpsSubsystem::announceMode(bool recursive) { + const char* modeStr = "UNKNOWN"; + switch (mode) { + case (HasModesIF::MODE_OFF): { + modeStr = "OFF"; + break; + } + case (HasModesIF::MODE_ON): { + modeStr = "ON"; + break; + } + case (DeviceHandlerIF::MODE_NORMAL): { + modeStr = "NORMAL"; + break; + } + } + sif::info << "EPS subsystem is now in " << modeStr << " mode" << std::endl; + return Subsystem::announceMode(recursive); +} diff --git a/mission/system/power/EpsSubsystem.h b/mission/system/power/EpsSubsystem.h new file mode 100644 index 00000000..33f24d46 --- /dev/null +++ b/mission/system/power/EpsSubsystem.h @@ -0,0 +1,13 @@ +#ifndef MISSION_SYSTEM_OBJECTS_EPSSUBSYSTEM_H_ +#define MISSION_SYSTEM_OBJECTS_EPSSUBSYSTEM_H_ +#include + +class EpsSubsystem : public Subsystem { + public: + EpsSubsystem(object_id_t objectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables); + + private: + void announceMode(bool recursive) override; +}; + +#endif /* MISSION_SYSTEM_OBJECTS_EPSSUBSYSTEM_H_ */ diff --git a/mission/system/power/epsModeTree.cpp b/mission/system/power/epsModeTree.cpp new file mode 100644 index 00000000..feeb6e5d --- /dev/null +++ b/mission/system/power/epsModeTree.cpp @@ -0,0 +1,42 @@ +#include + +#include "eive/objects.h" +#include "fsfw/devicehandlers/DeviceHandlerIF.h" +#include "fsfw/subsystem/Subsystem.h" +#include "mission/system/treeUtil.h" + +EpsSubsystem satsystem::eps::SUBSYSTEM(objects::EPS_SUBSYSTEM, 12, 24); + +namespace { +// Alias for checker function +const auto check = subsystem::checkInsert; +void buildOffSequence(Subsystem& ss, ModeListEntry& eh); +void buildNormalSequence(Subsystem& ss, ModeListEntry& eh); +} // namespace + +static const auto OFF = HasModesIF::MODE_OFF; +static const auto NML = DeviceHandlerIF::MODE_NORMAL; + +auto EPS_SEQUENCE_OFF = std::make_pair(OFF, FixedArrayList()); +auto EPS_TABLE_OFF_TGT = std::make_pair((OFF << 24) | 1, FixedArrayList()); +auto EPS_TABLE_OFF_TRANS_0 = std::make_pair((OFF << 24) | 2, FixedArrayList()); +auto EPS_TABLE_OFF_TRANS_1 = std::make_pair((OFF << 24) | 3, FixedArrayList()); + +auto EPS_SEQUENCE_NORMAL = std::make_pair(NML, FixedArrayList()); +auto EPS_TABLE_NORMAL_TGT = std::make_pair((NML << 24) | 1, FixedArrayList()); +auto EPS_TABLE_NORMAL_TRANS_0 = std::make_pair((NML << 24) | 2, FixedArrayList()); +auto EPS_TABLE_NORMAL_TRANS_1 = std::make_pair((NML << 24) | 3, FixedArrayList()); + +Subsystem& satsystem::eps::init() { + ModeListEntry entry; + buildOffSequence(SUBSYSTEM, entry); + buildNormalSequence(SUBSYSTEM, entry); + SUBSYSTEM.setInitialMode(OFF); + return SUBSYSTEM; +} + +namespace { + +void buildOffSequence(Subsystem& ss, ModeListEntry& eh) {} + +void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) {} // namespace diff --git a/mission/system/power/epsModeTree.h b/mission/system/power/epsModeTree.h new file mode 100644 index 00000000..3bf6708a --- /dev/null +++ b/mission/system/power/epsModeTree.h @@ -0,0 +1,15 @@ +#ifndef MISSION_SYSTEM_TREE_EPSMODETREE_H_ +#define MISSION_SYSTEM_TREE_EPSMODETREE_H_ + +#include + +namespace satsystem { +namespace eps { + +extern EpsSubsystem SUBSYSTEM; +Subsystem& init(); + +} // namespace eps +} // namespace satsystem + +#endif /* MISSION_SYSTEM_TREE_EPSMODETREE_H_ */ diff --git a/mission/system/systemTree.cpp b/mission/system/systemTree.cpp index 10c40617..6c45a813 100644 --- a/mission/system/systemTree.cpp +++ b/mission/system/systemTree.cpp @@ -11,6 +11,7 @@ #include "eive/objects.h" #include "mission/com/defs.h" #include "mission/system/acs/acsModeTree.h" +#include "mission/system/power/epsModeTree.h" #include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" #include "treeUtil.h" @@ -40,6 +41,8 @@ void satsystem::init(bool commandPlPcdu1) { tcsSubsystem.connectModeTreeParent(EIVE_SYSTEM); auto& comSubsystem = com::init(); comSubsystem.connectModeTreeParent(EIVE_SYSTEM); + auto& epsSubsystem = eps::init(); + epsSubsystem.connectModeTreeParent(EIVE_SYSTEM); ModeListEntry entry; buildBootSequence(EIVE_SYSTEM, entry); buildSafeSequence(EIVE_SYSTEM, entry); From a1a1c3aef9959001f679f8e29e4127c3f93e6e64 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 13 Sep 2023 16:29:54 +0200 Subject: [PATCH 17/67] biggest changes possible --- mission/controller/PowerController.cpp | 12 +++++++++--- mission/controller/PowerController.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 58177313..d10f233c 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -1,4 +1,3 @@ - #include PowerController::PowerController(object_id_t objectId, bool enableHkSets) @@ -89,6 +88,9 @@ void PowerController::performControlOperation() { // if (mode != MODE_OFF) { sif::debug << "oh shit, now i gotta do something" << std::endl; calculateStateOfCharge(); + if (mode == MODE_NORMAL) { + watchStateOfCharge(); + } // do something //} break; @@ -204,9 +206,13 @@ void PowerController::calculateStateOfCharge() { } } +void PowerController::watchStateOfCharge() { + // ToDo: FDIR +} + ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { float vBatCorrected = p60CoreHk.batteryVoltage.value - iBat * batteryInternalResistance; - uint8_t lookUpTableIdx = 99; + uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); if (result != returnvalue::OK) { return result; @@ -289,7 +295,7 @@ ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &i } ReturnValue_t PowerController::calculateCoulombCounterChargeUpperThreshold() { - uint8_t lookUpTableIdx = 99; + uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = lookUpTableOcvIdxFinder(coulombCounterVoltageUpperThreshold, lookUpTableIdx); if (result != returnvalue::OK) { diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index e7f9383c..700860bc 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -43,6 +43,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM void performControlOperation() override; void calculateStateOfCharge(); + void watchStateOfCharge(); ReturnValue_t calculateOpenCircuitVoltageCharge(); ReturnValue_t calculateCoulombCounterCharge(); ReturnValue_t updateEpsData(); @@ -58,6 +59,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM double maxAllowedTimeDiff = 0.5; // [s] // OCV Look-up-Table + static constexpr uint8_t LOOK_UP_TABLE_MAX_IDX = 99; float lookUpTableOcv[2][100] = { {0.00000000e+00, 3.16227766e-04, 4.52809661e-04, 6.48382625e-04, 9.28425483e-04, 1.32942162e-03, 1.90361194e-03, 2.72580074e-03, 3.90310099e-03, 5.58888885e-03, From 09951edbbadf46ce8fcf9bb12dcb573ba0a8b187 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 15 Sep 2023 10:05:04 +0200 Subject: [PATCH 18/67] removed deprecated input --- mission/controller/PowerController.cpp | 12 ------------ mission/controller/PowerController.h | 3 --- 2 files changed, 15 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index d10f233c..c87da007 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -250,18 +250,6 @@ ReturnValue_t PowerController::updateEpsData() { PoolReadGuard pgP60(&p60CoreHk); results.push_back(pgP60.getReadResult()); } - { - PoolReadGuard pgPdu1(&pdu1CoreHk); - results.push_back(pgPdu1.getReadResult()); - } - { - PoolReadGuard pgPdu2(&pdu2CoreHk); - results.push_back(pgPdu2.getReadResult()); - } - { - PoolReadGuard pgAcu(&acuCoreHk); - results.push_back(pgAcu.getReadResult()); - } for (const auto &result : results) { if (result != returnvalue::OK) { return result; diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 700860bc..cd984840 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -111,9 +111,6 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM // HK Datasets for Calculation BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); P60Dock::CoreHkSet p60CoreHk = P60Dock::CoreHkSet(objects::P60DOCK_HANDLER); - PDU1::Pdu1CoreHk pdu1CoreHk = PDU1::Pdu1CoreHk(objects::PDU1_HANDLER); - PDU2::Pdu2CoreHk pdu2CoreHk = PDU2::Pdu2CoreHk(objects::PDU2_HANDLER); - ACU::CoreHk acuCoreHk = ACU::CoreHk(objects::ACU_HANDLER); // Output Dataset pwrctrl::CoreHk pwrCtrlCoreHk; }; From f2e15bb13447fb7b8dea1c98a019db50eedb7149 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 20 Sep 2023 09:18:52 +0200 Subject: [PATCH 19/67] fixed wrong type --- mission/controller/PowerController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index cd984840..bfb28b52 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -105,7 +105,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float coulombCounterCharge = 0; // [mC] float coulombCounterChargeUpperThreshold = 0.0; // [mC] - static constexpr float INVALID_TOTAL_BATTERY_CURRENT = 0; + static constexpr int16_t INVALID_TOTAL_BATTERY_CURRENT = 0; static constexpr float INVALID_SOC = -1; // HK Datasets for Calculation From 5036836b442cd309fc8079cd445e8ab9a3bd056a Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 20 Sep 2023 09:19:09 +0200 Subject: [PATCH 20/67] use bpx voltage instead --- mission/controller/PowerController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index c87da007..c4bd6ae6 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -211,7 +211,7 @@ void PowerController::watchStateOfCharge() { } ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { - float vBatCorrected = p60CoreHk.batteryVoltage.value - iBat * batteryInternalResistance; + float vBatCorrected = bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance; uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); if (result != returnvalue::OK) { @@ -231,7 +231,7 @@ ReturnValue_t PowerController::calculateCoulombCounterCharge() { return returnvalue::FAILED; } if ((not pwrCtrlCoreHk.coulombCounterCharge.isValid()) or - (p60CoreHk.batteryVoltage.value > coulombCounterVoltageUpperThreshold and + (bpxBatteryHk.battVoltage.value > coulombCounterVoltageUpperThreshold and pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) { coulombCounterCharge = openCircuitVoltageCharge; } else { From 6b9e19198888d2f02710c34fea736a277853e38c Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 22 Sep 2023 10:08:04 +0200 Subject: [PATCH 21/67] fixed voltage bugs --- mission/controller/PowerController.cpp | 5 +++-- mission/controller/PowerController.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index c4bd6ae6..475c026b 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -211,7 +211,8 @@ void PowerController::watchStateOfCharge() { } ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { - float vBatCorrected = bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance; + float vBatCorrected = + (bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance) * MILLIVOLT2VOLT; uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); if (result != returnvalue::OK) { @@ -267,7 +268,7 @@ float PowerController::linearInterpolation(float x, float x0, float x1, float y0 } ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) { - if (voltage >= lookUpTableOcv[1][100]) { + if (voltage >= lookUpTableOcv[1][99]) { triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0); sif::error << "Power Controller::Voltage is too high" << std::endl; return returnvalue::FAILED; diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index bfb28b52..c26e9382 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -105,6 +105,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float coulombCounterCharge = 0; // [mC] float coulombCounterChargeUpperThreshold = 0.0; // [mC] + static constexpr float MILLIVOLT2VOLT = 1e-3; + static constexpr int16_t INVALID_TOTAL_BATTERY_CURRENT = 0; static constexpr float INVALID_SOC = -1; From 0ad3f508a905f5579983c228d01e3c2a5472ae77 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 22 Sep 2023 16:07:26 +0200 Subject: [PATCH 22/67] further fixes --- mission/controller/PowerController.cpp | 5 +++-- mission/controller/PowerController.h | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 475c026b..c47e2c21 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -212,7 +212,7 @@ void PowerController::watchStateOfCharge() { ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { float vBatCorrected = - (bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance) * MILLIVOLT2VOLT; + (bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance) * CONVERT_FROM_MILLI; uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); if (result != returnvalue::OK) { @@ -236,7 +236,8 @@ ReturnValue_t PowerController::calculateCoulombCounterCharge() { pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) { coulombCounterCharge = openCircuitVoltageCharge; } else { - coulombCounterCharge = pwrCtrlCoreHk.coulombCounterCharge.value + iBat * timeDiff; + coulombCounterCharge = + coulombCounterCharge + iBat * CONVERT_FROM_MILLI * timeDiff * SECONDS_TO_HOURS; } return returnvalue::OK; } diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index c26e9382..fbd2709b 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -58,7 +58,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float coulombCounterVoltageUpperThreshold = 16.2e3; // [mV] double maxAllowedTimeDiff = 0.5; // [s] - // OCV Look-up-Table + // OCV Look-up-Table {[Ah],[V]} static constexpr uint8_t LOOK_UP_TABLE_MAX_IDX = 99; float lookUpTableOcv[2][100] = { {0.00000000e+00, 3.16227766e-04, 4.52809661e-04, 6.48382625e-04, 9.28425483e-04, @@ -100,12 +100,13 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM // Variables timeval now; timeval oldTime; - int16_t iBat = 0.0; // [mA] - float openCircuitVoltageCharge = 0.0; // [mC] - float coulombCounterCharge = 0; // [mC] - float coulombCounterChargeUpperThreshold = 0.0; // [mC] + int16_t iBat = 0; // [mA] + float openCircuitVoltageCharge = 0.0; // [Ah] + float coulombCounterCharge = 0.0; // [Ah] + float coulombCounterChargeUpperThreshold = 0.0; // [Ah] - static constexpr float MILLIVOLT2VOLT = 1e-3; + static constexpr float CONVERT_FROM_MILLI = 1e-3; + static constexpr float SECONDS_TO_HOURS = 1. / (60. * 60.); static constexpr int16_t INVALID_TOTAL_BATTERY_CURRENT = 0; static constexpr float INVALID_SOC = -1; From 209e0c68fb990f2e43d7faaf921ef597ad41e721 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 26 Sep 2023 11:56:04 +0200 Subject: [PATCH 23/67] fixes --- mission/controller/PowerController.cpp | 19 +++++++++++++------ mission/power/defs.h | 3 +-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index c47e2c21..1e45a902 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -150,6 +150,8 @@ void PowerController::calculateStateOfCharge() { pwrCtrlCoreHk.setValidity(false, true); } } + // store time for next run + oldTime = now; return; } @@ -171,12 +173,12 @@ void PowerController::calculateStateOfCharge() { pwrCtrlCoreHk.coulombCounterCharge.setValid(false); } } + // store time for next run + oldTime = now; return; } result = calculateCoulombCounterCharge(); - // store time for next run - oldTime = now; if (result != returnvalue::OK) { // notifying events have already been triggered { @@ -191,6 +193,8 @@ void PowerController::calculateStateOfCharge() { pwrCtrlCoreHk.coulombCounterCharge.setValid(false); } } + // store time for next run + oldTime = now; return; } @@ -204,6 +208,8 @@ void PowerController::calculateStateOfCharge() { pwrCtrlCoreHk.setValidity(true, true); } } + // store time for next run + oldTime = now; } void PowerController::watchStateOfCharge() { @@ -231,13 +237,14 @@ ReturnValue_t PowerController::calculateCoulombCounterCharge() { sif::error << "Power Controller::Time delta too large for Coulomb Counter" << std::endl; return returnvalue::FAILED; } - if ((not pwrCtrlCoreHk.coulombCounterCharge.isValid()) or - (bpxBatteryHk.battVoltage.value > coulombCounterVoltageUpperThreshold and - pwrCtrlCoreHk.coulombCounterCharge.value >= coulombCounterChargeUpperThreshold)) { + if (not pwrCtrlCoreHk.coulombCounterCharge.isValid()) { coulombCounterCharge = openCircuitVoltageCharge; } else { coulombCounterCharge = coulombCounterCharge + iBat * CONVERT_FROM_MILLI * timeDiff * SECONDS_TO_HOURS; + if (coulombCounterCharge >= coulombCounterChargeUpperThreshold) { + coulombCounterCharge = coulombCounterChargeUpperThreshold; + } } return returnvalue::OK; } @@ -261,7 +268,7 @@ ReturnValue_t PowerController::updateEpsData() { } float PowerController::charge2stateOfCharge(float capacity) { - return capacity / batteryMaximumCapacity; + return capacity / coulombCounterChargeUpperThreshold; } float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) { diff --git a/mission/power/defs.h b/mission/power/defs.h index 87fc3f08..375aaf6e 100644 --- a/mission/power/defs.h +++ b/mission/power/defs.h @@ -54,8 +54,7 @@ static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, s //! P1: 1 too high, 0 too low static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH); //! [EXPORT] : [COMMENT] Time difference for Coulomb Counter was too large. -static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = - event::makeEvent(SUBSYSTEM_ID, 6, severity::MEDIUM); +static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 6, severity::LOW); enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING }; enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED }; From 23b15cf3029b4f0ce0daeb2fb04b93723f7850a7 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 27 Sep 2023 11:55:33 +0200 Subject: [PATCH 24/67] add EPS to transitions --- mission/system/power/epsModeTree.cpp | 73 ++++++++++++++++++++++++++-- mission/system/systemTree.cpp | 14 ++++-- 2 files changed, 79 insertions(+), 8 deletions(-) diff --git a/mission/system/power/epsModeTree.cpp b/mission/system/power/epsModeTree.cpp index feeb6e5d..dbc67fd7 100644 --- a/mission/system/power/epsModeTree.cpp +++ b/mission/system/power/epsModeTree.cpp @@ -20,23 +20,86 @@ static const auto NML = DeviceHandlerIF::MODE_NORMAL; auto EPS_SEQUENCE_OFF = std::make_pair(OFF, FixedArrayList()); auto EPS_TABLE_OFF_TGT = std::make_pair((OFF << 24) | 1, FixedArrayList()); auto EPS_TABLE_OFF_TRANS_0 = std::make_pair((OFF << 24) | 2, FixedArrayList()); -auto EPS_TABLE_OFF_TRANS_1 = std::make_pair((OFF << 24) | 3, FixedArrayList()); auto EPS_SEQUENCE_NORMAL = std::make_pair(NML, FixedArrayList()); auto EPS_TABLE_NORMAL_TGT = std::make_pair((NML << 24) | 1, FixedArrayList()); auto EPS_TABLE_NORMAL_TRANS_0 = std::make_pair((NML << 24) | 2, FixedArrayList()); -auto EPS_TABLE_NORMAL_TRANS_1 = std::make_pair((NML << 24) | 3, FixedArrayList()); Subsystem& satsystem::eps::init() { ModeListEntry entry; buildOffSequence(SUBSYSTEM, entry); buildNormalSequence(SUBSYSTEM, entry); - SUBSYSTEM.setInitialMode(OFF); + SUBSYSTEM.setInitialMode(NML); return SUBSYSTEM; } namespace { -void buildOffSequence(Subsystem& ss, ModeListEntry& eh) {} +void buildOffSequence(Subsystem& ss, ModeListEntry& eh) { + std::string context = "satsystem::eps::buildOffSequence"; + auto ctxc = context.c_str(); + // Insert Helper Table + auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode, ArrayList& table) { + eh.setObject(obj); + eh.setMode(mode); + eh.setSubmode(submode); + check(table.insert(eh), ctxc); + }; + // Insert Helper Sequence + auto ihs = [&](ArrayList& sequence, Mode_t tableId, uint32_t waitSeconds, + bool checkSuccess) { + eh.setTableId(tableId); + eh.setWaitSeconds(waitSeconds); + eh.setCheckSuccess(checkSuccess); + check(sequence.insert(eh), ctxc); + }; -void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) {} // namespace + // OFF target table is empty + check(ss.addTable(TableEntry(EPS_TABLE_OFF_TGT.first, &EPS_TABLE_OFF_TGT.second)), ctxc); + + // Transition 0 + iht(objects::POWER_CONTROLLER, OFF, 0, EPS_TABLE_OFF_TRANS_0.second); + check(ss.addTable(TableEntry(EPS_TABLE_OFF_TRANS_0.first, &EPS_TABLE_OFF_TRANS_0.second)), ctxc); + + ihs(EPS_SEQUENCE_OFF.second, EPS_TABLE_OFF_TGT.first, 0, false); + ihs(EPS_SEQUENCE_OFF.second, EPS_TABLE_OFF_TRANS_0.first, 0, false); + check(ss.addSequence(SequenceEntry(EPS_SEQUENCE_OFF.first, &EPS_SEQUENCE_OFF.second, + EPS_SEQUENCE_OFF.first)), + ctxc); +} +} // namespace + +void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) { + std::string context = "satsystem::tcs::buildNormalSequence"; + auto ctxc = context.c_str(); + // Insert Helper Table + auto iht = [&](object_id_t obj, Mode_t mode, Submode_t submode, ArrayList& table) { + eh.setObject(obj); + eh.setMode(mode); + eh.setSubmode(submode); + check(table.insert(eh), ctxc); + }; + // Insert Helper Sequence + auto ihs = [&](ArrayList& sequence, Mode_t tableId, uint32_t waitSeconds, + bool checkSuccess) { + eh.setTableId(tableId); + eh.setWaitSeconds(waitSeconds); + eh.setCheckSuccess(checkSuccess); + check(sequence.insert(eh), ctxc); + }; + + // Normal target table + iht(objects::POWER_CONTROLLER, NML, 0, EPS_TABLE_NORMAL_TGT.second); + check(ss.addTable(TableEntry(EPS_TABLE_NORMAL_TGT.first, &EPS_TABLE_NORMAL_TGT.second)), ctxc); + + // Transition 0 + iht(objects::POWER_CONTROLLER, NML, 0, EPS_TABLE_NORMAL_TRANS_0.second); + check(ss.addTable(TableEntry(EPS_TABLE_NORMAL_TRANS_0.first, &EPS_TABLE_NORMAL_TRANS_0.second)), + ctxc); + + ihs(EPS_SEQUENCE_NORMAL.second, EPS_TABLE_NORMAL_TGT.first, 0, false); + ihs(EPS_SEQUENCE_NORMAL.second, EPS_TABLE_NORMAL_TRANS_0.first, 0, false); + check(ss.addSequence(SequenceEntry(EPS_SEQUENCE_NORMAL.first, &EPS_SEQUENCE_NORMAL.second, + EPS_SEQUENCE_NORMAL.first)), + ctxc); +} // namespace diff --git a/mission/system/systemTree.cpp b/mission/system/systemTree.cpp index 6c45a813..c9894f21 100644 --- a/mission/system/systemTree.cpp +++ b/mission/system/systemTree.cpp @@ -144,9 +144,11 @@ void buildBootSequence(Subsystem& ss, ModeListEntry& eh) { iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TGT.second); iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); + iht(objects::EPS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TGT.second); check(ss.addTable(TableEntry(EIVE_TABLE_BOOT_TGT.first, &EIVE_TABLE_BOOT_TGT.second)), ctxc); - // Build SAFE transition 0. + // Build BOOT transition 0. + iht(objects::EPS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); iht(objects::COM_SUBSYSTEM, com::RX_ONLY, 0, EIVE_TABLE_BOOT_TRANS_0.second); iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_BOOT_TRANS_0.second); @@ -154,7 +156,7 @@ void buildBootSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addTable(TableEntry(EIVE_TABLE_BOOT_TRANS_0.first, &EIVE_TABLE_BOOT_TRANS_0.second)), ctxc); - // Build Safe sequence + // Build BOOT sequence ihs(EIVE_SEQUENCE_BOOT.second, EIVE_TABLE_BOOT_TGT.first, 0, false); ihs(EIVE_SEQUENCE_BOOT.second, EIVE_TABLE_BOOT_TRANS_0.first, 0, false); check(ss.addSequence(SequenceEntry(EIVE_SEQUENCE_BOOT.first, &EIVE_SEQUENCE_BOOT.second, @@ -190,13 +192,14 @@ void buildSafeSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addTable(TableEntry(EIVE_TABLE_SAFE_TGT.first, &EIVE_TABLE_SAFE_TGT.second)), ctxc); // Build SAFE transition 0. + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::PL_SUBSYSTEM, OFF, 0, EIVE_TABLE_SAFE_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::SAFE, 0, EIVE_TABLE_SAFE_TRANS_0.second, true); check(ss.addTable(TableEntry(EIVE_TABLE_SAFE_TRANS_0.first, &EIVE_TABLE_SAFE_TRANS_0.second)), ctxc); - // Build Safe sequence + // Build SAFE sequence ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TGT.first, 0, false); ihs(EIVE_SEQUENCE_SAFE.second, EIVE_TABLE_SAFE_TRANS_0.first, 0, false); check(ss.addSequence(SequenceEntry(EIVE_SEQUENCE_SAFE.first, &EIVE_SEQUENCE_SAFE.second, @@ -227,6 +230,7 @@ void buildIdleSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addTable(TableEntry(EIVE_TABLE_IDLE_TGT.first, &EIVE_TABLE_IDLE_TGT.second)), ctxc); // Build IDLE transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_IDLE_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_IDLE_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_IDLE, 0, EIVE_TABLE_IDLE_TRANS_0.second); check(ss.addTable(TableEntry(EIVE_TABLE_IDLE_TRANS_0.first, &EIVE_TABLE_IDLE_TRANS_0.second)), @@ -264,6 +268,7 @@ void buildPtgNadirSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_NADIR transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_NADIR_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_NADIR_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_NADIR, 0, EIVE_TABLE_PTG_NADIR_TRANS_0.second); check(ss.addTable( @@ -302,6 +307,7 @@ void buildPtgTargetSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_TARGET transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_TARGET, 0, EIVE_TABLE_PTG_TARGET_TRANS_0.second); check(ss.addTable( @@ -341,6 +347,7 @@ void buildPtgTargetGsSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_TARGET_GS transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_GS_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_TARGET_GS_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_TARGET_GS, 0, EIVE_TABLE_PTG_TARGET_GS_TRANS_0.second); @@ -382,6 +389,7 @@ void buildPtgInertialSequence(Subsystem& ss, ModeListEntry& eh) { ctxc); // Build PTG_INERTIAL transition 0 + iht(objects::EPS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_INERTIAL_TRANS_0.second); iht(objects::TCS_SUBSYSTEM, NML, 0, EIVE_TABLE_PTG_INERTIAL_TRANS_0.second); iht(objects::ACS_SUBSYSTEM, acs::AcsMode::PTG_INERTIAL, 0, EIVE_TABLE_PTG_INERTIAL_TRANS_0.second); From b7ccb8b41dd93aa838337f62770055b3fbbee69d Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 27 Sep 2023 13:00:18 +0200 Subject: [PATCH 25/67] cmake --- mission/system/power/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/system/power/CMakeLists.txt b/mission/system/power/CMakeLists.txt index 8fa4967e..a7e91e05 100644 --- a/mission/system/power/CMakeLists.txt +++ b/mission/system/power/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE GomspacePowerFdir.cpp) +target_sources(${LIB_EIVE_MISSION} PRIVATE epsModeTree.cpp EpsSubsystem.cpp GomspacePowerFdir.cpp) From 063a7efc6b9fc2feff3834bd7a889398c215c240 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 27 Sep 2023 13:00:29 +0200 Subject: [PATCH 26/67] fixed include --- mission/system/power/EpsSubsystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/system/power/EpsSubsystem.cpp b/mission/system/power/EpsSubsystem.cpp index 8d402553..2ec4155b 100644 --- a/mission/system/power/EpsSubsystem.cpp +++ b/mission/system/power/EpsSubsystem.cpp @@ -1,4 +1,4 @@ -#include +#include #include "fsfw/devicehandlers/DeviceHandlerIF.h" From 1973bd2c5b4fee75bddc2c668490813f7d76b5c8 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 27 Sep 2023 13:07:18 +0200 Subject: [PATCH 27/67] fix --- mission/system/power/epsModeTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/system/power/epsModeTree.cpp b/mission/system/power/epsModeTree.cpp index dbc67fd7..c28669f9 100644 --- a/mission/system/power/epsModeTree.cpp +++ b/mission/system/power/epsModeTree.cpp @@ -67,7 +67,6 @@ void buildOffSequence(Subsystem& ss, ModeListEntry& eh) { EPS_SEQUENCE_OFF.first)), ctxc); } -} // namespace void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) { std::string context = "satsystem::tcs::buildNormalSequence"; @@ -102,4 +101,5 @@ void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) { check(ss.addSequence(SequenceEntry(EPS_SEQUENCE_NORMAL.first, &EPS_SEQUENCE_NORMAL.second, EPS_SEQUENCE_NORMAL.first)), ctxc); +} } // namespace From c486bb2cf38b757adf1b91ec19b2b35d4ccb5e98 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 27 Sep 2023 14:46:45 +0200 Subject: [PATCH 28/67] pwr ctrl fdir --- mission/controller/PowerController.cpp | 21 ++++++++++++++++++++- mission/controller/PowerController.h | 5 +++++ mission/power/defs.h | 6 ++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 1e45a902..12ed5216 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -54,6 +54,12 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI case 0x3: parameterWrapper->set(maxAllowedTimeDiff); break; + case 0x4: + parameterWrapper->set(payloadLimit); + break; + case 0x5: + parameterWrapper->set(higherModesLimit); + break; default: return INVALID_IDENTIFIER_ID; } @@ -213,7 +219,20 @@ void PowerController::calculateStateOfCharge() { } void PowerController::watchStateOfCharge() { - // ToDo: FDIR + if (pwrCtrlCoreHk.coulombCounterCharge.isValid()) { + if (not pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value < payloadLimit) { + triggerEvent(power::POWER_LEVEL_LOW); + pwrLvlLowFlag = true; + } else { + pwrLvlLowFlag = false; + } + if (not pwrLvlCriticalFlag and pwrCtrlCoreHk.coulombCounterCharge.value < higherModesLimit) { + triggerEvent(power::POWER_LEVEL_CRITICAL); + pwrLvlCriticalFlag = true; + } else { + pwrLvlCriticalFlag = false; + } + } } ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index fbd2709b..e7031ad8 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -57,6 +57,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float batteryMaximumCapacity = 2.6 * 2; // [Ah] float coulombCounterVoltageUpperThreshold = 16.2e3; // [mV] double maxAllowedTimeDiff = 0.5; // [s] + float payloadLimit = 0.75; // [%] + float higherModesLimit = 0.6; // [%] // OCV Look-up-Table {[Ah],[V]} static constexpr uint8_t LOOK_UP_TABLE_MAX_IDX = 99; @@ -111,6 +113,9 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM static constexpr int16_t INVALID_TOTAL_BATTERY_CURRENT = 0; static constexpr float INVALID_SOC = -1; + bool pwrLvlLowFlag = false; + bool pwrLvlCriticalFlag = false; + // HK Datasets for Calculation BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); P60Dock::CoreHkSet p60CoreHk = P60Dock::CoreHkSet(objects::P60DOCK_HANDLER); diff --git a/mission/power/defs.h b/mission/power/defs.h index 375aaf6e..22a8af53 100644 --- a/mission/power/defs.h +++ b/mission/power/defs.h @@ -55,6 +55,12 @@ static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, s static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH); //! [EXPORT] : [COMMENT] Time difference for Coulomb Counter was too large. static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 6, severity::LOW); +//! [EXPORT] : [COMMENT] The State of Charge is below the limit for payload use. Setting Payload to +//! faulty. +static constexpr Event POWER_LEVEL_LOW = event::makeEvent(SUBSYSTEM_ID, 7, severity::HIGH); +//! [EXPORT] : [COMMENT] The State of Charge is below the limit for higher modes. Setting Reaction +//! Wheels to faulty. +static constexpr Event POWER_LEVEL_CRITICAL = event::makeEvent(SUBSYSTEM_ID, 8, severity::HIGH); enum class States { IDLE, SWITCHING_POWER, CHECKING_POWER, MODE_COMMANDING }; enum class OpCodes { NONE, TO_OFF_DONE, TO_NOT_OFF_DONE, TIMEOUT_OCCURED }; From 6a77635bfb9dd095e5e8d10dbec931ed8d25039b Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 27 Sep 2023 16:36:09 +0200 Subject: [PATCH 29/67] soc calculation fixes --- mission/controller/PowerController.cpp | 17 ++++++++++------- mission/controller/PowerController.h | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 12ed5216..1eb3abaf 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -162,8 +162,7 @@ void PowerController::calculateStateOfCharge() { } // calculate total battery current - iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.heaterCurrent.value + - bpxBatteryHk.dischargeCurrent.value; + iBat = p60CoreHk.batteryCurrent.value + bpxBatteryHk.dischargeCurrent.value; result = calculateOpenCircuitVoltageCharge(); if (result != returnvalue::OK) { @@ -193,7 +192,7 @@ void PowerController::calculateStateOfCharge() { pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; pwrCtrlCoreHk.totalBatteryCurrent.setValid(true); pwrCtrlCoreHk.openCircuitVoltageCharge.value = - charge2stateOfCharge(openCircuitVoltageCharge); + charge2stateOfCharge(openCircuitVoltageCharge, false); pwrCtrlCoreHk.openCircuitVoltageCharge.setValid(true); pwrCtrlCoreHk.coulombCounterCharge.value = INVALID_SOC; pwrCtrlCoreHk.coulombCounterCharge.setValid(false); @@ -209,8 +208,9 @@ void PowerController::calculateStateOfCharge() { PoolReadGuard pg(&pwrCtrlCoreHk); if (pg.getReadResult() == returnvalue::OK) { pwrCtrlCoreHk.totalBatteryCurrent.value = iBat; - pwrCtrlCoreHk.openCircuitVoltageCharge.value = charge2stateOfCharge(openCircuitVoltageCharge); - pwrCtrlCoreHk.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge); + pwrCtrlCoreHk.openCircuitVoltageCharge.value = + charge2stateOfCharge(openCircuitVoltageCharge, false); + pwrCtrlCoreHk.coulombCounterCharge.value = charge2stateOfCharge(coulombCounterCharge, true); pwrCtrlCoreHk.setValidity(true, true); } } @@ -286,8 +286,11 @@ ReturnValue_t PowerController::updateEpsData() { return returnvalue::OK; } -float PowerController::charge2stateOfCharge(float capacity) { - return capacity / coulombCounterChargeUpperThreshold; +float PowerController::charge2stateOfCharge(float capacity, bool coulombCounter) { + if (coulombCounter) { + return capacity / coulombCounterChargeUpperThreshold; + } + return capacity / batteryMaximumCapacity; } float PowerController::linearInterpolation(float x, float x0, float x1, float y0, float y1) { diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index e7031ad8..81522023 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -47,7 +47,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM ReturnValue_t calculateOpenCircuitVoltageCharge(); ReturnValue_t calculateCoulombCounterCharge(); ReturnValue_t updateEpsData(); - float charge2stateOfCharge(float capacity); + float charge2stateOfCharge(float capacity, bool coulombCounter); ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx); float linearInterpolation(float x, float x0, float x1, float y0, float y1); ReturnValue_t calculateCoulombCounterChargeUpperThreshold(); From 173ee62d39dda1b0ab05154b6cdf6d376f1b2652 Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 28 Sep 2023 12:00:04 +0200 Subject: [PATCH 30/67] connect pwr ctrl to eps --- bsp_q7s/em/emObjectFactory.cpp | 2 +- bsp_q7s/fmObjectFactory.cpp | 2 +- linux/ObjectFactory.cpp | 6 +++++- linux/ObjectFactory.h | 2 +- mission/system/power/epsModeTree.cpp | 10 +++++----- mission/system/power/epsModeTree.h | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 9b106dd2..94e10784 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -178,7 +178,7 @@ void ObjectFactory::produce(void* args) { power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); #endif createAcsController(true, enableHkSets); - createPowerController(enableHkSets); + createPowerController(true, enableHkSets); HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); createThermalController(*heaterHandler, true); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index 8e1672a8..c6dc1d28 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -132,6 +132,6 @@ void ObjectFactory::produce(void* args) { createMiscComponents(); createThermalController(*heaterHandler, false); createAcsController(true, enableHkSets); - createPowerController(enableHkSets); + createPowerController(true, enableHkSets); satsystem::init(false); } diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index b74057c1..cb3e043b 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -28,6 +28,7 @@ #include "devices/gpioIds.h" #include "eive/definitions.h" #include "mission/system/acs/acsModeTree.h" +#include "mission/system/power/epsModeTree.h" #include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" #include "mission/tcs/defs.h" @@ -338,8 +339,11 @@ AcsController* ObjectFactory::createAcsController(bool connectSubsystem, bool en return acsCtrl; } -PowerController* ObjectFactory::createPowerController(bool enableHkSets) { +PowerController* ObjectFactory::createPowerController(bool connectSubsystem, bool enableHkSets) { auto pwrCtrl = new PowerController(objects::POWER_CONTROLLER, enableHkSets); + if (connectSubsystem) { + pwrCtrl->connectModeTreeParent(satsystem::eps::EPS_SUBSYSTEM); + } return pwrCtrl; } diff --git a/linux/ObjectFactory.h b/linux/ObjectFactory.h index d8605f48..46baa685 100644 --- a/linux/ObjectFactory.h +++ b/linux/ObjectFactory.h @@ -32,6 +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); +PowerController* createPowerController(bool connectSubsystem, bool enableHkSets); } // namespace ObjectFactory diff --git a/mission/system/power/epsModeTree.cpp b/mission/system/power/epsModeTree.cpp index c28669f9..7c81b38f 100644 --- a/mission/system/power/epsModeTree.cpp +++ b/mission/system/power/epsModeTree.cpp @@ -5,7 +5,7 @@ #include "fsfw/subsystem/Subsystem.h" #include "mission/system/treeUtil.h" -EpsSubsystem satsystem::eps::SUBSYSTEM(objects::EPS_SUBSYSTEM, 12, 24); +EpsSubsystem satsystem::eps::EPS_SUBSYSTEM(objects::EPS_SUBSYSTEM, 12, 24); namespace { // Alias for checker function @@ -27,10 +27,10 @@ auto EPS_TABLE_NORMAL_TRANS_0 = std::make_pair((NML << 24) | 2, FixedArrayList Date: Thu, 28 Sep 2023 12:00:48 +0200 Subject: [PATCH 31/67] remove comments for mode handling --- mission/controller/PowerController.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 1eb3abaf..9347f681 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -91,14 +91,13 @@ void PowerController::performControlOperation() { return; } case InternalState::READY: { - // if (mode != MODE_OFF) { - sif::debug << "oh shit, now i gotta do something" << std::endl; - calculateStateOfCharge(); - if (mode == MODE_NORMAL) { - watchStateOfCharge(); + if (mode != MODE_OFF) { + sif::debug << "oh shit, now i gotta do something" << std::endl; + calculateStateOfCharge(); + if (mode == MODE_NORMAL) { + watchStateOfCharge(); + } } - // do something - //} break; } default: From eb84b5bb870c870d3188436e859be94fe499908e Mon Sep 17 00:00:00 2001 From: meggert Date: Thu, 28 Sep 2023 13:09:53 +0200 Subject: [PATCH 32/67] schedule pwr ctrl with bpx again --- common/config/eive/definitions.h | 3 +++ mission/pollingSeqTables.cpp | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/config/eive/definitions.h b/common/config/eive/definitions.h index b369f512..d446aa8d 100644 --- a/common/config/eive/definitions.h +++ b/common/config/eive/definitions.h @@ -79,6 +79,7 @@ static constexpr uint32_t SCHED_BLOCK_RTD = 150; static constexpr uint32_t SCHED_BLOCK_7_RW_READ_MS = 300; static constexpr uint32_t SCHED_BLOCK_8_PLPCDU_MS = 320; static constexpr uint32_t SCHED_BLOCK_9_RAD_SENS_MS = 340; +static constexpr uint32_t SCHED_BLOCK_10_PWR_CTRL_MS = 350; // 15 ms for FM static constexpr float SCHED_BLOCK_1_PERIOD = static_cast(SCHED_BLOCK_1_SUS_READ_MS) / 400.0; @@ -94,6 +95,8 @@ static constexpr float SCHED_BLOCK_RTD_PERIOD = static_cast(SCHED_BLOCK_R static constexpr float SCHED_BLOCK_7_PERIOD = static_cast(SCHED_BLOCK_7_RW_READ_MS) / 400.0; static constexpr float SCHED_BLOCK_8_PERIOD = static_cast(SCHED_BLOCK_8_PLPCDU_MS) / 400.0; static constexpr float SCHED_BLOCK_9_PERIOD = static_cast(SCHED_BLOCK_9_RAD_SENS_MS) / 400.0; +static constexpr float SCHED_BLOCK_10_PERIOD = + static_cast(SCHED_BLOCK_10_PWR_CTRL_MS) / 400.0; } // namespace spiSched diff --git a/mission/pollingSeqTables.cpp b/mission/pollingSeqTables.cpp index e2517abd..e9adf83b 100644 --- a/mission/pollingSeqTables.cpp +++ b/mission/pollingSeqTables.cpp @@ -134,8 +134,6 @@ ReturnValue_t pst::pstGompaceCan(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::PDU2_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::ACU_HANDLER, length * 0.5, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::POWER_CONTROLLER, length * 0.6, 0); - if (thisSequence->checkSequence() != returnvalue::OK) { sif::error << "GomSpace PST initialization failed" << std::endl; return returnvalue::FAILED; @@ -605,5 +603,8 @@ ReturnValue_t pst::pstTcsAndAcs(FixedTimeslotTaskIF *thisSequence, AcsPstCfg cfg DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::RAD_SENSOR, length * config::spiSched::SCHED_BLOCK_9_PERIOD, DeviceHandlerIF::GET_READ); + + thisSequence->addSlot(objects::POWER_CONTROLLER, length * config::spiSched::SCHED_BLOCK_10_PERIOD, + 0); return returnvalue::OK; } From 61ebe5ed99f9a04aa8276d3dcc52488fa5ad0159 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 09:49:21 +0200 Subject: [PATCH 33/67] scheduled EPS subsystem --- bsp_q7s/scheduling.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bsp_q7s/scheduling.cpp b/bsp_q7s/scheduling.cpp index d7c179ad..fa7fbe18 100644 --- a/bsp_q7s/scheduling.cpp +++ b/bsp_q7s/scheduling.cpp @@ -157,6 +157,10 @@ void scheduling::initTasks() { if (result != returnvalue::OK) { scheduling::printAddObjectError("PL_SUBSYSTEM", objects::PL_SUBSYSTEM); } + result = genericSysTask->addComponent(objects::EPS_SUBSYSTEM); + if (result != returnvalue::OK) { + scheduling::printAddObjectError("EPS_SUBSYSTEM", objects::EPS_SUBSYSTEM); + } result = genericSysTask->addComponent(objects::INTERNAL_ERROR_REPORTER); if (result != returnvalue::OK) { scheduling::printAddObjectError("ERROR_REPORTER", objects::INTERNAL_ERROR_REPORTER); From 49102463f533802e51a4182cafc991b17ea7c85f Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 09:49:52 +0200 Subject: [PATCH 34/67] ran generators --- .../fsfwconfig/events/translateEvents.cpp | 19 +++++++++++++++++-- .../fsfwconfig/objects/translateObjects.cpp | 10 ++++++++-- generators/bsp_hosted_events.csv | 5 +++++ generators/bsp_hosted_objects.csv | 2 ++ generators/bsp_hosted_returnvalues.csv | 8 ++++---- generators/bsp_q7s_events.csv | 5 +++++ generators/bsp_q7s_objects.csv | 2 ++ generators/bsp_q7s_returnvalues.csv | 8 ++++---- generators/events/translateEvents.cpp | 19 +++++++++++++++++-- generators/objects/translateObjects.cpp | 10 ++++++++-- linux/fsfwconfig/events/translateEvents.cpp | 19 +++++++++++++++++-- linux/fsfwconfig/objects/translateObjects.cpp | 10 ++++++++-- 12 files changed, 97 insertions(+), 20 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index d7a9d6aa..610a69fb 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 308 translations. + * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-25 17:49:54 + * Generated on: 2023-09-28 15:53:20 */ #include "translateEvents.h" @@ -105,6 +105,11 @@ const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; const char *FDIR_REACTION_IGNORED_STRING = "FDIR_REACTION_IGNORED"; +const char *DATASET_READ_FAILED_STRING = "DATASET_READ_FAILED"; +const char *VOLTAGE_OUT_OF_BOUNDS_STRING = "VOLTAGE_OUT_OF_BOUNDS"; +const char *TIMEDELTA_OUT_OF_BOUNDS_STRING = "TIMEDELTA_OUT_OF_BOUNDS"; +const char *POWER_LEVEL_LOW_STRING = "POWER_LEVEL_LOW"; +const char *POWER_LEVEL_CRITICAL_STRING = "POWER_LEVEL_CRITICAL"; const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; const char *HEATER_WENT_ON_STRING = "HEATER_WENT_ON"; @@ -516,6 +521,16 @@ const char *translateEvents(Event event) { return SWITCHING_Q7S_DENIED_STRING; case (11303): return FDIR_REACTION_IGNORED_STRING; + case (11304): + return DATASET_READ_FAILED_STRING; + case (11305): + return VOLTAGE_OUT_OF_BOUNDS_STRING; + case (11306): + return TIMEDELTA_OUT_OF_BOUNDS_STRING; + case (11307): + return POWER_LEVEL_LOW_STRING; + case (11308): + return POWER_LEVEL_CRITICAL_STRING; case (11400): return GPIO_PULL_HIGH_FAILED_STRING; case (11401): diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index ab0c8cec..f3f7d5fb 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -1,14 +1,15 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 171 translations. - * Generated on: 2023-09-25 17:49:54 + * Contains 173 translations. + * Generated on: 2023-09-28 15:53:20 */ #include "translateObjects.h" const char *TEST_TASK_STRING = "TEST_TASK"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *POWER_CONTROLLER_STRING = "POWER_CONTROLLER"; const char *GLOBAL_JSON_CFG_STRING = "GLOBAL_JSON_CFG"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *DUMMY_HANDLER_STRING = "DUMMY_HANDLER"; @@ -164,6 +165,7 @@ const char *ACS_SUBSYSTEM_STRING = "ACS_SUBSYSTEM"; const char *PL_SUBSYSTEM_STRING = "PL_SUBSYSTEM"; const char *TCS_SUBSYSTEM_STRING = "TCS_SUBSYSTEM"; const char *COM_SUBSYSTEM_STRING = "COM_SUBSYSTEM"; +const char *EPS_SUBSYSTEM_STRING = "EPS_SUBSYSTEM"; const char *MISC_TM_STORE_STRING = "MISC_TM_STORE"; const char *OK_TM_STORE_STRING = "OK_TM_STORE"; const char *NOT_OK_TM_STORE_STRING = "NOT_OK_TM_STORE"; @@ -186,6 +188,8 @@ const char *translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43000003: return CORE_CONTROLLER_STRING; + case 0x43000004: + return POWER_CONTROLLER_STRING; case 0x43000006: return GLOBAL_JSON_CFG_STRING; case 0x43400001: @@ -496,6 +500,8 @@ const char *translateObject(object_id_t object) { return TCS_SUBSYSTEM_STRING; case 0x73010004: return COM_SUBSYSTEM_STRING; + case 0x73010005: + return EPS_SUBSYSTEM_STRING; case 0x73020001: return MISC_TM_STORE_STRING; case 0x73020002: diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index 4d762f0e..442fc05c 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -99,6 +99,11 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/power/defs.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h 11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h +11304;0x2c28;DATASET_READ_FAILED;INFO;The dataset read for the inputs of the Power Controller has failed.;mission/power/defs.h +11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;The battery voltage read is out of the bounds in which it is supposed to be. P1: 1 too high, 0 too low;mission/power/defs.h +11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large.;mission/power/defs.h +11307;0x2c2b;POWER_LEVEL_LOW;HIGH;The State of Charge is below the limit for payload use. Setting Payload to faulty.;mission/power/defs.h +11308;0x2c2c;POWER_LEVEL_CRITICAL;HIGH;The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty.;mission/power/defs.h 11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11401;0x2c89;GPIO_PULL_LOW_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11402;0x2c8a;HEATER_WENT_ON;INFO;No description;mission/tcs/HeaterHandler.h diff --git a/generators/bsp_hosted_objects.csv b/generators/bsp_hosted_objects.csv index 3faac37c..4cb21f46 100644 --- a/generators/bsp_hosted_objects.csv +++ b/generators/bsp_hosted_objects.csv @@ -1,6 +1,7 @@ 0x42694269;TEST_TASK 0x43000002;ACS_CONTROLLER 0x43000003;CORE_CONTROLLER +0x43000004;POWER_CONTROLLER 0x43000006;GLOBAL_JSON_CFG 0x43400001;THERMAL_CONTROLLER 0x44000001;DUMMY_HANDLER @@ -156,6 +157,7 @@ 0x73010002;PL_SUBSYSTEM 0x73010003;TCS_SUBSYSTEM 0x73010004;COM_SUBSYSTEM +0x73010005;EPS_SUBSYSTEM 0x73020001;MISC_TM_STORE 0x73020002;OK_TM_STORE 0x73020003;NOT_OK_TM_STORE diff --git a/generators/bsp_hosted_returnvalues.csv b/generators/bsp_hosted_returnvalues.csv index 50a86ae3..e3db4c9a 100644 --- a/generators/bsp_hosted_returnvalues.csv +++ b/generators/bsp_hosted_returnvalues.csv @@ -357,7 +357,6 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3a02;MQI_Full;No space left for more messages;2;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a03;MQI_NoReplyPartner;Returned if a reply method was called without partner;3;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a04;MQI_DestinationInvalid;Returned if the target destination is invalid.;4;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h -0x3b00;SPH_ConnBroken;No description;0;SEMAPHORE_IF;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x3b01;SPH_SemaphoreTimeout;No description;1;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b02;SPH_SemaphoreNotOwned;No description;2;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b03;SPH_SemaphoreInvalid;No description;3;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h @@ -373,6 +372,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3e05;HKM_DatasetNotFound;No description;5;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h 0x3f01;DLEE_StreamTooShort;No description;1;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h 0x3f02;DLEE_DecodingError;No description;2;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h +0x4100;PUS9_ConnBroken;No description;0;PUS_SERVICE_9;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x4201;PUS11_InvalidTypeTimeWindow;No description;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4202;PUS11_InvalidTimeWindow;No description;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4203;PUS11_TimeshiftingNotPossible;No description;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h @@ -402,9 +402,9 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x4403;UXOS_CommandError;Command execution failed;3;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4404;UXOS_NoCommandLoadedOrPending;;4;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4406;UXOS_PcloseCallError;No description;6;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h -0x4500;HSPI_OpeningFileFailed;No description;0;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h -0x4501;HSPI_FullDuplexTransferFailed;No description;1;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h -0x4502;HSPI_HalfDuplexTransferFailed;No description;2;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h +0x4500;HSPI_HalTimeoutRetval;No description;0;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4501;HSPI_HalBusyRetval;No description;1;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4502;HSPI_HalErrorRetval;No description;2;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h 0x4503;HSPI_Timeout;No description;3;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4504;HSPI_Busy;No description;4;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4505;HSPI_GenericError;No description;5;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 4d762f0e..442fc05c 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -99,6 +99,11 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11301;0x2c25;SWITCH_HAS_CHANGED;INFO;Indicated that a switch state has changed P1: New switch state, 1 for on, 0 for off | P2: Switch Index;mission/power/defs.h 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h 11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h +11304;0x2c28;DATASET_READ_FAILED;INFO;The dataset read for the inputs of the Power Controller has failed.;mission/power/defs.h +11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;The battery voltage read is out of the bounds in which it is supposed to be. P1: 1 too high, 0 too low;mission/power/defs.h +11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large.;mission/power/defs.h +11307;0x2c2b;POWER_LEVEL_LOW;HIGH;The State of Charge is below the limit for payload use. Setting Payload to faulty.;mission/power/defs.h +11308;0x2c2c;POWER_LEVEL_CRITICAL;HIGH;The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty.;mission/power/defs.h 11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11401;0x2c89;GPIO_PULL_LOW_FAILED;LOW;No description;mission/tcs/HeaterHandler.h 11402;0x2c8a;HEATER_WENT_ON;INFO;No description;mission/tcs/HeaterHandler.h diff --git a/generators/bsp_q7s_objects.csv b/generators/bsp_q7s_objects.csv index eedafc52..914b7df6 100644 --- a/generators/bsp_q7s_objects.csv +++ b/generators/bsp_q7s_objects.csv @@ -1,6 +1,7 @@ 0x00005060;P60DOCK_TEST_TASK 0x43000002;ACS_CONTROLLER 0x43000003;CORE_CONTROLLER +0x43000004;POWER_CONTROLLER 0x43000006;GLOBAL_JSON_CFG 0x43400001;THERMAL_CONTROLLER 0x44120006;MGM_0_LIS3_HANDLER @@ -161,6 +162,7 @@ 0x73010002;PL_SUBSYSTEM 0x73010003;TCS_SUBSYSTEM 0x73010004;COM_SUBSYSTEM +0x73010005;EPS_SUBSYSTEM 0x73020001;MISC_TM_STORE 0x73020002;OK_TM_STORE 0x73020003;NOT_OK_TM_STORE diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index 1bc91860..065e5392 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -357,7 +357,6 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3a02;MQI_Full;No space left for more messages;2;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a03;MQI_NoReplyPartner;Returned if a reply method was called without partner;3;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a04;MQI_DestinationInvalid;Returned if the target destination is invalid.;4;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h -0x3b00;SPH_ConnBroken;No description;0;SEMAPHORE_IF;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x3b01;SPH_SemaphoreTimeout;No description;1;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b02;SPH_SemaphoreNotOwned;No description;2;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b03;SPH_SemaphoreInvalid;No description;3;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h @@ -373,6 +372,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3e05;HKM_DatasetNotFound;No description;5;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h 0x3f01;DLEE_StreamTooShort;No description;1;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h 0x3f02;DLEE_DecodingError;No description;2;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h +0x4100;PUS9_ConnBroken;No description;0;PUS_SERVICE_9;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x4201;PUS11_InvalidTypeTimeWindow;No description;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4202;PUS11_InvalidTimeWindow;No description;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4203;PUS11_TimeshiftingNotPossible;No description;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h @@ -402,9 +402,9 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x4403;UXOS_CommandError;Command execution failed;3;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4404;UXOS_NoCommandLoadedOrPending;;4;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4406;UXOS_PcloseCallError;No description;6;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h -0x4500;HSPI_OpeningFileFailed;No description;0;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h -0x4501;HSPI_FullDuplexTransferFailed;No description;1;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h -0x4502;HSPI_HalfDuplexTransferFailed;No description;2;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h +0x4500;HSPI_HalTimeoutRetval;No description;0;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4501;HSPI_HalBusyRetval;No description;1;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4502;HSPI_HalErrorRetval;No description;2;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h 0x4503;HSPI_Timeout;No description;3;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4504;HSPI_Busy;No description;4;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4505;HSPI_GenericError;No description;5;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index d7a9d6aa..610a69fb 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 308 translations. + * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-25 17:49:54 + * Generated on: 2023-09-28 15:53:20 */ #include "translateEvents.h" @@ -105,6 +105,11 @@ const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; const char *FDIR_REACTION_IGNORED_STRING = "FDIR_REACTION_IGNORED"; +const char *DATASET_READ_FAILED_STRING = "DATASET_READ_FAILED"; +const char *VOLTAGE_OUT_OF_BOUNDS_STRING = "VOLTAGE_OUT_OF_BOUNDS"; +const char *TIMEDELTA_OUT_OF_BOUNDS_STRING = "TIMEDELTA_OUT_OF_BOUNDS"; +const char *POWER_LEVEL_LOW_STRING = "POWER_LEVEL_LOW"; +const char *POWER_LEVEL_CRITICAL_STRING = "POWER_LEVEL_CRITICAL"; const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; const char *HEATER_WENT_ON_STRING = "HEATER_WENT_ON"; @@ -516,6 +521,16 @@ const char *translateEvents(Event event) { return SWITCHING_Q7S_DENIED_STRING; case (11303): return FDIR_REACTION_IGNORED_STRING; + case (11304): + return DATASET_READ_FAILED_STRING; + case (11305): + return VOLTAGE_OUT_OF_BOUNDS_STRING; + case (11306): + return TIMEDELTA_OUT_OF_BOUNDS_STRING; + case (11307): + return POWER_LEVEL_LOW_STRING; + case (11308): + return POWER_LEVEL_CRITICAL_STRING; case (11400): return GPIO_PULL_HIGH_FAILED_STRING; case (11401): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 19e0bf82..4f191225 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -1,14 +1,15 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 175 translations. - * Generated on: 2023-09-25 17:49:54 + * Contains 177 translations. + * Generated on: 2023-09-28 15:53:20 */ #include "translateObjects.h" const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *POWER_CONTROLLER_STRING = "POWER_CONTROLLER"; const char *GLOBAL_JSON_CFG_STRING = "GLOBAL_JSON_CFG"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; @@ -169,6 +170,7 @@ const char *ACS_SUBSYSTEM_STRING = "ACS_SUBSYSTEM"; const char *PL_SUBSYSTEM_STRING = "PL_SUBSYSTEM"; const char *TCS_SUBSYSTEM_STRING = "TCS_SUBSYSTEM"; const char *COM_SUBSYSTEM_STRING = "COM_SUBSYSTEM"; +const char *EPS_SUBSYSTEM_STRING = "EPS_SUBSYSTEM"; const char *MISC_TM_STORE_STRING = "MISC_TM_STORE"; const char *OK_TM_STORE_STRING = "OK_TM_STORE"; const char *NOT_OK_TM_STORE_STRING = "NOT_OK_TM_STORE"; @@ -190,6 +192,8 @@ const char *translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43000003: return CORE_CONTROLLER_STRING; + case 0x43000004: + return POWER_CONTROLLER_STRING; case 0x43000006: return GLOBAL_JSON_CFG_STRING; case 0x43400001: @@ -510,6 +514,8 @@ const char *translateObject(object_id_t object) { return TCS_SUBSYSTEM_STRING; case 0x73010004: return COM_SUBSYSTEM_STRING; + case 0x73010005: + return EPS_SUBSYSTEM_STRING; case 0x73020001: return MISC_TM_STORE_STRING; case 0x73020002: diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index d7a9d6aa..610a69fb 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 308 translations. + * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-25 17:49:54 + * Generated on: 2023-09-28 15:53:20 */ #include "translateEvents.h" @@ -105,6 +105,11 @@ const char *SWITCH_CMD_SENT_STRING = "SWITCH_CMD_SENT"; const char *SWITCH_HAS_CHANGED_STRING = "SWITCH_HAS_CHANGED"; const char *SWITCHING_Q7S_DENIED_STRING = "SWITCHING_Q7S_DENIED"; const char *FDIR_REACTION_IGNORED_STRING = "FDIR_REACTION_IGNORED"; +const char *DATASET_READ_FAILED_STRING = "DATASET_READ_FAILED"; +const char *VOLTAGE_OUT_OF_BOUNDS_STRING = "VOLTAGE_OUT_OF_BOUNDS"; +const char *TIMEDELTA_OUT_OF_BOUNDS_STRING = "TIMEDELTA_OUT_OF_BOUNDS"; +const char *POWER_LEVEL_LOW_STRING = "POWER_LEVEL_LOW"; +const char *POWER_LEVEL_CRITICAL_STRING = "POWER_LEVEL_CRITICAL"; const char *GPIO_PULL_HIGH_FAILED_STRING = "GPIO_PULL_HIGH_FAILED"; const char *GPIO_PULL_LOW_FAILED_STRING = "GPIO_PULL_LOW_FAILED"; const char *HEATER_WENT_ON_STRING = "HEATER_WENT_ON"; @@ -516,6 +521,16 @@ const char *translateEvents(Event event) { return SWITCHING_Q7S_DENIED_STRING; case (11303): return FDIR_REACTION_IGNORED_STRING; + case (11304): + return DATASET_READ_FAILED_STRING; + case (11305): + return VOLTAGE_OUT_OF_BOUNDS_STRING; + case (11306): + return TIMEDELTA_OUT_OF_BOUNDS_STRING; + case (11307): + return POWER_LEVEL_LOW_STRING; + case (11308): + return POWER_LEVEL_CRITICAL_STRING; case (11400): return GPIO_PULL_HIGH_FAILED_STRING; case (11401): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 19e0bf82..4f191225 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -1,14 +1,15 @@ /** * @brief Auto-generated object translation file. * @details - * Contains 175 translations. - * Generated on: 2023-09-25 17:49:54 + * Contains 177 translations. + * Generated on: 2023-09-28 15:53:20 */ #include "translateObjects.h" const char *P60DOCK_TEST_TASK_STRING = "P60DOCK_TEST_TASK"; const char *ACS_CONTROLLER_STRING = "ACS_CONTROLLER"; const char *CORE_CONTROLLER_STRING = "CORE_CONTROLLER"; +const char *POWER_CONTROLLER_STRING = "POWER_CONTROLLER"; const char *GLOBAL_JSON_CFG_STRING = "GLOBAL_JSON_CFG"; const char *THERMAL_CONTROLLER_STRING = "THERMAL_CONTROLLER"; const char *MGM_0_LIS3_HANDLER_STRING = "MGM_0_LIS3_HANDLER"; @@ -169,6 +170,7 @@ const char *ACS_SUBSYSTEM_STRING = "ACS_SUBSYSTEM"; const char *PL_SUBSYSTEM_STRING = "PL_SUBSYSTEM"; const char *TCS_SUBSYSTEM_STRING = "TCS_SUBSYSTEM"; const char *COM_SUBSYSTEM_STRING = "COM_SUBSYSTEM"; +const char *EPS_SUBSYSTEM_STRING = "EPS_SUBSYSTEM"; const char *MISC_TM_STORE_STRING = "MISC_TM_STORE"; const char *OK_TM_STORE_STRING = "OK_TM_STORE"; const char *NOT_OK_TM_STORE_STRING = "NOT_OK_TM_STORE"; @@ -190,6 +192,8 @@ const char *translateObject(object_id_t object) { return ACS_CONTROLLER_STRING; case 0x43000003: return CORE_CONTROLLER_STRING; + case 0x43000004: + return POWER_CONTROLLER_STRING; case 0x43000006: return GLOBAL_JSON_CFG_STRING; case 0x43400001: @@ -510,6 +514,8 @@ const char *translateObject(object_id_t object) { return TCS_SUBSYSTEM_STRING; case 0x73010004: return COM_SUBSYSTEM_STRING; + case 0x73010005: + return EPS_SUBSYSTEM_STRING; case 0x73020001: return MISC_TM_STORE_STRING; case 0x73020002: From 758add2928ccd43e996840202fa73a9837689309 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 09:50:48 +0200 Subject: [PATCH 35/67] improved events, allowed all modes, removed debug output --- mission/controller/PowerController.cpp | 17 ++++++++--------- mission/controller/PowerController.h | 2 +- mission/power/defs.h | 2 ++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 9347f681..054fcfd2 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -11,7 +11,6 @@ ReturnValue_t PowerController::initialize() { if (result != returnvalue::OK) { return result; } - sif::debug << "Rush B, no stop" << std::endl; return ExtendedControllerBase::initialize(); } @@ -92,7 +91,6 @@ void PowerController::performControlOperation() { } case InternalState::READY: { if (mode != MODE_OFF) { - sif::debug << "oh shit, now i gotta do something" << std::endl; calculateStateOfCharge(); if (mode == MODE_NORMAL) { watchStateOfCharge(); @@ -127,7 +125,7 @@ LocalPoolDataSetBase *PowerController::getDataSetHandle(sid_t sid) { ReturnValue_t PowerController::checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) { - if (mode == MODE_OFF) { + if (mode == MODE_OFF or mode == MODE_ON or mode == MODE_NORMAL) { if (submode == SUBMODE_NONE) { return returnvalue::OK; } else { @@ -251,8 +249,9 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { ReturnValue_t PowerController::calculateCoulombCounterCharge() { double timeDiff = timevalOperations::toDouble(now - oldTime); if (timeDiff > maxAllowedTimeDiff) { - triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS); - sif::error << "Power Controller::Time delta too large for Coulomb Counter" << std::endl; + triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS, static_cast(timeDiff * 10)); + sif::error << "Power Controller::Time delta too large for Coulomb Counter: " << timeDiff + << std::endl; return returnvalue::FAILED; } if (not pwrCtrlCoreHk.coulombCounterCharge.isValid()) { @@ -298,12 +297,12 @@ float PowerController::linearInterpolation(float x, float x0, float x1, float y0 ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) { if (voltage >= lookUpTableOcv[1][99]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0); - sif::error << "Power Controller::Voltage is too high" << std::endl; + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0, static_cast(voltage * 10)); + sif::error << "Power Controller::Voltage is too high: " << voltage << std::endl; return returnvalue::FAILED; } else if (voltage <= lookUpTableOcv[1][0]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1); - sif::error << "Power Controller::Voltage is too low" << std::endl; + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1, static_cast(voltage * 10)); + sif::error << "Power Controller::Voltage is too low: " << voltage << std::endl; return returnvalue::FAILED; } while (lookUpTableOcv[1][idx] > voltage) { diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index 81522023..e374391e 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -55,7 +55,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM // Parameters float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm] float batteryMaximumCapacity = 2.6 * 2; // [Ah] - float coulombCounterVoltageUpperThreshold = 16.2e3; // [mV] + float coulombCounterVoltageUpperThreshold = 16.2; // [V] double maxAllowedTimeDiff = 0.5; // [s] float payloadLimit = 0.75; // [%] float higherModesLimit = 0.6; // [%] diff --git a/mission/power/defs.h b/mission/power/defs.h index 22a8af53..28e5eca8 100644 --- a/mission/power/defs.h +++ b/mission/power/defs.h @@ -52,8 +52,10 @@ static constexpr Event DATASET_READ_FAILED = event::makeEvent(SUBSYSTEM_ID, 4, s //! [EXPORT] : [COMMENT] The battery voltage read is out of the bounds in which it is supposed to //! be. //! P1: 1 too high, 0 too low +//! P2: voltage in V * 10 static constexpr Event VOLTAGE_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 5, severity::HIGH); //! [EXPORT] : [COMMENT] Time difference for Coulomb Counter was too large. +//! P1: time in s * 10 static constexpr Event TIMEDELTA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 6, severity::LOW); //! [EXPORT] : [COMMENT] The State of Charge is below the limit for payload use. Setting Payload to //! faulty. From 1abc5036147131cb141561bc35202498535906ee Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 10:15:34 +0200 Subject: [PATCH 36/67] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 22a42108..dd74f6c3 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 22a42108b431bafa707de2b3a24cad9de95b70d0 +Subproject commit dd74f6c3ca0e730c7f316ed7959d2992c4a14fb4 From 69f5529adea173432eaebc2788643e17c555f274 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 10:16:23 +0200 Subject: [PATCH 37/67] added dataset for flag for pl usage --- mission/controller/PowerController.cpp | 33 +++++++++++++++++-- mission/controller/PowerController.h | 5 ++- .../PowerCtrlDefinitions.h | 13 +++++++- 3 files changed, 46 insertions(+), 5 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index 054fcfd2..a7dbd37c 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -4,7 +4,8 @@ PowerController::PowerController(object_id_t objectId, bool enableHkSets) : ExtendedControllerBase(objectId), enableHkSets(enableHkSets), parameterHelper(this), - pwrCtrlCoreHk(this) {} + pwrCtrlCoreHk(this), + enablePl(this) {} ReturnValue_t PowerController::initialize() { ReturnValue_t result = parameterHelper.initialize(); @@ -54,9 +55,12 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI parameterWrapper->set(maxAllowedTimeDiff); break; case 0x4: - parameterWrapper->set(payloadLimit); + parameterWrapper->set(payloadOpLimitOn); break; case 0x5: + parameterWrapper->set(payloadOpLimitLow); + break; + case 0x6: parameterWrapper->set(higherModesLimit); break; default: @@ -110,6 +114,8 @@ ReturnValue_t PowerController::initializeLocalDataPool(localpool::DataPool &loca new PoolEntry({0.0})); localDataPoolMap.emplace(pwrctrl::PoolIds::COULOMB_COUNTER_CHARGE, new PoolEntry({0.0})); poolManager.subscribeForRegularPeriodicPacket({pwrCtrlCoreHk.getSid(), enableHkSets, 60.0}); + localDataPoolMap.emplace(pwrctrl::PoolIds::PAYLOAD_FLAG, new PoolEntry({false})); + poolManager.subscribeForRegularPeriodicPacket({enablePl.getSid(), false, 60.0}); return returnvalue::OK; } @@ -117,6 +123,8 @@ LocalPoolDataSetBase *PowerController::getDataSetHandle(sid_t sid) { switch (sid.ownerSetId) { case pwrctrl::CORE_HK: return &pwrCtrlCoreHk; + case pwrctrl::ENABLE_PL: + return &enablePl; default: return nullptr; } @@ -217,7 +225,20 @@ void PowerController::calculateStateOfCharge() { void PowerController::watchStateOfCharge() { if (pwrCtrlCoreHk.coulombCounterCharge.isValid()) { - if (not pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value < payloadLimit) { + if (pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitOn) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.plUseAllowed.value = false; + enablePl.plUseAllowed.setValid(true); + } + } else { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.plUseAllowed.value = true; + enablePl.plUseAllowed.setValid(true); + } + } + if (not pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitLow) { triggerEvent(power::POWER_LEVEL_LOW); pwrLvlLowFlag = true; } else { @@ -229,6 +250,12 @@ void PowerController::watchStateOfCharge() { } else { pwrLvlCriticalFlag = false; } + } else { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.plUseAllowed.value = false; + enablePl.plUseAllowed.setValid(true); + } } } diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index e374391e..afab21b4 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -57,7 +57,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float batteryMaximumCapacity = 2.6 * 2; // [Ah] float coulombCounterVoltageUpperThreshold = 16.2; // [V] double maxAllowedTimeDiff = 0.5; // [s] - float payloadLimit = 0.75; // [%] + float payloadOpLimitOn = 0.90; // [%] + float payloadOpLimitLow = 0.75; // [%] float higherModesLimit = 0.6; // [%] // OCV Look-up-Table {[Ah],[V]} @@ -121,6 +122,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM P60Dock::CoreHkSet p60CoreHk = P60Dock::CoreHkSet(objects::P60DOCK_HANDLER); // Output Dataset pwrctrl::CoreHk pwrCtrlCoreHk; + // Dataset for PL Flag + pwrctrl::EnablePl enablePl; }; #endif /* MISSION_CONTROLLER_POWERCONTROLLER_H_ */ diff --git a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h index f7cce708..ff090e5b 100644 --- a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h +++ b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h @@ -10,15 +10,17 @@ namespace pwrctrl { -enum SetIds : uint32_t { CORE_HK }; +enum SetIds : uint32_t { CORE_HK, ENABLE_PL }; enum PoolIds : lp_id_t { TOTAL_BATTERY_CURRENT, OPEN_CIRCUIT_VOLTAGE_CHARGE, COULOMB_COUNTER_CHARGE, + PAYLOAD_FLAG }; static constexpr uint8_t CORE_HK_ENTRIES = 3; +static constexpr uint8_t ENABLE_PL_ENTRIES = 1; class CoreHk : public StaticLocalDataSet { public: @@ -34,6 +36,15 @@ class CoreHk : public StaticLocalDataSet { private: }; +class EnablePl : public StaticLocalDataSet { + public: + EnablePl(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, ENABLE_PL) {} + + lp_var_t plUseAllowed = lp_var_t(sid.objectId, PAYLOAD_FLAG, this); + + private: +}; + } // namespace pwrctrl #endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_POWERCTRLDEFINITIONS_H_ */ From 9f8e7b6673db1618fcff669123036205d2dd5120 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 10:29:52 +0200 Subject: [PATCH 38/67] enable dataset to be called by non-owner --- mission/controller/controllerdefinitions/PowerCtrlDefinitions.h | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h index ff090e5b..1b378cd0 100644 --- a/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h +++ b/mission/controller/controllerdefinitions/PowerCtrlDefinitions.h @@ -39,6 +39,7 @@ class CoreHk : public StaticLocalDataSet { class EnablePl : public StaticLocalDataSet { public: EnablePl(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, ENABLE_PL) {} + EnablePl(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, ENABLE_PL)) {} lp_var_t plUseAllowed = lp_var_t(sid.objectId, PAYLOAD_FLAG, this); From 9472faf899687c3eb0ef3ef5ce6725c519739a34 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 10:30:26 +0200 Subject: [PATCH 39/67] set plFlag to invalid if PWR ctrl is in on --- mission/controller/PowerController.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index a7dbd37c..ef625d8a 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -98,6 +98,11 @@ void PowerController::performControlOperation() { calculateStateOfCharge(); if (mode == MODE_NORMAL) { watchStateOfCharge(); + } else { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + enablePl.setValidity(false, true); + } } } break; @@ -229,13 +234,13 @@ void PowerController::watchStateOfCharge() { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { enablePl.plUseAllowed.value = false; - enablePl.plUseAllowed.setValid(true); + enablePl.setValidity(true, true); } } else { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { enablePl.plUseAllowed.value = true; - enablePl.plUseAllowed.setValid(true); + enablePl.setValidity(true, true); } } if (not pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitLow) { @@ -254,7 +259,7 @@ void PowerController::watchStateOfCharge() { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { enablePl.plUseAllowed.value = false; - enablePl.plUseAllowed.setValid(true); + enablePl.setValidity(true, true); } } } From 509243a47fdf39b8c2ee1fc94cb5ef8d4946b6c7 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 14:18:42 +0200 Subject: [PATCH 40/67] eive system event handling --- mission/system/EiveSystem.cpp | 110 ++++++++++++++++++++++++++++++++++ mission/system/EiveSystem.h | 11 ++++ 2 files changed, 121 insertions(+) diff --git a/mission/system/EiveSystem.cpp b/mission/system/EiveSystem.cpp index 6519806e..6e0097f5 100644 --- a/mission/system/EiveSystem.cpp +++ b/mission/system/EiveSystem.cpp @@ -81,6 +81,55 @@ ReturnValue_t EiveSystem::initialize() { return result; } + auto* plSs = ObjectManager::instance()->get(objects::PL_SUBSYSTEM); + if (plSs == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plSsQueueId = plSs->getCommandQueue(); + + auto* plPcdu = ObjectManager::instance()->get(objects::PLPCDU_HANDLER); + if (plPcdu == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plPcduQueueId = plPcdu->getCommandQueue(); + + auto* plocMpsoc = ObjectManager::instance()->get(objects::PLOC_MPSOC_HANDLER); + if (plocMpsoc == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plocMpsocQueueId = plocMpsoc->getCommandQueue(); + + auto* plocSupervisor = + ObjectManager::instance()->get(objects::PLOC_SUPERVISOR_HANDLER); + if (plocSupervisor == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + plocSupervisorQueueId = plocSupervisor->getCommandQueue(); + + auto* camera = ObjectManager::instance()->get(objects::CAM_SWITCHER); + if (camera == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + cameraQueueId = camera->getCommandQueue(); + + auto* scex = ObjectManager::instance()->get(objects::SCEX); + if (scex == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + scexQueueId = scex->getCommandQueue(); + + auto* radSensor = ObjectManager::instance()->get(objects::RAD_SENSOR); + if (radSensor == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + radSensorQueueId = radSensor->getCommandQueue(); + + auto* str = ObjectManager::instance()->get(objects::STAR_TRACKER); + if (str == nullptr) { + return ObjectManager::CHILD_INIT_FAILED; + } + strQueueId = str->getCommandQueue(); + auto* bpxDest = ObjectManager::instance()->get(objects::BPX_BATT_HANDLER); if (bpxDest == nullptr) { return ObjectManager::CHILD_INIT_FAILED; @@ -120,6 +169,8 @@ ReturnValue_t EiveSystem::initialize() { manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::OBC_OVERHEATING)); manager->subscribeToEvent(eventQueue->getId(), event::getEventId(tcsCtrl::MGT_OVERHEATING)); manager->subscribeToEvent(eventQueue->getId(), event::getEventId(pdec::INVALID_TC_FRAME)); + manager->subscribeToEvent(eventQueue->getId(), event::getEventId(power::POWER_LEVEL_LOW)); + manager->subscribeToEvent(eventQueue->getId(), event::getEventId(power::POWER_LEVEL_CRITICAL)); return Subsystem::initialize(); } @@ -151,6 +202,22 @@ void EiveSystem::handleEventMessages() { commandSelfToSafe(); break; } + case power::POWER_LEVEL_LOW: { + forceOffPayload(); + break; + } + case power::POWER_LEVEL_CRITICAL: + CommandMessage msg; + ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, + HasModesIF::MODE_OFF, HasModesIF::SUBMODE_NONE); + HealthMessage::setHealthMessage(&msg, HealthMessage::HEALTH_SET, HasHealthIF::FAULTY); + ReturnValue_t result = MessageQueueSenderIF::sendMessage( + strQueueId, &msg, MessageQueueIF::NO_QUEUE, false); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to STR Assembly failed" + << std::endl; + } + break; } break; default: @@ -336,6 +403,49 @@ void EiveSystem::pdecRecoveryLogic() { } } +void EiveSystem::forceOffPayload() { + CommandMessage msg; + // turn off PL Subsystem + ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, HasModesIF::MODE_OFF, + HasModesIF::SUBMODE_NONE); + ReturnValue_t result = commandQueue->sendMessage(plSsQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending OFF command to PL Subsystem failed" << std::endl; + } + // set PL to faulty + HealthMessage::setHealthMessage(&msg, HealthMessage::HEALTH_SET, HasHealthIF::FAULTY); + + result = commandQueue->sendMessage(plPcduQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PL PCDU failed" << std::endl; + } + + result = commandQueue->sendMessage(plocMpsocQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PLOC MPSOC failed" << std::endl; + } + + result = commandQueue->sendMessage(plocSupervisorQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PLOC SUPERVISOR failed" << std::endl; + } + + result = commandQueue->sendMessage(cameraQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to PL CAM failed" << std::endl; + } + + result = commandQueue->sendMessage(scexQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to SCEX failed" << std::endl; + } + + result = commandQueue->sendMessage(radSensorQueueId, &msg); + if (result != returnvalue::OK) { + sif::error << "EIVE System: Sending FAULTY command to RAD SENSOR failed" << std::endl; + } +} + void EiveSystem::commonI2cRecoverySequenceFinish() { alreadyTriedI2cRecovery = true; performI2cReboot = false; diff --git a/mission/system/EiveSystem.h b/mission/system/EiveSystem.h index e6ff19b9..78f8bdc9 100644 --- a/mission/system/EiveSystem.h +++ b/mission/system/EiveSystem.h @@ -49,6 +49,15 @@ class EiveSystem : public Subsystem, public HasActionsIF { PowerSwitchIF* powerSwitcher = nullptr; std::atomic_uint16_t& i2cErrors; + MessageQueueId_t plSsQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t plPcduQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t plocMpsocQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t plocSupervisorQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t cameraQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t scexQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t radSensorQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t strQueueId = MessageQueueIF::NO_QUEUE; + MessageQueueId_t pdecHandlerQueueId = MessageQueueIF::NO_QUEUE; MessageQueueId_t bpxBattQueueId = MessageQueueIF::NO_QUEUE; @@ -68,6 +77,8 @@ class EiveSystem : public Subsystem, public HasActionsIF { ReturnValue_t sendFullRebootCommand(); ReturnValue_t sendSelfRebootCommand(); + void forceOffPayload(); + void pdecRecoveryLogic(); void i2cRecoveryLogic(); From fda76e24ae7fa819f2b7d05143a7959846ab6acc Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 14:30:57 +0200 Subject: [PATCH 41/67] pl pcdu mode change soc check --- mission/payload/PayloadPcduHandler.cpp | 13 +++++++++++++ mission/payload/PayloadPcduHandler.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/mission/payload/PayloadPcduHandler.cpp b/mission/payload/PayloadPcduHandler.cpp index 1e6d16db..1a2b35ff 100644 --- a/mission/payload/PayloadPcduHandler.cpp +++ b/mission/payload/PayloadPcduHandler.cpp @@ -564,6 +564,19 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) return true; } +ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_SOC; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} + ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { using namespace plpcdu; if (mode == MODE_NORMAL) { diff --git a/mission/payload/PayloadPcduHandler.h b/mission/payload/PayloadPcduHandler.h index d9370dcf..e96eadf1 100644 --- a/mission/payload/PayloadPcduHandler.h +++ b/mission/payload/PayloadPcduHandler.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { #endif private: + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + static constexpr bool NO_ADC_CHECKS = false; enum class States : uint8_t { @@ -152,6 +155,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override; ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, uint16_t startAtIndex) override; From b66b202373eb9a04ecda4a920b1fa94e354c25d4 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 14:31:14 +0200 Subject: [PATCH 42/67] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index d246ce34..19093866 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit d246ce34d05ecc5c722fd127e61556374961c899 +Subproject commit 19093866eeffe96c4f6f454df2dc7e2502f8d2f6 From 8847ed611d0340283a6df4913a9abf547f0b4382 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 15:26:21 +0200 Subject: [PATCH 43/67] cam switcher mode change soc check --- mission/system/objects/CamSwitcher.cpp | 16 +++++++++++++++- mission/system/objects/CamSwitcher.h | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mission/system/objects/CamSwitcher.cpp b/mission/system/objects/CamSwitcher.cpp index 90a78945..93b67646 100644 --- a/mission/system/objects/CamSwitcher.cpp +++ b/mission/system/objects/CamSwitcher.cpp @@ -1,6 +1,6 @@ #include "CamSwitcher.h" -CamSwitcher::CamSwitcher(object_id_t objectId, PowerSwitchIF &pwrSwitcher, +CamSwitcher::CamSwitcher(object_id_t objectId, PowerSwitchIF& pwrSwitcher, power::Switch_t pwrSwitch) : PowerSwitcherComponent(objectId, &pwrSwitcher, pwrSwitch) {} void CamSwitcher::performFaultyOperation() { @@ -8,3 +8,17 @@ void CamSwitcher::performFaultyOperation() { switcher.turnOff(); } } + +ReturnValue_t CamSwitcher::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return TRANS_NOT_ALLOWED; + } + } + } + return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); +} diff --git a/mission/system/objects/CamSwitcher.h b/mission/system/objects/CamSwitcher.h index 57f371ce..a0d1b242 100644 --- a/mission/system/objects/CamSwitcher.h +++ b/mission/system/objects/CamSwitcher.h @@ -1,13 +1,19 @@ #ifndef MISSION_SYSTEM_OBJECTS_CAMSWITCHER_H_ #define MISSION_SYSTEM_OBJECTS_CAMSWITCHER_H_ +#include #include +#include class CamSwitcher : public PowerSwitcherComponent { public: - CamSwitcher(object_id_t objectId, PowerSwitchIF &pwrSwitcher, power::Switch_t pwrSwitch); + CamSwitcher(object_id_t objectId, PowerSwitchIF& pwrSwitcher, power::Switch_t pwrSwitch); private: + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; + void performFaultyOperation() override; }; From 2a66f335f244672a4b2e2cb4d5b44605c26837cf Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 15:27:03 +0200 Subject: [PATCH 44/67] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 19093866..e3a81544 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 19093866eeffe96c4f6f454df2dc7e2502f8d2f6 +Subproject commit e3a815444e401fc2fa75f6f19b40a18eceee08a5 From 2966ee500522df896c1e33311ba0a6cb41e6bf04 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 15:32:38 +0200 Subject: [PATCH 45/67] boop --- mission/payload/PayloadPcduHandler.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mission/payload/PayloadPcduHandler.h b/mission/payload/PayloadPcduHandler.h index e96eadf1..a4574f53 100644 --- a/mission/payload/PayloadPcduHandler.h +++ b/mission/payload/PayloadPcduHandler.h @@ -77,8 +77,6 @@ class PayloadPcduHandler : public DeviceHandlerBase { #endif private: - pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); - static constexpr bool NO_ADC_CHECKS = false; enum class States : uint8_t { @@ -155,8 +153,6 @@ class PayloadPcduHandler : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; - ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, - uint32_t* msToReachTheMode) override; ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override; ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, uint16_t startAtIndex) override; @@ -175,6 +171,10 @@ class PayloadPcduHandler : public DeviceHandlerBase { ReturnValue_t handleDoubleParamUpdate(std::string key, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues); LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; }; #endif /* LINUX_DEVICES_PLPCDUHANDLER_H_ */ From cbfcee0b1c3aff5c65ff75e0e1891af65a75aab9 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 15:33:09 +0200 Subject: [PATCH 46/67] ploc mpsoc mode change soc check --- linux/payload/PlocMpsocHandler.cpp | 13 +++++++++++++ linux/payload/PlocMpsocHandler.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 2421fcaa..d4c663e6 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1505,3 +1505,16 @@ void PlocMpsocHandler::cmdDoneHandler(bool success, ReturnValue_t result) { } disableAllReplies(); } + +ReturnValue_t PlocMpsocHandler::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_SOC; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index 10171ef5..0203b942 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -5,6 +5,7 @@ #include #include #include +#include #include @@ -309,6 +310,10 @@ class PlocMpsocHandler : public DeviceHandlerBase, public CommandsActionsIF { void stopSpecialComHelper(); void handleActionCommandFailure(ActionId_t actionId); + + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; }; #endif /* BSP_Q7S_DEVICES_PLOC_PLOCMPSOCHANDLER_H_ */ From 59bc783045ee8e925f4866583f463c706dd963bc Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 15:37:47 +0200 Subject: [PATCH 47/67] ploc supervisor mode change soc check --- linux/payload/PlocSupervisorHandler.cpp | 14 ++++++++++++++ linux/payload/PlocSupervisorHandler.h | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/linux/payload/PlocSupervisorHandler.cpp b/linux/payload/PlocSupervisorHandler.cpp index 0aaa7cfb..648ea74c 100644 --- a/linux/payload/PlocSupervisorHandler.cpp +++ b/linux/payload/PlocSupervisorHandler.cpp @@ -1993,6 +1993,20 @@ uint32_t PlocSupervisorHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t mod return 7000; } +ReturnValue_t PlocSupervisorHandler::checkModeCommand(Mode_t commandedMode, + Submode_t commandedSubmode, + uint32_t* msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_SOC; + } + } + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} + // ReturnValue_t PlocSupervisorHandler::checkMramPacketApid() { // uint16_t apid = (spacePacketBuffer[0] << 8 | spacePacketBuffer[1]) & supv::APID_MASK; // TODO: Fix diff --git a/linux/payload/PlocSupervisorHandler.h b/linux/payload/PlocSupervisorHandler.h index 3e5ac2a0..d7c5cb1e 100644 --- a/linux/payload/PlocSupervisorHandler.h +++ b/linux/payload/PlocSupervisorHandler.h @@ -3,6 +3,7 @@ #include #include +#include #include "OBSWConfig.h" #include "devices/powerSwitcherList.h" @@ -395,6 +396,10 @@ class PlocSupervisorHandler : public DeviceHandlerBase { void handleExecutionFailureReport(ExecutionReport& report); void printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId); + + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t* msToReachTheMode) override; }; #endif /* MISSION_DEVICES_PLOCSUPERVISORHANDLER_H_ */ From 0e4872165550b475772020b54aad9e3eb66255e4 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 29 Sep 2023 15:56:07 +0200 Subject: [PATCH 48/67] spam protection --- mission/controller/PowerController.cpp | 12 ++++++++++-- mission/controller/PowerController.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index ef625d8a..bd760012 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -281,6 +281,7 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { ReturnValue_t PowerController::calculateCoulombCounterCharge() { double timeDiff = timevalOperations::toDouble(now - oldTime); if (timeDiff > maxAllowedTimeDiff) { + // should not be a permanent state so no spam protection required triggerEvent(power::TIMEDELTA_OUT_OF_BOUNDS, static_cast(timeDiff * 10)); sif::error << "Power Controller::Time delta too large for Coulomb Counter: " << timeDiff << std::endl; @@ -329,14 +330,21 @@ float PowerController::linearInterpolation(float x, float x0, float x1, float y0 ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) { if (voltage >= lookUpTableOcv[1][99]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0, static_cast(voltage * 10)); + if (not voltageOutOfBoundsFlag) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0, static_cast(voltage * 10)); + voltageOutOfBoundsFlag = true; + } sif::error << "Power Controller::Voltage is too high: " << voltage << std::endl; return returnvalue::FAILED; } else if (voltage <= lookUpTableOcv[1][0]) { - triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1, static_cast(voltage * 10)); + if (not voltageOutOfBoundsFlag) { + triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1, static_cast(voltage * 10)); + voltageOutOfBoundsFlag = true; + } sif::error << "Power Controller::Voltage is too low: " << voltage << std::endl; return returnvalue::FAILED; } + voltageOutOfBoundsFlag = false; while (lookUpTableOcv[1][idx] > voltage) { idx--; } diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index afab21b4..adff4733 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -116,6 +116,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM bool pwrLvlLowFlag = false; bool pwrLvlCriticalFlag = false; + bool voltageOutOfBoundsFlag = false; // HK Datasets for Calculation BpxBatteryHk bpxBatteryHk = BpxBatteryHk(objects::BPX_BATT_HANDLER); From e9ad8d956ac9c4eddb8902bbdc94db1a70cece03 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 9 Oct 2023 09:33:37 +0200 Subject: [PATCH 49/67] i need a vacation ... --- linux/payload/PlocMpsocHandler.cpp | 2 +- linux/payload/PlocSupervisorHandler.cpp | 2 +- mission/payload/PayloadPcduHandler.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index d4c663e6..66fba6d8 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1512,7 +1512,7 @@ ReturnValue_t PlocMpsocHandler::checkModeCommand(Mode_t commandedMode, Submode_t PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { - return NON_OP_SOC; + return NON_OP_STATE_OF_CHARGE; } } } diff --git a/linux/payload/PlocSupervisorHandler.cpp b/linux/payload/PlocSupervisorHandler.cpp index 648ea74c..0c6311de 100644 --- a/linux/payload/PlocSupervisorHandler.cpp +++ b/linux/payload/PlocSupervisorHandler.cpp @@ -2000,7 +2000,7 @@ ReturnValue_t PlocSupervisorHandler::checkModeCommand(Mode_t commandedMode, PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { - return NON_OP_SOC; + return NON_OP_STATE_OF_CHARGE; } } } diff --git a/mission/payload/PayloadPcduHandler.cpp b/mission/payload/PayloadPcduHandler.cpp index 1a2b35ff..bda15b20 100644 --- a/mission/payload/PayloadPcduHandler.cpp +++ b/mission/payload/PayloadPcduHandler.cpp @@ -570,7 +570,7 @@ ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { - return NON_OP_SOC; + return NON_OP_STATE_OF_CHARGE; } } } From bd8cb7c26fffcf61078c27d70be42a0440b97e99 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 9 Oct 2023 11:42:42 +0200 Subject: [PATCH 50/67] what is dis --- mission/system/EiveSystem.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/mission/system/EiveSystem.cpp b/mission/system/EiveSystem.cpp index 6e0097f5..7093399e 100644 --- a/mission/system/EiveSystem.cpp +++ b/mission/system/EiveSystem.cpp @@ -208,8 +208,6 @@ void EiveSystem::handleEventMessages() { } case power::POWER_LEVEL_CRITICAL: CommandMessage msg; - ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, - HasModesIF::MODE_OFF, HasModesIF::SUBMODE_NONE); HealthMessage::setHealthMessage(&msg, HealthMessage::HEALTH_SET, HasHealthIF::FAULTY); ReturnValue_t result = MessageQueueSenderIF::sendMessage( strQueueId, &msg, MessageQueueIF::NO_QUEUE, false); From 47b15bec935b6c4538f9e8c9e21456cf182c61ac Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 9 Oct 2023 14:03:13 +0200 Subject: [PATCH 51/67] not needed as all PL components are set to faulty anyways --- mission/system/EiveSystem.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/mission/system/EiveSystem.cpp b/mission/system/EiveSystem.cpp index 7093399e..0df0fc95 100644 --- a/mission/system/EiveSystem.cpp +++ b/mission/system/EiveSystem.cpp @@ -403,17 +403,10 @@ void EiveSystem::pdecRecoveryLogic() { void EiveSystem::forceOffPayload() { CommandMessage msg; - // turn off PL Subsystem - ModeMessage::setModeMessage(&msg, ModeMessage::CMD_MODE_COMMAND_FORCED, HasModesIF::MODE_OFF, - HasModesIF::SUBMODE_NONE); - ReturnValue_t result = commandQueue->sendMessage(plSsQueueId, &msg); - if (result != returnvalue::OK) { - sif::error << "EIVE System: Sending OFF command to PL Subsystem failed" << std::endl; - } // set PL to faulty HealthMessage::setHealthMessage(&msg, HealthMessage::HEALTH_SET, HasHealthIF::FAULTY); - result = commandQueue->sendMessage(plPcduQueueId, &msg); + ReturnValue_t result = commandQueue->sendMessage(plPcduQueueId, &msg); if (result != returnvalue::OK) { sif::error << "EIVE System: Sending FAULTY command to PL PCDU failed" << std::endl; } From 706c5be7f71fd24abee12e1223c29e6c4ffec3e9 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 9 Oct 2023 14:03:57 +0200 Subject: [PATCH 52/67] stop the spam --- mission/controller/PowerController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index bd760012..edda2911 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -246,13 +246,13 @@ void PowerController::watchStateOfCharge() { if (not pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitLow) { triggerEvent(power::POWER_LEVEL_LOW); pwrLvlLowFlag = true; - } else { + } else if (pwrLvlLowFlag and pwrCtrlCoreHk.coulombCounterCharge.value > payloadOpLimitLow) { pwrLvlLowFlag = false; } if (not pwrLvlCriticalFlag and pwrCtrlCoreHk.coulombCounterCharge.value < higherModesLimit) { triggerEvent(power::POWER_LEVEL_CRITICAL); pwrLvlCriticalFlag = true; - } else { + } else if (pwrLvlCriticalFlag and pwrCtrlCoreHk.coulombCounterCharge.value > higherModesLimit) { pwrLvlCriticalFlag = false; } } else { From 25a5e187f6f4a5661c043e383e1f88f11526c5f5 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 9 Oct 2023 15:21:38 +0200 Subject: [PATCH 53/67] object factory changes --- bsp_q7s/em/emObjectFactory.cpp | 2 +- bsp_q7s/fmObjectFactory.cpp | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 94e10784..bf7db524 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -147,6 +147,7 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_BPX_BATTERY_HANDLER == 1 createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); #endif + createPowerController(true, enableHkSets); #if OBSW_ADD_STAR_TRACKER == 1 createStrComponents(pwrSwitcher); @@ -178,7 +179,6 @@ void ObjectFactory::produce(void* args) { power::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V); #endif createAcsController(true, enableHkSets); - createPowerController(true, enableHkSets); HeaterHandler* heaterHandler; createHeaterComponents(gpioComIF, pwrSwitcher, healthTable, heaterHandler); createThermalController(*heaterHandler, true); diff --git a/bsp_q7s/fmObjectFactory.cpp b/bsp_q7s/fmObjectFactory.cpp index c6dc1d28..c01c4ccb 100644 --- a/bsp_q7s/fmObjectFactory.cpp +++ b/bsp_q7s/fmObjectFactory.cpp @@ -81,14 +81,6 @@ void ObjectFactory::produce(void* args) { createTmpComponents(tmpDevsToAdd); #endif createSolarArrayDeploymentComponents(*pwrSwitcher, *gpioComIF); -#if OBSW_ADD_PL_PCDU == 1 - createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler); -#endif -#if OBSW_ADD_SYRLINKS == 1 - createSyrlinksComponents(pwrSwitcher); -#endif /* OBSW_ADD_SYRLINKS == 1 */ - createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF); - createPayloadComponents(gpioComIF, *pwrSwitcher); const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; if (core::FW_VERSION_MAJOR >= 4) { @@ -102,6 +94,17 @@ void ObjectFactory::produce(void* args) { #if OBSW_ADD_BPX_BATTERY_HANDLER == 1 createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); #endif + createPowerController(true, enableHkSets); + +#if OBSW_ADD_PL_PCDU == 1 + createPlPcduComponents(gpioComIF, spiMainComIF, pwrSwitcher, *stackHandler); +#endif +#if OBSW_ADD_SYRLINKS == 1 + createSyrlinksComponents(pwrSwitcher); +#endif /* OBSW_ADD_SYRLINKS == 1 */ + + createRtdComponents(q7s::SPI_DEFAULT_DEV, gpioComIF, pwrSwitcher, spiMainComIF); + createPayloadComponents(gpioComIF, *pwrSwitcher); #if OBSW_ADD_STAR_TRACKER == 1 createStrComponents(pwrSwitcher); @@ -132,6 +135,5 @@ void ObjectFactory::produce(void* args) { createMiscComponents(); createThermalController(*heaterHandler, false); createAcsController(true, enableHkSets); - createPowerController(true, enableHkSets); satsystem::init(false); } From 9421b220987b53bbd038b672dab17021b7c37221 Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 9 Oct 2023 15:21:53 +0200 Subject: [PATCH 54/67] remove from target table --- mission/system/power/epsModeTree.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mission/system/power/epsModeTree.cpp b/mission/system/power/epsModeTree.cpp index 7c81b38f..83f04ac5 100644 --- a/mission/system/power/epsModeTree.cpp +++ b/mission/system/power/epsModeTree.cpp @@ -87,8 +87,7 @@ void buildNormalSequence(Subsystem& ss, ModeListEntry& eh) { check(sequence.insert(eh), ctxc); }; - // Normal target table - iht(objects::POWER_CONTROLLER, NML, 0, EPS_TABLE_NORMAL_TGT.second); + // Normal table target table is empty check(ss.addTable(TableEntry(EPS_TABLE_NORMAL_TGT.first, &EPS_TABLE_NORMAL_TGT.second)), ctxc); // Transition 0 From 5f9247ee1e988be5d249734b5e008c7d2cde8b3d Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 9 Oct 2023 15:36:49 +0200 Subject: [PATCH 55/67] this does not work --- mission/controller/PowerController.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index edda2911..c990ee59 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -48,6 +48,7 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI ReturnValue_t result = calculateCoulombCounterChargeUpperThreshold(); if (result != returnvalue::OK) { coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; + return returnvalue::FAILED; } break; } @@ -268,7 +269,7 @@ ReturnValue_t PowerController::calculateOpenCircuitVoltageCharge() { float vBatCorrected = (bpxBatteryHk.battVoltage.value - iBat * batteryInternalResistance) * CONVERT_FROM_MILLI; uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; - ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx); + ReturnValue_t result = lookUpTableOcvIdxFinder(vBatCorrected, lookUpTableIdx, false); if (result != returnvalue::OK) { return result; } @@ -328,16 +329,16 @@ float PowerController::linearInterpolation(float x, float x0, float x1, float y0 return y0 + (x - x0) * (y1 - y0) / (x1 - x0); } -ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx) { +ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &idx, bool paramCmd) { if (voltage >= lookUpTableOcv[1][99]) { - if (not voltageOutOfBoundsFlag) { + if (not voltageOutOfBoundsFlag and not paramCmd) { triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 0, static_cast(voltage * 10)); voltageOutOfBoundsFlag = true; } sif::error << "Power Controller::Voltage is too high: " << voltage << std::endl; return returnvalue::FAILED; } else if (voltage <= lookUpTableOcv[1][0]) { - if (not voltageOutOfBoundsFlag) { + if (not voltageOutOfBoundsFlag and not paramCmd) { triggerEvent(power::VOLTAGE_OUT_OF_BOUNDS, 1, static_cast(voltage * 10)); voltageOutOfBoundsFlag = true; } @@ -354,7 +355,7 @@ ReturnValue_t PowerController::lookUpTableOcvIdxFinder(float voltage, uint8_t &i ReturnValue_t PowerController::calculateCoulombCounterChargeUpperThreshold() { uint8_t lookUpTableIdx = LOOK_UP_TABLE_MAX_IDX; ReturnValue_t result = - lookUpTableOcvIdxFinder(coulombCounterVoltageUpperThreshold, lookUpTableIdx); + lookUpTableOcvIdxFinder(coulombCounterVoltageUpperThreshold, lookUpTableIdx, true); if (result != returnvalue::OK) { return result; } From 33d3e7686cc56b4940cc355aeb7878fcbde73dba Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 10 Oct 2023 10:06:10 +0200 Subject: [PATCH 56/67] right we need dummies ... --- dummies/PlPcduDummy.cpp | 15 +++++++++++++++ dummies/PlPcduDummy.h | 6 ++++++ dummies/PlocMpsocDummy.cpp | 15 +++++++++++++++ dummies/PlocMpsocDummy.h | 5 +++++ dummies/PlocSupervisorDummy.cpp | 16 ++++++++++++++++ dummies/PlocSupervisorDummy.h | 5 +++++ 6 files changed, 62 insertions(+) diff --git a/dummies/PlPcduDummy.cpp b/dummies/PlPcduDummy.cpp index 7dfa4464..589fb075 100644 --- a/dummies/PlPcduDummy.cpp +++ b/dummies/PlPcduDummy.cpp @@ -43,3 +43,18 @@ ReturnValue_t PlPcduDummy::initializeLocalDataPool(localpool::DataPool &localDat localDataPoolMap.emplace(plpcdu::PlPcduPoolIds::TEMP, new PoolEntry({0.0}, true)); return returnvalue::OK; } + +ReturnValue_t PlPcduDummy::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); + } + } + return NON_OP_STATE_OF_CHARGE; + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} diff --git a/dummies/PlPcduDummy.h b/dummies/PlPcduDummy.h index 8bf7f0c2..70ee5c46 100644 --- a/dummies/PlPcduDummy.h +++ b/dummies/PlPcduDummy.h @@ -1,7 +1,9 @@ #ifndef DUMMIES_PLPCDUDUMMY_H_ #define DUMMIES_PLPCDUDUMMY_H_ +#include #include +#include #include class PlPcduDummy : public DeviceHandlerBase { @@ -29,6 +31,10 @@ class PlPcduDummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) override; + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); }; #endif /* DUMMIES_PLPCDUDUMMY_H_ */ diff --git a/dummies/PlocMpsocDummy.cpp b/dummies/PlocMpsocDummy.cpp index e1410ba1..47af8513 100644 --- a/dummies/PlocMpsocDummy.cpp +++ b/dummies/PlocMpsocDummy.cpp @@ -23,6 +23,21 @@ ReturnValue_t PlocMpsocDummy::buildCommandFromCommand(DeviceCommandId_t deviceCo return returnvalue::OK; } +ReturnValue_t PlocMpsocDummy::checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); + } + } + return NON_OP_STATE_OF_CHARGE; + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} + ReturnValue_t PlocMpsocDummy::scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) { return returnvalue::OK; diff --git a/dummies/PlocMpsocDummy.h b/dummies/PlocMpsocDummy.h index cc09e45e..28960fe3 100644 --- a/dummies/PlocMpsocDummy.h +++ b/dummies/PlocMpsocDummy.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include "mission/power/defs.h" @@ -24,6 +26,9 @@ class PlocMpsocDummy : public DeviceHandlerBase { size_t commandDataLen) override; ReturnValue_t scanForReply(const uint8_t *start, size_t len, DeviceCommandId_t *foundId, size_t *foundLen) override; + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) override; + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; void fillCommandAndReplyMap() override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; diff --git a/dummies/PlocSupervisorDummy.cpp b/dummies/PlocSupervisorDummy.cpp index b9b1948f..f37bb328 100644 --- a/dummies/PlocSupervisorDummy.cpp +++ b/dummies/PlocSupervisorDummy.cpp @@ -51,3 +51,19 @@ ReturnValue_t PlocSupervisorDummy::getSwitches(const uint8_t **switches, *switches = reinterpret_cast(&switchId); return returnvalue::OK; } + +ReturnValue_t PlocSupervisorDummy::checkModeCommand(Mode_t commandedMode, + Submode_t commandedSubmode, + uint32_t *msToReachTheMode) { + if (commandedMode != MODE_OFF) { + PoolReadGuard pg(&enablePl); + if (pg.getReadResult() == returnvalue::OK) { + if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); + } + } + return NON_OP_STATE_OF_CHARGE; + } + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); +} diff --git a/dummies/PlocSupervisorDummy.h b/dummies/PlocSupervisorDummy.h index 33951cb7..c5334e56 100644 --- a/dummies/PlocSupervisorDummy.h +++ b/dummies/PlocSupervisorDummy.h @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include class PlocSupervisorDummy : public DeviceHandlerBase { @@ -32,4 +34,7 @@ class PlocSupervisorDummy : public DeviceHandlerBase { ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; + ReturnValue_t checkModeCommand(Mode_t commandedMode, Submode_t commandedSubmode, + uint32_t *msToReachTheMode) override; + pwrctrl::EnablePl enablePl = pwrctrl::EnablePl(objects::POWER_CONTROLLER); }; From 000077f327a23233090fb5178d5a9cd36fce8590 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 10 Oct 2023 10:06:32 +0200 Subject: [PATCH 57/67] corrected logic --- linux/payload/PlocMpsocHandler.cpp | 6 ++++-- linux/payload/PlocSupervisorHandler.cpp | 6 ++++-- mission/payload/PayloadPcduHandler.cpp | 6 ++++-- mission/system/objects/CamSwitcher.cpp | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 66fba6d8..c5a17536 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1511,10 +1511,12 @@ ReturnValue_t PlocMpsocHandler::checkModeCommand(Mode_t commandedMode, Submode_t if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { - return NON_OP_STATE_OF_CHARGE; + if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); } } + return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/linux/payload/PlocSupervisorHandler.cpp b/linux/payload/PlocSupervisorHandler.cpp index 0c6311de..43b8abb2 100644 --- a/linux/payload/PlocSupervisorHandler.cpp +++ b/linux/payload/PlocSupervisorHandler.cpp @@ -1999,10 +1999,12 @@ ReturnValue_t PlocSupervisorHandler::checkModeCommand(Mode_t commandedMode, if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { - return NON_OP_STATE_OF_CHARGE; + if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); } } + return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/mission/payload/PayloadPcduHandler.cpp b/mission/payload/PayloadPcduHandler.cpp index bda15b20..d75ec35e 100644 --- a/mission/payload/PayloadPcduHandler.cpp +++ b/mission/payload/PayloadPcduHandler.cpp @@ -569,10 +569,12 @@ ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { - return NON_OP_STATE_OF_CHARGE; + if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { + return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); } } + return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/mission/system/objects/CamSwitcher.cpp b/mission/system/objects/CamSwitcher.cpp index 93b67646..300d1cb2 100644 --- a/mission/system/objects/CamSwitcher.cpp +++ b/mission/system/objects/CamSwitcher.cpp @@ -14,10 +14,12 @@ ReturnValue_t CamSwitcher::checkModeCommand(Mode_t commandedMode, Submode_t comm if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { - return TRANS_NOT_ALLOWED; + if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { + return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, + msToReachTheMode); } } + return TRANS_NOT_ALLOWED; } return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); From b635e02f2d57320c38d990c0651597fd05a147fc Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 10 Oct 2023 10:07:01 +0200 Subject: [PATCH 58/67] gens --- bsp_hosted/fsfwconfig/events/translateEvents.cpp | 2 +- bsp_hosted/fsfwconfig/objects/translateObjects.cpp | 2 +- generators/bsp_hosted_events.csv | 4 ++-- generators/bsp_hosted_returnvalues.csv | 1 + generators/bsp_q7s_events.csv | 4 ++-- generators/bsp_q7s_returnvalues.csv | 1 + generators/events/translateEvents.cpp | 2 +- generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 2 +- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- 10 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 610a69fb..c7d9efc1 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-28 15:53:20 + * Generated on: 2023-10-09 16:27:37 */ #include "translateEvents.h" diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index f3f7d5fb..ac93d7f1 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 173 translations. - * Generated on: 2023-09-28 15:53:20 + * Generated on: 2023-10-09 16:27:37 */ #include "translateObjects.h" diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index 442fc05c..2cd6ca2f 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -100,8 +100,8 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h 11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h 11304;0x2c28;DATASET_READ_FAILED;INFO;The dataset read for the inputs of the Power Controller has failed.;mission/power/defs.h -11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;The battery voltage read is out of the bounds in which it is supposed to be. P1: 1 too high, 0 too low;mission/power/defs.h -11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large.;mission/power/defs.h +11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;No description;mission/power/defs.h +11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large. P1: time in s * 10;mission/power/defs.h 11307;0x2c2b;POWER_LEVEL_LOW;HIGH;The State of Charge is below the limit for payload use. Setting Payload to faulty.;mission/power/defs.h 11308;0x2c2c;POWER_LEVEL_CRITICAL;HIGH;The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty.;mission/power/defs.h 11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h diff --git a/generators/bsp_hosted_returnvalues.csv b/generators/bsp_hosted_returnvalues.csv index e3db4c9a..49cfb0a2 100644 --- a/generators/bsp_hosted_returnvalues.csv +++ b/generators/bsp_hosted_returnvalues.csv @@ -210,6 +210,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x27a8;DHI_NoReplyExpected;No description;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27a9;DHI_NonOpTemperature;No description;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27aa;DHI_CommandNotImplemented;No description;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x27ab;DHI_NonOpStateOfCharge;No description;171;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b0;DHI_ChecksumError;No description;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b1;DHI_LengthMissmatch;No description;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b2;DHI_InvalidData;No description;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 442fc05c..2cd6ca2f 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -100,8 +100,8 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11302;0x2c26;SWITCHING_Q7S_DENIED;MEDIUM;No description;mission/power/defs.h 11303;0x2c27;FDIR_REACTION_IGNORED;MEDIUM;No description;mission/power/defs.h 11304;0x2c28;DATASET_READ_FAILED;INFO;The dataset read for the inputs of the Power Controller has failed.;mission/power/defs.h -11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;The battery voltage read is out of the bounds in which it is supposed to be. P1: 1 too high, 0 too low;mission/power/defs.h -11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large.;mission/power/defs.h +11305;0x2c29;VOLTAGE_OUT_OF_BOUNDS;HIGH;No description;mission/power/defs.h +11306;0x2c2a;TIMEDELTA_OUT_OF_BOUNDS;LOW;Time difference for Coulomb Counter was too large. P1: time in s * 10;mission/power/defs.h 11307;0x2c2b;POWER_LEVEL_LOW;HIGH;The State of Charge is below the limit for payload use. Setting Payload to faulty.;mission/power/defs.h 11308;0x2c2c;POWER_LEVEL_CRITICAL;HIGH;The State of Charge is below the limit for higher modes. Setting Reaction Wheels to faulty.;mission/power/defs.h 11400;0x2c88;GPIO_PULL_HIGH_FAILED;LOW;No description;mission/tcs/HeaterHandler.h diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index 065e5392..9983f079 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -210,6 +210,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x27a8;DHI_NoReplyExpected;No description;168;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27a9;DHI_NonOpTemperature;No description;169;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27aa;DHI_CommandNotImplemented;No description;170;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h +0x27ab;DHI_NonOpStateOfCharge;No description;171;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b0;DHI_ChecksumError;No description;176;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b1;DHI_LengthMissmatch;No description;177;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h 0x27b2;DHI_InvalidData;No description;178;DEVICE_HANDLER_IF;fsfw/src/fsfw/devicehandlers/DeviceHandlerIF.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 610a69fb..c7d9efc1 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-28 15:53:20 + * Generated on: 2023-10-09 16:27:37 */ #include "translateEvents.h" diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 4f191225..856a0bed 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 177 translations. - * Generated on: 2023-09-28 15:53:20 + * Generated on: 2023-10-09 16:27:37 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 610a69fb..c7d9efc1 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-09-28 15:53:20 + * Generated on: 2023-10-09 16:27:37 */ #include "translateEvents.h" diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 4f191225..856a0bed 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 177 translations. - * Generated on: 2023-09-28 15:53:20 + * Generated on: 2023-10-09 16:27:37 */ #include "translateObjects.h" From 98a1ce5380c8ca45d38a08737275228bd7e3397d Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 10 Oct 2023 11:53:54 +0200 Subject: [PATCH 59/67] this should work --- mission/controller/PowerController.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index c990ee59..b1b94d61 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -44,12 +44,17 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI break; case 0x2: { float oldCoulombCounterVoltageUpperThreshold = coulombCounterVoltageUpperThreshold; - parameterWrapper->set(coulombCounterVoltageUpperThreshold); - ReturnValue_t result = calculateCoulombCounterChargeUpperThreshold(); + ReturnValue_t result = newValues->getElement(&coulombCounterVoltageUpperThreshold); if (result != returnvalue::OK) { coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; - return returnvalue::FAILED; + return result; } + result = calculateCoulombCounterChargeUpperThreshold(); + if (result != returnvalue::OK) { + coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; + return result; + } + // parameterWrapper->set(coulombCounterVoltageUpperThreshold); break; } case 0x3: @@ -230,6 +235,11 @@ void PowerController::calculateStateOfCharge() { } void PowerController::watchStateOfCharge() { + if (test < 100) { + test++; + } else if (test == 100) { + // pwrCtrlCoreHk.coulombCounterCharge.value = 0.7; + } if (pwrCtrlCoreHk.coulombCounterCharge.isValid()) { if (pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitOn) { PoolReadGuard pg(&enablePl); From 2c30efa821c4aab542bd96e04f9ad24649936ffa Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 10 Oct 2023 11:54:32 +0200 Subject: [PATCH 60/67] aaand we revert --- dummies/PlPcduDummy.cpp | 6 ++---- dummies/PlocMpsocDummy.cpp | 6 ++---- dummies/PlocSupervisorDummy.cpp | 6 ++---- linux/payload/PlocMpsocHandler.cpp | 6 ++---- linux/payload/PlocSupervisorHandler.cpp | 6 ++---- mission/controller/PowerController.h | 13 ++++++++----- mission/payload/PayloadPcduHandler.cpp | 6 ++---- mission/system/objects/CamSwitcher.cpp | 6 ++---- 8 files changed, 22 insertions(+), 33 deletions(-) diff --git a/dummies/PlPcduDummy.cpp b/dummies/PlPcduDummy.cpp index 589fb075..cf652513 100644 --- a/dummies/PlPcduDummy.cpp +++ b/dummies/PlPcduDummy.cpp @@ -49,12 +49,10 @@ ReturnValue_t PlPcduDummy::checkModeCommand(Mode_t commandedMode, Submode_t comm if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { - return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, - msToReachTheMode); + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; } } - return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/dummies/PlocMpsocDummy.cpp b/dummies/PlocMpsocDummy.cpp index 47af8513..9959dd0f 100644 --- a/dummies/PlocMpsocDummy.cpp +++ b/dummies/PlocMpsocDummy.cpp @@ -28,12 +28,10 @@ ReturnValue_t PlocMpsocDummy::checkModeCommand(Mode_t commandedMode, Submode_t c if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { - return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, - msToReachTheMode); + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; } } - return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/dummies/PlocSupervisorDummy.cpp b/dummies/PlocSupervisorDummy.cpp index f37bb328..c560c91f 100644 --- a/dummies/PlocSupervisorDummy.cpp +++ b/dummies/PlocSupervisorDummy.cpp @@ -58,12 +58,10 @@ ReturnValue_t PlocSupervisorDummy::checkModeCommand(Mode_t commandedMode, if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { - return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, - msToReachTheMode); + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; } } - return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index c5a17536..66fba6d8 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1511,12 +1511,10 @@ ReturnValue_t PlocMpsocHandler::checkModeCommand(Mode_t commandedMode, Submode_t if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { - return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, - msToReachTheMode); + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; } } - return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/linux/payload/PlocSupervisorHandler.cpp b/linux/payload/PlocSupervisorHandler.cpp index 43b8abb2..0c6311de 100644 --- a/linux/payload/PlocSupervisorHandler.cpp +++ b/linux/payload/PlocSupervisorHandler.cpp @@ -1999,12 +1999,10 @@ ReturnValue_t PlocSupervisorHandler::checkModeCommand(Mode_t commandedMode, if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { - return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, - msToReachTheMode); + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; } } - return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index adff4733..e57a7858 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -24,6 +24,8 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM uint16_t startAtIndex) override; private: + int test = 0; + bool enableHkSets = false; ParameterHelper parameterHelper; @@ -48,7 +50,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM ReturnValue_t calculateCoulombCounterCharge(); ReturnValue_t updateEpsData(); float charge2stateOfCharge(float capacity, bool coulombCounter); - ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx); + ReturnValue_t lookUpTableOcvIdxFinder(float voltage, uint8_t& idx, bool paramCmd); float linearInterpolation(float x, float x0, float x1, float y0, float y1); ReturnValue_t calculateCoulombCounterChargeUpperThreshold(); @@ -103,10 +105,11 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM // Variables timeval now; timeval oldTime; - int16_t iBat = 0; // [mA] - float openCircuitVoltageCharge = 0.0; // [Ah] - float coulombCounterCharge = 0.0; // [Ah] - float coulombCounterChargeUpperThreshold = 0.0; // [Ah] + int16_t iBat = 0; // [mA] + float openCircuitVoltageCharge = 0.0; // [Ah] + float coulombCounterCharge = 0.0; // [Ah] + float coulombCounterChargeUpperThreshold = 0.0; // [Ah] + float oldCoulombCounterVoltageUpperThreshold = 0.0; // [V] static constexpr float CONVERT_FROM_MILLI = 1e-3; static constexpr float SECONDS_TO_HOURS = 1. / (60. * 60.); diff --git a/mission/payload/PayloadPcduHandler.cpp b/mission/payload/PayloadPcduHandler.cpp index d75ec35e..bda15b20 100644 --- a/mission/payload/PayloadPcduHandler.cpp +++ b/mission/payload/PayloadPcduHandler.cpp @@ -569,12 +569,10 @@ ReturnValue_t PayloadPcduHandler::checkModeCommand(Mode_t commandedMode, Submode if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { - return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, - msToReachTheMode); + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return NON_OP_STATE_OF_CHARGE; } } - return NON_OP_STATE_OF_CHARGE; } return DeviceHandlerBase::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); } diff --git a/mission/system/objects/CamSwitcher.cpp b/mission/system/objects/CamSwitcher.cpp index 300d1cb2..93b67646 100644 --- a/mission/system/objects/CamSwitcher.cpp +++ b/mission/system/objects/CamSwitcher.cpp @@ -14,12 +14,10 @@ ReturnValue_t CamSwitcher::checkModeCommand(Mode_t commandedMode, Submode_t comm if (commandedMode != MODE_OFF) { PoolReadGuard pg(&enablePl); if (pg.getReadResult() == returnvalue::OK) { - if (enablePl.plUseAllowed.isValid() and enablePl.plUseAllowed.value) { - return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, - msToReachTheMode); + if (enablePl.plUseAllowed.isValid() and not enablePl.plUseAllowed.value) { + return TRANS_NOT_ALLOWED; } } - return TRANS_NOT_ALLOWED; } return PowerSwitcherComponent::checkModeCommand(commandedMode, commandedSubmode, msToReachTheMode); From 0da1fecf390cf871bad9af5a017afc358102cc32 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 10 Oct 2023 13:50:15 +0200 Subject: [PATCH 61/67] updatr submodules --- fsfw | 2 +- tmtc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsfw b/fsfw index e3a81544..0f604b35 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e3a815444e401fc2fa75f6f19b40a18eceee08a5 +Subproject commit 0f604b35c6d3a2518e3c3ce3947825102e9fc4f4 diff --git a/tmtc b/tmtc index dd74f6c3..be1ac095 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit dd74f6c3ca0e730c7f316ed7959d2992c4a14fb4 +Subproject commit be1ac0951539971ada7cb490faab07f923b39430 From 9a80af9b95dcb879202f1beec2802a66f1f5eb25 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 10 Oct 2023 13:51:41 +0200 Subject: [PATCH 62/67] update tmtc --- bsp_hosted/fsfwconfig/events/translateEvents.cpp | 2 +- bsp_hosted/fsfwconfig/objects/translateObjects.cpp | 2 +- generators/bsp_hosted_returnvalues.csv | 8 ++++---- generators/bsp_q7s_returnvalues.csv | 8 ++++---- generators/events/translateEvents.cpp | 2 +- generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 2 +- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- tmtc | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index c7d9efc1..77df8166 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-10-09 16:27:37 + * Generated on: 2023-10-10 13:50:27 */ #include "translateEvents.h" diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index ac93d7f1..8d80ca56 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 173 translations. - * Generated on: 2023-10-09 16:27:37 + * Generated on: 2023-10-10 13:50:27 */ #include "translateObjects.h" diff --git a/generators/bsp_hosted_returnvalues.csv b/generators/bsp_hosted_returnvalues.csv index 49cfb0a2..0dfc94c3 100644 --- a/generators/bsp_hosted_returnvalues.csv +++ b/generators/bsp_hosted_returnvalues.csv @@ -358,6 +358,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3a02;MQI_Full;No space left for more messages;2;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a03;MQI_NoReplyPartner;Returned if a reply method was called without partner;3;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a04;MQI_DestinationInvalid;Returned if the target destination is invalid.;4;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h +0x3b00;SPH_ConnBroken;No description;0;SEMAPHORE_IF;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x3b01;SPH_SemaphoreTimeout;No description;1;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b02;SPH_SemaphoreNotOwned;No description;2;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b03;SPH_SemaphoreInvalid;No description;3;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h @@ -373,7 +374,6 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3e05;HKM_DatasetNotFound;No description;5;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h 0x3f01;DLEE_StreamTooShort;No description;1;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h 0x3f02;DLEE_DecodingError;No description;2;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h -0x4100;PUS9_ConnBroken;No description;0;PUS_SERVICE_9;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x4201;PUS11_InvalidTypeTimeWindow;No description;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4202;PUS11_InvalidTimeWindow;No description;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4203;PUS11_TimeshiftingNotPossible;No description;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h @@ -403,9 +403,9 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x4403;UXOS_CommandError;Command execution failed;3;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4404;UXOS_NoCommandLoadedOrPending;;4;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4406;UXOS_PcloseCallError;No description;6;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h -0x4500;HSPI_HalTimeoutRetval;No description;0;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h -0x4501;HSPI_HalBusyRetval;No description;1;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h -0x4502;HSPI_HalErrorRetval;No description;2;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4500;HSPI_OpeningFileFailed;No description;0;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h +0x4501;HSPI_FullDuplexTransferFailed;No description;1;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h +0x4502;HSPI_HalfDuplexTransferFailed;No description;2;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4503;HSPI_Timeout;No description;3;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4504;HSPI_Busy;No description;4;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4505;HSPI_GenericError;No description;5;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h diff --git a/generators/bsp_q7s_returnvalues.csv b/generators/bsp_q7s_returnvalues.csv index 9983f079..0e804457 100644 --- a/generators/bsp_q7s_returnvalues.csv +++ b/generators/bsp_q7s_returnvalues.csv @@ -358,6 +358,7 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3a02;MQI_Full;No space left for more messages;2;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a03;MQI_NoReplyPartner;Returned if a reply method was called without partner;3;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h 0x3a04;MQI_DestinationInvalid;Returned if the target destination is invalid.;4;MESSAGE_QUEUE_IF;fsfw/src/fsfw/ipc/MessageQueueIF.h +0x3b00;SPH_ConnBroken;No description;0;SEMAPHORE_IF;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x3b01;SPH_SemaphoreTimeout;No description;1;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b02;SPH_SemaphoreNotOwned;No description;2;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h 0x3b03;SPH_SemaphoreInvalid;No description;3;SEMAPHORE_IF;fsfw/src/fsfw/tasks/SemaphoreIF.h @@ -373,7 +374,6 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x3e05;HKM_DatasetNotFound;No description;5;HOUSEKEEPING_MANAGER;fsfw/src/fsfw/datapoollocal/LocalDataPoolManager.h 0x3f01;DLEE_StreamTooShort;No description;1;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h 0x3f02;DLEE_DecodingError;No description;2;DLE_ENCODER;fsfw/src/fsfw/globalfunctions/DleEncoder.h -0x4100;PUS9_ConnBroken;No description;0;PUS_SERVICE_9;fsfw/src/fsfw/osal/common/TcpTmTcServer.h 0x4201;PUS11_InvalidTypeTimeWindow;No description;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4202;PUS11_InvalidTimeWindow;No description;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4203;PUS11_TimeshiftingNotPossible;No description;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h @@ -403,9 +403,9 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path 0x4403;UXOS_CommandError;Command execution failed;3;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4404;UXOS_NoCommandLoadedOrPending;;4;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h 0x4406;UXOS_PcloseCallError;No description;6;LINUX_OSAL;fsfw/src/fsfw_hal/linux/CommandExecutor.h -0x4500;HSPI_HalTimeoutRetval;No description;0;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h -0x4501;HSPI_HalBusyRetval;No description;1;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h -0x4502;HSPI_HalErrorRetval;No description;2;HAL_SPI;fsfw/src/fsfw_hal/stm32h7/spi/spiDefinitions.h +0x4500;HSPI_OpeningFileFailed;No description;0;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h +0x4501;HSPI_FullDuplexTransferFailed;No description;1;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h +0x4502;HSPI_HalfDuplexTransferFailed;No description;2;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4503;HSPI_Timeout;No description;3;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4504;HSPI_Busy;No description;4;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h 0x4505;HSPI_GenericError;No description;5;HAL_SPI;fsfw/src/fsfw_hal/common/spi/spiCommon.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index c7d9efc1..77df8166 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-10-09 16:27:37 + * Generated on: 2023-10-10 13:50:27 */ #include "translateEvents.h" diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 856a0bed..aeb2b405 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 177 translations. - * Generated on: 2023-10-09 16:27:37 + * Generated on: 2023-10-10 13:50:27 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index c7d9efc1..77df8166 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** * @brief Auto-generated event translation file. Contains 313 translations. * @details - * Generated on: 2023-10-09 16:27:37 + * Generated on: 2023-10-10 13:50:27 */ #include "translateEvents.h" diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 856a0bed..aeb2b405 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 177 translations. - * Generated on: 2023-10-09 16:27:37 + * Generated on: 2023-10-10 13:50:27 */ #include "translateObjects.h" diff --git a/tmtc b/tmtc index be1ac095..bde03fc9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit be1ac0951539971ada7cb490faab07f923b39430 +Subproject commit bde03fc9c065cdd4dd8fd79da5c43f9510013813 From b9f05a14f7858dfa88d7ea82a5993fe6feab2fbd Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 11 Oct 2023 09:24:36 +0200 Subject: [PATCH 63/67] removed debug stuff --- mission/controller/PowerController.cpp | 7 +------ mission/controller/PowerController.h | 4 +--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/mission/controller/PowerController.cpp b/mission/controller/PowerController.cpp index b1b94d61..7b7db9e8 100644 --- a/mission/controller/PowerController.cpp +++ b/mission/controller/PowerController.cpp @@ -54,7 +54,7 @@ ReturnValue_t PowerController::getParameter(uint8_t domainId, uint8_t parameterI coulombCounterVoltageUpperThreshold = oldCoulombCounterVoltageUpperThreshold; return result; } - // parameterWrapper->set(coulombCounterVoltageUpperThreshold); + parameterWrapper->set(coulombCounterVoltageUpperThreshold); break; } case 0x3: @@ -235,11 +235,6 @@ void PowerController::calculateStateOfCharge() { } void PowerController::watchStateOfCharge() { - if (test < 100) { - test++; - } else if (test == 100) { - // pwrCtrlCoreHk.coulombCounterCharge.value = 0.7; - } if (pwrCtrlCoreHk.coulombCounterCharge.isValid()) { if (pwrCtrlCoreHk.coulombCounterCharge.value < payloadOpLimitOn) { PoolReadGuard pg(&enablePl); diff --git a/mission/controller/PowerController.h b/mission/controller/PowerController.h index e57a7858..1f27616d 100644 --- a/mission/controller/PowerController.h +++ b/mission/controller/PowerController.h @@ -24,8 +24,6 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM uint16_t startAtIndex) override; private: - int test = 0; - bool enableHkSets = false; ParameterHelper parameterHelper; @@ -58,7 +56,7 @@ class PowerController : public ExtendedControllerBase, public ReceivesParameterM float batteryInternalResistance = 70.0 / 2.0 / 1000.0; // [Ohm] float batteryMaximumCapacity = 2.6 * 2; // [Ah] float coulombCounterVoltageUpperThreshold = 16.2; // [V] - double maxAllowedTimeDiff = 0.5; // [s] + double maxAllowedTimeDiff = 1.5; // [s] float payloadOpLimitOn = 0.90; // [%] float payloadOpLimitLow = 0.75; // [%] float higherModesLimit = 0.6; // [%] From a0c246b1da3ab7cf31f01c9f227c353322520de5 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 11 Oct 2023 09:24:48 +0200 Subject: [PATCH 64/67] rw dummy fix --- dummies/RwDummy.cpp | 18 ++++++++++++++++++ dummies/RwDummy.h | 1 + 2 files changed, 19 insertions(+) diff --git a/dummies/RwDummy.cpp b/dummies/RwDummy.cpp index 0bf4db42..05e14396 100644 --- a/dummies/RwDummy.cpp +++ b/dummies/RwDummy.cpp @@ -93,3 +93,21 @@ ReturnValue_t RwDummy::initializeLocalDataPool(localpool::DataPool &localDataPoo subdp::RegularHkPeriodicParams(lastResetStatusSet.getSid(), false, 30.0)); return returnvalue::OK; } + +LocalPoolDataSetBase *RwDummy::getDataSetHandle(sid_t sid) { + switch (sid.ownerSetId) { + case (rws::SetIds::STATUS_SET_ID): { + return &statusSet; + } + case (rws::SetIds::LAST_RESET_ID): { + return &lastResetStatusSet; + } + case (rws::SetIds::SPEED_CMD_SET): { + return &rwSpeedActuationSet; + } + case (rws::SetIds::TM_SET_ID): { + return &tmDataset; + } + } + return nullptr; +} diff --git a/dummies/RwDummy.h b/dummies/RwDummy.h index 03629937..512c4250 100644 --- a/dummies/RwDummy.h +++ b/dummies/RwDummy.h @@ -37,6 +37,7 @@ class RwDummy : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) override; + LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override; }; #endif /* DUMMIES_RWDUMMY_H_ */ From eb24749abecabc12a28c3e4f206e979b72431362 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 11 Oct 2023 09:25:12 +0200 Subject: [PATCH 65/67] emObjectFactory fix --- bsp_q7s/em/emObjectFactory.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index bf7db524..370e8d3d 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -106,6 +106,17 @@ void ObjectFactory::produce(void* args) { #endif satsystem::EIVE_SYSTEM.setI2cRecoveryParams(pwrSwitcher); + const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; + if (core::FW_VERSION_MAJOR >= 4) { + battAndImtqI2cDev = q7s::I2C_PS_EIVE; + } + static_cast(battAndImtqI2cDev); + +#if OBSW_ADD_BPX_BATTERY_HANDLER == 1 + createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); +#endif + createPowerController(true, enableHkSets); + dummy::createDummies(dummyCfg, *pwrSwitcher, gpioComIF, enableHkSets); new CoreController(objects::CORE_CONTROLLER, enableHkSets); @@ -126,12 +137,6 @@ void ObjectFactory::produce(void* args) { gpioChecker(gpioComIF->addGpios(acsBoardGpios), "ACS Board"); #endif - const char* battAndImtqI2cDev = q7s::I2C_PL_EIVE; - if (core::FW_VERSION_MAJOR >= 4) { - battAndImtqI2cDev = q7s::I2C_PS_EIVE; - } - static_cast(battAndImtqI2cDev); - #if OBSW_ADD_MGT == 1 createImtqComponents(pwrSwitcher, enableHkSets, battAndImtqI2cDev); #endif @@ -144,11 +149,6 @@ void ObjectFactory::produce(void* args) { createReactionWheelComponents(gpioComIF, pwrSwitcher); #endif -#if OBSW_ADD_BPX_BATTERY_HANDLER == 1 - createBpxBatteryComponent(enableHkSets, battAndImtqI2cDev); -#endif - createPowerController(true, enableHkSets); - #if OBSW_ADD_STAR_TRACKER == 1 createStrComponents(pwrSwitcher); #endif /* OBSW_ADD_STAR_TRACKER == 1 */ From ac784b58993bd1e74b16fba896e334ff577e1ac9 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 11 Oct 2023 09:27:11 +0200 Subject: [PATCH 66/67] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index bde03fc9..d82cecbe 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit bde03fc9c065cdd4dd8fd79da5c43f9510013813 +Subproject commit d82cecbe6e51e76a5b3b974b1c0d32ea22693853 From 6cada9bfc0d4da0b6464722a8f3a6204e53ef2c0 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 11 Oct 2023 09:31:32 +0200 Subject: [PATCH 67/67] changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ae7901e..0426873f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,15 @@ will consitute of a breaking change warranting a new major release: # [unreleased] +- Bumped `eive-tmtc` to v5.7.0. +- Bumped `eive-fsfw` + +## Added + +- EPS Subsystem has been added to EIVE System Tree +- Power Controller for calculating the State of Charge and FDIR regarding low SoC has been + introduced. + ## Changed - Changed internals for MPSoC boot process to make the code more understandable and some