This synchronous function inserts or replaces values and qualities in the history database for the specified timestamps for one or more items.
If the item has a value at the specified timestamp, the new value and quality will replace the old one.
If there is no value at that timestamp, the function will insert the new data. The function runs to completion before returning.
This function is intended to unconditionally insert/replace values and qualities; e.g., correction of values for bad sensors.
Visual Basic (Declaration) | |
---|---|
Public Overloads Function InsertReplace( _ ByVal server() As Integer, _ ByVal timeStamps() As Date, _ ByVal dataValues() As Object, _ ByVal qualities() As Integer, _ ByRef errors As Integer() _ ) As Integer |
C# | |
---|---|
public int InsertReplace( int[] server, DateTime[] timeStamps, object[] dataValues, int[] qualities, out int[] errors ) |
Parameters
- server
- The list of server item handles for the items to be edited.
- timeStamps
- Array of the time stamps for the new values.
- dataValues
- Array of structures which contain the new item values.
- qualities
- Array of the quality flags of the new values. These are the Data Access Quality flags, not the HDA quality flags.
- errors
- OUT: Array of HRESULTs indicating the success of the individual item. The errors correspond to the handles passed in server. This indicates whether the edit succeeded in inserting/replacing a defined value, quality and timestamp.
Return Value
S_OK, S_FALSE, E_NOTIMPL, E_FAILThe server, timeStamps, values and qualities are arrays of equal size.
To set values and qualities for a number of different items at a single time, then fimeStamp array would have the same time for each item.
To set a stream of values, timestamps and qualities for a single item, set the size of the item array to the number of values to be inserted/replaced and put the same ItemID in each element. S_OK as a error return code for an individual value is allowed when the HDA server is unable to say whether there was already a value at that timestamp.
If the HDA server can determine whether the new value replaces a value that was already there, it should use OPC_S_INSERTED or OPC_S_REPLACED to return that information.
Target Platforms: Windows 7/8/10, Windows Server 2008/2012/2016, .NET 4.x