Update Rolling

This commit is contained in:
jomjol
2021-01-17 12:44:20 +01:00
parent 9bb715fcb2
commit c65de27e9d
21 changed files with 248 additions and 94 deletions

View File

@@ -33,6 +33,7 @@ If you would like to support the developer with a cup of coffee you can do that
### Known Issues
* slow response of web server during picture analysis
* spontaneous reboots (mostly due to html access during image processing) - self recovery implemented
------
@@ -40,7 +41,15 @@ If you would like to support the developer with a cup of coffee you can do that
##### Rolling - (2021-01-05)
##### Rolling - (2021-01-17)
* Disabling of digital counters implemented
* Attention: do not disable digital and analog!
* Bug fixing:
* Configuration of analog counters on html-page failed (enable/disable, undefined ROIs)
2021-01-05
* Configuration: simple enabling / disabling of analog counters

View File

@@ -217,7 +217,7 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
gw = std::string(ip4addr_ntoa(&ip_info2.gw));
vEventGroupDelete(wifi_event_group);
// vEventGroupDelete(wifi_event_group);
}

View File

@@ -97,7 +97,7 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
if (aktparamgraph[0] == ';')
{
disabled = true;
while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph));
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
printf("[Analog] is disabled !!!\n");
return true;
}

View File

