Rolling 20210701

This commit is contained in:
jomjol
2021-07-01 19:47:44 +02:00
parent 45154cb55c
commit f243f4b8ea
32 changed files with 227 additions and 221 deletions

View File

@@ -11,6 +11,16 @@
____ ____
#### #7 Extended Error Handling
Check different types of error (e.g. tflite not availabe) and generate an error on the html page.
To do:
* Make a list of "important" errors
* Implement a checking algo
* Extend the firmware and html page for the error handling
#### #6 Check for double ROI names #### #6 Check for double ROI names
Check during configuration, that ROI names are unique. Check during configuration, that ROI names are unique.

View File

@@ -12,6 +12,8 @@ respectively ESP32-Cam housing only: https://www.thingiverse.com/thing:4571627
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/watermeter.jpg" width="600"> <img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/watermeter.jpg" width="600">
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/powermeter.jpg" width="600">
@@ -45,7 +47,25 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
##### Rolling - (2021-06-17) ##### Rolling - (2021-07-01)
* NEW FEATURE: adding support for more than 1 number on a meter (e.g. two different power readings)
Therefore the concept of "Numbers" is implemented - a bunch of digits and analog counters are combined to one number. You can define them during setup of digital and analog ROIs:
<img src="https://raw.githubusercontent.com/jomjol/AI-on-the-edge-device/master/images/numbers.jpg" width="300">
* MQTT: standardization of the naming - only the main topic needs to be specified. The subtopics will be named automatically. This is necessary to handle the multi number option.
**ATTENTION**: the parameter `maintopic` needs to be set
* Remark:
* This is an early stage - do only use it on a test system and make a backup of your configuration.
* The documentation is not updated yet.
* <span style="color: red;">**ATTENTION: the configuration and prevalue files are modified automatically and will not be backward compatible!**</span>
Rolling - (2021-06-17)
* bug fix setting hostname, Flash-LED not off during reboot * bug fix setting hostname, Flash-LED not off during reboot

Binary file not shown.

View File

@@ -94,6 +94,23 @@ string ClassFlow::getReadout()
return string(); return string();
} }
std::string ClassFlow::GetParameterName(std::string _input)
{
string _param;
int _pospunkt = _input.find_first_of(".");
if (_pospunkt > -1)
{
_param = _input.substr(_pospunkt+1, _input.length() - _pospunkt - 1);
}
else
{
_param = _input;
}
// printf("Parameter: %s, Pospunkt: %d\n", _param.c_str(), _pospunkt);
return _param;
}
bool ClassFlow::getNextLine(FILE* pfile, string *rt) bool ClassFlow::getNextLine(FILE* pfile, string *rt)
{ {
char zw[1024]; char zw[1024];
@@ -102,13 +119,13 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
*rt = ""; *rt = "";
return false; return false;
} }
fgets(zw, 1024, pfile); if (!fgets(zw, 1024, pfile))
printf("%s", zw);
if ((strlen(zw) == 0) && feof(pfile))
{ {
*rt = ""; *rt = "";
printf("END OF FILE\n");
return false; return false;
} }
printf("%s", zw);
*rt = zw; *rt = zw;
*rt = trim(*rt); *rt = trim(*rt);
while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '[')) // Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph

View File

@@ -37,6 +37,8 @@ protected:
virtual void SetInitialParameter(void); virtual void SetInitialParameter(void);
std::string GetParameterName(std::string _input);
bool disabled; bool disabled;
public: public:

View File

@@ -275,7 +275,7 @@ string ClassFlowControll::getReadoutAll(int _type)
out = out + numbers[i]->ReturnValue; out = out + numbers[i]->ReturnValue;
break; break;
case READOUT_TYPE_PREVALUE: case READOUT_TYPE_PREVALUE:
out = out + std::to_string(numbers[i]->PreValue); out = out + numbers[i]->ReturnPreValue;
break; break;
case READOUT_TYPE_RAWVALUE: case READOUT_TYPE_RAWVALUE:
out = out + numbers[i]->ReturnRawValue; out = out + numbers[i]->ReturnRawValue;

View File

