C++ Based OPC UA Client/Server SDK  1.5.5.355
AggregateCalculator Class Reference

Calculates the value of an interpolative aggregate. More...

#include <aggregatecalculator.h>

Inherits AggregateCalculatorInterface.

Inherited by AggregateCalculatorAverage [private], AggregateCalculatorCount [private], AggregateCalculatorMinMax [private], AggregateCalculatorStartEnd [private], AggregateCalculatorStatus [private], and AggregateCalculatorStdDev [private].

Classes

struct  SubRegion
 A subset of a slice bounded by two raw data points. More...
 
struct  TimeSlice
 Stores information about a slice of data to be processed. More...
 

Public Member Functions

 AggregateCalculator (UaNodeId aggregateId, UaDateTime startTime, UaDateTime endTime, double processingInterval, bool stepped, OpcUa_AggregateConfiguration &configuration)
 Creates an aggregator with the passed AggregateId and configuration settings. More...
 
UaNodeId GetAggregateId ()
 The aggregate function applied by the calculator. More...
 
bool QueueRawValue (UaDataValue value)
 Queues a raw value for processing. More...
 
UaDataValue GetProcessedValue (bool returnPartial)
 Returns the next processed value. More...
 
bool HasEndTimePassed (UaDateTime currentTime)
 Indicates whether the specified time is later than the end time of the current interval. More...
 
bool UsesInterpolatedBounds ()
 Indicates whether this aggregate uses Interpolated Bounding Values. More...
 

Static Public Member Functions

static
AggregateCalculatorInterface
CreateCalculator (UaNodeId aggregateId, UaDateTime startTime, UaDateTime endTime, double processingInterval, bool stepped, OpcUa_AggregateConfiguration &configuration)
 Used by the Aggregators factory to create a new instance of the aggregate calculator. More...
 

Protected Types

enum  AggregateBits {
  Raw = 0x00, Calculated = 0x01, Interpolated = 0x02, DataSourceMask = 0x03,
  Partial = 0x04, ExtraData = 0x08, MultipleValues = 0x10
}
 AggregateBits enumeration. More...
 

Protected Member Functions

 AggregateCalculator (UaNodeId aggregateId)
 Creates an aggregator with the passed AggregateId and default configuration settings. More...
 
void Initialize (UaNodeId aggregateId, UaDateTime startTime, UaDateTime endTime, double processingInterval, bool stepped, OpcUa_AggregateConfiguration &configuration)
 Initializes the calculation stream. More...
 
UaDateTime GetStartTime ()
 The start time for the request. More...
 
UaDateTime GetEndTime ()
 The end time for the request. More...
 
double GetProcessingInterval ()
 The processing interval for the request. More...
 
bool GetStepped ()
 True if the data series requires stepped interpolation. More...
 
void GetConfiguration (OpcUa_AggregateConfiguration &returnValue)
 The configuration to use when processing. More...
 
bool GetUseServerTimestamp ()
 Whether to use the server timestamp for all processing. More...
 
bool GetTimeFlowsBackward ()
 True if data is being processed in reverse order. More...
 
bool GetComplete ()
 True if all values required for the request have been received and processed.
 
bool GetUsingExtrapolation ()
 True if data is extrapolated after the end of data. More...
 
bool GetSetPartialBit ()
 True if the GetProcessedValue method should set the Partial bit when appropriate. More...
 
int CompareTimestamps (const UaDataValue value1, const UaDataValue value2)
 Compares timestamps stored as UaDataValues according to the current UseServerTimestamp setting. More...
 
int CompareTimestamps (UaDateTime value1, UaDataValue value2)
 Compares a timestamps stored as UaDateTime to a timestamp stored as DataValue according to the current UseServerTimestamp setting. More...
 
bool IsGood (UaDataValue value)
 Checks if the value is good according to the configuration rules. More...
 
OpcUa_StatusCode SetCodeBits (OpcUa_StatusCode statusCode, unsigned int bits)
 Returns a status code with the bits pertaining to the code set. More...
 
OpcUa_StatusCode GetCodeBits (OpcUa_StatusCode statusCode)
 Returns the code bits of the specified status code. More...
 
OpcUa_StatusCode SetAggregateBits (OpcUa_StatusCode statusCode, unsigned int bits)
 Returns a status code with the bits pertaining to aggregates set. More...
 
OpcUa_StatusCode GetAggregateBits (OpcUa_StatusCode statusCode)
 Returns the aggregate bits of the specified status code. More...
 
