Pārlūkot izejas kodu

Merge branch 'rolling' into master

jomjol 5 gadi atpakaļ
vecāks
revīzija
46cfe45cf6
51 mainītis faili ar 1473 papildinājumiem un 894 dzēšanām
  1. 10 0
      README.md
  2. 72 4
      code/components/connect_wlan/connect_wlan.cpp
  3. 2 0
      code/components/connect_wlan/connect_wlan.h
  4. 24 23
      code/components/jomjol_controlGPIO/server_GPIO.cpp
  5. 2 3
      code/components/jomjol_controlcamera/server_camera.cpp
  6. 0 17
      code/components/jomjol_fileserver_ota/server_file.cpp
  7. 1 1
      code/components/jomjol_flowcontroll/CMakeLists.txt
  8. 7 4
      code/components/jomjol_flowcontroll/ClassFlow.cpp
  9. 3 1
      code/components/jomjol_flowcontroll/ClassFlow.h
  10. 177 18
      code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp
  11. 6 4
      code/components/jomjol_flowcontroll/ClassFlowAlignment.h
  12. 55 4
      code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp
  13. 5 2
      code/components/jomjol_flowcontroll/ClassFlowAnalog.h
  14. 42 15
      code/components/jomjol_flowcontroll/ClassFlowControll.cpp
  15. 3 0
      code/components/jomjol_flowcontroll/ClassFlowControll.h
  16. 23 4
      code/components/jomjol_flowcontroll/ClassFlowDigit.cpp
  17. 1 1
      code/components/jomjol_flowcontroll/ClassFlowDigit.h
  18. 4 0
      code/components/jomjol_flowcontroll/ClassFlowImage.cpp
  19. 3 1
      code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp
  20. 1 0
      code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp
  21. 54 28
      code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp
  22. 0 1
      code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h
  23. 31 29
      code/components/jomjol_image_proc/CAlignAndCutImage.cpp
  24. 4 1
      code/components/jomjol_image_proc/CAlignAndCutImage.h
  25. 132 38
      code/components/jomjol_image_proc/CFindTemplate.cpp
  26. 30 6
      code/components/jomjol_image_proc/CFindTemplate.h
  27. 5 2
      code/components/jomjol_logfile/ClassLogFile.cpp
  28. 3 0
      code/components/jomjol_logfile/ClassLogFile.h
  29. 8 3
      code/components/jomjol_tfliteclass/server_tflite.cpp
  30. 1 0
      code/main/main.cpp
  31. 3 3
      code/main/version.cpp
  32. 1 1
      code/main/version.h
  33. 0 4
      code/platformio.ini
  34. 3 3
      code/version.cpp
  35. BIN
      firmware/bootloader.bin
  36. BIN
      firmware/firmware.bin
  37. BIN
      firmware/html.zip
  38. 3 0
      sd-card/config/config.ini
  39. 2 0
      sd-card/html/debug.log
  40. 2 1
      sd-card/html/edit_alignment.html
  41. 84 19
      sd-card/html/edit_analog.html
  42. 1 0
      sd-card/html/edit_config.html
  43. 193 85
      sd-card/html/edit_config_param.html
  44. 73 16
      sd-card/html/edit_digits.html
  45. 1 0
      sd-card/html/edit_explain_6.html
  46. 1 0
      sd-card/html/edit_reference.html
  47. 2 2
      sd-card/html/gethost.js
  48. 44 166
      sd-card/html/readconfig.js
  49. 263 0
      sd-card/html/readconfigcommon.js
  50. 87 383
      sd-card/html/readconfigparam.js
  51. 1 1
      sd-card/html/version.txt

+ 10 - 0
README.md

@@ -33,6 +33,7 @@ If you would like to support the developer with a cup of coffee you can do that
 ### Known Issues
 ### Known Issues
 
 
 * slow response of web server during picture analysis
 * slow response of web server during picture analysis
+* spontaneous reboots (mostly due to html access during image processing) - self recovery implemented
 
 
 ------
 ------
 
 
@@ -40,6 +41,15 @@ If you would like to support the developer with a cup of coffee you can do that
 
 
 
 
 
 
+##### 6.1.0 Image Processing in Memory - (2021-01-20)
+
+* Disabling of analog / digital counters in configuration 
+* Improved Alignment Algorithm (`AlignmentAlgo`  = `Default`,  `Accurate` , `Fast`)
+* Analog counters: `ExtendedResolution` (last digit is extended by sub comma value of CNN)
+* `config.ini`: additional parameter `hostname`  (additional to wlan.ini)
+* Switching of GPIO12/13 via http-interface: `/GPIO?GPIO=12&Status=high/low`
+* Bug fixing: html configuration page, wlan password ("=" now possible)
+
 ##### 6.0.0 Image Processing in Memory - (2021-01-02)
 ##### 6.0.0 Image Processing in Memory - (2021-01-02)
 
 
 * **Major change**: image processing fully in memory - no need of SD card buffer anymore
 * **Major change**: image processing fully in memory - no need of SD card buffer anymore

+ 72 - 4
code/components/connect_wlan/connect_wlan.cpp

@@ -217,12 +217,78 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
     netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
     netmask = std::string(ip4addr_ntoa(&ip_info2.netmask));
     gw = std::string(ip4addr_ntoa(&ip_info2.gw));
     gw = std::string(ip4addr_ntoa(&ip_info2.gw));
 
 
-    vEventGroupDelete(wifi_event_group);
+//    vEventGroupDelete(wifi_event_group);
+}
+
+
+bool ChangeHostName(std::string fn, std::string _newhostname)
+{
+    if (_newhostname == hostname)
+        return false;
+
+    string line = "";
+    std::vector<string> zerlegt;
+
+    bool found = false;
+
+    std::vector<string> neuesfile;
+
+    FILE* pFile;
+    fn = FormatFileName(fn);
+    pFile = OpenFileAndWait(fn.c_str(), "r");
+
+    printf("file loaded\n");
+
+    if (pFile == NULL)
+        return false;
+
+    char zw[1024];
+    fgets(zw, 1024, pFile);
+    line = std::string(zw);
+
+    while ((line.size() > 0) || !(feof(pFile)))
+    {
+        printf("%s", line.c_str());
+        zerlegt = ZerlegeZeile(line, "=");
+        zerlegt[0] = trim(zerlegt[0], " ");
+
+        if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
+            line = "hostname = \"" + _newhostname + "\"\n";
+            found = true;
+        }
+
+        neuesfile.push_back(line);
+
+        if (fgets(zw, 1024, pFile) == NULL)
+        {
+            line = "";
+        }
+        else
+        {
+            line = std::string(zw);
+        }
+    }
+
+    if (!found)
+    {
+        line = "hostname = \"" + _newhostname + "\"\n";
+        neuesfile.push_back(line);        
+    }
+
+    fclose(pFile);
+
+    pFile = OpenFileAndWait(fn.c_str(), "w+");
+
+    for (int i = 0; i < neuesfile.size(); ++i)
+    {
+        fputs(neuesfile[i].c_str(), pFile);
+    }
+
+    fclose(pFile);
+
+    return true;
 }
 }
-///////////////////////////////////////////////////////////
-///////////////////////////////////////////////////////////
 
 
-//void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns)
 
 
 void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname)
 void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname)
 {
 {
@@ -248,6 +314,8 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
         printf("%s", line.c_str());
         printf("%s", line.c_str());
         zerlegt = ZerlegeZeile(line, "=");
         zerlegt = ZerlegeZeile(line, "=");
         zerlegt[0] = trim(zerlegt[0], " ");
         zerlegt[0] = trim(zerlegt[0], " ");
+        for (int i = 2; i < zerlegt.size(); ++i)
+            zerlegt[i] = zerlegt[i-1] + zerlegt[i];
 
 
         if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
         if ((zerlegt.size() > 1) && (toUpper(zerlegt[0]) == "HOSTNAME")){
             _hostname = trim(zerlegt[1]);
             _hostname = trim(zerlegt[1]);

+ 2 - 0
code/components/connect_wlan/connect_wlan.h

@@ -13,6 +13,8 @@ void initialise_wifi_fixed_ip(std::string _ip, std::string _gw, std::string _net
 void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname);
 void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphrase, std::string &_hostname);
 void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns);
 void LoadNetConfigFromFile(std::string fn, std::string &_ip, std::string &_gw, std::string &_netmask, std::string &_dns);
 
 
+bool ChangeHostName(std::string fn, std::string _newhostname);
+
 std::string getHostname();
 std::string getHostname();
 std::string getIPAddress();
 std::string getIPAddress();
 std::string getSSID();
 std::string getSSID();

+ 24 - 23
code/components/jomjol_controlGPIO/server_GPIO.cpp

@@ -18,7 +18,7 @@
 
 
 #include "Helper.h"
 #include "Helper.h"
 
 
-#define DEBUG_DETAIL_ON 
+// #define DEBUG_DETAIL_ON 
 
 
 esp_err_t handler_switch_GPIO(httpd_req_t *req)
 esp_err_t handler_switch_GPIO(httpd_req_t *req)
 {
 {
@@ -61,53 +61,52 @@ esp_err_t handler_switch_GPIO(httpd_req_t *req)
 
 
     gpionum = stoi(gpio);
     gpionum = stoi(gpio);
     
     
-    // frei: 16; 12-15; 2; 4
+    // frei: 16; 12-15; 2; 4  // nur 12 und 13 funktionieren 2: reboot, 4: BlitzLED, 14/15: DMA für SDKarte ???
 
 
     switch (gpionum) {
     switch (gpionum) {
-        case 2:
-            gpio_num = GPIO_NUM_2;
-            break;
-        case 4:
-            gpio_num = GPIO_NUM_4;
-            break;
         case 12:
         case 12:
             gpio_num = GPIO_NUM_12;
             gpio_num = GPIO_NUM_12;
             break;
             break;
         case 13:
         case 13:
             gpio_num = GPIO_NUM_13;
             gpio_num = GPIO_NUM_13;
             break;
             break;
-        case 14:
-            gpio_num = GPIO_NUM_14;
-            break;
-        case 15:
-            gpio_num = GPIO_NUM_15;
-            break;
-        case 16:
-            gpio_num = (gpio_num_t) 16;
-            break;
         default:
         default:
-            zw = "GPIO" + std::to_string(gpionum) + " not support - only 2, 4, 12-16 free";
+            zw = "GPIO" + std::to_string(gpionum) + " not support - only 12 & 13 free";
             httpd_resp_sendstr_chunk(req, zw.c_str());
             httpd_resp_sendstr_chunk(req, zw.c_str());
             httpd_resp_sendstr_chunk(req, NULL);          
             httpd_resp_sendstr_chunk(req, NULL);          
             return ESP_OK;    
             return ESP_OK;    
     }
     }
 
 
-	// Init the GPIO
-    gpio_pad_select_gpio(gpio_num);
-    /* Set the GPIO as a push/pull output */
-    gpio_set_direction(gpio_num, GPIO_MODE_OUTPUT);  
-
     if (status == "HIGH")  
     if (status == "HIGH")  
         gpio_set_level(gpio_num, 1);
         gpio_set_level(gpio_num, 1);
     else
     else
         gpio_set_level(gpio_num, 0); 
         gpio_set_level(gpio_num, 0); 
 
 
+
     zw = "GPIO" + std::to_string(gpionum) + " switched to " + status;
     zw = "GPIO" + std::to_string(gpionum) + " switched to " + status;
     httpd_resp_sendstr_chunk(req, zw.c_str());
     httpd_resp_sendstr_chunk(req, zw.c_str());
     httpd_resp_sendstr_chunk(req, NULL);          
     httpd_resp_sendstr_chunk(req, NULL);          
     return ESP_OK;    
     return ESP_OK;    
 };
 };
 
 
+void initGPIO()
+{
+    gpio_config_t io_conf;
+    //disable interrupt
+    io_conf.intr_type = GPIO_INTR_DISABLE;
+    //set as output mode
+    io_conf.mode = GPIO_MODE_OUTPUT;
+    //bit mask of the pins that you want to set,e.g.GPIO18/19
+//    io_conf.pin_bit_mask = ((1ULL<<GPIO_OUTPUT_IO_0) | (1ULL<<GPIO_OUTPUT_IO_1));
+//    io_conf.pin_bit_mask = ((1ULL << GPIO_NUM_12) | (1ULL << GPIO_NUM_2) | (1ULL << GPIO_NUM_4) | (1ULL << GPIO_NUM_12) | (1ULL << GPIO_NUM_13) | (1ULL << GPIO_NUM_14) | (1ULL << GPIO_NUM_15));
+    io_conf.pin_bit_mask = ((1ULL << GPIO_NUM_12) | (1ULL << GPIO_NUM_13));
+    //disable pull-down mode
+    io_conf.pull_down_en = (gpio_pulldown_t) 0;
+    //disable pull-up mode
+    io_conf.pull_up_en = (gpio_pullup_t) 0;
+    //configure GPIO with the given settings
+    gpio_config(&io_conf);
+}
 
 
 
 
 void register_server_GPIO_uri(httpd_handle_t server)
 void register_server_GPIO_uri(httpd_handle_t server)
@@ -120,4 +119,6 @@ void register_server_GPIO_uri(httpd_handle_t server)
     camuri.handler   = handler_switch_GPIO;
     camuri.handler   = handler_switch_GPIO;
     camuri.user_ctx  = (void*) "switch GPIO";    
     camuri.user_ctx  = (void*) "switch GPIO";    
     httpd_register_uri_handler(server, &camuri);
     httpd_register_uri_handler(server, &camuri);
+
+    initGPIO();
 }
 }

+ 2 - 3
code/components/jomjol_controlcamera/server_camera.cpp

@@ -95,10 +95,9 @@ esp_err_t handler_capture(httpd_req_t *req)
 
 
 esp_err_t handler_capture_with_ligth(httpd_req_t *req)
 esp_err_t handler_capture_with_ligth(httpd_req_t *req)
 {
 {
-
+#ifdef DEBUG_DETAIL_ON  
     LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
     LogFile.WriteHeapInfo("handler_capture_with_ligth - Start");
-
-    LogFile.WriteToFile("handler_capture_with_ligth");
+#endif
     char _query[100];
     char _query[100];
     char _delay[10];
     char _delay[10];
 
 

+ 0 - 17
code/components/jomjol_fileserver_ota/server_file.cpp

@@ -65,23 +65,6 @@ static esp_err_t index_html_get_handler(httpd_req_t *req)
     return ESP_OK;
     return ESP_OK;
 }
 }
 
 