@@ -13,6 +13,9 @@ void ClassFlowMQTT::SetInitialParameter(void)
topicError = ""; topicError = "";
topicRate = ""; topicRate = "";
topicTimeStamp = ""; topicTimeStamp = "";
maintopic = "";
mainerrortopic = "";
clientname = "watermeter"; clientname = "watermeter";
OldValue = ""; OldValue = "";
flowpostprocessing = NULL; flowpostprocessing = NULL;
@@ -88,33 +91,23 @@ bool ClassFlowMQTT::ReadParameter(FILE* pfile, string& aktparamgraph)
{ {
this->uri = zerlegt[1]; this->uri = zerlegt[1];
} }
if ((toUpper(zerlegt[0]) == "TOPIC") && (zerlegt.size() > 1))
{
this->topic = zerlegt[1];
}
if ((toUpper(zerlegt[0]) == "TOPICERROR") && (zerlegt.size() > 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];
} }
if (((toUpper(zerlegt[0]) == "TOPIC") || (toUpper(zerlegt[0]) == "MAINTOPIC")) && (zerlegt.size() > 1))
{
maintopic = zerlegt[1];
}
} }
if ((uri.length() > 0) && (topic.length() > 0)) if ((uri.length() > 0) && (maintopic.length() > 0))
{ {
MQTTInit(uri, clientname, user, password, topicError, 60); mainerrortopic = maintopic + "/connection";
MQTTInit(uri, clientname, user, password, mainerrortopic, 60);
MQTTPublish(mainerrortopic, "connected");
} }
return true; return true;
@@ -128,13 +121,39 @@ bool ClassFlowMQTT::doFlow(string zwtime)
std::string resultrate = ""; std::string resultrate = "";
std::string resulttimestamp = ""; std::string resulttimestamp = "";
string zw = ""; string zw = "";
string namenumber = "";
MQTTPublish(mainerrortopic, "connected");
if (flowpostprocessing) if (flowpostprocessing)
{ {
result = flowpostprocessing->getReadoutParam(false, true); std::vector<NumberPost*> NUMBERS = flowpostprocessing->GetNumbers();
resulterror = flowpostprocessing->getReadoutError();
resultrate = flowpostprocessing->getReadoutRate(); for (int i = 0; i < NUMBERS.size(); ++i)
resulttimestamp = flowpostprocessing->getReadoutTimeStamp(); {
result = NUMBERS[i]->ReturnValueNoError;
resulterror = NUMBERS[i]->ErrorMessageText;
resultrate = std::to_string(NUMBERS[i]->FlowRateAct);
resulttimestamp = NUMBERS[i]->timeStamp;
namenumber = NUMBERS[i]->name;
if (namenumber == "default")
namenumber = maintopic + "/";
else
namenumber = maintopic + "/" + namenumber + "/";
zw = namenumber + "value";
MQTTPublish(zw, result);
zw = namenumber + "error";
MQTTPublish(zw, resulterror, 1);
zw = namenumber + "rate";
MQTTPublish(zw, resultrate);
zw = namenumber + "timestamp";
MQTTPublish(zw, resulttimestamp);
}
} }
else else
{ {
@@ -149,25 +168,9 @@ bool ClassFlowMQTT::doFlow(string zwtime)
result = result + "\t" + zw; result = result + "\t" + zw;
} }
} }
MQTTPublish(topic, result);
} }
MQTTPublish(topic, result);
if (topicError.length() > 0) {
if (resulterror.length() == 0)
{
resulterror = " ";
}
MQTTPublish(topicError, resulterror, 1);
}
if (topicRate.length() > 0) {
MQTTPublish(topicRate, resultrate);
}
if (topicTimeStamp.length() > 0) {
MQTTPublish(topicTimeStamp, resulttimestamp);
}
OldValue = result; OldValue = result;

View File

@@ -12,7 +12,9 @@ protected:
std::string uri, topic, topicError, clientname, topicRate, topicTimeStamp; 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;
std::string maintopic, mainerrortopic;
void SetInitialParameter(void); void SetInitialParameter(void);
public: public:

View File

