91 lines
1.8 KiB
C++
91 lines
1.8 KiB
C++
|
|
/*
|
|||
|
|
* PiControllerProcess.cpp
|
|||
|
|
*
|
|||
|
|
* Created on: 5 <EFBFBD><EFBFBD><EFBFBD>. 2020 <EFBFBD>.
|
|||
|
|
* Author: LeonidTitov
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
#include "PiControllerProcess.hh"
|
|||
|
|
|
|||
|
|
void processing::acs::PiControllerProcess::set( TypeInput setpoint ) {
|
|||
|
|
|
|||
|
|
value_error = setpoint;
|
|||
|
|
|
|||
|
|
if( isConnected() and not(proc_enable) ) {
|
|||
|
|
|
|||
|
|
regulator.recalculate(value_error, current_value);
|
|||
|
|
|
|||
|
|
proc_enable = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
processing::acs::PiControllerProcess::TypeOutput processing::acs::PiControllerProcess::get() const {
|
|||
|
|
|
|||
|
|
return current_value;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void processing::acs::PiControllerProcess::set_output(
|
|||
|
|
SetInterface * output_interface ) {
|
|||
|
|
|
|||
|
|
if( not output_interface ) proc_enable = false;
|
|||
|
|
|
|||
|
|
output = output_interface;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
vector::ITechValue & processing::acs::PiControllerProcess::getLimit() {
|
|||
|
|
|
|||
|
|
return limit;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void processing::acs::PiControllerProcess::setSampleTime( float ts_in_second ) {
|
|||
|
|
|
|||
|
|
regulator.setTime(ts_in_second);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void processing::acs::PiControllerProcess::process() {
|
|||
|
|
|
|||
|
|
if( not proc_enable )
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
// value_error.update();
|
|||
|
|
// tracking.value.update();
|
|||
|
|
|
|||
|
|
value_output = regulator( value_error, tracking.value );
|
|||
|
|
|
|||
|
|
output->set(value_output);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void processing::acs::PiControllerProcess::reset() {
|
|||
|
|
|
|||
|
|
proc_enable = false;
|
|||
|
|
|
|||
|
|
value_error = 0.0f;
|
|||
|
|
tracking.value = current_value;
|
|||
|
|
|
|||
|
|
regulator.reset();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
vector::ITechValue & processing::acs::PiControllerProcess::getTrackingTract() {
|
|||
|
|
|
|||
|
|
return tracking;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
processing::acs::PiControllerProcess::PiControllerProcess(
|
|||
|
|
Regulator & regulator, systemic::ISignal & current_value ) : regulator(regulator), current_value(current_value),
|
|||
|
|
value_error(0.0f), tracking(), limit(regulator),
|
|||
|
|
proc_enable(false), output(nullptr), value_output(0.0f) {}
|
|||
|
|
|
|||
|
|
bool processing::acs::PiControllerProcess::isConnected() const {
|
|||
|
|
|
|||
|
|
return output;
|
|||
|
|
|
|||
|
|
}
|