Into

Modules

Documentation

classPiiMovingAverageOperation

#include <PiiMovingAverageOperation.h>

Calculate the moving average over a window of a predefined size.

Inherits PiiDefaultOperation

Description

The output will be the average over the last N input values, which must be of the same type (and size, if matrices are averaged).

Inputs

inputthe input value. Any numeric or complex type or a matrix containing such types.

Outputs

averagethe average over the last N entries (see windowSize). The output type is floating point numbers. Double and long int in input result in double output, others result in float output.

Properties

bool

If this property is true, output type will be forced to input type.

double

The maximum acceptable value.

double

The minimum acceptable value.

int

The size of the averaging window.

Constructors and destructor

Public member functions

bool
double
double
void
(
  • bool forceInputType
)
void
(
  • double rangeMax
)
void
(
  • double rangeMin
)
void
(
  • int windowSize
)
int

Protected member functions

virtual void
(
  • bool reset
)

Checks the operation for execution.

virtual void

Executes one round of processing.

Property details

  • bool forceInputType

    [read, write]

    If this property is true, output type will be forced to input type.

  • double rangeMax

    [read, write]

    The maximum acceptable value.

    See rangeMin for a detailed description. The default value is 0. Use 360 or 2*M_PI for angles.

  • double rangeMin

    [read, write]

    The minimum acceptable value.

    If rangeMin and rangeMax are not equal, they define the range of acceptable values, and the values are handled circularly. This is especially useful for angles, because the mean of 359 and 1 should be 0, not 180. The default value is 0. The range applies only to scalars. Matrices are not checked for range under/overflow.

  • int windowSize

    [read, write]

    The size of the averaging window.

    Note that the operation buffers this many past values. If large matrices are averaged, a large portion of memory may be reserved. The default value is two (2).

Function details

  • PiiMovingAverageOperation

    ()
  • bool forceInputType

    ()
  • double rangeMax

    ()
  • double rangeMin

    ()
  • void setForceInputType

    (
    • bool forceInputType
    )
  • void setRangeMax

    (
    • double rangeMax
    )
  • void setRangeMin

    (
    • double rangeMin
    )
  • void setWindowSize

    (
    • int windowSize
    )
  • int windowSize

    ()
  • virtual void check

    (
    • bool reset
    )
    [protected, virtual]

    Checks the operation for execution.

    This function creates a suitable flow controller by calling createFlowController(). It then sets the flow controller to the active processor and sets the processor as the input controller for all inputs.

    If you change socket groupings in your overridden implementation, please call PiiDefaultOperation::check() after that. Otherwise, your new groupings will not be in effect.

    Reimplemented from PiiDefaultOperation.

  • virtual void process

    ()
    [protected, virtual]

    Executes one round of processing.

    This function is invoked by the processor if the necessary preconditions for a new processing round are met. This function does all the necessary calculations to create output objects and sends them to output sockets.

    Calls to process(), syncEvent(), and setProperty() are synchronized and cannot occur simultaneously. PiiDefaultOperation ensures this by locking processLock() for reading before calling process().

    Note: With time-consuming operations, one should occasionally check that the operation hasn't been interrupted, i.e. that state() returns Running.

    Exceptions
    PiiExecutionException

    whenever an unrecoverable error occurs during a processing round, the operation is interrupted, or finishes execution due to end of input data.

    Reimplemented from PiiDefaultOperation.

Notes (0)

Add a note

Not a single note added yet. Be the first, add yours.