C# Class Opc.Ua.Server.AggregateCalculator

Calculates the value of an aggregate.
Inheritance: IAggregateCalculator
ファイルを表示 Open project: OPCFoundation/UA-.NET Class Usage Examples

Public Methods

Method Description
AggregateCalculator ( NodeId aggregateId, System.DateTime startTime, System.DateTime endTime, double processingInterval, bool stepped, AggregateConfiguration configuration ) : System

Initializes the calculation stream.

GetProcessedValue ( bool returnPartial ) : DataValue

Returns the next processed value.

HasEndTimePassed ( System.DateTime currentTime ) : bool

Returns true if the specified time is later than the end of the current interval.

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

QueueRawValue ( DataValue value ) : bool

Queues a raw value for processing.

SlopedInterpolate ( System.DateTime timestamp, DataValue earlyBound, DataValue lateBound ) : DataValue

Calculate the value at the timestamp using slopped interpolation.

SteppedInterpolate ( System.DateTime timestamp, DataValue earlyBound ) : DataValue

Calculate the value at the timestamp using slopped interpolation.

Protected Methods

Method Description
AggregateCalculator ( NodeId aggregateId ) : System

Creates a default aggregator.

CastToDouble ( DataValue value ) : double

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

CastToOriginalType ( double value, DataValue original ) : Variant

Converts the value back to its original type (throws exceptions if conversion fails).

CompareTimestamps ( DataValue value1, DataValue value2 ) : int

Compares timestamps for two DataValues according to the current UseServerTimestamp setting.

CompareTimestamps ( DataValue value1, LinkedListNode value2 ) : int

Compares timestamps for two DataValues according to the current UseServerTimestamp setting.

CompareTimestamps ( System.DateTime value1, LinkedListNode value2 ) : int

Compares timestamps for a timestamp to a DataValue according to the current UseServerTimestamp setting.

CompareTimestamps ( LinkedListNode value1, LinkedListNode value2 ) : int

Compares timestamps for two DataValues according to the current UseServerTimestamp setting.

ComputeValue ( Opc.Ua.Server.TimeSlice slice ) : DataValue

Calculates the value for the timeslice.

CreateSlice ( Opc.Ua.Server.TimeSlice previousSlice ) : Opc.Ua.Server.TimeSlice

Creates a new time slice to process.

GetNoDataValue ( System.DateTime timestamp ) : DataValue

Return a value indicating there is no data in the time slice.

GetNoDataValue ( Opc.Ua.Server.TimeSlice slice ) : DataValue

Return a value indicating there is no data in the time slice.

GetRegionsInValueSet ( List values, bool ignoreBadData, bool useSteppedCalculations ) : List

Returns the values in the list with simple bounds.

GetSimpleBound ( System.DateTime timestamp, Opc.Ua.Server.TimeSlice slice ) : DataValue

Returns the simple bound for the timestamp.

GetTimeBasedStatusCode ( List regions, StatusCode statusCode ) : StatusCode

Calculates the status code for the slice

GetTimeBasedStatusCode ( Opc.Ua.Server.TimeSlice slice, List values, StatusCode defaultCode ) : StatusCode

Calculates the status code for the slice

GetTimestamp ( Opc.Ua.Server.TimeSlice slice ) : System.DateTime

Returns the timestamp to use for the slice value.

GetValueBasedStatusCode ( Opc.Ua.Server.TimeSlice slice, List values, StatusCode statusCode ) : StatusCode

Calculates the value based status code for the slice

GetValues ( Opc.Ua.Server.TimeSlice slice ) : List

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

GetValuesWithInterpolatedBounds ( Opc.Ua.Server.TimeSlice slice ) : List

Returns the values in the list with interpolated bounds.

GetValuesWithSimpleBounds ( Opc.Ua.Server.TimeSlice slice ) : List

Returns the values in the list with simple bounds.

Initialize ( NodeId aggregateId, System.DateTime startTime, System.DateTime endTime, double processingInterval, bool stepped, AggregateConfiguration configuration ) : void

Initializes the calculation stream.

Interpolate ( System.DateTime timestamp, Opc.Ua.Server.TimeSlice reference ) : DataValue

Interpolates a value at the timestamp.

