diff --git a/README.md b/README.md index 9dd45821..8102bd08 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ In other cases you can contact the developer via email: 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; diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.h b/code/components/jomjol_flowcontroll/ClassFlowMQTT.h index 2ac29135..99035659 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.h +++ b/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; diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp index acbf565f..18afcc11 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp +++ b/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* lfc) { + FlowRateAct = 0; PreValueUse = false; PreValueAgeStartup = 30; AllowNegativeRates = false; @@ -150,6 +154,7 @@ ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector* 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(¤ttime); + localtime(¤ttime); + 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() { diff --git a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h b/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h index 435c6d48..3c8df529 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h +++ b/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(); diff --git a/code/main/version.cpp b/code/main/version.cpp index a9baceb0..68c969ab 100644 --- a/code/main/version.cpp +++ b/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"; \ No newline at end of file +const char* BUILD_TIME="2021-05-06 21:42"; \ No newline at end of file diff --git a/code/version.cpp b/code/version.cpp index a9baceb0..68c969ab 100644 --- a/code/version.cpp +++ b/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"; \ No newline at end of file +const char* BUILD_TIME="2021-05-06 21:42"; \ No newline at end of file diff --git a/firmware/bootloader.bin b/firmware/bootloader.bin index 636e3b94..069a8b89 100644 Binary files a/firmware/bootloader.bin and b/firmware/bootloader.bin differ diff --git a/firmware/firmware.bin b/firmware/firmware.bin index 87efda93..30c53a89 100644 Binary files a/firmware/firmware.bin and b/firmware/firmware.bin differ diff --git a/firmware/html.zip b/firmware/html.zip index 88f0c56d..d5078f8b 100644 Binary files a/firmware/html.zip and b/firmware/html.zip differ diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index 491cfa94..867ba103 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -518,6 +518,34 @@ textarea { MQTT topic, in which the error status is reported (empty = no error) + + + + + + TopicRate + + + + + + MQTT topic, in which the flow rate [units / minute] is reported + + + + + + + + TopicTimeStamp + + + + + + MQTT topic, reporting the last correct readout + + @@ -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); diff --git a/sd-card/html/gethost.js b/sd-card/html/gethost.js index 056a06e9..40a7c87a 100644 --- a/sd-card/html/gethost.js +++ b/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 } diff --git a/sd-card/html/html.zip b/sd-card/html/html.zip deleted file mode 100644 index 88f0c56d..00000000 Binary files a/sd-card/html/html.zip and /dev/null differ diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index e5f9516b..af7a0d00 100644 --- a/sd-card/html/readconfigparam.js +++ b/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"); diff --git a/sd-card/html/sd-card - Verknüpfung.lnk b/sd-card/html/sd-card - Verknüpfung.lnk new file mode 100644 index 00000000..4c6bfce3 Binary files /dev/null and b/sd-card/html/sd-card - Verknüpfung.lnk differ diff --git a/sd-card/html/version.txt b/sd-card/html/version.txt index f0e13c50..e029aa99 100644 --- a/sd-card/html/version.txt +++ b/sd-card/html/version.txt @@ -1 +1 @@ -6.7.0 +6.8.0