diff --git a/Version_Max_07_05_2018_CMake/src/relationChecker.cpp b/Version_Max_07_05_2018_CMake/src/relationChecker.cpp index 0981ff3..fe0205a 100755 --- a/Version_Max_07_05_2018_CMake/src/relationChecker.cpp +++ b/Version_Max_07_05_2018_CMake/src/relationChecker.cpp @@ -1,66 +1,49 @@ #include "relationChecker.h" #include //DATE18 float deviationValueReferenceValue(float sampleValue, float historyValue) { - - //printf("hier\n"); - float diff; - if (sampleValue < 0) { - sampleValue = sampleValue * (-1); - } - - - if (historyValue < 0) { - historyValue = historyValue * (-1); - } - - if (sampleValue > historyValue) - diff = sampleValue - historyValue; - else - diff = historyValue - sampleValue; - - //printf("sample %f, reference %f, diff %f, ", sampleValue, historyValue, diff); - + diff = historyValue - sampleValue; if (diff == 0) { - //printf("deviation %f\n", 0); return 0; } else { - //printf("deviation %f\n", (diff / sampleValue)); - return (diff / sampleValue); + diff = diff / sampleValue; + if (diff < 0) + diff = diff * (-1); + return (diff); } } bool valueIsRelatedToReferenceValue(float referenceValue, float value, float threshold) { float diff; if (referenceValue > value) diff = referenceValue - value; else diff = value - referenceValue; //printf("referenceValue %f, value %f, diff %f, threshold %f\n", referenceValue, value, diff, threshold); if (diff == 0 || (diff / referenceValue <= threshold)) { return true; } printf("\nRelated Calculation:\nAverage: %f\nActualValue: %f\nDiff: %f\ndeviation: %f\nthreshold: %f\n", referenceValue, value, diff, diff / referenceValue, threshold); return false; } bool valueIsRelatedToReferenceValueOrBetweenMinAndMax(float referenceValue, float minimumValue, float maximumValue, float value, float threshold) { if (value >= minimumValue && value <= maximumValue) { return true; } return valueIsRelatedToReferenceValue(referenceValue, value, threshold); } \ No newline at end of file