From 4bb9dd816ec910870cd8183951efbdae9cb74d0d Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 30 Nov 2020 16:06:59 +0100 Subject: [PATCH] compiling again --- datapoollocal/LocalPoolObjectBase.cpp | 4 + datapoollocal/LocalPoolObjectBase.h | 1 + datapoollocal/LocalPoolVariable.h | 18 +++- datapoollocal/LocalPoolVariable.tpp | 49 ++++++++- monitoring/AbsLimitMonitor.h | 4 +- monitoring/LimitMonitor.h | 4 +- monitoring/MonitorReporter.h | 8 +- power/Fuse.cpp | 50 ++++----- power/PowerSensor.cpp | 36 +++---- thermal/ThermalComponentCore.cpp | 146 +++++++++++++------------- thermal/ThermalComponentCore.h | 6 +- thermal/tcsDefinitions.h | 2 +- 12 files changed, 196 insertions(+), 132 deletions(-) diff --git a/datapoollocal/LocalPoolObjectBase.cpp b/datapoollocal/LocalPoolObjectBase.cpp index c25df25a..b4d0e306 100644 --- a/datapoollocal/LocalPoolObjectBase.cpp +++ b/datapoollocal/LocalPoolObjectBase.cpp @@ -67,3 +67,7 @@ void LocalPoolObjectBase::setChanged(bool changed) { bool LocalPoolObjectBase::hasChanged() const { return changed; } + +void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) { + this->readWriteMode = newReadWriteMode; +} diff --git a/datapoollocal/LocalPoolObjectBase.h b/datapoollocal/LocalPoolObjectBase.h index 8d1ab45e..7165fc24 100644 --- a/datapoollocal/LocalPoolObjectBase.h +++ b/datapoollocal/LocalPoolObjectBase.h @@ -18,6 +18,7 @@ public: DataSetIF* dataSet = nullptr, pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); + void setReadWriteMode(pool_rwm_t newReadWriteMode); pool_rwm_t getReadWriteMode() const; bool isValid() const override; diff --git a/datapoollocal/LocalPoolVariable.h b/datapoollocal/LocalPoolVariable.h index 173c2035..bb36089d 100644 --- a/datapoollocal/LocalPoolVariable.h +++ b/datapoollocal/LocalPoolVariable.h @@ -118,8 +118,21 @@ public: ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; - LocalPoolVar &operator=(T newValue); - LocalPoolVar &operator=(LocalPoolVar newPoolVariable); + LocalPoolVar &operator=(const T& newValue); + LocalPoolVar &operator=(const LocalPoolVar& newPoolVariable); + + bool operator==(const LocalPoolVar& other) const; + bool operator==(const T& other) const; + + bool operator!=(const LocalPoolVar& other) const; + bool operator!=(const T& other) const; + + bool operator<(const LocalPoolVar& other) const; + bool operator<(const T& other) const; + + bool operator>(const LocalPoolVar& other) const; + bool operator>(const T& other) const; + protected: /** * @brief Like #read, but without a lock protection of the global pool. @@ -165,5 +178,4 @@ using lp_int64_t = LocalPoolVar; using lp_float_t = LocalPoolVar; using lp_double_t = LocalPoolVar; - #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ */ diff --git a/datapoollocal/LocalPoolVariable.tpp b/datapoollocal/LocalPoolVariable.tpp index 8aa164d1..a63e550d 100644 --- a/datapoollocal/LocalPoolVariable.tpp +++ b/datapoollocal/LocalPoolVariable.tpp @@ -81,14 +81,14 @@ inline ReturnValue_t LocalPoolVar::commitWithoutLock() { } template -inline LocalPoolVar & LocalPoolVar::operator=(T newValue) { +inline LocalPoolVar & LocalPoolVar::operator=(const T& newValue) { value = newValue; return *this; } template inline LocalPoolVar& LocalPoolVar::operator =( - LocalPoolVar newPoolVariable) { + const LocalPoolVar& newPoolVariable) { value = newPoolVariable.value; return *this; } @@ -119,4 +119,47 @@ inline std::ostream& operator<< (std::ostream &out, return out; } -#endif +template +inline bool LocalPoolVar::operator ==(const LocalPoolVar &other) const { + return this->value == other.value; +} + +template +inline bool LocalPoolVar::operator ==(const T &other) const { + return this->value == other; +} + + +template +inline bool LocalPoolVar::operator !=(const LocalPoolVar &other) const { + return not (*this == other); +} + +template +inline bool LocalPoolVar::operator !=(const T &other) const { + return not (*this == other); +} + + +template +inline bool LocalPoolVar::operator <(const LocalPoolVar &other) const { + return this->value < other.value; +} + +template +inline bool LocalPoolVar::operator <(const T &other) const { + return this->value < other; +} + + +template +inline bool LocalPoolVar::operator >(const LocalPoolVar &other) const { + return not (*this < other); +} + +template +inline bool LocalPoolVar::operator >(const T &other) const { + return not (*this < other); +} + +#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_TPP_ */ diff --git a/monitoring/AbsLimitMonitor.h b/monitoring/AbsLimitMonitor.h index 1206dbf6..5feb369c 100644 --- a/monitoring/AbsLimitMonitor.h +++ b/monitoring/AbsLimitMonitor.h @@ -66,8 +66,8 @@ protected: switch (state) { case MonitoringIF::OUT_OF_RANGE: EventManagerIF::triggerEvent(this->reportingId, - violationEvent, this->parameterId.objectId, - this->parameterId.localPoolId); + violationEvent, this->globalPoolId.objectId, + this->globalPoolId.localPoolId); break; default: break; diff --git a/monitoring/LimitMonitor.h b/monitoring/LimitMonitor.h index 27e35aa7..c4448ced 100644 --- a/monitoring/LimitMonitor.h +++ b/monitoring/LimitMonitor.h @@ -80,11 +80,11 @@ protected: switch (state) { case MonitoringIF::BELOW_LOW_LIMIT: EventManagerIF::triggerEvent(this->reportingId, belowLowEvent, - this->parameterId.objectId, this->parameterId.localPoolId); + this->globalPoolId.objectId, this->globalPoolId.localPoolId); break; case MonitoringIF::ABOVE_HIGH_LIMIT: EventManagerIF::triggerEvent(this->reportingId, aboveHighEvent, - this->parameterId.objectId, this->parameterId.localPoolId); + this->globalPoolId.objectId, this->globalPoolId.localPoolId); break; default: break; diff --git a/monitoring/MonitorReporter.h b/monitoring/MonitorReporter.h index d6d8c8ed..9028e7e4 100644 --- a/monitoring/MonitorReporter.h +++ b/monitoring/MonitorReporter.h @@ -20,7 +20,7 @@ public: MonitorReporter(object_id_t reportingId, uint8_t monitorId, gp_id_t globalPoolId, uint16_t confirmationLimit) : - monitorId(monitorId), parameterId(parameterId), + monitorId(monitorId), globalPoolId(globalPoolId), reportingId(reportingId), oldState(MonitoringIF::UNCHECKED), reportingEnabled(ENABLED), eventEnabled(ENABLED), currentCounter(0), confirmationLimit(confirmationLimit) { @@ -96,7 +96,7 @@ public: protected: const uint8_t monitorId; - const gp_id_t parameterId; + const gp_id_t globalPoolId; object_id_t reportingId; ReturnValue_t oldState; @@ -167,13 +167,13 @@ protected: */ virtual void sendTransitionReport(T parameterValue, T crossedLimit, ReturnValue_t state) { - MonitoringReportContent report(parameterId, + MonitoringReportContent report(globalPoolId, parameterValue, crossedLimit, oldState, state); LimitViolationReporter::sendLimitViolationReport(&report); } ReturnValue_t setToState(ReturnValue_t state) { if (oldState != state && reportingEnabled) { - MonitoringReportContent report(parameterId, 0, 0, oldState, + MonitoringReportContent report(globalPoolId, 0, 0, oldState, state); LimitViolationReporter::sendLimitViolationReport(&report); oldState = state; diff --git a/power/Fuse.cpp b/power/Fuse.cpp index ff9c7b3c..1c30d83f 100644 --- a/power/Fuse.cpp +++ b/power/Fuse.cpp @@ -72,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.value, 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; } @@ -135,7 +135,7 @@ void Fuse::calculateFusePower() { return; } //Calculate fuse power. - //power = current * voltage; + power.value = current.value * voltage.value; power.setValid(PoolVariableIF::VALID); } @@ -188,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.value; } float Fuse::getPower() { -// if (power.isValid()) { -// return power; -// } else { -// return 0.0; -// } + if (power.isValid()) { + return power.value; + } else { + return 0.0; + } } void Fuse::setDataPoolEntriesInvalid() { diff --git a/power/PowerSensor.cpp b/power/PowerSensor.cpp index 8fe3cf3a..1ef041e3 100644 --- a/power/PowerSensor.cpp +++ b/power/PowerSensor.cpp @@ -26,24 +26,24 @@ ReturnValue_t PowerSensor::calculatePower() { 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; -// } -// powerSensorSet.commit(); + if (healthHelper.healthTable->isHealthy(getObjectId()) && voltage.isValid() + && current.isValid()) { + result1 = voltageLimit.doCheck(voltage.value); + result2 = currentLimit.doCheck(current.value); + } 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.value = current.value * voltage.value; + } + powerSensorSet.commit(); return result1; } diff --git a/thermal/ThermalComponentCore.cpp b/thermal/ThermalComponentCore.cpp index 53eeb58f..a64491c0 100644 --- a/thermal/ThermalComponentCore.cpp +++ b/thermal/ThermalComponentCore.cpp @@ -9,16 +9,18 @@ ThermalComponentCore::ThermalComponentCore(object_id_t reportingObjectId, targetState(targetStatePoolId, dataSet, PoolVariableIF::VAR_READ), currentState(currentStatePoolId, dataSet, PoolVariableIF::VAR_WRITE), heaterRequest(requestPoolId, dataSet, PoolVariableIF::VAR_WRITE), - parameters(parameters), domainId(domainId) { - //temperatureMonitor(reportingObjectId, domainId + 1, - // GlobalDataPool::poolIdAndPositionToPid(temperaturePoolId, 0), - // COMPONENT_TEMP_CONFIRMATION), domainId(domainId) { + parameters(parameters), domainId(domainId), + temperatureMonitor(reportingObjectId, domainId + 1,temperaturePoolId, + COMPONENT_TEMP_CONFIRMATION) { //Set thermal state once, then leave to operator. - //GlobDataSet mySet; - //gp_uint8_t writableTargetState(targetStatePoolId, &mySet, - // PoolVariableIF::VAR_WRITE); - //writableTargetState = initialTargetState; - //mySet.commit(PoolVariableIF::VALID); + targetState.setReadWriteMode(PoolVariableIF::VAR_WRITE); + ReturnValue_t result = targetState.read(); + if(result == HasReturnvaluesIF::RETURN_OK) { + targetState = initialTargetState; + targetState.setValid(true); + targetState.commit(); + } + targetState.setReadWriteMode(PoolVariableIF::VAR_READ); } void ThermalComponentCore::addSensor(AbstractTemperatureSensor* sensor) { @@ -57,19 +59,21 @@ ThermalComponentIF::HeaterRequest ThermalComponentCore::performOperation( HeaterRequest request = HEATER_DONT_CARE; //SHOULDDO: Better pass db_float_t* to getTemperature and set it invalid if invalid. temperature = getTemperature(); - //updateMinMaxTemp(); - //if ((temperature != INVALID_TEMPERATURE)) { - //temperature.setValid(PoolVariableIF::VALID); - //State state = getState(temperature, getParameters(), targetState); - //currentState = state; - //checkLimits(state); - //request = getHeaterRequest(targetState, temperature, getParameters()); - //} else { - // temperatureMonitor.setToInvalid(); - // temperature.setValid(PoolVariableIF::INVALID); - // currentState = UNKNOWN; - // request = HEATER_DONT_CARE; - //} + updateMinMaxTemp(); + if ((temperature != INVALID_TEMPERATURE)) { + temperature.setValid(PoolVariableIF::VALID); + State state = getState(temperature.value, getParameters(), + targetState.value); + currentState = state; + checkLimits(state); + request = getHeaterRequest(targetState.value, temperature.value, + getParameters()); + } else { + temperatureMonitor.setToInvalid(); + temperature.setValid(PoolVariableIF::INVALID); + currentState = UNKNOWN; + request = HEATER_DONT_CARE; + } currentState.setValid(PoolVariableIF::VALID); heaterRequest = request; heaterRequest.setValid(PoolVariableIF::VALID); @@ -77,11 +81,11 @@ ThermalComponentIF::HeaterRequest ThermalComponentCore::performOperation( } void ThermalComponentCore::markStateIgnored() { - //currentState = getIgnoredState(currentState); + currentState = getIgnoredState(currentState.value); } object_id_t ThermalComponentCore::getObjectId() { - //return temperatureMonitor.getReporterId(); + return temperatureMonitor.getReporterId(); return 0; } @@ -120,7 +124,7 @@ void ThermalComponentCore::setOutputInvalid() { currentState.setValid(PoolVariableIF::INVALID); heaterRequest = HEATER_DONT_CARE; heaterRequest.setValid(PoolVariableIF::INVALID); - //temperatureMonitor.setToUnchecked(); + temperatureMonitor.setToUnchecked(); } float ThermalComponentCore::getTemperature() { @@ -170,8 +174,8 @@ ThermalComponentIF::State ThermalComponentCore::getState(float temperature, void ThermalComponentCore::checkLimits(ThermalComponentIF::State state) { //Checks operational limits only. - //temperatureMonitor.translateState(state, temperature.value, - // getParameters().lowerOpLimit, getParameters().upperOpLimit); + temperatureMonitor.translateState(state, temperature.value, + getParameters().lowerOpLimit, getParameters().upperOpLimit); } @@ -221,17 +225,17 @@ ThermalComponentIF::State ThermalComponentCore::getIgnoredState(int8_t state) { } } -//void ThermalComponentCore::updateMinMaxTemp() { -// if (temperature == INVALID_TEMPERATURE) { -// return; -// } -// if (temperature < minTemp) { -// minTemp = temperature; -// } -// if (temperature > maxTemp) { -// maxTemp = temperature; -// } -//} +void ThermalComponentCore::updateMinMaxTemp() { + if (temperature == INVALID_TEMPERATURE) { + return; + } + if (temperature < minTemp) { + minTemp = temperature.value; + } + if (temperature > maxTemp) { + maxTemp = temperature.value; + } +} uint8_t ThermalComponentCore::getDomainId() const { return domainId; @@ -244,38 +248,38 @@ ThermalComponentCore::Parameters ThermalComponentCore::getParameters() { ReturnValue_t ThermalComponentCore::getParameter(uint8_t domainId, uint16_t parameterId, ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, uint16_t startAtIndex) { - //ReturnValue_t result = temperatureMonitor.getParameter(domainId, - // parameterId, parameterWrapper, newValues, startAtIndex); -// if (result != INVALID_DOMAIN_ID) { -// return result; -// } -// if (domainId != this->domainId) { -// return INVALID_DOMAIN_ID; -// } -// switch (parameterId) { -// case 0: -// parameterWrapper->set(parameters.heaterOn); -// break; -// case 1: -// parameterWrapper->set(parameters.hysteresis); -// break; -// case 2: -// parameterWrapper->set(parameters.heaterSwitchoff); -// break; -// case 3: -// parameterWrapper->set(minTemp); -// break; -// case 4: -// parameterWrapper->set(maxTemp); -// break; -// case 10: -// parameterWrapper->set(parameters.lowerOpLimit); -// break; -// case 11: -// parameterWrapper->set(parameters.upperOpLimit); -// break; -// default: -// return INVALID_IDENTIFIER_ID; -// } + ReturnValue_t result = temperatureMonitor.getParameter(domainId, + parameterId, parameterWrapper, newValues, startAtIndex); + if (result != INVALID_DOMAIN_ID) { + return result; + } + if (domainId != this->domainId) { + return INVALID_DOMAIN_ID; + } + switch (parameterId) { + case 0: + parameterWrapper->set(parameters.heaterOn); + break; + case 1: + parameterWrapper->set(parameters.hysteresis); + break; + case 2: + parameterWrapper->set(parameters.heaterSwitchoff); + break; + case 3: + parameterWrapper->set(minTemp); + break; + case 4: + parameterWrapper->set(maxTemp); + break; + case 10: + parameterWrapper->set(parameters.lowerOpLimit); + break; + case 11: + parameterWrapper->set(parameters.upperOpLimit); + break; + default: + return INVALID_IDENTIFIER_ID; + } return HasReturnvaluesIF::RETURN_OK; } diff --git a/thermal/ThermalComponentCore.h b/thermal/ThermalComponentCore.h index 6ef59058..19d72359 100644 --- a/thermal/ThermalComponentCore.h +++ b/thermal/ThermalComponentCore.h @@ -96,10 +96,10 @@ protected: Parameters parameters; - //ThermalMonitorReporter temperatureMonitor; - const uint8_t domainId; + ThermalMonitorReporter temperatureMonitor; + virtual float getTemperature(); virtual State getState(float temperature, Parameters parameters, int8_t targetState); @@ -111,7 +111,7 @@ protected: virtual State getIgnoredState(int8_t state); - //void updateMinMaxTemp(); + void updateMinMaxTemp(); virtual Parameters getParameters(); }; diff --git a/thermal/tcsDefinitions.h b/thermal/tcsDefinitions.h index ad258ced..37e5b849 100644 --- a/thermal/tcsDefinitions.h +++ b/thermal/tcsDefinitions.h @@ -2,7 +2,7 @@ #define TCSDEFINITIONS_H_ -static const uint32_t INVALID_TEMPERATURE = 999; +static const float INVALID_TEMPERATURE = 999; #endif /* TCSDEFINITIONS_H_ */