added some comments; minor (prelimnary) structural adaptions
This commit is contained in:
@@ -1,6 +1,20 @@
|
|||||||
|
/*
|
||||||
|
File: Controller.cpp
|
||||||
|
Description: This is a C++ source file containing implementation code for a program or library component.
|
||||||
|
Rev: 0.1
|
||||||
|
Created: 06.04.26
|
||||||
|
Author: Uwe Jakobeit
|
||||||
|
Copyright: Binder GmbH TUT 2026
|
||||||
|
Purpose: Prelimnary version of control algorithm
|
||||||
|
Notes: [Any relevant details, such as dependencies, usage examples, or known issues.]
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef BUILD_TARGET_SOM
|
#ifdef BUILD_TARGET_SOM
|
||||||
#include "application/AppLogic.hpp"
|
#include "application/AppLogic.hpp"
|
||||||
#include "application/Environment.hpp"
|
#include "application/Environment.hpp"
|
||||||
@@ -16,7 +30,8 @@ bool Controller::initialize(const char *configFilePath, appengine::IAppLogic *ap
|
|||||||
auto deviceState = appLogic->deviceState();
|
auto deviceState = appLogic->deviceState();
|
||||||
|
|
||||||
|
|
||||||
|
MV_ Magnet Variable
|
||||||
|
SV_ State Variable
|
||||||
|
|
||||||
// Beispiel:
|
// Beispiel:
|
||||||
SV_Temperatur_Variable_ = deviceState.getVariableByKey("Temperatur_Innenraum");
|
SV_Temperatur_Variable_ = deviceState.getVariableByKey("Temperatur_Innenraum");
|
||||||
@@ -136,80 +151,105 @@ bool Controller::initialize(const char *configFilePath, appengine::IAppLogic *ap
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
void Controller::stepSOM(void)
|
||||||
void Controller::step() {
|
{
|
||||||
#ifdef BUILD_TARGET_SOM
|
#ifdef BUILD_TARGET_SOM
|
||||||
ClimateAlgorithm::Inputs in{};
|
ClimateAlgorithm::Inputs in{};
|
||||||
in.Istwert_Temperatur = FILTERED_TEMP.step(SV_Temperatur_Variable_->toType<double>());
|
in.Istwert_Temperatur = FILTERED_TEMP.step(SV_Temperatur_Variable_->toType<double>());
|
||||||
in.Sollwert_Temperatur = SV_Sollwert_Temperatur_ ->toType<double>();
|
in.Sollwert_Temperatur = SV_Sollwert_Temperatur_ ->toType<double>();
|
||||||
in.Entleerbehaelter_Oben = Wasserstand_Oben_Config_->toType<bool>();
|
in.Entleerbehaelter_Oben = Wasserstand_Oben_Config_->toType<bool>();
|
||||||
in.Entleerbehaelter_Unten = Wasserstand_Unten_Config_->toType<bool>();
|
in.Entleerbehaelter_Unten = Wasserstand_Unten_Config_->toType<bool>();
|
||||||
in.Istwert_Feuchte = SV_Feuchte_Variable_->toType<double>();
|
in.Istwert_Feuchte = SV_Feuchte_Variable_->toType<double>();
|
||||||
in.Sollwert_Feuchte = SV_Sollwert_Feuchte_->toType<double>();
|
in.Sollwert_Feuchte = SV_Sollwert_Feuchte_->toType<double>();
|
||||||
in.Istwert_Temperatur_Tuer = FILTER_TUER.step(SV_Tuer_Variable_->toType<double>());
|
in.Istwert_Temperatur_Tuer = FILTER_TUER.step(SV_Tuer_Variable_->toType<double>());
|
||||||
in.Betauungsschutz = 50.0;
|
in.Betauungsschutz = 50.0;
|
||||||
in.Grenzwert_Untertemperatur = -80.0;
|
in.Grenzwert_Untertemperatur = -80.0;
|
||||||
in.Feuchteband=10.0;
|
in.Feuchteband=10.0;
|
||||||
in.Istwert_Temperatur_Verdampferausgang = SV_Verdampferausgang_->toType<double>();
|
in.Istwert_Temperatur_Verdampferausgang = SV_Verdampferausgang_->toType<double>();
|
||||||
in.Sollwert_Feuchte = SV_Sollwert_Feuchte_->toType<double>();
|
in.Sollwert_Feuchte = SV_Sollwert_Feuchte_->toType<double>();
|
||||||
in.Istwert_Ueberwachungsregler=in.Istwert_Temperatur;
|
in.Istwert_Ueberwachungsregler=in.Istwert_Temperatur;
|
||||||
in.Klasse_Ueberwachungsregler = 3.0;
|
in.Klasse_Ueberwachungsregler = 3.0;
|
||||||
in.reset_flag =false;
|
in.reset_flag =false;
|
||||||
in.Sammelalarm = false;
|
in.Sammelalarm = false;
|
||||||
in.Sollwert_Feuchte_aktiv = true;
|
in.Sollwert_Feuchte_aktiv = true;
|
||||||
in.Temperaturband = 5.0;
|
in.Temperaturband = 5.0;
|
||||||
in.Temperatur_Feuchtemodul = SV_Befeuchtungsmodul_->toType<double>();
|
in.Temperatur_Feuchtemodul = SV_Befeuchtungsmodul_->toType<double>();
|
||||||
in.Wasserkanister_leer = false;
|
in.Wasserkanister_leer = false;
|
||||||
in.Tuer_offen = false;
|
in.Tuer_offen = false;
|
||||||
|
|
||||||
|
|
||||||
// TODO: reset_flag und bool_inXX lesen:
|
// TODO: reset_flag und bool_inXX lesen:
|
||||||
// in.reset_flag = deviceState.getVariableByKey("reset_flag")->toType<bool>();
|
// in.reset_flag = deviceState.getVariableByKey("reset_flag")->toType<bool>();
|
||||||
// in.Sammelalarm_quittiert = ... bool_in01
|
// in.Sammelalarm_quittiert = ... bool_in01
|
||||||
// ...
|
// ...
|
||||||
// in.Istwert_Temperatur = real_in01
|
// in.Istwert_Temperatur = real_in01
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Minimal-Beispiel (falls du erstmal nur Temperatur/Setpoint testest):
|
// Minimal-Beispiel (falls du erstmal nur Temperatur/Setpoint testest):
|
||||||
//in.Istwert_Temperatur = tempVariable_ ? tempVariable_->toType<double>() : 0.0;
|
//in.Istwert_Temperatur = tempVariable_ ? tempVariable_->toType<double>() : 0.0;
|
||||||
//in.Sollwert_Temperatur = tempSetPointVariable_ ? tempSetPointVariable_->toType<double>() : 25.0;
|
//in.Sollwert_Temperatur = tempSetPointVariable_ ? tempSetPointVariable_->toType<double>() : 25.0;
|
||||||
|
|
||||||
auto out = algo_.step(in);
|
auto out = algo_.step(in);
|
||||||
|
|
||||||
Heizung_Bef_Config_ -> setValue(out.bool_out17);
|
Heizung_Bef_Config_ -> setValue(out.bool_out17);
|
||||||
MV_Kuehlung_Config_ ->setValue(out.bool_out18);
|
MV_Kuehlung_Config_ ->setValue(out.bool_out18);
|
||||||
Abschlaemmen_Config_->setValue(out.bool_out20);
|
Abschlaemmen_Config_->setValue(out.bool_out20);
|
||||||
Entleerpumpe_Config_->setValue(out.bool_out16);
|
Entleerpumpe_Config_->setValue(out.bool_out16);
|
||||||
Heizung_Kesselrand_Config_->setValue(out.bool_out12);
|
Heizung_Kesselrand_Config_->setValue(out.bool_out12);
|
||||||
Freigabe_Verfluessigerluefter_Config_->setValue(out.bool_out13);
|
Freigabe_Verfluessigerluefter_Config_->setValue(out.bool_out13);
|
||||||
Heizung_Innenraum_Config_->setValue(out.bool_out09);
|
Heizung_Innenraum_Config_->setValue(out.bool_out09);
|
||||||
Heizung_Tuer_Config_->setValue(out.bool_out11);
|
Heizung_Tuer_Config_->setValue(out.bool_out11);
|
||||||
Uebertemperatur_Config_->setValue(true);
|
Uebertemperatur_Config_->setValue(true);
|
||||||
MV_Entfeuchtung_Config_->setValue(out.bool_out19);
|
MV_Entfeuchtung_Config_->setValue(out.bool_out19);
|
||||||
MV_Druckluft_Config_->setValue(false);
|
MV_Druckluft_Config_->setValue(false);
|
||||||
|
|
||||||
Ansteuerung_Wassereinlass_Config_->setValue(out.bool_out14);
|
Ansteuerung_Wassereinlass_Config_->setValue(out.bool_out14);
|
||||||
//Ansteuerung_Verdichter_Config_->setValue(out.real_out21*20.0);
|
//Ansteuerung_Verdichter_Config_->setValue(out.real_out21*20.0);
|
||||||
SV_Verdichter_on_->setValue(1);
|
SV_Verdichter_on_->setValue(1);
|
||||||
Ansteuerung_Verdichter_Config_->setValue(static_cast<int> (out.real_out21*10.0));
|
Ansteuerung_Verdichter_Config_->setValue(static_cast<int> (out.real_out21*10.0));
|
||||||
Verdichter_Duty_Config->setValue(500);
|
Verdichter_Duty_Config->setValue(500);
|
||||||
|
|
||||||
SV_Stellgrad_Heizung->setValue(out.Stellgrad_Heizung);
|
SV_Stellgrad_Heizung->setValue(out.Stellgrad_Heizung);
|
||||||
SV_Stellgrad_Kuehlung->setValue(out.Stellgrad_Kuehlung);
|
SV_Stellgrad_Kuehlung->setValue(out.Stellgrad_Kuehlung);
|
||||||
SV_Stellgrad_Befeuchtung ->setValue(out.Stellgrad_Befeuchtung);
|
SV_Stellgrad_Befeuchtung ->setValue(out.Stellgrad_Befeuchtung);
|
||||||
SV_Stellgrad_Entfeuchtung->setValue(out.Stellgrad_Entfeuchtung);
|
SV_Stellgrad_Entfeuchtung->setValue(out.Stellgrad_Entfeuchtung);
|
||||||
Startup_->setValue(out.Startup);
|
Startup_->setValue(out.Startup);
|
||||||
CounterTuer_->setValue(out.Counter_Tuer);
|
CounterTuer_->setValue(out.Counter_Tuer);
|
||||||
|
|
||||||
// TODO: bool_outXX / real_outXX / alarm_XX setzen:
|
// TODO: bool_outXX / real_outXX / alarm_XX setzen:
|
||||||
// deviceState.getVariableByKey("bool_out01")->set(out.bool_out01);
|
// deviceState.getVariableByKey("bool_out01")->set(out.bool_out01);
|
||||||
// deviceState.getVariableByKey("real_out09")->set(out.real_out09);
|
// deviceState.getVariableByKey("real_out09")->set(out.real_out09);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::step(void)
|
||||||
|
{
|
||||||
|
#ifdef BUILD_TARGET_SOM
|
||||||
|
|
||||||
|
stepSOM();
|
||||||
|
|
||||||
|
#else
|
||||||
|
stepDesk();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Controller::stepDesk(void)
|
||||||
|
{
|
||||||
|
inputs = model->getInputs();
|
||||||
|
qDebug() << "Tist.: " << inputs->data()->analog.Istwert_Temperatur;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Controller::terminate() {
|
void Controller::terminate() {
|
||||||
#ifdef BUILD_TARGET_SOM
|
#ifdef BUILD_TARGET_SOM
|
||||||
subscriptions_.clear();
|
subscriptions_.clear();
|
||||||
@@ -222,3 +262,39 @@ ControllerBase *create() {
|
|||||||
return new Controller;
|
return new Controller;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// initialize algorithm according to configuration ( not yet available 02.04.26 )
|
||||||
|
// return plainly true (until otherwise)
|
||||||
|
bool Controller::initialize(const char *configFilePath)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
// uncomment when available
|
||||||
|
// result = (configFilePath != (const char *) nullptr);
|
||||||
|
|
||||||
|
// DataModel* model = new DataModel;
|
||||||
|
// QList<Input_t>* inputs;
|
||||||
|
// model->getInputs();
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Controller::initialize( QList<Input_t>* inputs)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Controller::initialize( DataModel* instance)
|
||||||
|
{
|
||||||
|
model = instance;
|
||||||
|
|
||||||
|
inputs = model->getInputs();
|
||||||
|
|
||||||
|
return inputs != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user