last analog result_float as Readout parameter, testcases for #921, #919

This commit is contained in:
Frank Haverland
2022-08-22 16:10:07 +02:00
parent 59aeeda786
commit 974044adf0
3 changed files with 100 additions and 47 deletions

View File

@@ -238,8 +238,9 @@ void ClassFlowPostProcessing::SavePreValue()
_zw = NUMBERS[j]->name + "\t" + NUMBERS[j]->timeStamp + "\t" + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + "\n"; _zw = NUMBERS[j]->name + "\t" + NUMBERS[j]->timeStamp + "\t" + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + "\n";
printf("Write PreValue Zeile: %s\n", _zw.c_str()); printf("Write PreValue Zeile: %s\n", _zw.c_str());
if (pFile) {
fputs(_zw.c_str(), pFile); fputs(_zw.c_str(), pFile);
}
} }
UpdatePreValueINI = false; UpdatePreValueINI = false;
@@ -568,8 +569,10 @@ void ClassFlowPostProcessing::InitNUMBERS()
NUMBERS.push_back(_number); NUMBERS.push_back(_number);
} }
for (int i = 0; i < NUMBERS.size(); ++i) for (int i = 0; i < NUMBERS.size(); ++i) {
printf("Number %s, Anz DIG: %d, Anz ANA %d\n", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog); printf("Number %s, Anz DIG: %d, Anz ANA %d\n", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog);
}
} }
string ClassFlowPostProcessing::ShiftDecimal(string in, int _decShift){ string ClassFlowPostProcessing::ShiftDecimal(string in, int _decShift){
@@ -667,7 +670,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
if (NUMBERS[j]->digit_roi) if (NUMBERS[j]->digit_roi)
{ {
if (NUMBERS[j]->analog_roi) if (NUMBERS[j]->analog_roi)
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, previous_value) + NUMBERS[j]->ReturnRawValue; NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float) + NUMBERS[j]->ReturnRawValue;
else else
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution nur falls es keine analogen Ziffern gibt NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution nur falls es keine analogen Ziffern gibt
} }

View File

