Răsfoiți Sursa

rolling 20210705

jomjol 4 ani în urmă
părinte
comite
2c6ce6fd07

+ 6 - 0
FeatureRequest.md

@@ -11,6 +11,12 @@
 
 
 ____
 ____
 
 
+#### #8 MQTT configurable readout intervall
+
+Make the readout intervall configurable via MQTT.
+
+* Change the mqtt part to receive and process input and not only sending
+
 #### #7 Extended Error Handling
 #### #7 Extended Error Handling
 
 
 Check different types of error (e.g. tflite not availabe) and generate an error on the html page.
 Check different types of error (e.g. tflite not availabe) and generate an error on the html page.

+ 5 - 0
README.md

@@ -47,6 +47,11 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
 
 
 
 
 
 
+##### Rolling - (2021-07-03)
+
+* Parameter `MaxRateValue` individual for each number
+* BugFix: MQTT server tried to connect even in case it was disabled
+
 ##### Rolling - (2021-07-01)
 ##### Rolling - (2021-07-01)
 
 
 * NEW FEATURE: adding support for more than 1 number on a meter (e.g. two different power readings)
 * NEW FEATURE: adding support for more than 1 number on a meter (e.g. two different power readings)

+ 1 - 0
code/components/jomjol_flowcontroll/ClassFlowControll.cpp

@@ -120,6 +120,7 @@ ClassFlow* ClassFlowControll::CreateClassFlow(std::string _type)
     }
     }
     if (toUpper(_type).compare("[MQTT]") == 0)
     if (toUpper(_type).compare("[MQTT]") == 0)
         cfc = new ClassFlowMQTT(&FlowControll);
         cfc = new ClassFlowMQTT(&FlowControll);
+        
     if (toUpper(_type).compare("[POSTPROCESSING]") == 0)
     if (toUpper(_type).compare("[POSTPROCESSING]") == 0)
     {
     {
         cfc = new ClassFlowPostProcessing(&FlowControll); 
         cfc = new ClassFlowPostProcessing(&FlowControll); 

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

@@ -24,6 +24,9 @@ void ClassFlowMQTT::SetInitialParameter(void)
     previousElement = NULL;
     previousElement = NULL;
     ListFlowControll = NULL; 
     ListFlowControll = NULL; 
     disabled = false;
     disabled = false;
+    MQTTenable = false;
+    
+    
 
 
 }       
 }       
 
 
@@ -108,6 +111,7 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
         mainerrortopic = maintopic + "/connection";
         mainerrortopic = maintopic + "/connection";
         MQTTInit(uri, clientname, user, password, mainerrortopic, 60); 
         MQTTInit(uri, clientname, user, password, mainerrortopic, 60); 
         MQTTPublish(mainerrortopic, "connected");
         MQTTPublish(mainerrortopic, "connected");
+        MQTTenable = true;
     }
     }
    
    
     return true;
     return true;
