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

+ 1 - 0
README.md

@@ -46,6 +46,7 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
 
 ##### Rolling - (2021-05-06)
 
+* Additional MQTT topics: flow rate (units/minute), time stamp last correct readout
 * Portrait or landscape image orientation in rotated image
 * based on v6.7.2
 

+ 23 - 0
code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp

@@ -11,6 +11,8 @@ void ClassFlowMQTT::SetInitialParameter(void)
     uri = "";
     topic = "";
     topicError = "";
+    topicRate = "";
+    topicTimeStamp = "";
     clientname = "watermeter";
     OldValue = "";
     flowpostprocessing = NULL;  
@@ -94,6 +96,15 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
         {
             this->topicError = zerlegt[1];
         }
+        if ((toUpper(zerlegt[0]) == "TOPICRATE") && (zerlegt.size() > 1))
+        {
+            this->topicRate  = zerlegt[1];
+        }
+        if ((toUpper(zerlegt[0]) == "TOPICTIMESTAMP") && (zerlegt.size() > 1))
+        {
+            this->topicTimeStamp  = zerlegt[1];
+        }
+
         if ((toUpper(zerlegt[0]) == "CLIENTID") && (zerlegt.size() > 1))
         {
             this->clientname = zerlegt[1];
@@ -114,12 +125,16 @@ bool ClassFlowMQTT::doFlow(string zwtime)
 {
     std::string result;
     std::string resulterror = "";
+    std::string resultrate = "";
+    std::string resulttimestamp = "";
     string zw = "";
     
     if (flowpostprocessing)
     {
         result =  flowpostprocessing->getReadoutParam(false, true);
         resulterror = flowpostprocessing->getReadoutError();
+        resultrate = flowpostprocessing->getReadoutRate();
+        resulttimestamp = flowpostprocessing->getReadoutTimeStamp();
     }
     else
     {
@@ -142,6 +157,14 @@ bool ClassFlowMQTT::doFlow(string zwtime)
         MQTTPublish(topicError, resulterror);
     }
 
+    if (topicRate.length() > 0) {
+        MQTTPublish(topicRate, resultrate);
+    }
+
+    if (topicRate.length() > 0) {
+        MQTTPublish(topicTimeStamp, resulttimestamp);
+    }
+
     OldValue = result;
     
     return true;

+ 1 - 1
code/components/jomjol_flowcontroll/ClassFlowMQTT.h

@@ -9,7 +9,7 @@ class ClassFlowMQTT :
     public ClassFlow
 {
 protected:
-    std::string uri, topic, topicError, clientname;
+    std::string uri, topic, topicError, clientname, topicRate, topicTimeStamp;
     std::string OldValue;
 	ClassFlowPostProcessing* flowpostprocessing;  
     std::string user, password;  

+ 33 - 7
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -74,10 +74,9 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
 
     tStart = mktime(&whenStart);
 
-    time_t now;
-    time(&now);
-    localtime(&now);
-    double difference = difftime(now, tStart);
+    time(&lastvalue);
+    localtime(&lastvalue);
+    double difference = difftime(lastvalue, tStart);
     difference /= 60;
     if (difference > PreValueAgeStartup)
         return false;
@@ -123,12 +122,16 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
         timeinfo = localtime(&rawtime);
 
         strftime(buffer, 80, "%Y-%m-%d_%H-%M-%S", timeinfo);
-        zwtime = std::string(buffer);
+        timeStamp = std::string(buffer);
+    }
+    else
+    {
+        timeStamp = zwtime;
     }
 
     PreValue = value;
 
-    fputs(zwtime.c_str(), pFile);
+    fputs(timeStamp.c_str(), pFile);
     fputs("\n", pFile);
     fputs(to_string(value).c_str(), pFile);
     fputs("\n", pFile);
@@ -139,6 +142,7 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
 
 ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
 {
+    FlowRateAct = 0;
     PreValueUse = false;
     PreValueAgeStartup = 30;
     AllowNegativeRates = false;
@@ -150,6 +154,7 @@ ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
     checkDigitIncreaseConsistency = false;
     DecimalShift = 0;    
     ErrorMessageText = "";
+    timeStamp = "";
     FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
     ListFlowControll = lfc;
 }
@@ -343,12 +348,15 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
 
             PreValueOkay = true;
             PreValue = Value;
-            
+            time(&lastvalue);
+            localtime(&lastvalue);
+
             SavePreValue(Value, zwtime);
         }
         return true;
     }
 
+
     zw = ErsetzteN(ReturnRawValue); 
 
     Value = std::stof(zw);
@@ -359,6 +367,14 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
 
     zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
 
