initial commit
This commit is contained in:
29
app/CMakeLists.txt
Normal file
29
app/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(app main.cpp
|
||||
)
|
||||
|
||||
qt_add_library(app_lib STATIC
|
||||
filter.h main.cpp filter.cpp
|
||||
Controller.hpp main.cpp Controller.cpp
|
||||
pwm.h pwm.cpp
|
||||
climate-algorithm.h climate-algorithm.cpp
|
||||
pid.h pid.cpp
|
||||
datamodel.h datamodel.cpp
|
||||
dataset.h dataset.cpp
|
||||
|
||||
text-templates.h
|
||||
|
||||
)
|
||||
|
||||
target_include_directories(app_lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_include_directories(app_lib PRIVATE ${Qt6Core_INCLUDE_DIRS})
|
||||
|
||||
# add_executable(app main.cpp filter.cpp)
|
||||
target_link_libraries(app PRIVATE
|
||||
app_lib
|
||||
Qt::Core
|
||||
)
|
||||
224
app/Controller.cpp
Normal file
224
app/Controller.cpp
Normal file
@@ -0,0 +1,224 @@
|
||||
#include "Controller.hpp"
|
||||
|
||||
|
||||
#ifdef BUILD_TARGET_SOM
|
||||
#include "application/AppLogic.hpp"
|
||||
#include "application/Environment.hpp"
|
||||
#include "application/EventLogger.hpp"
|
||||
#include "deviceConfig/model/DeviceConfiguration.hpp"
|
||||
#include "deviceConfig/model/state/GuardedAnalogConfiguration.hpp"
|
||||
#include "state/DeviceState.hpp"
|
||||
|
||||
|
||||
|
||||
bool Controller::initialize(const char *configFilePath, appengine::IAppLogic *appLogic) {
|
||||
appLogic_ = appLogic;
|
||||
auto deviceState = appLogic->deviceState();
|
||||
|
||||
|
||||
|
||||
|
||||
// Beispiel:
|
||||
SV_Temperatur_Variable_ = deviceState.getVariableByKey("Temperatur_Innenraum");
|
||||
SV_Feuchte_Variable_ = deviceState.getVariableByKey("Humidity");
|
||||
SV_Tuer_Variable_ = deviceState.getVariableByKey("Temperatur_Tuer");
|
||||
Wasserstand_Oben_Config_ = deviceState.getVariableByKey("Wasserstand_Hoch");
|
||||
Wasserstand_Unten_Config_ = deviceState.getVariableByKey("Wasserstand_Tief");
|
||||
Fuellstand_Config_ = deviceState.getVariableByKey("Fuellstand");
|
||||
Heizung_Bef_Config_ = deviceState.getVariableByKey("Heizung_Bef");
|
||||
MV_Kuehlung_Config_ = deviceState.getVariableByKey("MV_Kuehlung");
|
||||
Abschlaemmen_Config_ = deviceState.getVariableByKey("Abschlaemmen");
|
||||
Entleerpumpe_Config_ = deviceState.getVariableByKey("Entleerpumpe");
|
||||
Heizung_Kesselrand_Config_ = deviceState.getVariableByKey("Heizung_Kesselrand");
|
||||
Freigabe_Verfluessigerluefter_Config_ = deviceState.getVariableByKey("Freigabe_Verfluessigerluefter");
|
||||
Heizung_Innenraum_Config_ = deviceState.getVariableByKey("Heizung_Innenraum");
|
||||
Heizung_Tuer_Config_ = deviceState.getVariableByKey("Heizung_Tuer");
|
||||
Uebertemperatur_Config_ = deviceState.getVariableByKey("Uebertemperatur");
|
||||
MV_Entfeuchtung_Config_ = deviceState.getVariableByKey("MV_Entfeuchtung");
|
||||
MV_Druckluft_Config_ = deviceState.getVariableByKey("MV_Druckluft");
|
||||
Ansteuerung_Wassereinlass_Config_ = deviceState.getVariableByKey("Ansteuerung_Wassereinlass");
|
||||
Ansteuerung_Verdichter_Config_ = deviceState.getVariableByKey("Ansteuerung_Verdichter");
|
||||
Luefter_Innenraum_Config_ = deviceState.getVariableByKey("Luefter_Innenraum");
|
||||
SV_Verdampferausgang_ = deviceState.getVariableByKey("Temperatur_Verdampferausgang");
|
||||
SV_Befeuchtungsmodul_ = deviceState.getVariableByKey("Temperatur_Befeuchtungsmodul");
|
||||
const_duty_cycle_ = deviceState.getVariableByKey("steady_duty");
|
||||
const_freq_ = deviceState.getVariableByKey("steady_freq");
|
||||
Verdichter_Duty_Config = deviceState.getVariableByKey("Ansteuerung_Verdichter_duty");
|
||||
SV_Stellgrad_Heizung = deviceState.getVariableByKey("Stellgrad_Heizung");
|
||||
SV_Stellgrad_Kuehlung = deviceState.getVariableByKey("Stellgrad_Kuehlung");
|
||||
SV_Stellgrad_Befeuchtung = deviceState.getVariableByKey("Stellgrad_Befeuchtung");
|
||||
SV_Stellgrad_Entfeuchtung = deviceState.getVariableByKey("Stellgrad_Entfeuchtung");
|
||||
SV_Verdichter_on_ = deviceState.getVariableByKey("Verdichter_on");
|
||||
Startup_ = deviceState.getVariableByKey("Startup_finished");
|
||||
CounterTuer_ = deviceState.getVariableByKey("Counter_Tuer");
|
||||
|
||||
const_duty_cycle_ ->setValue(1000.0);
|
||||
const_freq_->setValue(1000.0);
|
||||
|
||||
auto TempConfig = dynamic_cast<appengine::deviceConfig::DeviceParameterConfiguration &>(SV_Temperatur_Variable_->configuration());
|
||||
auto FeuchteConfig = dynamic_cast<appengine::deviceConfig::DeviceParameterConfiguration &>(SV_Feuchte_Variable_->configuration());
|
||||
|
||||
|
||||
auto Sollwert_Temp_Config = TempConfig.setPointConfiguration();
|
||||
auto Sollwert_Feuchte_Config = FeuchteConfig.setPointConfiguration();
|
||||
SV_Sollwert_Temperatur_ = deviceState.getVariableByKey(Sollwert_Temp_Config->name());
|
||||
SV_Sollwert_Feuchte_ = deviceState.getVariableByKey(Sollwert_Feuchte_Config->name());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// std::vector<appengine::asio::SignalConnectionPtr> subscriptions_{};
|
||||
// std::shared_ptr<appengine::state::StateVariable> Heizung_Bef_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> MV_Kuehlung_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Abschlaemmen_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Entleerpumpe_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Heizung_Kesselrand;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Freigabe_Verfluessigerluefter;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Heizung_Innenraum;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Heizung_Tuer;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Uebertemperatur;
|
||||
// std::shared_ptr<appengine::state::StateVariable> MV_Entfeuchtung;
|
||||
// std::shared_ptr<appengine::state::StateVariable> MV_Druckluft;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Ansteuerung_Wassereinlass;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Wasserstand_oben_Config_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Wasserstand_oben_Config_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Ansteuerung_Verdichter;
|
||||
// std::shared_ptr<appengine::state::StateVariable> Luefter_Innenraum;
|
||||
// std::shared_ptr<appengine::state::StateVariable> heatingPower_Freq_;
|
||||
// std::vector<appengine::asio::SignalConnectionPtr> subscriptions_{};
|
||||
// std::shared_ptr<appengine::state::StateVariable> SV_Sollwert_Temperatur_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> SV_Temperatur_Variable_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> SV_Sollwert_Feuchte_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> SV_Feuchte_Variable_;
|
||||
// std::shared_ptr<appengine::state::StateVariable> SV_Tuer_Variable_;
|
||||
|
||||
// tempSetPointVariable_ = deviceState.getVariableByKey("Temperature_Setpoint");
|
||||
|
||||
// TODO: alle bool_inXX/real_inXX und bool_outXX/real_outXX/alarm_XX Variablen hier holen.
|
||||
// struct Inputs {
|
||||
// // Eingangswerte aus bool_inXX / real_inXX / reset_flag
|
||||
// bool reset_flag{};
|
||||
// bool Sammelalarm_quittiert{};
|
||||
// bool Tuer_offen{};
|
||||
// bool Sollwert_Feuchte_aktiv{};
|
||||
// bool Steuerkontakt_Standby{};
|
||||
// bool Steuerkontakt_Befeuchtung_aus{};
|
||||
// bool Steuerkontakt_Entfeuchtung_aus{};
|
||||
// bool Entleerbehaelter_Oben{};
|
||||
// bool Wasserkanister_leer{};
|
||||
// bool Entleerbehaelter_Unten{};
|
||||
// bool Sammelalarm{};
|
||||
|
||||
// double Istwert_Temperatur{};
|
||||
// double Sollwert_Temperatur{};
|
||||
// double Temperaturband{};
|
||||
// double Istwert_Ueberwachungsregler{};
|
||||
// double Klasse_Ueberwachungsregler{};
|
||||
// double Grenzwert_Untertemperatur{};
|
||||
// double Istwert_Feuchte{};
|
||||
// double Sollwert_Feuchte{};
|
||||
// double Feuchteband{};
|
||||
// double Sollwert_Luefter{};
|
||||
// double Istwert_Temperatur_Tuer{};
|
||||
// double Istwert_Temperatur_Verdampferausgang{};
|
||||
// double Temperatur_Feuchtemodul{};
|
||||
// double Bandalarm_nach{};
|
||||
// double Betauungsschutz{};
|
||||
// double real_in11{}; // du nutzt real_in11 später direkt in alarm_15
|
||||
// };
|
||||
|
||||
//Initialize PT1 Filter
|
||||
|
||||
FILTERED_TEMP.initialize(0.25,1);
|
||||
FILTER_TUER.initialize(0.25,1);
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void Controller::step() {
|
||||
#ifdef BUILD_TARGET_SOM
|
||||
ClimateAlgorithm::Inputs in{};
|
||||
in.Istwert_Temperatur = FILTERED_TEMP.step(SV_Temperatur_Variable_->toType<double>());
|
||||
in.Sollwert_Temperatur = SV_Sollwert_Temperatur_ ->toType<double>();
|
||||
in.Entleerbehaelter_Oben = Wasserstand_Oben_Config_->toType<bool>();
|
||||
in.Entleerbehaelter_Unten = Wasserstand_Unten_Config_->toType<bool>();
|
||||
in.Istwert_Feuchte = SV_Feuchte_Variable_->toType<double>();
|
||||
in.Sollwert_Feuchte = SV_Sollwert_Feuchte_->toType<double>();
|
||||
in.Istwert_Temperatur_Tuer = FILTER_TUER.step(SV_Tuer_Variable_->toType<double>());
|
||||
in.Betauungsschutz = 50.0;
|
||||
in.Grenzwert_Untertemperatur = -80.0;
|
||||
in.Feuchteband=10.0;
|
||||
in.Istwert_Temperatur_Verdampferausgang = SV_Verdampferausgang_->toType<double>();
|
||||
in.Sollwert_Feuchte = SV_Sollwert_Feuchte_->toType<double>();
|
||||
in.Istwert_Ueberwachungsregler=in.Istwert_Temperatur;
|
||||
in.Klasse_Ueberwachungsregler = 3.0;
|
||||
in.reset_flag =false;
|
||||
in.Sammelalarm = false;
|
||||
in.Sollwert_Feuchte_aktiv = true;
|
||||
in.Temperaturband = 5.0;
|
||||
in.Temperatur_Feuchtemodul = SV_Befeuchtungsmodul_->toType<double>();
|
||||
in.Wasserkanister_leer = false;
|
||||
in.Tuer_offen = false;
|
||||
|
||||
|
||||
// TODO: reset_flag und bool_inXX lesen:
|
||||
// in.reset_flag = deviceState.getVariableByKey("reset_flag")->toType<bool>();
|
||||
// in.Sammelalarm_quittiert = ... bool_in01
|
||||
// ...
|
||||
// in.Istwert_Temperatur = real_in01
|
||||
// ...
|
||||
|
||||
// Minimal-Beispiel (falls du erstmal nur Temperatur/Setpoint testest):
|
||||
//in.Istwert_Temperatur = tempVariable_ ? tempVariable_->toType<double>() : 0.0;
|
||||
//in.Sollwert_Temperatur = tempSetPointVariable_ ? tempSetPointVariable_->toType<double>() : 25.0;
|
||||
|
||||
auto out = algo_.step(in);
|
||||
|
||||
Heizung_Bef_Config_ -> setValue(out.bool_out17);
|
||||
MV_Kuehlung_Config_ ->setValue(out.bool_out18);
|
||||
Abschlaemmen_Config_->setValue(out.bool_out20);
|
||||
Entleerpumpe_Config_->setValue(out.bool_out16);
|
||||
Heizung_Kesselrand_Config_->setValue(out.bool_out12);
|
||||
Freigabe_Verfluessigerluefter_Config_->setValue(out.bool_out13);
|
||||
Heizung_Innenraum_Config_->setValue(out.bool_out09);
|
||||
Heizung_Tuer_Config_->setValue(out.bool_out11);
|
||||
Uebertemperatur_Config_->setValue(true);
|
||||
MV_Entfeuchtung_Config_->setValue(out.bool_out19);
|
||||
MV_Druckluft_Config_->setValue(false);
|
||||
|
||||
Ansteuerung_Wassereinlass_Config_->setValue(out.bool_out14);
|
||||
//Ansteuerung_Verdichter_Config_->setValue(out.real_out21*20.0);
|
||||
SV_Verdichter_on_->setValue(1);
|
||||
Ansteuerung_Verdichter_Config_->setValue(static_cast<int> (out.real_out21*10.0));
|
||||
Verdichter_Duty_Config->setValue(500);
|
||||
|
||||
SV_Stellgrad_Heizung->setValue(out.Stellgrad_Heizung);
|
||||
SV_Stellgrad_Kuehlung->setValue(out.Stellgrad_Kuehlung);
|
||||
SV_Stellgrad_Befeuchtung ->setValue(out.Stellgrad_Befeuchtung);
|
||||
SV_Stellgrad_Entfeuchtung->setValue(out.Stellgrad_Entfeuchtung);
|
||||
Startup_->setValue(out.Startup);
|
||||
CounterTuer_->setValue(out.Counter_Tuer);
|
||||
|
||||
// TODO: bool_outXX / real_outXX / alarm_XX setzen:
|
||||
// deviceState.getVariableByKey("bool_out01")->set(out.bool_out01);
|
||||
// deviceState.getVariableByKey("real_out09")->set(out.real_out09);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Controller::terminate() {
|
||||
#ifdef BUILD_TARGET_SOM
|
||||
subscriptions_.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef BUILD_TARGET_SOM
|
||||
ControllerBase *create() {
|
||||
|
||||
return new Controller;
|
||||
}
|
||||
#endif
|
||||
2530
app/Controller.hpp
Normal file
2530
app/Controller.hpp
Normal file
File diff suppressed because it is too large
Load Diff
1
app/climate-algorithm.cpp
Normal file
1
app/climate-algorithm.cpp
Normal file
@@ -0,0 +1 @@
|
||||
// todo: create, import file header
|
||||
22
app/climate-algorithm.h
Normal file
22
app/climate-algorithm.h
Normal file
@@ -0,0 +1,22 @@
|
||||
// todo: create, import file header
|
||||
|
||||
#ifndef CLIMATE_ALGORITHM_H
|
||||
#define CLIMATE_ALGORITHM_H
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
//todo - install
|
||||
// #include <nlohmann/json.hpp>
|
||||
|
||||
#include "filter.h"
|
||||
#include "pwm.hpp"
|
||||
#include "pid.h"
|
||||
|
||||
|
||||
class ClimateAlgorithm {
|
||||
public:
|
||||
private:
|
||||
|
||||
}
|
||||
|
||||
#endif // CLIMATE_ALGORITHM_H
|
||||
29
app/datamodel.cpp
Normal file
29
app/datamodel.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
|
||||
/*
|
||||
File: datamodel.cpp
|
||||
Description: This is a C++ source file containing implementation code for a data collection (called model) used for
|
||||
the realisation of a climate chamber control algorithm
|
||||
Rev: 0.1 - draft
|
||||
Created: 20.03.26
|
||||
Author: Uwe Jakobeit
|
||||
Copyright: Binder GmbH TUT
|
||||
Purpose: Configuration data and run-time datasets are provided for a controller simulation
|
||||
|
||||
Notes: [Any relevant details, such as dependencies, usage examples, or known issues.]
|
||||
*/
|
||||
|
||||
#include "datamodel.h"
|
||||
|
||||
DataModel::DataModel()
|
||||
{
|
||||
|
||||
// uj todo - set defaults, if JSON input fails
|
||||
// for now only hard-coded data
|
||||
Kennfeld_Ueberhitzung = Kennfeld_Ueberhitzung_Default;
|
||||
// In English:
|
||||
HeadlineOverheat = HeadlineOverheatDefault;
|
||||
|
||||
Kennfeld_Entfeuchtung = Kennfeld_Entfeuchtung_Default;
|
||||
|
||||
Kennfeld_Ueberhitzung = Kennfeld_Ueberhitzung_Default;
|
||||
}
|
||||
64
app/datamodel.h
Normal file
64
app/datamodel.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef DATAMODEL_H
|
||||
#define DATAMODEL_H
|
||||
|
||||
#include "dataset.h"
|
||||
|
||||
|
||||
#define HeadlineOverheat Kennfeld_Ueberhitzung
|
||||
#define HeadlineOverheatDefault Kennfeld_Ueberhitzung_Default
|
||||
|
||||
|
||||
class DataModel{
|
||||
public:
|
||||
DataModel();
|
||||
|
||||
private:
|
||||
QList<QList<double>> Kennfeld_Ueberhitzung;
|
||||
QList<QList<double>> Kennfeld_Entfeuchtung;
|
||||
QList<QList<double>> Kennfeld_Regler_Heizung_Xp;
|
||||
|
||||
QList<QList<double>> Kennfeld_Ueberhitzung_Default = {
|
||||
{-20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}, // 0: Temperatur
|
||||
{0.01, 0.02, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.0}, // 1: Skalierung Min
|
||||
{0.01, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.0, 1.0, 1.0}, // 1: Skalierung Max
|
||||
{-6.0, -8.0, -10.0, -8.0, -6.0, -8.0, -10.0, -12.0, -16.0, -20.0, -24.0, -28.0, -32.0} // 3: Sollwert Überhitzung
|
||||
};
|
||||
|
||||
QList<QList<double>> Kennfeld_Entfeuchtung_Default{
|
||||
{ -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0}, // 0: Temperatur
|
||||
{ 0.08, 0.08, 0.08, 0.10, 0.12, 0.14, 0.16, 0.18, 0.20, 0.22, 0.24, 0.26, 0.28}, // 1: Skalierung Entfeuchtung
|
||||
{ 120.0, 120.0, 120.0, 120.0, 120.0, 90.0, 60.0, 60.0, 60.0, 0.0, 0.0, 0.0, 0.0}, // 2: Abtauzyklus Pause
|
||||
{ 60.0, 60.0, 60.0, 30.0, 20.0, 10.0, 8.0, 4.0, 2.0, 0.0, 0.0, 0.0, 0.0} // 3: Abtauzyklus Dauer
|
||||
};
|
||||
|
||||
QList<double> Kennfeld_Regler_Heizung_Xp_Default{
|
||||
0.2, 0.5, 0.8, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
QList<double> Kennfeld_Regler_Kuehlung_Xp{
|
||||
0.1, 0.1, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.0};
|
||||
|
||||
QList<QList<double>> Kennfeld_Regler_Befeuchtung_Xp{
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02},
|
||||
{1.00, 0.54, 0.31, 0.18, 0.11, 0.07, 0.05, 0.03, 0.02}};
|
||||
|
||||
QList<QList<double>> Kennfeld_Regler_Entfeuchtung_Xp{
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20},
|
||||
{1.00, 0.80, 0.60, 0.50, 0.40, 0.35, 0.30, 0.25, 0.20}};
|
||||
};
|
||||
|
||||
|
||||
#endif // DATAMODEL_H
|
||||
60
app/dataset.cpp
Normal file
60
app/dataset.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
File: dataset.cpp
|
||||
Description: This is a C++ source file containing implementation code handling configuration data
|
||||
Rev: 0.1
|
||||
Created: 20.03.2026
|
||||
Author: Uwe Jakobeit
|
||||
Copyright: Binder GmbH, TUT 2026
|
||||
Purpose: [Briefly describe the file's functionality, e.g., "Implements a class for managing user data."]
|
||||
Implementation of classes which provide changes of dataset without (re-)comiling
|
||||
Notes: [Any relevant details, such as dependencies, usage examples, or known issues.]
|
||||
*/
|
||||
|
||||
|
||||
#include "dataset.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Read config file and setup headlines ( characteristics )
|
||||
Dataset::Dataset(QString& configFile)
|
||||
{
|
||||
// headline << &mHeadLineTemperature
|
||||
// << &mHeadLineHumidity
|
||||
// << &mHeadLineOverheat;
|
||||
|
||||
|
||||
// Now you can create a QVector of pointers to QVectorBase
|
||||
QVector<QVectorBase*> mixedVectors;
|
||||
|
||||
// QVector<QVectorBase*> mHeadlineVector;
|
||||
|
||||
|
||||
|
||||
|
||||
// Usage
|
||||
QVector<int> intVec = {1, 2, 3};
|
||||
QVector<double> dblVec = {1.0, 2, 3};
|
||||
|
||||
QVector<QString> stringVec = {"hello", "world"};
|
||||
|
||||
mixedVectors.append(new QVectorWrapper<int>(intVec));
|
||||
mixedVectors.append(new QVectorWrapper<QString>(stringVec));
|
||||
|
||||
mHeadlineVector.append(new QVectorWrapper<int>(intVec));
|
||||
mHeadlineVector.append(new QVectorWrapper<QString>(stringVec));
|
||||
|
||||
// Iterate and use polymorphic behavior
|
||||
for (QVectorBase* vec : mixedVectors) {
|
||||
vec->print();
|
||||
}
|
||||
// // Clean up
|
||||
// qDeleteAll(mixedVectors);
|
||||
// mixedVectors.clear();
|
||||
}
|
||||
|
||||
QVectorBase* Dataset::HeadLine(uint8_t LineId)
|
||||
{
|
||||
|
||||
return mHeadlineVector.at(LineId);
|
||||
}
|
||||
69
app/dataset.h
Normal file
69
app/dataset.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// #include <memory>
|
||||
// #include <vector>
|
||||
// #include <string>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace std;
|
||||
enum class LineId {
|
||||
Temperature,
|
||||
Humidity,
|
||||
OverHeat
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
class Dataset{
|
||||
|
||||
public:
|
||||
Dataset(QString& configFile);
|
||||
|
||||
// return headlines (Kennlinien) of known types from ST code
|
||||
QVector* HeadLine(enum class LineId);
|
||||
private:
|
||||
|
||||
// Class members (m_, but don't like the '_' )
|
||||
vector<std::unique_ptr> headline;
|
||||
|
||||
vector mHeadLineTemperature;
|
||||
vector mHeadLineOverheat;
|
||||
vector mHeadLineHumidity;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#include <QVector>
|
||||
#include <QMetaType>
|
||||
|
||||
|
||||
|
||||
|
||||
// Forward declaration of a base class for polymorphic behavior
|
||||
class QVectorBase {
|
||||
public:
|
||||
virtual ~QVectorBase() = default;
|
||||
virtual void print() const = 0;
|
||||
};
|
||||
|
||||
// Template class to wrap a QVector<T> and inherit from QVectorBase
|
||||
template<typename T>
|
||||
class QVectorWrapper : public QVectorBase {
|
||||
public:
|
||||
QVector<T> vec;
|
||||
|
||||
QVectorWrapper() = default;
|
||||
explicit QVectorWrapper(const QVector<T>& v) : vec(v) {}
|
||||
|
||||
void print() const override {
|
||||
qDebug() << "Vector of" << sizeof(T) << "bytes:" << vec;
|
||||
}
|
||||
};
|
||||
|
||||
class Dataset{
|
||||
public:
|
||||
Dataset(QString& configFile);
|
||||
QVectorBase *HeadLine(uint8_t LineId);
|
||||
|
||||
private:
|
||||
QVector<QVectorBase*> mHeadlineVector;
|
||||
};
|
||||
20
app/filter.cpp
Normal file
20
app/filter.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "filter.h"
|
||||
|
||||
PT1Filter::PT1Filter(double tau, double dt) : output(0.0) {
|
||||
filterFactor = dt / (tau + dt);
|
||||
}
|
||||
|
||||
double PT1Filter::update(double input) {
|
||||
output += filterFactor * (input - output);
|
||||
return output;
|
||||
}
|
||||
|
||||
double PT1Filter::step(double input) {
|
||||
output += filterFactor * (input - output);
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
void PT1Filter::reset() {
|
||||
output = 0.0;
|
||||
}
|
||||
20
app/filter.h
Normal file
20
app/filter.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef FILTER_H
|
||||
#define FILTER_H
|
||||
|
||||
#pragma once
|
||||
|
||||
class PT1Filter {
|
||||
private:
|
||||
double output;
|
||||
double filterFactor;
|
||||
|
||||
public:
|
||||
PT1Filter(double tau, double dt);
|
||||
double update(double input);
|
||||
double step(double input);
|
||||
void reset();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // FILTER_H
|
||||
30
app/main.cpp
Normal file
30
app/main.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include "Controller.hpp"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QCoreApplication a(argc, argv);
|
||||
|
||||
// Set up code that uses the Qt event loop here.
|
||||
// Call QCoreApplication::quit() or QCoreApplication::exit() to quit the application.
|
||||
// A not very useful example would be including
|
||||
// #include <QTimer>
|
||||
// near the top of the file and calling
|
||||
// QTimer::singleShot(5000, &a, &QCoreApplication::quit);
|
||||
// which quits the application after 5 seconds.
|
||||
|
||||
// If you do not need a running Qt event loop, remove the call
|
||||
// to QCoreApplication::exec() or use the Non-Qt Plain C++ Application template.
|
||||
|
||||
Controller bbr;
|
||||
|
||||
|
||||
qDebug() << "Perform one bbr setp";
|
||||
bbr.step();
|
||||
|
||||
return 0;
|
||||
|
||||
// return QCoreApplication::exec();
|
||||
}
|
||||
9
app/pid.cpp
Normal file
9
app/pid.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
// todo: create, import file header
|
||||
|
||||
#include "pid.h"
|
||||
|
||||
PID::PID()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
12
app/pid.h
Normal file
12
app/pid.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef PWM_H
|
||||
#define PWM_H
|
||||
|
||||
class PID{
|
||||
public:
|
||||
PID();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif //PWM_H
|
||||
18
app/pwm.cpp
Normal file
18
app/pwm.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
// todo: create, import file header
|
||||
|
||||
#include "pwm.h"
|
||||
|
||||
PWM::PWM(double cycleTime_Min,double cycleTime_Max)
|
||||
{
|
||||
m_cycle = 0.0;
|
||||
m_out = 0.0;
|
||||
m_cycleTime = 0.0;
|
||||
m_cycleTime_Min = cycleTime_Min;
|
||||
m_cycleTime_Max = cycleTime_Max;
|
||||
}
|
||||
|
||||
bool PWM::step(double setValue,double samplingTime)
|
||||
{
|
||||
bool output_bool;
|
||||
return output_bool;
|
||||
}
|
||||
20
app/pwm.h
Normal file
20
app/pwm.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef PWM_H
|
||||
#define PWM_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
class PWM
|
||||
{
|
||||
public:
|
||||
PWM(double cycleTime_Min,double cycleTime_Max);
|
||||
|
||||
bool step(double setValue,double samplingTime);
|
||||
|
||||
private:
|
||||
double m_cycle = 0.0;
|
||||
double m_out = 0.0;
|
||||
double m_cycleTime = 0.0;
|
||||
double m_cycleTime_Min = 0.0;
|
||||
double m_cycleTime_Max = 0.0;
|
||||
};
|
||||
#endif // PWM_H
|
||||
19
app/text-templates.h
Normal file
19
app/text-templates.h
Normal file
@@ -0,0 +1,19 @@
|
||||
// CPP Source file header ( as well h-file header, so far (20.03.26)
|
||||
|
||||
/*
|
||||
File: filename.cpp
|
||||
Description: This is a C++ source file containing implementation code for a program or library component.
|
||||
Rev: 0.1
|
||||
Created: [Date]
|
||||
Author: [Your Name]
|
||||
Copyright: [Your Organization or Name] [Year(s)]
|
||||
Purpose: [Briefly describe the file's functionality, e.g., "Implements a class for managing user data."]
|
||||
Notes: [Any relevant details, such as dependencies, usage examples, or known issues.]
|
||||
*/
|
||||
|
||||
|
||||
// CPP Source function header
|
||||
// todo
|
||||
|
||||
// Header file function header
|
||||
// todo
|
||||
Reference in New Issue
Block a user