Update FSFW #45

Merged
meierj merged 26 commits from mueller/master into eive/develop 2022-03-25 14:56:19 +01:00
4 changed files with 28 additions and 22 deletions
Showing only changes of commit d791fc87b7 - Show all commits

View File

@ -1,6 +1,7 @@
#ifndef FSFW_POWER_POWERSWITCHIF_H_
#define FSFW_POWER_POWERSWITCHIF_H_
#include "definitions.h"
#include "../events/Event.h"
#include "../returnvalues/HasReturnvaluesIF.h"
/**
@ -37,7 +38,7 @@ class PowerSwitchIF : public HasReturnvaluesIF {
* @param switchNr
* @param onOff on == @c SWITCH_ON; off != @c SWITCH_ON
*/
virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const = 0;
virtual void sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) const = 0;
/**
* Sends a command to the Power Unit to enable a certain fuse.
*/
@ -51,7 +52,7 @@ class PowerSwitchIF : public HasReturnvaluesIF {
* - @c SWITCH_OFF if the specified switch is off.
* - @c RETURN_FAILED if an error occured
*/
virtual ReturnValue_t getSwitchState(uint8_t switchNr) const = 0;
virtual ReturnValue_t getSwitchState(power::Switch_t switchNr) const = 0;
/**
* get state of a fuse.
* @param fuseNr

View File

@ -1,19 +1,12 @@
#include "definitions.h"
#include "fsfw/power/PowerSwitcher.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
PowerSwitcher::PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2,
PowerSwitcher::State_t setStartState)
: state(setStartState), firstSwitch(setSwitch1), secondSwitch(setSwitch2) {}
ReturnValue_t PowerSwitcher::initialize(object_id_t powerSwitchId) {
power = ObjectManager::instance()->get<PowerSwitchIF>(powerSwitchId);
if (power == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
PowerSwitcher::PowerSwitcher(PowerSwitchIF* switcher, power::Switch_t setSwitch1,
power::Switch_t setSwitch2, PowerSwitcher::State_t setStartState)
: power(switcher), state(setStartState), firstSwitch(setSwitch1), secondSwitch(setSwitch2) {}
ReturnValue_t PowerSwitcher::getStateOfSwitches() {
SwitchReturn_t result = howManySwitches();
@ -63,7 +56,7 @@ void PowerSwitcher::turnOff() {
}
PowerSwitcher::SwitchReturn_t PowerSwitcher::howManySwitches() {
if (secondSwitch == NO_SWITCH) {
if (secondSwitch == power::NO_SWITCH) {
return ONE_SWITCH;
} else {
return TWO_SWITCHES;

View File

@ -14,28 +14,27 @@ class PowerSwitcher : public HasReturnvaluesIF {
SWITCH_IS_OFF,
SWITCH_IS_ON,
};
State_t state;
static const uint8_t INTERFACE_ID = CLASS_ID::POWER_SWITCHER;
static const ReturnValue_t IN_POWER_TRANSITION = MAKE_RETURN_CODE(1);
static const ReturnValue_t SWITCH_STATE_MISMATCH = MAKE_RETURN_CODE(2);
PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2 = NO_SWITCH,
PowerSwitcher(PowerSwitchIF* switcher, uint8_t setSwitch1, uint8_t setSwitch2 = power::NO_SWITCH,
State_t setStartState = SWITCH_IS_OFF);
ReturnValue_t initialize(object_id_t powerSwitchId);
void turnOn();
void turnOff();
void doStateMachine();
State_t getState();
ReturnValue_t checkSwitchState();
uint32_t getSwitchDelay();
uint8_t getFirstSwitch() const;
uint8_t getSecondSwitch() const;
power::Switch_t getFirstSwitch() const;
power::Switch_t getSecondSwitch() const;
private:
uint8_t firstSwitch;
uint8_t secondSwitch;
PowerSwitchIF* power = nullptr;
State_t state;
power::Switch_t firstSwitch = power::NO_SWITCH;
power::Switch_t secondSwitch = power::NO_SWITCH;
static const uint8_t NO_SWITCH = 0xFF;
enum SwitchReturn_t { ONE_SWITCH = 1, TWO_SWITCHES = 2 };
ReturnValue_t getStateOfSwitches();
void commandSwitches(ReturnValue_t onOff);

View File

@ -0,0 +1,13 @@
#ifndef FSFW_SRC_FSFW_POWER_DEFINITIONS_H_
#define FSFW_SRC_FSFW_POWER_DEFINITIONS_H_
#include <cstdint>
namespace power {
using Switch_t = uint8_t;
static constexpr Switch_t NO_SWITCH = 0xFF;
}
#endif /* FSFW_SRC_FSFW_POWER_DEFINITIONS_H_ */