it compiles again
This commit is contained in:
parent
e7a96d5ad8
commit
f70ee7696a
@ -31,7 +31,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
|
||||
PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
||||
sid.objectId);
|
||||
if(hkOwner == nullptr) {
|
||||
|
@ -119,6 +119,7 @@ public:
|
||||
|
||||
|
||||
LocalPoolVar<T> &operator=(T newValue);
|
||||
LocalPoolVar<T> &operator=(LocalPoolVar<T> newPoolVariable);
|
||||
protected:
|
||||
/**
|
||||
* @brief Like #read, but without a lock protection of the global pool.
|
||||
@ -164,4 +165,5 @@ using lp_int64_t = LocalPoolVar<int64_t>;
|
||||
using lp_float_t = LocalPoolVar<float>;
|
||||
using lp_double_t = LocalPoolVar<double>;
|
||||
|
||||
|
||||
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ */
|
||||
|
@ -81,11 +81,18 @@ inline ReturnValue_t LocalPoolVar<T>::commitWithoutLock() {
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline LocalPoolVar<T> & LocalPoolVar<T>::operator =(T newValue) {
|
||||
inline LocalPoolVar<T> & LocalPoolVar<T>::operator=(T newValue) {
|
||||
value = newValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline LocalPoolVar<T>& LocalPoolVar<T>::operator =(
|
||||
LocalPoolVar<T> newPoolVariable) {
|
||||
value = newPoolVariable.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline ReturnValue_t LocalPoolVar<T>::serialize(uint8_t** buffer, size_t* size,
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
* @param dataSet The data set in which the variable shall register itself.
|
||||
* If nullptr, the variable is not registered.
|
||||
*/
|
||||
LocalPoolVector(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
||||
LocalPoolVector(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
|
||||
DataSetIF* dataSet = nullptr,
|
||||
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
#endif
|
||||
|
||||
template<typename T, uint16_t vectorSize>
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(lp_id_t poolId,
|
||||
HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet,
|
||||
inline LocalPoolVector<T, vectorSize>::LocalPoolVector(
|
||||
HasLocalDataPoolIF* hkOwner, lp_id_t poolId, DataSetIF* dataSet,
|
||||
pool_rwm_t setReadWriteMode):
|
||||
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
|
||||
|
||||
|
@ -66,7 +66,7 @@ union gp_id_t {
|
||||
|
||||
gp_id_t(): raw(INVALID_GPID) {}
|
||||
|
||||
gp_id_t(object_id_t objectID, lp_id_t localPoolId):
|
||||
gp_id_t(object_id_t objectId, lp_id_t localPoolId):
|
||||
objectId(objectId),
|
||||
localPoolId(localPoolId) {}
|
||||
|
||||
|
@ -8,12 +8,11 @@ template<typename T>
|
||||
class AbsLimitMonitor: public MonitorBase<T> {
|
||||
public:
|
||||
AbsLimitMonitor(object_id_t reporterId, uint8_t monitorId,
|
||||
object_id_t dataCreatorId, lp_id_t localPoolId,
|
||||
uint16_t confirmationLimit, T limit,
|
||||
gp_id_t globalPoolId, uint16_t confirmationLimit, T limit,
|
||||
Event violationEvent = MonitoringIF::VALUE_OUT_OF_RANGE,
|
||||
bool aboveIsViolation = true) :
|
||||
MonitorBase<T>(reporterId, monitorId, dataCreatorId, localPoolId,
|
||||
confirmationLimit),
|
||||
MonitorBase<T>(reporterId, monitorId, globalPoolId,
|
||||
confirmationLimit),
|
||||
limit(limit), violationEvent(violationEvent),
|
||||
aboveIsViolation(aboveIsViolation) {
|
||||
}
|
||||
@ -67,7 +66,8 @@ protected:
|
||||
switch (state) {
|
||||
case MonitoringIF::OUT_OF_RANGE:
|
||||
EventManagerIF::triggerEvent(this->reportingId,
|
||||
violationEvent, this->parameterId);
|
||||
violationEvent, this->parameterId.objectId,
|
||||
this->parameterId.localPoolId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -13,11 +13,11 @@ template<typename T>
|
||||
class LimitMonitor: public MonitorBase<T> {
|
||||
public:
|
||||
LimitMonitor(object_id_t reporterId, uint8_t monitorId,
|
||||
object_id_t creatorId, lp_id_t localPoolId,
|
||||
uint16_t confirmationLimit, T lowerLimit, T upperLimit,
|
||||
Event belowLowEvent = MonitoringIF::VALUE_BELOW_LOW_LIMIT,
|
||||
gp_id_t globalPoolId, uint16_t confirmationLimit, T lowerLimit,
|
||||
T upperLimit, Event belowLowEvent =
|
||||
MonitoringIF::VALUE_BELOW_LOW_LIMIT,
|
||||
Event aboveHighEvent = MonitoringIF::VALUE_ABOVE_HIGH_LIMIT) :
|
||||
MonitorBase<T>(reporterId, monitorId, creatorId, localPoolId,
|
||||
MonitorBase<T>(reporterId, monitorId, globalPoolId,
|
||||
confirmationLimit),
|
||||
lowerLimit(lowerLimit), upperLimit(upperLimit),
|
||||
belowLowEvent(belowLowEvent), aboveHighEvent(aboveHighEvent) {
|
||||
@ -80,11 +80,11 @@ protected:
|
||||
switch (state) {
|
||||
case MonitoringIF::BELOW_LOW_LIMIT:
|
||||
EventManagerIF::triggerEvent(this->reportingId, belowLowEvent,
|
||||
this->parameterId);
|
||||
this->parameterId.objectId, this->parameterId.localPoolId);
|
||||
break;
|
||||
case MonitoringIF::ABOVE_HIGH_LIMIT:
|
||||
EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent,
|
||||
this->parameterId);
|
||||
this->parameterId.objectId, this->parameterId.localPoolId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -25,11 +25,10 @@ class MonitorBase: public MonitorReporter<T> {
|
||||
public:
|
||||
|
||||
MonitorBase(object_id_t reporterId, uint8_t monitorId,
|
||||
object_id_t dataCreatorId, lp_id_t localPoolId,
|
||||
uint16_t confirmationLimit):
|
||||
MonitorReporter<T>(reporterId, monitorId, dataCreatorId,
|
||||
gp_id_t globalPoolId, uint16_t confirmationLimit):
|
||||
MonitorReporter<T>(reporterId, monitorId, globalPoolId,
|
||||
confirmationLimit),
|
||||
poolVariable(dataCreatorId, localPoolId) {
|
||||
poolVariable(globalPoolId) {
|
||||
}
|
||||
|
||||
virtual ~MonitorBase() {
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "MonitoringIF.h"
|
||||
#include "MonitoringMessageContent.h"
|
||||
|
||||
#include "../datapoollocal/locPoolDefinitions.h"
|
||||
#include "../events/EventManagerIF.h"
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
|
||||
@ -18,7 +19,7 @@ public:
|
||||
// TODO: Adapt to use SID instead of parameter ID.
|
||||
|
||||
MonitorReporter(object_id_t reportingId, uint8_t monitorId,
|
||||
uint32_t parameterId, uint16_t confirmationLimit) :
|
||||
gp_id_t globalPoolId, uint16_t confirmationLimit) :
|
||||
monitorId(monitorId), parameterId(parameterId),
|
||||
reportingId(reportingId), oldState(MonitoringIF::UNCHECKED),
|
||||
reportingEnabled(ENABLED), eventEnabled(ENABLED), currentCounter(0),
|
||||
@ -95,7 +96,7 @@ public:
|
||||
|
||||
protected:
|
||||
const uint8_t monitorId;
|
||||
const uint32_t parameterId;
|
||||
const gp_id_t parameterId;
|
||||
object_id_t reportingId;
|
||||
ReturnValue_t oldState;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "HasMonitorsIF.h"
|
||||
#include "MonitoringIF.h"
|
||||
#include "../datapoollocal/locPoolDefinitions.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serialize/SerialBufferAdapter.h"
|
||||
#include "../serialize/SerialFixedArrayListAdapter.h"
|
||||
@ -16,12 +17,17 @@ void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
//PID(uint32_t), TYPE, LIMIT_ID, value,limitValue, previous, later, timestamp
|
||||
/**
|
||||
* @brief Does magic.
|
||||
* @tparam T
|
||||
*/
|
||||
template<typename T>
|
||||
class MonitoringReportContent: public SerialLinkedListAdapter<SerializeIF> {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
SerializeElement<uint8_t> monitorId;
|
||||
SerializeElement<uint32_t> parameterId;
|
||||
SerializeElement<uint32_t> parameterObjectId;
|
||||
SerializeElement<lp_id_t> localPoolId;
|
||||
SerializeElement<T> parameterValue;
|
||||
SerializeElement<T> limitValue;
|
||||
SerializeElement<ReturnValue_t> oldState;
|
||||
@ -30,20 +36,23 @@ public:
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> timestampSerializer;
|
||||
TimeStamperIF* timeStamper;
|
||||
MonitoringReportContent() :
|
||||
SerialLinkedListAdapter<SerializeIF>(
|
||||
LinkedElement<SerializeIF>::Iterator(¶meterId)), monitorId(0), parameterId(
|
||||
0), parameterValue(0), limitValue(0), oldState(0), newState(
|
||||
0), rawTimestamp( { 0 }), timestampSerializer(rawTimestamp,
|
||||
SerialLinkedListAdapter<SerializeIF>(¶meterObjectId),
|
||||
monitorId(0), parameterObjectId(0),
|
||||
localPoolId(0), parameterValue(0),
|
||||
limitValue(0), oldState(0), newState(0),
|
||||
rawTimestamp( { 0 }), timestampSerializer(rawTimestamp,
|
||||
sizeof(rawTimestamp)), timeStamper(NULL) {
|
||||
setAllNext();
|
||||
}
|
||||
MonitoringReportContent(uint32_t setPID, T value, T limitValue,
|
||||
MonitoringReportContent(gp_id_t globalPoolId, T value, T limitValue,
|
||||
ReturnValue_t oldState, ReturnValue_t newState) :
|
||||
SerialLinkedListAdapter<SerializeIF>(
|
||||
LinkedElement<SerializeIF>::Iterator(¶meterId)), monitorId(0), parameterId(
|
||||
setPID), parameterValue(value), limitValue(limitValue), oldState(
|
||||
oldState), newState(newState), timestampSerializer(rawTimestamp,
|
||||
sizeof(rawTimestamp)), timeStamper(NULL) {
|
||||
SerialLinkedListAdapter<SerializeIF>(¶meterObjectId),
|
||||
monitorId(0), parameterObjectId(globalPoolId.objectId),
|
||||
localPoolId(globalPoolId.localPoolId),
|
||||
parameterValue(value), limitValue(limitValue),
|
||||
oldState(oldState), newState(newState),
|
||||
timestampSerializer(rawTimestamp, sizeof(rawTimestamp)),
|
||||
timeStamper(NULL) {
|
||||
setAllNext();
|
||||
if (checkAndSetStamper()) {
|
||||
timeStamper->addTimeStamp(rawTimestamp, sizeof(rawTimestamp));
|
||||
@ -53,16 +62,16 @@ private:
|
||||
|
||||
static object_id_t timeStamperId;
|
||||
void setAllNext() {
|
||||
parameterId.setNext(¶meterValue);
|
||||
parameterObjectId.setNext(¶meterValue);
|
||||
parameterValue.setNext(&limitValue);
|
||||
limitValue.setNext(&oldState);
|
||||
oldState.setNext(&newState);
|
||||
newState.setNext(×tampSerializer);
|
||||
}
|
||||
bool checkAndSetStamper() {
|
||||
if (timeStamper == NULL) {
|
||||
if (timeStamper == nullptr) {
|
||||
timeStamper = objectManager->get<TimeStamperIF>( timeStamperId );
|
||||
if ( timeStamper == NULL ) {
|
||||
if ( timeStamper == nullptr ) {
|
||||
sif::error << "MonitoringReportContent::checkAndSetStamper: "
|
||||
"Stamper not found!" << std::endl;
|
||||
return false;
|
||||
|
@ -8,17 +8,16 @@
|
||||
|
||||
object_id_t Fuse::powerSwitchId = 0;
|
||||
|
||||
Fuse::Fuse(object_id_t fuseObjectId, uint8_t fuseId, VariableIds ids,
|
||||
Fuse::Fuse(object_id_t fuseObjectId, uint8_t fuseId,
|
||||
sid_t variableSet, VariableIds ids,
|
||||
float maxCurrent, uint16_t confirmationCount) :
|
||||
SystemObject(fuseObjectId), oldFuseState(0), fuseId(fuseId), powerIF(
|
||||
NULL),
|
||||
SystemObject(fuseObjectId), oldFuseState(0), fuseId(fuseId),
|
||||
currentLimit(fuseObjectId, 1, ids.pidCurrent, confirmationCount,
|
||||
maxCurrent, FUSE_CURRENT_HIGH),
|
||||
powerMonitor(fuseObjectId, 2,
|
||||
GlobalDataPool::poolIdAndPositionToPid(ids.poolIdPower, 0),
|
||||
powerMonitor(fuseObjectId, 2, ids.poolIdPower,
|
||||
confirmationCount),
|
||||
set(), voltage(ids.pidVoltage, &set), current(ids.pidCurrent, &set),
|
||||
state(ids.pidState, &set),
|
||||
set(variableSet), voltage(ids.pidVoltage, &set),
|
||||
current(ids.pidCurrent, &set), state(ids.pidState, &set),
|
||||
power(ids.poolIdPower, &set, PoolVariableIF::VAR_READ_WRITE),
|
||||
parameterHelper(this), healthHelper(this, fuseObjectId) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue();
|
||||
@ -73,19 +72,19 @@ ReturnValue_t Fuse::check() {
|
||||
checkFuseState();
|
||||
calculateFusePower();
|
||||
//Check if power is valid and if fuse state is off or invalid.
|
||||
if (!power.isValid() || (state == 0) || !state.isValid()) {
|
||||
result = powerMonitor.setToInvalid();
|
||||
} else {
|
||||
float lowLimit = 0.0;
|
||||
float highLimit = RESIDUAL_POWER;
|
||||
calculatePowerLimits(&lowLimit, &highLimit);
|
||||
result = powerMonitor.checkPower(power, lowLimit, highLimit);
|
||||
if (result == MonitoringIF::BELOW_LOW_LIMIT) {
|
||||
reportEvents(POWER_BELOW_LOW_LIMIT);
|
||||
} else if (result == MonitoringIF::ABOVE_HIGH_LIMIT) {
|
||||
reportEvents(POWER_ABOVE_HIGH_LIMIT);
|
||||
}
|
||||
}
|
||||
// if (!power.isValid() || (state == 0) || !state.isValid()) {
|
||||
// result = powerMonitor.setToInvalid();
|
||||
// } else {
|
||||
// float lowLimit = 0.0;
|
||||
// float highLimit = RESIDUAL_POWER;
|
||||
// calculatePowerLimits(&lowLimit, &highLimit);
|
||||
// result = powerMonitor.checkPower(power, lowLimit, highLimit);
|
||||
// if (result == MonitoringIF::BELOW_LOW_LIMIT) {
|
||||
// reportEvents(POWER_BELOW_LOW_LIMIT);
|
||||
// } else if (result == MonitoringIF::ABOVE_HIGH_LIMIT) {
|
||||
// reportEvents(POWER_ABOVE_HIGH_LIMIT);
|
||||
// }
|
||||
// }
|
||||
set.commit();
|
||||
return result;
|
||||
}
|
||||
@ -136,7 +135,7 @@ void Fuse::calculateFusePower() {
|
||||
return;
|
||||
}
|
||||
//Calculate fuse power.
|
||||
power = current * voltage;
|
||||
//power = current * voltage;
|
||||
power.setValid(PoolVariableIF::VALID);
|
||||
}
|
||||
|
||||
@ -189,20 +188,20 @@ void Fuse::checkFuseState() {
|
||||
oldFuseState = 0;
|
||||
return;
|
||||
}
|
||||
if (state == 0) {
|
||||
if (oldFuseState != 0) {
|
||||
reportEvents(FUSE_WENT_OFF);
|
||||
}
|
||||
}
|
||||
oldFuseState = state;
|
||||
// if (state == 0) {
|
||||
// if (oldFuseState != 0) {
|
||||
// reportEvents(FUSE_WENT_OFF);
|
||||
// }
|
||||
// }
|
||||
// oldFuseState = state;
|
||||
}
|
||||
|
||||
float Fuse::getPower() {
|
||||
if (power.isValid()) {
|
||||
return power;
|
||||
} else {
|
||||
return 0.0;
|
||||
}
|
||||
// if (power.isValid()) {
|
||||
// return power;
|
||||
// } else {
|
||||
// return 0.0;
|
||||
// }
|
||||
}
|
||||
|
||||
void Fuse::setDataPoolEntriesInvalid() {
|
||||
|
32
power/Fuse.h
32
power/Fuse.h
@ -13,6 +13,7 @@
|
||||
#include "../parameters/ParameterHelper.h"
|
||||
#include <list>
|
||||
|
||||
#include "../datapoollocal/StaticLocalDataSet.h"
|
||||
namespace Factory {
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
@ -27,10 +28,10 @@ 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 {
|
||||
uint32_t pidVoltage;
|
||||
uint32_t pidCurrent;
|
||||
uint32_t pidState;
|
||||
uint32_t poolIdPower;
|
||||
gp_id_t pidVoltage;
|
||||
gp_id_t pidCurrent;
|
||||
gp_id_t pidState;
|
||||
gp_id_t poolIdPower;
|
||||
};
|
||||
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PCDU_1;
|
||||
@ -40,8 +41,8 @@ public:
|
||||
static const Event POWER_BELOW_LOW_LIMIT = MAKE_EVENT(5, SEVERITY::LOW); //!< PSS detected a fuse that violates its limits.
|
||||
|
||||
typedef std::list<PowerComponentIF*> DeviceList;
|
||||
Fuse(object_id_t fuseObjectId, uint8_t fuseId, VariableIds ids,
|
||||
float maxCurrent, uint16_t confirmationCount = 2);
|
||||
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();
|
||||
@ -71,12 +72,12 @@ public:
|
||||
private:
|
||||
uint8_t oldFuseState;
|
||||
uint8_t fuseId;
|
||||
PowerSwitchIF *powerIF; //could be static in our case.
|
||||
PowerSwitchIF *powerIF = nullptr; //could be static in our case.
|
||||
AbsLimitMonitor<float> currentLimit;
|
||||
class PowerMonitor: public MonitorReporter<float> {
|
||||
public:
|
||||
template<typename ... Args>
|
||||
PowerMonitor(Args ... args) :
|
||||
PowerMonitor(Args ... args):
|
||||
MonitorReporter<float>(std::forward<Args>(args)...) {
|
||||
}
|
||||
ReturnValue_t checkPower(float sample, float lowerLimit,
|
||||
@ -86,11 +87,16 @@ private:
|
||||
|
||||
};
|
||||
PowerMonitor powerMonitor;
|
||||
GlobDataSet set;
|
||||
PIDReader<float> voltage;
|
||||
PIDReader<float> current;
|
||||
PIDReader<uint8_t> state;
|
||||
gp_float_t power;
|
||||
StaticLocalDataSet<3> set;
|
||||
//LocalPoolDataSetBase* set = nullptr;
|
||||
//PIDReader<float> voltage;
|
||||
//PIDReader<float> current;
|
||||
//PIDReader<uint8_t> state;
|
||||
lp_var_t<float> voltage;
|
||||
lp_var_t<float> current;
|
||||
lp_var_t<uint8_t> state;
|
||||
|
||||
lp_var_t<float> power;
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
ParameterHelper parameterHelper;
|
||||
HealthHelper healthHelper;
|
||||
|
@ -2,15 +2,17 @@
|
||||
|
||||
#include "../ipc/QueueFactory.h"
|
||||
|
||||
PowerSensor::PowerSensor(object_id_t setId, VariableIds ids,
|
||||
PowerSensor::PowerSensor(object_id_t objectId, sid_t setId, VariableIds ids,
|
||||
DefaultLimits limits, SensorEvents events, uint16_t confirmationCount) :
|
||||
SystemObject(setId), parameterHelper(this), healthHelper(this, setId),
|
||||
set(), current(ids.pidCurrent, &set), voltage(ids.pidVoltage, &set),
|
||||
power(ids.poolIdPower, &set, PoolVariableIF::VAR_WRITE),
|
||||
currentLimit(setId, MODULE_ID_CURRENT, ids.pidCurrent, confirmationCount,
|
||||
SystemObject(objectId), parameterHelper(this),
|
||||
healthHelper(this, objectId),
|
||||
powerSensorSet(setId), current(ids.pidCurrent, &powerSensorSet),
|
||||
voltage(ids.pidVoltage, &powerSensorSet),
|
||||
power(ids.poolIdPower, &powerSensorSet, PoolVariableIF::VAR_WRITE),
|
||||
currentLimit(objectId, MODULE_ID_CURRENT, ids.pidCurrent, confirmationCount,
|
||||
limits.currentMin, limits.currentMax, events.currentLow,
|
||||
events.currentHigh),
|
||||
voltageLimit(setId, MODULE_ID_VOLTAGE,
|
||||
voltageLimit(objectId, MODULE_ID_VOLTAGE,
|
||||
ids.pidVoltage, confirmationCount, limits.voltageMin,
|
||||
limits.voltageMax, events.voltageLow, events.voltageHigh) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue();
|
||||
@ -21,27 +23,27 @@ PowerSensor::~PowerSensor() {
|
||||
}
|
||||
|
||||
ReturnValue_t PowerSensor::calculatePower() {
|
||||
set.read();
|
||||
powerSensorSet.read();
|
||||
ReturnValue_t result1 = HasReturnvaluesIF::RETURN_FAILED;
|
||||
ReturnValue_t result2 = HasReturnvaluesIF::RETURN_FAILED;
|
||||
if (healthHelper.healthTable->isHealthy(getObjectId()) && voltage.isValid()
|
||||
&& current.isValid()) {
|
||||
result1 = voltageLimit.doCheck(voltage);
|
||||
result2 = currentLimit.doCheck(current);
|
||||
} else {
|
||||
voltageLimit.setToInvalid();
|
||||
currentLimit.setToInvalid();
|
||||
result1 = OBJECT_NOT_HEALTHY;
|
||||
}
|
||||
if (result1 != HasReturnvaluesIF::RETURN_OK
|
||||
|| result2 != HasReturnvaluesIF::RETURN_OK) {
|
||||
result1 = MonitoringIF::INVALID;
|
||||
power.setValid(PoolVariableIF::INVALID);
|
||||
} else {
|
||||
power.setValid(PoolVariableIF::VALID);
|
||||
power = current * voltage;
|
||||
}
|
||||
set.commit();
|
||||
// if (healthHelper.healthTable->isHealthy(getObjectId()) && voltage.isValid()
|
||||
// && current.isValid()) {
|
||||
// result1 = voltageLimit.doCheck(voltage);
|
||||
// result2 = currentLimit.doCheck(current);
|
||||
// } else {
|
||||
// voltageLimit.setToInvalid();
|
||||
// currentLimit.setToInvalid();
|
||||
// result1 = OBJECT_NOT_HEALTHY;
|
||||
// }
|
||||
// if (result1 != HasReturnvaluesIF::RETURN_OK
|
||||
// || result2 != HasReturnvaluesIF::RETURN_OK) {
|
||||
// result1 = MonitoringIF::INVALID;
|
||||
// power.setValid(PoolVariableIF::INVALID);
|
||||
// } else {
|
||||
// power.setValid(PoolVariableIF::VALID);
|
||||
// power = current * voltage;
|
||||
// }
|
||||
// powerSensorSet.commit();
|
||||
return result1;
|
||||
}
|
||||
|
||||
@ -94,8 +96,8 @@ void PowerSensor::checkCommandQueue() {
|
||||
}
|
||||
|
||||
void PowerSensor::setDataPoolEntriesInvalid() {
|
||||
set.read();
|
||||
set.commit(PoolVariableIF::INVALID);
|
||||
powerSensorSet.read();
|
||||
powerSensorSet.commit(PoolVariableIF::INVALID);
|
||||
}
|
||||
|
||||
float PowerSensor::getPower() {
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "../datapoolglob/GlobalDataSet.h"
|
||||
#include "../datapoolglob/GlobalPoolVariable.h"
|
||||
#include "../datapoolglob/PIDReader.h"
|
||||
#include "../datapoollocal/StaticLocalDataSet.h"
|
||||
#include "../devicehandlers/HealthDevice.h"
|
||||
#include "../monitoring/LimitMonitor.h"
|
||||
#include "../parameters/ParameterHelper.h"
|
||||
@ -12,15 +13,18 @@
|
||||
|
||||
class PowerController;
|
||||
|
||||
/**
|
||||
* @brief Does magic.
|
||||
*/
|
||||
class PowerSensor: public SystemObject,
|
||||
public ReceivesParameterMessagesIF,
|
||||
public HasHealthIF {
|
||||
friend class PowerController;
|
||||
public:
|
||||
struct VariableIds {
|
||||
uint32_t pidCurrent;
|
||||
uint32_t pidVoltage;
|
||||
uint32_t poolIdPower;
|
||||
gp_id_t pidCurrent;
|
||||
gp_id_t pidVoltage;
|
||||
gp_id_t poolIdPower;
|
||||
};
|
||||
struct DefaultLimits {
|
||||
float currentMin;
|
||||
@ -34,8 +38,9 @@ public:
|
||||
Event voltageLow;
|
||||
Event voltageHigh;
|
||||
};
|
||||
PowerSensor(object_id_t setId, VariableIds setIds, DefaultLimits limits,
|
||||
SensorEvents events, uint16_t confirmationCount = 0);
|
||||
PowerSensor(object_id_t objectId, sid_t sid, VariableIds setIds,
|
||||
DefaultLimits limits, SensorEvents events,
|
||||
uint16_t confirmationCount = 0);
|
||||
virtual ~PowerSensor();
|
||||
ReturnValue_t calculatePower();
|
||||
ReturnValue_t performOperation(uint8_t opCode);
|
||||
@ -53,12 +58,16 @@ private:
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
ParameterHelper parameterHelper;
|
||||
HealthHelper healthHelper;
|
||||
GlobDataSet set;
|
||||
//GlobDataSet set;
|
||||
StaticLocalDataSet<3> powerSensorSet;
|
||||
//Variables in
|
||||
PIDReader<float> current;
|
||||
PIDReader<float> voltage;
|
||||
lp_var_t<float> current;
|
||||
lp_var_t<float> voltage;
|
||||
//PIDReader<float> current;
|
||||
//PIDReader<float> voltage;
|
||||
//Variables out
|
||||
gp_float_t power;
|
||||
lp_var_t<float> power;
|
||||
//gp_float_t power;
|
||||
|
||||
static const uint8_t MODULE_ID_CURRENT = 1;
|
||||
static const uint8_t MODULE_ID_VOLTAGE = 2;
|
||||
|
@ -38,7 +38,8 @@ bool ThermalMonitorReporter::isAboveHighLimit() {
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t ThermalMonitorReporter::translateState(ThermalComponentIF::State state, float sample, float lowerLimit,
|
||||
ReturnValue_t ThermalMonitorReporter::translateState(
|
||||
ThermalComponentIF::State state, float sample, float lowerLimit,
|
||||
float upperLimit, bool componentIsOperational) {
|
||||
if (ThermalComponentIF::isIgnoredState(state)) {
|
||||
setToUnchecked();
|
||||
@ -46,10 +47,12 @@ ReturnValue_t ThermalMonitorReporter::translateState(ThermalComponentIF::State s
|
||||
}
|
||||
switch (state) {
|
||||
case ThermalComponentIF::OUT_OF_RANGE_LOW:
|
||||
return monitorStateIs(MonitoringIF::BELOW_LOW_LIMIT, sample, lowerLimit);
|
||||
return monitorStateIs(MonitoringIF::BELOW_LOW_LIMIT, sample,
|
||||
lowerLimit);
|
||||
case ThermalComponentIF::NON_OPERATIONAL_LOW:
|
||||
if (componentIsOperational) {
|
||||
return monitorStateIs(ThermalComponentIF::BELOW_OPERATIONAL_LIMIT, sample, lowerLimit);
|
||||
return monitorStateIs(ThermalComponentIF::BELOW_OPERATIONAL_LIMIT,
|
||||
sample, lowerLimit);
|
||||
} else {
|
||||
return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0);
|
||||
}
|
||||
@ -57,12 +60,14 @@ ReturnValue_t ThermalMonitorReporter::translateState(ThermalComponentIF::State s
|
||||
return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0);
|
||||
case ThermalComponentIF::NON_OPERATIONAL_HIGH:
|
||||
if (componentIsOperational) {
|
||||
return monitorStateIs(ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT, sample, upperLimit);
|
||||
return monitorStateIs(ThermalComponentIF::ABOVE_OPERATIONAL_LIMIT,
|
||||
sample, upperLimit);
|
||||
} else {
|
||||
return monitorStateIs(HasReturnvaluesIF::RETURN_OK, sample, 0.0);
|
||||
}
|
||||
case ThermalComponentIF::OUT_OF_RANGE_HIGH:
|
||||
return monitorStateIs(MonitoringIF::ABOVE_HIGH_LIMIT, sample, upperLimit);
|
||||
return monitorStateIs(MonitoringIF::ABOVE_HIGH_LIMIT, sample,
|
||||
upperLimit);
|
||||
default:
|
||||
//Never reached, all states covered.
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
Loading…
Reference in New Issue
Block a user