Files
AI-on-the-edge-device/code/test/components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp
CaCO3 304b9e0c32 Merge branch 'rolling' (#1559)
* Fix for securing wlan.ini (#1509)

* Fix for securing wlan.ini

* Fixing error with ' instead of "

* Changing to errorcode 403

* maybe strcmp instead of regular ==

Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se>

* Update Web-Installer

* solves #1530 (#1531)

* Refactor JSON (#1518)

* use correct log level

* corrected logging

* typo

* refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre"

* Wrapped 'rate' into double quotes, like all other JSON values

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Various corrections (#1519)

* use correct log level

* corrected logging

* typo

* add release to webinstaller

* changed logs, added INFO log of raw, value, error

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Prevent auto restart on cam framebuffer init error (#1522)

* use correct log level

* revert autorestart on camera framebuffer init error

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* #1524 - ensure the recognized digit is less than 10 (#1525)

* fix kernel panic (vector out of range) in getReadoutRawString

* fix key of caches

* fix key of caches

* fix key caches

* fix cache keys

* fix cache keys

* move set variables to top

* debug

* fix key

* testing

* try fix changelog

* test

* Update Changelog.md for  release

* Revert "Update Changelog.md for  release"

This reverts commit 4f51ec7962.

* remove testing

* fix release creation

* testing

* Update Changelog.md for  release

* test

* Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device"

This reverts commit f68695a4c0, reversing
changes made to a096cf7182.

* Revert "test"

This reverts commit a096cf7182.

* revert testing

* #1524 - ensure the result of ZeigerEvalHybridNeu is <10

* Fix late digit transition #1503

Co-authored-by: github-actions <github-actions@github.com>

* fix frozen time in datafile on error (#1534)

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* log NTP server name (#1497)

* log NTP server name

* .

* .

* replace calls to /wasserzaehler.html with calls to /value (#1469)

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Fix cookie usage, use correct http response codes, add 404 page (#1495)

* replaced some HTTP response code with better matching codes

* add custom 404 page, add log entry for debugging

* fix cookie

* replace non-necessary whitespace

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Don't autofail if NTP server can't be reached during initalization (#1498)

This fixes an issue with a restricted network without internet access,
where the hardcoded ntp server can't be reached and thus the esp resets,
as it's not able to finish initalization.

* Update Changelog.md

* Update Changelog.md for  release

* Fix for securing wlan.ini (#1509)

* Fix for securing wlan.ini

* Fixing error with ' instead of "

* Changing to errorcode 403

* maybe strcmp instead of regular ==

Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se>

* Update Web-Installer

* solves #1530 (#1531)

* Refactor JSON (#1518)

* use correct log level

* corrected logging

* typo

* refactored JSON generagion: removed unused parameters, consolidated into singel function, added "pre"

* Wrapped 'rate' into double quotes, like all other JSON values

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Various corrections (#1519)

* use correct log level

* corrected logging

* typo

* add release to webinstaller

* changed logs, added INFO log of raw, value, error

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* Prevent auto restart on cam framebuffer init error (#1522)

* use correct log level

* revert autorestart on camera framebuffer init error

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* #1524 - ensure the recognized digit is less than 10 (#1525)

* fix kernel panic (vector out of range) in getReadoutRawString

* fix key of caches

* fix key of caches

* fix key caches

* fix cache keys

* fix cache keys

* move set variables to top

* debug

* fix key

* testing

* try fix changelog

* test

* Update Changelog.md for  release

* Revert "Update Changelog.md for  release"

This reverts commit 4f51ec7962.

* remove testing

* fix release creation

* testing

* Update Changelog.md for  release

* test

* Revert "Merge branch 'master' of https://github.com/haverland/AI-on-the-edge-device"

This reverts commit f68695a4c0, reversing
changes made to a096cf7182.

* Revert "test"

This reverts commit a096cf7182.

* revert testing

* #1524 - ensure the result of ZeigerEvalHybridNeu is <10

* Fix late digit transition #1503

Co-authored-by: github-actions <github-actions@github.com>

* only use sntp_getservername() after init sntp

* set default NTP server on dnew installations

Co-authored-by: CaCO3 <caco@ruinelli.ch>
Co-authored-by: Ralf Rachinger <git@ralfrachinger.de>
Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: parhedberg <par.hedberg@gmail.com>
Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se>
Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com>
Co-authored-by: Frank Haverland <fspapaping@googlemail.com>

* Renamed variables and added debug log (#1537)

* add debug logs

* renamed variables

* renamed TAGs, added flow status logging

* .

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>

* replaced printf usage in LogFile.WriteToFile()

* ENABLE_MQTT c++ macro definition (#1546)

* macro

* 2

* 2

* delete jomjol_mqtt from CMakeLists

* mqtt macro

* final

* ENABLE_INFLUXDB c++ macro definition (#1547)

* macro

* 2

* 2

* delete jomjol_mqtt from CMakeLists

* mqtt macro

* final

* ENABLE_INFLUXDB c++ macro definition

* Update Changelog.md

Co-authored-by: parhedberg <par.hedberg@gmail.com>
Co-authored-by: Pär Hedberg <par.hedberg@nordicmedtest.se>
Co-authored-by: jomjol <30766535+jomjol@users.noreply.github.com>
Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com>
Co-authored-by: CaCO3 <caco@ruinelli.ch>
Co-authored-by: Frank Haverland <fspapaping@googlemail.com>
Co-authored-by: github-actions <github-actions@github.com>
Co-authored-by: Ralf Rachinger <git@ralfrachinger.de>
Co-authored-by: Nicolas Liaudat <nliaudat@users.noreply.github.com>
2022-12-11 23:34:38 +01:00

159 lines
5.4 KiB
C++

#include "test_flow_postrocess_helper.h"
#include "esp_log.h"
static const char *TAG = "POSTPROC TEST";
UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType)
{
ClassFlowCNNGeneral* _analog;
ClassFlowCNNGeneral* _digit;
std::vector<ClassFlow*> FlowControll;
ClassFlowMakeImage* flowmakeimage;
// wird im doFlow verwendet
flowmakeimage = new ClassFlowMakeImage(&FlowControll);
FlowControll.push_back(flowmakeimage);
// Die Modeltypen werden gesetzt, da keine Modelle verwendet werden.
_analog = new ClassFlowCNNGeneral(nullptr, anaType);
_digit = new ClassFlowCNNGeneral(nullptr, digType);
return new UnderTestPost(&FlowControll, _analog, _digit);
}
std::string process_doFlow(UnderTestPost* _underTestPost) {
string time;
// run test
TEST_ASSERT_TRUE(_underTestPost->doFlow(time));
return _underTestPost->getReadout(0);
}
std::string process_doFlow(std::vector<float> analog, std::vector<float> digits, t_CNNType digType,
bool checkConsistency, bool extendedResolution, int decimal_shift) {
// setup the classundertest
UnderTestPost* _undertestPost = init_do_flow(analog, digits, digType, checkConsistency, extendedResolution, decimal_shift);
ESP_LOGD(TAG, "SetupClassFlowPostprocessing completed.");
string time;
// run test
TEST_ASSERT_TRUE(_undertestPost->doFlow(time));
std::string result = _undertestPost->getReadout(0);
delete _undertestPost;
return result;
}
UnderTestPost* init_do_flow(std::vector<float> analog, std::vector<float> digits, t_CNNType digType,
bool checkConsistency, bool extendedResolution, int decimal_shift) {
UnderTestPost* _undertestPost = setUpClassFlowPostprocessing(digType, Analogue100);
// digits
if (digits.size()>0) {
general* gen_digit = _undertestPost->flowDigit->GetGENERAL("default", true);
gen_digit->ROI.clear();
for (int i = 0; i<digits.size(); i++) {
roi* digitROI = new roi();
string name = "digit_" + std::to_string(i);
digitROI->name = name;
digitROI->result_klasse = (int) digits[i];
digitROI->result_float = digits[i];
gen_digit->ROI.push_back(digitROI);
}
}
// analog
if (analog.size()>0) {
general* gen_analog = _undertestPost->flowAnalog->GetGENERAL("default", true);
gen_analog->ROI.clear();
for (int i = 0; i<analog.size(); i++) {
roi* anaROI = new roi();
string name = "ana_1" + std::to_string(i);
anaROI->name = name;
anaROI->result_float = analog[i];
gen_analog->ROI.push_back(anaROI);
}
} else {
_undertestPost->flowAnalog = NULL;
}
ESP_LOGD(TAG, "Setting up of ROIs completed.");
_undertestPost->InitNUMBERS();
setConsitencyCheck(_undertestPost, checkConsistency);
setExtendedResolution(_undertestPost, extendedResolution);
setDecimalShift(_undertestPost, decimal_shift);
return _undertestPost;
}
void setPreValue(UnderTestPost* _underTestPost, double _preValue) {
if (_preValue>0) {
ESP_LOGD(TAG, "preValue=%f", _preValue);
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
(*NUMBERS)[_n]->PreValue = _preValue;
}
}
}
void setAllowNegatives(UnderTestPost* _underTestPost, bool _allowNegatives) {
ESP_LOGD(TAG, "checkConsistency=true");
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
(*NUMBERS)[_n]->AllowNegativeRates = _allowNegatives;
}
}
void setConsitencyCheck(UnderTestPost* _underTestPost, bool _checkConsistency) {
if (_checkConsistency) {
ESP_LOGD(TAG, "checkConsistency=true");
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
(*NUMBERS)[_n]->checkDigitIncreaseConsistency = true;
}
}
}
void setExtendedResolution(UnderTestPost* _underTestPost, bool _extendedResolution) {
if (_extendedResolution ) {
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
(*NUMBERS)[_n]->isExtendedResolution = true;
}
}
}
void setDecimalShift(UnderTestPost* _underTestPost, int _decimal_shift) {
if (_decimal_shift!=0) {
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
ESP_LOGD(TAG, "Setting decimal shift on number: %d to %d", _n, _decimal_shift);
(*NUMBERS)[_n]->DecimalShift = _decimal_shift;
(*NUMBERS)[_n]->DecimalShiftInitial = _decimal_shift;
}
}
}
void setAnalogdigitTransistionStart(UnderTestPost* _underTestPost, float _analogdigitTransistionStart) {
if (_analogdigitTransistionStart!=0) {
std::vector<NumberPost*>* NUMBERS = _underTestPost->GetNumbers();
for (int _n = 0; _n < (*NUMBERS).size(); ++_n) {
ESP_LOGD(TAG, "Setting decimal shift on number: %d to %f", _n, _analogdigitTransistionStart);
(*NUMBERS)[_n]->AnalogDigitalTransitionStart = _analogdigitTransistionStart;
}
}
}