jomjol 4 лет назад
Родитель
Сommit
8a26b817f7

+ 5 - 1
README.md

@@ -43,7 +43,11 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
 
 
 **General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
 **General remark:** Beside the `firmware.bin`, typically also the content of `/html` needs to be updated!
 
 
-##### Rolling - (2021-05-20)
+
+##### Rolling - (2021-05-22)
+* Bug fix: calculation of flow rate
+
+Rolling - (2021-05-20)
 * Bug fix: mqtt retain message flag
 * Bug fix: mqtt retain message flag
 
 
 Rolling - (2021-05-20)
 Rolling - (2021-05-20)

+ 50 - 14
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -11,6 +11,13 @@
 
 
 #include <time.h>
 #include <time.h>
 
 
+#include "time_sntp.h"
+
+
+#define PREVALUE_TIME_FORMAT_OUTPUT "%Y-%m-%dT%H:%M:%S"
+#define PREVALUE_TIME_FORMAT_INPUT "%d-%d-%dT%d:%d:%d"
+
+
 string ClassFlowPostProcessing::GetPreValue()
 string ClassFlowPostProcessing::GetPreValue()
 {
 {
     std::string result;
     std::string result;
@@ -63,7 +70,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
     int yy, month, dd, hh, mm, ss;
     int yy, month, dd, hh, mm, ss;
     struct tm whenStart;
     struct tm whenStart;
 
 
-    sscanf(zwtime.c_str(), "%d-%d-%dT%d:%d:%d", &yy, &month, &dd, &hh, &mm, &ss);
+    sscanf(zwtime.c_str(), PREVALUE_TIME_FORMAT_INPUT, &yy, &month, &dd, &hh, &mm, &ss);
     whenStart.tm_year = yy - 1900;
     whenStart.tm_year = yy - 1900;
     whenStart.tm_mon = month - 1;
     whenStart.tm_mon = month - 1;
     whenStart.tm_mday = dd;
     whenStart.tm_mday = dd;
@@ -72,11 +79,11 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
     whenStart.tm_sec = ss;
     whenStart.tm_sec = ss;
     whenStart.tm_isdst = -1;
     whenStart.tm_isdst = -1;
 
 
-    tStart = mktime(&whenStart);
+    lastvalue = mktime(&whenStart);
 
 
-    time(&lastvalue);
-    localtime(&lastvalue);
-    double difference = difftime(lastvalue, tStart);
+    time(&tStart);
+    localtime(&tStart);
+    double difference = difftime(tStart, lastvalue);
     difference /= 60;
     difference /= 60;
     if (difference > PreValueAgeStartup)
     if (difference > PreValueAgeStartup)
         return false;
         return false;
@@ -121,7 +128,7 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
         time(&rawtime);
         time(&rawtime);
         timeinfo = localtime(&rawtime);
         timeinfo = localtime(&rawtime);
 
 
-        strftime(buffer, 80, "%Y-%m-%dT%H:%M:%S", timeinfo);
+        strftime(buffer, 80, PREVALUE_TIME_FORMAT_OUTPUT, timeinfo);
         timeStamp = std::string(buffer);
         timeStamp = std::string(buffer);
     }
     }
     else
     else
@@ -157,6 +164,15 @@ ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
     timeStamp = "";
     timeStamp = "";
     FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
     FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
     ListFlowControll = lfc;
     ListFlowControll = lfc;
+    flowMakeImage = NULL;
+
+    for (int i = 0; i < ListFlowControll->size(); ++i)
+    {
+        if (((*ListFlowControll)[i])->name().compare("ClassFlowMakeImage") == 0)
+        {
+            flowMakeImage = (ClassFlowMakeImage*) (*ListFlowControll)[i];
+        }
+    }
 }
 }
 
 
 
 
@@ -348,8 +364,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
 
 
             PreValueOkay = true;
             PreValueOkay = true;
             PreValue = Value;
             PreValue = Value;
-            time(&lastvalue);
-            localtime(&lastvalue);
+            if (flowMakeImage) 
+            {
+                lastvalue = flowMakeImage->getTimeImageTaken();
+                zwtime = ConvertTimeToString(lastvalue, PREVALUE_TIME_FORMAT_OUTPUT);
+            }
+            else
+            {
+                time(&lastvalue);
+                localtime(&lastvalue);
+            }
 
 
             SavePreValue(Value, zwtime);
             SavePreValue(Value, zwtime);
         }
         }
@@ -387,16 +411,28 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
     if (ErrorMessage && (ErrorMessageText.length() > 0))
     if (ErrorMessage && (ErrorMessageText.length() > 0))
         ReturnValue = ReturnValue + "\t" + ErrorMessageText;
         ReturnValue = ReturnValue + "\t" + ErrorMessageText;
 
 
-    if (ErrorMessageText.length() == 0)
+    time_t currenttime;
+    if (flowMakeImage) 
+    {
+        currenttime = flowMakeImage->getTimeImageTaken();
+        zwtime = ConvertTimeToString(currenttime, PREVALUE_TIME_FORMAT_OUTPUT);
+    }
+    else
     {
     {
-        time_t currenttime;
         time(&currenttime);
         time(&currenttime);
         localtime(&currenttime);
         localtime(&currenttime);
-//        currenttime = 
-        double difference = difftime(currenttime, lastvalue);      // in Sekunden
-        difference /= 60;                                          // in Minuten
-        FlowRateAct = (Value - PreValue) / difference;
+    }
+
+    double difference = difftime(currenttime, lastvalue);      // in Sekunden
+    difference /= 60;                                          // in Minuten
+    FlowRateAct = (Value - PreValue) / difference;
+    lastvalue = currenttime;
+//    std::string _zw = "CalcRate: " + std::to_string(FlowRateAct) + " TimeDifference[min]: " +  std::to_string(difference);
+//    _zw = _zw  + " Value: " +  std::to_string(Value) + " PreValue: " +  std::to_string(PreValue);
+//    LogFile.WriteToFile(_zw);
 
 
+    if (ErrorMessageText.length() == 0)
+    {
         PreValue = Value;
         PreValue = Value;
         SavePreValue(Value, zwtime);
         SavePreValue(Value, zwtime);
     }
     }

+ 5 - 0
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h

@@ -1,9 +1,12 @@
 #pragma once
 #pragma once
 #include "ClassFlow.h"
 #include "ClassFlow.h"
+#include "ClassFlowMakeImage.h"
 
 
 #include <string>
 #include <string>
 
 
 
 
+
+
 class ClassFlowPostProcessing :
 class ClassFlowPostProcessing :
     public ClassFlow
     public ClassFlow
 {
 {
@@ -30,6 +33,8 @@ protected:
     string ErrorMessageText;        // Fehlermeldung bei Consistency Check
     string ErrorMessageText;        // Fehlermeldung bei Consistency Check
     string timeStamp;
     string timeStamp;
 
 
+    ClassFlowMakeImage *flowMakeImage;
+
     bool LoadPreValue(void);
     bool LoadPreValue(void);
     string ShiftDecimal(string in, int _decShift);
     string ShiftDecimal(string in, int _decShift);
 
 

+ 2 - 2
code/main/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="9b791bb";
+const char* GIT_REV="528a443";
 const char* GIT_TAG="";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-05-20 21:43";
+const char* BUILD_TIME="2021-05-22 07:33";

+ 2 - 2
code/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="9b791bb";
+const char* GIT_REV="528a443";
 const char* GIT_TAG="";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-05-20 21:43";
+const char* BUILD_TIME="2021-05-22 07:33";

BIN
firmware/bootloader.bin


BIN
firmware/firmware.bin