@@ -28,10 +28,11 @@ string ClassFlowPostProcessing::GetPreValue(std::string _number)
if (NUMBERS[i]->name == _number) if (NUMBERS[i]->name == _number)
index = i; index = i;
result = RundeOutput(NUMBERS[index]->PreValue, -NUMBERS[index]->DecimalShift); // result = RundeOutput(NUMBERS[index]->PreValue, -NUMBERS[index]->DecimalShift);
result = RundeOutput(NUMBERS[index]->PreValue, NUMBERS[index]->Nachkomma);
if (NUMBERS[index]->digit_roi && NUMBERS[index]->analog_roi) // if (NUMBERS[index]->digit_roi && NUMBERS[index]->analog_roi)
result = RundeOutput(NUMBERS[index]->PreValue, NUMBERS[index]->AnzahlAnalog - NUMBERS[index]->DecimalShift); // result = RundeOutput(NUMBERS[index]->PreValue, NUMBERS[index]->AnzahlAnalog - NUMBERS[index]->DecimalShift);
return result; return result;
} }
@@ -83,6 +84,7 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
if (NUMBERS[j]->name == name) if (NUMBERS[j]->name == name)
{ {
NUMBERS[j]->PreValue = stof(zwvalue.c_str()); NUMBERS[j]->PreValue = stof(zwvalue.c_str());
NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
time_t tStart; time_t tStart;
int yy, month, dd, hh, mm, ss; int yy, month, dd, hh, mm, ss;
@@ -247,10 +249,10 @@ 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", _name.c_str(), _pospunkt); printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
if (_pospunkt > -1) if (_pospunkt > -1)
{ {
_digit = _decsep.substr(_pospunkt+1, _decsep.length() - _pospunkt - 1); _digit = _decsep.substr(0, _pospunkt);
} }
else else
{ {
@@ -264,6 +266,8 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
if (NUMBERS[j]->name == _digit) if (NUMBERS[j]->name == _digit)
NUMBERS[j]->DecimalShift = stoi(_value); NUMBERS[j]->DecimalShift = stoi(_value);
NUMBERS[j]->Nachkomma = NUMBERS[j]->AnzahlAnalog - NUMBERS[j]->DecimalShift;
} }
} }
@@ -289,7 +293,9 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph)) while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
{ {
zerlegt = this->ZerlegeZeile(aktparamgraph); zerlegt = this->ZerlegeZeile(aktparamgraph);
if ((toUpper(zerlegt[0].substr(0, 12)) == "DECIMALSHIFT") && (zerlegt.size() > 1)) std::string _param = GetParameterName(zerlegt[0]);
if ((toUpper(_param) == "DECIMALSHIFT") && (zerlegt.size() > 1))
{ {
handleDecimalSeparator(zerlegt[0], zerlegt[1]); handleDecimalSeparator(zerlegt[0], zerlegt[1]);
} }
@@ -364,8 +370,10 @@ void ClassFlowPostProcessing::InitNUMBERS()
} }
} }
flowDigit->UpdateNameNumbers(&name_numbers); if (flowDigit)
flowAnalog->UpdateNameNumbers(&name_numbers); flowDigit->UpdateNameNumbers(&name_numbers);
if (flowAnalog)
flowAnalog->UpdateNameNumbers(&name_numbers);
printf("Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d\n", name_numbers.size(), anzDIGIT, anzANALOG); printf("Anzahl NUMBERS: %d - DIGITS: %d, ANALOG: %d\n", name_numbers.size(), anzDIGIT, anzANALOG);
@@ -398,6 +406,7 @@ void ClassFlowPostProcessing::InitNUMBERS()
_number->ReturnValue = ""; // korrigierter Rückgabewert, ggf. mit Fehlermeldung _number->ReturnValue = ""; // korrigierter Rückgabewert, ggf. mit Fehlermeldung
_number->ReturnValueNoError = ""; // korrigierter Rückgabewert ohne Fehlermeldung _number->ReturnValueNoError = ""; // korrigierter Rückgabewert ohne Fehlermeldung
_number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check _number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check
_number->ReturnPreValue = "";
_number->PreValueOkay = false; _number->PreValueOkay = false;
_number->AllowNegativeRates = false; _number->AllowNegativeRates = false;
_number->MaxRateValue = 0.1; _number->MaxRateValue = 0.1;
@@ -414,6 +423,8 @@ void ClassFlowPostProcessing::InitNUMBERS()
_number->ReturnValueNoError = ""; // korrigierter Rückgabewert ohne Fehlermeldung _number->ReturnValueNoError = ""; // korrigierter Rückgabewert ohne Fehlermeldung
_number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check _number->ErrorMessageText = ""; // Fehlermeldung bei Consistency Check
_number->Nachkomma = _number->AnzahlAnalog;
NUMBERS.push_back(_number); NUMBERS.push_back(_number);
} }
@@ -519,6 +530,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
NUMBERS[j]->PreValueOkay = true; NUMBERS[j]->PreValueOkay = true;
NUMBERS[j]->PreValue = NUMBERS[j]->Value; NUMBERS[j]->PreValue = NUMBERS[j]->Value;
NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
NUMBERS[j]->lastvalue = flowMakeImage->getTimeImageTaken(); NUMBERS[j]->lastvalue = flowMakeImage->getTimeImageTaken();
zwtime = ConvertTimeToString(NUMBERS[j]->lastvalue, PREVALUE_TIME_FORMAT_OUTPUT); zwtime = ConvertTimeToString(NUMBERS[j]->lastvalue, PREVALUE_TIME_FORMAT_OUTPUT);
@@ -547,9 +559,9 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
if (NUMBERS[j]->useMaxRateValue && (abs(NUMBERS[j]->Value - NUMBERS[j]->PreValue) > NUMBERS[j]->MaxRateValue)) if (NUMBERS[j]->useMaxRateValue && (abs(NUMBERS[j]->Value - NUMBERS[j]->PreValue) > NUMBERS[j]->MaxRateValue))
{ {
NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + zwvalue + " - Pre: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->AnzahlAnalog - NUMBERS[j]->DecimalShift) + " "; NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma) + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma) + " ";
NUMBERS[j]->Value = NUMBERS[j]->PreValue; NUMBERS[j]->Value = NUMBERS[j]->PreValue;
zwvalue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->AnzahlAnalog - NUMBERS[j]->DecimalShift); zwvalue = RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma);
} }
NUMBERS[j]->ReturnValueNoError = zwvalue; NUMBERS[j]->ReturnValueNoError = zwvalue;
@@ -566,6 +578,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
if (NUMBERS[j]->ErrorMessageText.length() == 0) if (NUMBERS[j]->ErrorMessageText.length() == 0)
{ {
NUMBERS[j]->PreValue = NUMBERS[j]->Value; NUMBERS[j]->PreValue = NUMBERS[j]->Value;
NUMBERS[j]->ReturnPreValue = RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
NUMBERS[j]->ErrorMessageText = "no error"; NUMBERS[j]->ErrorMessageText = "no error";
UpdatePreValueINI = true; UpdatePreValueINI = true;
} }

