jomjol 4 лет назад
Родитель
Сommit
379f4585e3

+ 6 - 1
README.md

@@ -54,7 +54,12 @@ In other cases you can contact the developer via email: <img src="https://raw.gi
 
 
 
-##### Rolling (2022-02-08)
+##### Rolling (2022-02-11)
+
+- Updated digital neural network file (`dig-s2-q-20220211.tflite`)
+- Corrected rounding in `CheckDigitIncreaseConsistency` algorithm
+
+Rolling (2022-02-08)
 
 - added Wifi RSSI to MQTT information
 

+ 29 - 34
code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp

@@ -21,22 +21,12 @@ ClassFlowCNNGeneral::ClassFlowCNNGeneral(ClassFlowAlignment *_flowalign, t_CNNTy
     previousElement = NULL;   
     SaveAllFiles = false; 
     disabled = false;
-//    extendedResolution = false;
     isLogImageSelect = false;
     CNNType = AutoDetect;
     CNNType = _cnntype;
     flowpostalignment = _flowalign;
 }
 
-/*
-int ClassFlowCNNGeneral::AnzahlROIs(int _analog = 0)
-{
-    int zw = GENERAL[_analog]->ROI.size();
-    if (extendedResolution && (CNNType != Digital)) zw++;   // da letzte Ziffer inkl Nachhkomma, es sei denn, das Nachkomma gibt es nicht (Digital)
-    return zw;
-} 
-*/
-
 string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution = false)
 {
     string result = "";    
@@ -78,7 +68,6 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
 
     if (CNNType == DigitalHyprid)
     {
-//        int ergebnis_nachkomma = -1;
         int zif_akt = -1;
 
         float zahl = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float;
@@ -127,7 +116,6 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
 int ClassFlowCNNGeneral::ZeigerEvalHybrid(float zahl, float zahl_vorgaenger, int eval_vorgaenger)
 {
     int ergebnis_nachkomma = ((int) floor(zahl * 10)) % 10;
-//    int ergebnis_vorkomma = ((int) floor(zahl)) % 10;
 
     if (zahl_vorgaenger < 0)                // keine Vorzahl vorhanden !!! --> Runde die Zahl
     {
@@ -206,13 +194,6 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
         )       // Paragraph passt nicht
         return false;
 
-
-/*
-    if ((aktparamgraph.compare("[Analog]") != 0) && (aktparamgraph.compare(";[Analog]") != 0) 
-        && (aktparamgraph.compare("[Digit]") != 0) && (aktparamgraph.compare(";[Digit]")))       // Paragraph passt nicht
-        return false;
-*/
-
     if (aktparamgraph[0] == ';')
     {
         disabled = true;
@@ -273,14 +254,6 @@ bool ClassFlowCNNGeneral::ReadParameter(FILE* pfile, string& aktparamgraph)
             if (toUpper(zerlegt[1]) == "TRUE")
                 SaveAllFiles = true;
         }
-
-/*
-        if ((toUpper(zerlegt[0]) == "EXTENDEDRESOLUTION") && (zerlegt.size() > 1))
-        {
-            if (toUpper(zerlegt[1]) == "TRUE")
-                extendedResolution = true;
-        }
-*/
     }
 
 
@@ -303,7 +276,6 @@ general* ClassFlowCNNGeneral::FindGENERAL(string _name_number)
 }
 
 
-
 general* ClassFlowCNNGeneral::GetGENERAL(string _name, bool _create = true)
 {
     string _analog, _roi;
@@ -338,6 +310,7 @@ general* ClassFlowCNNGeneral::GetGENERAL(string _name, bool _create = true)
 
     roi* neuroi = new roi;
     neuroi->name = _roi;
+
     _ret->ROI.push_back(neuroi);
 
     printf("GetGENERAL - GENERAL %s - roi %s\n", _analog.c_str(), _roi.c_str());
@@ -482,6 +455,10 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
                 CNNType = Digital;
                 printf("TFlite-Type set to Digital\n");
                 break;
+            case 20:
+                CNNType = DigitalHyprid10;
+                printf("TFlite-Type set to DigitalHyprid10\n");
+                break;
             case 22:
                 CNNType = DigitalHyprid;
                 printf("TFlite-Type set to DigitalHyprid\n");
@@ -489,7 +466,6 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
             default:
                 printf("ERROR ERROR ERROR - tflite passt nicht zur Firmware - ERROR ERROR ERROR\n");
         }
-//        flowpostprocessing->UpdateNachkommaDecimalShift();
     }
 
     for (int _ana = 0; _ana < GENERAL.size(); ++_ana)
@@ -559,6 +535,30 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
                         _zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
                         if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
 
