mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-10 05:26:52 +03:00
rewrite of ZeigerEvalAnalogToDigitNeu added explizit test-cases for it.
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#include <unity.h>
|
||||
#include <ClassFlowCNNGeneral.h>
|
||||
|
||||
class UnderTestCNNGeneral : public ClassFlowCNNGeneral {
|
||||
public:
|
||||
UnderTestCNNGeneral( ClassFlowAlignment *_flowalign, t_CNNType _cnntype) :
|
||||
ClassFlowCNNGeneral(_flowalign, _cnntype) {};
|
||||
|
||||
using ClassFlowCNNGeneral::ZeigerEvalAnalogToDigitNeu;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* Transition = x.8 - x.2 hier keine Transition in den Testfaellen
|
||||
* Versatz = dig=x.n, ana= n.y: kein Versatz, da beide "n" gleich
|
||||
*/
|
||||
void test_analogToDigit_Standard() {
|
||||
|
||||
UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100);
|
||||
|
||||
// 4.8 ist eine "hängende" 5. Heißt sie ist nicht bis auf 5.0 umgesprungen.
|
||||
// ab Transition sollte trotzdem ein "hängendes Digit" gerundet werden.
|
||||
// Transition = ja
|
||||
// Versatz = nein
|
||||
TEST_ASSERT_EQUAL_INT(5, undertest->ZeigerEvalAnalogToDigitNeu(4.8, 8.0, 8, 9.2));
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issue-1344032217
|
||||
// Standard: dig=9.6, ana=6.8 => erg=9
|
||||
// Transition = nein
|
||||
// Versatz = nein
|
||||
TEST_ASSERT_EQUAL_INT(9, undertest->ZeigerEvalAnalogToDigitNeu( 9.6, 6.8, 6, 9.2));
|
||||
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1220365920
|
||||
// Standard: dig=4.6, ana=6.2 => erg=4
|
||||
// Transition = nein
|
||||
// Versatz = nein
|
||||
TEST_ASSERT_EQUAL_INT(4, undertest->ZeigerEvalAnalogToDigitNeu( 4.6, 6.2, 6, 9.2));
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
|
||||
// Hängendes digit ()
|
||||
// Standard: dig=6.8, ana=8.6 => erg=7
|
||||
// Transition = nein
|
||||
// Versatz = nein
|
||||
TEST_ASSERT_EQUAL_INT(7, undertest->ZeigerEvalAnalogToDigitNeu( 6.8, 8.6, 6, 9.2));
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
|
||||
// Ebenfalls Hängendes digit () bei kleinem Zeiger nach 0-Durchlauf
|
||||
// Standard: dig=6.8, ana=1.0 => erg=7
|
||||
// Transition = nein
|
||||
// Versatz = nein
|
||||
TEST_ASSERT_EQUAL_INT(7, undertest->ZeigerEvalAnalogToDigitNeu( 6.8, 8.6, 6, 9.2));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void test_analogToDigit_Transition() {
|
||||
UnderTestCNNGeneral* undertest = new UnderTestCNNGeneral(nullptr, Digital100);
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/921#issuecomment-1222672175
|
||||
// Standard: dig=3.9, ana=9.7 => erg=3
|
||||
// Transition = ja
|
||||
// Nulldurchgang = nein
|
||||
// Versatz = nein
|
||||
TEST_ASSERT_EQUAL_INT(3, undertest->ZeigerEvalAnalogToDigitNeu( 3.9, 9.7, 9, 9.2));
|
||||
|
||||
// ohne Referenz
|
||||
// Standard: dig=4.0, ana=9.1 => erg=4
|
||||
// Transition = ja
|
||||
// Nulldurchgang = nein
|
||||
// Versatz = nein
|
||||
// Besonderheit: Digit ist bei analog 9.1 noch nicht losgelaufen
|
||||
TEST_ASSERT_EQUAL_INT(4, undertest->ZeigerEvalAnalogToDigitNeu( 4.0, 9.1, 9, 9.2));
|
||||
|
||||
// ohne Referenz
|
||||
// Standard: dig=9.8, ana=0.1, ana_2=9.9 => erg=9
|
||||
// Transition = ja
|
||||
// Nulldurchgang = nein
|
||||
// Versatz = nein
|
||||
// Besonderheit: analog wird durch vorherigen analog wieder auf 9 gesetzt
|
||||
TEST_ASSERT_EQUAL_INT(9, undertest->ZeigerEvalAnalogToDigitNeu( 9.8, 0.1, 9, 9.2));
|
||||
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_flow.h"
|
||||
#include "test_flow_postrocess_helper.h"
|
||||
|
||||
|
||||
UnderTestPost* setUpClassFlowPostprocessing(t_CNNType digType, t_CNNType anaType)
|
||||
@@ -42,7 +42,9 @@ std::string process_doFlow(std::vector<float> analog, std::vector<float> digits,
|
||||
// run test
|
||||
TEST_ASSERT_TRUE(_undertestPost->doFlow(time));
|
||||
|
||||
return _undertestPost->getReadout(0);
|
||||
std::string result = _undertestPost->getReadout(0);
|
||||
delete _undertestPost;
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "test_flow.h"
|
||||
#include "test_flow_postrocess_helper.h"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#include "test_flow.h"
|
||||
#include "test_flow_postrocess_helper.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ACHTUNG! Die Test laufen aktuell nur mit ausgeschaltetem Debug in ClassFlowCNNGeneral
|
||||
*
|
||||
*
|
||||
* @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
|
||||
@@ -29,7 +32,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#issue-1344032217
|
||||
*
|
||||
* Das Ergebnis sollte "376529.6" sein.
|
||||
*/
|
||||
@@ -40,7 +43,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-1220365920
|
||||
*
|
||||
* Das Ergebnis sollte "167734.6" sein. Bzw. 16.98 ohne Extended true
|
||||
*/
|
||||
@@ -81,13 +84,13 @@ void test_doFlow() {
|
||||
|
||||
digits = { 1.1, 9.0, 4.0};
|
||||
analogs = { 8.1, 2.6, 6.25, 9.7};
|
||||
expected = "193.8259";
|
||||
expected = "194.8259";
|
||||
result = process_doFlow(analogs, digits);
|
||||
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
||||
|
||||
digits = { 1.1, 9.0, 4.0};
|
||||
analogs = { 9.1, 2.6, 6.25, 9.7};
|
||||
expected = "193.9259";
|
||||
expected = "194.9259";
|
||||
result = process_doFlow(analogs, digits);
|
||||
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
||||
|
||||
@@ -346,10 +349,10 @@ void test_doFlow() {
|
||||
|
||||
// Fehler bei V12.0.1
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issue-1391153343
|
||||
digits = { 1.0, 4.0, 2.0}; // 142.9269 als falsches Ergebnis
|
||||
digits = { 1.0, 4.0, 2.0}; // 141.9269 als falsches Ergebnis
|
||||
analogs = { 9.2, 2.5, 6.8, 9.0};
|
||||
expected = "141.9269";
|
||||
expected_extended= "141.92690";
|
||||
expected = "142.9269";
|
||||
expected_extended= "142.92690";
|
||||
|
||||
// extendResolution=false
|
||||
result = process_doFlow(analogs, digits, Digital100, false, false, 0);
|
||||
@@ -364,8 +367,11 @@ void test_doFlow() {
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1262626388
|
||||
digits = { 1.2, 6.8, 0.0, 0.0, 5.0, 2.8}; //170.05387 als falsches Ergebnis
|
||||
analogs = { 8.7};
|
||||
expected = "170.0528";
|
||||
expected_extended= "170.05287";
|
||||
// Aktuell nicht sicher, ob doch
|
||||
expected = "170.0538";
|
||||
expected_extended= "170.05387";
|
||||
//expected = "170.0528";
|
||||
//expected_extended= "170.05287";
|
||||
|
||||
// extendResolution=false
|
||||
result = process_doFlow(analogs, digits, Digital100, false, false, -3);
|
||||
@@ -378,10 +384,10 @@ void test_doFlow() {
|
||||
|
||||
// Fehler bei rolling post V12.0.1
|
||||
// lokal watermeter1
|
||||
digits = { 0.0, 0.0, 9.0, 1.0}; //91.88174 als falsches Ergebnis
|
||||
digits = { 0.0, 0.0, 9.0, 1.0}; //90.88174 als falsches Ergebnis
|
||||
analogs = {9.0, 8.0, 1.8, 7.4};
|
||||
expected = "90.8817";
|
||||
expected_extended= "90.88174";
|
||||
expected = "91.8817";
|
||||
expected_extended= "91.88174";
|
||||
|
||||
// extendResolution=false
|
||||
result = process_doFlow(analogs, digits, Digital100, false, false, 0);
|
||||
@@ -426,9 +432,8 @@ void test_doFlow() {
|
||||
// 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";
|
||||
expected = "577.8649";
|
||||
expected_extended= "577.86490";
|
||||
|
||||
// extendResolution=false
|
||||
result = process_doFlow(analogs, digits, Digital100, false, false, 0);
|
||||
@@ -440,19 +445,18 @@ void test_doFlow() {
|
||||
|
||||
|
||||
// Fehler V12.0.1 "TODO 00211.03480 vs 00211.03580"
|
||||
// Lokal
|
||||
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";
|
||||
// Lokal "Hängendes Digit"
|
||||
digits = { 2.0, 1.0, 1.0, 0.0, 3.0, 4.8}; // 00211.03480 als falsches Ergebnis
|
||||
analogs = {8.0};
|
||||
expected = "211.0358";
|
||||
expected_extended= "211.03580";
|
||||
|
||||
// extendResolution=false
|
||||
result = process_doFlow(analogs, digits, Digital100, false, false, 0);
|
||||
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, 0);
|
||||
result = process_doFlow(analogs, digits, Digital100, false, true, -3);
|
||||
TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user