@@ -116,6 +120,9 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
 
 
 bool ClassFlowMQTT::doFlow(string zwtime)
 bool ClassFlowMQTT::doFlow(string zwtime)
 {
 {
+    if (!MQTTenable)
+        return true;
+
     std::string result;
     std::string result;
     std::string resulterror = "";
     std::string resulterror = "";
     std::string resultrate = "";
     std::string resultrate = "";

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

@@ -13,6 +13,7 @@ protected:
     std::string OldValue;
     std::string OldValue;
 	ClassFlowPostProcessing* flowpostprocessing;  
 	ClassFlowPostProcessing* flowpostprocessing;  
     std::string user, password; 
     std::string user, password; 
+    bool MQTTenable;
 
 
     std::string maintopic, mainerrortopic; 
     std::string maintopic, mainerrortopic; 
 	void SetInitialParameter(void);        
 	void SetInitialParameter(void);        

+ 36 - 18
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -249,15 +249,11 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
 {
 {
     string _digit, _decpos;
     string _digit, _decpos;
     int _pospunkt = _decsep.find_first_of(".");
     int _pospunkt = _decsep.find_first_of(".");
-    printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
+//    printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
     if (_pospunkt > -1)
     if (_pospunkt > -1)
-    {
         _digit = _decsep.substr(0, _pospunkt);
         _digit = _decsep.substr(0, _pospunkt);
-    }
     else
     else
-    {
         _digit = "default";
         _digit = "default";
-    }
 
 
     for (int j = 0; j < NUMBERS.size(); ++j)
     for (int j = 0; j < NUMBERS.size(); ++j)
     {
     {
@@ -271,6 +267,32 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
     }
     }
 }
 }
 
 
+void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value)
+{
+    string _digit, _decpos;
+    int _pospunkt = _decsep.find_first_of(".");
+//    printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
+    if (_pospunkt > -1)
+        _digit = _decsep.substr(0, _pospunkt);
+    else
+        _digit = "default";
+
+    for (int j = 0; j < NUMBERS.size(); ++j)
+    {
+        if (_digit == "default")                        // erstmal auf default setzen (falls sonst nichts gesetzt)
+        {
+            NUMBERS[j]->useMaxRateValue = true;
+            NUMBERS[j]->MaxRateValue = stof(_value);
+        }
+
+        if (NUMBERS[j]->name == _digit)
+        {
+            NUMBERS[j]->useMaxRateValue = true;
+            NUMBERS[j]->MaxRateValue = stof(_value);
+        }
+    }
+}
+
 
 
 bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
 bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
 {
 {
@@ -299,43 +321,39 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
         {
         {
             handleDecimalSeparator(zerlegt[0], zerlegt[1]);
             handleDecimalSeparator(zerlegt[0], zerlegt[1]);
         }
         }
+        if ((toUpper(_param) == "MAXRATEVALUE") && (zerlegt.size() > 1))
+        {
+            handleDecimalSeparator(zerlegt[0], zerlegt[1]);
+        }
 
 
-        if ((toUpper(zerlegt[0]) == "PREVALUEUSE") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "PREVALUEUSE") && (zerlegt.size() > 1))
         {
         {
             if (toUpper(zerlegt[1]) == "TRUE")
             if (toUpper(zerlegt[1]) == "TRUE")
             {
             {
                 PreValueUse = true;
                 PreValueUse = true;
             }
             }
         }
         }
-        if ((toUpper(zerlegt[0]) == "CHECKDIGITINCREASECONSISTENCY") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "CHECKDIGITINCREASECONSISTENCY") && (zerlegt.size() > 1))
         {
         {
             if (toUpper(zerlegt[1]) == "TRUE")
             if (toUpper(zerlegt[1]) == "TRUE")
                 for (_n = 0; _n < NUMBERS.size(); ++_n)
                 for (_n = 0; _n < NUMBERS.size(); ++_n)
                     NUMBERS[_n]->checkDigitIncreaseConsistency = true;
                     NUMBERS[_n]->checkDigitIncreaseConsistency = true;
         }        
         }        
-        if ((toUpper(zerlegt[0]) == "ALLOWNEGATIVERATES") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "ALLOWNEGATIVERATES") && (zerlegt.size() > 1))
         {
         {
             if (toUpper(zerlegt[1]) == "TRUE")
             if (toUpper(zerlegt[1]) == "TRUE")
                 for (_n = 0; _n < NUMBERS.size(); ++_n)
                 for (_n = 0; _n < NUMBERS.size(); ++_n)
                     NUMBERS[_n]->AllowNegativeRates = true;
                     NUMBERS[_n]->AllowNegativeRates = true;
         }
         }
-        if ((toUpper(zerlegt[0]) == "ERRORMESSAGE") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "ERRORMESSAGE") && (zerlegt.size() > 1))
         {
         {
             if (toUpper(zerlegt[1]) == "TRUE")
             if (toUpper(zerlegt[1]) == "TRUE")
                 ErrorMessage = true;
                 ErrorMessage = true;
         }
         }
-        if ((toUpper(zerlegt[0]) == "PREVALUEAGESTARTUP") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "PREVALUEAGESTARTUP") && (zerlegt.size() > 1))
         {
         {
             PreValueAgeStartup = std::stoi(zerlegt[1]);
             PreValueAgeStartup = std::stoi(zerlegt[1]);
         }
         }
