Skip to content

Commit

Permalink
negatives on last value digit with -1 will set to prevalue and is not…
Browse files Browse the repository at this point in the history
… an error #2744
  • Loading branch information
haverland committed Dec 28, 2023
1 parent 061a6d5 commit ce10ee5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -880,10 +880,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
NUMBERS[j]->ReturnValue = to_string(NUMBERS[j]->PreValue);
}
else if {
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
NUMBERS[j]->ReturnValue = to_string(NUMBERS[j]->PreValue);
} else {
else {
NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Neg. Rate - Read: " + zwvalue + " - Raw: " + NUMBERS[j]->ReturnRawValue + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " ";
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
NUMBERS[j]->ReturnValue = "";
Expand Down
31 changes: 21 additions & 10 deletions code/test/components/jomjol-flowcontroll/test_flow_pp_negative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,32 @@ void testNegative() {
delete underTestPost;

// extendResolution=false
// value < preValue
preValue = 16.99; // zu groß
// value < (preValue -.01)
preValue = 17.00; // zu groß
underTestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
setAllowNegatives(underTestPost, false);
setPreValue(underTestPost, preValue_extended);
setPreValue(underTestPost, preValue);
result = process_doFlow(underTestPost);
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 16.98 - Pre: 16.99 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 16.98 - Pre: 17.00 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("", result.c_str());
delete underTestPost;

// extendResolution=false
// value > (preValue -.01)
// ist im Rahmen der Ungenauigkeit (-1 auf letzter Stelle)
preValue = 16.99; // zu groß
underTestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
setAllowNegatives(underTestPost, false);
setPreValue(underTestPost, preValue);
result = process_doFlow(underTestPost);
TEST_ASSERT_EQUAL_STRING("no error", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("16.99", result.c_str());
delete underTestPost;

// extendResolution=false
// value < preValue
// Aber Prüfung abgeschaltet => kein Fehler
preValue = 16.99; // zu groß
preValue = 17.99; // zu groß
underTestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
setAllowNegatives(underTestPost, true);
setPreValue(underTestPost, preValue_extended);
Expand All @@ -84,22 +95,22 @@ void testNegative_Issues() {
// Ohne decimal_shift
std::vector<float> digits = { 2.0, 2.0, 0.0, 1.0, 7.2, 9.0, 8.0};
std::vector<float> analogs = { };
double preValue_extended = 22018.080;
double preValue = 22018.08;
double preValue_extended = 22018.090;
double preValue = 22018.09;

const char* expected = "22017.98";

// https://github.com/jomjol/AI-on-the-edge-device/issues/2145#issuecomment-1461899094
// extendResolution=false
// value < preValue
// Prüfung eingeschaltet => Fehler
preValue = 22018.08; // zu groß
preValue = 22018.09; // zu groß
UnderTestPost* underTestPost = init_do_flow(analogs, digits, Digital100, false, false, -2);
setAllowNegatives(underTestPost, false);
setPreValue(underTestPost, preValue_extended);
std::string result = process_doFlow(underTestPost);
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 22017.98 - Pre: 22018.08 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
TEST_ASSERT_EQUAL_STRING("Neg. Rate - Read: - Raw: 22017.98 - Pre: 22018.09 ", underTestPost->getReadoutError().c_str());
TEST_ASSERT_EQUAL_STRING("", result.c_str());
delete underTestPost;

}
4 changes: 2 additions & 2 deletions code/test/test_suite_flowcontroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ extern "C" void app_main()

UNITY_BEGIN();
RUN_TEST(testNegative_Issues);
/* RUN_TEST(testNegative);
RUN_TEST(testNegative);
/*
RUN_TEST(test_analogToDigit_Standard);
RUN_TEST(test_analogToDigit_Transition);
RUN_TEST(test_doFlowPP);
Expand Down

0 comments on commit ce10ee5

Please sign in to comment.