diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index 703e621f..661ce729 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -234,18 +234,19 @@ int ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu(float zahl, float ziffer_vor // Beispiel dig=6.8, ana=2.2 ==> dig=7 // dig=4.8, ana=5.5 => dig=4 - // Aber zwischen ziffer_vorgaenger 3..8 keine Veränderung - if (ergebnis_nachkomma >= 1 || (ziffer_vorgaenger>3 && ziffer_vorgaenger<8) ) { - + // Vorlauf bei ergebnis_nachkomma >=0..1 und ziffer_vorgaenger 8..9 + if (ergebnis_nachkomma <= 1 && ziffer_vorgaenger>=8) { + result = (ergebnis_vorkomma - 1 + 10) % 10; + } else { // Ziffer bleibt bei x.8 oder x.9 "hängen", kommt also nicht richtig auf x.0 // muss eine Rundung erfolgen - if (eval_vorgaenger<8 && ergebnis_nachkomma >= 7) + // jedoch nicht im während der Transition (ziffer_vorgaenger>=8) + if (eval_vorgaenger<9 && ziffer_vorgaenger<8 && ergebnis_nachkomma >= 8) result = ((int) round(zahl) + 10) % 10; else result = ergebnis_vorkomma; - } else - result = (ergebnis_vorkomma - 1 + 10) % 10; - + } + if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu - 9.0 --> noch kein Nulldurchgang = " + std::to_string(result) + " zahl: " + std::to_string(zahl) + " ziffer_vorgaenger = " + std::to_string(ziffer_vorgaenger) + " DigitalUnschaerfe = " + std::to_string(DigitalUnschaerfe)); return result; diff --git a/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp b/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp index 10f479e2..196460ee 100644 --- a/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp +++ b/code/test/components/jomjol-flowcontroll/test_flowpostprocessing.cpp @@ -82,7 +82,7 @@ void test_doFlow() { TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); /* - * https://github.com/jomjol/AI-on-the-edge-device/issues/921 + * https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1222672175 * * Das Ergebnis sollte "376529.6" sein. Bzw. 16.98 ohne Extended true */ @@ -427,6 +427,37 @@ void test_doFlow() { result = process_doFlow(analogs, digits, Digital100, false, true, 0); TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); + // Fehler V12.0.1 + // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issue-1400807695 + digits = { 7.0, 4.0, 7.0, 2.0, 7.0, 5.4, 9.4}; // 7472.749 als falsches Ergebnis + analogs = {}; + expected = "7472.759"; + expected_extended= "7472.7594"; + + // extendResolution=false + result = process_doFlow(analogs, digits, Digital100, false, false, -3); + TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); + + // checkConsistency=false und extendResolution=true + result = process_doFlow(analogs, digits, Digital100, false, true, -3); + TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); + + // Fehler V12.0.1 + // https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805 + digits = { 4.9, 6.9, 6.8}; // 576.8649 als falsches Ergebnis + analogs = {8.6, 6.2, 5.0, 9.0}; + // fall unklar ob wirklich 577 oder 576, erst mal 577 + expected = "576.8649"; + expected_extended= "576.86490"; + + // extendResolution=false + result = process_doFlow(analogs, digits, Digital100, false, false, 0); + TEST_ASSERT_EQUAL_STRING(expected, result.c_str()); + + // checkConsistency=false und extendResolution=true + result = process_doFlow(analogs, digits, Digital100, false, true, 0); + TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str()); + }