Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
SybexX committed Dec 16, 2024
1 parent f4dccc1 commit 0300fd1
Show file tree
Hide file tree
Showing 14 changed files with 227 additions and 77 deletions.
29 changes: 26 additions & 3 deletions code/components/jomjol_flowcontroll/ClassFlowAlignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ ClassFlowAlignment::ClassFlowAlignment(std::vector<ClassFlow *> *lfc)
bool ClassFlowAlignment::ReadParameter(FILE *pfile, string &aktparamgraph)
{
std::vector<string> splitted;
int suchex = 40;
int suchey = 40;
int suchex = 20;
int suchey = 20;
int maxangle = 45;
int alg_algo = 0; // default=0; 1 =HIGHACCURACY; 2= FAST; 3= OFF //add disable aligment algo |01.2023

aktparamgraph = trim(aktparamgraph);
Expand Down Expand Up @@ -97,6 +98,11 @@ bool ClassFlowAlignment::ReadParameter(FILE *pfile, string &aktparamgraph)
suchey = std::stod(splitted[1]);
}
}
else if ((toUpper(splitted[0]) == "SEARCHMAXANGLE") && (splitted.size() > 1)) {
if (isStringNumeric(splitted[1])) {
maxangle = std::stod(splitted[1]);
}
}
else if ((toUpper(splitted[0]) == "ANTIALIASING") && (splitted.size() > 1)) {
use_antialiasing = alphanumericToBoolean(splitted[1]);
}
Expand Down Expand Up @@ -141,6 +147,7 @@ bool ClassFlowAlignment::ReadParameter(FILE *pfile, string &aktparamgraph)
for (int i = 0; i < anz_ref; ++i) {
References[i].search_x = suchex;
References[i].search_y = suchey;
References[i].search_max_angle = maxangle;
References[i].fastalg_SAD_criteria = SAD_criteria;
References[i].alignment_algo = alg_algo;
#ifdef DEBUG_DETAIL_ON
Expand Down Expand Up @@ -169,6 +176,14 @@ string ClassFlowAlignment::getHTMLSingleStep(string host)

bool ClassFlowAlignment::doFlow(string time)
{
// no align algo if set to 3 = off
if (References[0].alignment_algo == 3) {
flowctrl.alignmentOk = true;
}
else {
flowctrl.alignmentOk = false;
}

#ifdef ALGROI_LOAD_FROM_MEM_AS_JPG
// AlgROI needs to be allocated before ImageTMP to avoid heap fragmentation
if (!AlgROI) {
Expand Down Expand Up @@ -231,8 +246,16 @@ bool ClassFlowAlignment::doFlow(string time)

// no align algo if set to 3 = off //add disable aligment algo |01.2023
if (References[0].alignment_algo != 3) {
if (!AlignAndCutImage->Align(&References[0], &References[1])) {
int AlignRetval = AlignAndCutImage->Align(&References[0], &References[1]);
if (AlignRetval >= 0) {
SaveReferenceAlignmentValues();
flowctrl.alignmentOk = true;
}
else if (AlignRetval == -1) {
// Alignment failed
flowctrl.alignmentOk = false;
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, "Can't allocate Align -> Exec this round aborted!");
LogFile.WriteHeapInfo("ClassFlowAlignment-doFlow");
}
} // no align

Expand Down
4 changes: 2 additions & 2 deletions code/components/jomjol_flowcontroll/ClassFlowCNNGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
if ((CNNType == DoubleHyprid10) || (CNNType == Digit100)) {
float number = GENERAL[_analog]->ROI[GENERAL[_analog]->ROI.size() - 1]->result_float;
// NaN?
if (number >= 0) {
if ((number >= 0) && (number < 10)) {
// is only set if it is the first digit (no analogue before!)
if (_extendedResolution) {
int result_after_decimal_point = ((int) floor(number * 10)) % 10;
Expand Down Expand Up @@ -107,7 +107,7 @@ string ClassFlowCNNGeneral::getReadout(int _analog = 0, bool _extendedResolution
}

for (int i = GENERAL[_analog]->ROI.size() - 2; i >= 0; --i) {
if (GENERAL[_analog]->ROI[i]->result_float >= 0) {
if ((GENERAL[_analog]->ROI[i]->result_float >= 0) && (GENERAL[_analog]->ROI[i]->result_float < 10)) {
prev = PointerEvalHybridNew(GENERAL[_analog]->ROI[i]->result_float, GENERAL[_analog]->ROI[i+1]->result_float, prev);
LogFile.WriteToFile(ESP_LOG_DEBUG, TAG, "getReadout#PointerEvalHybridNew()= " + std::to_string(prev));
result = std::to_string(prev) + result;
Expand Down
12 changes: 5 additions & 7 deletions code/components/jomjol_flowcontroll/ClassFlowControll.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#endif //ENABLE_WEBHOOK
#include "ClassFlowCNNGeneral.h"

class ClassFlowControll :
public ClassFlow
class ClassFlowControll : public ClassFlow
{
protected:
std::vector<ClassFlow*> FlowControll;
Expand All @@ -35,14 +34,16 @@ class ClassFlowControll :
ClassFlowTakeImage* flowtakeimage;
ClassFlow* CreateClassFlow(std::string _type);

bool AutoStart;
float AutoInterval;
void SetInitialParameter(void);
std::string aktstatusWithTime;
std::string aktstatus;
int aktRunNr;

public:
bool AutoStart;
float AutoInterval;

bool alignmentOk;
bool SetupModeActive;

void InitFlow(std::string config);
Expand Down Expand Up @@ -93,6 +94,3 @@ class ClassFlowControll :
};

#endif



3 changes: 1 addition & 2 deletions code/components/jomjol_flowcontroll/ClassFlowDefineTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ enum t_RateType {
RateChange // time difference is considered and a normalized rate is used for comparison with NumberPost.maxRate
};


/**
* 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).
Expand All @@ -46,6 +45,7 @@ struct NumberPost {
bool PreValueOkay; // previousValueValid; indicates that the reading of the previous round has no errors
bool AllowNegativeRates; // allowNegativeRate; defines if the consistency checks allow negative rates between consecutive meter readings.
bool checkDigitIncreaseConsistency; // extendedConsistencyCheck; performs an additional consistency check to avoid wrong readings
// bool AlignmentFailsValue; // Use the value even if alignment fails
time_t timeStampLastValue; // Timestamp for the last read value; is used for the log
time_t timeStampLastPreValue; // Timestamp for the last PreValue set; is used for useMaxRateValue
time_t timeStampTimeUTC; // FIXME: not used; can be removed.
Expand Down Expand Up @@ -83,4 +83,3 @@ struct NumberPost {
};

#endif

62 changes: 56 additions & 6 deletions code/components/jomjol_flowcontroll/ClassFlowPostProcessing.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "ClassFlowPostProcessing.h"
#include "Helper.h"
#include "ClassFlowTakeImage.h"
#include "ClassLogFile.h"

#include <iomanip>
#include <sstream>

#include <time.h>

#include "ClassFlowPostProcessing.h"
#include "ClassFlowTakeImage.h"
#include "ClassLogFile.h"
#include "MainFlowControl.h"

#include "Helper.h"
#include "time_sntp.h"

#include "esp_log.h"
Expand Down Expand Up @@ -484,6 +485,35 @@ void ClassFlowPostProcessing::handleMaxRateValue(string _decsep, string _value)
}
}

/*
void ClassFlowPostProcessing::handleAlignmentFailsValue(string _decsep, string _value)
{
string _digit, _decpos;
int _pospunkt = _decsep.find_first_of(".");
// ESP_LOGD(TAG, "Name: %s, Pospunkt: %d", _decsep.c_str(), _pospunkt);
if (_pospunkt > -1)
{
_digit = _decsep.substr(0, _pospunkt);
}
else
{
_digit = "default";
}
for (int j = 0; j < NUMBERS.size(); ++j)
{
bool _zwdc = alphanumericToBoolean(_value);
// Set to default first (if nothing else is set)
if ((_digit == "default") || (NUMBERS[j]->name == _digit))
{
NUMBERS[j]->AlignmentFailsValue = _zwdc;
}
}
}
*/

void ClassFlowPostProcessing::handleChangeRateThreshold(string _decsep, string _value) {
string _digit, _decpos;
int _pospunkt = _decsep.find_first_of(".");
Expand Down Expand Up @@ -592,6 +622,13 @@ bool ClassFlowPostProcessing::ReadParameter(FILE* pfile, string& aktparamgraph)
}
}
}

/*
if ((toUpper(_param) == "ALIGNMENTFAILSVALUE") && (splitted.size() > 1))
{
handleAlignmentFailsValue(splitted[0], splitted[1]);
}
*/

if ((toUpper(_param) == "ALLOWNEGATIVERATES") && (splitted.size() > 1)) {
handleAllowNegativeRate(splitted[0], splitted[1]);
Expand Down Expand Up @@ -677,8 +714,9 @@ void ClassFlowPostProcessing::InitNUMBERS() {
_number->DecimalShift = 0;
_number->DecimalShiftInitial = 0;
_number->isExtendedResolution = false;
_number->AnalogToDigitTransitionStart=9.2;
_number->AnalogToDigitTransitionStart = 9.2;
_number->ChangeRateThreshold = 2;
// _number->AlignmentFailsValue = true;

_number->Value = 0; // last value read out, incl. corrections
_number->ReturnValue = ""; // corrected return value, possibly with error message
Expand Down Expand Up @@ -777,6 +815,18 @@ bool ClassFlowPostProcessing::doFlow(string zwtime) {
// calculate time difference
// double LastValueTimeDifference = difftime(imagetime, NUMBERS[j]->timeStampLastValue); // in seconds
double LastPreValueTimeDifference = difftime(imagetime, NUMBERS[j]->timeStampLastPreValue); // in seconds

// if ((!flowctrl.alignmentOk) && (!NUMBERS[j]->AlignmentFailsValue)) {
if (!flowctrl.alignmentOk) {
NUMBERS[j]->ErrorMessageText = "Alignment failed";

NUMBERS[j]->timeStampLastValue = imagetime;

std::string _zw = NUMBERS[j]->name + ": Raw: " + NUMBERS[j]->ReturnRawValue + ", Value: " + NUMBERS[j]->ReturnValue + ", Status: " + NUMBERS[j]->ErrorMessageText;
LogFile.WriteToFile(ESP_LOG_ERROR, TAG, _zw);
WriteDataLog(j);
continue;
}

UpdateNachkommaDecimalShift();

Expand Down
8 changes: 2 additions & 6 deletions code/components/jomjol_flowcontroll/ClassFlowPostProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

#include <string>


class ClassFlowPostProcessing :
public ClassFlow
class ClassFlowPostProcessing : public ClassFlow
{
protected:
bool UpdatePreValueINI;
Expand Down Expand Up @@ -41,9 +39,8 @@ class ClassFlowPostProcessing :
void handleMaxRateType(string _decsep, string _value);
void handleAnalogToDigitTransitionStart(string _decsep, string _value);
void handleAllowNegativeRate(string _decsep, string _value);
// void handleAlignmentFailsValue(string _decsep, string _value);
void handleChangeRateThreshold(string _decsep, string _value);

std::string GetStringReadouts(general);

void WriteDataLog(int _index);

Expand Down Expand Up @@ -75,5 +72,4 @@ class ClassFlowPostProcessing :
string name(){return "ClassFlowPostProcessing";};
};


#endif //CLASSFFLOWPOSTPROCESSING_H
Loading

0 comments on commit 0300fd1

Please sign in to comment.