mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-08 12:36:52 +03:00
Revert "Fix for #712 "Incorrect rollover digital numbers""
This reverts commit 11bfaf0e91.
This commit is contained in:
@@ -105,13 +105,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
{
|
{
|
||||||
if (GENERAL[_analog]->ROI[i]->result_float >= 0)
|
if (GENERAL[_analog]->ROI[i]->result_float >= 0)
|
||||||
{
|
{
|
||||||
// Digital Modelle haben nur x.0 und benötigen eine andere Prüfung bei Nullübergang
|
prev = ZeigerEvalHybrid(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
|
||||||
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;
|
result = std::to_string(prev) + result;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -175,46 +169,6 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
|
|||||||
return result;
|
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 ClassFlowCNNGeneral::ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int eval_vorgaenger)
|
||||||
{
|
{
|
||||||
int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;
|
int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ protected:
|
|||||||
|
|
||||||
int ZeigerEval(float zahl, int ziffer_vorgaenger);
|
int ZeigerEval(float zahl, int ziffer_vorgaenger);
|
||||||
int ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int eval_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);
|
bool doNeuralNetwork(string time);
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ class UnderTest : public ClassFlowCNNGeneral {
|
|||||||
public:
|
public:
|
||||||
using ClassFlowCNNGeneral::ZeigerEval;
|
using ClassFlowCNNGeneral::ZeigerEval;
|
||||||
using ClassFlowCNNGeneral::ZeigerEvalHybrid;
|
using ClassFlowCNNGeneral::ZeigerEvalHybrid;
|
||||||
using ClassFlowCNNGeneral::ZeigerEvalDigital;
|
|
||||||
using ClassFlowCNNGeneral::ClassFlowCNNGeneral;
|
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)
|
// 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));
|
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));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,24 +84,9 @@ void test_ZeigerEvalHybrid() {
|
|||||||
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybrid(4.5, 9.6, 0));
|
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybrid(4.5, 9.6, 0));
|
||||||
|
|
||||||
// the 4.5 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.6)
|
// 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));
|
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)
|
|
||||||
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)
|
// 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));
|
TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybrid(4.5, 9.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.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));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ extern "C" void app_main()
|
|||||||
|
|
||||||
RUN_TEST(test_ZeigerEval);
|
RUN_TEST(test_ZeigerEval);
|
||||||
RUN_TEST(test_ZeigerEvalHybrid);
|
RUN_TEST(test_ZeigerEvalHybrid);
|
||||||
RUN_TEST(test_ZeigerEvalDigital);
|
|
||||||
|
|
||||||
UNITY_END();
|
UNITY_END();
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user