+                        if (isLogImage)
+                            LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
+                    } break;
+                case DigitalHyprid10:
+                    {
+                        int _num, _nachkomma;
+
+                        tflite->LoadInputImageBasis(GENERAL[_ana]->ROI[i]->image);        
+                        tflite->Invoke();
+                        if (debugdetailgeneral) LogFile.WriteToFile("Nach Invoke");
+
+                        _num = tflite->GetOutClassification(0, 9);
+                        _nachkomma = tflite->GetOutClassification(10, 19);
+
+
+                        string _zwres = "Nach Invoke - Nummer: " + to_string(_num) + " Nachkomma: " + to_string(_nachkomma);
+                        if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
+
+                        GENERAL[_ana]->ROI[i]->result_float = fmod((double) _num + (((double)_nachkomma)-5)/10 + (double) 10, 10);
+
+                        printf("Result General(DigitalHyprid)%i: %f\n", i, GENERAL[_ana]->ROI[i]->result_float); 
+                        _zwres = "Result General(DigitalHyprid)" + to_string(i) + ": " + to_string(GENERAL[_ana]->ROI[i]->result_float);
+                        if (debugdetailgeneral) LogFile.WriteToFile(_zwres);
+
                         if (isLogImage)
                             LogImage(logPath, GENERAL[_ana]->ROI[i]->name, &GENERAL[_ana]->ROI[i]->result_float, NULL, time, GENERAL[_ana]->ROI[i]->image_org);
                     } break;
@@ -575,7 +575,6 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time)
 
 bool ClassFlowCNNGeneral::isExtendedResolution(int _number)
 {
-//    if (extendedResolution && !(CNNType == Digital))
     if (!(CNNType == Digital))
         return true;
 
@@ -616,13 +615,9 @@ std::vector<HTMLInfo*> ClassFlowCNNGeneral::GetHTMLInfo()
             zw->image = GENERAL[_ana]->ROI[i]->image;
             zw->image_org = GENERAL[_ana]->ROI[i]->image_org;
 
-//            printf("Push %s\n", zw->filename.c_str());
-
             result.push_back(zw);
         }
 
-//    printf("größe: %d\n", result.size());
-
     return result;
 }
 

+ 1 - 4
code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.h

@@ -3,7 +3,6 @@
 
 #include"ClassFlowDefineTypes.h"
 #include "ClassFlowAlignment.h"
-// #include "ClassFlowPostProcessing.h"
 
 
 enum t_CNNType {
@@ -11,6 +10,7 @@ enum t_CNNType {
     Analogue,
     Digital,
     DigitalHyprid,
+    DigitalHyprid10,
     None
  };
 
@@ -50,7 +50,6 @@ public:
 
    	std::vector<HTMLInfo*> GetHTMLInfo();   
 
-//    int AnzahlROIs(int _analog);
     int getAnzahlGENERAL();
     general* GetGENERAL(int _analog);
     general* GetGENERAL(string _name, bool _create);
@@ -59,8 +58,6 @@ public:
 
     bool isExtendedResolution(int _number = 0);
 
-//    void setPostprocessing(ClassFlowPostProcessing *_fpp){flowpostprocessing = _fpp;}; 
-
     void UpdateNameNumbers(std::vector<std::string> *_name_numbers);
 
     t_CNNType getCNNType(){return CNNType;};

+ 6 - 0
code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h

@@ -16,10 +16,16 @@ struct general {
     std::vector<roi*> ROI;
 };
 
+enum t_RateType {
+    AbsoluteChange,
+    RateChange
+ };
+
 
 struct NumberPost {
     float MaxRateValue;
     bool useMaxRateValue;
+    t_RateType RateType;
     bool ErrorMessage;
     bool PreValueOkay;
     bool AllowNegativeRates;

+ 50 - 6
code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp

@@ -304,6 +304,39 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
     }
 }
 
