Reference
OpcNodeHistory Members
Represents a history of values kept in memory in ascending order of their timestamps, with at most one value per timestamp.
Reference
OpcNodeHistory<T> Members
- Type
- OpcNodeHistory<T>
- Namespace
- Opc.UaFx.Server
- Assembly
- Opc.UaFx.Advanced.dll
- Package
- Opc.UaFx.Advanced v2.59.0
Constructors
OpcNodeHistory
| Overload | Description |
|---|---|
| OpcNodeHistory() | Initializes a new instance of the OpcNodeHistory< |
| OpcNodeHistory( | Initializes a new instance of the OpcNodeHistory<capacity specified. |
| OpcNodeHistory( | Initializes a new instance of the OpcNodeHistory<values specified. |
| OpcNodeHistory( | Initializes a new instance of the OpcNodeHistory<capacity and values specified. |
| OpcNodeHistory( | Initializes a new instance of the OpcNodeHistory<values specified. |
| OpcNodeHistory( | Initializes a new instance of the OpcNodeHistory<capacity and values specified. |
OpcNodeHistory()
Initializes a new instance of the OpcNodeHistory<T> class whose Capacity is -1 (unlimited).
public OpcNodeHistory()Public Sub New()OpcNodeHistory(int)
Initializes a new instance of the OpcNodeHistory<T> class using the capacity specified.
public OpcNodeHistory(int capacity)Public Sub New(capacity As Integer)Parameters
| Name | Type | Description |
|---|---|---|
capacity | Int32 | The maximum number of values the history keeps: -1 ( |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The capacity is 0 or less than -1. |
OpcNodeHistory(IEnumerable<T>)
Initializes a new instance of the OpcNodeHistory<T> class using the values specified. The number of values the history keeps is not limited.
public OpcNodeHistory(IEnumerable<T> values)Public Sub New(values As IEnumerable(Of T))Parameters
| Name | Type | Description |
|---|---|---|
values | IEnumerable< | A sequence of the values to add to the history. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | Two of the values have the same timestamp. |
| Argument | The values or one of its items is a null reference ( |
OpcNodeHistory(int, IEnumerable<T>)
Initializes a new instance of the OpcNodeHistory<T> class using the capacity and values specified.
public OpcNodeHistory(int capacity, IEnumerable<T> values)Public Sub New(capacity As Integer, values As IEnumerable(Of T))Parameters
| Name | Type | Description |
|---|---|---|
capacity | Int32 | The maximum number of values the history keeps: -1 ( |
values | IEnumerable< | A sequence of the values to add to the history. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | Two of the added values have the same timestamp. |
| Argument | The values or one of the added items is a null reference ( |
| Argument | The capacity is 0 or less than -1. |
Remarks
If the capacity is not -1, only the last capacity items of the sequence are added, regardless of their timestamps.
OpcNodeHistory(params T[])
Initializes a new instance of the OpcNodeHistory<T> class using the values specified. The number of values the history keeps is not limited.
public OpcNodeHistory(params T[] values)Public Sub New(ParamArray values As T())Parameters
| Name | Type | Description |
|---|---|---|
values | params T[] | The values to add to the history. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | Two of the values have the same timestamp. |
| Argument | The values or one of its items is a null reference ( |
OpcNodeHistory(int, params T[])
Initializes a new instance of the OpcNodeHistory<T> class using the capacity and values specified.
public OpcNodeHistory(int capacity, params T[] values)Public Sub New(capacity As Integer, ParamArray values As T())Parameters
| Name | Type | Description |
|---|---|---|
capacity | Int32 | The maximum number of values the history keeps: -1 ( |
values | params T[] | The values to add to the history. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | Two of the added values have the same timestamp. |
| Argument | The values or one of the added items is a null reference ( |
| Argument | The capacity is 0 or less than -1. |
Remarks
If the capacity is not -1, only the last capacity items of the array are added, regardless of their timestamps.
Properties
Capacity
Gets the maximum number of values the history keeps.
public int Capacity { get; }Public ReadOnly Property Capacity As IntegerProperty value
The maximum number of values: -1 (unlimited) or a positive number.
Remarks
When a value is added to a history which has reached its capacity, the value with the earliest timestamp is removed first, also if the value added is earlier, and the Removed event is raised.
Count
Gets the number of values in the history.
public int Count { get; }Public ReadOnly Property Count As IntegerProperty value
The number of values in the history.
EnableRaisingEvents
Gets or sets a value indicating whether the history raises the events Added, Removed and Replaced.
public bool EnableRaisingEvents { get; set; }Public Property EnableRaisingEvents As BooleanProperty value
The value true if the history raises the events; otherwise the value false. The default value is true.
EndTime
Gets the latest timestamp of the values in the history.
public DateTime? EndTime { get; }Public ReadOnly Property EndTime As Date?Property value
The latest timestamp or a null reference (Nothing in Visual Basic) if the history is empty.
StartTime
Gets the earliest timestamp of the values in the history.
public DateTime? StartTime { get; }Public ReadOnly Property StartTime As Date?Property value
The earliest timestamp or a null reference (Nothing in Visual Basic) if the history is empty.
Methods
Add
Adds the value specified to the history and raises the Added event.
public void Add(T value)Public Sub Add(value As T)Parameters
| Name | Type | Description |
|---|---|---|
value | T | The value to add. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The history already contains a value with the timestamp of the value. |
| Argument | The value is a null reference ( |
Remarks
If the history has reached its Capacity, the value with the earliest timestamp is removed first.
AddRange
| Overload | Description |
|---|---|
| AddRange( | Adds the values specified to the history and raises the Added event. |
| AddRange( | Adds the values specified to the history and raises the Added event. |
Exceptions (all overloads)
| Exception | Condition |
|---|---|
| Argument | The history already contains a value with the timestamp of one of the values. |
| Argument | The values or one of its items is a null reference ( |
AddRange(IEnumerable<T>)
Adds the values specified to the history and raises the Added event.
public void AddRange(IEnumerable<T> values)Public Sub AddRange(values As IEnumerable(Of T))Parameters
| Name | Type | Description |
|---|---|---|
values | IEnumerable< | A sequence of the values to add. |
Remarks
The values are added in the order of the sequence. If a value cannot be added, the method stops and throws the exception; the values added before remain in the history. For a value which already exists, the Added event provides the values added before; for an item which is a null reference, the event is not raised.
AddRange(params T[])
Adds the values specified to the history and raises the Added event.
public void AddRange(params T[] values)Public Sub AddRange(ParamArray values As T())Parameters
| Name | Type | Description |
|---|---|---|
values | params T[] | The values to add. |
Remarks
The values are added in the order of the array. If a value cannot be added, the method stops and throws the exception; the values added before remain in the history. For a value which already exists, the Added event provides the values added before; for an item which is a null reference, the event is not raised.
Clear
Removes all values from the history and raises the Removed event.
public void Clear()Public Sub Clear()Contains
| Overload | Description |
|---|---|
| Contains( | Determines whether the history contains a value at the timestamp specified. |
| Contains( | Determines whether the history contains the value specified. |
Contains(DateTime)
Determines whether the history contains a value at the timestamp specified.
public bool Contains(DateTime timestamp)Public Function Contains(timestamp As Date) As BooleanParameters
| Name | Type | Description |
|---|---|---|
timestamp | DateTime | The timestamp to look for. |
Returns
The value true if the history contains a value at the timestamp; otherwise the value false.
Contains(T)
Determines whether the history contains the value specified.
public bool Contains(T value)Public Function Contains(value As T) As BooleanParameters
| Name | Type | Description |
|---|---|---|
value | T | The value to look for. |
Returns
The value true if the value of the history at the timestamp of the value is equal to the value; otherwise the value false.
Exceptions
| Exception | Condition |
|---|---|
| Argument | The value is a null reference ( |
Enumerate
| Overload | Description |
|---|---|
| Enumerate() | Enumerates the values of the history in ascending order of their timestamps. |
| Enumerate( | |
| Enumerate( |
Enumerate()
Enumerates the values of the history in ascending order of their timestamps.
public IEnumerable<T> Enumerate()Public Function Enumerate() As IEnumerable(Of T)Returns
IEnumerable<T>
A sequence of the values of the history.
Remarks
The history stays locked while the sequence is enumerated, so that other threads which access the history wait until the enumeration has completed or the enumerator has been disposed.
Enumerate(DateTime?)
public IEnumerable<T> Enumerate(DateTime? startTime)Public Function Enumerate(startTime As Date?) As IEnumerable(Of T)Parameters
| Name | Type | Description |
|---|---|---|
startTime | Nullable<DateTime> |
Returns
IEnumerable<T>
Enumerate(DateTime?, DateTime?)
public IEnumerable<T> Enumerate(DateTime? startTime, DateTime? endTime)Public Function Enumerate(
startTime As Date?,
endTime As Date?) As IEnumerable(Of T)Parameters
| Name | Type | Description |
|---|---|---|
startTime | Nullable<DateTime> | |
endTime | Nullable<DateTime> |
Returns
IEnumerable<T>
GetEnumerator
Returns an enumerator which iterates through the values of the history in ascending order of their timestamps.
public IEnumerator<T> GetEnumerator()Public Function GetEnumerator() As IEnumerator(Of T)Returns
IEnumerator<T>
An enumerator for the values of the history.
Implements
Remarks
The history stays locked while the enumerator is used, so that other threads which access the history wait until the enumeration has completed or the enumerator has been disposed.
OnAdded
Raises the Added event using the specified event data.
protected virtual void OnAdded(OpcNodeHistoryEventArgs<T> e)Protected Overridable Sub OnAdded(e As OpcNodeHistoryEventArgs(Of T))Parameters
| Name | Type | Description |
|---|---|---|
e | Opc | The Opc |
OnRemoved
Raises the Removed event using the specified event data.
protected virtual void OnRemoved(OpcNodeHistoryEventArgs<T> e)Protected Overridable Sub OnRemoved(e As OpcNodeHistoryEventArgs(Of T))Parameters
| Name | Type | Description |
|---|---|---|
e | Opc | The Opc |
OnReplaced
Raises the Replaced event using the specified event data.
protected virtual void OnReplaced(OpcNodeHistoryEventArgs<T> e)Protected Overridable Sub OnReplaced(e As OpcNodeHistoryEventArgs(Of T))Parameters
| Name | Type | Description |
|---|---|---|
e | Opc | The Opc |
Remove
Removes the value specified from the history and raises the Removed event.
public bool Remove(T value)Public Function Remove(value As T) As BooleanParameters
| Name | Type | Description |
|---|---|---|
value | T | The value to remove. |
Returns
The value true if the history contained the value (see Contains) and the value has been removed; otherwise the value false.
Exceptions
| Exception | Condition |
|---|---|
| Argument | The value is a null reference ( |
RemoveAt
| Overload | Description |
|---|---|
| RemoveAt( | Removes the value at the index specified in the ascending order of the timestamps and raises the Removed event. |
| RemoveAt( | Removes the value at the timestamp specified and raises the Removed event. |
| RemoveAt( | Removes the values at the timestamps specified and raises the Removed event. |
| RemoveAt( | Removes the values at the timestamps specified and raises the Removed event. |
RemoveAt(int)
Removes the value at the index specified in the ascending order of the timestamps and raises the Removed event.
public void RemoveAt(int index)Public Sub RemoveAt(index As Integer)Parameters
| Name | Type | Description |
|---|---|---|
index | Int32 | The zero-based index of the value to remove. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The index is less than zero or not less than Count. |
RemoveAt(DateTime)
Removes the value at the timestamp specified and raises the Removed event.
public void RemoveAt(DateTime timestamp)Public Sub RemoveAt(timestamp As Date)Parameters
| Name | Type | Description |
|---|---|---|
timestamp | DateTime | The timestamp of the value to remove. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The history contains no value at the timestamp. |
RemoveAt(IEnumerable<DateTime>)
Removes the values at the timestamps specified and raises the Removed event.
public void RemoveAt(IEnumerable<DateTime> timestamps)Public Sub RemoveAt(timestamps As IEnumerable(Of Date))Parameters
| Name | Type | Description |
|---|---|---|
timestamps | IEnumerable<DateTime> | A sequence of the timestamps of the values to remove. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The timestamps is a null reference ( |
| Argument | The history contains no value at one of the timestamps. |
Remarks
The values are removed in the order of the sequence. If the history contains no value at a timestamp, the method stops and throws the exception; the values removed before stay removed.
RemoveAt(params DateTime[])
Removes the values at the timestamps specified and raises the Removed event.
public void RemoveAt(params DateTime[] timestamps)Public Sub RemoveAt(ParamArray timestamps As Date())Parameters
| Name | Type | Description |
|---|---|---|
timestamps | params DateTime[] | The timestamps of the values to remove. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The timestamps is a null reference ( |
| Argument | The history contains no value at one of the timestamps. |
Remarks
The values are removed in the order of the array. If the history contains no value at a timestamp, the method stops and throws the exception; the values removed before stay removed.
RemoveRange
| Overload | Description |
|---|---|
| RemoveRange( | |
| RemoveRange( |
RemoveRange(DateTime?)
public void RemoveRange(DateTime? startTime)Public Sub RemoveRange(startTime As Date?)Parameters
| Name | Type | Description |
|---|---|---|
startTime | Nullable<DateTime> |
Exceptions
| Exception | Condition |
|---|---|
| Argument |
RemoveRange(DateTime?, DateTime?)
public void RemoveRange(DateTime? startTime, DateTime? endTime)Public Sub RemoveRange(startTime As Date?, endTime As Date?)Parameters
| Name | Type | Description |
|---|---|---|
startTime | Nullable<DateTime> | |
endTime | Nullable<DateTime> |
Replace
Replaces the value at the timestamp of the value specified with the value and raises the Replaced event.
public void Replace(T value)Public Sub Replace(value As T)Parameters
| Name | Type | Description |
|---|---|---|
value | T | The new value. |
Exceptions
| Exception | Condition |
|---|---|
| Argument | The history contains no value at the timestamp of the value. |
| Argument | The value is a null reference ( |
Events
Added
Occurs after values have been added to the history.
public event EventHandler<OpcNodeHistoryEventArgs<T>> AddedPublic Event Added As EventHandler(Of OpcNodeHistoryEventArgs(Of T))Event type
EventHandler<OpcNodeHistoryEventArgs<T>>
Remarks
A method which adds several values raises the event once for all values added, also if no value has been added. The event is not raised while EnableRaisingEvents is false.
Removed
Occurs after values have been removed from the history, also if a value has been removed because the history reached its Capacity.
public event EventHandler<OpcNodeHistoryEventArgs<T>> RemovedPublic Event Removed As EventHandler(Of OpcNodeHistoryEventArgs(Of T))Event type
EventHandler<OpcNodeHistoryEventArgs<T>>
Remarks
A method which removes several values raises the event once for all values removed, also if no value has been removed. The event is not raised while EnableRaisingEvents is false.
Replaced
Occurs after a value of the history has been replaced.
public event EventHandler<OpcNodeHistoryEventArgs<T>> ReplacedPublic Event Replaced As EventHandler(Of OpcNodeHistoryEventArgs(Of T))Event type
EventHandler<OpcNodeHistoryEventArgs<T>>
Remarks
The Values of the event data provide the values which have been replaced, not the new values. The event is not raised while EnableRaisingEvents is false.
Indexers
Item
| Overload | Description |
|---|---|
| this[int] | Gets or sets the value at the index specified in the ascending order of the timestamps. |
| this[DateTime] | Gets or sets the value at the timestamp specified. |
this[int]
Gets or sets the value at the index specified in the ascending order of the timestamps.
public T this[int index] { get; set; }Public Default Property this[](index As Integer) As TParameters
| Name | Type | Description |
|---|---|---|
index | Int32 | The zero-based index of the value. |
Property value
T
The value at the index specified.
Exceptions
| Exception | Condition |
|---|---|
| Argument | The index is less than zero or not less than Count. |
Remarks
The setter replaces the value at the timestamp of the value at the index without comparing the timestamp of the new value and raises the Replaced event. To replace a value by its own timestamp use Replace.
this[DateTime]
Gets or sets the value at the timestamp specified.
public T this[DateTime timestamp] { get; set; }Public Default Property this[](timestamp As Date) As TParameters
| Name | Type | Description |
|---|---|---|
timestamp | DateTime | The timestamp of the value. |
Property value
T
The value at the timestamp specified.
Exceptions
| Exception | Condition |
|---|---|
| Key | The history contains no value at the timestamp specified. |
Remarks
The setter replaces the value at the timestamp without comparing the timestamp of the new value and raises the Replaced event. To replace a value by its own timestamp use Replace.

