1
0
forked from fsfw/fsfw

power update

This commit is contained in:
2020-12-03 18:29:28 +01:00
parent f0f7388c0d
commit 9ba8ef1ae2
10 changed files with 156 additions and 129 deletions

View File

@ -1,22 +1,25 @@
#include "Fuse.h"
#include "../monitoring/LimitViolationReporter.h"
#include "../monitoring/MonitoringMessageContent.h"
#include "../objectmanager/ObjectManagerIF.h"
#include "Fuse.h"
#include "../serialize/SerialFixedArrayListAdapter.h"
#include "../ipc/QueueFactory.h"
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), currentLimit(fuseObjectId, 1, ids.pidCurrent, confirmationCount,
maxCurrent, FUSE_CURRENT_HIGH), powerMonitor(fuseObjectId, 2,
DataPool::poolIdAndPositionToPid(ids.poolIdPower, 0),
confirmationCount), set(), voltage(ids.pidVoltage, &set), current(
ids.pidCurrent, &set), state(ids.pidState, &set), power(
ids.poolIdPower, &set, PoolVariableIF::VAR_READ_WRITE), commandQueue(
NULL), parameterHelper(this), healthHelper(this, fuseObjectId) {
SystemObject(fuseObjectId), oldFuseState(0), fuseId(fuseId),
currentLimit(fuseObjectId, 1, ids.pidCurrent, confirmationCount,
maxCurrent, FUSE_CURRENT_HIGH),
powerMonitor(fuseObjectId, 2, ids.poolIdPower,
confirmationCount),
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();
}
@ -75,7 +78,7 @@ ReturnValue_t Fuse::check() {
float lowLimit = 0.0;
float highLimit = RESIDUAL_POWER;
calculatePowerLimits(&lowLimit, &highLimit);
result = powerMonitor.checkPower(power, lowLimit, highLimit);
result = powerMonitor.checkPower(power.value, lowLimit, highLimit);
if (result == MonitoringIF::BELOW_LOW_LIMIT) {
reportEvents(POWER_BELOW_LOW_LIMIT);
} else if (result == MonitoringIF::ABOVE_HIGH_LIMIT) {
@ -109,7 +112,7 @@ size_t Fuse::getSerializedSize() const {
}
ReturnValue_t Fuse::deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) {
Endianness streamEndianness) {
ReturnValue_t result = RETURN_FAILED;
for (DeviceList::iterator iter = devices.begin(); iter != devices.end();
iter++) {
@ -132,7 +135,7 @@ void Fuse::calculateFusePower() {
return;
}
//Calculate fuse power.
power = current * voltage;
power.value = current.value * voltage.value;
power.setValid(PoolVariableIF::VALID);
}
@ -190,12 +193,12 @@ void Fuse::checkFuseState() {
reportEvents(FUSE_WENT_OFF);
}
}
oldFuseState = state;
oldFuseState = state.value;
}
float Fuse::getPower() {
if (power.isValid()) {
return power;
return power.value;
} else {
return 0.0;
}