142 lines
2.5 KiB
C++
142 lines
2.5 KiB
C++
/*
|
||
* PhaseSpaceLimit.cpp
|
||
*
|
||
* Created on: 10 авг. 2020 г.
|
||
* Author: LeonidTitov
|
||
*/
|
||
|
||
#include "PhaseSpaceLimit.hh"
|
||
|
||
#include <cmath>
|
||
|
||
void processing::acs::PhaseSpaceLimit::set( TypeInput phaseSpacePoint ) {
|
||
|
||
if( isConnected() ) {
|
||
|
||
bool limited = false;
|
||
|
||
if( phaseSpacePoint.value > h_t ) {
|
||
phaseSpacePoint.value = h_t;
|
||
|
||
if( phaseSpacePoint.d_value > 0 )
|
||
phaseSpacePoint.d_value = 0;
|
||
|
||
|
||
limited = true;
|
||
|
||
}
|
||
|
||
if( phaseSpacePoint.value < l_t ) {
|
||
phaseSpacePoint.value = l_t;
|
||
|
||
if( phaseSpacePoint.d_value < 0 )
|
||
phaseSpacePoint.d_value = 0;
|
||
|
||
limited = true;
|
||
}
|
||
|
||
limited_flag = limited;
|
||
limited_value = phaseSpacePoint;
|
||
|
||
output->set( phaseSpacePoint );
|
||
|
||
}
|
||
|
||
}
|
||
|
||
processing::acs::PhaseSpaceLimit::TypeOutput processing::acs::PhaseSpaceLimit::get() const {
|
||
|
||
return limited_value;
|
||
|
||
}
|
||
|
||
void processing::acs::PhaseSpaceLimit::set_output( SetInterface * new_output ) {
|
||
|
||
output = new_output;
|
||
|
||
}
|
||
|
||
void processing::acs::PhaseSpaceLimit::reset() {
|
||
|
||
limited_value = TypeOutput( NAN, NAN );
|
||
limited_flag = false;
|
||
|
||
}
|
||
|
||
vector::ITechValue & processing::acs::PhaseSpaceLimit::getUpperLimit() {
|
||
|
||
return upper;
|
||
|
||
}
|
||
|
||
vector::ITechValue & processing::acs::PhaseSpaceLimit::getLowerLimit() {
|
||
|
||
return lower;
|
||
|
||
}
|
||
|
||
void processing::acs::PhaseSpaceLimit::apply() {
|
||
|
||
if( upper.value > lower.value ) {
|
||
|
||
h_t = upper.value;
|
||
l_t = lower.value;
|
||
|
||
range_valid = true;
|
||
|
||
} else {
|
||
|
||
if( upper.value == lower.value) {
|
||
|
||
h_t = l_t = upper.value;
|
||
|
||
} else {
|
||
|
||
h_t = 0.0f;
|
||
l_t = 0.0f;
|
||
|
||
}
|
||
|
||
range_valid = false;
|
||
|
||
}
|
||
}
|
||
|
||
const bool & processing::acs::PhaseSpaceLimit::valid_range() const {
|
||
|
||
return range_valid;
|
||
|
||
}
|
||
|
||
const bool& processing::acs::PhaseSpaceLimit::is_limited() const {
|
||
|
||
return limited_flag;
|
||
|
||
}
|
||
|
||
void processing::acs::PhaseSpaceLimit::configure( Setting & config ) {
|
||
|
||
upper.value = config.upper_limit;
|
||
lower.value = config.lower_limit;
|
||
|
||
apply();
|
||
|
||
}
|
||
|
||
bool processing::acs::PhaseSpaceLimit::Setting::isValid() {
|
||
|
||
using namespace std;
|
||
return upper_limit >= lower_limit;
|
||
|
||
}
|
||
|
||
processing::acs::PhaseSpaceLimit::PhaseSpaceLimit() :
|
||
range_valid(false), limited_flag(false), lower(), upper(),
|
||
h_t(NAN), l_t(NAN), limited_value(NAN, NAN), output(nullptr) {}
|
||
|
||
bool processing::acs::PhaseSpaceLimit::isConnected() const {
|
||
|
||
return output;
|
||
|
||
}
|