View File

@@ -23,11 +23,13 @@ struct NumberPost {
float Value; // letzer ausgelesener Wert, inkl. Korrekturen float Value; // letzer ausgelesener Wert, inkl. Korrekturen
string ReturnRawValue; // Rohwert (mit N & führenden 0) string ReturnRawValue; // Rohwert (mit N & führenden 0)
string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung string ReturnValue; // korrigierter Rückgabewert, ggf. mit Fehlermeldung
string ReturnValueNoError; // korrigierter Rückgabewert ohne Fehlermeldung string ReturnPreValue; // korrigierter Rückgabewert ohne Fehlermeldung
string ReturnValueNoError;
string ErrorMessageText; // Fehlermeldung bei Consistency Check string ErrorMessageText; // Fehlermeldung bei Consistency Check
int AnzahlAnalog; int AnzahlAnalog;
int AnzahlDigital; int AnzahlDigital;
int DecimalShift; int DecimalShift;
int Nachkomma;
// ClassFlowAnalog* ANALOG; // ClassFlowAnalog* ANALOG;
// ClassFlowDigit* DIGIT; // ClassFlowDigit* DIGIT;

View File

@@ -387,7 +387,7 @@ httpd_handle_t start_webserver(void)
httpd_config_t config = { }; httpd_config_t config = { };
config.task_priority = tskIDLE_PRIORITY+5; config.task_priority = tskIDLE_PRIORITY+5;
config.stack_size = 32384; // bei 32k stürzt das Programm beim Bilderaufnehmen ab config.stack_size = 32768; // bei 32k stürzt das Programm beim Bilderaufnehmen ab
config.core_id = tskNO_AFFINITY; config.core_id = tskNO_AFFINITY;
config.server_port = 80; config.server_port = 80;
config.ctrl_port = 32768; config.ctrl_port = 32768;

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="f4edd36"; const char* GIT_REV="45154cb";
const char* GIT_TAG=""; const char* GIT_TAG="";
const char* GIT_BRANCH="rolling"; const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-06-17 20:14"; const char* BUILD_TIME="2021-07-01 19:03";

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="f4edd36"; const char* GIT_REV="45154cb";
const char* GIT_TAG=""; const char* GIT_TAG="";
const char* GIT_BRANCH="rolling"; const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-06-17 20:14"; const char* BUILD_TIME="2021-07-01 19:03";

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
images/numbers.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
images/powermeter.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -18,7 +18,7 @@ InitialMirror= false
AlignmentAlgo = Default AlignmentAlgo = Default
[Digits] [Digits]
Model = /config/dig0901s1q.tflite Model = /config/dig1030s1q.tflite
;LogImageLocation = /log/digit ;LogImageLocation = /log/digit
;LogfileRetentionInDays = 3 ;LogfileRetentionInDays = 3
ModelInputSize = 20 32 ModelInputSize = 20 32

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -69,10 +69,16 @@ th, td {
<div id="div1"> <div id="div1">
<table>
<tr>
<td><canvas id="canvas" crossorigin></canvas></td>
</tr>
</table>
<p> <p>
<table> <table>
<tr> <tr>
<class id="Numbers_text" style="color:black;">Number: </class> <class id="Numbers_text" style="color:black;"><b>Number: </b></class>
<select id="Numbers_value1" onchange="numberChanged()"> <select id="Numbers_value1" onchange="numberChanged()">
<option value="0" selected>default</option> <option value="0" selected>default</option>
<option value="1" >NT</option> <option value="1" >NT</option>
@@ -85,12 +91,6 @@ th, td {
</table> </table>
</p> </p>
<table>
<tr>
<td><canvas id="canvas" crossorigin></canvas></td>
</tr>
</table>
<table> <table>
<tr> <tr>
<td><input class="button" type="submit" id= "newROI" name="newROI" onclick="newROI()" value="New ROI (after current)"></td> <td><input class="button" type="submit" id= "newROI" name="newROI" onclick="newROI()" value="New ROI (after current)"></td>
@@ -268,7 +268,6 @@ function UpdateROIs(){
document.getElementById("newROI").disabled = false; document.getElementById("newROI").disabled = false;
document.getElementById("deleteROI").disabled = true; document.getElementById("deleteROI").disabled = true;
document.getElementById("index").disabled = true; document.getElementById("index").disabled = true;
document.getElementById("saveroi").disabled = true;
document.getElementById("renameROI").disabled = true; document.getElementById("renameROI").disabled = true;
document.getElementById("moveNext").disabled = true; document.getElementById("moveNext").disabled = true;
document.getElementById("movePrevious").disabled = true; document.getElementById("movePrevious").disabled = true;
@@ -280,7 +279,6 @@ function UpdateROIs(){
document.getElementById("deleteROI").disabled = false; document.getElementById("deleteROI").disabled = false;
document.getElementById("renameROI").disabled = false; document.getElementById("renameROI").disabled = false;
document.getElementById("index").disabled = false; document.getElementById("index").disabled = false;
document.getElementById("saveroi").disabled = false;
} }
var _index = document.getElementById("index"); var _index = document.getElementById("index");

View File

@@ -41,7 +41,6 @@ textarea {
</table> </table>
<script type="text/javascript" src="./gethost.js"></script> <script type="text/javascript" src="./gethost.js"></script>
<script type="text/javascript" src="./readconfig.js"></script>
<script type="text/javascript" src="./readconfigcommon.js"></script> <script type="text/javascript" src="./readconfigcommon.js"></script>
<script type="text/javascript"> <script type="text/javascript">

View File

@@ -506,58 +506,18 @@ textarea {
</tr> </tr>
<tr> <tr>
<td width="20px" style="padding-left: 40px;"> <td width="20px" style="padding-left: 40px;">
<input type="checkbox" id="MQTT_Topic_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "Topic")' unchecked > <input type="checkbox" id="MQTT_MainTopic_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "MainTopic")' unchecked >
</td> </td>
<td width="200px"> <td width="200px">
<class id="MQTT_Topic_text" style="color:black;">Topic</class> <class id="MQTT_MainTopic_text" style="color:black;">MainTopic</class>
</td> </td>
<td> <td>
<input type="text" id="MQTT_Topic_value1"> <input type="text" id="MQTT_MainTopic_value1">
</td> </td>
<td style="font-size: 80%;"> <td style="font-size: 80%;">
MQTT topic, in which the value is registered MQTT main topic, under which the counters are published. The single value will be published with the following key: MAINTOPIC/VALUE_NAME/PARAMTER <br>
</td> where parameters are: value, rate, timestamp, error<br>
</tr> The general connection status can be found in MAINTOPiC"/CONNECTION
<tr>
<td width="20px" style="padding-left: 40px;">
<input type="checkbox" id="MQTT_TopicError_enabled" value="1" onclick = 'InvertEnableItem("MQTT", "TopicError")' unchecked >
</td>
<td width="200px">
<class id="MQTT_TopicError_text" style="color:black;">TopicError</class>
</td>
<td>
<input type="text" id="MQTT_TopicError_value1">
</td>
<td style="font-size: 80%;">
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> </td>
</tr> </tr>
<tr> <tr>
@@ -762,7 +722,7 @@ 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); // loadConfig(basepath);
ParseConfig(); ParseConfig();
param = getConfigParameters(); param = getConfigParameters();
category = getConfigCategory(); category = getConfigCategory();
@@ -804,7 +764,7 @@ function getParameterByName(name, url = window.location.href) {
function WriteParameter(_param, _category, _cat, _name, _optional, _select = false, _anzpara = 1, _number = -1){ function WriteParameter(_param, _category, _cat, _name, _optional, _select = false, _anzpara = 1, _number = -1){
if (_number > -1) if (_number > -1)
{ {
if (NUMBERS[_number][_cat][_name]["found"]){ {
if (_optional) { if (_optional) {
document.getElementById(_cat+"_"+_name+"_enabled").checked = _param[_cat][_name]["enabled"]; document.getElementById(_cat+"_"+_name+"_enabled").checked = _param[_cat][_name]["enabled"];
for (var j = 1; j <= _anzpara; ++j) for (var j = 1; j <= _anzpara; ++j)
@@ -827,19 +787,10 @@ function WriteParameter(_param, _category, _cat, _name, _optional, _select = fal
document.getElementById(_cat+"_"+_name+"_value"+j).value = NUMBERS[_number][_cat][_name]["value"+j]; document.getElementById(_cat+"_"+_name+"_value"+j).value = NUMBERS[_number][_cat][_name]["value"+j];
} }
} }
else {
if (_optional) {
document.getElementById(_cat+"_"+_name+"_enabled").disabled = true;
for (var j = 1; j <= _anzpara; ++j) {
document.getElementById(_cat+"_"+_name+"_value"+j).disabled = true;
}
}
document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"
}
} }
else else
{ {
if (_param[_cat][_name]["found"]){ {
if (_optional) { if (_optional) {
document.getElementById(_cat+"_"+_name+"_enabled").checked = _param[_cat][_name]["enabled"]; document.getElementById(_cat+"_"+_name+"_enabled").checked = _param[_cat][_name]["enabled"];
for (var j = 1; j <= _anzpara; ++j) for (var j = 1; j <= _anzpara; ++j)
@@ -862,15 +813,6 @@ function WriteParameter(_param, _category, _cat, _name, _optional, _select = fal
document.getElementById(_cat+"_"+_name+"_value"+j).value = _param[_cat][_name]["value"+j]; document.getElementById(_cat+"_"+_name+"_value"+j).value = _param[_cat][_name]["value"+j];
} }
} }
else {
if (_optional) {
document.getElementById(_cat+"_"+_name+"_enabled").disabled = true;
for (var j = 1; j <= _anzpara; ++j) {
document.getElementById(_cat+"_"+_name+"_value"+j).disabled = true;
}
}
document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"
}
} }
///////////////// am Ende, falls Kategorie als gesamtes nicht ausgewählt --> deaktivieren ///////////////// am Ende, falls Kategorie als gesamtes nicht ausgewählt --> deaktivieren
@@ -917,7 +859,7 @@ function InvertEnableItem(_cat, _param)
function EnDisableItem(_status, _param, _category, _cat, _name, _optional, _number = -1) function EnDisableItem(_status, _param, _category, _cat, _name, _optional, _number = -1)
{ {
_status = _param[_cat][_name]["found"] && _category[_cat]["enabled"]; _status = _category[_cat]["enabled"];
_color = "color:lightgrey;"; _color = "color:lightgrey;";
if (_status) { if (_status) {
@@ -965,35 +907,31 @@ function ReadParameter(_param, _cat, _name, _optional, _select = false, _number
if (_cat == "Analog") if (_cat == "Analog")
_cat = "analog" _cat = "analog"
if (NUMBERS[_number][_cat][_name]["found"]){ if (_optional) {
if (_optional) { NUMBERS[_number][_cat][_name]["enabled"] = document.getElementById(_cat+"_"+_name+"_enabled").checked;
NUMBERS[_number][_cat][_name]["enabled"] = document.getElementById(_cat+"_"+_name+"_enabled").checked; }
} if (_select) {
if (_select) { var sel = document.getElementById(_cat+"_"+_name+"_value1");
var sel = document.getElementById(_cat+"_"+_name+"_value1"); NUMBERS[_number][_cat][_name]["value1"] = sel.options[sel.selectedIndex].text;
NUMBERS[_number][_cat][_name]["value1"] = sel.options[sel.selectedIndex].text; }
} else {
else { for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) { NUMBERS[_number][_cat][_name]["value"+j] = document.getElementById(_cat+"_"+_name+"_value"+j).value;
NUMBERS[_number][_cat][_name]["value"+j] = document.getElementById(_cat+"_"+_name+"_value"+j).value;
}
} }
} }
} }
else else
{ {
if (_param[_cat][_name]["found"]){ if (_optional) {
if (_optional) { _param[_cat][_name]["enabled"] = document.getElementById(_cat+"_"+_name+"_enabled").checked;
_param[_cat][_name]["enabled"] = document.getElementById(_cat+"_"+_name+"_enabled").checked; }
} if (_select) {
if (_select) { var sel = document.getElementById(_cat+"_"+_name+"_value1");
var sel = document.getElementById(_cat+"_"+_name+"_value1"); _param[_cat][_name]["value1"] = sel.options[sel.selectedIndex].text;
_param[_cat][_name]["value1"] = sel.options[sel.selectedIndex].text; }
} else {
else { for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) { _param[_cat][_name]["value"+j] = document.getElementById(_cat+"_"+_name+"_value"+j).value;
_param[_cat][_name]["value"+j] = document.getElementById(_cat+"_"+_name+"_value"+j).value;
}
} }
} }
} }
@@ -1049,10 +987,7 @@ function UpdateInput() {
WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true, true); WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
WriteParameter(param, category, "MQTT", "Uri", true); WriteParameter(param, category, "MQTT", "Uri", true);
WriteParameter(param, category, "MQTT", "Topic", true); WriteParameter(param, category, "MQTT", "MainTopic", 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);
@@ -1107,10 +1042,7 @@ function ReadParameterAll()
ReadParameter(param, "PostProcessing", "CheckDigitIncreaseConsistency", true, true); ReadParameter(param, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
ReadParameter(param, "MQTT", "Uri", true); ReadParameter(param, "MQTT", "Uri", true);
ReadParameter(param, "MQTT", "Topic", true); ReadParameter(param, "MQTT", "MainTopic", 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);
@@ -1127,7 +1059,7 @@ function ReadParameterAll()
UpdateInputIndividual(); UpdateInputIndividual();
FormatDecimalValue(param, "PostProcessing", "MaxRateValue"); // FormatDecimalValue(param, "PostProcessing", "MaxRateValue");
} }
function WriteConfig(){ function WriteConfig(){
@@ -1147,6 +1079,7 @@ function UpdateAfterCategoryCheck() {
ReadParameterAll(); ReadParameterAll();
category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked; category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked;
category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked; category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked;
category["MQTT"]["enabled"] = document.getElementById("Category_MQTT_enabled").checked;
UpdateInput(); UpdateInput();
UpdateInputIndividual(); UpdateInputIndividual();
} }
@@ -1176,10 +1109,6 @@ function saveTextAsFile()
ReadParameterAll(); ReadParameterAll();
WriteConfigININew(); WriteConfigININew();
SaveConfigToServer(basepath); SaveConfigToServer(basepath);
// var textToSave = WriteConfig();
// FileDeleteOnServer("/config/config.ini", basepath);
// FileSendContent(textToSave, "/config/config.ini", basepath);
} }
} }

View File

@@ -59,10 +59,17 @@ th, td {
Edit Digits</h2> Edit Digits</h2>
<div id="div1"> <div id="div1">
<table>
<tr>
<canvas id="canvas" crossorigin></canvas>
</tr>
</table>
<p> <p>
<table> <table>
<tr> <tr>
<class id="Numbers_text" style="color:black;">Number: </class> <class id="Numbers_text" style="color:black;"><b>Number:</b> </class>
<select id="Numbers_value1" onchange="numberChanged()"> <select id="Numbers_value1" onchange="numberChanged()">
<option value="0" selected>default</option> <option value="0" selected>default</option>
<option value="1" >NT</option> <option value="1" >NT</option>
@@ -74,17 +81,8 @@ th, td {
</tr> </tr>
</table> </table>
</p> </p>
<table>
<tr>
<canvas id="canvas" crossorigin></canvas>
</tr>
</table>
<table>
<table>
<tr> <tr>
<td><input class="button" type="submit" id="newROI" name="newROI" onclick="newROI()" value="New ROI (after current)"></td> <td><input class="button" type="submit" id="newROI" name="newROI" onclick="newROI()" value="New ROI (after current)"></td>
<td><input class="button" type="submit" id="deleteROI" name="deleteROI" onclick="deleteROI()" value="Delete ROI"></td> <td><input class="button" type="submit" id="deleteROI" name="deleteROI" onclick="deleteROI()" value="Delete ROI"></td>

View File

@@ -53,7 +53,7 @@ table {
</tr> </tr>
<tr> <tr>
<td><label for="mirror">Pre-rotate Angle:</label></td> <td><label for="mirror">Pre-rotate Angle:</label></td>
<td><input type="number" id="prerotateangle" name="prerotateangle" value=0 min="-360" max="360" onchange="drawRotated()">Degrees</td> <td><input type="number" id="prerotateangle" name="prerotateangle" value="0" min="-360" max="360" onchange="drawRotated()">Degrees</td>
<td> <td>
<class id="MakeImage_Brightness_text" style="color:black;">Brightness: </class> <class id="MakeImage_Brightness_text" style="color:black;">Brightness: </class>
<input type="number" id="MakeImage_Brightness_value1" size="13" value=0 min="-2" max="2" style="float: right; clear: both;"> <input type="number" id="MakeImage_Brightness_value1" size="13" value=0 min="-2" max="2" style="float: right; clear: both;">

View File

@@ -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.26"; // 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.22"; // jomjol interner Real
// host = "."; // jomjol interner localhost // host = "."; // jomjol interner localhost

View File

@@ -44,7 +44,7 @@ function createReader(file) {
function ZerlegeZeile(input, delimiter = " =,\t") function ZerlegeZeile(input, delimiter = " =,\t\r")
{ {
var Output = Array(0); var Output = Array(0);
// delimiter = " =,\t"; // delimiter = " =,\t";
@@ -106,6 +106,11 @@ function trim(istring, adddelimiter)
} }
function getConfig()
{
return config_gesamt;
}
function loadConfig(_basepath) { function loadConfig(_basepath) {
var xhttp = new XMLHttpRequest(); var xhttp = new XMLHttpRequest();

View File

@@ -84,10 +84,7 @@ function ParseConfig() {
category[catname]["found"] = false; category[catname]["found"] = false;
param[catname] = new Object(); param[catname] = new Object();
ParamAddValue(param, catname, "Uri"); ParamAddValue(param, catname, "Uri");
ParamAddValue(param, catname, "Topic"); ParamAddValue(param, catname, "MainTopic");
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");
@@ -191,7 +188,8 @@ function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _
function ParamExtractValueAll(_param, _linesplit, _catname, _aktline, _iscom){ function ParamExtractValueAll(_param, _linesplit, _catname, _aktline, _iscom){
for (var paramname in _param[_catname]) { for (var paramname in _param[_catname]) {
if ((_linesplit[0].toUpperCase() == paramname.toUpperCase()) && (_linesplit.length > _param[_catname][paramname]["anzParam"])) _param_zw = _linesplit[0].substring(_linesplit[0].length - paramname.length, _linesplit[0].length);
if ((_param_zw.toUpperCase() == paramname.toUpperCase()) && (_linesplit.length > _param[_catname][paramname]["anzParam"]))
{ {
_param[_catname][paramname]["found"] = true; _param[_catname][paramname]["found"] = true;
_param[_catname][paramname]["enabled"] = !_iscom; _param[_catname][paramname]["enabled"] = !_iscom;
@@ -258,38 +256,36 @@ function WriteConfigININew()
{ {
for (_num in NUMBERS) for (_num in NUMBERS)
{ {
if (NUMBERS[_num][cat][name]["found"]) { if (NUMBERS[_num]["name"] == "default")
if (NUMBERS[_num]["name"] == "default") text = name;
text = name; else
else text = NUMBERS[_num]["name"] + "." + name;
text = name + "." + NUMBERS[_num]["name"];
var text = text + " =" var text = text + " ="
for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) {
text = text + " " + NUMBERS[_num][cat][name]["value"+j];
}
if (!NUMBERS[_num][cat][name]["enabled"]) {
text = ";" + text;
}
config_split.push(text);
}
}
}
else
{
if (param[cat][name]["found"]) {
var text = name + " ="
for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) { for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) {
text = text + " " + param[cat][name]["value"+j]; if (!(typeof NUMBERS[_num][cat][name]["value"+j] == 'undefined'))
text = text + " " + NUMBERS[_num][cat][name]["value"+j];
} }
if (!param[cat][name]["enabled"]) { if (!NUMBERS[_num][cat][name]["enabled"]) {
text = ";" + text; text = ";" + text;
} }
config_split.push(text); config_split.push(text);
} }
}
else
{
var text = name + " ="
for (var j = 1; j <= param[cat][name]["anzParam"]; ++j) {
if (!(typeof param[cat][name]["value"+j] == 'undefined'))
text = text + " " + param[cat][name]["value"+j];
}
if (!param[cat][name]["enabled"]) {
text = ";" + text;
} }
config_split.push(text);
}
} }
if (cat == "Digits") if (cat == "Digits")
{ {
@@ -597,6 +593,18 @@ function CreateNUMBER(_numbernew){
_ret["name"] = _numbernew; _ret["name"] = _numbernew;
_ret['digit'] = new Array(); _ret['digit'] = new Array();
_ret['analog'] = new Array(); _ret['analog'] = new Array();
for (_cat in param)
for (_param in param[_cat])
if (param[_cat][_param]["Numbers"] == true){
_ret[_cat] = new Object();
_ret[_cat][_param] = new Object();
_ret[_cat][_param]["found"] = false;
_ret[_cat][_param]["enabled"] = false;
_ret[_cat][_param]["anzParam"] = param[_cat][_param]["anzParam"];
}
NUMBERS.push(_ret); NUMBERS.push(_ret);
return ""; return "";

View File

@@ -1 +1 @@
8.0.0 9.0.0