fix for #919 the prev is int, so <9.0 instead of <9.5

This commit is contained in:
Frank Haverland
2022-08-18 19:28:13 +02:00
parent 0d168f3445
commit 7706b4dbc3
2 changed files with 13 additions and 3 deletions

View File

@@ -106,8 +106,10 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
if (GENERAL[_analog]->ROI[i]->result_float >= 0) if (GENERAL[_analog]->ROI[i]->result_float >= 0)
{ {
prev = ZeigerEvalHybrid(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev); prev = ZeigerEvalHybrid(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout#ZeigerEvalHybrid()= " + std::to_string(prev));
result = std::to_string(prev) + result; result = std::to_string(prev) + result;
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::getReadout#result= " + result);
} }
else else
{ {
@@ -171,6 +173,8 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
int ClassFlowCNNGeneral::ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int eval_vorgaenger) int ClassFlowCNNGeneral::ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int eval_vorgaenger)
{ {
if (debugdetailgeneral) LogFile.WriteToFile("ClassFlowCNNGeneral::ZeigerEvalHybrid( " + std::to_string(zahl) + ", " + std::to_string(zahl_vorgaenger) + ", " + std::to_string(eval_vorgaenger) + ")");
int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10; int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;
int ergebnis_vorkomma = ((int) floor(zahl) + 10) % 10; int ergebnis_vorkomma = ((int) floor(zahl) + 10) % 10;
@@ -183,7 +187,9 @@ int ClassFlowCNNGeneral::ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int
return ((int) trunc(zahl) + 10) % 10; return ((int) trunc(zahl) + 10) % 10;
} }
if ((zahl_vorgaenger >= 0.5 ) && (zahl_vorgaenger < 9.5)) // 9.0, da bei getReadout() prev als int übergeben wird (9 statt 9.5)
// tritt bei der ersten ziffer von digit auf, wenn analog davor (2. Aufruf von getReadout)
if ((zahl_vorgaenger >= 0.5 ) && (zahl_vorgaenger < 9.0))
{ {
// kein Ziffernwechsel, da Vorkomma weit genug weg ist (0+/-0.5) --> zahl wird gerundet // kein Ziffernwechsel, da Vorkomma weit genug weg ist (0+/-0.5) --> zahl wird gerundet
return ((int) round(zahl) + 10) % 10; return ((int) round(zahl) + 10) % 10;

View File

@@ -85,7 +85,7 @@ void test_ZeigerEvalHybrid() {
// 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.4 (digital100) is not above 5 and the previous digit (analog) not over Zero (9.5) // 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)); TEST_ASSERT_EQUAL(4, undertest.ZeigerEvalHybrid(4.5, 9.5, 9));
// 59.96889 - Pre: 58.94888 // 59.96889 - Pre: 58.94888
@@ -93,6 +93,10 @@ void test_ZeigerEvalHybrid() {
// 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(8, undertest.ZeigerEvalHybrid(8.6, 9.8, 9)); TEST_ASSERT_EQUAL(8, undertest.ZeigerEvalHybrid(8.6, 9.8, 9));
// pre = 9.9 (0.0 raw)
// zahl = 1.8
TEST_ASSERT_EQUAL(1, undertest.ZeigerEvalHybrid(1.8, 9.0, 9));
// issue #879 vorgaenger is -1, zahl = 6.7 // issue #879 vorgaenger is -1, zahl = 6.7
//TEST_ASSERT_EQUAL(7, undertest.ZeigerEvalHybrid(6.7, -1.0, -1)); //TEST_ASSERT_EQUAL(7, undertest.ZeigerEvalHybrid(6.7, -1.0, -1));