@@ -76,6 +76,8 @@ void ClassFlowControll::SetInitialParameter(void)
flowanalog = NULL;
flowpostprocessing = NULL;
disabled = false;
aktRunNr = 0;
aktstatus = "Startup";
}
@@ -241,6 +243,21 @@ bool ClassFlowControll::doFlow(string time)
return result;
}
void ClassFlowControll::UpdateAktStatus(std::string _flow)
{
aktstatus = gettimestring("%Y%m%d-%H%M%S");
aktstatus = aktstatus + "\t" + std::to_string(aktRunNr) + "\t";
if (_flow == "ClassFlowMakeImage")
aktstatus = aktstatus + "Taking Raw Image";
else
if (_flow == "ClassFlowAlignment")
aktstatus = aktstatus + "Aligning Image";
}
string ClassFlowControll::getReadout(bool _rawvalue = false, bool _noerror = false)
{
if (flowpostprocessing)

View File

@@ -28,6 +28,9 @@ protected:
bool SetupModeActive;
void SetInitialParameter(void);
std::string aktstatus;
int aktRunNr;
void UpdateAktStatus(std::string _flow);
public:
void InitFlow(std::string config);

View File

@@ -88,10 +88,18 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
if (!this->GetNextParagraph(pfile, aktparamgraph))
return false;
if (aktparamgraph.compare("[Digits]") != 0) // Paragraph passt nicht
if ((aktparamgraph.compare("[Digits]") != 0) && (aktparamgraph.compare(";[Digits]") != 0)) // Paragraph passt nich zu MakeImage
return false;
if (aktparamgraph[0] == ';')
{
disabled = true;
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
printf("[Digits] is disabled !!!\n");
return true;
}
while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph))
{
zerlegt = this->ZerlegeZeile(aktparamgraph);
@@ -169,6 +177,9 @@ string ClassFlowDigit::getHTMLSingleStep(string host)
bool ClassFlowDigit::doFlow(string time)
{
if (disabled)
return true;
if (!doAlignAndCut(time)){
return false;
};
@@ -182,6 +193,9 @@ bool ClassFlowDigit::doFlow(string time)
bool ClassFlowDigit::doAlignAndCut(string time)
{
if (disabled)
return true;
CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();
for (int i = 0; i < ROI.size(); ++i)
@@ -200,6 +214,9 @@ bool ClassFlowDigit::doAlignAndCut(string time)
bool ClassFlowDigit::doNeuralNetwork(string time)
{
if (disabled)
return true;
string logPath = CreateLogFolder(time);
#ifndef OHNETFLITE

View File

@@ -14,16 +14,27 @@
string ClassFlowPostProcessing::GetPreValue()
{
std::string result;
bool isAnalog = false;
bool isDigit = false;
int AnzahlAnalog = 0;
result = RundeOutput(PreValue, -DecimalShift);
for (int i = 0; i < ListFlowControll->size(); ++i)
{
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
{
int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
isAnalog = true;
AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
}
if (((*ListFlowControll)[i])->name().compare("ClassFlowDigit") == 0)
{
isDigit = true;
}
}
if (isDigit && isAnalog)
result = RundeOutput(PreValue, AnzahlAnalog - DecimalShift);
}
}
return result;
}
@@ -75,16 +86,23 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
ReturnValue = to_string(Value);
ReturnValueNoError = ReturnValue;
// falls es Analog gibt, dann die Anzahl der Nachkommastellen feststellen und entsprechend runden:
bool isAnalog = false;
bool isDigit = false;
int AnzahlAnalog = 0;
for (int i = 0; i < ListFlowControll->size(); ++i)
{
if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
isAnalog = true;
if (((*ListFlowControll)[i])->name().compare("ClassFlowDigit") == 0)
isDigit = true;
}
if (isDigit || isAnalog)
{
int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
ReturnValueNoError = ReturnValue;
}
}
return true;
}
@@ -119,28 +137,6 @@ void ClassFlowPostProcessing::SavePreValue(float value, string zwtime)
}
/*
ClassFlowPostProcessing::ClassFlowPostProcessing()
{
PreValueUse = false;
PreValueAgeStartup = 30;
AllowNegativeRates = false;
MaxRateValue = 0.1;
ErrorMessage = false;
ListFlowControll = NULL;
PreValueOkay = false;
useMaxRateValue = false;
checkDigitIncreaseConsistency = false;
DecimalShift = 0;
ErrorMessageText = "";
disabled = false;
disabled = false;
FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
}
*/
ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
{
PreValueUse = false;
@@ -273,6 +269,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
int AnzahlAnalog = 0;
string zw;
time_t imagetime = 0;
string rohwert;
ErrorMessageText = "";
@@ -311,6 +308,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
// isdigit = true; digit = "12N";
// isanalog = true; analog = "456";
ReturnRawValue = "";
if (isdigit)
ReturnRawValue = digit;
if (isdigit && isanalog)
@@ -318,8 +317,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
if (isanalog)
ReturnRawValue = ReturnRawValue + analog;
if (!isdigit)
{
AnzahlAnalog = 0;
}
ReturnRawValue = ShiftDecimal(ReturnRawValue, DecimalShift);
rohwert = ReturnRawValue;
if (!PreValueUse || !PreValueOkay)
{
ReturnValue = ReturnRawValue;
@@ -354,7 +361,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
if ((!AllowNegativeRates) && (Value < PreValue))
{
ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " ";
ErrorMessageText = ErrorMessageText + "Negative Rate - Returned old value - read value: " + zwvalue + " - raw value: " + ReturnRawValue;
Value = PreValue;
zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
}
@@ -397,10 +404,24 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror)
string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){
std::stringstream stream;
int _zw = _in;
// printf("AnzNachkomma: %d\n", _anzNachkomma);
if (_anzNachkomma < 0) {
_anzNachkomma = 0;
}
if (_anzNachkomma > 0)
{
stream << std::fixed << std::setprecision(_anzNachkomma) << _in;
return stream.str();
}
else
{
stream << _zw;
}
return stream.str();
}

View File

@@ -34,7 +34,6 @@ protected:
string RundeOutput(float _in, int _anzNachkomma);
public:
// ClassFlowPostProcessing();
ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc);
bool ReadParameter(FILE* pfile, string& aktparamgraph);
bool doFlow(string time);

View File