+    time_t currenttime;
+    time(&currenttime);
+    localtime(&currenttime);
+    double difference = difftime(currenttime, lastvalue);      // in Sekunden
+    difference /= 60;                                          // in Minuten
+
+    FlowRateAct = (Value - PreValue) / difference;
+
     if ((!AllowNegativeRates) && (Value < PreValue))
     {
         ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " - raw value: " + ReturnRawValue + " - checked value: " + std::to_string(Value) + " "; 
@@ -506,6 +522,16 @@ float ClassFlowPostProcessing::checkDigitConsistency(float input, int _decilamsh
     return input;
 }
 
+string ClassFlowPostProcessing::getReadoutRate()
+{
+    return std::to_string(FlowRateAct);
+}
+
+string ClassFlowPostProcessing::getReadoutTimeStamp()
+{
+   return timeStamp; 
+}
+
 
 string ClassFlowPostProcessing::getReadoutError() 
 {

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

@@ -17,6 +17,9 @@ protected:
     bool PreValueOkay;
     bool checkDigitIncreaseConsistency;
     int DecimalShift;
+    time_t lastvalue;
+    float FlowRateAct;          // m3 / min
+
 
     string FilePreValue;
     float PreValue;             // letzter Wert, der gut ausgelesen wurde
@@ -25,6 +28,7 @@ protected:
     string ReturnValue;         // korrigierter Rückgabewert, ggf. mit Fehlermeldung
     string ReturnValueNoError;  // korrigierter Rückgabewert ohne Fehlermeldung
     string ErrorMessageText;        // Fehlermeldung bei Consistency Check
+    string timeStamp;
 
     bool LoadPreValue(void);
     string ShiftDecimal(string in, int _decShift);
@@ -40,6 +44,8 @@ public:
     string getReadout();
     string getReadoutParam(bool _rawValue, bool _noerror);
     string getReadoutError();
+    string getReadoutRate();
+    string getReadoutTimeStamp();
     void SavePreValue(float value, string time = "");
     string GetPreValue();
 

+ 2 - 2
code/main/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="bc6a014";
+const char* GIT_REV="016f408";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-05-06 20:21";
+const char* BUILD_TIME="2021-05-06 21:42";

+ 2 - 2
code/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="bc6a014";
+const char* GIT_REV="016f408";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-05-06 20:21";
+const char* BUILD_TIME="2021-05-06 21:42";

BIN
firmware/bootloader.bin


BIN
firmware/firmware.bin


BIN
firmware/html.zip


+ 32 - 0
sd-card/html/edit_config_param.html

@@ -518,6 +518,34 @@ textarea {
 				MQTT topic, in which the error status is reported (empty = no error)
 			</td>
 		</tr>
+		<tr>
+			<td width="20px"  style="padding-left: 40px;">
+				<input type="checkbox" id="MQTT_TopicRate_enabled" value="1"  onclick = 'InvertEnableItem("MQTT", "TopicRate")' unchecked >
+			</td>
+			<td  width="200px">
+				<class id="MQTT_TopicRate_text" style="color:black;">TopicRate</class>
+			</td>
+			<td>
+				<input type="text" id="MQTT_TopicRate_value1">
+			</td>
+			<td style="font-size: 80%;">
+				MQTT topic, in which the flow rate [units / minute] is reported
+			</td>
+		</tr>
+		<tr>
+			<td width="20px"  style="padding-left: 40px;">
+				<input type="checkbox" id="MQTT_TopicTimeStamp_enabled" value="1"  onclick = 'InvertEnableItem("MQTT", "TopicTimeStamp")' unchecked >
+			</td>
+			<td  width="200px">
+				<class id="MQTT_TopicTimeStamp_text" style="color:black;">TopicTimeStamp</class>
+			</td>
+			<td>
+				<input type="text" id="MQTT_TopicTimeStamp_value1">
+			</td>
+			<td style="font-size: 80%;">
+				MQTT topic, reporting the last correct readout
+			</td>
+		</tr>
 		<tr>
 			<td width="20px"  style="padding-left: 40px;">
 				<input type="checkbox" id="MQTT_ClientID_enabled" value="1"  onclick = 'InvertEnableItem("MQTT", "ClientID")' unchecked >
@@ -907,6 +935,8 @@ function UpdateInput() {
 	WriteParameter(param, category, "MQTT", "Uri", true);	
 	WriteParameter(param, category, "MQTT", "Topic", true);	
 	WriteParameter(param, category, "MQTT", "TopicError", true);	
+	WriteParameter(param, category, "MQTT", "TopicRate", true);	
+	WriteParameter(param, category, "MQTT", "TopicTimeStamp", true);	
 	WriteParameter(param, category, "MQTT", "ClientID", true);	
 	WriteParameter(param, category, "MQTT", "user", true);	
 	WriteParameter(param, category, "MQTT", "password", true);	
@@ -964,6 +994,8 @@ function ReadParameterAll()
 	ReadParameter(param, "MQTT", "Uri", true);	
 	ReadParameter(param, "MQTT", "Topic", true);	
 	ReadParameter(param, "MQTT", "TopicError", true);	
+	ReadParameter(param, "MQTT", "TopicRate", true);
+	ReadParameter(param, "MQTT", "TopicTimeStamp", true);
 	ReadParameter(param, "MQTT", "ClientID", true);	
 	ReadParameter(param, "MQTT", "user", true);	
 	ReadParameter(param, "MQTT", "password", true);	

+ 1 - 1
sd-card/html/gethost.js

@@ -9,7 +9,7 @@ function getbasepath(){
     {
 //        host = "http://192.168.2.118";          // jomjol interner test
 //        host = "http://192.168.178.26";          // jomjol interner test
-        host = "http://192.168.178.75";          // jomjol interner Real
+        host = "http://192.168.178.22";          // jomjol interner Real
 //        host = ".";                           // jomjol interner localhost   
 
     }

BIN
sd-card/html/html.zip


+ 2 - 0
sd-card/html/readconfigparam.js

@@ -84,6 +84,8 @@ function ParseConfig() {
      ParamAddValue(param, catname, "Uri");
      ParamAddValue(param, catname, "Topic");
      ParamAddValue(param, catname, "TopicError");
+     ParamAddValue(param, catname, "TopicRate");
+     ParamAddValue(param, catname, "TopicTimeStamp");
      ParamAddValue(param, catname, "ClientID");
      ParamAddValue(param, catname, "user");
      ParamAddValue(param, catname, "password");     

BIN
sd-card/html/sd-card - Verknüpfung.lnk


+ 1 - 1
sd-card/html/version.txt

@@ -1 +1 @@
-6.7.0
+6.8.0