diff --git a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp index 8b1b011e..1793d96d 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp @@ -439,6 +439,7 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph) neuroi->posy = std::stoi(zerlegt[2]); neuroi->deltax = std::stoi(zerlegt[3]); neuroi->deltay = std::stoi(zerlegt[4]); + neuroi->CCW = toUpper(zerlegt[5]) == "TRUE"; neuroi->result_float = -1; neuroi->image = NULL; neuroi->image_org = NULL; @@ -511,7 +512,7 @@ general* ClassFlowCNNGeneral::GetGENERAL(string _name, bool _create = true) _ret->ROI.push_back(neuroi); - printf("GetGENERAL - GENERAL %s - roi %s\n", _analog.c_str(), _roi.c_str()); + printf("GetGENERAL - GENERAL %s - roi %s - CCW: %d\n", _analog.c_str(), _roi.c_str(), neuroi->CCW); return _ret; } @@ -724,8 +725,13 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) f1 = tflite->GetOutputValue(0); f2 = tflite->GetOutputValue(1); float result = fmod(atan2(f1, f2) / (M_PI * 2) + 2, 1); - GENERAL[_ana]->ROI[i]->result_float = result * 10; - printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float); + + if(GENERAL[_ana]->ROI[i]->CCW) + GENERAL[_ana]->ROI[i]->result_float = 10 - (result * 10); + else + GENERAL[_ana]->ROI[i]->result_float = result * 10; + + printf("Result General(Analog)%i - CCW: %d - %f\n", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float); if (isLogImage) LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org); } break; @@ -916,15 +922,17 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) _num = tflite->GetOutClassification(); - GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0; + if(GENERAL[_ana]->ROI[i]->CCW) + GENERAL[_ana]->ROI[i]->result_float = 10 - ((float)_num / 10.0); + else + GENERAL[_ana]->ROI[i]->result_float = (float)_num / 10.0; - _result_save_file = GENERAL[_ana]->ROI[i]->result_float; GENERAL[_ana]->ROI[i]->isReject = false; - printf("Result General(Analog)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float); + printf("Result General(Analog)%i - CCW: %d - %f\n", i, GENERAL[_ana]->ROI[i]->CCW, GENERAL[_ana]->ROI[i]->result_float); if (isLogImage) { diff --git a/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h b/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h index 98432886..8c1cf64b 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h +++ b/code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h @@ -7,7 +7,7 @@ struct roi { int posx, posy, deltax, deltay; float result_float; int result_klasse; - bool isReject; + bool isReject, CCW; string name; CImageBasis *image, *image_org; }; diff --git a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp index f4e014e9..6f270cd6 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowMQTT.cpp @@ -170,6 +170,9 @@ bool ClassFlowMQTT::doFlow(string zwtime) sprintf(rssi, "%d", get_WIFI_RSSI()); MQTTPublish(zw, rssi, SetRetainFlag); + zw = maintopic + "/" + "CPUtemp"; + std::string cputemp = std::to_string(temperatureRead()); + MQTTPublish(zw, cputemp, SetRetainFlag); if (flowpostprocessing) { diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index 28619fcf..4e25dada 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -21,6 +21,7 @@ #include "server_GPIO.h" #include "server_file.h" +#include "connect_wlan.h" #define DEBUG_DETAIL_ON @@ -590,6 +591,55 @@ esp_err_t handler_statusflow(httpd_req_t *req) return ESP_OK; }; +esp_err_t handler_cputemp(httpd_req_t *req) +{ +#ifdef DEBUG_DETAIL_ON + LogFile.WriteHeapInfo("handler_cputemp - Start"); +#endif + + const char* resp_str; + char cputemp[20]; + + sprintf(cputemp, "CPU Temp: %4.1f°C", temperatureRead()); + + resp_str = cputemp; + + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + httpd_resp_send(req, resp_str, strlen(resp_str)); + /* Respond with an empty chunk to signal HTTP response completion */ + httpd_resp_send_chunk(req, NULL, 0); + +#ifdef DEBUG_DETAIL_ON + LogFile.WriteHeapInfo("handler_cputemp - End"); +#endif + + return ESP_OK; +}; + +esp_err_t handler_rssi(httpd_req_t *req) +{ +#ifdef DEBUG_DETAIL_ON + LogFile.WriteHeapInfo("handler_rssi - Start"); +#endif + + const char* resp_str; + char rssi[20]; + + sprintf(rssi, "RSSI: %idBm", get_WIFI_RSSI()); + + resp_str = rssi; + + httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); + httpd_resp_send(req, resp_str, strlen(resp_str)); + /* Respond with an empty chunk to signal HTTP response completion */ + httpd_resp_send_chunk(req, NULL, 0); + +#ifdef DEBUG_DETAIL_ON + LogFile.WriteHeapInfo("handler_rssi - End"); +#endif + + return ESP_OK; +}; esp_err_t handler_prevalue(httpd_req_t *req) { @@ -643,7 +693,7 @@ esp_err_t handler_prevalue(httpd_req_t *req) httpd_resp_send_chunk(req, NULL, 0); #ifdef DEBUG_DETAIL_ON - LogFile.WriteHeapInfo("handler_prevalue - Start"); + LogFile.WriteHeapInfo("handler_prevalue - End"); #endif return ESP_OK; @@ -766,6 +816,16 @@ void register_server_tflite_uri(httpd_handle_t server) camuri.user_ctx = (void*) "Light Off"; httpd_register_uri_handler(server, &camuri); + camuri.uri = "/cputemp.html"; + camuri.handler = handler_cputemp; + camuri.user_ctx = (void*) "Light Off"; + httpd_register_uri_handler(server, &camuri); + + camuri.uri = "/rssi.html"; + camuri.handler = handler_rssi; + camuri.user_ctx = (void*) "Light Off"; + httpd_register_uri_handler(server, &camuri); + camuri.uri = "/editflow.html"; camuri.handler = handler_editflow; camuri.user_ctx = (void*) "EditFlow"; diff --git a/sd-card/config/config.ini b/sd-card/config/config.ini index 5b657b46..ee7c75fc 100644 --- a/sd-card/config/config.ini +++ b/sd-card/config/config.ini @@ -25,9 +25,9 @@ Model = /config/dig-cont_0570_s3.tflite CNNGoodThreshold = 0.5 ;LogImageLocation = /log/digit ;LogfileRetentionInDays = 3 -main.dig1 294 126 30 54 -main.dig2 343 126 30 54 -main.dig3 391 126 30 54 +main.dig1 294 126 30 54 false +main.dig2 343 126 30 54 false +main.dig3 391 126 30 54 false [Analog] Model = /config/ana-cont_11.3.0_s2.tflite @@ -35,10 +35,10 @@ CNNGoodThreshold = 0.5 ;LogImageLocation = /log/analog ;LogfileRetentionInDays = 3 ExtendedResolution = true -main.ana1 432 230 92 92 -main.ana2 379 332 92 92 -main.ana3 283 374 92 92 -main.ana4 155 328 92 92 +main.ana1 432 230 92 92 false +main.ana2 379 332 92 92 false +main.ana3 283 374 92 92 false +main.ana4 155 328 92 92 false [PostProcessing] main.DecimalShift = 0 diff --git a/sd-card/html/edit_analog.html b/sd-card/html/edit_analog.html index 572cd094..1c7665c8 100644 --- a/sd-card/html/edit_analog.html +++ b/sd-card/html/edit_analog.html @@ -116,18 +116,19 @@ th, td { x: dx: - + y: dy: + - + @@ -216,9 +217,9 @@ function newROI(){ var _roinew = prompt("Please enter name of new ROI", "name"); if (ROIInfo.length > 0) - erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"]); + erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"], ROIInfo[aktindex]["CCW"]=="true"); else - erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, 30, 30); + erg = CreateROI(_number, "analog", sel.selectedIndex, _roinew, 1, 1, 30, 30, false); if (erg != "") alert(erg); @@ -246,6 +247,17 @@ function changelockAR(){ lockAR = document.getElementById("lockAR").checked; } +function changeCCW(){ + var sel = document.getElementById("Numbers_value1"); + var _number = sel.options[sel.selectedIndex].text; + + ROIInfo = getROIInfo("analog", _number); + aktindex = parseInt(document.getElementById("index").value); + + ROIInfo[aktindex]["CCW"] = document.getElementById("CCW").checked; + UpdateROIs(); +} + function ChangeSelection(){ aktindex = parseInt(document.getElementById("index").value); // lockAR = true; @@ -261,7 +273,7 @@ function SaveToConfig(){ } -function UpdateROIs(){ +function UpdateROIs(_sel){ document.getElementById("Category_Analog_enabled").checked = true; var sel = document.getElementById("Numbers_value1"); var _number = sel.options[sel.selectedIndex].text; @@ -332,6 +344,8 @@ function UpdateROIs(){ document.getElementById("refy").value = ROIInfo[aktindex]["y"]; document.getElementById("refdx").value = ROIInfo[aktindex]["dx"]; document.getElementById("refdy").value = ROIInfo[aktindex]["dy"]; + document.getElementById("CCW").checked = ROIInfo[aktindex]["CCW"] == "true"; + rect.startX = ROIInfo[aktindex]["x"]; rect.startY = ROIInfo[aktindex]["y"]; rect.w = ROIInfo[aktindex]["dx"]; diff --git a/sd-card/html/edit_digits.html b/sd-card/html/edit_digits.html index 6a62566a..c0685acb 100644 --- a/sd-card/html/edit_digits.html +++ b/sd-card/html/edit_digits.html @@ -209,9 +209,9 @@ function newROI() { var _roinew = prompt("Please enter name of new ROI", "name"); if (ROIInfo.length > 0) - erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"]); + erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, ROIInfo[aktindex]["dx"], ROIInfo[aktindex]["dy"], 0); else - erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, 30, 51); + erg = CreateROI(_number, "digit", sel.selectedIndex, _roinew, 1, 1, 30, 51, 0); if (erg != "") alert(erg); diff --git a/sd-card/html/readconfigparam.js b/sd-card/html/readconfigparam.js index 7977fce9..90604727 100644 --- a/sd-card/html/readconfigparam.js +++ b/sd-card/html/readconfigparam.js @@ -236,9 +236,9 @@ function ParseConfigParamAll(_aktline, _catname){ let [isCom, input] = isCommented(_input); var linesplit = ZerlegeZeile(input); ParamExtractValueAll(param, linesplit, _catname, _aktline, isCom); - if (!isCom && (linesplit.length == 5) && (_catname == 'Digits')) + if (!isCom && (linesplit.length == 6) && (_catname == 'Digits')) ExtractROIs(input, "digit"); - if (!isCom && (linesplit.length == 5) && (_catname == 'Analog')) + if (!isCom && (linesplit.length == 6) && (_catname == 'Analog')) ExtractROIs(input, "analog"); if (!isCom && (linesplit.length == 3) && (_catname == 'Alignment')) { @@ -398,6 +398,7 @@ function WriteConfigININew() text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["y"]; text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dx"]; text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["dy"]; + text = text + " " + NUMBERS[_roi]["digit"][_roiddet]["CCW"]; config_split.push(text); } } @@ -416,6 +417,7 @@ function WriteConfigININew() text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["y"]; text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dx"]; text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["dy"]; + text = text + " " + NUMBERS[_roi]["analog"][_roiddet]["CCW"]; config_split.push(text); } } @@ -484,6 +486,7 @@ function ExtractROIs(_aktline, _type){ abc["dx"] = linesplit[3]; abc["dy"] = linesplit[4]; abc["ar"] = parseFloat(linesplit[3]) / parseFloat(linesplit[4]); + abc["CCW"] = linesplit[5]; } @@ -712,7 +715,7 @@ function DeleteNUMBER(_delte){ return ""; } -function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy){ +function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy, _CCW){ _indexnumber = -1; for (j = 0; j < NUMBERS.length; ++j) if (NUMBERS[j]["name"] == _number) @@ -735,6 +738,7 @@ function CreateROI(_number, _type, _pos, _roinew, _x, _y, _dx, _dy){ _ret["dx"] = _dx; _ret["dy"] = _dy; _ret["ar"] = _dx / _dy; + _ret["CCW"] = _CCW; NUMBERS[_indexnumber][_type].splice(_pos+1, 0, _ret); diff --git a/sd-card/html/wasserzaehler_roi.html b/sd-card/html/wasserzaehler_roi.html index 381d5837..f7596606 100644 --- a/sd-card/html/wasserzaehler_roi.html +++ b/sd-card/html/wasserzaehler_roi.html @@ -20,7 +20,7 @@
- + @@ -57,6 +57,8 @@
Value:
+
+
@@ -83,6 +85,8 @@ function addZero(i) { $('#img').html(''); $('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s)); loadStatus(); + loadCPUTemp(); + loadRSSI(); refresh(); }); @@ -94,10 +98,10 @@ function refresh() { var h = addZero(d.getHours()); var m = addZero(d.getMinutes()); var s = addZero(d.getSeconds()); + // reassign the url to be like alg_roi.jpg?timestamp=456784512 based on timestamp $('#img').html(''); $('#timestamp').html("Last Page Refresh:" + (h + ":" + m + ":" + s)); - loadStatus(); init(); refresh(); }, 300000); @@ -120,6 +124,32 @@ function refresh() { xhttp.send(); } + function loadCPUTemp() { + url = basepath + '/cputemp.html'; + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var _rsp = xhttp.responseText; + $('#cputemp').html(_rsp); + } + } + xhttp.open("GET", url, true); + xhttp.send(); + } + + function loadRSSI() { + url = basepath + '/rssi.html'; + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState == 4 && this.status == 200) { + var _rsp = xhttp.responseText; + $('#rssi').html(_rsp); + } + } + xhttp.open("GET", url, true); + xhttp.send(); + } + function loadValue(_type, _div, _style) { url = basepath + '/wasserzaehler.html?all=true&type=' + _type; var xhttp = new XMLHttpRequest(); @@ -167,6 +197,8 @@ function refresh() { loadValue("prevalue", "prevalue"); loadValue("error", "error", "font-size:8px"); loadStatus(); + loadCPUTemp(); + loadRSSI(); } init();