Renamed digital to digit (#3219)

* renamed Digital to Digit

* added param migration

* Update .github/label-commenter-config.yaml

* renamed AnalogDigitTransition* to AnalogToDigitTransition*

---------

Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
CaCO3
2024-09-29 22:10:10 +02:00
committed by GitHub
parent 5496573369
commit f6bdd48bca
35 changed files with 228 additions and 236 deletions

View File

@@ -243,7 +243,7 @@ bool ClassFlowAlignment::doFlow(string time)
DrawRef(ImageTMP);
}
flowctrl.DigitalDrawROI(ImageTMP);
flowctrl.DigitDrawROI(ImageTMP);
flowctrl.AnalogDrawROI(ImageTMP);
ImageTMP->writeToMemoryAsJPG((ImageData *)AlgROI, 90);
}

View File

@@ -35,7 +35,7 @@ ClassFlowCNNGeneral::ClassFlowCNNGeneral(ClassFlowAlignment *_flowalign, t_CNNTy
imagesRetention = 5;
}
string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution, int prev, float _before_narrow_Analog, float analogDigitalTransitionStart) {
string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution, int prev, float _before_narrow_Analog, float AnalogToDigitTransitionStart) {
string result = "";
if (GENERAL[_analog]->ROI.size() == 0) {
@@ -63,7 +63,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
return result;
}
if (CNNType == Digital) {
if (CNNType == Digit) {
for (int i = 0; i < GENERAL[_analog]->ROI.size(); ++i) {
if (GENERAL[_analog]->ROI[i]->result_klasse >= 10) {
result = result + "N";
@@ -75,7 +75,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
return result;
}
if ((CNNType == DoubleHyprid10) || (CNNType == Digital100)) {
if ((CNNType == DoubleHyprid10) || (CNNType == Digit100)) {
float number = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float;
// NaN?
if (number >= 0) {
@@ -90,7 +90,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
}
else {
if (_before_narrow_Analog >= 0) {
prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, _before_narrow_Analog, prev, true, analogDigitalTransitionStart);
prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, _before_narrow_Analog, prev, true, AnalogToDigitTransitionStart);
}
else {
prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float, prev, prev);
@@ -101,7 +101,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
}
else {
result = "N";
if (_extendedResolution && (CNNType != Digital)) {
if (_extendedResolution && (CNNType != Digit)) {
result = "NN";
}
}
@@ -135,13 +135,13 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
* 0.1 => 0 (eval_predecessors)
* The 0 makes a 9.9 to 0 (eval_predecessors)
* The 0 makes a 9.8 to 0
* @param Analog_Predecessors false/true if the last ROI is an analog or digital ROI (default=false)
* @param Analog_Predecessors false/true if the last ROI is an analog or digit ROI (default=false)
* runs in special handling because analog is much less precise
* @param digitalAnalogTransitionStart start of the transitionlogic begins on number_of_predecessor (default=9.2)
* @param digitAnalogTransitionStart start of the transitionlogic begins on number_of_predecessor (default=9.2)
*
* @return int the determined number of the current ROI
*/
int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors, float digitalAnalogTransitionStart) {
int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors, float digitAnalogTransitionStart) {
int result;
int result_after_decimal_point = ((int) floor(number * 10)) % 10;
int result_before_decimal_point = ((int) floor(number) + 10) % 10;
@@ -153,21 +153,21 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
result = (int) ((int) trunc(round((number+10 % 10)*100)) ) / 100;
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - No predecessor - Result = " + std::to_string(result) +
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digit_Uncertainty = " + std::to_string(Digit_Uncertainty));
return result;
}
if (Analog_Predecessors) {
result = PointerEvalAnalogToDigitNew(number, number_of_predecessors, eval_predecessors, digitalAnalogTransitionStart);
result = PointerEvalAnalogToDigitNew(number, number_of_predecessors, eval_predecessors, digitAnalogTransitionStart);
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - Analog predecessor, evaluation over PointerEvalAnalogNew = " + std::to_string(result) +
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digit_Uncertainty = " + std::to_string(Digit_Uncertainty));
return result;
}
if ((number_of_predecessors >= Digital_Transition_Area_Predecessor ) && (number_of_predecessors <= (10.0 - Digital_Transition_Area_Predecessor))) {
// no digit change, because predecessor is far enough away (0+/-DigitalTransitionRangePredecessor) --> number is rounded
if ((number_of_predecessors >= Digit_Transition_Area_Predecessor ) && (number_of_predecessors <= (10.0 - Digit_Transition_Area_Predecessor))) {
// no digit change, because predecessor is far enough away (0+/-DigitTransitionRangePredecessor) --> number is rounded
// Band around the digit --> Round off, as digit reaches inaccuracy in the frame
if ((result_after_decimal_point <= DigitalBand) || (result_after_decimal_point >= (10-DigitalBand))) {
if ((result_after_decimal_point <= DigitBand) || (result_after_decimal_point >= (10-DigitBand))) {
result = ((int) round(number) + 10) % 10;
}
else {
@@ -175,7 +175,7 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
}
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - NO analogue predecessor, no change of digits, as pre-decimal point far enough away = " + std::to_string(result) +
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digit_Uncertainty = " + std::to_string(Digit_Uncertainty));
return result;
}
@@ -192,16 +192,16 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
result = result_before_decimal_point % 10;
}
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - NO analogue predecessor, zero crossing has taken placen = " + std::to_string(result) +
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty));
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digit_Uncertainty = " + std::to_string(Digit_Uncertainty));
return result;
}
// remains only >= 9.x --> no zero crossing yet --> 2.8 --> 2,
// and from 9.7(DigitalTransitionRangeLead) 3.1 --> 2
// and from 9.7(DigitTransitionRangeLead) 3.1 --> 2
// everything >=x.4 can be considered as current number in transition. With 9.x predecessor the current
// number can still be x.6 - x.7.
// Preceding (else - branch) does not already happen from 9.
if (Digital_Transition_Area_Forward>=number_of_predecessors || result_after_decimal_point >= 4) {
if (Digit_Transition_Area_Forward>=number_of_predecessors || result_after_decimal_point >= 4) {
// The current digit, like the previous digit, does not yet have a zero crossing.
result = result_before_decimal_point % 10;
}
@@ -212,39 +212,39 @@ int ClassFlowCNNGeneral::PointerEvalHybridNew(float number, float number_of_pred
}
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalHybridNew - O analogue predecessor, >= 9.5 --> no zero crossing yet = " + std::to_string(result) +
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digital_Uncertainty = " + std::to_string(Digital_Uncertainty) + " result_after_decimal_point = " + std::to_string(result_after_decimal_point));
" number: " + std::to_string(number) + " number_of_predecessors = " + std::to_string(number_of_predecessors)+ " eval_predecessors = " + std::to_string(eval_predecessors) + " Digit_Uncertainty = " + std::to_string(Digit_Uncertainty) + " result_after_decimal_point = " + std::to_string(result_after_decimal_point));
return result;
}
int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral_preceder, int eval_predecessors, float analogDigitalTransitionStart) {
int ClassFlowCNNGeneral::PointerEvalAnalogToDigitNew(float number, float numeral_preceder, int eval_predecessors, float AnalogToDigitTransitionStart) {
int result;
int result_after_decimal_point = ((int) floor(number * 10)) % 10;
int result_before_decimal_point = ((int) floor(number) + 10) % 10;
bool roundedUp = false;
// Within the digital inequalities
if ((result_after_decimal_point >= (10-Digital_Uncertainty * 10)) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame
// Within the digit inequalities
if ((result_after_decimal_point >= (10-Digit_Uncertainty * 10)) // Band around the digit --> Round off, as digit reaches inaccuracy in the frame
|| (eval_predecessors <= 4 && result_after_decimal_point>=6)) { // or digit runs after (analogue =0..4, digit >=6)
result = (int) (round(number) + 10) % 10;
roundedUp = true;
// before/ after decimal point, because we adjust the number based on the uncertainty.
result_after_decimal_point = ((int) floor(result * 10)) % 10;
result_before_decimal_point = ((int) floor(result) + 10) % 10;
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Digital Uncertainty - Result = " + std::to_string(result) +
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Digit Uncertainty - Result = " + std::to_string(result) +
" number: " + std::to_string(number) + " numeral_preceder: " + std::to_string(numeral_preceder) +
" erg before comma: " + std::to_string(result_before_decimal_point) +
" erg after comma: " + std::to_string(result_after_decimal_point));
}
else {
result = (int) ((int) trunc(number) + 10) % 10;
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - NO digital Uncertainty - Result = " + std::to_string(result) +
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - NO digit Uncertainty - Result = " + std::to_string(result) +
" number: " + std::to_string(number) + " numeral_preceder = " + std::to_string(numeral_preceder));
}
// No zero crossing has taken place.
// Only eval_predecessors used because numeral_preceder could be wrong here.
// numeral_preceder<=0.1 & eval_predecessors=9 corresponds to analogue was reset because of previous analogue that are not yet at 0.
if ((eval_predecessors>=6 && (numeral_preceder>analogDigitalTransitionStart || numeral_preceder<=0.2) && roundedUp)) {
if ((eval_predecessors>=6 && (numeral_preceder>AnalogToDigitTransitionStart || numeral_preceder<=0.2) && roundedUp)) {
result = ((result_before_decimal_point+10) - 1) % 10;
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "PointerEvalAnalogToDigitNew - Nulldurchgang noch nicht stattgefunden = " + std::to_string(result) +
" number: " + std::to_string(number) +
@@ -593,17 +593,17 @@ bool ClassFlowCNNGeneral::getNetworkParameter() {
ESP_LOGD(TAG, "TFlite-Type set to DoubleHyprid10");
break;
case 11:
CNNType = Digital;
ESP_LOGD(TAG, "TFlite-Type set to Digital");
CNNType = Digit;
ESP_LOGD(TAG, "TFlite-Type set to Digit");
break;
/* case 20:
CNNType = DigitalHyprid10;
ESP_LOGD(TAG, "TFlite-Type set to DigitalHyprid10");
CNNType = DigitHyprid10;
ESP_LOGD(TAG, "TFlite-Type set to DigitHyprid10");
break;
*/
// case 22:
// CNNType = DigitalHyprid;
// ESP_LOGD(TAG, "TFlite-Type set to DigitalHyprid");
// CNNType = DigitHyprid;
// ESP_LOGD(TAG, "TFlite-Type set to DigitHyprid");
// break;
case 100:
if (modelxsize==32 && modelysize == 32) {
@@ -611,8 +611,8 @@ bool ClassFlowCNNGeneral::getNetworkParameter() {
ESP_LOGD(TAG, "TFlite-Type set to Analogue100");
}
else {
CNNType = Digital100;
ESP_LOGD(TAG, "TFlite-Type set to Digital");
CNNType = Digit100;
ESP_LOGD(TAG, "TFlite-Type set to Digit");
}
break;
default:
@@ -686,8 +686,8 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) {
}
} break;
case Digital:
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital");
case Digit:
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digit");
{
GENERAL[n]->ROI[roi]->result_klasse = 0;
GENERAL[n]->ROI[roi]->result_klasse = tflite->GetClassFromImageBasis(GENERAL[n]->ROI[roi]->image);
@@ -778,10 +778,10 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) {
}
}
} break;
case Digital100:
case Digit100:
case Analogue100:
{
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digital100 or Analogue100");
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "CNN Type: Digit100 or Analogue100");
int _num;
float _result_save_file;
@@ -829,7 +829,7 @@ bool ClassFlowCNNGeneral::doNeuralNetwork(string time) {
}
bool ClassFlowCNNGeneral::isExtendedResolution(int _number) {
if (CNNType == Digital) {
if (CNNType == Digit) {
return false;
}
@@ -861,7 +861,7 @@ std::vector<HTMLInfo*> ClassFlowCNNGeneral::GetHTMLInfo() {
zw->filename_org = GENERAL[_ana]->name + "_" + GENERAL[_ana]->ROI[i]->name + ".jpg";
}
if (CNNType == Digital) {
if (CNNType == Digit) {
zw->val = GENERAL[_ana]->ROI[i]->result_klasse;
}
else {
@@ -927,7 +927,7 @@ string ClassFlowCNNGeneral::getReadoutRawString(int _analog)
rt = rt + "," + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1);
}
if (CNNType == Digital) {
if (CNNType == Digit) {
if (GENERAL[_analog]->ROI[i]->result_klasse >= 10) {
rt = rt + ",N";
}
@@ -936,7 +936,7 @@ string ClassFlowCNNGeneral::getReadoutRawString(int _analog)
}
}
if ((CNNType == DoubleHyprid10) || (CNNType == Digital100)) {
if ((CNNType == DoubleHyprid10) || (CNNType == Digit100)) {
rt = rt + "," + RundeOutput(GENERAL[_analog]->ROI[i]->result_float, 1);
}
}

View File

@@ -11,10 +11,10 @@ enum t_CNNType {
AutoDetect,
Analogue,
Analogue100,
Digital,
DigitalHyprid10,
Digit,
DigitHyprid10,
DoubleHyprid10,
Digital100,
Digit100,
None
};
@@ -26,15 +26,6 @@ protected:
std::vector<general*> GENERAL;
float CNNGoodThreshold;
//moved to define.h
//float Analog_error = 3.0;
//float AnalogToDigtalFehler = 0.8;
//float Digital_Uncertainty = 0.2;
//int DigitalBand = 3;
//float Digital_Transition_Range_Predecessor = 2;
//float Digital_Transition_Area_Predecessor = 0.7; // 9.3 - 0.7
//float Digital_Transition_Area_Forward = 9.7; // Pre-run zero crossing only happens from approx. 9.7 onwards
string cnnmodelfile;
int modelxsize, modelysize, modelchannel;
bool isLogImageSelect;
@@ -44,8 +35,8 @@ protected:
bool SaveAllFiles;
int PointerEvalAnalogNew(float zahl, int numeral_preceder);
int PointerEvalAnalogToDigitNew(float zahl, float numeral_preceder, int eval_predecessors, float analogDigitalTransitionStart);
int PointerEvalHybridNew(float zahl, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors = false, float analogDigitalTransitionStart=9.2);
int PointerEvalAnalogToDigitNew(float zahl, float numeral_preceder, int eval_predecessors, float AnalogToDigitTransitionStart);
int PointerEvalHybridNew(float zahl, float number_of_predecessors, int eval_predecessors, bool Analog_Predecessors = false, float AnalogToDigitTransitionStart=9.2);
@@ -61,7 +52,7 @@ public:
bool doFlow(string time);
string getHTMLSingleStep(string host);
string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _before_narrow_Analog = -1, float analogDigitalTransitionStart=9.2);
string getReadout(int _analog, bool _extendedResolution = false, int prev = -1, float _before_narrow_Analog = -1, float AnalogToDigitTransitionStart=9.2);
string getReadoutRawString(int _analog);

View File

@@ -96,7 +96,7 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input)
}
if (_input.compare("ClassFlowCNNGeneral") == 0) {
return ("Digitalization of ROIs");
return ("Digitization of ROIs");
}
#ifdef ENABLE_MQTT
@@ -126,10 +126,10 @@ std::string ClassFlowControll::TranslateAktstatus(std::string _input)
return "Unkown Status";
}
std::vector<HTMLInfo*> ClassFlowControll::GetAllDigital()
std::vector<HTMLInfo*> ClassFlowControll::GetAllDigit()
{
if (flowdigit) {
ESP_LOGD(TAG, "ClassFlowControll::GetAllDigital - flowdigit != NULL");
ESP_LOGD(TAG, "ClassFlowControll::GetAllDigit - flowdigit != NULL");
return flowdigit->GetHTMLInfo();
}
@@ -147,7 +147,7 @@ std::vector<HTMLInfo*> ClassFlowControll::GetAllAnalog()
return empty;
}
t_CNNType ClassFlowControll::GetTypeDigital()
t_CNNType ClassFlowControll::GetTypeDigit()
{
if (flowdigit) {
return flowdigit->getCNNType();
@@ -166,7 +166,7 @@ t_CNNType ClassFlowControll::GetTypeAnalog()
}
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
void ClassFlowControll::DigitalDrawROI(CImageBasis *_zw)
void ClassFlowControll::DigitDrawROI(CImageBasis *_zw)
{
if (flowdigit) {
flowdigit->DrawROI(_zw);
@@ -326,7 +326,7 @@ void ClassFlowControll::InitFlow(std::string config)
// printf("Name: %s\n", cfc->name().c_str());
if (cfc) {
ESP_LOGD(TAG, "Start ReadParameter (%s)", line.c_str());
ESP_LOGE(TAG, "Start ReadParameter (%s)", line.c_str());
cfc->ReadParameter(pFile, line);
}
else {
@@ -841,8 +841,8 @@ esp_err_t ClassFlowControll::GetJPGStream(std::string _fn, httpd_req_t *req)
else {
std::vector<HTMLInfo*> htmlinfo;
htmlinfo = GetAllDigital();
ESP_LOGD(TAG, "After getClassFlowControll::GetAllDigital");
htmlinfo = GetAllDigit();
ESP_LOGD(TAG, "After getClassFlowControll::GetAllDigit");
for (int i = 0; i < htmlinfo.size(); ++i)
{

View File

@@ -61,7 +61,7 @@ public:
string TranslateAktstatus(std::string _input);
#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
void DigitalDrawROI(CImageBasis *_zw);
void DigitDrawROI(CImageBasis *_zw);
void AnalogDrawROI(CImageBasis *_zw);
#endif
@@ -77,10 +77,10 @@ public:
std::string* getActStatus();
void setActStatus(std::string _aktstatus);
std::vector<HTMLInfo*> GetAllDigital();
std::vector<HTMLInfo*> GetAllDigit();
std::vector<HTMLInfo*> GetAllAnalog();
t_CNNType GetTypeDigital();
t_CNNType GetTypeDigit();
t_CNNType GetTypeAnalog();
#ifdef ENABLE_MQTT

View File

@@ -33,7 +33,7 @@ enum t_RateType {
/**
* Holds all properties and settings of a sequence. A sequence is a set of digital and/or analog ROIs that are combined to
* Holds all properties and settings of a sequence. A sequence is a set of digit and/or analog ROIs that are combined to
* provide one meter reading (value).
* FIXME: can be renamed to `Sequence`
*/
@@ -60,10 +60,10 @@ struct NumberPost {
string ReturnPreValue; // lastValidValueStr; corrected return value without error message
string ErrorMessageText; // errorMessage; Error message for consistency checks
int AnzahlAnalog; // numAnalogRoi; number of analog ROIs used in this sequence
int AnzahlDigital; // numDigitalRoi; number of digital ROIs used in this sequence
int AnzahlDigit; // numDigitRoi; number of digit ROIs used in this sequence
int DecimalShift; // decimalShift; each increment shifts the decimal separator by one digit; value=value*10^decimalShift; pos. value shifts to the right
int DecimalShiftInitial; // decimalShiftInitial; same as decimalShift but is a const to reset decimalShift after calculations
float AnalogDigitalTransitionStart; // analogDigitalTransitionStartValue; FIXME: need a better description; When is the digit > x.1, i.e. when does it start to tilt?
float AnalogToDigitTransitionStart; // AnalogToDigitTransitionStartValue; FIXME: need a better description; When is the digit > x.1, i.e. when does it start to tilt?
int Nachkomma; // decimalPlaces; usually defined by the number of analog ROIs; affected by DecimalShift
string FieldV1; // influxdbFieldName_v1; Name of the Field in InfluxDBv1
@@ -74,7 +74,7 @@ struct NumberPost {
bool isExtendedResolution; // extendResolution; Adds the decimal place of the least significant analog ROI to the value
general *digit_roi; // digitalRoi; set of digital ROIs for the sequence
general *digit_roi; // digitRoi; set of digit ROIs for the sequence
general *analog_roi; // analogRoi; set of analog ROIs for the sequence
string name; // name; Designation for the sequence

View File

@@ -286,7 +286,7 @@ bool ClassFlowMQTT::doFlow(string zwtime)
if (resultchangabs.length() > 0) {
success |= MQTTPublish(namenumber + "changeabsolut", resultchangabs, qos, SetRetainFlag); // Legacy API
success |= MQTTPublish(namenumber + "rate_per_digitalization_round", resultchangabs, qos, SetRetainFlag);
success |= MQTTPublish(namenumber + "rate_per_Digitization_round", resultchangabs, qos, SetRetainFlag);
}
if (resultraw.length() > 0)

View File

@@ -382,7 +382,7 @@ void ClassFlowPostProcessing::handleDecimalSeparator(string _decsep, string _val
}
}
void ClassFlowPostProcessing::handleAnalogDigitalTransitionStart(string _decsep, string _value) {
void ClassFlowPostProcessing::handleAnalogToDigitTransitionStart(string _decsep, string _value) {
string _digit, _decpos;
int _pospunkt = _decsep.find_first_of(".");
// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
@@ -403,7 +403,7 @@ void ClassFlowPostProcessing::handleAnalogDigitalTransitionStart(string _decsep,
// Set to default first (if nothing else is set)
if ((_digit == "default") || (NUMBERS[j]->name == _digit)) {
NUMBERS[j]->AnalogDigitalTransitionStart = _zwdc;
NUMBERS[j]->AnalogToDigitTransitionStart = _zwdc;
}
}
@@ -564,8 +564,8 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
handleDecimalSeparator(splitted[0], splitted[1]);
}
if ((toUpper(_param) == "ANALOGDIGITALTRANSITIONSTART") && (splitted.size() > 1)) {
handleAnalogDigitalTransitionStart(splitted[0], splitted[1]);
if ((toUpper(_param) == "AnalogToDigitTransitionStart") && (splitted.size() > 1)) {
handleAnalogToDigitTransitionStart(splitted[0], splitted[1]);
}
if ((toUpper(_param) == "MAXRATEVALUE") && (splitted.size() > 1)) {
@@ -648,10 +648,10 @@ void ClassFlowPostProcessing::InitNUMBERS() {
}
if (_number->digit_roi) {
_number->AnzahlDigital = _number->digit_roi->ROI.size();
_number->AnzahlDigit = _number->digit_roi->ROI.size();
}
else {
_number->AnzahlDigital = 0;
_number->AnzahlDigit = 0;
}
_number->analog_roi = NULL;
@@ -677,7 +677,7 @@ void ClassFlowPostProcessing::InitNUMBERS() {
_number->DecimalShift = 0;
_number->DecimalShiftInitial = 0;
_number->isExtendedResolution = false;
_number->AnalogDigitalTransitionStart=9.2;
_number->AnalogToDigitTransitionStart=9.2;
_number->ChangeRateThreshold = 2;
_number->Value = 0; // last value read out, incl. corrections
@@ -693,7 +693,7 @@ void ClassFlowPostProcessing::InitNUMBERS() {
}
for (int i = 0; i < NUMBERS.size(); ++i) {
ESP_LOGD(TAG, "Number %s, Anz DIG: %d, Anz ANA %d", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigital, NUMBERS[i]->AnzahlAnalog);
ESP_LOGD(TAG, "Number %s, Anz DIG: %d, Anz ANA %d", NUMBERS[i]->name.c_str(), NUMBERS[i]->AnzahlDigit, NUMBERS[i]->AnzahlAnalog);
}
}
@@ -804,7 +804,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
if (NUMBERS[j]->digit_roi) {
if (NUMBERS[j]->analog_roi) {
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float, NUMBERS[j]->AnalogDigitalTransitionStart) + NUMBERS[j]->ReturnRawValue;
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, false, previous_value, NUMBERS[j]->analog_roi->ROI[0]->result_float, NUMBERS[j]->AnalogToDigitTransitionStart) + NUMBERS[j]->ReturnRawValue;
}
else {
NUMBERS[j]->ReturnRawValue = flowDigit->getReadout(j, NUMBERS[j]->isExtendedResolution, previous_value); // Extended Resolution only if there are no analogue digits
@@ -812,7 +812,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
}
#ifdef SERIAL_DEBUG
ESP_LOGD(TAG, "After digital->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
ESP_LOGD(TAG, "After digit->getReadout: ReturnRaw %s", NUMBERS[j]->ReturnRawValue.c_str());
#endif
NUMBERS[j]->ReturnRawValue = ShiftDecimal(NUMBERS[j]->ReturnRawValue, NUMBERS[j]->DecimalShift);
@@ -868,8 +868,8 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
if (NUMBERS[j]->checkDigitIncreaseConsistency) {
if (flowDigit) {
if (flowDigit->getCNNType() != Digital) {
ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - ignored due to wrong CNN-Type (not Digital Classification)");
if (flowDigit->getCNNType() != Digit) {
ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - ignored due to wrong CNN-Type (not Digit Classification)");
}
else {
NUMBERS[j]->Value = checkDigitConsistency(NUMBERS[j]->Value, NUMBERS[j]->DecimalShift, NUMBERS[j]->analog_roi != NULL, NUMBERS[j]->PreValue);
@@ -877,7 +877,7 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
}
else {
#ifdef SERIAL_DEBUG
ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - no digital numbers defined!");
ESP_LOGD(TAG, "checkDigitIncreaseConsistency = true - no digit numbers defined!");
#endif
}
}
@@ -990,7 +990,7 @@ void ClassFlowPostProcessing::WriteDataLog(int _index) {
}
string analog = "";
string digital = "";
string digit = "";
string timezw = "";
char buffer[80];
struct tm* timeinfo = localtime(&NUMBERS[_index]->timeStampLastValue);
@@ -1002,20 +1002,20 @@ void ClassFlowPostProcessing::WriteDataLog(int _index) {
}
if (flowDigit) {
digital = flowDigit->getReadoutRawString(_index);
digit = flowDigit->getReadoutRawString(_index);
}
LogFile.WriteToData(timezw, NUMBERS[_index]->name, NUMBERS[_index]->ReturnRawValue, NUMBERS[_index]->ReturnValue, NUMBERS[_index]->ReturnPreValue,
NUMBERS[_index]->ReturnRateValue, NUMBERS[_index]->ReturnChangeAbsolute, NUMBERS[_index]->ErrorMessageText, digital, analog);
NUMBERS[_index]->ReturnRateValue, NUMBERS[_index]->ReturnChangeAbsolute, NUMBERS[_index]->ErrorMessageText, digit, analog);
ESP_LOGD(TAG, "WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_index]->ReturnRawValue.c_str(), NUMBERS[_index]->ReturnValue.c_str(), NUMBERS[_index]->ErrorMessageText.c_str(), digital.c_str(), analog.c_str());
ESP_LOGD(TAG, "WriteDataLog: %s, %s, %s, %s, %s", NUMBERS[_index]->ReturnRawValue.c_str(), NUMBERS[_index]->ReturnValue.c_str(), NUMBERS[_index]->ErrorMessageText.c_str(), digit.c_str(), analog.c_str());
}
void ClassFlowPostProcessing::UpdateNachkommaDecimalShift() {
for (int j = 0; j < NUMBERS.size(); ++j) {
// There are only digital digits
// There are only digits
if (NUMBERS[j]->digit_roi && !NUMBERS[j]->analog_roi) {
// ESP_LOGD(TAG, "Nurdigital");
// ESP_LOGD(TAG, "Nurdigit");
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
// Extended resolution is on and should also be used for this digit.
@@ -1037,9 +1037,9 @@ void ClassFlowPostProcessing::UpdateNachkommaDecimalShift() {
NUMBERS[j]->Nachkomma = -NUMBERS[j]->DecimalShift;
}
// digital + analog
// digit + analog
if (NUMBERS[j]->digit_roi && NUMBERS[j]->analog_roi) {
// ESP_LOGD(TAG, "Nur digital + analog");
// ESP_LOGD(TAG, "Nur digit + analog");
NUMBERS[j]->DecimalShift = NUMBERS[j]->DecimalShiftInitial;
NUMBERS[j]->Nachkomma = NUMBERS[j]->analog_roi->ROI.size() - NUMBERS[j]->DecimalShift;

View File

@@ -39,7 +39,7 @@ protected:
void handleMaxRateValue(string _decsep, string _value);
void handleDecimalExtendedResolution(string _decsep, string _value);
void handleMaxRateType(string _decsep, string _value);
void handleAnalogDigitalTransitionStart(string _decsep, string _value);
void handleAnalogToDigitTransitionStart(string _decsep, string _value);
void handleAllowNegativeRate(string _decsep, string _value);
void handleChangeRateThreshold(string _decsep, string _value);

View File

@@ -674,17 +674,17 @@ esp_err_t handler_wasserzaehler(httpd_req_t *req)
}
else
{
/* Digital ROIs */
/* Digit ROIs */
txt = "<body style=\"font-family: arial\">";
txt += "<hr><h3>Recognized Digit ROIs (previous round)</h3>\n";
txt += "<table style=\"border-spacing: 5px\"><tr style=\"text-align: center; vertical-align: top;\">\n";
std::vector<HTMLInfo *> htmlinfodig;
htmlinfodig = flowctrl.GetAllDigital();
htmlinfodig = flowctrl.GetAllDigit();
for (int i = 0; i < htmlinfodig.size(); ++i)
{
if (flowctrl.GetTypeDigital() == Digital)
if (flowctrl.GetTypeDigit() == Digit)
{
// Numbers greater than 10 and less than 0 indicate NaN, since a Roi can only have values from 0 to 9.
if ((htmlinfodig[i]->val >= 10) || (htmlinfodig[i]->val < 0))

View File

@@ -120,15 +120,15 @@ void psram_free_shared_temp_image_memory(void) {
/*******************************************************************
* Memory used in Digitalization Steps
* Memory used in Digitization Steps
* During this step we only use the shared part of the PSRAM for the
* Tensor Arena and one of the Models.
* The shared memory is large enough for the largest model and the
* Tensor Arena. Therefore we do not need to monitor the usage.
*******************************************************************/
void *psram_get_shared_tensor_arena_memory(void) {
if ((sharedMemoryInUseFor == "") || (sharedMemoryInUseFor == "Digitalization_Model")) {
sharedMemoryInUseFor = "Digitalization_Tensor";
if ((sharedMemoryInUseFor == "") || (sharedMemoryInUseFor == "Digitization_Model")) {
sharedMemoryInUseFor = "Digitization_Tensor";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Allocating Tensor Arena (" + std::to_string(TENSOR_ARENA_SIZE) + " bytes, use shared memory in PSRAM)...");
return shared_region; // Use 1th part of the shared memory for Tensor
}
@@ -140,8 +140,8 @@ void *psram_get_shared_tensor_arena_memory(void) {
void *psram_get_shared_model_memory(void) {
if ((sharedMemoryInUseFor == "") || (sharedMemoryInUseFor == "Digitalization_Tensor")) {
sharedMemoryInUseFor = "Digitalization_Model";
if ((sharedMemoryInUseFor == "") || (sharedMemoryInUseFor == "Digitization_Tensor")) {
sharedMemoryInUseFor = "Digitization_Model";
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "Allocating Model memory (" + std::to_string(MAX_MODEL_SIZE) + " bytes, use shared memory in PSRAM)...");
return (uint8_t *)shared_region + TENSOR_ARENA_SIZE; // Use 2nd part of the shared memory (after Tensor Arena) for the model
}

View File

@@ -20,7 +20,7 @@ void psram_free_shared_stbi_memory(void *p);
void *psram_reserve_shared_tmp_image_memory(void);
void psram_free_shared_temp_image_memory(void);
/* Memory used in Digitalization Steps */
/* Memory used in Digitization Steps */
void *psram_get_shared_tensor_arena_memory(void);
void *psram_get_shared_model_memory(void);
void psram_free_shared_tensor_arena_and_model_memory(void);

View File

@@ -32,7 +32,7 @@ void ClassLogFile::WriteHeapInfo(std::string _id)
}
void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog)
void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digit, std::string _analog)
{
ESP_LOGD(TAG, "Start WriteToData");
time_t rawtime;
@@ -67,7 +67,7 @@ void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::s
fputs(_ReturnChangeAbsolute.c_str(), pFile);
fputs(",", pFile);
fputs(_ErrorMessageText.c_str(), pFile);
fputs(_digital.c_str(), pFile);
fputs(_digit.c_str(), pFile);
fputs(_analog.c_str(), pFile);
fputs("\n", pFile);

View File

@@ -39,8 +39,8 @@ public:
void RemoveOldLogFile();
void RemoveOldDataLog();
// void WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digital, std::string _analog);
void WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digital, std::string _analog);
// void WriteToData(std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ErrorMessageText, std::string _digit, std::string _analog);
void WriteToData(std::string _timestamp, std::string _name, std::string _ReturnRawValue, std::string _ReturnValue, std::string _ReturnPreValue, std::string _ReturnRateValue, std::string _ReturnChangeAbsolute, std::string _ErrorMessageText, std::string _digit, std::string _analog);
std::string GetCurrentFileName();

View File

@@ -188,10 +188,10 @@ bool MQTThomeassistantDiscovery(int qos) {
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "value", "Value", "gauge", valueUnit, meterType, "total_increasing", "", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "raw", "Raw Value", "raw", "", "", "", "diagnostic", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "error", "Error", "alert-circle-outline", "", "", "", "diagnostic", qos);
/* Not announcing "rate" as it is better to use rate_per_time_unit resp. rate_per_digitalization_round */
/* Not announcing "rate" as it is better to use rate_per_time_unit resp. rate_per_Digitization_round */
// allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate", "Rate (Unit/Minute)", "swap-vertical", "", "", "", ""); // Legacy, always Unit per Minute
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate_per_time_unit", "Rate (" + rateUnit + ")", "swap-vertical", rateUnit, "", "measurement", "", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate_per_digitalization_round", "Change since last digitalization round", "arrow-expand-vertical", valueUnit, "", "measurement", "", qos); // correctly the Unit is Unit/Interval!
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "rate_per_Digitization_round", "Change since last Digitization round", "arrow-expand-vertical", valueUnit, "", "measurement", "", qos); // correctly the Unit is Unit/Interval!
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "timestamp", "Timestamp", "clock-time-eight-outline", "", "timestamp", "", "diagnostic", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "json", "JSON", "code-json", "", "", "", "diagnostic", qos);
allSendsSuccessed |= sendHomeAssistantDiscoveryTopic(group, "problem", "Problem", "alert-outline", "", "problem", "", "", qos); // Special binary sensor which is based on error topic