Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revert to setting lastvalue in only success case #2511

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,13 +757,6 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
NUMBERS[j]->ErrorMessageText = "";
NUMBERS[j]->Value = -1;

/* calculate time difference BEFORE we overwrite the 'lastvalue' */
double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in seconds

/* TODO:
* We could call `NUMBERS[j]->lastvalue = imagetime;` here and remove all other such calls further down.
* But we should check nothing breaks! */

UpdateNachkommaDecimalShift();

int previous_value = -1;
Expand Down Expand Up @@ -819,8 +812,6 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
{
string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
LogFile.WriteToFile(ESP_LOG_INFO, TAG, _zw);
/* TODO to be discussed, see https://github.com/jomjol/AI-on-the-edge-device/issues/1617 */
NUMBERS[j]->lastvalue = imagetime;

WriteDataLog(j);
continue; // there is no number because there is still an N.
Expand Down Expand Up @@ -880,7 +871,6 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
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 = "";
NUMBERS[j]->lastvalue = imagetime;

string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zw);
Expand All @@ -894,7 +884,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
#ifdef SERIAL_DEBUG
ESP_LOGD(TAG, "After AllowNegativeRates: Value %f", NUMBERS[j]->Value);
#endif

double difference = difftime(imagetime, NUMBERS[j]->lastvalue); // in seconds
difference /= 60;
NUMBERS[j]->FlowRateAct = (NUMBERS[j]->Value - NUMBERS[j]->PreValue) / difference;
NUMBERS[j]->ReturnRateValue = to_string(NUMBERS[j]->FlowRateAct);
Expand All @@ -913,7 +903,6 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
NUMBERS[j]->Value = NUMBERS[j]->PreValue;
NUMBERS[j]->ReturnValue = "";
NUMBERS[j]->ReturnRateValue = "";
NUMBERS[j]->lastvalue = imagetime;

string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zw);
Expand All @@ -929,7 +918,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
NUMBERS[j]->ReturnChangeAbsolute = RundeOutput(NUMBERS[j]->Value - NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
NUMBERS[j]->PreValue = NUMBERS[j]->Value;
NUMBERS[j]->PreValueOkay = true;
NUMBERS[j]->lastvalue = imagetime;
NUMBERS[j]->lastvalue = imagetime; // must only be set in case of good value !!!

NUMBERS[j]->ReturnValue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma);
NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
Expand Down