void CreateSlice (TimeSlice &newSlice, UaDateTime previousStart, UaDateTime previousEnd)
 Creates a new timeslice to process. More...
 
bool UpdateSlice (TimeSlice &slice)
 Updates the timeslice to process. More...
 
virtual UaDataValue ComputeValue (TimeSlice &slice)
 Calculates the value for the timeslice. More...
 
UaDataValue GetNoDataValue (TimeSlice slice)
 Returns a value indicating that there is no data in the timeslice. More...
 
UaDateTime GetTimestamp (TimeSlice slice)
 Returns the timestamp to use for the slice value. More...
 
UaDataValue GetNoDataValue (UaDateTime timestamp)
 Returns a value indicating that there is no data in the timeslice. More...
 
UaDataValue Interpolate (UaDateTime timestamp)
 Interpolates a value at the timestamp. More...
 
UaDataValue SteppedInterpolate (UaDateTime timestamp, UaDataValue earlyBound)
 Calculates the value at the timestamp using stepped interpolation. More...
 
UaDataValue SlopedInterpolate (UaDateTime timestamp, UaDataValue earlyBound, UaDataValue lateBound)
 Calculates the value at the timestamp using sloped interpolation. More...
 
double CastToDouble (UaDataValue value)
 Converts the value to a double for use in calculations (throws exceptions if conversion fails). More...
 
UaDataValue GetSimpleBound (UaDateTime timestamp, TimeSlice &slice)
 Returns the simple bound for the timestamp. More...
 
void GetValuesWithSimpleBounds (TimeSlice &slice, std::list< UaDataValue > &returnList)
 Returns the values in the list with simple bounds. More...
 
bool GetValues (TimeSlice &slice, std::list< UaDataValue > &returnList)
 Returns the values between the start time and the end time for the slice. More...
 
void GetValuesWithInterpolatedBounds (TimeSlice &slice, std::list< UaDataValue > &returnList)
 Returns the values in the list with interpolated bounds. More...
 
void GetRegionsInValueSet (std::list< UaDataValue > &values, bool ignoreBadData, bool useSteppedCalculations, std::list< SubRegion > &returnList)
 Returns the values in the list with simple bounds. More...
 
UaStatusCode GetValueBasedStatusCode (TimeSlice &slice, std::list< UaDataValue > &values, UaStatusCode statusCode)
 Calculates the value based status code for the slice.
 
UaStatusCode GetTimeBasedStatusCode (TimeSlice &slice, std::list< UaDataValue > &values, UaStatusCode defaultCode)
 Calculates the status code for the slice.
 
UaStatusCode GetTimeBasedStatusCode (std::list< SubRegion > &regions, UaStatusCode statusCode)
 Calculates the status code for the slice.
 

Detailed Description

Calculates the value of an interpolative aggregate.

Member Enumeration Documentation

AggregateBits enumeration.

Enumerator
Raw 

A raw data value

Calculated 

A calculated data value

Interpolated 

A data value which was interpolated

DataSourceMask 

A mask that selects the bit which identify the source of the value (raw, calculated, interpolated)

Partial 

A data value which was calculated with an incomplete interval

ExtraData 

A raw data value that hides other data at the same timestamp

MultipleValues 

Multiple values match the aggregate criteria (i.e. multiple minimum values at different timestamps within the same interval)

Constructor & Destructor Documentation

AggregateCalculator::AggregateCalculator ( UaNodeId  aggregateId,
UaDateTime  startTime,
UaDateTime  endTime,
double  processingInterval,
bool  stepped,
OpcUa_AggregateConfiguration configuration 
)

Creates an aggregator with the passed AggregateId and configuration settings.

Parameters
[in]aggregateIdThe aggregate function to apply.
[in]startTimeThe start time.
[in]endTimeThe end time.
[in]processingIntervalThe processing interval.
[in]steppedWhether to use stepped interpolation.
[in]configurationThe aggregate configuration.
AggregateCalculator::AggregateCalculator ( UaNodeId  aggregateId)
protected

Creates an aggregator with the passed AggregateId and default configuration settings.

Parameters
[in]aggregateIdThe aggregate function to apply.

Member Function Documentation

double AggregateCalculator::CastToDouble ( UaDataValue  value)
protected

Converts the value to a double for use in calculations (throws exceptions if conversion fails).