-        if ((toUpper(zerlegt[0]) == "MAXRATEVALUE") && (zerlegt.size() > 1))
-        {
-            for (_n = 0; _n < NUMBERS.size(); ++_n)
-            {
-            NUMBERS[_n]->useMaxRateValue = true;
-            NUMBERS[_n]->MaxRateValue = std::stof(zerlegt[1]);
-            }
-        }
     }
     }
 
 
     if (PreValueUse) {
     if (PreValueUse) {

+ 2 - 8
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h

@@ -53,15 +53,8 @@ protected:
 
 
     bool PreValueUse;
     bool PreValueUse;
     int PreValueAgeStartup; 
     int PreValueAgeStartup; 
-//    bool AllowNegativeRates;
-//    float MaxRateValue;
-//    bool useMaxRateValue;
     bool ErrorMessage;
     bool ErrorMessage;
- //   bool PreValueOkay;
-//    bool checkDigitIncreaseConsistency;
-//    int DecimalShift;
-//    time_t lastvalue;
-//    float FlowRateAct;          // m3 / min
+
 
 
     ClassFlowAnalog* flowAnalog;
     ClassFlowAnalog* flowAnalog;
     ClassFlowDigit* flowDigit;    
     ClassFlowDigit* flowDigit;    
@@ -80,6 +73,7 @@ protected:
 
 
     void InitNUMBERS();
     void InitNUMBERS();
     void handleDecimalSeparator(string _decsep, string _value);
     void handleDecimalSeparator(string _decsep, string _value);
+    void handleMaxRateValue(string _decsep, string _value);
 
 
 
 
 public:
 public:

+ 2 - 2
code/main/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="45154cb";
+const char* GIT_REV="f243f4b";
 const char* GIT_TAG="";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-07-01 19:03";
+const char* BUILD_TIME="2021-07-04 06:46";

+ 2 - 2
code/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="45154cb";
+const char* GIT_REV="f243f4b";
 const char* GIT_TAG="";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2021-07-01 19:03";
+const char* BUILD_TIME="2021-07-04 06:46";

BIN
firmware/bootloader.bin


BIN
firmware/firmware.bin


BIN
firmware/html.zip


+ 17 - 16
sd-card/html/edit_config_param.html

@@ -410,20 +410,6 @@ textarea {
 				Set on "false" to ensure, that only positive changes are accepted (typically for counter)
 				Set on "false" to ensure, that only positive changes are accepted (typically for counter)
 			</td>
 			</td>
 		</tr>
 		</tr>
-		<tr>
-			<td width="20px"  style="padding-left: 40px;">
-				<input type="checkbox" id="PostProcessing_MaxRateValue_enabled" value="1"  onclick = 'InvertEnableItem("PostProcessing", "MaxRateValue")' unchecked >
-			</td>
-			<td  width="200px">
-				<class id="PostProcessing_MaxRateValue_text" style="color:black;">MaxRateValue</class>
-			</td>
-			<td>
-				<input type="number" id="PostProcessing_MaxRateValue_value1" size="13" min="0" step="any">
-			</td>
-			<td style="font-size: 80%;">
-				Maximum change of reading from one to the next readout
-			</td>
-		</tr>
 		<tr class="expert"  id="ex12">
 		<tr class="expert"  id="ex12">
 			<td width="20px"  style="padding-left: 40px;">
 			<td width="20px"  style="padding-left: 40px;">
 				<input type="checkbox" id="PostProcessing_ErrorMessage_enabled" value="1"  onclick = 'InvertEnableItem("PostProcessing", "ErrorMessage")' unchecked >
 				<input type="checkbox" id="PostProcessing_ErrorMessage_enabled" value="1"  onclick = 'InvertEnableItem("PostProcessing", "ErrorMessage")' unchecked >
@@ -484,6 +470,20 @@ textarea {
 				shift the digit separator within the digital digits (positiv and negativ)
 				shift the digit separator within the digital digits (positiv and negativ)
 			</td>
 			</td>
 		</tr>
 		</tr>
+		<tr>
+			<td width="20px"  style="padding-left: 40px;">
+				<input type="checkbox" id="PostProcessing_MaxRateValue_enabled" value="1"  onclick = 'InvertEnableItem("PostProcessing", "MaxRateValue")' unchecked >
+			</td>
+			<td  width="200px">
+				<class id="PostProcessing_MaxRateValue_text" style="color:black;">MaxRateValue</class>
+			</td>
+			<td>
+				<input type="number" id="PostProcessing_MaxRateValue_value1" size="13" min="0" step="any">
+			</td>
+			<td style="font-size: 80%;">
+				Maximum change of reading from one to the next readout
+			</td>
+		</tr>
 
 
 
 
 
 
@@ -722,7 +722,6 @@ function LoadConfigNeu() {
 		alert("Config.ini could not be loaded!\nPlease reload the page.");
 		alert("Config.ini could not be loaded!\nPlease reload the page.");
 		return;
 		return;
 	} 
 	} 
-//	loadConfig(basepath); 
 	ParseConfig();	
 	ParseConfig();	
 	param = getConfigParameters();
 	param = getConfigParameters();
 	category = getConfigCategory();
 	category = getConfigCategory();
@@ -942,11 +941,13 @@ function UpdateInputIndividual()
 	if (NUNBERSAkt != -1)
 	if (NUNBERSAkt != -1)
 	{
 	{
 		ReadParameter(param, "PostProcessing", "DecimalShift", true, false, NUNBERSAkt)		
 		ReadParameter(param, "PostProcessing", "DecimalShift", true, false, NUNBERSAkt)		
+		ReadParameter(param, "PostProcessing", "MaxRateValue", true, false, NUNBERSAkt)		
 	}
 	}
 
 
 	var sel = document.getElementById("Numbers_value1");
 	var sel = document.getElementById("Numbers_value1");
 	NUNBERSAkt = sel.selectedIndex;
 	NUNBERSAkt = sel.selectedIndex;
 	WriteParameter(param, category, "PostProcessing", "DecimalShift", true, false, 1, NUNBERSAkt);
 	WriteParameter(param, category, "PostProcessing", "DecimalShift", true, false, 1, NUNBERSAkt);
+	WriteParameter(param, category, "PostProcessing", "MaxRateValue", true, false, 1, NUNBERSAkt);
 }
 }
 
 
 function UpdateInput() {
 function UpdateInput() {
@@ -982,7 +983,7 @@ function UpdateInput() {
 	WriteParameter(param, category, "PostProcessing", "PreValueUse", true, true);		
 	WriteParameter(param, category, "PostProcessing", "PreValueUse", true, true);		
 	WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", true);		
 	WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", true);		
 	WriteParameter(param, category, "PostProcessing", "AllowNegativeRates", true, true);
 	WriteParameter(param, category, "PostProcessing", "AllowNegativeRates", true, true);
-	WriteParameter(param, category, "PostProcessing", "MaxRateValue", true);		
+//	WriteParameter(param, category, "PostProcessing", "MaxRateValue", true);		
 	WriteParameter(param, category, "PostProcessing", "ErrorMessage", true, true);
 	WriteParameter(param, category, "PostProcessing", "ErrorMessage", true, true);
 	WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
 	WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
 
 

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

@@ -8,8 +8,8 @@ function getbasepath(){
     if ((host == "127.0.0.1") || (host == "localhost"))
     if ((host == "127.0.0.1") || (host == "localhost"))
     {
     {
 //        host = "http://192.168.2.219";          // jomjol interner test
 //        host = "http://192.168.2.219";          // jomjol interner test
-        host = "http://192.168.178.47";          // jomjol interner test
-//        host = "http://192.168.178.22";          // jomjol interner Real
+//        host = "http://192.168.178.47";          // jomjol interner test
+        host = "http://192.168.178.22";          // jomjol interner Real
 
 
 //        host = ".";                           // jomjol interner localhost   
 //        host = ".";                           // jomjol interner localhost   
 
 

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

@@ -74,7 +74,7 @@ function ParseConfig() {
      ParamAddValue(param, catname, "PreValueUse");
      ParamAddValue(param, catname, "PreValueUse");
      ParamAddValue(param, catname, "PreValueAgeStartup");
      ParamAddValue(param, catname, "PreValueAgeStartup");
      ParamAddValue(param, catname, "AllowNegativeRates");
      ParamAddValue(param, catname, "AllowNegativeRates");
-     ParamAddValue(param, catname, "MaxRateValue");
+     ParamAddValue(param, catname, "MaxRateValue", 1, true);
      ParamAddValue(param, catname, "ErrorMessage");
      ParamAddValue(param, catname, "ErrorMessage");
      ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");     
      ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");     
 
 
@@ -476,7 +476,8 @@ function getNUMBERS(_name, _type, _create = true)
           for (_cat in param)
           for (_cat in param)
                for (_param in param[_cat])
                for (_param in param[_cat])
                     if (param[_cat][_param]["Numbers"] == true){
                     if (param[_cat][_param]["Numbers"] == true){
-                         _ret[_cat] = new Object();
+                         if (typeof  _ret[_cat] == 'undefined')
+                              _ret[_cat] = new Object();
                          _ret[_cat][_param] = new Object();
                          _ret[_cat][_param] = new Object();
                          _ret[_cat][_param]["found"] = false;
                          _ret[_cat][_param]["found"] = false;
                          _ret[_cat][_param]["enabled"] = false;
                          _ret[_cat][_param]["enabled"] = false;

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

@@ -1 +1 @@
-9.0.0
+9.1.0