fsfw/power/PowerSensor.h

78 lines
2.0 KiB
C
Raw Normal View History

2020-09-26 15:16:13 +02:00
#ifndef FSFW_POWER_POWERSENSOR_H_
#define FSFW_POWER_POWERSENSOR_H_
2020-08-28 18:33:29 +02:00
2020-11-30 15:30:56 +01:00
#include "../datapoollocal/StaticLocalDataSet.h"
2020-08-28 18:33:29 +02:00
#include "../devicehandlers/HealthDevice.h"
#include "../monitoring/LimitMonitor.h"
#include "../parameters/ParameterHelper.h"
#include "../objectmanager/SystemObject.h"
#include "../ipc/MessageQueueIF.h"
class PowerController;
2020-11-30 15:30:56 +01:00
/**
* @brief Does magic.
*/
2020-08-28 18:33:29 +02:00
class PowerSensor: public SystemObject,
public ReceivesParameterMessagesIF,
public HasHealthIF {
friend class PowerController;
public:
struct VariableIds {
2020-11-30 15:30:56 +01:00
gp_id_t pidCurrent;
gp_id_t pidVoltage;
gp_id_t poolIdPower;
2020-08-28 18:33:29 +02:00
};
struct DefaultLimits {
float currentMin;
float currentMax;
float voltageMin;
float voltageMax;
};
struct SensorEvents {
Event currentLow;
Event currentHigh;
Event voltageLow;
Event voltageHigh;
};
2020-11-30 15:30:56 +01:00
PowerSensor(object_id_t objectId, sid_t sid, VariableIds setIds,
DefaultLimits limits, SensorEvents events,
uint16_t confirmationCount = 0);
2020-08-28 18:33:29 +02:00
virtual ~PowerSensor();
ReturnValue_t calculatePower();
ReturnValue_t performOperation(uint8_t opCode);
void setAllMonitorsToUnchecked();
MessageQueueId_t getCommandQueue() const;
ReturnValue_t initialize();
void setDataPoolEntriesInvalid();
float getPower();
ReturnValue_t setHealth(HealthState health);
HasHealthIF::HealthState getHealth();
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
ParameterWrapper *parameterWrapper,
const ParameterWrapper *newValues, uint16_t startAtIndex);
private:
2020-09-26 15:16:13 +02:00
MessageQueueIF* commandQueue = nullptr;
2020-08-28 18:33:29 +02:00
ParameterHelper parameterHelper;
HealthHelper healthHelper;
2020-11-30 15:30:56 +01:00
//GlobDataSet set;
StaticLocalDataSet<3> powerSensorSet;
2020-08-28 18:33:29 +02:00
//Variables in
2020-11-30 15:30:56 +01:00
lp_var_t<float> current;
lp_var_t<float> voltage;
//PIDReader<float> current;
//PIDReader<float> voltage;
2020-08-28 18:33:29 +02:00
//Variables out
2020-11-30 15:30:56 +01:00
lp_var_t<float> power;
//gp_float_t power;
2020-08-28 18:33:29 +02:00
static const uint8_t MODULE_ID_CURRENT = 1;
static const uint8_t MODULE_ID_VOLTAGE = 2;
void checkCommandQueue();
protected:
LimitMonitor<float> currentLimit;
LimitMonitor<float> voltageLimit;
};
2020-09-26 15:16:13 +02:00
#endif /* FSFW_POWER_POWERSENSOR_H_ */