mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 12:06:58 +03:00
Compare commits
21 Commits
log-mqtt-c
...
analog-dig
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
919ede0e7c | ||
|
|
b0a7c7716f | ||
|
|
aff08fafee | ||
|
|
ed746f96b9 | ||
|
|
fa08a02e12 | ||
|
|
57715b5bdd | ||
|
|
53f3b99f05 | ||
|
|
ba63d0a589 | ||
|
|
0309620fd6 | ||
|
|
295038a881 | ||
|
|
488ae174a4 | ||
|
|
4b4b42d4c5 | ||
|
|
135b03d505 | ||
|
|
74c09ac023 | ||
|
|
1f4b8807fb | ||
|
|
827ca1cf61 | ||
|
|
dc640d7bce | ||
|
|
b551eadf8a | ||
|
|
8e8ac621dd | ||
|
|
54d4990d16 | ||
|
|
f8dd986e4f |
@@ -166,7 +166,8 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
|
||||
return result;
|
||||
}
|
||||
|
||||
if ((number_of_predecessors >= Digital_Transition_Area_Predecessor ) && (number_of_predecessors <= (10.0 - Digital_Transition_Area_Predecessor))) {
|
||||
if ((number_of_predecessors > Digital_Transition_Area_Predecessor ) && (number_of_predecessors < (10.0 - Digital_Transition_Area_Predecessor)))
|
||||
{
|
||||
// no digit change, because predecessor is far enough away (0+/-DigitalTransitionRangePredecessor) --> number is rounded
|
||||
// Band around the digit --> Round off, as digit reaches inaccuracy in the frame
|
||||
if ((result_after_decimal_point <= DigitalBand) || (result_after_decimal_point >= (10-DigitalBand))) {
|
||||
@@ -204,7 +205,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
|
||||
// number can still be x.6 - x.7.
|
||||
// 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.
|
||||
result = result_before_decimal_point % 10;
|
||||
}
|
||||
@@ -227,8 +229,8 @@ int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral
|
||||
bool roundedUp = false;
|
||||
|
||||
// Within the digital inequalities
|
||||
if ((result_after_decimal_point >= (10-Digital_Uncertainty * 10)) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame
|
||||
|| (eval_predecessors <= 4 && result_after_decimal_point>=6)) { // or digit runs after (analogue =0..4, digit >=6)
|
||||
if ((result_after_decimal_point >= (10-Digital_Uncertainty * 10) && ((int)numeral_preceder == eval_predecessors)) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame
|
||||
|| (eval_predecessors <= 4 && result_after_decimal_point>=6)) { // or digit runs after (analogue =0..4, digit >=6)
|
||||
result = (int) (round(number) + 10) % 10;
|
||||
roundedUp = true;
|
||||
// before/ after decimal point, because we adjust the number based on the uncertainty.
|
||||
@@ -238,7 +240,14 @@ int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral
|
||||
" 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 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 {
|
||||
result = (int) ((int) trunc(number) + 10) % 10;
|
||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - NO digital Uncertainty - Result = " + std::to_string(result) +
|
||||
@@ -248,9 +257,10 @@ int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral
|
||||
// No zero crossing has taken place.
|
||||
// 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.
|
||||
if ((eval_predecessors>=6 && (numeral_preceder>analogDigitalTransitionStart || numeral_preceder<=0.2) && roundedUp)) {
|
||||
result = ((result_before_decimal_point+10) - 1) % 10;
|
||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) +
|
||||
if ((eval_predecessors >= 3 && (numeral_preceder > analogDigitalTransitionStart) && roundedUp))
|
||||
{
|
||||
result = ((result_before_decimal_point+10) - 1) % 10;
|
||||
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - No correction = " + std::to_string(result) +
|
||||
" number: " + std::to_string(number) +
|
||||
" numeral_preceder = " + std::to_string(numeral_preceder) +
|
||||
" eerg after comma = " + std::to_string(result_after_decimal_point));
|
||||
|
||||
@@ -333,3 +333,17 @@ CTfLiteClass::~CTfLiteClass()
|
||||
|
||||
psram_free_shared_tensor_arena_and_model_memory();
|
||||
}
|
||||
|
||||
#ifdef SUPRESS_TFLITE_ERRORS
|
||||
namespace tflite
|
||||
{
|
||||
//tflite::ErrorReporter
|
||||
// int OwnMicroErrorReporter::Report(const char* format, va_list args)
|
||||
|
||||
int OwnMicroErrorReporter::Report(const char* format, va_list args)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,3 +1,16 @@
|
||||
manifest_hash: 63f5c6c9f0bcebc7b9ca12d2aa8b26b2c5f5218d377dc4b2375d9b9ca1df7815
|
||||
target: esp32
|
||||
version: 1.0.0
|
||||
dependencies:
|
||||
espressif/esp-nn:
|
||||
component_hash: b32869798bdb40dec6bc99caca48cd65d42f8a9f506b9ab9c598a076f891ede9
|
||||
source:
|
||||
pre_release: true
|
||||
service_url: https://api.components.espressif.com/
|
||||
type: service
|
||||
version: 1.0.2
|
||||
idf:
|
||||
component_hash: null
|
||||
source:
|
||||
type: idf
|
||||
version: 5.1.2
|
||||
manifest_hash: a5f7be33336cfab90d6c2eb74757b616296d8c1e61665336749ed18905905567
|
||||
target: esp32
|
||||
version: 1.0.0
|
||||
|
||||
@@ -191,7 +191,7 @@
|
||||
#define Digital_Uncertainty 0.2
|
||||
#define DigitalBand 3
|
||||
#define Digital_Transition_Range_Predecessor 2
|
||||
#define Digital_Transition_Area_Predecessor 0.7 // 9.3 - 0.7
|
||||
#define Digital_Transition_Area_Predecessor 1.0 // 9.0 - 1.0
|
||||
#define Digital_Transition_Area_Forward 9.7 // Pre-run zero crossing only happens from approx. 9.7 onwards
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ void test_analogToDigit_Standard() {
|
||||
// Default: dig=6.8, ana=8.6 => erg=7
|
||||
// Transition = no
|
||||
// Offset = no
|
||||
TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 8.6, 6, 9.2));
|
||||
TEST_ASSERT_EQUAL_INT(7, undertest->PointerEvalAnalogToDigitNew( 6.8, 8.6, 8, 9.2));
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/1143#issuecomment-1274434805
|
||||
// Also hanging digit () with small pointer after 0 pass.
|
||||
@@ -101,4 +101,4 @@ void test_analogToDigit_Transition() {
|
||||
// Special feature: Digit runs with analogue. Therefore 1.8 (vs. 7.8)
|
||||
TEST_ASSERT_EQUAL_INT(1, undertest->PointerEvalAnalogToDigitNew( 1.8, 7.8, 7, 7.7));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -108,9 +108,13 @@ void test_ZeigerEvalHybrid() {
|
||||
|
||||
// pre = 9.9 (0.0 raw)
|
||||
// zahl = 1.8
|
||||
TEST_ASSERT_EQUAL(2, undertest.PointerEvalHybridNew(1.8, 9.0, 9));
|
||||
|
||||
// if a digit have an early transition and the pointer is < 9.0
|
||||
TEST_ASSERT_EQUAL(1, undertest.PointerEvalHybridNew(1.8, 9.0, 9));
|
||||
|
||||
// pre = 8.8 (0.0 raw)
|
||||
// zahl = 1.8
|
||||
TEST_ASSERT_EQUAL(2, undertest.PointerEvalHybridNew(1.8, 8.9, 8));
|
||||
|
||||
// if a digit have an early transition and the pointer is < 9.0
|
||||
// prev (pointer) = 6.2, but on digital readout = 6.0 (prev is int parameter)
|
||||
// zahl = 4.6
|
||||
TEST_ASSERT_EQUAL(4, undertest.PointerEvalHybridNew(4.6, 6.0, 6));
|
||||
@@ -120,5 +124,4 @@ void test_ZeigerEvalHybrid() {
|
||||
//TEST_ASSERT_EQUAL(7, undertest.ZeigerEvalHybrid(6.7, -1.0, -1));
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "test_flow_postrocess_helper.h"
|
||||
|
||||
|
||||
|
||||
#include <memory>
|
||||
|
||||
/**
|
||||
* ACHTUNG! Die Test laufen aktuell nur mit ausgeschaltetem Debug in ClassFlowCNNGeneral
|
||||
@@ -477,12 +476,18 @@ void test_doFlowPP3() {
|
||||
expected_extended= "126.9231";
|
||||
|
||||
// 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());
|
||||
delete undertestPost;
|
||||
|
||||
// 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());
|
||||
delete undertestPost;
|
||||
|
||||
// Fehler V12.0.1
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/1110#issuecomment-1282168030
|
||||
@@ -542,4 +547,266 @@ void test_doFlowPP4() {
|
||||
|
||||
}
|
||||
|
||||
std::string postProcess(std::vector<float> digits,
|
||||
std::vector<float> analogs,
|
||||
float analog2DigitalTransition=0.0,
|
||||
int decimalShift=0)
|
||||
{
|
||||
std::unique_ptr<UnderTestPost> undertestPost(init_do_flow(std::move(analogs),
|
||||
std::move(digits),
|
||||
Digital100,
|
||||
false, false, decimalShift));
|
||||
|
||||
setAnalogdigitTransistionStart(undertestPost.get(), analog2DigitalTransition);
|
||||
return process_doFlow(undertestPost.get());
|
||||
}
|
||||
|
||||
void test_doFlowLateTransition()
|
||||
{
|
||||
// in these test cases, the last digit before comma turns 3.6 too late
|
||||
float a2dt = 3.4; // value when last digit reaches x.8 region
|
||||
|
||||
// Questionable? (Meter shows 011.0210 but it already needs to be 012.0210, before transition)
|
||||
// Slider0007: In my opionion this series starts clearly with 11.x
|
||||
// As I remember right, this is a real series from rainman110, therefore the following cases
|
||||
// also needs to be corrected the same way
|
||||
TEST_ASSERT_EQUAL_STRING("11.0210", postProcess({0.0, 1.0, 1.0}, {0.2, 2.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
// meter shows 011.3210 but it already needs to be 012.3210, just before transition
|
||||
TEST_ASSERT_EQUAL_STRING("11.3210", postProcess({0.0, 1.0, 1.2}, {3.3, 2.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
// meter shows 012.4210 , this is after transition
|
||||
TEST_ASSERT_EQUAL_STRING("11.4210", postProcess({0.0, 1.0, 2.0}, {4.3, 2.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
// meter shows 012.987
|
||||
TEST_ASSERT_EQUAL_STRING("11.9870", postProcess({0.0, 1.0, 2.0}, {9.8, 8.7, 7.0, 0.0}, a2dt).c_str());
|
||||
|
||||
// meter shows 0012.003
|
||||
TEST_ASSERT_EQUAL_STRING("12.003", postProcess({0.0, 0.0, 1.0, 2.0}, {0.1, 0.3, 3.1}, a2dt).c_str());
|
||||
|
||||
// meter shows 0012.351
|
||||
TEST_ASSERT_EQUAL_STRING("12.351", postProcess({0.0, 0.0, 1.0, 2.8}, {3.5, 5.2, 1.1}, a2dt).c_str());
|
||||
|
||||
// meter shows 0013.421
|
||||
TEST_ASSERT_EQUAL_STRING("12.421", postProcess({0.0, 0.0, 1.0, 3.0}, {4.1, 2.2, 1.1}, a2dt).c_str());
|
||||
}
|
||||
|
||||
void test_doFlowEarlyTransition()
|
||||
{
|
||||
// in these test cases, the last digit before comma turns at around 7.5
|
||||
// start transition 7.0 end transition 8.0
|
||||
float a2dt = 7.8; // value when last digit reaches x.8 region
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("12.6789", postProcess({0.0, 1.0, 2.0}, {6.7, 7.8, 8.9, 9.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("12.7234", postProcess({0.0, 1.0, 2.4}, {7.2, 2.3, 3.4, 4.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("12.7789", postProcess({0.0, 1.0, 2.7}, {7.7, 7.8, 8.9, 9.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("12.8123", postProcess({0.0, 1.0, 3.0}, {8.1, 1.2, 2.3, 3.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("13.1234", postProcess({0.0, 1.0, 3.0}, {1.2, 2.3, 3.4, 4.0}, a2dt).c_str());
|
||||
}
|
||||
|
||||
|
||||
void test_doFlowEarlyTransitionEdgeCase()
|
||||
{
|
||||
float a2dt = 8.;
|
||||
|
||||
// Silder0007: In my opinion this is a unrealistic case {0.0, **0.0**, 9.9, 9,0}, {5.0, 0.0}
|
||||
// More realistic values: {0.0, 0.9, 9.9, 9,0}, {5.0, 0.0}
|
||||
TEST_ASSERT_EQUAL_STRING("99.50", postProcess({0.0, 0.0, 9.0, 9.0}, {5.0, 0.0}, a2dt).c_str());
|
||||
|
||||
// fails with 99.50
|
||||
TEST_ASSERT_EQUAL_STRING("199.50", postProcess({0.0, 1.0, 9.0, 9.0}, {5.0, 0.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("99.95", postProcess({0.0, 1.0, 0.0, 0.0}, {9.5, 5.0}, a2dt).c_str());
|
||||
}
|
||||
|
||||
void test_doFlowIssue2857()
|
||||
{
|
||||
// reported by gec75
|
||||
float a2dt = 9.2;
|
||||
int decimalShift = 3;
|
||||
TEST_ASSERT_EQUAL_STRING("252090.0", postProcess({ 2.0, 5.0, 1.9}, { 0.8, 8.8, 9.9, 0.1},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// reported by Kornelius777
|
||||
decimalShift = 0;
|
||||
TEST_ASSERT_EQUAL_STRING("1017.8099", postProcess({ 0.0, 1.0, 0.0, 1.0, 7.0}, { 8.2, 0.9, 9.9, 9.8},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// with hanging digit
|
||||
TEST_ASSERT_EQUAL_STRING("1017.8099", postProcess({ 0.0, 1.0, 0.0, 1.0, 6.9}, { 8.2, 0.9, 9.9, 9.8},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// and deccimal shift
|
||||
decimalShift = -2;
|
||||
TEST_ASSERT_EQUAL_STRING("10.178099", postProcess({ 0.0, 1.0, 0.0, 1.0, 6.9}, { 8.2, 0.9, 9.9, 9.8},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
|
||||
// reported by marcniedersachsen
|
||||
decimalShift = 0;
|
||||
TEST_ASSERT_EQUAL_STRING("778.1480", postProcess({ 0.0, 7.0, 7.0, 7.9}, { 1.4, 4.7, 8.0, 0.5},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
decimalShift = 3;
|
||||
TEST_ASSERT_EQUAL_STRING("778148.0", postProcess({ 0.0, 7.0, 7.0, 7.9}, { 1.4, 4.7, 8.0, 0.5},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// reported by ohkaja
|
||||
decimalShift = 0;
|
||||
TEST_ASSERT_EQUAL_STRING("1052.6669", postProcess({ 0.0, 1.0, 10.0, 4.9, 2.0}, { 6.7, 6.7, 6.9, 9.1},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// FrankCGN01
|
||||
decimalShift = -3;
|
||||
a2dt = 9.7;
|
||||
TEST_ASSERT_EQUAL_STRING("159.3659", postProcess({ 0.9, 4.8, 8.9, 3.0, 6.0, 5.0}, { 9.6},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// Second test in https://github.com/jomjol/AI-on-the-edge-device/issues/2857#issuecomment-1937452352
|
||||
// The last digit seems to be falsely recongnized. It looks like a regular "2" (no transition)
|
||||
// but it is recognized by the inference as "2.5".
|
||||
decimalShift = -3;
|
||||
TEST_ASSERT_EQUAL_STRING("159.5022", postProcess({ 0.9, 4.9, 8.9, 5.0, 0.0, 2.5}, { 2.2},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// reported by penapena
|
||||
// Note: this is a strange example, as the last digit (4.4) seems to have very early transition
|
||||
decimalShift = 0;
|
||||
TEST_ASSERT_EQUAL_STRING("124.4981", postProcess({ 0.0, 1.0, 2.0, 4.4}, { 5.1, 9.8, 8.3, 1.6},
|
||||
a2dt, decimalShift).c_str());
|
||||
|
||||
// reported by warnmat
|
||||
decimalShift = 0;
|
||||
TEST_ASSERT_EQUAL_STRING("51.653", postProcess({ 0.1, 0.1, 5.0, 1.0}, { 6.7, 5.4, 3.1},
|
||||
a2dt, decimalShift).c_str());
|
||||
}
|
||||
|
||||
|
||||
void test_doFlowLateTransitionHanging()
|
||||
{
|
||||
float a2dt = 3.6;
|
||||
|
||||
// haverland: this is the case if the analog pointer is a bit before the digit.
|
||||
// It's the normal late transition up to 2.0 on analog must the digit transition ends
|
||||
// After 2.0 on analog it named "hanging digit" by me. It never reach the x.0 until the next
|
||||
// transition begins.
|
||||
// BUT. It makes the issue you have later, because all other unter 3.6 are negative values now.
|
||||
TEST_ASSERT_EQUAL_STRING("12.1210", postProcess({0.0, 1.0, 1.9}, {1.2, 2.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
// Questionable? (meter shows 012.4210 , this is after transition)
|
||||
// Slider0007: In my opionion this series starts with 11.x with this a2dt value
|
||||
// As I remember right, this is a real series from rainman110, therefore the following cases
|
||||
// also needs to be corrected the same way
|
||||
TEST_ASSERT_EQUAL_STRING("11.4210", postProcess({0.0, 1.0, 1.9}, {4.3, 2.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("11.6210", postProcess({0.0, 1.0, 1.9}, {6.3, 2.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("12.3610", postProcess({0.0, 1.0, 2.5}, {3.5, 6.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("12.4510", postProcess({0.0, 1.0, 3.0}, {4.5, 5.2, 1.0, 0.0}, a2dt).c_str());
|
||||
|
||||
TEST_ASSERT_EQUAL_STRING("12.4510", postProcess({0.0, 1.0, 2.9}, {4.5, 5.2, 1.0, 0.0}, a2dt).c_str());
|
||||
}
|
||||
|
||||
|
||||
void test_doFlowPP_rainman110()
|
||||
{
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/issues/2743
|
||||
// --> Extreme early digit transition. AnanlogDigitTransition needs to set to 3.5 (was limited to 6)
|
||||
std::vector<float> digits = {4.0, 1.0, 1.8}; // wrong result: 412.3983
|
||||
std::vector<float> analogs = {3.6, 9.9, 8.1, 3.5};
|
||||
UnderTestPost* undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 3.5);
|
||||
TEST_ASSERT_EQUAL_STRING("411.3983", process_doFlow(undertestPost).c_str());
|
||||
delete undertestPost;
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/pull/2887
|
||||
// --> Extreme early digit transition. AnanlogDigitTransition needs to set to 3.5 (was limited to 6)
|
||||
digits = {4.0, 1.0, 7.9}; // wrong result: 417.2579
|
||||
analogs = {2.5, 5.8, 7.7, 9.0};
|
||||
|
||||
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 3.5);
|
||||
TEST_ASSERT_EQUAL_STRING("418.2579", process_doFlow(undertestPost).c_str());
|
||||
delete undertestPost;
|
||||
|
||||
// Edge Case
|
||||
digits = {9.9, 9.4};
|
||||
analogs = {5.0, 0.0};
|
||||
|
||||
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 8.0);
|
||||
TEST_ASSERT_EQUAL_STRING("99.50", process_doFlow(undertestPost).c_str());
|
||||
delete undertestPost;
|
||||
|
||||
// Edge Case
|
||||
digits = {1.0, 0.0, 0.0};
|
||||
analogs = {9.5, 5.0};
|
||||
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 8.0);
|
||||
TEST_ASSERT_EQUAL_STRING("99.95", process_doFlow(undertestPost).c_str());
|
||||
delete undertestPost;
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/pull/2887
|
||||
// Discussion 149365.9 vs. 149364.9
|
||||
digits = {0.9, 4.8, 9.0, 3.0, 6.0, 5.0};
|
||||
analogs = {9.6};
|
||||
|
||||
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 9.2);
|
||||
TEST_ASSERT_EQUAL_STRING("149364.9", process_doFlow(undertestPost).c_str());
|
||||
delete undertestPost;
|
||||
}
|
||||
|
||||
|
||||
void test_doFlowPP_rainman110_transition()
|
||||
{
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/pull/2887
|
||||
// Edge cases
|
||||
std::vector<float> digits = {4.0, 1.0, 7.9};
|
||||
std::vector<float> analogs = {1.4, 5.8, 7.7, 9.0};
|
||||
|
||||
UnderTestPost* undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 3.5);
|
||||
std::string result = process_doFlow(undertestPost);
|
||||
TEST_ASSERT_EQUAL_STRING("418.1579", result.c_str());
|
||||
delete undertestPost;
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/pull/2887
|
||||
// Edge cases
|
||||
digits = {4.0, 1.0, 7.9};
|
||||
analogs = {3.4, 5.8, 7.7, 9.0};
|
||||
|
||||
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 3.5);
|
||||
result = process_doFlow(undertestPost);
|
||||
TEST_ASSERT_EQUAL_STRING("418.3579", result.c_str());
|
||||
delete undertestPost;
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/pull/2887
|
||||
// Edge cases
|
||||
digits = {4.0, 1.0, 8.5};
|
||||
analogs = {3.7, 5.8, 7.7, 9.0};
|
||||
|
||||
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 3.5);
|
||||
result = process_doFlow(undertestPost);
|
||||
TEST_ASSERT_EQUAL_STRING("418.3579", result.c_str());
|
||||
delete undertestPost;
|
||||
|
||||
// https://github.com/jomjol/AI-on-the-edge-device/pull/2887
|
||||
// Edge cases
|
||||
digits = {4.0, 1.0, 8.9};
|
||||
analogs = {4.0, 5.8, 7.7, 9.0};
|
||||
|
||||
undertestPost = init_do_flow(analogs, digits, Digital100, false, false, 0);
|
||||
setAnalogdigitTransistionStart(undertestPost, 3.5);
|
||||
result = process_doFlow(undertestPost);
|
||||
TEST_ASSERT_EQUAL_STRING("418.4579", result.c_str());
|
||||
delete undertestPost;
|
||||
}
|
||||
|
||||
@@ -138,6 +138,21 @@ void task_UnityTesting(void *pvParameter)
|
||||
RUN_TEST(test_doFlowPP3);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowPP4);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowLateTransition);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowEarlyTransition);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowEarlyTransitionEdgeCase);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowIssue2857);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowLateTransitionHanging);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowPP_rainman110);
|
||||
printf("---------------------------------------------------------------------------\n");
|
||||
RUN_TEST(test_doFlowPP_rainman110_transition);
|
||||
|
||||
UNITY_END();
|
||||
|
||||
while(1);
|
||||
@@ -153,20 +168,7 @@ extern "C" void app_main()
|
||||
Init_NVS_SDCard();
|
||||
esp_log_level_set("*", ESP_LOG_ERROR); // set all components to ERROR level
|
||||
|
||||
UNITY_BEGIN();
|
||||
RUN_TEST(testNegative_Issues);
|
||||
RUN_TEST(testNegative);
|
||||
|
||||
RUN_TEST(test_analogToDigit_Standard);
|
||||
RUN_TEST(test_analogToDigit_Transition);
|
||||
RUN_TEST(test_doFlowPP);
|
||||
RUN_TEST(test_doFlowPP1);
|
||||
RUN_TEST(test_doFlowPP2);
|
||||
RUN_TEST(test_doFlowPP3);
|
||||
RUN_TEST(test_doFlowPP4);
|
||||
|
||||
// getReadoutRawString test
|
||||
RUN_TEST(test_getReadoutRawString);
|
||||
|
||||
UNITY_END();
|
||||
// Create dedicated testing task (heap size can be configured - large enough to handle a lot of testing cases)
|
||||
// ********************************************
|
||||
xTaskCreate(&task_UnityTesting, "task_UnityTesting", 12 * 1024, NULL, tskIDLE_PRIORITY+2, NULL);
|
||||
}
|
||||
|
||||
@@ -925,8 +925,8 @@
|
||||
<label for=PostProcessing_AnalogDigitalTransitionStart_enabled><class id="PostProcessing_AnalogDigitalTransitionStart_text" style="color:black;">Analog/Digital Transition Start</class></label>
|
||||
</td>
|
||||
<td>
|
||||
<input required type="number" id="PostProcessing_AnalogDigitalTransitionStart_value1" step="0.1" min="5.0" max="9.9" value="9.2"
|
||||
oninput="(!validity.rangeUnderflow||(value=5.0)) && (!validity.rangeOverflow||(value=9.9)) &&
|
||||
<input required type="number" id="PostProcessing_AnalogDigitalTransitionStart_value1" step="0.1" min="3.0" max="9.9" value="9.2"
|
||||
oninput="(!validity.rangeUnderflow||(value=3.0)) && (!validity.rangeOverflow||(value=9.9)) &&
|
||||
(!validity.stepMismatch||(value=parseInt(this.value)));">
|
||||
</td>
|
||||
<td>$TOOLTIP_PostProcessing_NUMBER.AnalogDigitalTransitionStart</td>
|
||||
|
||||
Reference in New Issue
Block a user