Interpolate ( Opc.Ua.Server.TimeSlice slice ) : DataValue

Calculate the interpolate aggregate for the timeslice.

IsGood ( DataValue value ) : bool

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

UpdateSlice ( Opc.Ua.Server.TimeSlice slice ) : bool

Creates a new time slice to process.

Method Details

AggregateCalculator() protected method

Creates a default aggregator.
protected AggregateCalculator ( NodeId aggregateId ) : System
aggregateId NodeId
return System

AggregateCalculator() public method

Initializes the calculation stream.
public AggregateCalculator ( NodeId aggregateId, System.DateTime startTime, System.DateTime endTime, double processingInterval, bool stepped, AggregateConfiguration configuration ) : System
aggregateId NodeId The aggregate function to apply.
startTime System.DateTime The start time.
endTime System.DateTime The end time.
processingInterval double The processing interval.
stepped bool Whether to use stepped interpolation.
configuration AggregateConfiguration The aggregate configuration.
return System

CastToDouble() protected static method

Converts the value to a double for use in calculations (throws exceptions if conversion fails).
protected static CastToDouble ( DataValue value ) : double
value DataValue
return double

CastToOriginalType() protected static method

Converts the value back to its original type (throws exceptions if conversion fails).
protected static CastToOriginalType ( double value, DataValue original ) : Variant
value double
original DataValue
return System.Variant

CompareTimestamps() protected method

Compares timestamps for two DataValues according to the current UseServerTimestamp setting.
protected CompareTimestamps ( DataValue value1, DataValue value2 ) : int
value1 DataValue The first value to compare.
value2 DataValue The second value to compare.
return int

CompareTimestamps() protected method

Compares timestamps for two DataValues according to the current UseServerTimestamp setting.
protected CompareTimestamps ( DataValue value1, LinkedListNode value2 ) : int
value1 DataValue The first value to compare.
value2 LinkedListNode The second value to compare.
return int

CompareTimestamps() protected method

Compares timestamps for a timestamp to a DataValue according to the current UseServerTimestamp setting.
protected CompareTimestamps ( System.DateTime value1, LinkedListNode value2 ) : int
value1 System.DateTime The timestamp to compare.
value2 LinkedListNode The data value to compare.
return int

CompareTimestamps() protected method

Compares timestamps for two DataValues according to the current UseServerTimestamp setting.
protected CompareTimestamps ( LinkedListNode value1, LinkedListNode value2 ) : int
value1 LinkedListNode The first value to compare.
value2 LinkedListNode The second value to compare.
return int

ComputeValue() protected method

Calculates the value for the timeslice.
protected ComputeValue ( Opc.Ua.Server.TimeSlice slice ) : DataValue
slice Opc.Ua.Server.TimeSlice The slice to process.
return DataValue

CreateSlice() protected method

Creates a new time slice to process.
protected CreateSlice ( Opc.Ua.Server.TimeSlice previousSlice ) : Opc.Ua.Server.TimeSlice
previousSlice Opc.Ua.Server.TimeSlice The previous processed slice.
return Opc.Ua.Server.TimeSlice

GetNoDataValue() protected method

Return a value indicating there is no data in the time slice.
protected GetNoDataValue ( System.DateTime timestamp ) : DataValue
timestamp System.DateTime
return DataValue

GetNoDataValue() protected method

Return a value indicating there is no data in the time slice.
protected GetNoDataValue ( Opc.Ua.Server.TimeSlice slice ) : DataValue
slice Opc.Ua.Server.TimeSlice
return DataValue

GetProcessedValue() public method

Returns the next processed value.
public GetProcessedValue ( bool returnPartial ) : DataValue
returnPartial bool If true a partial interval should be processed.
return DataValue

GetRegionsInValueSet() protected method

Returns the values in the list with simple bounds.
protected GetRegionsInValueSet ( List values, bool ignoreBadData, bool useSteppedCalculations ) : List
values List
ignoreBadData bool
useSteppedCalculations bool
return List

GetSimpleBound() protected method

Returns the simple bound for the timestamp.
protected GetSimpleBound ( System.DateTime timestamp, Opc.Ua.Server.TimeSlice slice ) : DataValue
timestamp System.DateTime
slice Opc.Ua.Server.TimeSlice
return DataValue