@@ -470,14 +470,19 @@ esp_err_t handler_prevalue(httpd_req_t *req)
const char* resp_str;
string zw;
// printf("handler_prevalue:\n"); printf(req->uri); printf("\n");
#ifdef DEBUG_DETAIL_ON
printf("handler_prevalue:\n"); printf(req->uri); printf("\n");
#endif
char _query[100];
char _size[10] = "";
if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
{
// printf("Query: "); printf(_query); printf("\n");
#ifdef DEBUG_DETAIL_ON
printf("Query: "); printf(_query); printf("\n");
#endif
if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
{
#ifdef DEBUG_DETAIL_ON

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="e520609";
const char* GIT_REV="9bb715f";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-01-05 20:40";
const char* BUILD_TIME="2021-01-17 12:21";

View File

@@ -1,4 +1,4 @@
const char* GIT_REV="e520609";
const char* GIT_REV="9bb715f";
const char* GIT_TAG="";
const char* GIT_BRANCH="rolling";
const char* BUILD_TIME="2021-01-05 20:40";
const char* BUILD_TIME="2021-01-17 12:21";

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -147,16 +147,20 @@ function EnDisableAnalog() {
$("#div2").addClass("disabledDiv");
}
sah1(document.getElementById("div1"));
sah1(document.getElementById("div1"), !isEnabled);
if (isEnabled)
{
UpdateROIs();
}
}
function sah1(el) {
function sah1(el, _target) {
try {
el.disabled = el.disabled ? false : true;
el.disabled = _target;
} catch (E) {}
if (el.childNodes && el.childNodes.length > 0) {
for (var x = 0; x < el.childNodes.length; x++) {
sah1(el.childNodes[x]);
sah1(el.childNodes[x], _target);
}
}
}
@@ -219,7 +223,7 @@ function ChangeSelection(){
}
function SaveToConfig(){
_enabled = document.getElementById("index").checked;
_enabled = document.getElementById("Category_Analog_enabled").checked;
SaveROIToConfig(ROIInfo, "[Analog]", basepath, _enabled);
UpdatePage();
}
@@ -350,6 +354,8 @@ function ParseIni(_basepath) {
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
context.drawImage(imageObj, 0, 0);
if (document.getElementById("Category_Analog_enabled").checked)
{
lw = 4
context.lineWidth = lw;
context.strokeStyle = "#FF0000";
@@ -363,6 +369,7 @@ function ParseIni(_basepath) {
ROIInfo[aktindex]["dx"] = rect.w;
ROIInfo[aktindex]["dy"] = rect.h;
}
}
function getCoords(elem) { // crossbrowser version
var box = elem.getBoundingClientRect();

View File

@@ -179,8 +179,10 @@ textarea {
</td>
</tr>
<tr class="expert" id="ex4">
<td colspan="4" style="padding-left: 20px;"><h4>Digits</h4></td>
<tr id="Category_Digits_ex4">
<td colspan="4" style="padding-left: 20px;">
<h4><input type="checkbox" id="Category_Digits_enabled" value="1" onclick = 'UpdateAfterCategoryCheck()' unchecked >Digits</h4></td>
</tr>
<tr>
<td width="20px" style="padding-left: 40px;">
@@ -736,6 +738,7 @@ function ReadParameter(_param, _cat, _name, _optional, _select = false){
function UpdateInput() {
document.getElementById("Category_Analog_enabled").checked = category["Analog"]["enabled"];
document.getElementById("Category_Digits_enabled").checked = category["Digits"]["enabled"];
document.getElementById("Category_MQTT_enabled").checked = category["MQTT"]["enabled"];
WriteParameter(param, category, "MakeImage", "LogImageLocation", true);
@@ -787,6 +790,7 @@ function UpdateInput() {
function ReadParameterAll()
{
category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked;
category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked;
category["MQTT"]["enabled"] = document.getElementById("Category_MQTT_enabled").checked;
ReadParameter(param, "MakeImage", "LogImageLocation", true);
@@ -853,6 +857,7 @@ function FormatDecimalValue(_param, _cat, _name) {
function UpdateAfterCategoryCheck() {
ReadParameterAll();
category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked;
category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked;
UpdateInput();
}

View File

@@ -55,7 +55,10 @@ th, td {
<body style="font-family: arial; padding: 0px 10px;">
<h2>Edit Digits</h2>
<h2><input type="checkbox" id="Category_Digits_enabled" value="1" onclick = 'EnDisableDigits()' checked >
Edit Digits</h2>
<div id="div1">
<table>
<tr>
@@ -93,6 +96,8 @@ th, td {
</tr>
</table>
</div>
<table>
<tr>
<td><input class="button" type="submit" id="saveroi" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini"></td>
@@ -102,6 +107,7 @@ th, td {
<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="./jquery-3.5.1.min.js"></script>
<script language="JavaScript">
var canvas = document.getElementById('canvas'),
@@ -115,6 +121,41 @@ th, td {
lockAR = true;
basepath = "http://192.168.178.26";
function EnDisableDigits() {
isEnabled = document.getElementById("Category_Digits_enabled").checked;
$("#div2").attr("disabled", "disabled").off('click');
var x1=$("#div2").hasClass("disabledDiv");
if (isEnabled)
{
$("#div2").removeClass("disabledDiv");
}
else
{
$("#div2").addClass("disabledDiv");
}
sah1(document.getElementById("div1"), !isEnabled);
if (isEnabled)
{
UpdateROIs();
}
}
function sah1(el, _target) {
try {
el.disabled = _target;
} catch (E) {}
if (el.childNodes && el.childNodes.length > 0) {
for (var x = 0; x < el.childNodes.length; x++) {
sah1(el.childNodes[x], _target);
}
}
}
function onNameChange(){
ROIInfo[aktindex]["name"] = document.getElementById("name").value;
UpdateROIs();
@@ -173,7 +214,8 @@ function ChangeSelection(){
}
function SaveToConfig(){
SaveROIToConfig(ROIInfo, "[Digits]", basepath);
_enabled = document.getElementById("Category_Digits_enabled").checked;
SaveROIToConfig(ROIInfo, "[Digits]", basepath, _enabled);
UpdatePage();
}
@@ -231,8 +273,19 @@ function UpdateROIs(){
function ParseIni(_basepath) {
loadConfig(_basepath);
ParseConfig();
document.getElementById("Category_Digits_enabled").checked = true;
ROIInfo = getROIInfo("[Digits]");
if (!GetDigitsEnabled())
{
document.getElementById("Category_Digits_enabled").checked = false;
EnDisableDigits();
alert("Digital ROIs are disabled - please enable (Check box top left).\n");
return;
}
UpdateROIs();
}
@@ -288,10 +341,12 @@ function ParseIni(_basepath) {
}
function draw() {
function draw() {
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
context.drawImage(imageObj, 0, 0);
if (document.getElementById("Category_Digits_enabled").checked)
{
lw = 4
context.lineWidth = lw;
context.strokeStyle = "#FF0000";
@@ -305,6 +360,7 @@ function ParseIni(_basepath) {
ROIInfo[aktindex]["dx"] = rect.w;
ROIInfo[aktindex]["dy"] = rect.h;
}
}
function getCoords(elem) { // crossbrowser version
var box = elem.getBoundingClientRect();

View File

@@ -10,6 +10,8 @@ var analog = new Array(0);
var initalrotate = new Object();
var analogEnabled = false;
var posAnalogHeader;
var digitsEnabled = false;
var posDigitsHeader;
function MakeRefZW(zw, _basepath){
url = _basepath + "/editflow.html?task=cutref&in=/config/reference.jpg&out=/img_tmp/ref_zw_org.jpg&x=" + zw["x"] + "&y=" + zw["y"] + "&dx=" + zw["dx"] + "&dy=" + zw["dy"];
@@ -96,6 +98,12 @@ function GetAnalogEnabled() {
return analogEnabled;
}
function GetDigitsEnabled() {
return digitsEnabled;
}
function ParseConfigAnalog(_aktline){
++_aktline;
analog.length = 0;
@@ -133,16 +141,19 @@ function getROIInfo(_typeROI){
}
function SaveROIToConfig(_ROIInfo, _typeROI, _basepath, _enabled){
if (_typeROI == "[Digits]"){
targetROI = digit;
}
if (_typeROI == "[Analog]"){
if (_enabled) {
text = _typeROI;
}
else {
text = ";" + _typeROI;
}
if (_typeROI == "[Digits]"){
config_split[posDigitsHeader] = text;
targetROI = digit;
}
if (_typeROI == "[Analog]"){
config_split[posAnalogHeader] = text;
targetROI = analog;
}
@@ -188,14 +199,18 @@ function ParseConfig() {
continue;
}
if ((config_split[aktline].trim().toUpperCase() == "[DIGITS]") || (config_split[aktline].trim().toUpperCase() == ";[DIGITS]")){
posDigitsHeader = aktline;
if (config_split[aktline][0] == "[") {
digitsEnabled = true;
}
aktline = ParseConfigDigit(aktline);
continue;
}
if ((config_split[aktline].trim().toUpperCase() == "[ANALOG]") || (config_split[aktline].trim().toUpperCase() == ";[ANALOG]")) {
posAnalogHeader = aktline;
if (config_split[aktline][0] == "[") {
analogEnabled = true;
posAnalogHeader = aktline;
}
aktline = ParseConfigAnalog(aktline);
continue;

View File

@@ -1 +1 @@
5.0.1
5.1.0