mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-11 22:16:56 +03:00
Add analogdigit early zero crossing case
This commit is contained in:
@@ -195,7 +195,8 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
|
|||||||
// everything >=x.4 can be considered as current number in transition. With 9.x predecessor the current
|
// everything >=x.4 can be considered as current number in transition. With 9.x predecessor the current
|
||||||
// number can still be x.6 - x.7.
|
// number can still be x.6 - x.7.
|
||||||
// Preceding (else - branch) does not already happen from 9.
|
// Preceding (else - branch) does not already happen from 9.
|
||||||
if (Digital_Transition_Area_Forward>=number_of_predecessors || result_after_decimal_point >= 4)
|
if (((Digital_Transition_Area_Forward>=number_of_predecessors) && (eval_predecessors == (int)number_of_predecessors))
|
||||||
|
|| result_after_decimal_point >= 4)
|
||||||
// The current digit, like the previous digit, does not yet have a zero crossing.
|
// The current digit, like the previous digit, does not yet have a zero crossing.
|
||||||
result = result_before_decimal_point % 10;
|
result = result_before_decimal_point % 10;
|
||||||
else
|
else
|
||||||
@@ -228,7 +229,14 @@ int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral
|
|||||||
" number: " + std::to_string(number) + " numeral_preceder: " + std::to_string(numeral_preceder) +
|
" number: " + std::to_string(number) + " numeral_preceder: " + std::to_string(numeral_preceder) +
|
||||||
" erg before comma: " + std::to_string(result_before_decimal_point) +
|
" erg before comma: " + std::to_string(result_before_decimal_point) +
|
||||||
" erg after comma: " + std::to_string(result_after_decimal_point));
|
" erg after comma: " + std::to_string(result_after_decimal_point));
|
||||||
}
|
}
|
||||||
|
else if (result_after_decimal_point < Digital_Uncertainty && numeral_preceder > analogDigitalTransitionStart) {
|
||||||
|
result = ((result_before_decimal_point+10) - 1) % 10;
|
||||||
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Digital Uncertainty - Too early zero crossing - Result = " + std::to_string(result) +
|
||||||
|
" number: " + std::to_string(number) + " numeral_preceder: " + std::to_string(numeral_preceder) +
|
||||||
|
" erg before comma: " + std::to_string(result_before_decimal_point) +
|
||||||
|
" erg after comma: " + std::to_string(result_after_decimal_point));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
result = (int) ((int) trunc(number) + 10) % 10;
|
result = (int) ((int) trunc(number) + 10) % 10;
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - NO digital Uncertainty - Result = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - NO digital Uncertainty - Result = " + std::to_string(result) +
|
||||||
@@ -238,9 +246,9 @@ int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral
|
|||||||
// No zero crossing has taken place.
|
// No zero crossing has taken place.
|
||||||
// Only eval_predecessors used because numeral_preceder could be wrong here.
|
// Only eval_predecessors used because numeral_preceder could be wrong here.
|
||||||
// numeral_preceder<=0.1 & eval_predecessors=9 corresponds to analogue was reset because of previous analogue that are not yet at 0.
|
// numeral_preceder<=0.1 & eval_predecessors=9 corresponds to analogue was reset because of previous analogue that are not yet at 0.
|
||||||
if ((eval_predecessors >= 3 && (numeral_preceder >= analogDigitalTransitionStart) && roundedUp))
|
if ((eval_predecessors >= 3 && (numeral_preceder > analogDigitalTransitionStart) && roundedUp))
|
||||||
{
|
{
|
||||||
result = ((result_before_decimal_point+10) - 1) % 10;
|
result = ((result_before_decimal_point+10) - 1) % 10;
|
||||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - No correction = " + std::to_string(result) +
|
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - No correction = " + std::to_string(result) +
|
||||||
" number: " + std::to_string(number) +
|
" number: " + std::to_string(number) +
|
||||||
" numeral_preceder = " + std::to_string(numeral_preceder) +
|
" numeral_preceder = " + std::to_string(numeral_preceder) +
|
||||||
|
|||||||
@@ -476,12 +476,18 @@ void test_doFlowPP3() {
|
|||||||
expected_extended= "126.9231";
|
expected_extended= "126.9231";
|
||||||
|
|
||||||
// extendResolution=false
|
// extendResolution=false
|
||||||
result = process_doFlow(analogs, digits, Digital100, false, false, 0);
|
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||||
|
setAnalogdigitTransistionStart(undertestPost, 9.4); // Extreme late transition
|
||||||
|
result = process_doFlow(undertestPost);
|
||||||
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
TEST_ASSERT_EQUAL_STRING(expected, result.c_str());
|
||||||
|
delete undertestPost;
|
||||||
|
|
||||||
// checkConsistency=false und extendResolution=true
|
// checkConsistency=false und extendResolution=true
|
||||||
result = process_doFlow(analogs, digits, Digital100, false, true, 0);
|
undertestPost = init_do_flow(analogs, digits, Digital100, false, true, 0);
|
||||||
|
setAnalogdigitTransistionStart(undertestPost, 9.4); // Extreme late transition
|
||||||
|
result = process_doFlow(undertestPost);
|
||||||
TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
TEST_ASSERT_EQUAL_STRING(expected_extended, result.c_str());
|
||||||
|
delete undertestPost;
|
||||||
|
|
||||||
// Fehler V12.0.1
|
// Fehler V12.0.1
|
||||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030
|
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030
|
||||||
@@ -564,4 +570,17 @@ void test_doFlowPP_rainman110() {
|
|||||||
result = process_doFlow(undertestPost);
|
result = process_doFlow(undertestPost);
|
||||||
TEST_ASSERT_EQUAL_STRING("418.2579", result.c_str());
|
TEST_ASSERT_EQUAL_STRING("418.2579", result.c_str());
|
||||||
delete undertestPost;
|
delete undertestPost;
|
||||||
|
|
||||||
|
// Edge cases
|
||||||
|
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||||
|
setAnalogdigitTransistionStart(undertestPost, 8.0);
|
||||||
|
TEST_ASSERT_EQUAL_STRING("99.50", process_doFlow({5.0, 0.0}, {9.9, 9.4},
|
||||||
|
Digital100, false, false, 0).c_str());
|
||||||
|
delete undertestPost;
|
||||||
|
|
||||||
|
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||||
|
setAnalogdigitTransistionStart(undertestPost, 8.0);
|
||||||
|
TEST_ASSERT_EQUAL_STRING("99.95", process_doFlow({9.5, 5.0}, {1.0, 0.0, 0.0},
|
||||||
|
Digital100, false, false, 0).c_str());
|
||||||
|
delete undertestPost;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user