Revert "Fix for #712 "Incorrect rollover digital numbers""

This reverts commit 11bfaf0e91.
This commit is contained in:
Frank Haverland
2022-07-20 19:12:19 +02:00
parent a0ffc88e47
commit 3f3532defe
4 changed files with 3 additions and 73 deletions

View File

@@ -105,13 +105,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
{
if (GENERAL[_analog]->ROI[i]->result_float >= 0)
{
// Digital Modelle haben nur x.0 und benötigen eine andere Prüfung bei Nullübergang
if (CNNType != Digital){
prev = ZeigerEvalDigital(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
} else {
prev = ZeigerEvalHybrid(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
}
result = std::to_string(prev) + result;
}
@@ -175,46 +169,6 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
return result;
}
int ClassFlowCNNGeneral::ZeigerEvalDigital(float zahl, float zahl_vorgaenger, int eval_vorgaenger)
{
int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;
if (zahl_vorgaenger < 0) // keine Vorzahl vorhanden !!! --> Runde die Zahl
{
if ((ergebnis_nachkomma <= 2) || (ergebnis_nachkomma >= 8)) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht
return ((int) round(zahl) + 10) % 10;
else
return ((int) trunc(zahl) + 10) % 10;
}
if (zahl_vorgaenger > 9.2) // Ziffernwechsel beginnt
{
if (eval_vorgaenger == 0) // Wechsel hat schon stattgefunden
{
return ((int) round(zahl) + 10) % 10; // Annahme, dass die neue Zahl schon in der Nähe des Ziels ist
}
else
{
if (zahl_vorgaenger <= 9.5) // Wechsel startet gerade, aber beginnt erst
{
if ((ergebnis_nachkomma <= 2) || (ergebnis_nachkomma >= 8)) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht
return ((int) round(zahl) + 10) % 10;
else
return ((int) trunc(zahl) + 10) % 10;
}
else
{
return ((int) trunc(zahl) + 10) % 10; // Wechsel schon weiter fortgeschritten, d.h. über 2 als Nachkomma
}
}
}
if ((ergebnis_nachkomma <= 2) || (ergebnis_nachkomma >= 8)) // Band um die Ziffer --> Runden, da Ziffer im Rahmen Ungenauigkeit erreicht
return ((int) round(zahl) + 10) % 10;
return ((int) trunc(zahl) + 10) % 10;
}
int ClassFlowCNNGeneral::ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int eval_vorgaenger)
{
int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;

View File

@@ -36,7 +36,6 @@ protected:
int ZeigerEval(float zahl, int ziffer_vorgaenger);
int ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int eval_vorgaenger);
int ZeigerEvalDigital(float zahl, float zahl_vorgaenger, int eval_vorgaenger);
bool doNeuralNetwork(string time);

View File

@@ -5,7 +5,6 @@ class UnderTest : public ClassFlowCNNGeneral {
public:
using ClassFlowCNNGeneral::ZeigerEval;
using ClassFlowCNNGeneral::ZeigerEvalHybrid;
using ClassFlowCNNGeneral::ZeigerEvalDigital;
using ClassFlowCNNGeneral::ClassFlowCNNGeneral;
};
@@ -45,12 +44,6 @@ void test_ZeigerEval()
// the 4.5 (digital100) is not above 5 and the previous digit (analog) too (9.6)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEval(4.5, 0));
// the 5.5 (digital100) is not above 6 and the previous digit (analog) not over Zero (9.7)
TEST_ASSERT_EQUAL(5, undertest.ZeigerEval(5.5, 9));
// the 5.0 (digital100) and the previous digit (analog) not over Zero (9.5). The transition is not completed
TEST_ASSERT_EQUAL(4, undertest.ZeigerEval(5.0, 9));
}
/**
@@ -92,23 +85,8 @@ void test_ZeigerEvalHybrid() {
// the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.6)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybrid(4.5, 9.6, 9));
// the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5)
// the 4.4 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5)
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybrid(4.5, 9.5, 9));
//56.95797
// the 4.4 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5)
TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalHybrid(5.5, 9.7, 9));
// the 5.0 (digital100) and the previous digit (analog) not over Zero (9.5). The transition is not completed
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybrid(5.0, 9.7, 9));
}
void test_ZeigerEvalDigital() {
UnderTest undertest = UnderTest(nullptr, Digital);
// the 4.4 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5)
TEST_ASSERT_EQUAL(5, undertest.ZeigerEvalDigital(5.0, 9.7, 9));
}

View File

@@ -11,7 +11,6 @@ extern "C" void app_main()
RUN_TEST(test_ZeigerEval);
RUN_TEST(test_ZeigerEvalHybrid);
RUN_TEST(test_ZeigerEvalDigital);
UNITY_END();
}