stec-platform
algo::DbxDistributionFilter Class Reference

class DbxDistributionFilter DbxDistributionFilter is a simple class for online filtering of non-equidistant values into equidistant data. The employed filter algorithm tries to be as close as possible to the original data being fed to it. Depending on the situation it either uses averaging of or linear interpolation between the values. No history data arrays or loops are being used excepts when interpolating between 2 distant points. Smart filter needs to know about the direction of filtering in order to properly assign the axis. The axis coordinates can either be a position (or alike) for filtering of data in cross direction, or the time for filtering in machine direction, millisecond timestamps can be provided automatically, Depending on what insertValue() member function will be used to feed the values to the smart filter. As soon as there is enough data available to calculate the next filtered value(s), smart filter will do so and then automatically envoke the virtual filteredValue() function once for each value pair. When data collection has been finished, e.g. the scanner stops / reverses, or an edge of sheet got detected, the flushValue() member function should be called to flush eventually incomplete values, normally this happens automatically once an edge of e.g. a databox got reached or crossed. The step size of the output axis can be set to any value, default is 1, e.g. 1 databox, or 1 second,so this class can also be used to shrink or expand data arrays in a very flexible way, e.g. a step size of 2 would cause all values coming in for 2 databoxes to be averaged into a single databox. The other useful feature is the linear interpolation if some data points are missing, so smart filter will act as a hole filter here and fill up the gap with values interpolated between the edges values. More...

#include <algo.h>

Collaboration diagram for algo::DbxDistributionFilter:

Public Member Functions

 DbxDistributionFilter (QVariant stepSize=static_cast< double >(1.0))
 default constructor of a smart filter object with a default step size of 1.. More...
 
 DbxDistributionFilter (const DbxDistributionFilter &ref)
 copy constructor for recreating a new smart filter object from an existing object reference..
 
QVariant step (void)
 get the step size of the output axis..
 
bool setStep (QVariant stepSize)
 set the step size of the output axis.. More...
 
bool forward (void)
 return true if the actual filtering direction is forward..
 
void setDirection (DbxDistributionFilter::Direction dir=Forward)
 
virtual bool insertValue (const QVariant v, const QVariant vA)
 insert a value and a value axis, e.g. position, to be used for CD filtering.. More...
 
virtual bool insertAValue (const QVariant v)
 insert a value, the epoch time will be the axis, to be used for MD filtering.. More...
 
virtual void flushValue (void)
 if available, flush the value which hasn't been completed yet.. More...
 
virtual void interpolatedValue (const QVariant value, const QVariant vAxis)
 virtual function for a new filtered value pair, will be called as soon as a new value pair could be calculated..
 

Protected Types

enum  Direction { Forward , Reverse }
 we'll need to know which direction we're going in order for proper axis and boundary calculations.. More...
 

Protected Attributes

Direction direction
 we'll need to know about the direction of filtering in order to properly assign the axis..
 
bool WaitForFirst
 wait for the first data point after construction or after reversing filtering direction..
 
bool WaitForValue
 wait for the next value after we had reached exactly the edge of the previous one..
 
double VAxisStep
 step size of the output axis / coordinates, default is 1, e.g. 1 databox, or 1 second..
 
double StartVAxis
 starting boundary of the element currently being calculated..
 
double TotalValue
 total value so far of the element currently being calculated..
 
double LastVAxis
 last value axis from the previous insertion of a value (pair)..
 

Detailed Description

class DbxDistributionFilter DbxDistributionFilter is a simple class for online filtering of non-equidistant values into equidistant data. The employed filter algorithm tries to be as close as possible to the original data being fed to it. Depending on the situation it either uses averaging of or linear interpolation between the values. No history data arrays or loops are being used excepts when interpolating between 2 distant points. Smart filter needs to know about the direction of filtering in order to properly assign the axis. The axis coordinates can either be a position (or alike) for filtering of data in cross direction, or the time for filtering in machine direction, millisecond timestamps can be provided automatically, Depending on what insertValue() member function will be used to feed the values to the smart filter. As soon as there is enough data available to calculate the next filtered value(s), smart filter will do so and then automatically envoke the virtual filteredValue() function once for each value pair. When data collection has been finished, e.g. the scanner stops / reverses, or an edge of sheet got detected, the flushValue() member function should be called to flush eventually incomplete values, normally this happens automatically once an edge of e.g. a databox got reached or crossed. The step size of the output axis can be set to any value, default is 1, e.g. 1 databox, or 1 second,so this class can also be used to shrink or expand data arrays in a very flexible way, e.g. a step size of 2 would cause all values coming in for 2 databoxes to be averaged into a single databox. The other useful feature is the linear interpolation if some data points are missing, so smart filter will act as a hole filter here and fill up the gap with values interpolated between the edges values.

Member Enumeration Documentation

◆ Direction

we'll need to know which direction we're going in order for proper axis and boundary calculations..

Enumerator
Reverse 

0, filtering commences in forward direction, e.g. incrementing positions or time..

1, filtering commences in reverse direction, e.g. decrementing positions..

Constructor & Destructor Documentation

◆ DbxDistributionFilter()

algo::DbxDistributionFilter::DbxDistributionFilter ( QVariant  stepSize = static_cast<double>(1.0))

default constructor of a smart filter object with a default step size of 1..

test function to simulate some test patterns for proving the proper functionality of the smart filter..

set the step size of the output axis..