int AggregateCalculator::CompareTimestamps ( const UaDataValue  value1,
const UaDataValue  value2 
)
protected

Compares timestamps stored as UaDataValues according to the current UseServerTimestamp setting.

Parameters
value1The first value to compare.
value2The second value to compare.
Returns
Less than 0 if value1 is earlier than value2; 0 if they are equal; greater than zero otherwise.
int AggregateCalculator::CompareTimestamps ( UaDateTime  value1,
UaDataValue  value2 
)
protected

Compares a timestamps stored as UaDateTime to a timestamp stored as DataValue according to the current UseServerTimestamp setting.

Parameters
value1The timestamp to compare.
value2The data value to compare.
Returns
Less than 0 if value1 is earlier than value2; 0 if they are equal; greater than zero otherwise.
UaDataValue AggregateCalculator::ComputeValue ( TimeSlice slice)
protectedvirtual

Calculates the value for the timeslice.

Parameters
sliceThe slice to process.
Returns
The processed value.

Reimplemented in AggregateCalculatorMinMax, AggregateCalculatorAverage, AggregateCalculatorCount, AggregateCalculatorStartEnd, AggregateCalculatorStatus, and AggregateCalculatorStdDev.

AggregateCalculatorInterface * AggregateCalculator::CreateCalculator ( UaNodeId  aggregateId,
UaDateTime  startTime,
UaDateTime  endTime,
double  processingInterval,
bool  stepped,
OpcUa_AggregateConfiguration configuration 
)
static

Used by the Aggregators factory to create a new instance of the aggregate calculator.

Parameters
[in]aggregateIdThe aggregate function to apply.
[in]startTimeThe start time.
[in]endTimeThe end time.
[in]processingIntervalThe processing interval.
[in]steppedWhether to use stepped interpolation.
[in]configurationThe aggregate configuration.
void AggregateCalculator::CreateSlice ( TimeSlice newSlice,
UaDateTime  previousStart,
UaDateTime  previousEnd 
)
protected

Creates a new timeslice to process.

Parameters
newSliceThe slice.
previousStartThe previous start time.
previousEndThe previous end time.
Returns
The new timeslice.
OpcUa_StatusCode AggregateCalculator::GetAggregateBits ( OpcUa_StatusCode  statusCode)
inlineprotected

Returns the aggregate bits of the specified status code.

Parameters
statusCodeThe original code.
Returns
The aggregate bits of the status code.
UaNodeId AggregateCalculator::GetAggregateId ( )
inlinevirtual

The aggregate function applied by the calculator.

Implements AggregateCalculatorInterface.

OpcUa_StatusCode AggregateCalculator::GetCodeBits ( OpcUa_StatusCode  statusCode)
inlineprotected

Returns the code bits of the specified status code.

Parameters
statusCodeThe original code.
Returns
The code bits of the status code.
void AggregateCalculator::GetConfiguration ( OpcUa_AggregateConfiguration returnValue)
inlineprotected

The configuration to use when processing.

UaDateTime AggregateCalculator::GetEndTime ( )
inlineprotected

The end time for the request.

UaDataValue AggregateCalculator::GetNoDataValue ( TimeSlice  slice)
protected

Returns a value indicating that there is no data in the timeslice.

UaDataValue AggregateCalculator::GetNoDataValue ( UaDateTime  timestamp)
protected

Returns a value indicating that there is no data in the timeslice.

UaDataValue AggregateCalculator::GetProcessedValue ( bool  returnPartial)
virtual

Returns the next processed value.

Parameters
returnPartialIf true, a partial interval should be processed.
Returns
The processed value. Null if nothing available and returnPartial is false.

Implements AggregateCalculatorInterface.

double AggregateCalculator::GetProcessingInterval ( )
inlineprotected

The processing interval for the request.

void AggregateCalculator::GetRegionsInValueSet ( std::list< UaDataValue > &  values,
bool  ignoreBadData,
bool  useSteppedCalculations,
std::list< SubRegion > &  returnList 
)
protected

Returns the values in the list with simple bounds.

bool AggregateCalculator::GetSetPartialBit ( )
inlineprotected

True if the GetProcessedValue method should set the Partial bit when appropriate.

UaDataValue AggregateCalculator::GetSimpleBound ( UaDateTime  timestamp,
TimeSlice slice 
)
protected

Returns the simple bound for the timestamp.

UaDateTime AggregateCalculator::GetStartTime ( )
inlineprotected

