From b78929745bec650b87baf1712c9c48d35b47e5b9 Mon Sep 17 00:00:00 2001 From: jomjol <30766535+jomjol@users.noreply.github.com> Date: Sun, 23 Oct 2022 16:12:34 +0200 Subject: [PATCH] Improve data logging --- .../ClassFlowCNNGeneral.cpp | 9 ++++-- .../ClassFlowPostProcessing.cpp | 3 ++ .../ClassFlowPostProcessing.h | 1 - code/components/jomjol_helper/Helper.cpp | 28 +++++++++++++++++++ code/components/jomjol_helper/Helper.h | 2 ++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index 82869a1c..e46078bb 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -980,17 +980,20 @@ string ClassFlowCNNGeneral::getReadoutRawString(int _analog) { if (CNNType == Analogue || CNNType == Analogue100) { - rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_float); + rt = rt + "\t" + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1); } if (CNNType == Digital) { - rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_klasse); + if (GENERAL[_analog]->ROI[i]->result_klasse == 10) + rt = rt + "\tN"; + else + rt = rt + "\t" + RundeOutput(GENERAL[_analog]->ROI[i]->result_klasse, 0); } if ((CNNType == DoubleHyprid10) || (CNNType == Digital100)) { - rt = rt + "\t" + std::to_string(GENERAL[_analog]->ROI[i]->result_float); + rt = rt + "\t" + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1); } } return rt; diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index 319ca661..afe21a16 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp @@ -927,6 +927,8 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror, i return NUMBERS[_number]->ReturnValue; } +/* Jetzt als globale Funktion in Helper.h + string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){ std::stringstream stream; int _zw = _in; @@ -949,6 +951,7 @@ string ClassFlowPostProcessing::RundeOutput(double _in, int _anzNachkomma){ return stream.str(); } +*/ string ClassFlowPostProcessing::ErsetzteN(string input, double _prevalue) diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index f707f170..3c53bb82 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h @@ -34,7 +34,6 @@ protected: string ErsetzteN(string, double _prevalue); float checkDigitConsistency(double input, int _decilamshift, bool _isanalog, double _preValue); - string RundeOutput(double _in, int _anzNachkomma); void InitNUMBERS(); void handleDecimalSeparator(string _decsep, string _value); diff --git a/code/components/jomjol_helper/Helper.cpp b/code/components/jomjol_helper/Helper.cpp index 69ef3e1d..130cf69c 100644 --- a/code/components/jomjol_helper/Helper.cpp +++ b/code/components/jomjol_helper/Helper.cpp @@ -7,6 +7,9 @@ #include #include +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -695,3 +698,28 @@ string SDCardParseManufacturerIDs(int id) return ret_val; } + +string RundeOutput(double _in, int _anzNachkomma) +{ + std::stringstream stream; + int _zw = _in; +// ESP_LOGD(TAG, "AnzNachkomma: %d", _anzNachkomma); + + if (_anzNachkomma < 0) { + _anzNachkomma = 0; + } + + if (_anzNachkomma > 0) + { + stream << std::fixed << std::setprecision(_anzNachkomma) << _in; + return stream.str(); + } + else + { + stream << _zw; + } + + + return stream.str(); +} + diff --git a/code/components/jomjol_helper/Helper.h b/code/components/jomjol_helper/Helper.h index 8d7c2cf0..9dcd333d 100644 --- a/code/components/jomjol_helper/Helper.h +++ b/code/components/jomjol_helper/Helper.h @@ -15,6 +15,8 @@ void RenameFile(string from, string to); void MakeDir(std::string _what); +string RundeOutput(double _in, int _anzNachkomma); + FILE* OpenFileAndWait(const char* nm, const char* _mode, int _waitsec = 1);