Merge pull request 'basic faulty cb for power switcher component' (#134) from feature_power_switch_faulty_cb into develop

Reviewed-on: eive/fsfw#134
This commit is contained in:
Robin Müller 2023-03-14 14:15:11 +01:00
commit 0973ba6bf2
3 changed files with 18 additions and 12 deletions

View File

@ -29,6 +29,9 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) {
continue; continue;
} }
} }
if (getHealth() == FAULTY) {
performFaultyOperation();
}
if (switcher.active()) { if (switcher.active()) {
switcher.doStateMachine(); switcher.doStateMachine();
auto currState = switcher.getState(); auto currState = switcher.getState();
@ -118,3 +121,5 @@ ReturnValue_t PowerSwitcherComponent::connectModeTreeParent(HasModeTreeChildrenI
object_id_t PowerSwitcherComponent::getObjectId() const { return SystemObject::getObjectId(); } object_id_t PowerSwitcherComponent::getObjectId() const { return SystemObject::getObjectId(); }
ModeTreeChildIF& PowerSwitcherComponent::getModeTreeChildIF() { return *this; } ModeTreeChildIF& PowerSwitcherComponent::getModeTreeChildIF() { return *this; }
void PowerSwitcherComponent::performFaultyOperation() {}

View File

@ -1,5 +1,4 @@
#ifndef _FSFW_POWER_POWERSWITCHERCOMPONENT_H_ #pragma once
#define _FSFW_POWER_POWERSWITCHERCOMPONENT_H_
#include <fsfw/health/HasHealthIF.h> #include <fsfw/health/HasHealthIF.h>
#include <fsfw/health/HealthHelper.h> #include <fsfw/health/HealthHelper.h>
@ -37,9 +36,11 @@ class PowerSwitcherComponent : public SystemObject,
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
ModeTreeChildIF &getModeTreeChildIF() override; ModeTreeChildIF &getModeTreeChildIF() override;
protected:
PowerSwitcher switcher;
private: private:
MessageQueueIF *queue = nullptr; MessageQueueIF *queue = nullptr;
PowerSwitcher switcher;
Mode_t mode = MODE_OFF; Mode_t mode = MODE_OFF;
Submode_t submode = 0; Submode_t submode = 0;
@ -49,24 +50,23 @@ class PowerSwitcherComponent : public SystemObject,
void setMode(Mode_t newMode, Submode_t newSubmode); void setMode(Mode_t newMode, Submode_t newSubmode);
virtual ReturnValue_t performOperation(uint8_t opCode) override; ReturnValue_t performOperation(uint8_t opCode) override;
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
MessageQueueId_t getCommandQueue() const override; [[nodiscard]] MessageQueueId_t getCommandQueue() const override;
void getMode(Mode_t *mode, Submode_t *submode) override; void getMode(Mode_t *mode, Submode_t *submode) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override; uint32_t *msToReachTheMode) override;
void startTransition(Mode_t mode, Submode_t submode) override; void startTransition(Mode_t mode, Submode_t submode) override;
virtual void performFaultyOperation();
void setToExternalControl() override; void setToExternalControl() override;
void announceMode(bool recursive) override; void announceMode(bool recursive) override;
ReturnValue_t setHealth(HealthState health) override; ReturnValue_t setHealth(HealthState health) override;
HasHealthIF::HealthState getHealth() override; HasHealthIF::HealthState getHealth() override;
object_id_t getObjectId() const override; [[nodiscard]] object_id_t getObjectId() const override;
const HasHealthIF *getOptHealthIF() const override; [[nodiscard]] const HasHealthIF *getOptHealthIF() const override;
const HasModesIF &getModeIF() const override; [[nodiscard]] const HasModesIF &getModeIF() const override;
}; };
#endif /* _FSFW_POWER_POWERSWITCHERCOMPONENT_H_ */

View File

@ -112,8 +112,9 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
if (i2cCookie->errorCounter < 3) { if (i2cCookie->errorCounter < 3) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::sendMessage: Failed to send data to I2C " sif::error << "I2cComIF::sendMessage: Failed to send data to I2C "
"device from " << deviceFile << " with error code " "device from "
<< errno << ". Error description: " << strerror(errno) << std::endl; << deviceFile << " with error code " << errno
<< ". Error description: " << strerror(errno) << std::endl;
#endif #endif
} }
return returnvalue::FAILED; return returnvalue::FAILED;