Rolling 20210506v2

This commit is contained in:
jomjol
2021-05-06 21:50:14 +02:00
parent 016f4088d4
commit d36cbde7aa
16 changed files with 104 additions and 14 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -518,6 +518,34 @@ textarea {
MQTT topic, in which the error status is reported (empty = no error) MQTT topic, in which the error status is reported (empty = no error)
</td> </td>
</tr> </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> <tr>
<td width="20px" style="padding-left: 40px;"> <td width="20px" style="padding-left: 40px;">
<input type="checkbox" id="MQTT_ClientID_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "ClientID")' unchecked > <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", "Uri", true);
WriteParameter(param, category, "MQTT", "Topic", true); WriteParameter(param, category, "MQTT", "Topic", true);
WriteParameter(param, category, "MQTT", "TopicError", 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", "ClientID", true);
WriteParameter(param, category, "MQTT", "user", true); WriteParameter(param, category, "MQTT", "user", true);
WriteParameter(param, category, "MQTT", "password", true); WriteParameter(param, category, "MQTT", "password", true);
@@ -964,6 +994,8 @@ function ReadParameterAll()
ReadParameter(param, "MQTT", "Uri", true); ReadParameter(param, "MQTT", "Uri", true);
ReadParameter(param, "MQTT", "Topic", true); ReadParameter(param, "MQTT", "Topic", true);
ReadParameter(param, "MQTT", "TopicError", true); ReadParameter(param, "MQTT", "TopicError", true);
ReadParameter(param, "MQTT", "TopicRate", true);
ReadParameter(param, "MQTT", "TopicTimeStamp", true);
ReadParameter(param, "MQTT", "ClientID", true); ReadParameter(param, "MQTT", "ClientID", true);
ReadParameter(param, "MQTT", "user", true); ReadParameter(param, "MQTT", "user", true);
ReadParameter(param, "MQTT", "password", true); ReadParameter(param, "MQTT", "password", true);

View File

@@ -9,7 +9,7 @@ function getbasepath(){
{ {
// host = "http://192.168.2.118"; // jomjol interner test // host = "http://192.168.2.118"; // jomjol interner test
// host = "http://192.168.178.26"; // 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 // host = "."; // jomjol interner localhost
} }

Binary file not shown.

View File

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

Binary file not shown.

View File

@@ -1 +1 @@
6.7.0 6.8.0