GetTimeBasedStatusCode() protected method

Calculates the status code for the slice
protected GetTimeBasedStatusCode ( List regions, StatusCode statusCode ) : StatusCode
regions List
statusCode StatusCode
return StatusCode

GetTimeBasedStatusCode() protected method

Calculates the status code for the slice
protected GetTimeBasedStatusCode ( Opc.Ua.Server.TimeSlice slice, List values, StatusCode defaultCode ) : StatusCode
slice Opc.Ua.Server.TimeSlice
values List
defaultCode StatusCode
return StatusCode

GetTimestamp() protected method

Returns the timestamp to use for the slice value.
protected GetTimestamp ( Opc.Ua.Server.TimeSlice slice ) : System.DateTime
slice Opc.Ua.Server.TimeSlice
return System.DateTime

GetValueBasedStatusCode() protected method

Calculates the value based status code for the slice
protected GetValueBasedStatusCode ( Opc.Ua.Server.TimeSlice slice, List values, StatusCode statusCode ) : StatusCode
slice Opc.Ua.Server.TimeSlice
values List
statusCode StatusCode
return StatusCode

GetValues() protected method

Returns the values between the start time and the end time for the slice.
protected GetValues ( Opc.Ua.Server.TimeSlice slice ) : List
slice Opc.Ua.Server.TimeSlice
return List

GetValuesWithInterpolatedBounds() protected method

Returns the values in the list with interpolated bounds.
protected GetValuesWithInterpolatedBounds ( Opc.Ua.Server.TimeSlice slice ) : List
slice Opc.Ua.Server.TimeSlice
return List

GetValuesWithSimpleBounds() protected method

Returns the values in the list with simple bounds.
protected GetValuesWithSimpleBounds ( Opc.Ua.Server.TimeSlice slice ) : List
slice Opc.Ua.Server.TimeSlice
return List

HasEndTimePassed() public method

Returns true if the specified time is later than the end of the current interval.
Return true if time flows forward and the time is later than the end time.
public HasEndTimePassed ( System.DateTime currentTime ) : bool
currentTime System.DateTime
return bool

Initialize() protected method

Initializes the calculation stream.
protected Initialize ( NodeId aggregateId, System.DateTime startTime, System.DateTime endTime, double processingInterval, bool stepped, AggregateConfiguration configuration ) : void
aggregateId NodeId The aggregate function to apply.
startTime System.DateTime The start time.
endTime System.DateTime The end time.
processingInterval double The processing interval.
stepped bool Whether to use stepped interpolation.
configuration AggregateConfiguration The aggregate configuration.
return void

Interpolate() protected method

Interpolates a value at the timestamp.
protected Interpolate ( System.DateTime timestamp, Opc.Ua.Server.TimeSlice reference ) : DataValue
timestamp System.DateTime The timestamp.
reference Opc.Ua.Server.TimeSlice The timeslice that contains the timestamp.
return DataValue

Interpolate() protected method

Calculate the interpolate aggregate for the timeslice.
protected Interpolate ( Opc.Ua.Server.TimeSlice slice ) : DataValue
slice Opc.Ua.Server.TimeSlice
return DataValue

IsGood() protected method

Checks if the value is good according to the configuration rules.
protected IsGood ( DataValue value ) : bool
value DataValue The value to test.
return bool

QueueRawValue() public method

Queues a raw value for processing.
public QueueRawValue ( DataValue value ) : bool
value DataValue The data value to process.
return bool

SlopedInterpolate() public static method

Calculate the value at the timestamp using slopped interpolation.
public static SlopedInterpolate ( System.DateTime timestamp, DataValue earlyBound, DataValue lateBound ) : DataValue
timestamp System.DateTime
earlyBound DataValue
lateBound DataValue
return DataValue

SteppedInterpolate() public static method

Calculate the value at the timestamp using slopped interpolation.
public static SteppedInterpolate ( System.DateTime timestamp, DataValue earlyBound ) : DataValue
timestamp System.DateTime
earlyBound DataValue
return DataValue

UpdateSlice() protected method

Creates a new time slice to process.
protected UpdateSlice ( Opc.Ua.Server.TimeSlice slice ) : bool
slice Opc.Ua.Server.TimeSlice The slice to update.
return bool