Update FSFW #51
@ -1,7 +1,7 @@
|
||||
target_sources(${LIB_FSFW_NAME}
|
||||
PRIVATE
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
Fuse.cpp
|
||||
PowerComponent.cpp
|
||||
PowerSensor.cpp
|
||||
PowerSwitcher.cpp
|
||||
DummyPowerSwitcher.cpp
|
||||
)
|
42
src/fsfw/power/DummyPowerSwitcher.cpp
Normal file
42
src/fsfw/power/DummyPowerSwitcher.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "DummyPowerSwitcher.h"
|
||||
|
||||
DummyPowerSwitcher::DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, uint32_t switchDelayMs)
|
||||
: switcherList(numberOfSwitches), fuseList(numberOfFuses), switchDelayMs(switchDelayMs) {
|
||||
}
|
||||
|
||||
void DummyPowerSwitcher::setInitialSwitcherList(std::vector<ReturnValue_t> switcherList) {
|
||||
this->switcherList = switcherList;
|
||||
}
|
||||
|
||||
void DummyPowerSwitcher::setInitialFusesList(std::vector<ReturnValue_t> fuseList) {
|
||||
this->fuseList = fuseList;
|
||||
}
|
||||
|
||||
ReturnValue_t DummyPowerSwitcher::sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) {
|
||||
if (switchNr < switcherList.capacity()) {
|
||||
switcherList[switchNr] = onOff;
|
||||
}
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t DummyPowerSwitcher::sendFuseOnCommand(uint8_t fuseNr) {
|
||||
if(fuseNr < fuseList.capacity()) {
|
||||
fuseList[fuseNr] = FUSE_ON;
|
||||
}
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t DummyPowerSwitcher::getSwitchState(power::Switch_t switchNr) const {
|
||||
if (switchNr < switcherList.capacity()) {
|
||||
return switcherList[switchNr];
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const {
|
||||
return 5000;
|
||||
}
|
31
src/fsfw/power/DummyPowerSwitcher.h
Normal file
31
src/fsfw/power/DummyPowerSwitcher.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_
|
||||
#define FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_
|
||||
|
||||
#include "PowerSwitchIF.h"
|
||||
#include "definitions.h"
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
|
||||
class DummyPowerSwitcher: public PowerSwitchIF {
|
||||
public:
|
||||
DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, uint32_t switchDelayMs = 5000);
|
||||
|
||||
void setInitialSwitcherList(std::vector<ReturnValue_t> switcherList);
|
||||
void setInitialFusesList(std::vector<ReturnValue_t> switcherList);
|
||||
|
||||
virtual ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) override;
|
||||
virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override;
|
||||
virtual ReturnValue_t getSwitchState(power::Switch_t switchNr) const override;
|
||||
virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override;
|
||||
virtual uint32_t getSwitchDelayMs(void) const override;
|
||||
|
||||
private:
|
||||
std::vector<ReturnValue_t> switcherList;
|
||||
std::vector<ReturnValue_t> fuseList;
|
||||
uint32_t switchDelayMs = 5000;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_ */
|
@ -38,11 +38,11 @@ class PowerSwitchIF : public HasReturnvaluesIF {
|
||||
* @param switchNr
|
||||
* @param onOff on == @c SWITCH_ON; off != @c SWITCH_ON
|
||||
*/
|
||||
virtual void sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) const = 0;
|
||||
virtual ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) = 0;
|
||||
/**
|
||||
* Sends a command to the Power Unit to enable a certain fuse.
|
||||
*/
|
||||
virtual void sendFuseOnCommand(uint8_t fuseNr) const = 0;
|
||||
virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) = 0;
|
||||
|
||||
/**
|
||||
* get the state of the Switches.
|
||||
|
Loading…
Reference in New Issue
Block a user