cappedPressure : use std::clamp

This commit is contained in:
2026-07-28 11:31:17 +02:00
parent a85c4f9c03
commit 4847b9543f
+8 -10
View File
@@ -3,16 +3,17 @@
#include "Average.h"
#include "DemandHandler.h"
#include "InputHandler.h"
#include <algorithm>
#include <string>
void PressureCalculator::update() {
double averagePower = average.getAverage();
double c2contrib = averagePower * cachedConstant2;
double c1contrib =
float averagePower = average.getAverage();
float c2contrib = averagePower * cachedConstant2;
float c1contrib =
cachedConstant1 * (cachedTemperature - cachedSP - c2contrib);
double uncappedPressure = cachedMinimalPressure + c1contrib;
float uncappedPressure = cachedMinimalPressure + c1contrib;
double cappedPressure = uncappedPressure;
float cappedPressure = uncappedPressure;
if (c2contrib != 0) {
c2contrib = -c2contrib * cachedConstant1;
@@ -20,11 +21,8 @@ void PressureCalculator::update() {
c2contrib = 0.0f;
}
if (cappedPressure < cachedMinimalPressure)
cappedPressure = cachedMinimalPressure;
if (cappedPressure > cachedMaximalPressure)
cappedPressure = cachedMaximalPressure;
cappedPressure = std::clamp(uncappedPressure, cachedMinimalPressure,
cachedMaximalPressure);
Event event = {};