Member Function Documentation

◆ flushValue()

void algo::DbxDistributionFilter::flushValue ( void  )
virtual

if available, flush the value which hasn't been completed yet..

we are not waiting for the value anymore, so the has been one already..

we are filtering in forward direction, e.g. incrementing positions or time..

call the virtual function with the value so far..

we are filtering in forward direction, e.g. in decrementing positions or time..

call the virtual function with the value so far..

◆ insertAValue()

bool algo::DbxDistributionFilter::insertAValue ( const QVariant  v)
virtual

insert a value, the epoch time will be the axis, to be used for MD filtering..

get epoch time in seconds with milliseconds as decimals, so default step will be 1.000s..

insert a value and a value axis..

◆ insertValue()

bool algo::DbxDistributionFilter::insertValue ( const QVariant  v,
const QVariant  vA 
)
virtual

insert a value and a value axis, e.g. position, to be used for CD filtering..

we are filtering in forward direction, e.g. incrementing positions or time..

wait for the first data point after construction or after reversing filtering direction..

set the start of the element to the lower edge..

and remember the position / axis coordinate in the last value axis buffer..

wait for the next value after we had reached exactly the edge of the previous one..

are we still within the started element boundaries ?

if so, take actual value as start for the total value for further averaging or interpolation..

we received the first value of an element, so clear the request flag..

is it the first one, or are we moving in forward direction ?

are we still below the next upper boundary ?

if so, do some wheighted recursive averaging of the new value with the prrevious value history..

are we still below or at the 2nd-next upper boundary ?

do some wheighted recursive averaging of the new value with the prrevious value history up to the elements boundary..

call the virtual function with new result and appropriate axis..

adjust axis to upper next boundary as this will be the right location for the next value..

our current axis is right on the element boundary ?

if so, we'll have to wait for the next value coming in to start a new calculation..

our current element's axis is above the previous element's upper boundary..

else we'll take the current element's value as start of a new calculation..

our current axis is right on the next element's boundary ?

call the virtual function with new result and appropriate axis..

adjust axis to upper next boundary as this will be the right location for the next value..

if so, we'll have to wait for the next value coming in to start a new calculation..

so here we are to do some linear interpolation as we encountered a hole without sufficient values in between..

calculate last element's upper boundary..

calculate final element's upper boundary..

and save the result of calculation for the current element to a buffer..

loop while we are still below the current elements axis..

just do a linear interpolation between the lower and the upper edge coordinates..

call the virtual function with new result and appropriate axis..

adjust axis to upper next boundary as this will be the right location for the next value..

our current axis is right on the element boundary ?

if so, we'll have to wait for the next value coming in to start a new calculation..

else we'll take the current element's value as start of a new calculation..

we are not moving in forward direction..

so return false to indicate failure..

we are filtering in forward direction, e.g. in decrementing positions or time..

wait for the first data point after construction or after reversing filtering direction..

set the start of the element to the upper edge..

and remember the position / axis coordinate in the last value axis buffer..

wait for the next value after we had reached exactly the edge of the previous one..

are we still within the started element boundaries ?

if so, take actual value as start for the total value for further averaging or interpolation..

we received the first value of an element, so clear the request flag..

is it the first one, or are we moving in reverse direction ?

are we still above the next lower boundary ?

if so, do some wheighted recursive averaging of the new value with the prrevious value history..

are we still above or at the 2nd-next lower boundary ?

do some wheighted recursive averaging of the new value with the prrevious value history up to the elements boundary..

adjust axis to lower next boundary as this will be the right location for this value..

call the virtual function with new result and appropriate axis..

our current axis is right on the element boundary ?

if so, we'll have to wait for the next value coming in to start a new calculation..

our current element's axis is below the previous element's lower boundary..

else we'll take the current element's value as start of a new calculation..

our current axis is right on the next element's boundary ?

adjust axis to lower next boundary as this will be the right location for this value..

call the virtual function with new result and appropriate axis..

if so, we'll have to wait for the next value coming in to start a new calculation..

so here we are to do some linear interpolation as we encountered a hole without sufficient values in between..

calculate last element's upper boundary..

calculate final element's upper boundary..

and save the result of calculation for the current element to a buffer..

loop while we are still above the current elements axis..

just do a linear interpolation between the upper and the lower edge coordinates..

adjust axis to lower next boundary as this will be the right location for this value..

call the virtual function with new result and appropriate axis..

our current axis is right on the element boundary ?

if so, we'll have to wait for the next value coming in to start a new calculation..

else we'll take the current element's value as start of a new calculation..

we are not moving in reverse direction..

so return false to indicate failure..

we now have received the first element, so clear the appropriate flag..

save the current axis to the axis history for further calculations..

and finally return true to indicate success..

◆ setDirection()

void algo::DbxDistributionFilter::setDirection ( DbxDistributionFilter::Direction  dir = Forward)

not yet forward filtering direction ?

set forward filtering direction, e.g. incrementing positions or time..

waiting for the first value (pair) to show up..

not yet reverse filtering direction ?

set reverse filtering direction, e.g. decrementing positions..

waiting for the first value (pair) to show up..

◆ setStep()

bool algo::DbxDistributionFilter::setStep ( QVariant  stepSize)

set the step size of the output axis..

step size within reasonable range ?

accept the new step size..

and return true to indicate success..

force to the default step size of 1..

and return false to indicate failure..


The documentation for this class was generated from the following files: