Update FSFW #45
@ -1,6 +1,7 @@
|
|||||||
#ifndef FSFW_POWER_POWERSWITCHIF_H_
|
#ifndef FSFW_POWER_POWERSWITCHIF_H_
|
||||||
#define FSFW_POWER_POWERSWITCHIF_H_
|
#define FSFW_POWER_POWERSWITCHIF_H_
|
||||||
|
|
||||||
|
#include "definitions.h"
|
||||||
#include "../events/Event.h"
|
#include "../events/Event.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
/**
|
/**
|
||||||
@ -37,7 +38,7 @@ class PowerSwitchIF : public HasReturnvaluesIF {
|
|||||||
* @param switchNr
|
* @param switchNr
|
||||||
* @param onOff on == @c SWITCH_ON; off != @c SWITCH_ON
|
* @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.
|
* 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 SWITCH_OFF if the specified switch is off.
|
||||||
* - @c RETURN_FAILED if an error occured
|
* - @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.
|
* get state of a fuse.
|
||||||
* @param fuseNr
|
* @param fuseNr
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
|
#include "definitions.h"
|
||||||
#include "fsfw/power/PowerSwitcher.h"
|
#include "fsfw/power/PowerSwitcher.h"
|
||||||
|
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
PowerSwitcher::PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2,
|
PowerSwitcher::PowerSwitcher(PowerSwitchIF* switcher, power::Switch_t setSwitch1,
|
||||||
PowerSwitcher::State_t setStartState)
|
power::Switch_t setSwitch2, PowerSwitcher::State_t setStartState)
|
||||||
: state(setStartState), firstSwitch(setSwitch1), secondSwitch(setSwitch2) {}
|
: power(switcher), 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t PowerSwitcher::getStateOfSwitches() {
|
ReturnValue_t PowerSwitcher::getStateOfSwitches() {
|
||||||
SwitchReturn_t result = howManySwitches();
|
SwitchReturn_t result = howManySwitches();
|
||||||
@ -63,7 +56,7 @@ void PowerSwitcher::turnOff() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PowerSwitcher::SwitchReturn_t PowerSwitcher::howManySwitches() {
|
PowerSwitcher::SwitchReturn_t PowerSwitcher::howManySwitches() {
|
||||||
if (secondSwitch == NO_SWITCH) {
|
if (secondSwitch == power::NO_SWITCH) {
|
||||||
return ONE_SWITCH;
|
return ONE_SWITCH;
|
||||||
} else {
|
} else {
|
||||||
return TWO_SWITCHES;
|
return TWO_SWITCHES;
|
||||||
|
@ -14,28 +14,27 @@ class PowerSwitcher : public HasReturnvaluesIF {
|
|||||||
SWITCH_IS_OFF,
|
SWITCH_IS_OFF,
|
||||||
SWITCH_IS_ON,
|
SWITCH_IS_ON,
|
||||||
};
|
};
|
||||||
State_t state;
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::POWER_SWITCHER;
|
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 IN_POWER_TRANSITION = MAKE_RETURN_CODE(1);
|
||||||
static const ReturnValue_t SWITCH_STATE_MISMATCH = MAKE_RETURN_CODE(2);
|
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);
|
State_t setStartState = SWITCH_IS_OFF);
|
||||||
ReturnValue_t initialize(object_id_t powerSwitchId);
|
|
||||||
void turnOn();
|
void turnOn();
|
||||||
void turnOff();
|
void turnOff();
|
||||||
void doStateMachine();
|
void doStateMachine();
|
||||||
State_t getState();
|
State_t getState();
|
||||||
ReturnValue_t checkSwitchState();
|
ReturnValue_t checkSwitchState();
|
||||||
uint32_t getSwitchDelay();
|
uint32_t getSwitchDelay();
|
||||||
uint8_t getFirstSwitch() const;
|
power::Switch_t getFirstSwitch() const;
|
||||||
uint8_t getSecondSwitch() const;
|
power::Switch_t getSecondSwitch() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t firstSwitch;
|
|
||||||
uint8_t secondSwitch;
|
|
||||||
PowerSwitchIF* power = nullptr;
|
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 };
|
enum SwitchReturn_t { ONE_SWITCH = 1, TWO_SWITCHES = 2 };
|
||||||
ReturnValue_t getStateOfSwitches();
|
ReturnValue_t getStateOfSwitches();
|
||||||
void commandSwitches(ReturnValue_t onOff);
|
void commandSwitches(ReturnValue_t onOff);
|
||||||
|
13
src/fsfw/power/definitions.h
Normal file
13
src/fsfw/power/definitions.h
Normal 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_ */
|
Loading…
Reference in New Issue
Block a user