-/* Handler to respond with an icon file embedded in flash.
- * Browsers expect to GET website icon at URI /favicon.ico.
- * This can be overridden by uploading file with same name */
-
-/*
-static esp_err_t favicon_get_handler(httpd_req_t *req)
-{
-    extern const unsigned char favicon_ico_start[] asm("_binary_favicon_ico_start");
-    extern const unsigned char favicon_ico_end[]   asm("_binary_favicon_ico_end");
-    const size_t favicon_ico_size = (favicon_ico_end - favicon_ico_start);
-    httpd_resp_set_type(req, "image/x-icon");
-    httpd_resp_send(req, (const char *)favicon_ico_start, favicon_ico_size);
-    httpd_resp_send_chunk(req, NULL, 0);       
-    return ESP_OK;
-}
-*/
-
 /* Send HTTP response with a run-time generated html consisting of
 /* Send HTTP response with a run-time generated html consisting of
  * a list of all files and folders under the requested path.
  * a list of all files and folders under the requested path.
  * In case of SPIFFS this returns empty list when path is any
  * In case of SPIFFS this returns empty list when path is any

+ 1 - 1
code/components/jomjol_flowcontroll/CMakeLists.txt

@@ -2,6 +2,6 @@ FILE(GLOB_RECURSE app_sources ${CMAKE_CURRENT_SOURCE_DIR}/*.*)
 
 
 idf_component_register(SRCS ${app_sources}
 idf_component_register(SRCS ${app_sources}
                     INCLUDE_DIRS "."
                     INCLUDE_DIRS "."
-                    REQUIRES jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_fileserver_ota jomjol_image_proc)
+                    REQUIRES jomjol_tfliteclass jomjol_helper jomjol_controlcamera jomjol_mqtt jomjol_fileserver_ota jomjol_image_proc connect_wlan)
 
 
 
 

+ 7 - 4
code/components/jomjol_flowcontroll/ClassFlow.cpp

@@ -10,6 +10,7 @@ void ClassFlow::SetInitialParameter(void)
 {
 {
 	ListFlowControll = NULL;
 	ListFlowControll = NULL;
 	previousElement = NULL;	
 	previousElement = NULL;	
+	disabled = false;
 }
 }
 
 
 
 
@@ -39,16 +40,18 @@ std::vector<string> ClassFlow::ZerlegeZeile(std::string input, std::string delim
 
 
 bool ClassFlow::isNewParagraph(string input)
 bool ClassFlow::isNewParagraph(string input)
 {
 {
-	if (input[0] == '[')
+	if ((input[0] == '[') || ((input[0] == ';') && (input[1] == '[')))
+	{
 		return true;
 		return true;
+	}
 	return false;
 	return false;
 }
 }
 
 
 bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
 bool ClassFlow::GetNextParagraph(FILE* pfile, string& aktparamgraph)
 {
 {
-	while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph));
+	while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
 
 
-	if (this->isNewParagraph(aktparamgraph))
+	if (isNewParagraph(aktparamgraph))
 		return true;
 		return true;
 	return false;
 	return false;
 }
 }
@@ -108,7 +111,7 @@ bool ClassFlow::getNextLine(FILE* pfile, string *rt)
 	}
 	}
 	*rt = zw;
 	*rt = zw;
 	*rt = trim(*rt);
 	*rt = trim(*rt);
-	while (zw[0] == ';' || zw[0] == '#' || (rt->size() == 0))			// Kommentarzeilen (; oder #) und Leerzeilen überspringen
+	while ((zw[0] == ';' || zw[0] == '#' || (rt->size() == 0)) && !(zw[1] == '['))			// Kommentarzeilen (; oder #) und Leerzeilen überspringen, es sei denn es ist ein neuer auskommentierter Paragraph
 	{
 	{
 		fgets(zw, 1024, pfile);
 		fgets(zw, 1024, pfile);
 		printf("%s", zw);		
 		printf("%s", zw);		

+ 3 - 1
code/components/jomjol_flowcontroll/ClassFlow.h

@@ -27,7 +27,7 @@ class ClassFlow
 {
 {
 protected:
 protected:
 //	std::vector<string> ZerlegeZeile(string input);
 //	std::vector<string> ZerlegeZeile(string input);
-	std::vector<string> ZerlegeZeile(string input, string delimiter = " =, ");
+	std::vector<string> ZerlegeZeile(string input, string delimiter = " =, \t");
 	bool isNewParagraph(string input);
 	bool isNewParagraph(string input);
 	bool GetNextParagraph(FILE* pfile, string& aktparamgraph);
 	bool GetNextParagraph(FILE* pfile, string& aktparamgraph);
 	bool getNextLine(FILE* pfile, string* rt);
 	bool getNextLine(FILE* pfile, string* rt);
@@ -37,6 +37,8 @@ protected:
 
 
 	virtual void SetInitialParameter(void);
 	virtual void SetInitialParameter(void);
 
 
+	bool disabled;
+
 public:
 public:
 	ClassFlow(void);
 	ClassFlow(void);
 	ClassFlow(std::vector<ClassFlow*> * lfc);
 	ClassFlow(std::vector<ClassFlow*> * lfc);

+ 177 - 18
code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp

@@ -4,29 +4,31 @@
 
 
 #include "CRotateImage.h"
 #include "CRotateImage.h"
 
 
+
 #include "ClassLogFile.h"
 #include "ClassLogFile.h"
 
 
 
 
 
 
 bool AlignmentExtendedDebugging = true;
 bool AlignmentExtendedDebugging = true;
 
 
+// #define DEBUG_DETAIL_ON  
+
 
 
 void ClassFlowAlignment::SetInitialParameter(void)
 void ClassFlowAlignment::SetInitialParameter(void)
 {
 {
     initalrotate = 0;
     initalrotate = 0;
     anz_ref = 0;
     anz_ref = 0;
-    suchex = 40;
-    suchey = 40;
     initialmirror = false;
     initialmirror = false;
     SaveAllFiles = false;
     SaveAllFiles = false;
     namerawimage =  "/sdcard/img_tmp/raw.jpg";
     namerawimage =  "/sdcard/img_tmp/raw.jpg";
+    FileStoreRefAlignment = "/sdcard/config/align.txt";
     ListFlowControll = NULL;
     ListFlowControll = NULL;
     AlignAndCutImage = NULL;
     AlignAndCutImage = NULL;
     ImageBasis = NULL;
     ImageBasis = NULL;
     ImageTMP = NULL;
     ImageTMP = NULL;
     previousElement = NULL;
     previousElement = NULL;
-    ref_dx[0] = 0; ref_dx[1] = 0;
-    ref_dy[0] = 0; ref_dy[1] = 0;
+    disabled = false;
+    SAD_criteria = 0.05;
 }
 }
 
 
 ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
 ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
@@ -53,6 +55,10 @@ ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow*>* lfc)
 bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
 bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
 {
 {
     std::vector<string> zerlegt;
     std::vector<string> zerlegt;
+    int suchex = 40;
+    int suchey = 40;
+    int alg_algo = 0;
+
 
 
     aktparamgraph = trim(aktparamgraph);
     aktparamgraph = trim(aktparamgraph);
 
 
@@ -65,29 +71,29 @@ bool ClassFlowAlignment::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);
-        if ((zerlegt[0] == "InitialMirror") && (zerlegt.size() > 1))
+        zerlegt = ZerlegeZeile(aktparamgraph);
+        if ((toUpper(zerlegt[0]) == "INITIALMIRROR") && (zerlegt.size() > 1))
         {
         {
             if (toUpper(zerlegt[1]) == "TRUE")
             if (toUpper(zerlegt[1]) == "TRUE")
                 initialmirror = true;
                 initialmirror = true;
         }
         }
-        if (((zerlegt[0] == "InitalRotate") || (zerlegt[0] == "InitialRotate")) && (zerlegt.size() > 1))
+        if (((toUpper(zerlegt[0]) == "INITALROTATE") || (toUpper(zerlegt[0]) == "INITIALROTATE")) && (zerlegt.size() > 1))
         {
         {
             this->initalrotate = std::stod(zerlegt[1]);
             this->initalrotate = std::stod(zerlegt[1]);
         }
         }
-        if ((zerlegt[0] == "SearchFieldX") && (zerlegt.size() > 1))
+        if ((toUpper(zerlegt[0]) == "SEARCHFIELDX") && (zerlegt.size() > 1))
         {
         {
-            this->suchex = std::stod(zerlegt[1]);
+            suchex = std::stod(zerlegt[1]);
         }   
         }   
-        if ((zerlegt[0] == "SearchFieldY") && (zerlegt.size() > 1))
+        if ((toUpper(zerlegt[0]) == "SEARCHFIELDY") && (zerlegt.size() > 1))
         {
         {
-            this->suchey = std::stod(zerlegt[1]);
+            suchey = std::stod(zerlegt[1]);
         }               
         }               
         if ((zerlegt.size() == 3) && (anz_ref < 2))
         if ((zerlegt.size() == 3) && (anz_ref < 2))
         {
         {
-            reffilename[anz_ref] = FormatFileName("/sdcard" + zerlegt[0]);
-            ref_x[anz_ref] = std::stod(zerlegt[1]);
-            ref_y[anz_ref] = std::stod(zerlegt[2]);
+            References[anz_ref].image_file = FormatFileName("/sdcard" + zerlegt[0]);
+            References[anz_ref].target_x = std::stod(zerlegt[1]);
+            References[anz_ref].target_y = std::stod(zerlegt[2]);
             anz_ref++;
             anz_ref++;
         }
         }
 
 
@@ -96,8 +102,33 @@ bool ClassFlowAlignment::ReadParameter(FILE* pfile, string& aktparamgraph)
             if (toUpper(zerlegt[1]) == "TRUE")
             if (toUpper(zerlegt[1]) == "TRUE")
                 SaveAllFiles = true;
                 SaveAllFiles = true;
         }
         }
+        if ((toUpper(zerlegt[0]) == "ALIGNMENTALGO") && (zerlegt.size() > 1))
+        {
+#ifdef DEBUG_DETAIL_ON
+            std::string zw2 = "Alignmentmodus gewählt: " + zerlegt[1];
+            LogFile.WriteToFile(zw2);
+#endif
+            if (toUpper(zerlegt[1]) == "HIGHACCURACY")
+                alg_algo = 1;
+            if (toUpper(zerlegt[1]) == "FAST")
+                alg_algo = 2;
+        }
+    }
 
 
+    for (int i = 0; i < anz_ref; ++i)
+    {
+        References[i].search_x = suchex;
+        References[i].search_y = suchey;
+        References[i].fastalg_SAD_criteria = SAD_criteria;
+        References[i].alignment_algo = alg_algo;
+#ifdef DEBUG_DETAIL_ON
+        std::string zw2 = "Alignmentmodus geschrieben: " + std::to_string(alg_algo);
+        LogFile.WriteToFile(zw2);
+#endif
     }
     }
+
+    LoadReferenceAlignmentValues();
+    
     return true;
     return true;
 
 
 }
 }
@@ -136,8 +167,11 @@ bool ClassFlowAlignment::doFlow(string time)
         if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg"));
         if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/rot.jpg"));
     }
     }
 
 
-    AlignAndCutImage->Align(reffilename[0], ref_x[0], ref_y[0], reffilename[1], ref_x[1], ref_y[1], suchex, suchey, "");
-    AlignAndCutImage->GetRefSize(ref_dx, ref_dy);
+    if (!AlignAndCutImage->Align(&References[0], &References[1])) 
+    {
+        SaveReferenceAlignmentValues();
+    }
+
     if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/alg.jpg"));
     if (SaveAllFiles) AlignAndCutImage->SaveToFile(FormatFileName("/sdcard/img_tmp/alg.jpg"));
 
 
     if (SaveAllFiles)
     if (SaveAllFiles)
@@ -152,13 +186,138 @@ bool ClassFlowAlignment::doFlow(string time)
         ImageTMP = NULL;
         ImageTMP = NULL;
     }  
     }  
 
 
+    LoadReferenceAlignmentValues();
+
     return true;
     return true;
 }
 }
 
 
 
 
+
+void ClassFlowAlignment::SaveReferenceAlignmentValues()
+{
+    FILE* pFile;
+    std::string zwtime, zwvalue;
+
+    pFile = fopen(FileStoreRefAlignment.c_str(), "w");
+
+    if (strlen(zwtime.c_str()) == 0)
+    {
+        time_t rawtime;
+        struct tm* timeinfo;
+        char buffer[80];
+
+        time(&rawtime);
+        timeinfo = localtime(&rawtime);
+
+        strftime(buffer, 80, "%Y-%m-%d_%H-%M-%S", timeinfo);
+        zwtime = std::string(buffer);
+    }
+
+    fputs(zwtime.c_str(), pFile);
+    fputs("\n", pFile);
+
+    zwvalue = std::to_string(References[0].fastalg_x) + "\t" + std::to_string(References[0].fastalg_y);
+    zwvalue = zwvalue + "\t" +std::to_string(References[0].fastalg_SAD)+ "\t" +std::to_string(References[0].fastalg_min); 
+    zwvalue = zwvalue + "\t" +std::to_string(References[0].fastalg_max)+ "\t" +std::to_string(References[0].fastalg_avg); 
+    fputs(zwvalue.c_str(), pFile);
+    fputs("\n", pFile);
+
+    zwvalue = std::to_string(References[1].fastalg_x) + "\t" + std::to_string(References[1].fastalg_y);
+    zwvalue = zwvalue + "\t" +std::to_string(References[1].fastalg_SAD)+ "\t" +std::to_string(References[1].fastalg_min); 
+    zwvalue = zwvalue + "\t" +std::to_string(References[1].fastalg_max)+ "\t" +std::to_string(References[1].fastalg_avg); 
+    fputs(zwvalue.c_str(), pFile);
+    fputs("\n", pFile);
+
+    fclose(pFile);
+}
+
+
+
+
+
+bool ClassFlowAlignment::LoadReferenceAlignmentValues(void)
+{
+    FILE* pFile;
+    char zw[1024];
+    string zwvalue;
+    std::vector<string> zerlegt;  
+
+
+//    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues01");      
+
+    pFile = fopen(FileStoreRefAlignment.c_str(), "r");
+    if (pFile == NULL)
+        return false;
+
+//    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues01");      
+
+    fgets(zw, 1024, pFile);
+    printf("%s", zw);
+
+//    zwvalue = "LoadReferenceAlignmentValues Time: " + std::string(zw);
+
+//    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zwvalue);      
+
+//    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues02");      
+
+    fgets(zw, 1024, pFile);
+    zerlegt = ZerlegeZeile(std::string(zw), " \t");
+    if (zerlegt.size() < 6)
+    {
+//        LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "Exit 01");      
+        fclose(pFile);
+        return false;
+    }
+
+//    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues03");      
+
+    References[0].fastalg_x = stoi(zerlegt[0]);
+    References[0].fastalg_y = stoi(zerlegt[1]);
+    References[0].fastalg_SAD = stof(zerlegt[2]);
+    References[0].fastalg_min = stoi(zerlegt[3]);
+    References[0].fastalg_max = stoi(zerlegt[4]);
+    References[0].fastalg_avg = stof(zerlegt[5]);
+
+    fgets(zw, 1024, pFile);
+    zerlegt = ZerlegeZeile(std::string(zw));
+    if (zerlegt.size() < 6)
+    {
+//        LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "Exit 02");      
+        fclose(pFile);
+        return false;
+    }
+
+//    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", "LoadReferenceAlignmentValues03");      
+
+    References[1].fastalg_x = stoi(zerlegt[0]);
+    References[1].fastalg_y = stoi(zerlegt[1]);
+    References[1].fastalg_SAD = stof(zerlegt[2]);
+    References[1].fastalg_min = stoi(zerlegt[3]);
+    References[1].fastalg_max = stoi(zerlegt[4]);
+    References[1].fastalg_avg = stof(zerlegt[5]);
+
+    fclose(pFile);
+
+
+#ifdef DEBUG_DETAIL_ON  
+    std::string _zw = "\tLoadReferences[0]\tx,y:\t" + std::to_string(References[0].fastalg_x) + "\t" + std::to_string(References[0].fastalg_x);
+    _zw = _zw + "\tSAD, min, max, avg:\t" + std::to_string(References[0].fastalg_SAD) + "\t" + std::to_string(References[0].fastalg_min);
+    _zw = _zw + "\t" + std::to_string(References[0].fastalg_max) + "\t" + std::to_string(References[0].fastalg_avg);
+    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", _zw);
+    _zw = "\tLoadReferences[1]\tx,y:\t" + std::to_string(References[1].fastalg_x) + "\t" + std::to_string(References[1].fastalg_x);
+    _zw = _zw + "\tSAD, min, max, avg:\t" + std::to_string(References[1].fastalg_SAD) + "\t" + std::to_string(References[1].fastalg_min);
+    _zw = _zw + "\t" + std::to_string(References[1].fastalg_max) + "\t" + std::to_string(References[1].fastalg_avg);
+    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", _zw);
+#endif
+
+    return true;
+}
+
+
+
 void ClassFlowAlignment::DrawRef(CImageBasis *_zw)
 void ClassFlowAlignment::DrawRef(CImageBasis *_zw)
 {
 {
-    _zw->drawRect(ref_x[0], ref_y[0], ref_dx[0], ref_dy[0], 255, 0, 0, 2);
-    _zw->drawRect(ref_x[1], ref_y[1], ref_dx[1], ref_dy[1], 255, 0, 0, 2);
+    _zw->drawRect(References[0].target_x, References[0].target_y, References[0].width, References[0].height, 255, 0, 0, 2);
+    _zw->drawRect(References[1].target_x, References[1].target_y, References[1].width, References[1].height, 255, 0, 0, 2);
 }
 }
 
 

+ 6 - 4
code/components/jomjol_flowcontroll/ClassFlowAlignment.h

@@ -3,6 +3,7 @@
 #include "ClassFlow.h"
 #include "ClassFlow.h"
 #include "Helper.h"
 #include "Helper.h"
 #include "CAlignAndCutImage.h"
 #include "CAlignAndCutImage.h"
+#include "CFindTemplate.h"
 
 
 #include <string>
 #include <string>
 
 
@@ -14,16 +15,17 @@ class ClassFlowAlignment :
 protected:
 protected:
     float initalrotate;
     float initalrotate;
     bool initialmirror;
     bool initialmirror;
-    string reffilename[2];
-    int ref_x[2], ref_y[2];
-    int ref_dx[2], ref_dy[2];
+    RefInfo References[2];
     int anz_ref;
     int anz_ref;
-    int suchex, suchey;
     string namerawimage;
     string namerawimage;
     bool SaveAllFiles;
     bool SaveAllFiles;
     CAlignAndCutImage *AlignAndCutImage;
     CAlignAndCutImage *AlignAndCutImage;
+    std::string FileStoreRefAlignment;
+    float SAD_criteria;
 
 
     void SetInitialParameter(void);
     void SetInitialParameter(void);
+    bool LoadReferenceAlignmentValues(void);
+    void SaveReferenceAlignmentValues();
 
 
 public:
 public:
     CImageBasis *ImageBasis, *ImageTMP;
     CImageBasis *ImageBasis, *ImageTMP;

+ 55 - 4
code/components/jomjol_flowcontroll/ClassFlowAnalog.cpp

@@ -3,7 +3,7 @@
 #include <math.h>
 #include <math.h>
 #include <iomanip>
 #include <iomanip>
 #include <sys/types.h>
 #include <sys/types.h>
-
+  
 // #define OHNETFLITE
 // #define OHNETFLITE
 
 
 #ifndef OHNETFLITE
 #ifndef OHNETFLITE
@@ -24,6 +24,8 @@ void ClassFlowAnalog::SetInitialParameter(void)
     ListFlowControll = NULL;
     ListFlowControll = NULL;
     previousElement = NULL;   
     previousElement = NULL;   
     SaveAllFiles = false; 
     SaveAllFiles = false; 
+    disabled = false;
+    extendedResolution = false;
 }   
 }   
 
 
 ClassFlowAnalog::ClassFlowAnalog(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
 ClassFlowAnalog::ClassFlowAnalog(std::vector<ClassFlow*>* lfc) : ClassFlowImage(lfc, TAG)
@@ -42,15 +44,40 @@ ClassFlowAnalog::ClassFlowAnalog(std::vector<ClassFlow*>* lfc) : ClassFlowImage(
 }
 }
 
 
 
 
+int ClassFlowAnalog::AnzahlROIs()
+{
+    int zw = ROI.size();
+    if (extendedResolution)
+        zw++;
+    
+    return zw;
+} 
+
+
 string ClassFlowAnalog::getReadout()
 string ClassFlowAnalog::getReadout()
 {
 {
+    string result = "";    
+    if (ROI.size() == 0)
+        return result;
+
+
+    float zahl = ROI[ROI.size() - 1]->result;
+    int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;
+
     int prev = -1;
     int prev = -1;
-    string result = "";
-    for (int i = ROI.size() - 1; i >= 0; --i)
+
+    prev = ZeigerEval(ROI[ROI.size() - 1]->result, prev);
+    result = std::to_string(prev);
+
+    if (extendedResolution)
+        result = result + std::to_string(ergebnis_nachkomma);
+
+    for (int i = ROI.size() - 2; i >= 0; --i)
     {
     {
         prev = ZeigerEval(ROI[i]->result, prev);
         prev = ZeigerEval(ROI[i]->result, prev);
         result = std::to_string(prev) + result;
         result = std::to_string(prev) + result;
     }
     }
+
     return result;
     return result;
 }
 }
 
 
@@ -89,9 +116,18 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
             return false;
             return false;
 
 
 
 
-    if (aktparamgraph.compare("[Analog]") != 0)       // Paragraph passt nich zu MakeImage
+    if ((aktparamgraph.compare("[Analog]") != 0) && (aktparamgraph.compare(";[Analog]") != 0))       // Paragraph passt nich zu MakeImage
         return false;
         return false;
 
 
+    if (aktparamgraph[0] == ';')
+    {
+        disabled = true;
+        while (getNextLine(pfile, &aktparamgraph) && !isNewParagraph(aktparamgraph));
+        printf("[Analog] is disabled !!!\n");
+        return true;
+    }
+
+
     while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
     while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
     {
     {
         zerlegt = this->ZerlegeZeile(aktparamgraph);
         zerlegt = this->ZerlegeZeile(aktparamgraph);
@@ -132,6 +168,12 @@ bool ClassFlowAnalog::ReadParameter(FILE* pfile, string& aktparamgraph)
             if (toUpper(zerlegt[1]) == "TRUE")
             if (toUpper(zerlegt[1]) == "TRUE")
                 SaveAllFiles = true;
                 SaveAllFiles = true;
         }
         }
+
+        if ((toUpper(zerlegt[0]) == "EXTENDEDRESOLUTION") && (zerlegt.size() > 1))
+        {
+            if (toUpper(zerlegt[1]) == "TRUE")
+                extendedResolution = true;
+        }
     }
     }
 
 
     for (int i = 0; i < ROI.size(); ++i)
     for (int i = 0; i < ROI.size(); ++i)
@@ -171,6 +213,9 @@ string ClassFlowAnalog::getHTMLSingleStep(string host)
 
 
 bool ClassFlowAnalog::doFlow(string time)
 bool ClassFlowAnalog::doFlow(string time)
 {
 {
+    if (disabled)
+      return true;
+
     if (!doAlignAndCut(time)){
     if (!doAlignAndCut(time)){
         return false;
         return false;
     };
     };
@@ -186,6 +231,9 @@ bool ClassFlowAnalog::doFlow(string time)
 
 
 bool ClassFlowAnalog::doAlignAndCut(string time)
 bool ClassFlowAnalog::doAlignAndCut(string time)
 {
 {
+    if (disabled)
+        return true;
+
     CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();    
     CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();    
 
 
     for (int i = 0; i < ROI.size(); ++i)
     for (int i = 0; i < ROI.size(); ++i)
@@ -219,6 +267,9 @@ void ClassFlowAnalog::DrawROI(CImageBasis *_zw)
 
 
 bool ClassFlowAnalog::doNeuralNetwork(string time)
 bool ClassFlowAnalog::doNeuralNetwork(string time)
 {
 {
+    if (disabled)
+        return true;
+
     string logPath = CreateLogFolder(time);
     string logPath = CreateLogFolder(time);
     
     
     string input = "/sdcard/img_tmp/alg.jpg";
     string input = "/sdcard/img_tmp/alg.jpg";

+ 5 - 2
code/components/jomjol_flowcontroll/ClassFlowAnalog.h

@@ -21,11 +21,14 @@ protected:
     int ZeigerEval(float zahl, int ziffer_vorgaenger);
     int ZeigerEval(float zahl, int ziffer_vorgaenger);
     bool SaveAllFiles;    
     bool SaveAllFiles;    
 
 
+
     ClassFlowAlignment* flowpostalignment;
     ClassFlowAlignment* flowpostalignment;
 
 
 	void SetInitialParameter(void);        
 	void SetInitialParameter(void);        
 
 
 public:
 public:
+    bool extendedResolution;
+
     ClassFlowAnalog(std::vector<ClassFlow*>* lfc);
     ClassFlowAnalog(std::vector<ClassFlow*>* lfc);
 
 
     bool ReadParameter(FILE* pfile, string& aktparamgraph);
     bool ReadParameter(FILE* pfile, string& aktparamgraph);
@@ -38,8 +41,8 @@ public:
     bool doNeuralNetwork(string time); 
     bool doNeuralNetwork(string time); 
     bool doAlignAndCut(string time);
     bool doAlignAndCut(string time);
    	std::vector<HTMLInfo*> GetHTMLInfo();   
    	std::vector<HTMLInfo*> GetHTMLInfo();   
-    int AnzahlROIs(){return ROI.size();}; 
+    int AnzahlROIs(); 
 
 
-    string name(){return "ClassFlowAnalog";};
+    string name(){return "ClassFlowAnalog";}; 
 };
 };
 
 

+ 42 - 15
code/components/jomjol_flowcontroll/ClassFlowControll.cpp

@@ -1,5 +1,7 @@
 #include "ClassFlowControll.h"
 #include "ClassFlowControll.h"
 
 
+#include "connect_wlan.h"
+
 #include "freertos/task.h"
 #include "freertos/task.h"
 
 
 #include <sys/stat.h>
 #include <sys/stat.h>
@@ -19,28 +21,25 @@ static const char* TAG = "flow_controll";
 std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
 std::string ClassFlowControll::doSingleStep(std::string _stepname, std::string _host){
     std::string _classname = "";
     std::string _classname = "";
     std::string result = "";
     std::string result = "";
-    if (_stepname.compare("[MakeImage]") == 0){
+    if ((_stepname.compare("[MakeImage]") == 0) || (_stepname.compare(";[MakeImage]") == 0)){
         _classname = "ClassFlowMakeImage";
         _classname = "ClassFlowMakeImage";
     }
     }
-    if (_stepname.compare("[Alignment]") == 0){
+    if ((_stepname.compare("[Alignment]") == 0) || (_stepname.compare(";[Alignment]") == 0)){
         _classname = "ClassFlowAlignment";
         _classname = "ClassFlowAlignment";
     }
     }
-    if (_stepname.compare("[Digits]") == 0){
+    if ((_stepname.compare("[Digits]") == 0) || (_stepname.compare(";[Digits]") == 0)){
         _classname = "ClassFlowDigit";
         _classname = "ClassFlowDigit";
     }
     }
-    if (_stepname.compare("[Analog]") == 0){
+    if ((_stepname.compare("[Analog]") == 0) || (_stepname.compare(";[Analog]") == 0)){
         _classname = "ClassFlowAnalog";
         _classname = "ClassFlowAnalog";
     }
     }
-    if (_stepname.compare("[MQTT]") == 0){
+    if ((_stepname.compare("[MQTT]") == 0) || (_stepname.compare(";[MQTT]") == 0)){
         _classname = "ClassFlowMQTT";
         _classname = "ClassFlowMQTT";
     }
     }
-//    std::string zw = "Classname: " + _classname + "\n";
-//    printf(zw.c_str());
 
 
     for (int i = 0; i < FlowControll.size(); ++i)
     for (int i = 0; i < FlowControll.size(); ++i)
         if (FlowControll[i]->name().compare(_classname) == 0){
         if (FlowControll[i]->name().compare(_classname) == 0){
- //           printf(FlowControll[i]->name().c_str()); printf("\n");
-            FlowControll[i]->doFlow("");
+             FlowControll[i]->doFlow("");
             result = FlowControll[i]->getHTMLSingleStep(_host);
             result = FlowControll[i]->getHTMLSingleStep(_host);
         }
         }
 
 
@@ -76,6 +75,10 @@ void ClassFlowControll::SetInitialParameter(void)
     flowdigit = NULL;
     flowdigit = NULL;
     flowanalog = NULL;
     flowanalog = NULL;
     flowpostprocessing = NULL;
     flowpostprocessing = NULL;
+    disabled = false;
+    aktRunNr = 0;
+    aktstatus = "Startup";
+
 }
 }
 
 
 bool ClassFlowControll::isAutoStart(long &_intervall)
 bool ClassFlowControll::isAutoStart(long &_intervall)
@@ -209,10 +212,9 @@ bool ClassFlowControll::doFlow(string time)
         zw_time = gettimestring("%Y%m%d-%H%M%S");
         zw_time = gettimestring("%Y%m%d-%H%M%S");
         aktstatus = zw_time + ": " + FlowControll[i]->name();
         aktstatus = zw_time + ": " + FlowControll[i]->name();
         
         
-// #ifdef DEBUG_DETAIL_ON         
+       
         string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
         string zw = "FlowControll.doFlow - " + FlowControll[i]->name();
         LogFile.WriteHeapInfo(zw);
         LogFile.WriteHeapInfo(zw);
-// #endif
 
 
         if (!FlowControll[i]->doFlow(time)){
         if (!FlowControll[i]->doFlow(time)){
             repeat++;
             repeat++;
@@ -240,6 +242,21 @@ bool ClassFlowControll::doFlow(string time)
     return result;
     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)
 string ClassFlowControll::getReadout(bool _rawvalue = false, bool _noerror = false)
 {
 {
     if (flowpostprocessing)
     if (flowpostprocessing)
@@ -356,9 +373,17 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
         {
         {
             string zw = "Set TimeZone: " + zerlegt[1];
             string zw = "Set TimeZone: " + zerlegt[1];
             reset_servername(zerlegt[1]);
             reset_servername(zerlegt[1]);
-        }      
-
+        }  
 
 
+        if ((toUpper(zerlegt[0]) == "HOSTNAME") && (zerlegt.size() > 1))
+        {
+            if (ChangeHostName("/sdcard/wlan.ini", zerlegt[1]))
+            {
+                // reboot notwendig damit die neue wlan.ini auch benutzt wird !!!
+                fclose(pfile);
+                doReboot();
+            }
+        }
 
 
         if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1))
         if ((toUpper(zerlegt[0]) == "SETUPMODE") && (zerlegt.size() > 1))
         {
         {
@@ -368,8 +393,10 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
             }        
             }        
         }      
         }      
 
 
-
-
+        if ((toUpper(zerlegt[0]) == "LOGLEVEL") && (zerlegt.size() > 1))
+        {
+            LogFile.setLogLevel(stoi(zerlegt[1]));
+        }      
     }
     }
     return true;
     return true;
 }
 }

+ 3 - 0
code/components/jomjol_flowcontroll/ClassFlowControll.h

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

+ 23 - 4
code/components/jomjol_flowcontroll/ClassFlowDigit.cpp

@@ -25,6 +25,8 @@ void ClassFlowDigit::SetInitialParameter(void)
     ListFlowControll = NULL;
     ListFlowControll = NULL;
     previousElement = NULL;    
     previousElement = NULL;    
     SaveAllFiles = false;
     SaveAllFiles = false;
+    disabled = false;
+
 }    
 }    
 
 
 ClassFlowDigit::ClassFlowDigit() : ClassFlowImage(TAG)
 ClassFlowDigit::ClassFlowDigit() : ClassFlowImage(TAG)
@@ -83,14 +85,22 @@ bool ClassFlowDigit::ReadParameter(FILE* pfile, string& aktparamgraph)
     aktparamgraph = trim(aktparamgraph);
     aktparamgraph = trim(aktparamgraph);
 
 
     if (aktparamgraph.size() == 0)
     if (aktparamgraph.size() == 0)
-        if (!this->GetNextParagraph(pfile, aktparamgraph))
+        if (!this->GetNextParagraph(pfile, aktparamgraph)) 
             return false;
             return false;
 
 
-
-    if (aktparamgraph.compare("[Digits]") != 0)       // Paragraph passt nich zu MakeImage
+    if ((aktparamgraph.compare("[Digits]") != 0) && (aktparamgraph.compare(";[Digits]") != 0))       // Paragraph passt nich zu MakeImage
         return false;
         return false;
 
 
-    while (this->getNextLine(pfile, &aktparamgraph) && !this->isNewParagraph(aktparamgraph))
+    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);
         zerlegt = this->ZerlegeZeile(aktparamgraph);
         if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1))
         if ((zerlegt[0] == "LogImageLocation") && (zerlegt.size() > 1))
@@ -167,6 +177,9 @@ string ClassFlowDigit::getHTMLSingleStep(string host)
 
 
 bool ClassFlowDigit::doFlow(string time)
 bool ClassFlowDigit::doFlow(string time)
 {
 {
+    if (disabled)
+        return true;
+        
     if (!doAlignAndCut(time)){
     if (!doAlignAndCut(time)){
         return false;
         return false;
     };
     };
@@ -180,6 +193,9 @@ bool ClassFlowDigit::doFlow(string time)
 
 
 bool ClassFlowDigit::doAlignAndCut(string time)
 bool ClassFlowDigit::doAlignAndCut(string time)
 {
 {
+    if (disabled)
+        return true;
+
     CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();
     CAlignAndCutImage *caic = flowpostalignment->GetAlignAndCutImage();
 
 
     for (int i = 0; i < ROI.size(); ++i)
     for (int i = 0; i < ROI.size(); ++i)
@@ -198,6 +214,9 @@ bool ClassFlowDigit::doAlignAndCut(string time)
 
 
 bool ClassFlowDigit::doNeuralNetwork(string time)
 bool ClassFlowDigit::doNeuralNetwork(string time)
 {
 {
+    if (disabled)
+        return true;
+            
     string logPath = CreateLogFolder(time);
     string logPath = CreateLogFolder(time);
 
 
 #ifndef OHNETFLITE
 #ifndef OHNETFLITE

+ 1 - 1
code/components/jomjol_flowcontroll/ClassFlowDigit.h

@@ -23,7 +23,7 @@ protected:
     bool SaveAllFiles;
     bool SaveAllFiles;
 
 
     ClassFlowAlignment* flowpostalignment;
     ClassFlowAlignment* flowpostalignment;
-
+ 
     bool doNeuralNetwork(string time); 
     bool doNeuralNetwork(string time); 
     bool doAlignAndCut(string time); 
     bool doAlignAndCut(string time); 
 
 

+ 4 - 0
code/components/jomjol_flowcontroll/ClassFlowImage.cpp

@@ -11,18 +11,22 @@ ClassFlowImage::ClassFlowImage(const char* logTag)
 {
 {
 	this->logTag = logTag;
 	this->logTag = logTag;
 	isLogImage = false;
 	isLogImage = false;
+    disabled = false;
+
 }
 }
 
 
 ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, const char* logTag) : ClassFlow(lfc)
 ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, const char* logTag) : ClassFlow(lfc)
 {
 {
 	this->logTag = logTag;
 	this->logTag = logTag;
 	isLogImage = false;
 	isLogImage = false;
+    disabled = false;
 }
 }
 
 
 ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, ClassFlow *_prev, const char* logTag) :  ClassFlow(lfc, _prev)
 ClassFlowImage::ClassFlowImage(std::vector<ClassFlow*> * lfc, ClassFlow *_prev, const char* logTag) :  ClassFlow(lfc, _prev)
 {
 {
 	this->logTag = logTag;
 	this->logTag = logTag;
 	isLogImage = false;
 	isLogImage = false;
+    disabled = false;
 }
 }
 
 
 
 

+ 3 - 1
code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp

@@ -17,7 +17,9 @@ void ClassFlowMQTT::SetInitialParameter(void)
     user = "";
     user = "";
     password = "";   
     password = "";   
     previousElement = NULL;
     previousElement = NULL;
-    ListFlowControll = NULL;     
+    ListFlowControll = NULL; 
+    disabled = false;
+
 }       
 }       
 
 
 ClassFlowMQTT::ClassFlowMQTT()
 ClassFlowMQTT::ClassFlowMQTT()

+ 1 - 0
code/components/jomjol_flowcontroll/ClassFlowMakeImage.cpp

@@ -33,6 +33,7 @@ void ClassFlowMakeImage::SetInitialParameter(void)
     rawImage = NULL;
     rawImage = NULL;
     ImageSize = FRAMESIZE_VGA;
     ImageSize = FRAMESIZE_VGA;
     SaveAllFiles = false;
     SaveAllFiles = false;
+    disabled = false;
     namerawimage =  "/sdcard/img_tmp/raw.jpg";
     namerawimage =  "/sdcard/img_tmp/raw.jpg";
 }     
 }     
 
 

+ 54 - 28
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -14,17 +14,28 @@
 string ClassFlowPostProcessing::GetPreValue()
 string ClassFlowPostProcessing::GetPreValue()
 {
 {
     std::string result;
     std::string result;
+    bool isAnalog = false;
+    bool isDigit = false;
+
+    int AnzahlAnalog = 0;
     result = RundeOutput(PreValue, -DecimalShift);
     result = RundeOutput(PreValue, -DecimalShift);
 
 
     for (int i = 0; i < ListFlowControll->size(); ++i)
     for (int i = 0; i < ListFlowControll->size(); ++i)
     {
     {
         if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
         if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
         {
         {
-            int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
-            result =  RundeOutput(PreValue, AnzahlAnalog - DecimalShift);
+            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;
     return result;
 }
 }
 
 
@@ -75,17 +86,24 @@ bool ClassFlowPostProcessing::LoadPreValue(void)
     ReturnValue = to_string(Value);
     ReturnValue = to_string(Value);
     ReturnValueNoError = ReturnValue; 
     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)
     for (int i = 0; i < ListFlowControll->size(); ++i)
     {
     {
         if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
         if (((*ListFlowControll)[i])->name().compare("ClassFlowAnalog") == 0)
-        {
-            int AnzahlAnalog = ((ClassFlowAnalog*)(*ListFlowControll)[i])->AnzahlROIs();
-            ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
-            ReturnValueNoError = ReturnValue;
-        }
+            isAnalog = true;
+        if (((*ListFlowControll)[i])->name().compare("ClassFlowDigit") == 0)
+            isDigit = true;
     }
     }
-    
+
+    if (isDigit || isAnalog)
+    {
+        ReturnValue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
+        ReturnValueNoError = ReturnValue;
+    }
+   
     return true;
     return true;
 }
 }
 
 
@@ -119,23 +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 = "";
-    FilePreValue = FormatFileName("/sdcard/config/prevalue.ini");
-}
-
 ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
 ClassFlowPostProcessing::ClassFlowPostProcessing(std::vector<ClassFlow*>* lfc)
 {
 {
     PreValueUse = false;
     PreValueUse = false;
@@ -268,6 +269,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
     int AnzahlAnalog = 0;
     int AnzahlAnalog = 0;
     string zw;
     string zw;
     time_t imagetime = 0;
     time_t imagetime = 0;
+    string rohwert;
 
 
     ErrorMessageText = "";
     ErrorMessageText = "";
 
 
@@ -306,6 +308,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
     //    isdigit = true; digit = "12N";
     //    isdigit = true; digit = "12N";
     //    isanalog = true; analog = "456";
     //    isanalog = true; analog = "456";
 
 
+    ReturnRawValue = "";
+
     if (isdigit)
     if (isdigit)
         ReturnRawValue = digit;
         ReturnRawValue = digit;
     if (isdigit && isanalog)
     if (isdigit && isanalog)
@@ -313,8 +317,16 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
     if (isanalog)
     if (isanalog)
         ReturnRawValue = ReturnRawValue + analog; 
         ReturnRawValue = ReturnRawValue + analog; 
 
 
+
+    if (!isdigit)
+    {
+        AnzahlAnalog = 0;
+    }
+
     ReturnRawValue = ShiftDecimal(ReturnRawValue, DecimalShift);   
     ReturnRawValue = ShiftDecimal(ReturnRawValue, DecimalShift);   
 
 
+    rohwert = ReturnRawValue;
+
     if (!PreValueUse || !PreValueOkay)
     if (!PreValueUse || !PreValueOkay)
     {
     {
         ReturnValue = ReturnRawValue;
         ReturnValue = ReturnRawValue;
@@ -349,7 +361,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
 
 
     if ((!AllowNegativeRates) && (Value < PreValue))
     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;
         Value = PreValue;
         zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
         zwvalue = RundeOutput(Value, AnzahlAnalog - DecimalShift);
     }
     }
@@ -392,10 +404,24 @@ string ClassFlowPostProcessing::getReadoutParam(bool _rawValue, bool _noerror)
 
 
 string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){
 string ClassFlowPostProcessing::RundeOutput(float _in, int _anzNachkomma){
     std::stringstream stream;
     std::stringstream stream;
+    int _zw = _in;    
+//    printf("AnzNachkomma: %d\n", _anzNachkomma);
+
     if (_anzNachkomma < 0) {
     if (_anzNachkomma < 0) {
         _anzNachkomma = 0;
         _anzNachkomma = 0;
     }
     }
-    stream << std::fixed << std::setprecision(_anzNachkomma) << _in;
+
+    if (_anzNachkomma > 0)
+    {
+        stream << std::fixed << std::setprecision(_anzNachkomma) << _in;
+        return stream.str();          
+    }
+    else
+    {
+        stream << _zw;
+    }
+
+
     return stream.str();  
     return stream.str();  
 }
 }
 
 

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

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

+ 31 - 29
code/components/jomjol_image_proc/CAlignAndCutImage.cpp

@@ -1,6 +1,6 @@
 #include "CAlignAndCutImage.h"
 #include "CAlignAndCutImage.h"
 #include "CRotateImage.h"
 #include "CRotateImage.h"
-#include "CFindTemplate.h"
+#include "ClassLogFile.h"
 
 
 #define _USE_MATH_DEFINES
 #define _USE_MATH_DEFINES
 #include <math.h>
 #include <math.h>
@@ -33,31 +33,33 @@ void CAlignAndCutImage::GetRefSize(int *ref_dx, int *ref_dy)
     ref_dy[1] = t1_dy;
     ref_dy[1] = t1_dy;
 }
 }
 
 
-void CAlignAndCutImage::Align(std::string _template0, int ref0_x, int ref0_y, std::string _template1, int ref1_x, int ref1_y, int deltax, int deltay, std::string imageROI)
+bool CAlignAndCutImage::Align(RefInfo *_temp1, RefInfo *_temp2)
 {
 {
     int dx, dy;
     int dx, dy;
     int r0_x, r0_y, r1_x, r1_y;
     int r0_x, r0_y, r1_x, r1_y;
+    bool isSimilar1, isSimilar2;
 
 
-//    CFindTemplate* ft = new CFindTemplate(filename);
     CFindTemplate* ft = new CFindTemplate(rgb_image, channels, width, height, bpp);
     CFindTemplate* ft = new CFindTemplate(rgb_image, channels, width, height, bpp);
 
 
-    r0_x = ref0_x;
-    r0_y = ref0_y;
-    ft->FindTemplate(_template0, &r0_x, &r0_y, deltax, deltay);
-    t0_dx = ft->tpl_width;
-    t0_dy = ft->tpl_height;    
+    r0_x = _temp1->target_x;
+    r0_y = _temp1->target_y;
+    printf("Vor ft->FindTemplate(_temp1);  %s\n", _temp1->image_file.c_str());
+    isSimilar1 = ft->FindTemplate(_temp1);
+    _temp1->width = ft->tpl_width;
+    _temp1->height = ft->tpl_height; 
 
 
-    r1_x = ref1_x;
-    r1_y = ref1_y;
-    ft->FindTemplate(_template1, &r1_x, &r1_y, deltax, deltay);
-    t1_dx = ft->tpl_width;
-    t1_dy = ft->tpl_height;
+    r1_x = _temp2->target_x;
+    r1_y = _temp2->target_y;
+    printf("Vor ft->FindTemplate(_temp2);  %s\n", _temp2->image_file.c_str());
+    isSimilar2 = ft->FindTemplate(_temp2);
+    _temp2->width = ft->tpl_width;
+    _temp2->height = ft->tpl_height; 
 
 
     delete ft;
     delete ft;
 
 
 
 
-    dx = ref0_x - r0_x;
-    dy = ref0_y - r0_y;
+    dx = _temp1->target_x - _temp1->found_x;
+    dy = _temp1->target_y - _temp1->found_y;
 
 
     r0_x += dx;
     r0_x += dx;
     r0_y += dy;
     r0_y += dy;
@@ -67,32 +69,32 @@ void CAlignAndCutImage::Align(std::string _template0, int ref0_x, int ref0_y, st
 
 
     float w_org, w_ist, d_winkel;
     float w_org, w_ist, d_winkel;
 
 
-    w_org = atan2(ref1_y - ref0_y, ref1_x - ref0_x);
+    w_org = atan2(_temp2->found_y - _temp1->found_y, _temp2->found_x - _temp1->found_x);
     w_ist = atan2(r1_y - r0_y, r1_x - r0_x);
     w_ist = atan2(r1_y - r0_y, r1_x - r0_x);
 
 
-    d_winkel = (w_org - w_ist) * 180 / M_PI;
-
-    if (imageROI.length() > 0)
-    {
-        CImageBasis* imgzw = new CImageBasis(this);
-        imgzw->drawRect(r0_x, r0_y, t0_dx, t0_dy, 255, 0, 0, 2);
-        imgzw->drawRect(r1_x, r1_y, t1_dx, t1_dy, 255, 0, 0, 2);
-        imgzw->SaveToFile(imageROI);
-        printf("Alignment: alignment ROI created: %s\n", imageROI.c_str());
-        delete imgzw;
-    }
+    d_winkel = (w_ist - w_org) * 180 / M_PI;
 
 
+#ifdef DEBUG_DETAIL_ON
     std::string zw = "\tdx:\t" + std::to_string(dx) + "\tdy:\t" + std::to_string(dy) + "\td_winkel:\t" + std::to_string(d_winkel);
     std::string zw = "\tdx:\t" + std::to_string(dx) + "\tdy:\t" + std::to_string(dy) + "\td_winkel:\t" + std::to_string(d_winkel);
-//    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
+    zw = zw + "\tt1_x_y:\t" + std::to_string(_temp1->found_x) + "\t" + std::to_string(_temp1->found_y);
+    zw = zw + "\tpara1_found_min_avg_max_SAD:\t" + std::to_string(_temp1->fastalg_min) + "\t" + std::to_string(_temp1->fastalg_avg) + "\t" + std::to_string(_temp1->fastalg_max) + "\t"+ std::to_string(_temp1->fastalg_SAD);
+    zw = zw + "\tt2_x_y:\t" + std::to_string(_temp2->found_x) + "\t" + std::to_string(_temp2->found_y);
+    zw = zw + "\tpara2_found_min_avg_max:\t" + std::to_string(_temp2->fastalg_min) + "\t" + std::to_string(_temp2->fastalg_avg) + "\t" + std::to_string(_temp2->fastalg_max) + "\t"+ std::to_string(_temp2->fastalg_SAD);
+    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
+#endif
 
 
     CRotateImage rt(this, ImageTMP);
     CRotateImage rt(this, ImageTMP);
     rt.Translate(dx, dy);
     rt.Translate(dx, dy);
-    rt.Rotate(d_winkel, ref0_x, ref0_y);
+    rt.Rotate(d_winkel, _temp1->target_x, _temp1->target_y);
     printf("Alignment: dx %d - dy %d - rot %f\n", dx, dy, d_winkel);
     printf("Alignment: dx %d - dy %d - rot %f\n", dx, dy, d_winkel);
+
+    return (isSimilar1 && isSimilar2);
 }
 }
 
 
 
 
 
 
+
+
 void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int dx, int dy)
 void CAlignAndCutImage::CutAndSave(std::string _template1, int x1, int y1, int dx, int dy)
 {
 {
 
 

+ 4 - 1
code/components/jomjol_image_proc/CAlignAndCutImage.h

@@ -1,4 +1,6 @@
 #include "CImageBasis.h"
 #include "CImageBasis.h"
+#include "CFindTemplate.h"
+
 
 
 class CAlignAndCutImage : public CImageBasis
 class CAlignAndCutImage : public CImageBasis
 {
 {
@@ -9,7 +11,8 @@ class CAlignAndCutImage : public CImageBasis
         CAlignAndCutImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;};
         CAlignAndCutImage(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {ImageTMP = NULL;};
         CAlignAndCutImage(CImageBasis *_org, CImageBasis *_temp);
         CAlignAndCutImage(CImageBasis *_org, CImageBasis *_temp);
 
 
-        void Align(std::string _template1, int x1, int y1, std::string _template2, int x2, int y2, int deltax = 40, int deltay = 40, std::string imageROI = "");
+        bool Align(RefInfo *_temp1, RefInfo *_temp2);
+//        void Align(std::string _template1, int x1, int y1, std::string _template2, int x2, int y2, int deltax = 40, int deltay = 40, std::string imageROI = "");
         void CutAndSave(std::string _template1, int x1, int y1, int dx, int dy);
         void CutAndSave(std::string _template1, int x1, int y1, int dx, int dy);
         CImageBasis* CutAndSave(int x1, int y1, int dx, int dy);
         CImageBasis* CutAndSave(int x1, int y1, int dx, int dy);
         void CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *_target);
         void CutAndSave(int x1, int y1, int dx, int dy, CImageBasis *_target);

+ 132 - 38
code/components/jomjol_image_proc/CFindTemplate.cpp

@@ -1,91 +1,185 @@
 #include "CFindTemplate.h"
 #include "CFindTemplate.h"
 
 
-void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y)
-{
-    FindTemplate(_template, found_x, found_y, 0, 0);
-}
+#include "ClassLogFile.h"
+
+// #define DEBUG_DETAIL_ON  
 
 
-void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy)
+
+bool CFindTemplate::FindTemplate(RefInfo *_ref)
 {
 {
-    uint8_t* rgb_template = stbi_load(_template.c_str(), &tpl_width, &tpl_height, &tpl_bpp, channels);
+    uint8_t* rgb_template = stbi_load(_ref->image_file.c_str(), &tpl_width, &tpl_height, &tpl_bpp, channels);
+
+//    printf("FindTemplate 01\n");
 
 
     int ow, ow_start, ow_stop;
     int ow, ow_start, ow_stop;
     int oh, oh_start, oh_stop;
     int oh, oh_start, oh_stop;
 
 
-    if (_dx == 0)
+    if (_ref->search_x == 0)
     {
     {
-        _dx = width;
-        *found_x = 0;
+        _ref->search_x = width;
+        _ref->found_x = 0;
     }
     }
 
 
-    if (_dy == 0)
+    if (_ref->search_y == 0)
     {
     {
-        _dy = height;
-        *found_y = 0;
+        _ref->search_y = height;
+        _ref->found_y = 0;
     }
     }
 
 
 
 
-    ow_start = *found_x - _dx;
+    ow_start = _ref->target_x - _ref->search_x;
     ow_start = std::max(ow_start, 0);
     ow_start = std::max(ow_start, 0);
-    ow_stop = *found_x + _dx;
+    ow_stop = _ref->target_x + _ref->search_x;
     if ((ow_stop + tpl_width) > width)
     if ((ow_stop + tpl_width) > width)
         ow_stop = width - tpl_width;
         ow_stop = width - tpl_width;
     ow = ow_stop - ow_start + 1;
     ow = ow_stop - ow_start + 1;
 
 
-    oh_start = *found_y - _dy;
+    oh_start = _ref->target_y - _ref->search_y;
     oh_start = std::max(oh_start, 0);
     oh_start = std::max(oh_start, 0);
-    oh_stop = *found_y + _dy;
+    oh_stop = _ref->target_y + _ref->search_y;
     if ((oh_stop + tpl_height) > height)
     if ((oh_stop + tpl_height) > height)
         oh_stop = height - tpl_height;
         oh_stop = height - tpl_height;
     oh = oh_stop - oh_start + 1;
     oh = oh_stop - oh_start + 1;
 
 
-    uint8_t* odata = (unsigned char*)GET_MEMORY(ow * oh * channels);
+    float avg, SAD;
+    int min, max;
+    bool isSimilar = false;
+
+//    printf("FindTemplate 02\n");
+
+    if ((_ref->alignment_algo == 2) && (_ref->fastalg_x > -1) && (_ref->fastalg_y > -1))     // für Testzwecke immer Berechnen
+    {
+        isSimilar = CalculateSimularities(rgb_template, _ref->fastalg_x, _ref->fastalg_y, ow, oh, min, avg, max, SAD, _ref->fastalg_SAD, _ref->fastalg_SAD_criteria);
+#ifdef DEBUG_DETAIL_ON  
+        std::string zw = "\t" + _ref->image_file + "\tt1_x_y:\t" + std::to_string(_ref->fastalg_x) + "\t" + std::to_string(_ref->fastalg_y);
+        zw = zw + "\tpara1_found_min_avg_max_SAD:\t" + std::to_string(min) + "\t" + std::to_string(avg) + "\t" + std::to_string(max) + "\t"+ std::to_string(SAD);
+        LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
+#endif
+    }
+
+//    printf("FindTemplate 03\n");
+
+
+    if (isSimilar)
+    {
+#ifdef DEBUG_DETAIL_ON  
+        LogFile.WriteToFile("Use FastAlignment sucessfull");
+#endif
+        _ref->found_x = _ref->fastalg_x;
+        _ref->found_y = _ref->fastalg_y;
+        return true;
+    }
+
+//    printf("FindTemplate 04\n");
+
 
 
     double aktSAD;
     double aktSAD;
     double minSAD = pow(tpl_width * tpl_height * 255, 2);
     double minSAD = pow(tpl_width * tpl_height * 255, 2);
 
 
     RGBImageLock();
     RGBImageLock();
 
 
-    for (int xouter = ow_start; xouter <= ow_stop; xouter++)
-        for (int youter = oh_start; youter <= oh_stop; ++youter)
+//    printf("FindTemplate 05\n");
+    int xouter, youter, tpl_x, tpl_y, _ch;
+    int _anzchannels = channels;
+    if (_ref->alignment_algo == 0)  // 0 = "Default" (nur R-Kanal)
+        _anzchannels = 1;
+
+    for (xouter = ow_start; xouter <= ow_stop; xouter++)
+        for (youter = oh_start; youter <= oh_stop; ++youter)
         {
         {
             aktSAD = 0;
             aktSAD = 0;
-            for (int tpl_x = 0; tpl_x < tpl_width; tpl_x++)
-                for (int tpl_y = 0; tpl_y < tpl_height; tpl_y++)
+            for (tpl_x = 0; tpl_x < tpl_width; tpl_x++)
+                for (tpl_y = 0; tpl_y < tpl_height; tpl_y++)
                 {
                 {
                     stbi_uc* p_org = rgb_image + (channels * ((youter + tpl_y) * width + (xouter + tpl_x)));
                     stbi_uc* p_org = rgb_image + (channels * ((youter + tpl_y) * width + (xouter + tpl_x)));
                     stbi_uc* p_tpl = rgb_template + (channels * (tpl_y * tpl_width + tpl_x));
                     stbi_uc* p_tpl = rgb_template + (channels * (tpl_y * tpl_width + tpl_x));
-                    aktSAD += pow(p_tpl[0] - p_org[0], 2);
+                    for (_ch = 0; _ch < _anzchannels; ++_ch)
+                    {
+                        aktSAD += pow(p_tpl[_ch] - p_org[_ch], 2);
+                    }
                 }
                 }
-            stbi_uc* p_out = odata + (channels * ((youter - oh_start) * ow + (xouter - ow_start)));
-
-            p_out[0] = int(sqrt(aktSAD / (tpl_width * tpl_height)));
             if (aktSAD < minSAD)
             if (aktSAD < minSAD)
             {
             {
                 minSAD = aktSAD;
                 minSAD = aktSAD;
-                *found_x = xouter;
-                *found_y = youter;
+                _ref->found_x = xouter;
+                _ref->found_y = youter;
             }
             }
         }
         }
 
 
-    RGBImageRelease();
+//    printf("FindTemplate 06\n");
+
+
+    if (_ref->alignment_algo == 2)
+        CalculateSimularities(rgb_template, _ref->found_x, _ref->found_y, ow, oh, min, avg, max, SAD, _ref->fastalg_SAD, _ref->fastalg_SAD_criteria);
 
 
-    stbi_write_bmp("sdcard\\find.bmp", ow, oh, channels, odata);
 
 
-    stbi_image_free(odata);
+//    printf("FindTemplate 07\n");
+
+    _ref->fastalg_x = _ref->found_x;
+    _ref->fastalg_y = _ref->found_y;
+    _ref->fastalg_min = min;
+    _ref->fastalg_avg = avg;
+    _ref->fastalg_max = max;
+    _ref->fastalg_SAD = SAD;
+
+    
+#ifdef DEBUG_DETAIL_ON  
+    std::string zw = "\t" + _ref->image_file + "\tt1_x_y:\t" + std::to_string(_ref->fastalg_x) + "\t" + std::to_string(_ref->fastalg_y);
+    zw = zw + "\tpara1_found_min_avg_max_SAD:\t" + std::to_string(min) + "\t" + std::to_string(avg) + "\t" + std::to_string(max) + "\t"+ std::to_string(SAD);
+    LogFile.WriteToDedicatedFile("/sdcard/alignment.txt", zw);
+#endif
+
+    RGBImageRelease();
     stbi_image_free(rgb_template);
     stbi_image_free(rgb_template);
-}
+    
+//    printf("FindTemplate 08\n");
 
 
-void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y, std::string _imageout)
-{
-    FindTemplate(_template, found_x, found_y);
-    SaveToFile(_imageout);
+    return false;
 }
 }
 
 
-void CFindTemplate::FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy, std::string _imageout)
+
+
+bool CFindTemplate::CalculateSimularities(uint8_t* _rgb_tmpl, int _startx, int _starty, int _sizex, int _sizey, int &min, float &avg, int &max, float &SAD, float _SADold, float _SADcrit)
 {
 {
-    FindTemplate(_template, found_x, found_y, _dx, _dy);
-    SaveToFile(_imageout);
+    int dif;
+    int minDif = 255;
+    int maxDif = -255;
+    double avgDifSum = 0;
+    long int anz = 0;
+    double aktSAD = 0;    
+
+    int xouter, youter, _ch;
+
+    for (xouter = 0; xouter <= _sizex; xouter++)
+        for (youter = 0; youter <= _sizey; ++youter)
+        {
+            stbi_uc* p_org = rgb_image + (channels * ((youter + _starty) * width + (xouter + _startx)));
+            stbi_uc* p_tpl = _rgb_tmpl + (channels * (youter * tpl_width + xouter));
+            for (_ch = 0; _ch < channels; ++_ch)
+            {
+                dif = p_tpl[_ch] - p_org[_ch];
+                aktSAD += pow(p_tpl[_ch] - p_org[_ch], 2);                
+                if (dif < minDif) minDif = dif;
+                if (dif > maxDif) maxDif = dif;
+                avgDifSum += dif;
+                anz++;
+            }
+        }
+
+    avg = avgDifSum / anz;
+    min = minDif;
+    max = maxDif;
+    SAD = sqrt(aktSAD) / anz;
+
+    float _SADdif = abs(SAD - _SADold);
+
+    printf("Anzahl %ld, avgDifSum %fd, avg %f, SAD_neu: %fd, _SAD_old: %f, _SAD_crit:%f\n", anz, avgDifSum, avg, SAD, _SADold, _SADdif);
+
+    if (_SADdif <= _SADcrit)
+        return true;
+
+    return false;
 }
 }
 
 
 
 
+

+ 30 - 6
code/components/jomjol_image_proc/CFindTemplate.h

@@ -1,16 +1,40 @@
+#ifndef __CFINDTEMPLATE_CLASS
+#define __CFINDTEMPLATE_CLASS
+
 #include "CImageBasis.h"
 #include "CImageBasis.h"
 
 
+struct RefInfo {
+    std::string image_file; 
+    int target_x = 0;
+    int target_y = 0;
+    int width = 0;
+    int height = 0;
+    int found_x;
+    int found_y;
+    int search_x;
+    int search_y;
+    int fastalg_x = -1;
+    int fastalg_y = -1;
+    int fastalg_min = -256;
+    float fastalg_avg = -1;
+    int fastalg_max = -1;
+    float fastalg_SAD = -1;
+    float fastalg_SAD_criteria = -1;
+    int alignment_algo = 0;             // 0 = "Default" (nur R-Kanal), 1 = "HighAccurity" (RGB-Kanal), 2 = "Fast" (1.x RGB, dann isSimilar)
+};
+
+
+
 
 
 class CFindTemplate : public CImageBasis
 class CFindTemplate : public CImageBasis
 {
 {
     public:
     public:
         int tpl_width, tpl_height, tpl_bpp;    
         int tpl_width, tpl_height, tpl_bpp;    
-//        CFindTemplate(std::string _image);
         CFindTemplate(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {};
         CFindTemplate(uint8_t* _rgb_image, int _channels, int _width, int _height, int _bpp) : CImageBasis(_rgb_image, _channels, _width, _height, _bpp) {};
 
 
+        bool FindTemplate(RefInfo *_ref);
+
+        bool CalculateSimularities(uint8_t* _rgb_tmpl, int _startx, int _starty, int _sizex, int _sizey, int &min, float &avg, int &max, float &SAD, float _SADold, float _SADcrit);
+};
 
 
-        void FindTemplate(std::string _template, int* found_x, int* found_y, std::string _imageout);
-        void FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy, std::string _imageout);
-        void FindTemplate(std::string _template, int* found_x, int* found_y);
-        void FindTemplate(std::string _template, int* found_x, int* found_y, int _dx, int _dy);
-};
+#endif

+ 5 - 2
code/components/jomjol_logfile/ClassLogFile.cpp

@@ -12,8 +12,10 @@ ClassLogFile LogFile("/sdcard/log/message", "log_%Y-%m-%d.txt");
 
 
 void ClassLogFile::WriteHeapInfo(std::string _id)
 void ClassLogFile::WriteHeapInfo(std::string _id)
 {
 {
-    std::string _zw;
-    _zw = "\t" + _id + "\t" + getESPHeapInfo();
+std::string _zw = "\t" + _id;
+    if (loglevel > 0)
+        _zw =  _zw + "\t" + getESPHeapInfo();
+
     WriteToFile(_zw);
     WriteToFile(_zw);
 }
 }
 
 
@@ -188,4 +190,5 @@ ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile)
     logfile =  _logfile;
     logfile =  _logfile;
     doLogFile = true;
     doLogFile = true;
     retentionInDays = 10;
     retentionInDays = 10;
+    loglevel = 0;
 }
 }

+ 3 - 0
code/components/jomjol_logfile/ClassLogFile.h

@@ -9,11 +9,14 @@ private:
     std::string logfile;
     std::string logfile;
     bool doLogFile;
     bool doLogFile;
     unsigned short retentionInDays;
     unsigned short retentionInDays;
+    int loglevel;
 public:
 public:
     ClassLogFile(std::string _logpath, std::string _logfile);
     ClassLogFile(std::string _logpath, std::string _logfile);
 
 
     std::string getESPHeapInfo();
     std::string getESPHeapInfo();
 
 
+    void setLogLevel(int i){loglevel = i;};
+
     void WriteHeapInfo(std::string _id);
     void WriteHeapInfo(std::string _id);
 
 
     void SwitchOnOff(bool _doLogFile);
     void SwitchOnOff(bool _doLogFile);

+ 8 - 3
code/components/jomjol_tfliteclass/server_tflite.cpp

@@ -470,21 +470,26 @@ esp_err_t handler_prevalue(httpd_req_t *req)
     const char* resp_str;
     const char* resp_str;
     string zw;
     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 _query[100];
     char _size[10] = "";
     char _size[10] = "";
 
 
     if (httpd_req_get_url_query_str(req, _query, 100) == ESP_OK)
     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)
         if (httpd_query_key_value(_query, "value", _size, 10) == ESP_OK)
         {
         {
 #ifdef DEBUG_DETAIL_ON       
 #ifdef DEBUG_DETAIL_ON       
             printf("Value: "); printf(_size); printf("\n"); 
             printf("Value: "); printf(_size); printf("\n"); 
 #endif
 #endif
         }
         }
-    }           
+    }      
 
 
     if (strlen(_size) == 0)
     if (strlen(_size) == 0)
         zw = tfliteflow.GetPrevalue();
         zw = tfliteflow.GetPrevalue();

+ 1 - 0
code/main/main.cpp

@@ -140,6 +140,7 @@ extern "C" void app_main(void)
     register_server_tflite_uri(server);
     register_server_tflite_uri(server);
     register_server_file_uri(server, "/sdcard");
     register_server_file_uri(server, "/sdcard");
     register_server_ota_sdcard_uri(server);
     register_server_ota_sdcard_uri(server);
+    register_server_GPIO_uri(server);
     register_server_main_uri(server, "/sdcard");
     register_server_main_uri(server, "/sdcard");
 
 
     TFliteDoAutoStart();
     TFliteDoAutoStart();

+ 3 - 3
code/main/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="aeafd63";
+const char* GIT_REV="3869da9";
 const char* GIT_TAG="";
 const char* GIT_TAG="";
-const char* GIT_BRANCH="master";
-const char* BUILD_TIME="2021-01-05 18:08";
+const char* GIT_BRANCH="rolling";
+const char* BUILD_TIME="2021-01-20 19:24";

+ 1 - 1
code/main/version.h

@@ -13,7 +13,7 @@ extern "C"
 #include "Helper.h"
 #include "Helper.h"
 #include <fstream>
 #include <fstream>
 
 
-const char* GIT_BASE_BRANCH = "master - v6.0.0 - 2020-01-02";
+const char* GIT_BASE_BRANCH = "master - v6.1.0 - 2020-01-20";
 
 
 
 
 const char* git_base_branch(void)
 const char* git_base_branch(void)

+ 0 - 4
code/platformio.ini

@@ -18,10 +18,6 @@ platform = espressif32
 board = esp32cam
 board = esp32cam
 framework = espidf
 framework = espidf
 
 
-board_build.embed_files  =
-  main/favicon.ico
-
-
 ;board_build.partitions = partitions_singleapp.csv
 ;board_build.partitions = partitions_singleapp.csv
 board_build.partitions = partitions.csv
 board_build.partitions = partitions.csv
 
 

+ 3 - 3
code/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="aeafd63";
+const char* GIT_REV="3869da9";
 const char* GIT_TAG="";
 const char* GIT_TAG="";
-const char* GIT_BRANCH="master";
-const char* BUILD_TIME="2021-01-05 18:08";
+const char* GIT_BRANCH="rolling";
+const char* BUILD_TIME="2021-01-20 19:24";

BIN
firmware/bootloader.bin


BIN
firmware/firmware.bin


BIN
firmware/html.zip


+ 3 - 0
sd-card/config/config.ini

@@ -11,6 +11,7 @@ InitalRotate=180
 /config/ref1.jpg 456 138
 /config/ref1.jpg 456 138
 SearchFieldX = 20
 SearchFieldX = 20
 SearchFieldY = 20
 SearchFieldY = 20
+AlignmentAlgo = Default
 
 
 
 
 [Digits]
 [Digits]
@@ -31,6 +32,7 @@ analog1 444 225 92 92
 analog2 391 329 92 92
 analog2 391 329 92 92
 analog3 294 369 92 92
 analog3 294 369 92 92
 analog4 168 326 92 92
 analog4 168 326 92 92
+ExtendedResolution = false
 
 
 [PostProcessing]
 [PostProcessing]
 DecimalShift = 0
 DecimalShift = 0
@@ -60,6 +62,7 @@ LogfileRetentionInDays = 3
 [System]
 [System]
 TimeZone = CET-1CEST,M3.5.0,M10.5.0/3
 TimeZone = CET-1CEST,M3.5.0,M10.5.0/3
 ;TimeServer = fritz.box
 ;TimeServer = fritz.box
+;hostname = watermeter
 SetupMode = true
 SetupMode = true
 
 
 [Ende]
 [Ende]

+ 2 - 0
sd-card/html/debug.log

@@ -1 +1,3 @@
 [1204/185120.033:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3)
 [1204/185120.033:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3)
+[0102/122131.430:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3)
+[0118/210038.095:ERROR:directory_reader_win.cc(43)] FindFirstFile: Das System kann den angegebenen Pfad nicht finden. (0x3)

+ 2 - 1
sd-card/html/edit_alignment.html

@@ -90,7 +90,8 @@ select {
 	</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="./readconfig.js"></script> 
+<script type="text/javascript" src="./readconfigcommon.js"></script>   
 
 
 <script language="JavaScript">
 <script language="JavaScript">
         var canvas = document.getElementById('canvas'),
         var canvas = document.getElementById('canvas'),

+ 84 - 19
sd-card/html/edit_analog.html

@@ -49,13 +49,26 @@ select {
 th, td {
 th, td {
   padding: 5px 5px 5px 0px;
   padding: 5px 5px 5px 0px;
 }
 }
+
+#div2{
+  background-color:#777;
+  margin-bottom:20px;
+}
+.disabledDiv {
+    pointer-events: none;
+    opacity: 0.4;
+}
 </style>
 </style>
 
 
 </head>
 </head>
 
 
 <body style="font-family: arial; padding: 0px 10px;">
 <body style="font-family: arial; padding: 0px 10px;">
 
 
-	<h2>Edit Analog</h2>
+    <h2><input type="checkbox" id="Category_Analog_enabled" value="1"  onclick = 'EnDisableAnalog()' checked >
+        Edit Analog</h2>
+   
+
+<div id="div1">
 
 
 	<table>
 	<table>
 	  <tr>
 	  <tr>
@@ -78,8 +91,8 @@ th, td {
 		</td>
 		</td>
 		<td>Name: <input type="text" name="name" id="name" onchange="onNameChange()" size="13"></td>
 		<td>Name: <input type="text" name="name" id="name" onchange="onNameChange()" size="13"></td>
 		<td>
 		<td>
-		<input class="move" type="submit" id="moveNext" onclick="moveNext()" value="move Next">
-		<input class="move" type="submit" id="movePrevious" onclick="movePrevious()" value="move Previous">  
+		<input class="button" type="submit" id="moveNext" onclick="moveNext()" value="move Next">
+		<input class="button" type="submit" id="movePrevious" onclick="movePrevious()" value="move Previous">  
 		</td>	
 		</td>	
 	  </tr>
 	  </tr>
 	  <tr>
 	  <tr>
@@ -92,15 +105,19 @@ th, td {
 		<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()"></td>
 		<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()"></td>
 	  </tr>
 	  </tr>
 	</table>			 
 	</table>			 
-			 
+</div>	 
+
 	<table>
 	<table>
 	  <tr>
 	  <tr>
 		<td><input class="button" type="submit" id="saveroi" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini"></td>
 		<td><input class="button" type="submit" id="saveroi" name="saveroi" onclick="SaveToConfig()" value="Save all to Config.ini"></td>
 	  </tr>  
 	  </tr>  
-	</table>		 
+    </table>	
+
 
 
 <script type="text/javascript" src="./gethost.js"></script> 
 <script type="text/javascript" src="./gethost.js"></script> 
+<script type="text/javascript" src="./readconfigcommon.js"></script>  
 <script type="text/javascript" src="./readconfig.js"></script>  
 <script type="text/javascript" src="./readconfig.js"></script>  
+<script type="text/javascript" src="./jquery-3.5.1.min.js"></script>  
 
 
 <script language="JavaScript">
 <script language="JavaScript">
         var canvas = document.getElementById('canvas'),
         var canvas = document.getElementById('canvas'),
@@ -114,6 +131,40 @@ th, td {
             lockAR = true;
             lockAR = true;
             basepath = "http://192.168.178.26";
             basepath = "http://192.168.178.26";
 
 
+
+function EnDisableAnalog() {
+        isEnabled = document.getElementById("Category_Analog_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(){
 function onNameChange(){
     ROIInfo[aktindex]["name"] = document.getElementById("name").value;
     ROIInfo[aktindex]["name"] = document.getElementById("name").value;
     UpdateROIs();
     UpdateROIs();
@@ -172,7 +223,8 @@ function ChangeSelection(){
 }
 }
 
 
 function SaveToConfig(){
 function SaveToConfig(){
-    SaveROIToConfig(ROIInfo, "[Analog]", basepath);
+    _enabled = document.getElementById("Category_Analog_enabled").checked;
+    SaveROIToConfig(ROIInfo, "[Analog]", basepath, _enabled);
     UpdatePage();  
     UpdatePage();  
 }
 }
 
 
@@ -230,8 +282,18 @@ function UpdateROIs(){
 function ParseIni(_basepath) {
 function ParseIni(_basepath) {
     loadConfig(_basepath);
     loadConfig(_basepath);
     ParseConfig();
     ParseConfig();
+
+    document.getElementById("Category_Analog_enabled").checked = true;
     ROIInfo = getROIInfo("[Analog]");
     ROIInfo = getROIInfo("[Analog]");
 
 
+    if (!GetAnalogEnabled()) 
+    {
+        document.getElementById("Category_Analog_enabled").checked = false;
+        EnDisableAnalog();
+        alert("Analog ROIs are disabled - please enable (Check box top left).\n");
+        return;
+    }
+
     UpdateROIs();
     UpdateROIs();
 }
 }
 			
 			
@@ -288,22 +350,25 @@ function ParseIni(_basepath) {
         }  
         }  
 
 
 
 
-        function draw() {
+    function draw() {
         var canvas = document.getElementById('canvas');
         var canvas = document.getElementById('canvas');
         var context = canvas.getContext('2d');
         var context = canvas.getContext('2d');
         context.drawImage(imageObj, 0, 0);
         context.drawImage(imageObj, 0, 0);
-        lw = 4
-        context.lineWidth = lw;
-        context.strokeStyle = "#FF0000";
-        var x0 = parseInt(rect.startX) - parseInt(lw/2);
-        var y0 = parseInt(rect.startY) - parseInt(lw/2);
-        var dx = parseInt(rect.w) + parseInt(lw);
-        var dy = parseInt(rect.h) + parseInt(lw);
-        context.strokeRect(x0, y0, dx, dy);    
-        ROIInfo[aktindex]["x"] = rect.startX;       
-        ROIInfo[aktindex]["y"] = rect.startY;       
-        ROIInfo[aktindex]["dx"] = rect.w;       
-        ROIInfo[aktindex]["dy"] = rect.h;       
+        if (document.getElementById("Category_Analog_enabled").checked)
+        {
+            lw = 4
+            context.lineWidth = lw;
+            context.strokeStyle = "#FF0000";
+            var x0 = parseInt(rect.startX) - parseInt(lw/2);
+            var y0 = parseInt(rect.startY) - parseInt(lw/2);
+            var dx = parseInt(rect.w) + parseInt(lw);
+            var dy = parseInt(rect.h) + parseInt(lw);
+            context.strokeRect(x0, y0, dx, dy);    
+            ROIInfo[aktindex]["x"] = rect.startX;       
+            ROIInfo[aktindex]["y"] = rect.startY;       
+            ROIInfo[aktindex]["dx"] = rect.w;       
+            ROIInfo[aktindex]["dy"] = rect.h;       
+        }
     }
     }
 
 
     function getCoords(elem) { // crossbrowser version
     function getCoords(elem) { // crossbrowser version

+ 1 - 0
sd-card/html/edit_config.html

@@ -42,6 +42,7 @@ textarea {
 
 
 <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="./readconfig.js"></script>  
+<script type="text/javascript" src="./readconfigcommon.js"></script>  
  
  
 <script type="text/javascript">
 <script type="text/javascript">
 	var canvas = document.getElementById('canvas'),
 	var canvas = document.getElementById('canvas'),

+ 193 - 85
sd-card/html/edit_config_param.html

@@ -160,9 +160,29 @@ textarea {
 				y size (height) in which the reference is searched (default = "20") 
 				y size (height) in which the reference is searched (default = "20") 
 			</td>
 			</td>
 		</tr>
 		</tr>
+		<tr class="expert"  id="AlignmentAlgo_ex8">
+			<td  width="20px"  style="padding-left: 40px;">
+				<input type="checkbox" id="Alignment_AlignmentAlgo_enabled" value="1"  onclick = 'document.getElementById("Alignment_AlignmentAlgo_value1").disabled = !document.getElementById("Alignment_AlignmentAlgo_value1").disabled' unchecked >
+			</td>
+			<td>
+				<class id="Alignment_AlignmentAlgo_text" style="color:black;">AlignmentAlgo</class>
+			</td>
+			<td>
+				<select id="Alignment_AlignmentAlgo_value1">
+					<option value="0" selected>Default</option>
+					<option value="1" >HighAccurity</option>
+					<option value="2" >Fast</option>
+				</select>
+				</td>
+			<td style="font-size: 80%;">
+				"Default" = use only R-Channel, "HighAccurity" = use all Channels (RGB, 3x slower), <br> "Fast" (First time RGB, then only check if image is shifted) 
+			</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> 
 		<tr>
 		<tr>
 			<td width="20px"  style="padding-left: 40px;">
 			<td width="20px"  style="padding-left: 40px;">
@@ -174,7 +194,7 @@ textarea {
 				<input type="text" id="Digits_Model_value1">
 				<input type="text" id="Digits_Model_value1">
 			</td>
 			</td>
 			<td style="font-size: 80%;">
 			<td style="font-size: 80%;">
-				path to CNN model file for image recognition (in seconds)
+				path to CNN model file for image recognition
 			</td>
 			</td>
 		</tr>
 		</tr>
 		<tr>
 		<tr>
@@ -221,62 +241,61 @@ textarea {
 		</tr>
 		</tr>
 
 
 		<tr class="expert"  id="ex4">
 		<tr class="expert"  id="ex4">
-			<td colspan="4" style="padding-left: 20px;"><h4>Analog</h4></td>
+			<td colspan="4" style="padding-left: 20px;">
+				<h4><input type="checkbox" id="Category_Analog_enabled" value="1"  onclick = 'UpdateAfterCategoryCheck()' unchecked > Analog</h4></td>
 		</tr> 
 		</tr> 
 		<tr>
 		<tr>
-			<td width="20px"  style="padding-left: 40px;">
-			</td>
-			<td  width="200px">
-				<class id="Analog_Model_text" style="color:black;">Model</class>
-			</td>
-			<td>
-				<input type="text" id="Analog_Model_value1">
-			</td>
-			<td style="font-size: 80%;">
-				path to CNN model file for image recognition (in seconds)
-			</td>
+			<td width="20px"  style="padding-left: 40px;"> </td>
+			<td width="200px"> <class id="Analog_Model_text" style="color:black;">Model</class> </td>
+			<td> <input type="text" id="Analog_Model_value1"> </td>
+			<td style="font-size: 80%;"> path to CNN model file for image recognition</td>
 		</tr>
 		</tr>
 		<tr>
 		<tr>
 			<td width="20px"  style="padding-left: 40px;">
 			<td width="20px"  style="padding-left: 40px;">
 				<input type="checkbox" id="Analog_LogImageLocation_enabled" value="1"  onclick = 'document.getElementById("Analog_LogImageLocation_value1").disabled = !document.getElementById("Analog_LogImageLocation_value1").disabled' unchecked >
 				<input type="checkbox" id="Analog_LogImageLocation_enabled" value="1"  onclick = 'document.getElementById("Analog_LogImageLocation_value1").disabled = !document.getElementById("Analog_LogImageLocation_value1").disabled' unchecked >
 			</td>
 			</td>
-			<td>
-				<class id="Analog_LogImageLocation_text" style="color:black;">LogImageLocation</class>
-			</td>
-			<td>
-				<input type="text" name="name" id="Analog_LogImageLocation_value1">
-			</td>
-			<td style="font-size: 80%;">
-				Location to store separated digits for logging
-			</td>
+			<td> <class id="Analog_LogImageLocation_text" style="color:black;">LogImageLocation</class> </td>
+			<td> <input type="text" name="name" id="Analog_LogImageLocation_value1"> </td>
+			<td style="font-size: 80%;"> Location to store separated digits for logging </td>
 		</tr>
 		</tr>
 		<tr>
 		<tr>
 			<td width="20px"  style="padding-left: 40px;">
 			<td width="20px"  style="padding-left: 40px;">
 				<td"><input type="checkbox" id="Analog_LogfileRetentionInDays_enabled" value="1"  onclick = 'document.getElementById("Analog_LogfileRetentionInDays_value1").disabled = !document.getElementById("Analog_LogfileRetentionInDays_value1").disabled' unchecked ></td>
 				<td"><input type="checkbox" id="Analog_LogfileRetentionInDays_enabled" value="1"  onclick = 'document.getElementById("Analog_LogfileRetentionInDays_value1").disabled = !document.getElementById("Analog_LogfileRetentionInDays_value1").disabled' unchecked ></td>
 			</td>
 			</td>
-			<td>
-				<class id="Analog_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class>
+			<td> <class id="Analog_LogfileRetentionInDays_text" style="color:black;">LogfileRetentionInDays</class> </td>
+			<td> <input type="number" id="Analog_LogfileRetentionInDays_value1" min="0" step="1"> </td>
+			<td style="font-size: 80%;"> Time to keep the separated digit images (in days -"0" = forever) </td>
+		</tr>
+
+		<tr class="expert"  id="Analog_ExtendedResolution_ex10">
+			<td width="20px"  style="padding-left: 40px;">
+				<input type="checkbox" id="Analog_ExtendedResolution_enabled" value="1"  onclick = 'document.getElementById("Analog_ExtendedResolution_value1").disabled = !document.getElementById("Analog_ExtendedResolution_value1").disabled' unchecked >
+			</td>
+			<td  width="200px">
+				<class id="Analog_ExtendedResolution_text" style="color:black;">ExtendedResolution</class>
 			</td>
 			</td>
 			<td>
 			<td>
-				<input type="number" id="Analog_LogfileRetentionInDays_value1" min="0" step="1">
+				<select id="Analog_ExtendedResolution_value1">
+					<option value="0" selected>true</option>
+					<option value="1" >false</option>
+				</select>
 			</td>
 			</td>
 			<td style="font-size: 80%;">
 			<td style="font-size: 80%;">
-				Time to keep the separated digit images (in days -"0" = forever)
+				Enable to use the after point resolution for the last analog counter
 			</td>
 			</td>
 		</tr>
 		</tr>
+
+
+		ExtendedResolution
+
 		<tr class="expert"  id="ex10">
 		<tr class="expert"  id="ex10">
-			<td width="20px"  style="padding-left: 40px;">
-			</td>
-			<td>
-				<class id="Analog_ModelInputSize_text" style="color:black;">ModelInputSize</class>
-			</td>
+			<td width="20px"  style="padding-left: 40px;"> </td>
+			<td> <class id="Analog_ModelInputSize_text" style="color:black;">ModelInputSize</class> </td>
 			<td>
 			<td>
 				x: <input type="number" id="Analog_ModelInputSize_value1" style="width: 30px;" min="1" step="1">
 				x: <input type="number" id="Analog_ModelInputSize_value1" style="width: 30px;" min="1" step="1">
 				y: <input type="number" id="Analog_ModelInputSize_value2" style="width: 30px;" min="1" step="1">
 				y: <input type="number" id="Analog_ModelInputSize_value2" style="width: 30px;" min="1" step="1">
 			</td>
 			</td>
-			<td style="font-size: 80%;">
-				Size of the input image for the CNN model
-			</td>
+			<td style="font-size: 80%;"> Size of the input image for the CNN model </td>
 		</tr>
 		</tr>
 
 
 		<tr>
 		<tr>
@@ -394,7 +413,7 @@ textarea {
 		</tr>
 		</tr>
 
 
 		<tr>
 		<tr>
-			<td colspan="4" style="padding-left: 20px;"><h4>MQTT</h4></td>
+			<td colspan="4" style="padding-left: 20px;"><h4><input type="checkbox" id="Category_MQTT_enabled" value="1"  onclick = 'UpdateAfterCategoryCheck()' unchecked > MQTT</h4></td>
 		</tr> 		
 		</tr> 		
 		<tr>
 		<tr>
 			<td width="20px"  style="padding-left: 40px;">
 			<td width="20px"  style="padding-left: 40px;">
@@ -468,7 +487,7 @@ textarea {
 		</tr>
 		</tr>
 		<tr>
 		<tr>
 			<td width="20px"  style="padding-left: 40px;">
 			<td width="20px"  style="padding-left: 40px;">
-				<input type="checkbox" id="MQTT_password_enabled" value="1"  onclick = 'document.getElementById("MQTT_password_value1").disabled = !document.getElementById("MQTT_password_value1").disabled' checked >
+				<input type="checkbox" id="MQTT_password_enabled" value="1"  onclick = 'document.getElementById("MQTT_password_value1").disabled = !document.getElementById("MQTT_password_value1").disabled' unchecked >
 			</td>
 			</td>
 			<td  width="200px">
 			<td  width="200px">
 				<class id="MQTT_password_text" style="color:black;">password</class>
 				<class id="MQTT_password_text" style="color:black;">password</class>
@@ -582,6 +601,21 @@ textarea {
 				Time server to synchronize system time (default: "pool.ntp.org" - used if nothing is specified)
 				Time server to synchronize system time (default: "pool.ntp.org" - used if nothing is specified)
 			</td>
 			</td>
 		</tr>
 		</tr>
+		<tr class="expert"  id="System_Hostname">
+			<td width="20px"  style="padding-left: 40px;">
+				<td"><input type="checkbox" id="System_Hostname_enabled" value="1"  onclick = 'document.getElementById("System_Hostname_value1").disabled = !document.getElementById("System_Hostname_value1").disabled' unchecked ></td>
+			</td>
+			<td>
+				<class id="System_Hostname_text" style="color:black;">Hostname</class>
+			</td>
+			<td>
+				<input type="text" id="System_Hostname_value1">
+			</td>
+			<td style="font-size: 80%;">
+				Hostname for server - will be transfered to wlan.ini at next startup)
+			</td>
+		</tr>
+
 	</table>
 	</table>
 
 
 	<p>
 	<p>
@@ -597,12 +631,14 @@ textarea {
 </div>
 </div>
 
 
 <script type="text/javascript" src="./gethost.js"></script> 
 <script type="text/javascript" src="./gethost.js"></script> 
+<script type="text/javascript" src="./readconfigcommon.js"></script>  
 <script type="text/javascript" src="./readconfigparam.js"></script>  
 <script type="text/javascript" src="./readconfigparam.js"></script>  
  
  
 <script type="text/javascript">
 <script type="text/javascript">
 	var canvas = document.getElementById('canvas'),
 	var canvas = document.getElementById('canvas'),
 		basepath = "http://192.168.178.22"; 
 		basepath = "http://192.168.178.22"; 
 		param;
 		param;
+		category;
 
 
 
 
 function LoadConfigNeu() {
 function LoadConfigNeu() {
@@ -613,12 +649,14 @@ function LoadConfigNeu() {
 	} 
 	} 
 	loadConfig(basepath); 
 	loadConfig(basepath); 
 	ParseConfig();	
 	ParseConfig();	
+	param = getConfigParameters();
+	category = getConfigCategory();	
 	UpdateInput();
 	UpdateInput();
 	UpdateExpertModus();
 	UpdateExpertModus();
 	document.getElementById("divall").style.display = ''; 
 	document.getElementById("divall").style.display = ''; 
 	}
 	}
 
 
-function WriteParameter(_param, _cat, _name, _optional, _select = false, _anzpara = 1){
+function WriteParameter(_param, _category, _cat, _name, _optional, _select = false, _anzpara = 1){
 	if (_param[_cat][_name]["found"]){
 	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"];
@@ -654,6 +692,52 @@ function WriteParameter(_param, _cat, _name, _optional, _select = false, _anzpar
 		document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"		
 		document.getElementById(_cat+"_"+_name+"_text").style="color:lightgrey;"		
 	}
 	}
 
 
+
+	///////////////// am Ende, falls Kategorie als gesamtes nicht ausgewählt --> deaktivieren
+	if (_category[_cat]["enabled"] == false) 
+	{
+		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;"		
+	}
+	EnDisableItem(_category[_cat]["enabled"], _param, _category, _cat, _name, _optional);
+}
+
+function EnDisableItem(_status, _param, _category, _cat, _name, _optional)
+{
+	_status = _param[_cat][_name]["found"] && _category[_cat]["enabled"];
+
+	_color = "color:lightgrey;";
+	if (_status) {
+		_color = "color:black;";
+	}
+
+	if (_optional) {
+		document.getElementById(_cat+"_"+_name+"_enabled").disabled = !_status;
+		document.getElementById(_cat+"_"+_name+"_enabled").style=_color;	
+	}
+
+	if (!_param[_cat][_name]["enabled"]) {
+		_status = false;
+		_color = "color:lightgrey;";
+	}
+
+	document.getElementById(_cat+"_"+_name+"_text").disabled = !_status;
+	document.getElementById(_cat+"_"+_name+"_text").style = _color;
+
+	if (_param[_cat][_name]["anzParam"] == 2) {
+		_color = "width: 30px;" + _color;
+	}
+
+	for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
+			document.getElementById(_cat+"_"+_name+"_value"+j).disabled = !_status;	
+			document.getElementById(_cat+"_"+_name+"_value"+j).style=_color;	
+	}
+
 }
 }
 
 
 
 
@@ -667,7 +751,7 @@ function ReadParameter(_param, _cat, _name, _optional, _select = false){
 			_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]["anzpara"]; ++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;
 			}
 			}
 		}
 		}
@@ -675,52 +759,63 @@ function ReadParameter(_param, _cat, _name, _optional, _select = false){
 }
 }
 
 
 function UpdateInput() {
 function UpdateInput() {
-	param = getConfigParameters();
-	WriteParameter(param, "MakeImage", "LogImageLocation", true);
-	WriteParameter(param, "MakeImage", "LogfileRetentionInDays", true);
-	WriteParameter(param, "MakeImage", "WaitBeforeTakingPicture", false);		
-	WriteParameter(param, "MakeImage", "ImageQuality", false);		
-	WriteParameter(param, "MakeImage", "ImageSize", false, true, true);		
-
-	WriteParameter(param, "Alignment", "SearchFieldX", false);		
-	WriteParameter(param, "Alignment", "SearchFieldY", false);		
-
-	WriteParameter(param, "Digits", "Model", false);		
-	WriteParameter(param, "Digits", "LogImageLocation", false);		
-	WriteParameter(param, "Digits", "LogfileRetentionInDays", false);		
-	WriteParameter(param, "Digits", "ModelInputSize", false, false, 2);	
+	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);
+	WriteParameter(param, category, "MakeImage", "LogfileRetentionInDays", true);
+	WriteParameter(param, category, "MakeImage", "WaitBeforeTakingPicture", false);		
+	WriteParameter(param, category, "MakeImage", "ImageQuality", false);		
+	WriteParameter(param, category, "MakeImage", "ImageSize", false, true, true);		
+
+	WriteParameter(param, category, "Alignment", "SearchFieldX", false);		
+	WriteParameter(param, category, "Alignment", "SearchFieldY", false);		
+	WriteParameter(param, category, "Alignment", "AlignmentAlgo", true, true, true);		
+
+	WriteParameter(param, category, "Digits", "Model", false);		
+	WriteParameter(param, category, "Digits", "LogImageLocation", true);		
+	WriteParameter(param, category, "Digits", "LogfileRetentionInDays", true);		
+	WriteParameter(param, category, "Digits", "ModelInputSize", false, false, 2);	
 	
 	
-	WriteParameter(param, "Analog", "Model", false);		
-	WriteParameter(param, "Analog", "LogImageLocation", false);		
-	WriteParameter(param, "Analog", "LogfileRetentionInDays", false);		
-	WriteParameter(param, "Analog", "ModelInputSize", false, false, 2);		
+	WriteParameter(param, category, "Analog", "Model", false);		
+	WriteParameter(param, category, "Analog", "LogImageLocation", true);		
+	WriteParameter(param, category, "Analog", "LogfileRetentionInDays", true);		
+	WriteParameter(param, category, "Analog", "ExtendedResolution", true, true);		
+	WriteParameter(param, category, "Analog", "ModelInputSize", false, false, 2);		
 	
 	
-	WriteParameter(param, "PostProcessing", "DecimalShift", true);		
-	WriteParameter(param, "PostProcessing", "PreValueUse", true, true);		
-	WriteParameter(param, "PostProcessing", "PreValueAgeStartup", true);		
-	WriteParameter(param, "PostProcessing", "AllowNegativeRates", true, true);
-	WriteParameter(param, "PostProcessing", "MaxRateValue", true);		
-	WriteParameter(param, "PostProcessing", "ErrorMessage", true, true);
-	WriteParameter(param, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
-
-	WriteParameter(param, "MQTT", "Uri", true);	
-	WriteParameter(param, "MQTT", "Topic", true);	
-	WriteParameter(param, "MQTT", "TopicError", true);	
-	WriteParameter(param, "MQTT", "ClientID", true);	
-	WriteParameter(param, "MQTT", "user", true);	
-	WriteParameter(param, "MQTT", "password", true);	
-
-	WriteParameter(param, "AutoTimer", "AutoStart", true, true);	
-	WriteParameter(param, "AutoTimer", "Intervall", true);	
-
-	WriteParameter(param, "Debug", "Logfile", true, true);	
-	WriteParameter(param, "Debug", "LogfileRetentionInDays", true);	
-
-	WriteParameter(param, "System", "TimeZone", true);	
-	WriteParameter(param, "System", "TimeServer", true);	
+	WriteParameter(param, category, "PostProcessing", "DecimalShift", true);		
+	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", "ErrorMessage", true, true);
+	WriteParameter(param, category, "PostProcessing", "CheckDigitIncreaseConsistency", true, true);
+
+	WriteParameter(param, category, "MQTT", "Uri", true);	
+	WriteParameter(param, category, "MQTT", "Topic", true);	
+	WriteParameter(param, category, "MQTT", "TopicError", true);	
+	WriteParameter(param, category, "MQTT", "ClientID", true);	
+	WriteParameter(param, category, "MQTT", "user", true);	
+	WriteParameter(param, category, "MQTT", "password", true);	
+
+	WriteParameter(param, category, "AutoTimer", "AutoStart", true, true);	
+	WriteParameter(param, category, "AutoTimer", "Intervall", true);	
+
+	WriteParameter(param, category, "Debug", "Logfile", true, true);	
+	WriteParameter(param, category, "Debug", "LogfileRetentionInDays", true);	
+
+	WriteParameter(param, category, "System", "TimeZone", true);	
+	WriteParameter(param, category, "System", "Hostname", true);	
+	WriteParameter(param, category, "System", "TimeServer", true);	
 }
 }
 
 
-function WriteConfig(){
+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);
 	ReadParameter(param, "MakeImage", "LogImageLocation", true);
 	ReadParameter(param, "MakeImage", "LogfileRetentionInDays", true);
 	ReadParameter(param, "MakeImage", "LogfileRetentionInDays", true);
 	ReadParameter(param, "MakeImage", "WaitBeforeTakingPicture", false);		
 	ReadParameter(param, "MakeImage", "WaitBeforeTakingPicture", false);		
@@ -728,7 +823,8 @@ function WriteConfig(){
 	ReadParameter(param, "MakeImage", "ImageSize", false, true);	
 	ReadParameter(param, "MakeImage", "ImageSize", false, true);	
 
 
 	ReadParameter(param, "Alignment", "SearchFieldX", false);		
 	ReadParameter(param, "Alignment", "SearchFieldX", false);		
-	ReadParameter(param, "Alignment", "SearchFieldY", false);	
+	ReadParameter(param, "Alignment", "SearchFieldY", false);
+	ReadParameter(param, "Alignment", "AlignmentAlgo", true, true);
 
 
 	ReadParameter(param, "Digits", "Model", false);		
 	ReadParameter(param, "Digits", "Model", false);		
 	ReadParameter(param, "Digits", "LogImageLocation", true);		
 	ReadParameter(param, "Digits", "LogImageLocation", true);		
@@ -738,6 +834,7 @@ function WriteConfig(){
 	ReadParameter(param, "Analog", "Model", false);		
 	ReadParameter(param, "Analog", "Model", false);		
 	ReadParameter(param, "Analog", "LogImageLocation", true);		
 	ReadParameter(param, "Analog", "LogImageLocation", true);		
 	ReadParameter(param, "Analog", "LogfileRetentionInDays", true);		
 	ReadParameter(param, "Analog", "LogfileRetentionInDays", true);		
+	ReadParameter(param, "Analog", "ExtendedResolution", true, true);		
 	ReadParameter(param, "Analog", "ModelInputSize", false, false, 2);
 	ReadParameter(param, "Analog", "ModelInputSize", false, false, 2);
 
 
 	ReadParameter(param, "PostProcessing", "DecimalShift", true);		
 	ReadParameter(param, "PostProcessing", "DecimalShift", true);		
@@ -762,21 +859,32 @@ function WriteConfig(){
 	ReadParameter(param, "Debug", "LogfileRetentionInDays", true);	
 	ReadParameter(param, "Debug", "LogfileRetentionInDays", true);	
 
 
 	ReadParameter(param, "System", "TimeZone", true);	
 	ReadParameter(param, "System", "TimeZone", true);	
+	ReadParameter(param, "System", "Hostname", true);	
 	ReadParameter(param, "System", "TimeServer", true);	
 	ReadParameter(param, "System", "TimeServer", true);	
 	
 	
 	FormatDecimalValue(param, "PostProcessing", "MaxRateValue");
 	FormatDecimalValue(param, "PostProcessing", "MaxRateValue");
+}
 
 
-	return setConfigParameters(param);
+function WriteConfig(){
+	ReadParameterAll();
+	return setConfigParameters(param, category);
 }
 }
 
 
 function FormatDecimalValue(_param, _cat, _name) {
 function FormatDecimalValue(_param, _cat, _name) {
-	for (var j = 1; j <= _param[_cat][_name]["anzpara"]; ++j) {
+	for (var j = 1; j <= _param[_cat][_name]["anzParam"]; ++j) {
 		var _val = _param[_cat][_name]["value"+j];
 		var _val = _param[_cat][_name]["value"+j];
 		_val = _val.replace(",", ".");
 		_val = _val.replace(",", ".");
 		_param[_cat][_name]["value"+j] = _val;
 		_param[_cat][_name]["value"+j] = _val;
 	}
 	}
 }
 }
 
 
+function UpdateAfterCategoryCheck() {
+	ReadParameterAll();
+	category["Analog"]["enabled"] = document.getElementById("Category_Analog_enabled").checked;
+	category["Digits"]["enabled"] = document.getElementById("Category_Digits_enabled").checked;
+	UpdateInput();
+}
+
 function UpdateExpertModus()
 function UpdateExpertModus()
 {
 {
 	var _style = 'display:none;';
 	var _style = 'display:none;';

+ 73 - 16
sd-card/html/edit_digits.html

@@ -55,7 +55,10 @@ th, td {
 
 
 <body style="font-family: arial; padding: 0px 10px;">
 <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>
 	<table>
 	  <tr>
 	  <tr>
@@ -91,7 +94,9 @@ th, td {
 		<td>y: <input type="number" name="refy" id="refy" step=1 onchange="valuemanualchanged()"></td>	
 		<td>y: <input type="number" name="refy" id="refy" step=1 onchange="valuemanualchanged()"></td>	
 		<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()"></td>
 		<td>dy: <input type="number" name="refdy" id="refdy" step=1 onchange="valuemanualchanged()"></td>
 	  </tr>
 	  </tr>
-	</table>			 
+    </table>	
+    
+</div>
 			 
 			 
 	<table>
 	<table>
 	  <tr>
 	  <tr>
@@ -101,6 +106,8 @@ th, td {
 
 
 <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="./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">
 <script language="JavaScript">
         var canvas = document.getElementById('canvas'),
         var canvas = document.getElementById('canvas'),
@@ -114,6 +121,41 @@ th, td {
             lockAR = true;
             lockAR = true;
             basepath = "http://192.168.178.26";
             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(){
 function onNameChange(){
     ROIInfo[aktindex]["name"] = document.getElementById("name").value;
     ROIInfo[aktindex]["name"] = document.getElementById("name").value;
     UpdateROIs();
     UpdateROIs();
@@ -172,7 +214,8 @@ function ChangeSelection(){
 }
 }
 
 
 function SaveToConfig(){
 function SaveToConfig(){
-    SaveROIToConfig(ROIInfo, "[Digits]", basepath);
+    _enabled = document.getElementById("Category_Digits_enabled").checked;
+    SaveROIToConfig(ROIInfo, "[Digits]", basepath, _enabled);
     UpdatePage();  
     UpdatePage();  
 }
 }
 
 
@@ -230,8 +273,19 @@ function UpdateROIs(){
 function ParseIni(_basepath) {
 function ParseIni(_basepath) {
     loadConfig(_basepath);
     loadConfig(_basepath);
     ParseConfig();
     ParseConfig();
+
+    document.getElementById("Category_Digits_enabled").checked = true;
     ROIInfo = getROIInfo("[Digits]");
     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();
     UpdateROIs();
 }
 }
 			
 			
@@ -287,22 +341,25 @@ function ParseIni(_basepath) {
         }  
         }  
 
 
 
 
-        function draw() {
+function draw() {
         var canvas = document.getElementById('canvas');
         var canvas = document.getElementById('canvas');
         var context = canvas.getContext('2d');
         var context = canvas.getContext('2d');
         context.drawImage(imageObj, 0, 0);
         context.drawImage(imageObj, 0, 0);
-        lw = 4
-        context.lineWidth = lw;
-        context.strokeStyle = "#FF0000";
-        var x0 = parseInt(rect.startX) - parseInt(lw/2);
-        var y0 = parseInt(rect.startY) - parseInt(lw/2);
-        var dx = parseInt(rect.w) + parseInt(lw);
-        var dy = parseInt(rect.h) + parseInt(lw);
-        context.strokeRect(x0, y0, dx, dy);    
-        ROIInfo[aktindex]["x"] = rect.startX;       
-        ROIInfo[aktindex]["y"] = rect.startY;       
-        ROIInfo[aktindex]["dx"] = rect.w;       
-        ROIInfo[aktindex]["dy"] = rect.h;       
+        if (document.getElementById("Category_Digits_enabled").checked)
+        {
+            lw = 4
+            context.lineWidth = lw;
+            context.strokeStyle = "#FF0000";
+            var x0 = parseInt(rect.startX) - parseInt(lw/2);
+            var y0 = parseInt(rect.startY) - parseInt(lw/2);
+            var dx = parseInt(rect.w) + parseInt(lw);
+            var dy = parseInt(rect.h) + parseInt(lw);
+            context.strokeRect(x0, y0, dx, dy);    
+            ROIInfo[aktindex]["x"] = rect.startX;       
+            ROIInfo[aktindex]["y"] = rect.startY;       
+            ROIInfo[aktindex]["dx"] = rect.w;       
+            ROIInfo[aktindex]["dy"] = rect.h;       
+        }
     }
     }
 
 
     function getCoords(elem) { // crossbrowser version
     function getCoords(elem) { // crossbrowser version

+ 1 - 0
sd-card/html/edit_explain_6.html

@@ -45,6 +45,7 @@ p {font-size: 1em;}
 
 
     <script type="text/javascript" src="./gethost.js"></script> 
     <script type="text/javascript" src="./gethost.js"></script> 
     <script type="text/javascript" src="./readconfigparam.js"></script> 
     <script type="text/javascript" src="./readconfigparam.js"></script> 
+    <script type="text/javascript" src="./readconfigcommon.js"></script> 
 
 
     <script type="text/javascript">
     <script type="text/javascript">
         var canvas = document.getElementById('canvas'),
         var canvas = document.getElementById('canvas'),

+ 1 - 0
sd-card/html/edit_reference.html

@@ -67,6 +67,7 @@ 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="./readconfig.js"></script>  
+    <script type="text/javascript" src="./readconfigcommon.js"></script>  
 
 
     <script language="JavaScript">
     <script language="JavaScript">
         var canvas = document.getElementById('canvas'),
         var canvas = document.getElementById('canvas'),

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

@@ -7,8 +7,8 @@ function getbasepath(){
     var host = window.location.hostname;
     var host = window.location.hostname;
     if ((host == "127.0.0.1") || (host == "localhost"))
     if ((host == "127.0.0.1") || (host == "localhost"))
     {
     {
-        host = "http://192.168.2.118";          // jomjol interner test
-//        host = "http://192.168.178.26";          // 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.22";          // jomjol interner Real
 //        host = "http://192.168.178.22";          // jomjol interner Real
 //        host = ".";                           // jomjol interner localhost   
 //        host = ".";                           // jomjol interner localhost   
 
 

+ 44 - 166
sd-card/html/readconfig.js

@@ -8,6 +8,10 @@ var ref = new Array(2);
 var digit = new Array(0);
 var digit = new Array(0);
 var analog = new Array(0);
 var analog = new Array(0);
 var initalrotate = new Object();
 var initalrotate = new Object();
+var analogEnabled = false;
+var posAnalogHeader;
+var digitsEnabled = false;
+var posDigitsHeader;
 
 
 function MakeRefZW(zw, _basepath){
 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"];
      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"];
@@ -36,7 +40,9 @@ function ParseConfigAlignment(_aktline){
      var akt_ref = 0;
      var akt_ref = 0;
      ++_aktline;
      ++_aktline;
 
 
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
+     while ((_aktline < config_split.length) 
+            && !(config_split[_aktline][0] == "[") 
+            && !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
           var linesplit = ZerlegeZeile(config_split[_aktline]);
           var linesplit = ZerlegeZeile(config_split[_aktline]);
           if ((linesplit[0].toUpperCase() == "INITIALMIRROR") && (linesplit.length > 1))
           if ((linesplit[0].toUpperCase() == "INITIALMIRROR") && (linesplit.length > 1))
           {
           {
@@ -67,7 +73,9 @@ function ParseConfigDigit(_aktline){
      ++_aktline;
      ++_aktline;
      digit.length = 0;
      digit.length = 0;
 
 
-     while ((_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
+     while ((_aktline < config_split.length) 
+            && !(config_split[_aktline][0] == "[") 
+            && !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
           var linesplit = ZerlegeZeile(config_split[_aktline]);
           var linesplit = ZerlegeZeile(config_split[_aktline]);
           if (linesplit.length >= 5)
           if (linesplit.length >= 5)
           {
           {
@@ -86,12 +94,23 @@ function ParseConfigDigit(_aktline){
      return _aktline; 
      return _aktline; 
 }
 }
 
 
+function GetAnalogEnabled() {
+     return analogEnabled;
+}
+
+
+function GetDigitsEnabled() {
+     return digitsEnabled;
+}
+
 
 
 function ParseConfigAnalog(_aktline){
 function ParseConfigAnalog(_aktline){
      ++_aktline;
      ++_aktline;
      analog.length = 0;
      analog.length = 0;
 
 
-     while ((_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
+     while ((_aktline < config_split.length) 
+            && !(config_split[_aktline][0] == "[") 
+            && !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
           var linesplit = ZerlegeZeile(config_split[_aktline]);
           var linesplit = ZerlegeZeile(config_split[_aktline]);
           if (linesplit.length >= 5)
           if (linesplit.length >= 5)
           {
           {
@@ -121,11 +140,21 @@ function getROIInfo(_typeROI){
      return targetROI.slice();         // Kopie senden, nicht orginal!!!
      return targetROI.slice();         // Kopie senden, nicht orginal!!!
 }
 }
 
 
-function SaveROIToConfig(_ROIInfo, _typeROI, _basepath){
+function SaveROIToConfig(_ROIInfo, _typeROI, _basepath, _enabled){
+     if (_enabled) {
+          text = _typeROI;
+     }
+     else {
+          text = ";" + _typeROI;
+     }
+
      if (_typeROI == "[Digits]"){
      if (_typeROI == "[Digits]"){
+          config_split[posDigitsHeader] = text;
           targetROI = digit;
           targetROI = digit;
      }
      }
+
      if (_typeROI == "[Analog]"){
      if (_typeROI == "[Analog]"){
+          config_split[posAnalogHeader] = text;
           targetROI = analog;
           targetROI = analog;
      }
      }
 
 
@@ -165,16 +194,24 @@ function ParseConfig() {
      var aktline = 0;
      var aktline = 0;
 
 
      while (aktline < config_split.length){
      while (aktline < config_split.length){
-          if (config_split[aktline].trim().toUpperCase() == "[ALIGNMENT]") {
+          if ((config_split[aktline].trim().toUpperCase() == "[ALIGNMENT]") || (config_split[aktline].trim().toUpperCase() == ";[ALIGNMENT]")){
                aktline = ParseConfigAlignment(aktline);
                aktline = ParseConfigAlignment(aktline);
                continue;
                continue;
           }
           }
-          if (config_split[aktline].trim().toUpperCase() == "[DIGITS]") {
+          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);
                aktline = ParseConfigDigit(aktline);
                continue;
                continue;
           }
           }
 
 
-          if (config_split[aktline].trim().toUpperCase() == "[ANALOG]") {
+          if ((config_split[aktline].trim().toUpperCase() == "[ANALOG]") || (config_split[aktline].trim().toUpperCase() == ";[ANALOG]")) {
+               posAnalogHeader = aktline;
+               if (config_split[aktline][0] == "[") {
+                    analogEnabled = true;
+               }
                aktline = ParseConfigAnalog(aktline);
                aktline = ParseConfigAnalog(aktline);
                continue;
                continue;
           }
           }
@@ -313,19 +350,6 @@ function MakeContrastImageZW(zw, _enhance, _basepath){
      }
      }
 }
 }
 
 
-function createReader(file) {
-     var image = new Image();
-     reader.onload = function(evt) {
-         var image = new Image();
-         image.onload = function(evt) {
-             var width = this.width;
-             var height = this.height;
-             alert (width); // will produce something like 198
-         };
-         image.src = evt.target.result; 
-     };
-     reader.readAsDataURL(file);
- }
 
 
 function GetReferenceSize(name){
 function GetReferenceSize(name){
      img = new Image();
      img = new Image();
@@ -346,83 +370,6 @@ function GetReferenceSize(name){
      return [img.width, img.height];
      return [img.width, img.height];
 }
 }
 
 
-
-function ZerlegeZeile(input)
-     {
-          var Output = Array(0);
-          delimiter = " =,\r";
-     
-          input = trim(input, delimiter);
-          var pos = findDelimiterPos(input, delimiter);
-          var token;
-          while (pos > -1) {
-               token = input.substr(0, pos);
-               token = trim(token, delimiter);
-               Output.push(token);
-               input = input.substr(pos+1, input.length);
-               input = trim(input, delimiter);
-               pos = findDelimiterPos(input, delimiter);
-          }
-          Output.push(input);
-     
-          return Output;
-     
-     }    
-
-function findDelimiterPos(input, delimiter)
-     {
-          var pos = -1;
-          var zw;
-          var akt_del;
-     
-          for (var anz = 0; anz < delimiter.length; ++anz)
-          {
-               akt_del = delimiter[anz];
-               zw = input.indexOf(akt_del);
-               if (zw > -1)
-               {
-                    if (pos > -1)
-                    {
-                         if (zw < pos)
-                              pos = zw;
-                    }
-                    else
-                         pos = zw;
-               }
-          }
-          return pos;
-     }
-     
-     
-
-function trim(istring, adddelimiter)
-     {
-          while ((istring.length > 0) && (adddelimiter.indexOf(istring[0]) >= 0)){
-               istring = istring.substr(1, istring.length-1);
-          }
-          
-          while ((istring.length > 0) && (adddelimiter.indexOf(istring[istring.length-1]) >= 0)){
-               istring = istring.substr(0, istring.length-1);
-          }
-
-          return istring;
-     }
-     
-
-     
-function loadConfig(_basepath) {
-     var xhttp = new XMLHttpRequest();
-     try {
-          url = _basepath + '/fileserver/config/config.ini';     
-          xhttp.open("GET", url, false);
-          xhttp.send();
-          config_gesamt = xhttp.responseText;
-     }
-     catch (error)
-     {
-     //          alert("Deleting Config.ini failed");
-     }
-}
 	 
 	 
 function getConfig() {
 function getConfig() {
 	return config_gesamt;
 	return config_gesamt;
@@ -438,76 +385,7 @@ function dataURLtoBlob(dataurl) {
      }
      }
      return new Blob([u8arr], {type:mime});
      return new Blob([u8arr], {type:mime});
      }	
      }	
-     
-function FileCopyOnServer(_source, _target, _basepath = ""){
-     url = _basepath + "/editflow.html?task=copy&in=" + _source + "&out=" + _target;
-     var xhttp = new XMLHttpRequest();  
-     try {
-          xhttp.open("GET", url, false);
-          xhttp.send();     }
-     catch (error)
-     {
-//          alert("Deleting Config.ini failed");
-     }
-}
-
-function FileDeleteOnServer(_filename, _basepath = ""){
-     var xhttp = new XMLHttpRequest();
-     var okay = false;
-
-     xhttp.onreadystatechange = function() {
-          if (xhttp.readyState == 4) {
-               if (xhttp.status == 200) {
-                    okay = true;
-               } else if (xhttp.status == 0) {
-//                    alert("Server closed the connection on delete abruptly!");
-//                    location.reload()
-               } else {
-//                    alert(xhttp.status + " Error!\n" + xhttp.responseText);
-//                    location.reload()
-               }
-          }
-     };
-     try {
-          var url = _basepath + "/delete" + _filename;
-          xhttp.open("POST", url, false);
-          xhttp.send();
-     }
-     catch (error)
-     {
-//          alert("Deleting Config.ini failed");
-     }
-
-     return okay;
-}
-
-function FileSendContent(_content, _filename, _basepath = ""){
-     var xhttp = new XMLHttpRequest();  
-     var okay = false;
-
-     xhttp.onreadystatechange = function() {
-          if (xhttp.readyState == 4) {
-               if (xhttp.status == 200) {
-                    okay = true;
-               } else if (xhttp.status == 0) {
-                    alert("Server closed the connection abruptly!");
-               } else {
-                    alert(xhttp.status + " Error!\n" + xhttp.responseText);
-               }
-          }
-     };
 
 
-     try {
-          upload_path = _basepath + "/upload" + _filename;
-          xhttp.open("POST", upload_path, false);
-          xhttp.send(_content);
-     }
-     catch (error)
-     {
-//          alert("Deleting Config.ini failed");
-     }     
-    return okay;        
-}
                     
                     
 function SaveReferenceImage(_id_canvas, _filename, _doDelete, _basepath = ""){
 function SaveReferenceImage(_id_canvas, _filename, _doDelete, _basepath = ""){
      if (_doDelete){
      if (_doDelete){

+ 263 - 0
sd-card/html/readconfigcommon.js

@@ -0,0 +1,263 @@
+function readconfig_Version(){
+     return "1.0.0 - 20200910";
+ }
+
+function SaveConfigToServer(_basepath){
+     // leere Zeilen am Ende löschen
+     var zw = config_split.length - 1;
+     while (config_split[zw] == "") {
+          config_split.pop();
+     }
+
+     var config_gesamt = "";
+     for (var i = 0; i < config_split.length; ++i)
+     {
+          config_gesamt = config_gesamt + config_split[i] + "\n";
+     } 
+
+     FileDeleteOnServer("/config/config.ini", _basepath);
+
+     FileSendContent(config_gesamt, "/config/config.ini", _basepath);          
+}
+
+function UpdateConfigFileReferenceChange(_basepath){
+     for (var _index = 0; _index < ref.length; ++_index){
+          var zeile = ref[_index]["name"] + " " + ref[_index]["x"] + " " + ref[_index]["y"];
+          var _pos = ref[_index]["pos_ref"];
+          config_split[_pos] = zeile;          
+     }
+
+     zeile = "InitialRotate = " + initalrotate["angle"];
+     var _pos = initalrotate["pos_config"];
+     config_split[_pos] = zeile;
+
+     var mirror = false;
+     if (initalrotate.hasOwnProperty("mirror")) {
+          mirror = initalrotate["mirror"];
+     }
+     var mirror_pos = -1;
+     if (initalrotate.hasOwnProperty("pos_config_mirror")) {
+          mirror_pos = initalrotate["pos_config_mirror"];
+     }     
+     if (mirror_pos > -1) {
+          if (mirror) {
+               config_split[mirror_pos] = "InitialMirror = true";
+          }
+          else {
+               config_split[mirror_pos] = "InitialMirror = false";
+          }
+     }
+     else {
+          if (mirror) {       // neue Zeile muss an der richtigen Stelle eingefügt werden - hier direct nach [Alignment]
+               var aktline = 0;
+
+               while (aktline < config_split.length){
+                    if (config_split[aktline].trim() == "[Alignment]") {
+                         break;
+                    }
+                    aktline++
+               }
+
+               // fuege neue Zeile in config_split ein
+               var zw = config_split[config_split.length-1];
+               config_split.push(zw);
+               for (var j = config_split.length-2; j > aktline + 1; --j){
+                    config_split[j] = config_split[j-1];
+               }
+
+               config_split[aktline + 1] = "InitialMirror = True"
+          }
+     }
+
+     SaveConfigToServer(_basepath);
+}
+
+function UpdateConfig(zw, _index, _enhance, _basepath){
+     var zeile = zw["name"] + " " + zw["x"] + " " + zw["y"];
+     var _pos = ref[_index]["pos_ref"];
+     config_split[_pos] = zeile;
+
+     SaveConfigToServer(_basepath);
+
+     var namezw = zw["name"];
+     FileCopyOnServer("/img_tmp/ref_zw.jpg", namezw, _basepath);
+     var namezw = zw["name"].replace(".jpg", "_org.jpg");
+     FileCopyOnServer("/img_tmp/ref_zw_org.jpg", namezw, _basepath);     
+}
+
+
+function createReader(file) {
+     var image = new Image();
+     reader.onload = function(evt) {
+         var image = new Image();
+         image.onload = function(evt) {
+             var width = this.width;
+             var height = this.height;
+             alert (width); // will produce something like 198
+         };
+         image.src = evt.target.result; 
+     };
+     reader.readAsDataURL(file);
+ }
+
+
+
+function ZerlegeZeile(input)
+     {
+          var Output = Array(0);
+          delimiter = " =,\r";
+     
+          input = trim(input, delimiter);
+          var pos = findDelimiterPos(input, delimiter);
+          var token;
+          while (pos > -1) {
+               token = input.substr(0, pos);
+               token = trim(token, delimiter);
+               Output.push(token);
+               input = input.substr(pos+1, input.length);
+               input = trim(input, delimiter);
+               pos = findDelimiterPos(input, delimiter);
+          }
+          Output.push(input);
+     
+          return Output;
+     
+     }    
+
+function findDelimiterPos(input, delimiter)
+     {
+          var pos = -1;
+          var zw;
+          var akt_del;
+     
+          for (var anz = 0; anz < delimiter.length; ++anz)
+          {
+               akt_del = delimiter[anz];
+               zw = input.indexOf(akt_del);
+               if (zw > -1)
+               {
+                    if (pos > -1)
+                    {
+                         if (zw < pos)
+                              pos = zw;
+                    }
+                    else
+                         pos = zw;
+               }
+          }
+          return pos;
+     }
+     
+     
+
+function trim(istring, adddelimiter)
+     {
+          while ((istring.length > 0) && (adddelimiter.indexOf(istring[0]) >= 0)){
+               istring = istring.substr(1, istring.length-1);
+          }
+          
+          while ((istring.length > 0) && (adddelimiter.indexOf(istring[istring.length-1]) >= 0)){
+               istring = istring.substr(0, istring.length-1);
+          }
+
+          return istring;
+     }
+     
+
+     
+function loadConfig(_basepath) {
+     var xhttp = new XMLHttpRequest();
+     try {
+          url = _basepath + '/fileserver/config/config.ini';     
+          xhttp.open("GET", url, false);
+          xhttp.send();
+          config_gesamt = xhttp.responseText;
+     }
+     catch (error)
+     {
+     //          alert("Deleting Config.ini failed");
+     }
+     return true;
+}
+
+     
+
+
+function dataURLtoBlob(dataurl) {
+     var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
+          bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
+     while(n--){
+          u8arr[n] = bstr.charCodeAt(n);
+     }
+     return new Blob([u8arr], {type:mime});
+     }	
+     
+function FileCopyOnServer(_source, _target, _basepath = ""){
+     url = _basepath + "/editflow.html?task=copy&in=" + _source + "&out=" + _target;
+     var xhttp = new XMLHttpRequest();  
+     try {
+          xhttp.open("GET", url, false);
+          xhttp.send();     }
+     catch (error)
+     {
+//          alert("Deleting Config.ini failed");
+     }
+}
+
+function FileDeleteOnServer(_filename, _basepath = ""){
+     var xhttp = new XMLHttpRequest();
+     var okay = false;
+
+     xhttp.onreadystatechange = function() {
+          if (xhttp.readyState == 4) {
+               if (xhttp.status == 200) {
+                    okay = true;
+               } else if (xhttp.status == 0) {
+//                    alert("Server closed the connection on delete abruptly!");
+//                    location.reload()
+               } else {
+//                    alert(xhttp.status + " Error!\n" + xhttp.responseText);
+//                    location.reload()
+               }
+          }
+     };
+     try {
+          var url = _basepath + "/delete" + _filename;
+          xhttp.open("POST", url, false);
+          xhttp.send();
+     }
+     catch (error)
+     {
+//          alert("Deleting Config.ini failed");
+     }
+
+     return okay;
+}
+
+function FileSendContent(_content, _filename, _basepath = ""){
+     var xhttp = new XMLHttpRequest();  
+     var okay = false;
+
+     xhttp.onreadystatechange = function() {
+          if (xhttp.readyState == 4) {
+               if (xhttp.status == 200) {
+                    okay = true;
+               } else if (xhttp.status == 0) {
+                    alert("Server closed the connection abruptly!");
+               } else {
+                    alert(xhttp.status + " Error!\n" + xhttp.responseText);
+               }
+          }
+     };
+
+     try {
+          upload_path = _basepath + "/upload" + _filename;
+          xhttp.open("POST", upload_path, false);
+          xhttp.send(_content);
+     }
+     catch (error)
+     {
+//          alert("Deleting Config.ini failed");
+     }     
+    return okay;        
+}

+ 87 - 383
sd-card/html/readconfigparam.js

@@ -5,6 +5,7 @@ function readconfig_Version(){
 var config_gesamt;
 var config_gesamt;
 var config_split;
 var config_split;
 var param;
 var param;
+var category;
 var ref = new Array(2);
 var ref = new Array(2);
 
 
 function ParseConfig() {
 function ParseConfig() {
@@ -12,8 +13,12 @@ function ParseConfig() {
      var aktline = 0;
      var aktline = 0;
 
 
      param = new Object();
      param = new Object();
+     category = new Object(); 
 
 
      var catname = "MakeImage";
      var catname = "MakeImage";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "LogImageLocation");
      ParamAddValue(param, catname, "LogImageLocation");
      ParamAddValue(param, catname, "WaitBeforeTakingPicture");
      ParamAddValue(param, catname, "WaitBeforeTakingPicture");
@@ -22,25 +27,39 @@ function ParseConfig() {
      ParamAddValue(param, catname, "ImageSize");     
      ParamAddValue(param, catname, "ImageSize");     
 
 
      var catname = "Alignment";
      var catname = "Alignment";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "SearchFieldX");
      ParamAddValue(param, catname, "SearchFieldX");
      ParamAddValue(param, catname, "SearchFieldY");     
      ParamAddValue(param, catname, "SearchFieldY");     
+     ParamAddValue(param, catname, "AlignmentAlgo");     
 
 
      var catname = "Digits";
      var catname = "Digits";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "Model");
      ParamAddValue(param, catname, "Model");
      ParamAddValue(param, catname, "LogImageLocation");
      ParamAddValue(param, catname, "LogImageLocation");
      ParamAddValue(param, catname, "LogfileRetentionInDays");
      ParamAddValue(param, catname, "LogfileRetentionInDays");
-     ParamAddValue(param, catname, "ModelInputSize");     
+     ParamAddValue(param, catname, "ModelInputSize", 2);     
 
 
      var catname = "Analog";
      var catname = "Analog";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "Model");
      ParamAddValue(param, catname, "Model");
      ParamAddValue(param, catname, "LogImageLocation");
      ParamAddValue(param, catname, "LogImageLocation");
      ParamAddValue(param, catname, "LogfileRetentionInDays");
      ParamAddValue(param, catname, "LogfileRetentionInDays");
-     ParamAddValue(param, catname, "ModelInputSize");
+     ParamAddValue(param, catname, "ModelInputSize", 2);
+     ParamAddValue(param, catname, "ExtendedResolution");
 
 
      var catname = "PostProcessing";
      var catname = "PostProcessing";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "DecimalShift");
      ParamAddValue(param, catname, "DecimalShift");
      ParamAddValue(param, catname, "PreValueUse");
      ParamAddValue(param, catname, "PreValueUse");
@@ -51,6 +70,9 @@ function ParseConfig() {
      ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");     
      ParamAddValue(param, catname, "CheckDigitIncreaseConsistency");     
 
 
      var catname = "MQTT";
      var catname = "MQTT";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = 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, "Topic");
@@ -60,227 +82,77 @@ function ParseConfig() {
      ParamAddValue(param, catname, "password");     
      ParamAddValue(param, catname, "password");     
 
 
      var catname = "AutoTimer";
      var catname = "AutoTimer";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "AutoStart");
      ParamAddValue(param, catname, "AutoStart");
      ParamAddValue(param, catname, "Intervall");     
      ParamAddValue(param, catname, "Intervall");     
 
 
      var catname = "Debug";
      var catname = "Debug";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "Logfile");
      ParamAddValue(param, catname, "Logfile");
      ParamAddValue(param, catname, "LogfileRetentionInDays");
      ParamAddValue(param, catname, "LogfileRetentionInDays");
 
 
      var catname = "System";
      var catname = "System";
+     category[catname] = new Object(); 
+     category[catname]["enabled"] = false;
+     category[catname]["found"] = false;
      param[catname] = new Object();
      param[catname] = new Object();
      ParamAddValue(param, catname, "TimeZone");
      ParamAddValue(param, catname, "TimeZone");
      ParamAddValue(param, catname, "TimeServer");         
      ParamAddValue(param, catname, "TimeServer");         
      ParamAddValue(param, catname, "AutoAdjustSummertime");
      ParamAddValue(param, catname, "AutoAdjustSummertime");
+     ParamAddValue(param, catname, "Hostname");   
      ParamAddValue(param, catname, "SetupMode");   
      ParamAddValue(param, catname, "SetupMode");   
 
 
      while (aktline < config_split.length){
      while (aktline < config_split.length){
-          if (config_split[aktline].trim().toUpperCase() == "[MAKEIMAGE]") {
-               aktline = ParseConfigParamMakeImage(aktline);
-               continue;
-          }
-
-          if (config_split[aktline].trim().toUpperCase() == "[ALIGNMENT]") {
-               aktline = ParseConfigParamAlignment(aktline);
-               continue;
-          }
-
-          if (config_split[aktline].trim().toUpperCase() == "[DIGITS]") {
-               aktline = ParseConfigParamDigit(aktline);
-               continue;
-          }
-
-          if (config_split[aktline].trim().toUpperCase() == "[ANALOG]") {
-               aktline = ParseConfigParamAnalog(aktline);
-               continue;
+          for (var cat in category) {
+               zw = cat.toUpperCase();
+               zw1 = "[" + zw + "]";
+               zw2 = ";[" + zw + "]";
+               if ((config_split[aktline].trim().toUpperCase() == zw1) || (config_split[aktline].trim().toUpperCase() == zw2)) {
+                    if (config_split[aktline].trim().toUpperCase() == zw1) {
+                         category[cat]["enabled"] = true;
+                    }
+                    category[cat]["found"] = true;
+                    category[cat]["line"] = aktline;
+                    aktline = ParseConfigParamAll(aktline, cat);
+                    continue;
+               }
           }
           }
-
-          if (config_split[aktline].trim().toUpperCase() == "[POSTPROCESSING]") {
-               aktline = ParseConfigParamPostProcessing(aktline);
-               continue;
-          }          
-
-          if (config_split[aktline].trim().toUpperCase() == "[MQTT]") {
-               aktline = ParseConfigParamMQTT(aktline);
-               continue;
-          }  
-
-          if (config_split[aktline].trim().toUpperCase() == "[AUTOTIMER]") {
-               aktline = ParseConfigParamAutoTimer(aktline);
-               continue;
-          }  
-
-          if (config_split[aktline].trim().toUpperCase() == "[DEBUG]") {
-               aktline = ParseConfigParamDebug(aktline);
-               continue;
-          }          
-
-          if (config_split[aktline].trim().toUpperCase() == "[SYSTEM]") {
-               aktline = ParseConfigParamSystem(aktline);
-               continue;
-          }              
-          
-          
-
-
-
           aktline++;
           aktline++;
      }
      }
 }
 }
 
 
-function ParamAddValue(param, _cat, _param){
+function ParamAddValue(param, _cat, _param, _anzParam = 1){
      param[_cat][_param] = new Object(); 
      param[_cat][_param] = new Object(); 
      param[_cat][_param]["found"] = false;
      param[_cat][_param]["found"] = false;
      param[_cat][_param]["enabled"] = false;
      param[_cat][_param]["enabled"] = false;
-     param[_cat][_param]["line"] = -1;     
+     param[_cat][_param]["line"] = -1; 
+     param[_cat][_param]["anzParam"] = _anzParam;    
 };
 };
 
 
 
 
-function ParseConfigParamSystem(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "System";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input, " =");
-
-          ParamExtractValue(param, linesplit, catname, "TimeZone", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "TimeServer", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "AutoAdjustSummertime", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "TimeUpdateIntervall", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "SetupMode", _aktline, isCom);
-
-          ++_aktline;
-     }    
-     return _aktline; 
-}
-
-function ParseConfigParamDebug(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "Debug";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "Logfile", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
-
-          ++_aktline;
-     }    
-     return _aktline; 
-}
-
-function ParseConfigParamAutoTimer(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "AutoTimer";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "AutoStart", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "Intervall", _aktline, isCom);
-
-          ++_aktline;
-     }    
-     return _aktline; 
-}
-
-function ParseConfigParamMQTT(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "MQTT";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "Uri", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "Topic", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "TopicError", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "ClientID", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "user", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "password", _aktline, isCom);
-
-          ++_aktline;
-     }    
-     return _aktline; 
-}
-
-function ParseConfigParamPostProcessing(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "PostProcessing";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "DecimalShift", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "PreValueUse", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "PreValueAgeStartup", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "AllowNegativeRates", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "MaxRateValue", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "ErrorMessage", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "CheckDigitIncreaseConsistency", _aktline, isCom);
-
-          ++_aktline;
-     }    
-     return _aktline; 
-}
 
 
-function ParseConfigParamAnalog(_aktline){
-     var akt_ref = 0;
+function ParseConfigParamAll(_aktline, _catname){
      ++_aktline;
      ++_aktline;
 
 
-     var catname = "Analog";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
+     while ((_aktline < config_split.length) 
+            && !(config_split[_aktline][0] == "[") 
+            && !((config_split[_aktline][0] == ";") && (config_split[_aktline][1] == "["))) {
           var _input = config_split[_aktline];
           var _input = config_split[_aktline];
           let [isCom, input] = isCommented(_input);
           let [isCom, input] = isCommented(_input);
           var linesplit = ZerlegeZeile(input);
           var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "Model", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "LogImageLocation", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "ModelInputSize", _aktline, isCom, 2);
+          ParamExtractValueAll(param, linesplit, _catname, _aktline, isCom);
 
 
           ++_aktline;
           ++_aktline;
      }    
      }    
      return _aktline; 
      return _aktline; 
 }
 }
 
 
-function ParseConfigParamDigit(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "Digits";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "Model", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "LogImageLocation", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "ModelInputSize", _aktline, isCom, 2);
-
-          ++_aktline;
-     }    
-     return _aktline; 
-}
-
-
 function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _iscom, _anzvalue = 1){
 function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _iscom, _anzvalue = 1){
      if ((_linesplit[0].toUpperCase() == _paramname.toUpperCase()) && (_linesplit.length > _anzvalue))
      if ((_linesplit[0].toUpperCase() == _paramname.toUpperCase()) && (_linesplit.length > _anzvalue))
      {
      {
@@ -294,66 +166,40 @@ function ParamExtractValue(_param, _linesplit, _catname, _paramname, _aktline, _
      }
      }
 }
 }
 
 
-
-function ParseConfigParamAlignment(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "Alignment";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "SearchFieldX", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "SearchFieldY", _aktline, isCom);
-
-          ++_aktline;
-     }    
-     return _aktline; 
-}
-
-function ParseConfigParamMakeImage(_aktline){
-     var akt_ref = 0;
-     ++_aktline;
-
-     var catname = "MakeImage";
-     while ((akt_ref < 2) && (_aktline < config_split.length) && (config_split[_aktline][0] != "[")) {
-          var _input = config_split[_aktline];
-          let [isCom, input] = isCommented(_input);
-          var linesplit = ZerlegeZeile(input);
-
-          ParamExtractValue(param, linesplit, catname, "LogImageLocation", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "WaitBeforeTakingPicture", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "LogfileRetentionInDays", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "ImageQuality", _aktline, isCom);
-          ParamExtractValue(param, linesplit, catname, "ImageSize", _aktline, isCom);          
-
-          ++_aktline;
-     }    
-     return _aktline; 
+function ParamExtractValueAll(_param, _linesplit, _catname, _aktline, _iscom){
+     for (var paramname in _param[_catname]) {
+          if ((_linesplit[0].toUpperCase() == paramname.toUpperCase()) && (_linesplit.length > _param[_catname][paramname]["anzParam"]))
+          {
+               _param[_catname][paramname]["found"] = true;
+               _param[_catname][paramname]["enabled"] = !_iscom;
+               _param[_catname][paramname]["line"] = _aktline;
+               for (var j = 1; j <= _param[_catname][paramname]["anzParam"]; ++j) {
+                    _param[_catname][paramname]["value"+j] = _linesplit[j];
+                    }
+          }
+     }
 }
 }
 
 
 function getConfigParameters() {
 function getConfigParameters() {
      return param;
      return param;
 }
 }
 
 
-function setConfigParameters(_param) {
+function setConfigParameters(_param, _category) {
      for (var cat in _param) {
      for (var cat in _param) {
           for (var name in _param[cat]) {
           for (var name in _param[cat]) {
                param[cat][name]["found"] = _param[cat][name]["found"];
                param[cat][name]["found"] = _param[cat][name]["found"];
                param[cat][name]["enabled"] = _param[cat][name]["enabled"];
                param[cat][name]["enabled"] = _param[cat][name]["enabled"];
                param[cat][name]["line"] = _param[cat][name]["line"];
                param[cat][name]["line"] = _param[cat][name]["line"];
 
 
-               param[cat][name]["anzpara"] = _param[cat][name]["anzpara"];
-               for (var j = 1; j <= _param[cat][name]["anzpara"]; ++j) {
+               param[cat][name]["anzParam"] = _param[cat][name]["anzParam"];
+               for (var j = 1; j <= _param[cat][name]["anzParam"]; ++j) {
                     param[cat][name]["value"+j] =  _param[cat][name]["value"+j];
                     param[cat][name]["value"+j] =  _param[cat][name]["value"+j];
                     }
                     }
 
 
                if (param[cat][name]["found"]) {
                if (param[cat][name]["found"]) {
                     var text = name + " =" 
                     var text = name + " =" 
                     
                     
-                    for (var j = 1; j <= _param[cat][name]["anzpara"]; ++j) {
+                    for (var j = 1; j <= _param[cat][name]["anzParam"]; ++j) {
                          text = text + " " + param[cat][name]["value"+j];
                          text = text + " " + param[cat][name]["value"+j];
                          }
                          }
                     if (!param[cat][name]["enabled"]) {
                     if (!param[cat][name]["enabled"]) {
@@ -364,6 +210,19 @@ function setConfigParameters(_param) {
           }
           }
      }
      }
 
 
+     for (var cat in _category) {
+          if (category[cat]["found"])
+          {
+               category[cat]["enabled"] = _category[cat]["enabled"];
+               text = "[" + cat + "]";
+               if (!category[cat]["enabled"]) {
+                    text = ";" + text;
+               }
+               config_split[category[cat]["line"]] = text;
+
+          }
+     }
+     
      config_gesamt = config_split[0];
      config_gesamt = config_split[0];
      for (var i = 1; i < config_split.length; ++i){
      for (var i = 1; i < config_split.length; ++i){
           config_gesamt = config_gesamt + "\n" + config_split[i]; 
           config_gesamt = config_gesamt + "\n" + config_split[i]; 
@@ -397,171 +256,16 @@ function SaveConfigToServer(_basepath){
      } 
      } 
 
 
      FileDeleteOnServer("/config/config.ini", _basepath);
      FileDeleteOnServer("/config/config.ini", _basepath);
-
      FileSendContent(config_gesamt, "/config/config.ini", _basepath);          
      FileSendContent(config_gesamt, "/config/config.ini", _basepath);          
 }
 }
-
-function createReader(file) {
-     var image = new Image();
-     reader.onload = function(evt) {
-         var image = new Image();
-         image.onload = function(evt) {
-             var width = this.width;
-             var height = this.height;
-             alert (width); // will produce something like 198
-         };
-         image.src = evt.target.result; 
-     };
-     reader.readAsDataURL(file);
- }
-
-function ZerlegeZeile(input, delimiter = " =,")
-     {
-          var Output = Array(0);
-//          delimiter = " =,";
-     
-          input = trim(input, delimiter);
-          var pos = findDelimiterPos(input, delimiter);
-          var token;
-          while (pos > -1) {
-               token = input.substr(0, pos);
-               token = trim(token, delimiter);
-               Output.push(token);
-               input = input.substr(pos+1, input.length);
-               input = trim(input, delimiter);
-               pos = findDelimiterPos(input, delimiter);
-          }
-          Output.push(input);
-     
-          return Output;
-     
-     }    
-
-function findDelimiterPos(input, delimiter)
-     {
-          var pos = -1;
-          var zw;
-          var akt_del;
-     
-          for (var anz = 0; anz < delimiter.length; ++anz)
-          {
-               akt_del = delimiter[anz];
-               zw = input.indexOf(akt_del);
-               if (zw > -1)
-               {
-                    if (pos > -1)
-                    {
-                         if (zw < pos)
-                              pos = zw;
-                    }
-                    else
-                         pos = zw;
-               }
-          }
-          return pos;
-     }
- 
-function trim(istring, adddelimiter)
-     {
-          while ((istring.length > 0) && (adddelimiter.indexOf(istring[0]) >= 0)){
-               istring = istring.substr(1, istring.length-1);
-          }
-          
-          while ((istring.length > 0) && (adddelimiter.indexOf(istring[istring.length-1]) >= 0)){
-               istring = istring.substr(0, istring.length-1);
-          }
-
-          return istring;
-     }
-     
-function loadConfig(_basepath) {
-     var xhttp = new XMLHttpRequest();
-     config_gesamt = "";
-     try {
-          url = _basepath + '/fileserver/config/config.ini';     
-          xhttp.open("GET", url, false);
-          xhttp.send();
-          config_gesamt = xhttp.responseText;
-          return true;
-     }
-     catch (error)
-     {
-     //          alert("Deleting Config.ini failed");
-     }
-     return false;
-}
 	 
 	 
 function getConfig() {
 function getConfig() {
 	return config_gesamt;
 	return config_gesamt;
      }
      }
-     
-     
-function FileCopyOnServer(_source, _target, _basepath = ""){
-     url = _basepath + "/editflow.html?task=copy&in=" + _source + "&out=" + _target;
-     var xhttp = new XMLHttpRequest();  
-     try {
-          xhttp.open("GET", url, false);
-          xhttp.send();     }
-     catch (error)
-     {
-//          alert("Deleting Config.ini failed");
-     }
-}
 
 
-function FileDeleteOnServer(_filename, _basepath = ""){
-     var xhttp = new XMLHttpRequest();
-     var okay = false;
-
-     xhttp.onreadystatechange = function() {
-          if (xhttp.readyState == 4) {
-               if (xhttp.status == 200) {
-                    okay = true;
-               } else if (xhttp.status == 0) {
-//                    alert("Server closed the connection on delete abruptly!");
-//                    location.reload()
-               } else {
-//                    alert(xhttp.status + " Error!\n" + xhttp.responseText);
-//                    location.reload()
-               }
-          }
-     };
-     try {
-          var url = _basepath + "/delete" + _filename;
-          xhttp.open("POST", url, false);
-          xhttp.send();
-     }
-     catch (error)
-     {
-//          alert("Deleting Config.ini failed");
-     }
-
-     return okay;
+function getConfigCategory() {
+     return category;
 }
 }
+     
 
 
-function FileSendContent(_content, _filename, _basepath = ""){
-     var xhttp = new XMLHttpRequest();  
-     var okay = false;
-
-     xhttp.onreadystatechange = function() {
-          if (xhttp.readyState == 4) {
-               if (xhttp.status == 200) {
-                    okay = true;
-               } else if (xhttp.status == 0) {
-                    alert("Server closed the connection abruptly!");
-               } else {
-                    alert(xhttp.status + " Error!\n" + xhttp.responseText);
-               }
-          }
-     };
 
 
-     try {
-          upload_path = _basepath + "/upload" + _filename;
-          xhttp.open("POST", upload_path, false);
-          xhttp.send(_content);
-     }
-     catch (error)
-     {
-//          alert("Deleting Config.ini failed");
-     }     
-    return okay;        
-}

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

@@ -1 +1 @@
-4.0.2
+5.1.0