@@ -83,7 +83,7 @@ void test_ZeigerEvalHybrid() {
// pre = 9.9 (0.0 raw) // pre = 9.9 (0.0 raw)
// zahl = 1.8 // zahl = 1.8
TEST_ASSERT_EQUAL(1, undertest.ZeigerEvalHybrid(1.8, 9.0, 9)); TEST_ASSERT_EQUAL(2, undertest.ZeigerEvalHybrid(1.8, 9.0, 9));
// if a digit have an early transition and the pointer is < 9.0 // if a digit have an early transition and the pointer is < 9.0
// prev (pointer) = 6.2, but on digital readout = 6.0 (prev is int parameter) // prev (pointer) = 6.2, but on digital readout = 6.0 (prev is int parameter)

View File

@@ -4,6 +4,8 @@
#include <ClassFlowCNNGeneral.h> #include <ClassFlowCNNGeneral.h>
#include <ClassFlowMakeImage.h> #include <ClassFlowMakeImage.h>
void setUpClassFlowPostprocessing(void);
string process_doFlow(std::vector<float> analog, std::vector<float> digits);
ClassFlowCNNGeneral* _analog; ClassFlowCNNGeneral* _analog;
ClassFlowCNNGeneral* _digit; ClassFlowCNNGeneral* _digit;
@@ -21,6 +23,67 @@ class UnderTestPost : public ClassFlowPostProcessing {
UnderTestPost* undertestPost; UnderTestPost* undertestPost;
/**
* @brief Testet die doFlow-Methode von ClassFlowPostprocessing
* digits[] - enthält die liste der vom Model zurückgegebenen Ergebnisse (class100/cont) in der Reihenfolge von links nach rechts
* analog[] - enthält die Liste der Zeiger vom Model, wie bei den digits
* expected - enthält das erwartete Ergebnis, wobei der Dezimalpunkt genau zwischen digits und analog ist.
*
*/
void test_doFlow() {
/*
*
* digit1 = 1.2
* digit2 = 6.7
* analog1 = 9.5
* analog2 = 8.4
*
* Das Ergebnis sollte "16.984" sein. Bzw. 16.98 ohne Extended true
*/
std::vector<float> digits = { 1.2, 6.7};
std::vector<float> analogs = { 9.5, 8.4};
const char* expected = "16.98";
std::string result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
/*
* https://github.com/jomjol/AI-on-the-edge-device/issues/921
*
* Das Ergebnis sollte "376529.6" sein. Bzw. 16.98 ohne Extended true
*/
digits = { 3.0, 7.0, 6.0, 5.0, 2.5, 9.6};
analogs = { 6.4};
expected = "376529.6";
result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
/*
* https://github.com/jomjol/AI-on-the-edge-device/issues/921
*
* Das Ergebnis sollte "167734.6" sein. Bzw. 16.98 ohne Extended true
*/
digits = { 1.1, 6.0, 7.0, 7.0, 3.0, 4.6};
analogs = { 6.2};
expected = "167734.6";
result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
/*
* https://github.com/jomjol/AI-on-the-edge-device/issues/919
*
* Das Ergebnis sollte "58.96889" sein. Bzw. 16.98 ohne Extended true
*/
digits = { 5.0, 8.6};
analogs = { 9.8, 6.7, 8.9, 8.6, 9.8};
expected = "58.96889";
result = process_doFlow(analogs, digits);
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
}
void setUpClassFlowPostprocessing(void) void setUpClassFlowPostprocessing(void)
{ {
@@ -38,61 +101,48 @@ void setUpClassFlowPostprocessing(void)
} }
/** std::string process_doFlow(std::vector<float> analog, std::vector<float> digits) {
* @brief getestet wird das Ergebnis von
* digit1 = 1.2
* digit2 = 6.7
* analog1 = 9.5
* analog2 = 8.4
*
* Das Ergebnis sollte "16.984" sein.
*/
void test_doFlow() {
// setup the classundertest // setup the classundertest
setUpClassFlowPostprocessing(); setUpClassFlowPostprocessing();
printf("SetupClassFlowPostprocessing completed.\n"); printf("SetupClassFlowPostprocessing completed.\n");
general* gen_digit = _digit->GetGENERAL("default", true); // digits
// digit1 if (digits.size()>0) {
roi* digit1 = new roi(); general* gen_digit = _digit->GetGENERAL("default", true);
digit1->name = "digit1"; gen_digit->ROI.clear();
digit1->result_float = 1.2;
gen_digit->ROI.push_back(digit1); for (int i = 0; i<digits.size(); i++) {
// digit2 roi* digitROI = new roi();
roi* digit2 = new roi(); string name = "digit_" + std::to_string(i);
digit2->name = "digit2"; digitROI->name = name;
digit2->result_float = 6.7; digitROI->result_float = digits[i];
gen_digit->ROI.push_back(digit2); gen_digit->ROI.push_back(digitROI);
}
general* gen_analog = _analog->GetGENERAL("default", true); }
// analog1
roi* analog1 = new roi(); // analog
analog1->name = "analog1"; if (analog.size()>0) {
analog1->result_float = 9.5; general* gen_analog = _analog->GetGENERAL("default", true);
gen_analog->ROI.push_back(analog1); gen_analog->ROI.clear();
// analog2 for (int i = 0; i<analog.size(); i++) {
roi* analog2 = new roi(); roi* anaROI = new roi();
analog2->name = "analog2"; string name = "ana_" + std::to_string(i);
analog2->result_float = 8.4; anaROI->name = name;
gen_analog->ROI.push_back(analog2); anaROI->result_float = analog[i];
gen_analog->ROI.push_back(anaROI);
}
}
printf("Setup ROIs completed.\n"); printf("Setup ROIs completed.\n");
undertestPost->InitNUMBERS(); undertestPost->InitNUMBERS();
string time; string time;
// run test // run test
TEST_ASSERT_TRUE(undertestPost->doFlow(time)); TEST_ASSERT_TRUE(undertestPost->doFlow(time));
printf("DoFlow completed.\n"); return undertestPost->getReadout(0);
TEST_ASSERT_EQUAL_STRING("0000", undertestPost->getReadout(0).c_str());
} }