Browse Source

rolling 20210705

jomjol 4 năm trước cách đây
mục cha
commit
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
 
 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)
 
 * 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)
         cfc = new ClassFlowMQTT(&FlowControll);
+        
     if (toUpper(_type).compare("[POSTPROCESSING]") == 0)
     {
         cfc = new ClassFlowPostProcessing(&FlowControll); 

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

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

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

@@ -13,6 +13,7 @@ protected:
     std::string OldValue;
 	ClassFlowPostProcessing* flowpostprocessing;  
     std::string user, password; 
+    bool MQTTenable;
 
     std::string maintopic, mainerrortopic; 
 	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;
     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)
-    {
         _digit = _decsep.substr(0, _pospunkt);
-    }
     else
-    {
         _digit = "default";
-    }
 
     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)
 {
@@ -299,43 +321,39 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
         {
             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")
             {
                 PreValueUse = true;
             }
         }
-        if ((toUpper(zerlegt[0]) == "CHECKDIGITINCREASECONSISTENCY") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "CHECKDIGITINCREASECONSISTENCY") && (zerlegt.size() > 1))
         {
             if (toUpper(zerlegt[1]) == "TRUE")
                 for (_n = 0; _n < NUMBERS.size(); ++_n)
                     NUMBERS[_n]->checkDigitIncreaseConsistency = true;
         }        
-        if ((toUpper(zerlegt[0]) == "ALLOWNEGATIVERATES") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "ALLOWNEGATIVERATES") && (zerlegt.size() > 1))
         {
             if (toUpper(zerlegt[1]) == "TRUE")
                 for (_n = 0; _n < NUMBERS.size(); ++_n)
                     NUMBERS[_n]->AllowNegativeRates = true;
         }
-        if ((toUpper(zerlegt[0]) == "ERRORMESSAGE") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "ERRORMESSAGE") && (zerlegt.size() > 1))
         {
             if (toUpper(zerlegt[1]) == "TRUE")
                 ErrorMessage = true;
         }
-        if ((toUpper(zerlegt[0]) == "PREVALUEAGESTARTUP") && (zerlegt.size() > 1))
+        if ((toUpper(_param) == "PREVALUEAGESTARTUP") && (zerlegt.size() > 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) {

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

@@ -53,15 +53,8 @@ protected:
 
     bool PreValueUse;
     int PreValueAgeStartup; 
-//    bool AllowNegativeRates;
-//    float MaxRateValue;
-//    bool useMaxRateValue;
     bool ErrorMessage;
- //   bool PreValueOkay;
-//    bool checkDigitIncreaseConsistency;
-//    int DecimalShift;
-//    time_t lastvalue;
-//    float FlowRateAct;          // m3 / min
+
 
     ClassFlowAnalog* flowAnalog;
     ClassFlowDigit* flowDigit;    
@@ -80,6 +73,7 @@ protected:
 
     void InitNUMBERS();
     void handleDecimalSeparator(string _decsep, string _value);
+    void handleMaxRateValue(string _decsep, string _value);
 
 
 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_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_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)
 			</td>
 		</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">
 			<td width="20px"  style="padding-left: 40px;">
 				<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)
 			</td>
 		</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.");
 		return;
 	} 
-//	loadConfig(basepath); 
 	ParseConfig();	
 	param = getConfigParameters();
 	category = getConfigCategory();
@@ -942,11 +941,13 @@ function UpdateInputIndividual()
 	if (NUNBERSAkt != -1)
 	{
 		ReadParameter(param, "PostProcessing", "DecimalShift", true, false, NUNBERSAkt)		
+		ReadParameter(param, "PostProcessing", "MaxRateValue", true, false, NUNBERSAkt)		
 	}
 
 	var sel = document.getElementById("Numbers_value1");
 	NUNBERSAkt = sel.selectedIndex;
 	WriteParameter(param, category, "PostProcessing", "DecimalShift", true, false, 1, NUNBERSAkt);
+	WriteParameter(param, category, "PostProcessing", "MaxRateValue", true, false, 1, NUNBERSAkt);
 }
 
 function UpdateInput() {
@@ -982,7 +983,7 @@ function UpdateInput() {
 	WriteParameter(param, category, "PostProcessing", "PreValueUse", true, true);		
 	WriteParameter(param, category, "PostProcessing", "PreValueAgeStartup", 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", "CheckDigitIncreaseConsistency", true, true);
 

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

@@ -8,8 +8,8 @@ function getbasepath(){
     if ((host == "127.0.0.1") || (host == "localhost"))
     {
 //        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   
 

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

@@ -74,7 +74,7 @@ function ParseConfig() {
      ParamAddValue(param, catname, "PreValueUse");
      ParamAddValue(param, catname, "PreValueAgeStartup");
      ParamAddValue(param, catname, "AllowNegativeRates");
-     ParamAddValue(param, catname, "MaxRateValue");
+     ParamAddValue(param, catname, "MaxRateValue", 1, true);
      ParamAddValue(param, catname, "ErrorMessage");
      ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");     
 
@@ -476,7 +476,8 @@ function getNUMBERS(_name, _type, _create = true)
           for (_cat in param)
                for (_param in param[_cat])
                     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]["found"] = false;
                          _ret[_cat][_param]["enabled"] = false;

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

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