The start time for the request.

bool AggregateCalculator::GetStepped ( )
inlineprotected

True if the data series requires stepped interpolation.

bool AggregateCalculator::GetTimeFlowsBackward ( )
inlineprotected

True if data is being processed in reverse order.

UaDateTime AggregateCalculator::GetTimestamp ( TimeSlice  slice)
protected

Returns the timestamp to use for the slice value.

bool AggregateCalculator::GetUseServerTimestamp ( )
inlineprotected

Whether to use the server timestamp for all processing.

bool AggregateCalculator::GetUsingExtrapolation ( )
inlineprotected

True if data is extrapolated after the end of data.

bool AggregateCalculator::GetValues ( TimeSlice slice,
std::list< UaDataValue > &  returnList 
)
protected

Returns the values between the start time and the end time for the slice.

void AggregateCalculator::GetValuesWithInterpolatedBounds ( TimeSlice slice,
std::list< UaDataValue > &  returnList 
)
protected

Returns the values in the list with interpolated bounds.

void AggregateCalculator::GetValuesWithSimpleBounds ( TimeSlice slice,
std::list< UaDataValue > &  returnList 
)
protected

Returns the values in the list with simple bounds.

bool AggregateCalculator::HasEndTimePassed ( UaDateTime  currentTime)
virtual

Indicates whether the specified time is later than the end time of the current interval.

Returns
true if time flows forward and the time is later than the end time.

Implements AggregateCalculatorInterface.

void AggregateCalculator::Initialize ( UaNodeId  aggregateId,
UaDateTime  startTime,
UaDateTime  endTime,
double  processingInterval,
bool  stepped,
OpcUa_AggregateConfiguration configuration 
)
protected

Initializes the calculation stream.

Parameters
[in]aggregateIdThe aggregate function to apply.
[in]startTimeThe start time.
[in]endTimeThe end time.
[in]processingIntervalThe processing interval.
[in]steppedWhether to use stepped interpolation.
[in]configurationThe aggregate configuration.
UaDataValue AggregateCalculator::Interpolate ( UaDateTime  timestamp)
protected

Interpolates a value at the timestamp.

Parameters
timestampThe timestamp.
Returns
The interpolated value.
bool AggregateCalculator::IsGood ( UaDataValue  value)
protected

Checks if the value is good according to the configuration rules.

Parameters
valueThe value to test.
Returns
True if the value is good.
bool AggregateCalculator::QueueRawValue ( UaDataValue  value)
virtual

Queues a raw value for processing.

Returns
True if successful, false if the timestamp has been superseded by values already in the stream.
Parameters
[in]valueThe data value to process.

Implements AggregateCalculatorInterface.

OpcUa_StatusCode AggregateCalculator::SetAggregateBits ( OpcUa_StatusCode  statusCode,
unsigned int  bits 
)
inlineprotected

Returns a status code with the bits pertaining to aggregates set.

Parameters
statusCodeThe original code to modify.
bitsThe bits to change.
Returns
The modified status code.
OpcUa_StatusCode AggregateCalculator::SetCodeBits ( OpcUa_StatusCode  statusCode,
unsigned int  bits 
)
inlineprotected

Returns a status code with the bits pertaining to the code set.

Parameters
statusCodeThe original code to modify.
bitsThe bits to change.
Returns
The modified status code.
UaDataValue AggregateCalculator::SlopedInterpolate ( UaDateTime  timestamp,
UaDataValue  earlyBound,
UaDataValue  lateBound 
)
protected

Calculates the value at the timestamp using sloped interpolation.

UaDataValue AggregateCalculator::SteppedInterpolate ( UaDateTime  timestamp,
UaDataValue  earlyBound 
)
protected

Calculates the value at the timestamp using stepped interpolation.

bool AggregateCalculator::UpdateSlice ( TimeSlice slice)
protected

Updates the timeslice to process.

Parameters
sliceThe slice to update.
Returns
True if the slice is complete.
bool AggregateCalculator::UsesInterpolatedBounds ( )
virtual

Indicates whether this aggregate uses Interpolated Bounding Values.

Returns
True if this aggregate uses Interpolated Bounding Values and false if it uses Simple Bounding Values.

Implements AggregateCalculatorInterface.

Reimplemented in AggregateCalculatorMinMax, AggregateCalculatorAverage, AggregateCalculatorCount, AggregateCalculatorStartEnd, and AggregateCalculatorStatus.


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