+
+
+void ClassFlowPostProcessing::handleMaxRateType(string _decsep, string _value)
+{
+    string _digit, _decpos;
+    int _pospunkt = _decsep.find_first_of(".");
+//    printf("Name: %s, Pospunkt: %d\n", _decsep.c_str(), _pospunkt);
+    if (_pospunkt > -1)
+        _digit = _decsep.substr(0, _pospunkt);
+    else
+        _digit = "default";
+
+    for (int j = 0; j < NUMBERS.size(); ++j)
+    {
+        t_RateType _rt = AbsoluteChange;
+
+        if (toUpper(_value) == "RATECHANGE")
+            _rt = RateChange;
+
+        if (_digit == "default")                        // erstmal auf default setzen (falls sonst nichts gesetzt)
+        {
+            NUMBERS[j]->RateType = _rt;
+        }
+
+        if (NUMBERS[j]->name == _digit)
+        {
+            NUMBERS[j]->RateType = _rt;
+        }
+    }
+}
+
+
+
 void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value)
 {
     string _digit, _decpos;
@@ -379,6 +412,10 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
         {
             handleMaxRateValue(zerlegt[0], zerlegt[1]);
         }
+        if ((toUpper(_param) == "MAXRATETYPE") && (zerlegt.size() > 1))
+        {
+            handleMaxRateType(zerlegt[0], zerlegt[1]);
+        }
 
         if ((toUpper(_param) == "PREVALUEUSE") && (zerlegt.size() > 1))
         {
@@ -476,6 +513,7 @@ void ClassFlowPostProcessing::InitNUMBERS()
         _number->PreValueOkay = false;
         _number->AllowNegativeRates = false;
         _number->MaxRateValue = 0.1;
+        _number->RateType = AbsoluteChange;
         _number->useMaxRateValue = false;
         _number->checkDigitIncreaseConsistency = false;
         _number->DecimalShift = 0;
@@ -648,11 +686,17 @@ bool ClassFlowPostProcessing::doFlow(string zwtime)
             }
 
             double difference = difftime(imagetime, NUMBERS[j]->lastvalue);      // in Sekunden
-            difference /= 60;                                                    // in Minuten
+            difference /= 60;  
             NUMBERS[j]->FlowRateAct = (NUMBERS[j]->Value - NUMBERS[j]->PreValue) / difference;
             NUMBERS[j]->ReturnRateValue = std::to_string(NUMBERS[j]->FlowRateAct);
+
+            float _ratedifference;                                                   
+            if (NUMBERS[j]->RateType == RateChange)
+                _ratedifference = (NUMBERS[j]->Value - NUMBERS[j]->PreValue) / difference;
+            else
+                _ratedifference = (NUMBERS[j]->Value - NUMBERS[j]->PreValue);
             
-            if (NUMBERS[j]->useMaxRateValue && (abs(NUMBERS[j]->FlowRateAct) > NUMBERS[j]->MaxRateValue))
+            if (NUMBERS[j]->useMaxRateValue && (abs(_ratedifference) > NUMBERS[j]->MaxRateValue))
             {
                 NUMBERS[j]->ErrorMessageText = NUMBERS[j]->ErrorMessageText + "Rate too high - Read: " + RundeOutput(NUMBERS[j]->Value, NUMBERS[j]->Nachkomma) + " - Pre: " + RundeOutput(NUMBERS[j]->PreValue, NUMBERS[j]->Nachkomma);
                 NUMBERS[j]->Value = NUMBERS[j]->PreValue;
@@ -820,14 +864,14 @@ float ClassFlowPostProcessing::checkDigitConsistency(float input, int _decilamsh
     while (pot <= pot_max)
     {
         zw = input / pow(10, pot-1);
-        aktdigit_before = ((int) zw + 10) % 10;
+        aktdigit_before = ((int) round(zw) + 10) % 10;
         zw = _preValue / pow(10, pot-1);
-        olddigit_before = ((int) zw + 10) % 10;
+        olddigit_before = ((int) round(zw) + 10) % 10;
 
         zw = input / pow(10, pot);
-        aktdigit = ((int) zw + 10) % 10;
+        aktdigit = ((int) round(zw) + 10) % 10;
         zw = _preValue / pow(10, pot);
-        olddigit = ((int) zw + 10) % 10;
+        olddigit = ((int) round(zw) + 10) % 10;
 
         no_nulldurchgang = (olddigit_before <= aktdigit_before);
 

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

@@ -8,6 +8,7 @@
 
 #include <string>
 
+
 class ClassFlowPostProcessing :
     public ClassFlow
 {
@@ -38,7 +39,9 @@ protected:
     void InitNUMBERS();
     void handleDecimalSeparator(string _decsep, string _value);
     void handleMaxRateValue(string _decsep, string _value);
-    void handleDecimalExtendedResolution(string _decsep, string _value);    
+    void handleDecimalExtendedResolution(string _decsep, string _value); 
+    void handleMaxRateType(string _decsep, string _value);
+
 
 
 

+ 2 - 2
code/main/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="ac3409f";
+const char* GIT_REV="45a7198";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2022-02-08 19:19";
+const char* BUILD_TIME="2022-02-11 20:05";

+ 2 - 2
code/version.cpp

@@ -1,4 +1,4 @@
-const char* GIT_REV="ac3409f";
+const char* GIT_REV="45a7198";
 const char* GIT_TAG="";
 const char* GIT_BRANCH="rolling";
-const char* BUILD_TIME="2022-02-08 19:19";
+const char* BUILD_TIME="2022-02-11 20:05";

BIN
firmware/ana-s1-q-20220129.tflite


BIN
firmware/ana-s3-q-20220105.tflite


BIN
firmware/bootloader.bin


BIN
firmware/dig-s1-q-20220206.tflite


BIN
firmware/dig-s2-q-20220211.tflite


BIN
firmware/firmware.bin


BIN
firmware/html.zip


+ 1 - 1
sd-card/config/config.ini

@@ -21,7 +21,7 @@ FlipImageSize = false
 /config/ref1.jpg 442 142
 
 [Digits]
-Model = /config/dig-s1-q-20220206.tflite
+Model = /config/dig-s2-q-20220211.tflite
 ;LogImageLocation = /log/digit
 ;LogfileRetentionInDays = 3
 ModelInputSize = 20 32

BIN
sd-card/config/dig-s1-q-20220206.tflite


BIN
sd-card/config/dig-s2-q-20220211.tflite


+ 20 - 1
sd-card/html/edit_config_param.html

@@ -503,7 +503,24 @@ textarea {
 				<input type="number" id="PostProcessing_MaxRateValue_value1" size="13" min="0" step="any">
 			</td>
 			<td style="font-size: 80%;">
-				Maximum change of reading per minute
+				Maximum change of a reading - if threated as absolute or relative change see next parameter.
+			</td>
+		</tr>
+		<tr>
+			<td width="20px"  style="padding-left: 40px;">
+				<input type="checkbox" id="PostProcessing_MaxRateType_enabled" value="1"  onclick = 'InvertEnableItem("PostProcessing", "MaxRateType")' unchecked >
+			</td>
+			<td  width="200px">
+				<class id="PostProcessing_MaxRateType_text" style="color:black;">MaxRateType</class>
+			</td>
+			<td>
+				<select id="PostProcessing_MaxRateType_value1">
+					<option value="AbsoluteChange" >AbsoluteChange</option>
+					<option value="RateChange" selected>RateChange</option>
+				</select>
+			</td>
+			<td style="font-size: 80%;">
+				Defines if the change rate compared to the previous value is calculated as absolute change (AbsoluteChange) or as rate normalized to the intervall (RateChange = change/minute).
 			</td>
 		</tr>
 		<tr>
@@ -1697,6 +1714,7 @@ function UpdateInputIndividual()
 	{
 		ReadParameter(param, "PostProcessing", "DecimalShift", true, NUNBERSAkt)		
 		ReadParameter(param, "PostProcessing", "MaxRateValue", true, NUNBERSAkt)		
+		ReadParameter(param, "PostProcessing", "MaxRateType", true, NUNBERSAkt)		
 		ReadParameter(param, "PostProcessing", "ExtendedResolution", true, NUNBERSAkt)		
 		ReadParameter(param, "PostProcessing", "IgnoreLeadingNaN", true, NUNBERSAkt)		
 	}
@@ -1705,6 +1723,7 @@ function UpdateInputIndividual()
 	NUNBERSAkt = sel.selectedIndex;
 	WriteParameter(param, category, "PostProcessing", "DecimalShift", true, NUNBERSAkt);
 	WriteParameter(param, category, "PostProcessing", "MaxRateValue", true, NUNBERSAkt);
+	WriteParameter(param, category, "PostProcessing", "MaxRateType", true, NUNBERSAkt);
 	WriteParameter(param, category, "PostProcessing", "ExtendedResolution", true, NUNBERSAkt);
 	WriteParameter(param, category, "PostProcessing", "IgnoreLeadingNaN", true, NUNBERSAkt);
 }

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

@@ -13,7 +13,7 @@ function getbasepath(){
     {
 //        host = "http://192.168.2.219";          // jomjol interner test
 //        host = "http://192.168.178.46";          // jomjol interner test
-        host = "http://192.168.178.60";          // jomjol interner Real
+        host = "http://192.168.178.62";          // jomjol interner Real
 //        host = "http://192.168.43.191";
 //        host = ".";                           // jomjol interner localhost   
 

+ 1 - 0
sd-card/html/readconfigparam.js

@@ -107,6 +107,7 @@ function ParseConfig() {
      ParamAddValue(param, catname, "PreValueAgeStartup");
      ParamAddValue(param, catname, "AllowNegativeRates");
      ParamAddValue(param, catname, "MaxRateValue", 1, true);
+     ParamAddValue(param, catname, "MaxRateType", 1, true);
      ParamAddValue(param, catname, "ExtendedResolution", 1, true);
      ParamAddValue(param, catname, "IgnoreLeadingNaN", 1, true);
      ParamAddValue(param, catname, "ErrorMessage");

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

@@ -1 +1 @@
-13.0.0
+13.1.0