2020-12-03 18:29:28 +01:00
|
|
|
#ifndef FSFW_POWER_FUSE_H_
|
|
|
|
#define FSFW_POWER_FUSE_H_
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
#include <list>
|
2020-12-03 18:29:28 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "../datapoollocal/StaticLocalDataSet.h"
|
2020-12-03 18:29:28 +01:00
|
|
|
#include "../devicehandlers/HealthDevice.h"
|
|
|
|
#include "../monitoring/AbsLimitMonitor.h"
|
2020-08-13 20:53:35 +02:00
|
|
|
#include "../parameters/ParameterHelper.h"
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
|
|
|
#include "PowerComponentIF.h"
|
|
|
|
#include "PowerSwitchIF.h"
|
2020-04-21 22:28:43 +02:00
|
|
|
namespace Factory {
|
2018-07-12 16:29:32 +02:00
|
|
|
void setStaticFrameworkObjectIds();
|
|
|
|
}
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
class Fuse : public SystemObject,
|
|
|
|
public HasHealthIF,
|
|
|
|
public ReceivesParameterMessagesIF,
|
|
|
|
public SerializeIF {
|
|
|
|
friend void(Factory::setStaticFrameworkObjectIds)();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
private:
|
|
|
|
static constexpr float RESIDUAL_POWER =
|
|
|
|
0.005 * 28.5; //!< This is the upper limit of residual power lost by fuses and switches.
|
|
|
|
//!< Worst case is Fuse and one of two switches on. See PCDU ICD 1.9 p29 bottom
|
|
|
|
public:
|
|
|
|
struct VariableIds {
|
|
|
|
gp_id_t pidVoltage;
|
|
|
|
gp_id_t pidCurrent;
|
|
|
|
gp_id_t pidState;
|
|
|
|
gp_id_t poolIdPower;
|
|
|
|
};
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PCDU_1;
|
2022-03-28 12:48:15 +02:00
|
|
|
//! PSS detected that current on a fuse is totally out of bounds.
|
|
|
|
static const Event FUSE_CURRENT_HIGH = MAKE_EVENT(1, severity::LOW);
|
|
|
|
//! PSS detected a fuse that went off.
|
|
|
|
static const Event FUSE_WENT_OFF = MAKE_EVENT(2, severity::LOW);
|
|
|
|
//! PSS detected a fuse that violates its limits.
|
|
|
|
static const Event POWER_ABOVE_HIGH_LIMIT = MAKE_EVENT(4, severity::LOW);
|
|
|
|
//! PSS detected a fuse that violates its limits.
|
|
|
|
static const Event POWER_BELOW_LOW_LIMIT = MAKE_EVENT(5, severity::LOW);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
typedef std::list<PowerComponentIF *> DeviceList;
|
|
|
|
Fuse(object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet, VariableIds ids,
|
|
|
|
float maxCurrent, uint16_t confirmationCount = 2);
|
|
|
|
virtual ~Fuse();
|
|
|
|
void addDevice(PowerComponentIF *set);
|
|
|
|
float getPower();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
bool isPowerValid();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
ReturnValue_t check();
|
|
|
|
uint8_t getFuseId() const;
|
2022-05-01 17:48:49 +02:00
|
|
|
ReturnValue_t initialize() override;
|
2022-02-02 10:29:30 +01:00
|
|
|
DeviceList devices;
|
|
|
|
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
|
|
|
SerializeIF::Endianness streamEndianness) const override;
|
|
|
|
size_t getSerializedSize() const override;
|
|
|
|
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
|
|
|
SerializeIF::Endianness streamEndianness) override;
|
|
|
|
void setAllMonitorsToUnchecked();
|
|
|
|
ReturnValue_t performOperation(uint8_t opCode);
|
|
|
|
MessageQueueId_t getCommandQueue() const;
|
|
|
|
void setDataPoolEntriesInvalid();
|
|
|
|
ReturnValue_t setHealth(HealthState health);
|
|
|
|
HasHealthIF::HealthState getHealth();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId, ParameterWrapper *parameterWrapper,
|
|
|
|
const ParameterWrapper *newValues, uint16_t startAtIndex);
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
private:
|
|
|
|
uint8_t oldFuseState;
|
|
|
|
uint8_t fuseId;
|
|
|
|
PowerSwitchIF *powerIF = nullptr; // could be static in our case.
|
|
|
|
AbsLimitMonitor<float> currentLimit;
|
|
|
|
class PowerMonitor : public MonitorReporter<float> {
|
|
|
|
public:
|
|
|
|
template <typename... Args>
|
|
|
|
PowerMonitor(Args... args) : MonitorReporter<float>(std::forward<Args>(args)...) {}
|
|
|
|
ReturnValue_t checkPower(float sample, float lowerLimit, float upperLimit);
|
|
|
|
void sendTransitionEvent(float currentValue, ReturnValue_t state) {}
|
|
|
|
};
|
|
|
|
PowerMonitor powerMonitor;
|
|
|
|
StaticLocalDataSet<3> set;
|
2020-12-10 16:57:43 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
lp_var_t<float> voltage;
|
|
|
|
lp_var_t<float> current;
|
|
|
|
lp_var_t<uint8_t> state;
|
2020-12-03 18:29:28 +01:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
lp_var_t<float> power;
|
|
|
|
MessageQueueIF *commandQueue = nullptr;
|
|
|
|
ParameterHelper parameterHelper;
|
|
|
|
HealthHelper healthHelper;
|
|
|
|
static object_id_t powerSwitchId;
|
|
|
|
void calculatePowerLimits(float *low, float *high);
|
|
|
|
void calculateFusePower();
|
|
|
|
void checkFuseState();
|
|
|
|
void reportEvents(Event event);
|
|
|
|
void checkCommandQueue();
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
bool areSwitchesOfComponentOn(DeviceList::iterator iter);
|
2018-07-12 16:29:32 +02:00
|
|
|
};
|
|
|
|
|
2020-12-03 18:29:28 +01:00
|
|
|
#endif /* FSFW_POWER_FUSE_H_ */
|