Method Reference

Important: You do not have the latest version of Historian! You are missing out on the newest capabilities and enhanced security. For information on all the latest features, see the Historian product page. For more information on upgrades, contact your GE Digital sales agent or e-mail GE Digital Sales Support. For the most up-to-date documentation, go here.

Method Reference A-B

APIStatusToString Method (Server Object)

Converts a status ID into a string.

Syntax

object.APIStatusToString(nStatus, bHRESULT)

Table 1. Parameters
Name Data Type Description
nStatus Long The status ID to be converted.
bHRESULT Boolean If true, then the status ID is an HRESULT; otherwise, it is an APIStatus.

Returns

String. The translation of the status code.

Add Method (Archives Object)

Adds a new archive with the specified characteristics to the Historian server. You can also use this method to add an existing archive file to the archives collection to restore an archive.

Specify the FileLocation in the context of the Historian server machine drive and directory structure. If the specified FileLocation points to an existing valid Historian archive, the method effectively re-registers this archive and automatically loads it. Use this method when you return a previously unloaded archive to the system.

Since the Add request is synchronous, it immediately creates a new Archive object on the Historian server and another one in the Archives collection on the client.

Syntax

object.Add(ArchiveName As String, FileLocation As String, FileSize As Long, ArchiveDataStoreName As String)

Table 2. Parameters
Name Data Type Description
ArchiveName String Name of the archive to add (Read-Only).
FileLocation String Fully qualified name of the archive file (Read-Only).
FileSize Long Size of archive in MB (Read-Only).
ArchiveDataStoreName String Name of the archive data store the archive belongs to. This is an optional parameter.

Returns

Archive. The newly added Archive object or Nothing.

Add Method (Collectors Object)

Adds a new collector with the specified name to the Historian server. The collector name must be unique in a given Historian server.

Since the Add request is synchronous, it immediately creates a new Collector Object on the Historian server and another one in the Collectors collection on the client.

Syntax

object.Add(CollectorName)

Table 3. Parameters
Name Data Type
CollectorName String Name of the new collector to add. (Read-only)

Returns

Collector. Returns a reference to the newly created Collector object.

Add Method (DataRecordset Object)

Adds a new blank DataValue record to the current DataRecordset for the specified tag. The DataValue is written to the server when the WriteRecordset method of the DataRecordset object is called. You can optionally specify the value of the record or specify it after creation by operating on the DataValue object.

Syntax

object.Add(Tagname, TimeStamp, [InValue])

Table 4. Parameters
Name Data Type Definition
Tagname String Tag to which you are adding a new data value (read-only).
TimeStamp Date Timestamp to add value at (read-only).
InValue DataValue New value (optional).

Returns

DataValue. Returns a reference to the newly created data value.

Add Method (DataStores Object)

Adds a Data Store.

Syntax

object.Add(MyDataStoreName,MyDefaultDS, MyDataStoreType, MyDataStoreDescription)

Table 5. Parameters
Name Data Type
DataStoreName String Indicates the name of the data store.
IsDefault Boolean Indicates whether the data store is the default data store.
DataStoreType String Indicates the type of the data store: Historical, User, or SCADA buffer.
Description String The description provided for the data store.

Returns

DataStore.

Add Method (EnumeratedSets Object)

Adds an enumerated set to the Enumerated Sets collection. The enumerated set is not added to the Historian Server until the SaveSet Method is called.

Syntax

object.Add(MySet)

Table 6. Parameters
Name Data Type Description
MySet EnumeratedSet The set that has to be added.

Returns

None.

Add Method (EnumeratedStates Object)

Adds an enumerated state to the enumerated set collection. The enumerated state is not added to the Historian Server until the SaveSet Method is called.

Syntax

Object.Add(MyState)

Table 7. Parameters
Name Data Type Description
MyState EnumeratedState The state that has to be added.

Returns

None.

Add Method (MessageRecordset Object)

Adds a new blank message record to the current MessageRecordset. The message is written to the server when the WriteRecordset method of the MessageRecordset object is called.

Syntax

object.Add

Parameters

None

Returns

The empty message that was added.

Add Method (TagDependencies Object)

Adds a dependent Tag to the current calculation. The calculation will be triggered when the value of this tag changes.

Syntax

object.Add(Tagname)

Table 8. Parameters
Name Data Type Description
Tagname String Name of the tag to add

Returns

Boolean. Whether the Add operation succeeded.

Add Method (TagRecordset Object)

Adds a new blank tag record to the current TagRecordset. The tag is written to the server when the WriteRecordset method of the TagRecordset object is called.

Syntax

object.Add(Tagname)

Table 9. Parameters
Name Data Type Description
Tagname String Name of the tag to add

Returns

Returns a reference to the newly created tag.

Add Method (UserDefinedtypeFields Object)

Adds multiple fields to the User Defined Type. The User Defined Type is not added to the Historian Server until the SaveSet Method is called.

Syntax

object.Add(MyField)

Table 10. Parameters
Name Data Type Description
MyField UserDefinedTypeField The field to be added.

Returns

None.

AddComment Method (DataValue Object)

Adds a comment to the current DataValue. If you supply a secondary username and password, the SDK authenticates the username and password before the committing the comment.

Syntax

object.AddComment(Comment, [DataTypeHint], [SecondaryUser], [SecondaryPassword])

Table 11. Parameters
Name Data Type Description
Comment Variant The comment to add.
DataTypeHint String The name of the data type for the comment (optional, read-only).
SecondaryUser String Supervisor's username to sign comment (optional, read-only).
SecondaryPassword String Supervisor's password to sign comment (optional, read-only).

Returns

Boolean. Returns True if the AddComment Method operation succeeded.

AddEx Method (Archives Object)

Adds a new archive with the specified characteristics to the Historian server. You can also use this method to add an existing archive file to the archives collection to restore an archive.

Specify the FileLocation in the context of the Historian server machine drive and directory structure. If the specified FileLocation points to an existing valid Historian archive, the method effectively re-registers this archive and automatically loads it. Use this method when you return a previously unloaded archive to the system.

Since the Add request is synchronous, it immediately creates a new Archive object on the Historian server and another one in the Archives collection on the client.

The window pointed to by hWnd is kept alive (messages processed) while the archive is being added.

Syntax

object.AddEx(ArchiveName As String, FileLocation As String, FileSize As Long, hWnd As Long, ArchiveDataStoreName As String)

Table 12. Parameters
Name Data Type Description
ArchiveName String Name of the archive to add (Read-Only).
FileLocation String Fully qualified name of the archive file (Read-Only).
FileSize Long Size of archive in MB (Read-Only).
hWnd Long The window handle to keep alive.
ArchiveDataStoreName String Name of the archive data store the archive belongs to. This is an optional parameter.

Returns

Archive. The newly added Archive object or Nothing.

AddServer Method (ServerManager Object)

Registers a new server to the list of registered servers on the client. It makes an attempt to authenticate the connection based on the username and password supplied. If a username and password are not supplied, it assumes the user to be the currently authenticated domain user.

If it cannot authenticate the connection, because of incorrect user information or an invalid ServerName, the AddServer method returns False and does not register the supplied ServerName on the client.

Syntax

object.AddServer(ServerName, [UserName], [Password], [ConnectionTimeout])

Table 13. Parameters
Name Data Type Description
ServerName String Computer name of the Historian server (read-only).
UserName String Username to authenticate (optional, read-only).
Password String Password to authenticate (optional, read-only).
ConnectionTimeout Long The maximum length of time clients should wait for messages from the server before concluding the server is unavailable (optional, read-only).

Returns

Boolean. Returns True if the AddServer operation succeeded.

Example

Dim MyManager As New iHistorian_SDK.ServerManager
Dim MyServer As iHistorian_SDK.Server
' Try to add the new server
If MyManager.AddServer("USGB014") Then
Set MyServer = MyManager.Servers("USGB014") Else
err.Raise 1, , "Failed to authenticate new server" End If

AlarmAttributesRecordSet Method (Alarms Object)

This function returns a list of all the Vendor Attributes in the Alarm Archiver.

Syntax

object.AlarmAttributesRecordSet

Parameters

None.

Returns

AlarmAttributes. The AlarmAttributes object contains the list of vendor attributes.

AlarmRecordSet Method (Alarms Object)

This function is used to query alarms or events from the archiver. This function takes one parameter, an AlarmOpenRecordSetInfo object, which specifies the query. The following sections describe how to populate this object to perform an Alarm or Event query.

AlarmOpenRecordSetInfo Parameter

This object contains details on what to select, and any filters for the query. After creating the object, you first specify which fields to select, and which fields to sort (SelectFields), and then specify any criteria/filter to apply (AlarmCriteria).

Create the object: Dim myAlarmOpenRecordSetInfo As New AlarmOpenRecordSetInfo

Alarm Fields

The following is a list of the alarm fields that can be returned in the recordset, or used to sort or filter the recordset. These are used in the SelectFields and AlarmCriteria object (see below for more details).

Table 14.
Option Data Type Description
AlarmID Long The unique ID of the alarm or event in the Historian alarm database.
ItemID String The OPC ItemID of the alarm. This contains the source address of the data access tag the alarm is associated with. This could contain a NULL value if the alarm is not associated with a tag.
Source String This is the unique identifier used by the OPC AE Collector for the alarm or event.
DataSource String The collector interface name associated with the alarm or event.
Tagname String The Historian Tag Name associated with the alarm. The tag name will be NULL unless the tag is also collected by Historian.
EventCategory String The OPC event category of the alarm or event.
ConditionName String The OPC condition of the alarm. This does not apply to event data. This, combined with the Source, comprises an alarm.
SubConditionName String The OPC sub-condition of the alarm. This does not apply to event data. This is the state of the alarm.
StartTime Date The start time or time stamp of the alarm or event.
EndTime Date The end time of the alarm. This does not apply to event data.
AckTime Date The time the alarm was acknowledged. This does not apply to event data.
Timestamp Date The time stamp of the alarm or event.
Message String The message attached to the alarm or event.
Acked Boolean Stores the acknowledgement status of the alarm. If the alarm is acknowledged, this will be set to TRUE.
Severity Long The severity of the alarm or event. This is stored as an integer value with a range of 1-1000.
Actor String The operator who acknowledged the alarm, or caused the tracking event.
Quality String The quality of the alarm or event.

AlarmOpenRecordSetInfo.SelectFields

Each of the fields above can be selected, or used to sort the alarm recordset. Fill in the AlarmOpenRecordSetInfo.SelectFields for each field, according to the following table.

Option Data Type Description
Select Boolean True to select the field.
OrderBy Boolean True to order by the field.
OrderPriority Integer Relative priority compared to other field order priorities. Highest first. Ties are random.
Descending Boolean True to sort descending. OrderBy must also be True.

Example

Set up SelectFields to select the AlarmId and ItemId. Order by the AlarmId, then the ItemId.
myAlarmOpenRecordSetInfo.SelectFields.AlarmId.Select = TRUE 
myAlarmOpenRecordSetInfo.SelectFields.AlarmId.OrderBy = TRUE 
myAlarmOpenRecordSetInfo.SelectFields.AlarmId.OrderPriority = 10 
myAlarmOpenRecordSetInfo.SelectFields.ItemId.Select = TRUE 
myAlarmOpenRecordSetInfo.SelectFields.ItemId.OrderBy = TRUE 
myAlarmOpenRecordSetInfo.SelectFields.ItemId.OrderPriority = 20
The SelectFields object has one other field, AllFields, which can be used to select all fields.
SelectFields.AllFields = TRUE

Choose Query Type

For all queries, the type of query should be specified. If it is not specified, the default is to return a record set containing the events. The query type is specified by setting the AlarmOpenRecordSetInfo.AlarmCriteria.AlarmType object.
Query Alarms: myAlarmOpenRecordSetInfo.AlarmType = ihALARM_CONDITION 
Query Events: myAlarmOpenRecordSetInfo.AlarmType = ihALARM_TRACKING 
Query Historical Alarm Transitions: myAlarmOpenRecordSetInfo.AlarmType = ihALARM_CONDITION_HIST 
Add filters
Similar to the SelectFields object, each field listed above (Alarm Fields) can have criteria associated with it. This criteria is used to filter the record set, so for example, you can ask for all alarms with severity greater than 500. The type of Criteria that can be applied is dependant on the Data Type of the field. The following table lists the available criteria.:
Field Data Type Criteria Types
Integer/Long Min, Max, Equal, NotEqual
Float Min, Max, Equal, NotEqual
String StringMask
Quality Min, Max, Equal, NotEqual
For example, the Severity field is of type Long. Therefore, Min, Max, Equal, or NotEqual criteria can be specified for the severity. To query where severity is greater than 500:
myAlarmOpenRecordSetInfo.AlarmCriteria.SeverityCriteria.Min = 500 

Specify Max Records

An optional criteria, MaxRecords, can be set to set the upper limit size of the recordset.

Example: Return the first 10 records:
myAlarmOpenRecordSetInfo.AlarmCriteria.MaxRecords = 10
Note: To avoid having random rows returned, if you specify a MaxRecords criteria, you should generally also specify an Order By (see SelectFields above).

Syntax

object.AlarmRecordSet(theAlarmOpenRecordSetInfo)

Table 15. Parameters
Name Data Type Description
theAlarmOpenRecordSetInfo Variant See above for details.
Returns

AlarmRecordset. An AlarmRecordset object, populated according the details specified in the AlarmOpenRecordSetInfo parameter.

Example

Dim MyServer As iHistorian_SDK.Server 
Set MyServer = GetServer 
Dim myAlarmOpenRecordSetInfo As AlarmOpenRecordSetInfo 
' Select the last 100 alarms in the alarm history table 
myAlarmOpenRecordSetInfo.SelectFields.AllFields = True 
myAlarmOpenRecordSetInfo.SelectFields.Timestamp.OrderBy = True 
myAlarmOpenRecordSetInfo.SelectFields.Timestamp.Descending = True 
myAlarmOpenRecordSetInfo.AlarmCriteria.AlarmType = ihALARM_CONDITION_HIST 
myAlarmOpenRecordSetInfo.AlarmCriteria.MaxRecords = 100 
Dim myAlarmRecordSet As AlarmRecordSet 
Set myAlarmRecordSet = MyServer.Alarms.AlarmRecordSet(myAlarmOpenRecordSetInfo)

AllFields Method (DataFields Object)

Specifies that all DataFields should be returned in the DataRecordset query.

Syntax

Syntax object.AllFields

Parameters

None.

Returns

None.

AllFields Method (MessageFields Object)

Specifies that all MessageFields should be returned in the MessageRecordset query.

Syntax

object.AllFields

Parameters

None.

Returns

None.

AllFields Method (TagFields Object)

Sets all fields for retrieval in the TagRecordset query.

Syntax

object.AllFields

Parameters

None.

Returns

None.

Backup Alarms Method

Backs up or saves a copy of the alarms to an offline file.

Syntax

object.BackupAlarms

Table 16. Parameters
Name Data Type Description
BackupFile String The file that stores the backup alarm data.
StartTime Date Start time of the alarm data.
EndTime Date End time of the alarm data.

Returns

Boolean. Returns TRUE if the alarms are backed up.

Example
Dim Status As ihStatus
Dim ReturnStatus As Boolean
Dim AlarmsStartTime As ihTimeStruct 
Dim AlarmsEndTime As ihTimeStruct Status = ihSTATUS_FAILED ReturnStatus = False
AlarmsStartTime = Date_To_UTC(StartTime) AlarmsEndTime = Date_To_UTC(EndTime)
On Error GoTo errc
Status = ihBackupAlarms(MyServer.Handle, BackupFile, AlarmsStartTime, AlarmsEndTime, 0)
If Status <> ihSTATUS_OK Then err.Raise 1, , "Error while performing Backup alarms [" + ErrorDescription(Status) ReturnStatus = True
BackupAlarms = ReturnStatus errc:
zLastError = "Backup Alarms >> " + err.Description
BackupAlarms = ReturnStatusEnd Function

Backup Method (Archive Object)

Performs an online backup of the specified archive by stopping inbound data flow and copying an image of the specified archive into the file identified by the BackupFileName parameter.

When the online backup operation completes, the archive returns to normal operation and accepts inbound data flow.

Syntax

object.Backup(BackupFileName As String, Optional DataStoreName As String)

Table 17. Parameters
Name Data Type Description
BackupFileName String Fully qualified name of the backup file (read-only).
DataStoreName String Name of the data store to which the backup file belongs. This is an optional parameter.

Returns

Boolean. Returns whether or not the BackupFile operation succeeded.

Example
Dim BackupFilename As String
BackupFilename = ArchiverLauncher.Archives & "\TheCurrentArchive.ZIP" 
Set MyArchives = GetServer.Archives
' Find The Current Archive, Then Initiate A Backup
With MyArchives
  For I = 1 To .Item.count
    If .Item(I).IsCurrent Then
      If Not .Item(I).Backup(BackupFilename) Then 
        err.Raise 1, "Backup", "Backup Failed"
      End If
    End If
  Next I 
End With

BackupEx Method (Archive Object)

Performs an online backup of the specified archive by stopping inbound data flow and copying an image of the specified archive into the file identified by the BackupFileName parameter.

When the online backup operation completes, the archive returns to normal operation and accepts inbound data flow.

The Ex method will process messages for a client window while waiting for the backup to complete (so clients do not appear to be frozen.

Syntax

object.BackupEx(BackupFileName As String, hWnd As Long, DataStoreName As String)

Table 18. Parameters
Name Data Type Description
BackupFileName String Fully qualified name of the backup file (read-only)
hWnd Long The handle of the window to keep alive.
DataStoreName String Name of the data store. This is an optional parameter.

Returns

Boolean. Returns whether or not the BackupFile operation succeeded.

Example
Dim BackupFilename As String
BackupFilename = ArchiverLauncher.Archives & "\TheCurrentArchive.ZIP" Set MyArchives = GetServer.Archives
' Find The Current Archive, Then Initiate A Backup
With MyArchives
  For I = 1 To .Item.count
    If .Item(I).IsCurrent Then
      If Not .Item(I).Backup(BackupFilename) 
        Then err.Raise 1, "Backup", "Backup Failed"
      End If
    End If
  Next I 
End With

Browse Method (OPCBrowse Object)

Populates the Browse Object with sources and areas for the current browse position.

Syntax

object.Browse(theServer, theCollector)

Table 19. Parameters
Name Data Type Description
theServer Variant The Server Object for the Historian Server.
theCollector Variant The Collector Object for the Collector to Browse.

Returns

Boolean. Returns whether or not the Browse operation succeeded.

BrowseCollector Method (TagRecordset Object)

Browses a collector for its available tags.

Syntax

object.BrowseCollector(CollectorName, AdditionsOnly, SourceFilter, DescriptionFilter, [BrowsePosition], [Recursive])

Table 20. Parameters
Name Data Type Description
CollectorName String The name of the collector to browse.
AdditionsOnly Boolean Browse only tags that are additions to the Historian server.
SourceFilter String The tag source address filter.
DescriptionFilter String The tag description filter.
BrowsePosition String The browse position when performing an OPC hierarchical browse (optional, default = "").
Recursive Boolean Whether to perform an OPC hierarchical browse (optional, default = False).

Returns

Boolean. Success/Failure.

BrowseTags Method (Collector Object)

BrowseTags is available for collection in the data source. The tags can then be added to the archiver using the WriteRecordSet Method.

Syntax

object.BrowseTags([AdditionsOnly], [SourceFilter], [DescriptionFilter], [BrowsePosition], [Recursive])

Table 21. Parameters
Name Data Type Description
AdditionsOnly Boolean Browse only tags that are additions to the Historian server (optional, default = True).
SourceFilter String The tag source address filter (optional, default = "").
DescriptionFilter String The tag description filter (optional, default = "").
BrowsePosition String The browse position when performing an OPC hierarchical browse (optional, default = "").
Recursive Boolean Whether to perform an OPC hierarchical browse (optional, default = False).

Returns

TagRecordset. Returns a reference to the tag record that resulted from browsing the selected collector.

Example
Dim MyNewTags As iHistorian_SDK.TagRecordset
' Request The Collector To Browse Its Tag Source
Set MyNewTags = MyCollectors.Item("USIM031_OPC1").BrowseTags
' Modify Tag Records In Recordset To Add Additional Configuration Information
' Go Ahead And Add New Tags To System
If Not MyNewTags.WriteRecordset Then
  err.Raise 1, , "TagRecordset.WriteRecord failed: " + MyNewTags.LastError
End If

Method Reference C-D

C

Clear Method (DataCriteria Object)

Clears any previously supplied criteria for the DataRecordset query. Use this method to initialize the DataRecordset query.

Syntax

object.Clear

Parameters

None.

Returns

None.

Clear Method (DataFields Object)

Clears all DataFields from being returned in the DataRecordset query. Use this method to initialize the DataRecordset query.

Syntax

object.Clear

Parameters

None.

Returns

None.

Clear Method (Enumerated Sets Object)

Applies to:

Clears all the elements from the EnumeratedSets collection object and create a new instance of the EnumeratedSets collection.

Syntax

object.Clear

Parameters

None.

Returns

None.

Clear Method (EnumeratedStates Object)

Applies to:

Clears all the states from the enumerated set collection.

Syntax

object.Clear

Parameters

None.

Returns

None.

Clear Method (MessageCriteria Object)

Clears all previously supplied criteria for the MessageRecordset query. Use this method to initialize the MessageRecordset query.

Syntax

object.Clear

Parameters

None.

Returns

None.

Clear Method (MessageFields Object)

Clears all previously supplied criteria for the MessageRecordset query. Use this method to initialize the MessageRecordset query.

Syntax

object.Clear

Parameters

None.

Returns

None.

Clear Method (TagCriteria Object)

Clears previously entered criteria for the TagRecordset query. Use this method to initialize the TagRecordset query.

Syntax

object.Clear

Parameters

None.

Returns

None.

Clear Method (TagFields Object)

Clears all fields for retrieval in the TagRecordset query.

Syntax

object.Clear

Parameters

None.

Returns

None.

Returns

Clear Method (UserDefinedTypeFields Object)

Applies to:

Clears all the fields from the User Defined Type.

Syntax

object.Clear

Parameters

None.

Returns

None.

Returns

ClearRecordset Method (DataRecordset Object)

Clears specific records from the DataRecordset without deleting them from the Historian server.

You can specify a tagname to remove all DataValues for a specific tag, or supply a specific timestamp to remove a single DataValue.
CAUTION:
You can clear the entire DataRecordset by omitting both the tagname and timestamp.

Syntax

object.ClearRecordset([Tagname], [TimeStamp])

Table 22. Parameters
Name Data Type Description
Tagname String Tag to clear records for (optional, read-only).
TimeStamp Date Timestamp to clear records for (optional, read-only).

Returns

Boolean. Returns True if the ClearRecordset operation succeeded.

ClearRecordset Method (TagRecordset Object)

Clears specific records from the TagRecordset without deleting them from the Historian server. You can specify a tagname to delete a specific record.
CAUTION:
You can clear the entire TagRecordset by omitting the tag name.

Syntax

object.ClearRecordset([Tagname])

Table 23. Parameters
Name Data Type Description
Tagname String Name of tag to remove from record set (read-only, optional).

Returns

Boolean. Success/Failure.

CloseAlarms Method (Alarms Object)

This function sends a special alarm request to close alarms on a specific collector before a specific date. This is useful to close out any alarms that are stuck mid-lifecycle.

Syntax

object.CloseAlarms(endDate, theCollector)

Table 24. Parameters
Name Data Type Description
endDate Date The date from which to close alarms. Alarms before this date are closed.
theCollector String Close alarms associated with this collector/datasource.
Note: If your alarm collector is linked to a data collector, pass in the data collector name.

Returns

None.

CloseArchive Method (Archive Object)

Closes the specified archive for new data flow. You can perform this operation on the current archive only (the one accepting the newest data). Once an archive is closed, the Historian server looks to the next available empty archive to re-commence data storage.

If no empty archive is found, the method creates one or overwrites the oldest loaded archive. The archiving options, ArchiveAutomaticCreate, ArchiveAutomaticFreeSpace, ArchiveDefaultSize, and ArchiveOverWriteOld, control this behavior.

If ArchiveAutomaticCreate is running and enough free space exists on the drive of the ArchiveDefaultPath, the method creates a new archive of default size after it creates an archive of default size.

If the method cannot create a new archive, it overwrites the oldest archive based on ArchiveOverWriteOld being on. If ArchiveOverWriteOld is not on, the Historian archiver shuts down and the collectors start buffering data.

Syntax

object.CloseArchive(DataStoreName As String)

Table 25. Parameters
Name Data Type Description
DataStoreName String The name of the data store the archive belongs to. This is an optional parameter.

Returns

Boolean. Returns whether or not the CloseArchive operation succeeded.

CollectorHasBackup Method (Collectors Object)

Returns whether a collector has a backup collector.

Syntax

object.CollectorHasBackup(CollectorName)

Table 26. Parameters
Name Data Type Description
CollectorName String Name of the collector to determine if a backup exists.

Returns

Boolean. True if the Collector has a backup, False otherwise.

Example
Dim MyCollectors As iHistorian_SDK.Collectors
Set MyCollectors = MyServer.Collectors
Dim HasBackup As Boolean
HasBackup = MyCollectors.CollectorHasBackup("SimulationCollector")

CommitImport Method (Alarms Object)

Writes the alarms/events acquired via the Import method to the Historian Archiver.

Syntax

object.CommitImport

Parameters

None

Returns

Boolean. Returns whether or not the Import operation succeeded.

Connect Method (Server Object)

Initiates a connection to the current server. Calling the Connect method on a currently connected session re-authenticates the user.

If a ServerName has been set, the method authenticates the user by the username and password supplied, if any. If they are not supplied, it authenticates the user by the currently authenticated domain user. If a ServerName has not been set, it uses the ServerName registered as the Default Server. If a username and password are not supplied, it uses the username and password registered with the default server. If neither establishes a username, it authenticates the user by the currently authenticated domain user.

Syntax

object.Connect([ServerName], [UserName], [Password])

Table 27. Parameters
Name Data Type Description
ServerName String Table text
UserName String Username to authenticate (optional).
Password String Password to authenticate (optional).

Returns

Boolean. Returns whether or not the Connect operation succeeded.

Example
Dim MyServer As New iHistorian_SDK.Server
' Connect to the default server using default user
If Not MyServer.Connect Then
err.Raise 1, , "Failed to authenticate on server " + MyServer.ServerName
End If
' Connect to the default server using specific user
If Not MyServer.Connect("Fred", "000") Then
err.Raise 1, , "Failed to authenticate on server " + MyServer.ServerName
End If
' Connect to specific server using specific user
If Not MyServer.Connect("USGB014", "Fred", "000") Then
err.Raise 1, , "Failed to authenticate on server " + MyServer.ServerName
End If

ConvertShortcutToTime Method (Server Object)

Converts a time shortcut to a date. It converts the time from UTC into formatted time based on the ConnectionOptions (TimeOption) settings listed below.

Value Description
(N)ow The current time (absolute).
(T)oday Today at midnight (absolute).
(Y)esterday Yesterday at midnight (absolute).
(D)ays Number of Days (relative).
(M)in Number of Minutes (relative).
(H)our Number of Hours (relative).
(W)eek Number of Weeks (relative).
(BOM) Beginning of this month at Midnight (absolute).
(EOM) Last Day of this month at Midnight (absolute).
(BOY) First Day of this year at Midnight (absolute).
(EOY) Last Day of this year at Midnight (absolute).

Syntax

object.ConvertShortcutToTime(Shortcut)

Table 28. Parameters
Name Data Type Description
Shortcut String Date of shortcut to convert (read-only).

Returns

Date. Returns date converted from string shortcut.

CopyTo Method (Tag Object)

Copies the properties of the given tag to the specified destination tag.

Syntax

object.CopyTo(TargetTag)

Table 29. Parameters
Name Data Type Description
TargetTag Variant The destination tag.

Returns

None.

CriteriaFromStrings Method (QueryModifiers Object)

Applies to:

Returns the sampling mode, calculation mode and query modifiers associated with the input CriteriaString.

Syntax

object.CriteriaFromStrings(CriteriaString As String)

Table 30. Parameters
Name Data Type Description
CriteriaString String Indicates the criteria string. For example, #ONLYGOOD.

Returns

DataCriteria

D

DataStoreUpdate Method (DataStores Object)

Updates the changes made to the data store settings.

Syntax

object.MyDataStores.Item(DataStoreName)

Table 31. Parameters
Name Data Type Description
DataStoreName String Name of the data store that should be updated.
IsDefault Boolean Indicates whether the data store is the default data store.
Description String Description of the data store. This is an optional parameter.
StorageType String Indicates whether the storage type is historical or SCADA buffer. This is an optional parameter.

Returns

Boolean. Returns TRUE if the data store has been updated and FALSE if there is an error in updating the data store.

Delete Method (Archive Object)

Deletes the specified archive on the Historian server. This is a synchronous operation that executes immediately when you call the Delete Method.

Syntax

object.Delete(DataStoreName As String)

Table 32. Parameters
Name Data Type Description
DataStoreName String Name of the data store that contains the archive. This is an optional parameter.

Returns

Boolean. Returns whether or not the Delete operation succeeded.

Delete Method (Archives Object)

Attempts to delete an Archive from the Historian server.

Syntax

object.Delete(ArchiveName As String, ArchiveDataStoreName As String)

Table 33. Parameters
Name Data Type Description
ArchiveName String Name of the archive to delete.
ArchiveDataStoreName String Name of the archive data store the archive belongs to. This is an optional parameter.

Returns

Boolean. Returns whether or not the Delete operation succeeded.

Delete Method (Collector Object)

Deletes the specified collector on the Historian Server.
CAUTION:
The default option also deletes all tags marked with this collector as their source (CollectorName Property) at the same time it deletes the collector.

Syntax

object.Delete([DeleteTags])

Table 34. Parameters
Name Data Type Description
DeleteTags Boolean Deletes collector tags when deleting the collector. (optional, default = True)

Returns

Boolean. Whether the Delete was successful.

Delete Method (Collectors Object)

Removes an existing collector with the specified name from the Historian server.

Syntax

object.Delete(CollectorName, [DeleteTags])

Table 35. Parameters
Name Data Type Description
CollectorName String Name of the collector to Delete.
DeleteTags Boolean Should the tags from this collector be deleted as well?

Returns

Boolean. Success/Failure.

Example

Dim MyCollectors As iHistorian_SDK.Collectors 
Set MyCollectors = MyServer.Collectors 
MyCollectors.Delete "OPC Collector"

Delete Method (DataRecordset Object)

Marks the specified tag in the current TagRecordset for deletion. If the specified tag does not exist in the current TagRecordset, the method adds it. If the tag is not found, the Delete method fails.

In either case, the method does not delete this tag on the Historian server until the WriteRecordset Method of the TagRecordset object is called.

Syntax

object.Delete(Tagname, TimeStamp)

Table 36. Parameters
Name Data Type Description
Tagname String Name of the tag to delete (read-only).
TimeStamp Date Tag timestamp (optional).

Returns

Boolean. Returns True if successful.

Delete Method (DataStores Object)

Deletes the data store.

Syntax

object.Delete(DataStoreName As String)

Table 37. Parameters
Name Data Type Description
DataStoreName String Indicates the name of the data store that has to be deleted.

Returns

Boolean. Returns TRUE if the data store has been deleted and FALSE if there is an error in deleting the data store.

Delete Method (DataValue Object)

Deletes the DataValue from the archive. Commit the Delete operation by calling the WriteRecordset method of the DataRecordset object.

Syntax

object.Delete

Parameters

None

Returns

Boolean. Returns whether or not the Delete operation succeeded.

Delete Method (EnumeratedSets Object)

Deletes the specified set from the Historian Server. This is a synchronous operation that is executed immediately when you call the Delete method.

Syntax

object.Delete(setName)
Table 38. Parameters
Name Data Type Description
SetName Variant The name of the set that has to be deleted.

Returns

Boolean. Returns True if the method has been deleted

Delete Method (EnumeratedStates Object)

Deletes the specified state from the enumerated set. This is a synchronous operation that is executed immediately when you call the Delete method.

Syntax

object.Delete(StateName)

Table 39. Parameters
Name Data Type Description
StateName Variant The name of the state that has to be deleted.

Returns

Boolean. Returns True if the state has been deleted or False if not.

Delete Method (Tag Object)

Deletes the specified tag on the Historian Server. This is a synchronous operation that executes immediately when you call the Delete method. You can choose to delete a tag permanently from the Historian Server by passing an additional parameter as True or False.
Note: This method is called within the WriteRecordset method. For more information, refer to the Sample Code section.

Syntax

object.Delete((Optional) DeletePermanent)

Table 40. Parameters
Name Data Type Description
DeletePermanent Boolean (Optional) Pass TRUE to permanently delete a tag.

Returns

Boolean. Returns whether or not the Delete operation succeeded.

Delete Method (TagRecordset Object)

Marks the specified tag in the current TagRecordset for deletion. If the specified tag does not exist in the current TagRecordset, the method adds it. If the tag is not found, the Delete method fails. In either case, the method does not delete this tag on the Historian server until the WriteRecordset method of the TagRecordset object is called.

Syntax

object.Delete(Tagname)

Table 41. Parameters
Name Data Type Description
Tagname String Name of the tag to delete (read-only).

Returns

Boolean. Returns whether or not the Delete operation succeeded.

Delete Method (UserDefinedTypeFields Object)

Deletes a field from the User Defined Type. This is a synchronous operation that is executed immediately when you call the Delete method.

Syntax

object.Delete(FieldName)

Table 42. Parameters
Name Data Type Description
FieldName Variant The name of the state that has to be deleted.

Returns

Boolean. Returns TRUE if the state has been deleted.

DeleteEx Method (Archive Object)

Deletes the specified archive on the Historian server. This is a synchronous operation that executes immediately when you call the Delete Method. The window associated with the handle passed in is kept alive (messages processed) while the operation takes place.

Syntax

object.DeleteEx(hWnd As Long, DataStoreName As String)

Table 43. Parameters
Name Data Type Description
hWnd Long The handle of the window to keep alive.
DataStoreName String Name of the data store that contains the archive. This is an optional parameter.

Returns

Boolean. Returns whether or not the Delete operation succeeded.

DeleteEx Method (Archives Object)

Attempts to delete an Archive from the Historian server. Keeps the window with handle hwnd alive by processing its messages while waiting for the deletion to occur.

Syntax

object.DeleteEx(ArchiveName As String, hWnd As Long, ArchiveDataStoreName As String)

Table 44. Parameters
Name Data Type Description
ArchiveName String Name of the archive to delete
hWnd Long The window handle to keep alive.
ArchiveDataStoreName String Name of the archive data store the archive belongs to. This is an optional parameter.

Returns

Boolean. Success/Failure.

Disconnect Method (Server Object)

Disconnects the currently authenticated connection to the Server.

Syntax

object.Disconnect

Parameters

None

Returns

None.

Method Reference E-H

E

Export Method (Alarms Object)

Exports the contents of the AlarmRecordSet into the specified file.

Syntax

object.Export(AlmRS, RSInfo, FileName, FileFormat)

Table 45. Parameters
Name Data Type Description
AlmRS AlarmRecordSet Returns the requested records (writeable).
RSInfo AlarmOpenRecordSetInfo Contains descriptions of the desired records (read-only).
FileName String Fully qualified export filename (read-only).
FileFormat ihFileFormat File format of the export file (read-only).

Returns

Boolean. Returns whether or not the Export operation succeeded.

Export Method (DataRecordset Object)

Exports the contents of the current DataRecordset into the specified file.

Syntax

object.Export(FileName, FileFormat)

Table 46. Parameters
Name Data Type Description
FileName String Fully qualified export filename (read-only.
FileFormat ihFileFormat File format of the export file (read-only).

Returns

Boolean. Returns whether or not the Export operation succeeded.

Example

' Export File From Existing Query Results
If Not MyRecordset.Export("C:\Temp\DataReport.RPT", ihFileFormat.Report) Then
Err.Raise 1, , "Error Exporting File: " + MyRecordset.LastError
End If

Export Method (EnumeratedSets Object)

Applies to:

Exports the contents of the EnumeratedSets collection into the specified file.

The following file formats are supported:

Name Description Value
CSV File is imported/exported as comma separated values. 1
XML File is imported/exported as XML. 2

Imported files follow a specific format that contains specific keywords. With CSV, the first row of the file establishes the fields in the file and their positions. With XML reports, the files describe the format of the data.

Syntax

object. Export(FileName, FileFormat)

Table 47. Parameters
Name Data Type Description
FileName String Fully qualified export file name (read-only).
FileFormat ihFileFormat File format of the export file (read-only).

Returns

Boolean. Returns True if the sets have been exported successfully.

Export Method (MessageRecordset Object)

Exports the contents of the current MessageRecordset into the specified file.

The following file formats are supported. Exported files follow a specific format containing specific keywords. With CSV and tabular reports, the first row of the file establishes the fields in the file and their positions. With XML, the file itself describes the format of the data.

Name Description Value
CSV File is imported/exported as comma separated values. 1
XML File is imported/exported as XML. 2
Report File is exported as a columnar report 3

Syntax

object.Export(FileName, FileFormat)

Table 48. Parameters
Name Data Type Description
FileName String Fully qualified export file name (read-only).
FileFormat ihFileFormat File format of the export file (read-only).

Returns

Boolean. Success/Failure.

Export Method (TagRecordset Object)

Exports the contents of the current TagRecordset into the specified file.

The following file formats are supported:

Name Description Value
CSV File is imported/exported as comma separated values. 1
XML File is imported/exported as XML. 2
Report File is exported as a columnar report 3
Imported files follow a specific format that contains specific keywords. With CSV and tabular reports, the first row of the file establishes the fields in the file and their positions. With XML reports, the files describe the format of the data. Prepare a file for import by exporting it with the desired fields for import.

Syntax

object.Export(FileName, FileFormat)

Table 49. Parameters
Name Data Type Description
FileName String Fully qualified export file name (read-only).
FileFormat ihFileFormat File format of the export file (read-only).

Returns

Returns whether or not the Export operation succeeded.

Example

' Export file from existing query results
Set MyRecordset = MyServer.Tags.NewRecordset 
MyRecordset.Criteria.Tagname = "*" 
MyRecordset.Fields.AllFields 
MyRecordset.QueryRecordset
If Not MyRecordset.Export(Path & "TagReport.RPT", ihFileFormat.Report) Then 
err.Raise 1, , "Error exporting file: " & MyRecordset.LastError
End If

Export Method (UserDefinedType Object)

Applies to:

Exports the contents of the User Defined Type into the specified file.

The following file formats are supported:

Name Description Value
CSV File is imported/exported as comma separated values. 1
XML File is imported/exported as XML. 2
Imported files follow a specific format that contains specific keywords. With CSV, the first row of the file establishes the fields in the file and their positions. With XML reports, the files describe the format of the data.

Syntax

object. Export(FileName, FileFormat)
Table 50. Parameters
Name Data Type Description
FileName String Fully qualified export file name (read-only).
FileFormat ihFileFormat File format of the export file (read-only).

Returns

Boolean. Returns TRUE if the User Defined Type is exported successfully.

G

GetCurrentValue Method (Collector Object)

Returns the current value for a given tag.

Syntax

object.GetCurrentValue(SourceAddress, ErrorMessage, CurrentValue)

Table 51. Parameters
Name Data Type Description
SourceAddress String The tag source address.
ErrorMessage String The error message string encountered, if any.
CurrentValue String A DataValue object representing the current tag value.

Returns

Boolean. Succeeded/Failed. Example
Dim OPC1 As iHistorian_SDK.Collector
Dim MyTagValue As Variant
Dim MyErrorMessage As String
' Request The Collector To Get the Current Value for a Tag 
Set OPC1 = MyCollectors.Item("USIM031_OPC1") 
OPC1.GetCurrentValue "OPCTag1", MyErrorMessage, MyTagValue

GetFilters Method (OPCFilters Object)

Returns the current set of Filters configured for MyCollector.

Syntax

object.GetFilters(MyServer, MyCollector)

Table 52. Parameters
Name Data Type Description
MyServer Variant The Historian server connection.
MyCollector MyCollector The Collector object to acquire the Filter information for.

Returns

Boolean true on success, false otherwise

GetLastError Method (Server Object)

Returns the last error message encountered by the Server object. To see a complete list of messages, refer to the ErrorList property. When possible, the system translates messages into the locale of the client.

Syntax

object.GetLastError

Parameters

None

Returns

String. The last error message encountered.

GetPrimaryCollectorName Method (Collectors Object)

Returns the name of the Primary Collector for a set of redundantly configured Collectors.

Syntax

object.GetPrimaryCollectorName(CollectorName)

Table 53. Parameters
Name Data Type Description
CollectorName String The name of the Collector.

Returns

String. The primary collector name.

Method Reference I-L

I

Import Method (Alarms Object)

This function imports the alarms/events in the specified file into this Alarms object.
CAUTION:
Any previously imported alarms will be discarded.

Syntax

object.Import(FileName, FileFormat)

Table 54. Parameters
Name Data Type Description
FileName String Fully qualified import filename (read-only).
FileFormat Long File format of the import file (read-only).

Returns

Boolean. Returns whether or not the Import operation succeeded.

Import Method (DataRecordset Object)

Imports the specified file into the current DataRecordset. If the DataRecordset contains items when the Import Method is invoked, the method first clears current DataRecordset before it imports the specified file.

Syntax

object.Import(FileName, FileFormat)

Table 55. Parameters
Name Data Type Description
FileName String Fully qualified import filename (read-only).
FileFormat Long File format of the import file (read-only).

Returns

Boolean. Returns whether or not the Import operation succeeded.

Example

' Get A New Recordset
Set MyRecordset = MyData.NewRecordset
' Import The File
If Not MyRecordset.Import("C:\Temp\ImportData.CSV", ihFileFormat.CSV) Then
Err.Raise 1, , "Error Importing File:" + MyRecordset.LastError
End If
' Commit Data
If Not MyRecordset.WriteRecordset Then
Err.Raise 1, , "Error Committing File: " + MyRecordset.LastError
End If

ImportMethod (EnumeratedSets Object)

Imports the specified file into the EnumeratedSets collection. The following file formats are supported:
Name Description Value
CSV File is imported/exported as comma separated values. 1
XML File is imported/exported as XML. 2
Imported files follow a specific format that contains specific keywords. With CSV files, the first row of the file establishes the fields in the file and their positions. With XML reports, the files describe the format of the data.

Syntax

object. Import(FileName, FileFormat, Server)

Table 56. Parameters
Name Data Type Description
FileName String Fully qualified export file name (read-only).
FileFormat ihFileFormat File format of the export file (read-only).
Server Server Server from which the sets are imported.

Returns

Boolean. Returns True if the sets have been imported successfully.

Import Method (MessageRecordset Object)

Attempts to import a list of Messages from a file.

Syntax

object.Import(FileName, FileFormat)
Table 57. Parameters
Name Data Type Description
FileFormat ihFileFormat The format of the file specified in FileName
FileName String The name of the file to import.

Returns

Boolean true if the Import succeeded, false otherwise.

Import Method (TagRecordset Object)

Imports the specified file into the current TagRecordset. If the TagRecordset contains items when the Import method is invoked, the method first clears the current TagRecordset before importing the specified file. After you have imported a file, call the WriteRecordset method of the TagRecordset object to save the data to the Historian server. The following file formats are supported:
Name Description Value
CSV File is imported/exported as comma separated values. 1
XML File is imported/exported as XML. 2
Report File is exported as a columnar report. 3
Imported files follow a specific format that contains specific keywords. With CSV and tabular reports, the first row of the file establishes the fields in the file and their positions. With XML reports, the files describe the format of the data.
Note: Prepare a file for import by exporting it with the desired fields for import.

Syntax

object.Import(FileName, FileFormat)

Table 58. Parameters
Name Data Type Description
FileName String Fully qualified import file name (read-only).
FileFormat Long File format of the import file (read-only).

Returns

Returns whether or not the Import operation succeeded.

Example

' Get a new recordset
Set MyRecordset = MyTags.NewRecordset
' Import the file
If Not MyRecordset.Import(Path & "ImportTags.csv", ihFileFormat.CSV) Then err.Raise 1, , "Error importing file: " & MyRecordset.LastError
End If
' Commit Data
If Not MyRecordset.WriteRecordset Then
err.Raise 1, , "Error committing file: " & MyRecordset.LastError
End If

Import Method (UserDefinedType Object)

Applies to:

Imports the specified file into the User Defined Type collection. The following file formats are supported:
Name Description Value
CSV File is imported/exported as comma separated values. 1
XML File is imported/exported as XML. 2
Imported files follow a specific format that contains specific keywords. With CSV files, the first row of the file establishes the fields in the file and their positions. With XML reports, the files describe the format of the data.

Syntax

object. Import(FileName, FileFormat, Server)

Table 59. Parameters
Name Data Type Description
FileFormat ihFileFormat File format of the import file (read-only).
FileName String Fully qualified export file name (read-only).
Server Server Server from which the sets are imported.

Returns

Boolean. Returns TRUE if the type imports successfully.

InitiateFailover Method (Collectors Object)

Manually tries to initiate a Failover to a redundantly configured collector.

Syntax

object.InitiateFailover(CollectorName)

Table 60. Parameters
Name Data Type Description
CollectorName String Name of the collector to fail-over.

Returns

Collector. Returns Success/Failure.

Example

Dim MyCollectors As iHistorian_SDK.Collectors 
Set MyCollectors = MyServer.Collectors 
MyCollectors.InitiateFailover "SimulationCollector"

L

LastError Method (Alarms Object)

This function returns the last error message generated by this object.

Syntax

object.LastError

Parameters

None

Returns

String. The last error message encountered.

LoadUserCalcLibrary Method (Server Object)

Retrieves the user calculation library from the Server object. This library contains all of the user-created functions and subroutines available for calculations on this Server. The calculation library will be returned as an array of UserCalcFunction objects. If no functions exist in the library, UserCalcFunctions should be set to Empty

Syntax

object.LoadUserCalcLibrary(UserCalcFunctions)

Table 61. Parameters
Name Data Type Description
UserCalcFunctions Variant Resulting array of UserCalcFunction objects.

Returns

Boolean. Returns whether or not the calculation library was loaded successfully.

Example

Dim MyServer As New iHistorian_SDK.Server
Dim MyUserCalcFunctions() As iHistorian_SDK.UserCalcFunction
Dim MyNewFunction As New iHistorian_SDK.UserCalcFunction
' Connect to the local server
If Not MyServer.Connect("", "", "") Then
err.Raise 1, , "Failed to connect to the local server" End If
' Load the calculation library
MyServer.LoadUserCalcLibrary MyUserCalcFunctions
' Create a new function
MyNewFunction.Name = "Sum"
MyNewFunction.Definition = "Function Sum(a, b)" & vbCrLf & "Sum = a + b" & vbCrLf & "End Function"
' Add it to the loaded library
If IsArray(MyUserCalcFunctions) Then
ReDim Preserve MyUserCalcFunctions(UBound(MyUserCalcFunctions) + 1) Else
ReDim MyUserCalcFunctions(0) End If
Set MyUserCalcFunctions(UBound(MyUserCalcFunctions)) = MyNewFunction
' Save the changes to the calculation library
If Not MyServer.SaveUserCalcLibrary(MyUserCalcFunctions) Then err.Raise 1, , "Failed to save the calculation library"
End If

Method Reference M-P

M

ManageServerDialog Method (ServerManager Object)

Displays a dialog box to manage server connection information on the client. This dialog box allows you to add and remove new connections, and to modify the default username and password. This method optionally returns the name of the server last selected in the dialog.

Syntax

object.ManageServerDialog([SelectedServer])
Table 62. Parameters
Name Data Type Description
SelectedServer String Name of the selected Historian Server (optional, read/write).

Returns

None.

Example
Dim MyManager As New iHistorian_SDK.ServerManager
Dim MyServer As iHistorian_SDK.Server
Dim SelectedServer As String
' Show the manage server dialog
MyManager.ManageServerDialog SelectedServer
' If a server was selected, get the server
If Trim(SelectedServer) <> "" Then
Set MyServer = MyManager.Servers(SelectedServer) End If

N

NewRecordset Method (Data Object)

Returns a new DataRecordset object to subsequently build a query for tag data from the Historian server. It is the responsibility of the developer to release the DataRecordset object when processing has been completed. DataRecordset objects may be re-used by re-executing a query with new criteria set through the DataCriteria of the DataRecordset object.

You must also use a new DataRecordset object to add new data points to the system and delete existing data points from the system. Changes are not committed until calling the WriteRecordset method of the DataRecordset object.

Syntax

object.NewRecordset

Parameters

None

Returns

DataRecordset. A new, empty, DataRecordset object.

NewRecordset Method (Messages Object)

Returns a new MessageRecordset object to build a query for messages and alerts from the Historian server message archive. You must release the MessageRecordset object when processing completes. You can re-use a MessageRecordset object by re-executing a query with new criteria set through the MessageCriteria of the MessageRecordset object.

To add new messages, you must use a new MessageRecordset object. Call the WriteRecordset method of the MessageRecordset object to commit changes to the archiver.

Syntax

object.NewRecordset

Parameters

None

Returns

MessageRecordset. Returns the newly created MessageRecordset object.

NewRecordset Method (Tags Object)

Returns a new TagRecordset object to build a query for tag information. You must terminate the TagRecordset object when processing completes. You can re-use the TagRecordset objects by re-executing a query with new criteria set through the TagCriteria of the TagRecordset object.

You must also use a new TagRecordset object to add new tags to the system and to delete tags from the system. Call the WriteRecordset Method of the TagRecordset object to commit changes to the archiver.

Syntax

object.NewRecordset

Parameters

None.

Returns

TagRecordset. Returns a reference to the newly created Recordset Object.

Purge Alarms By Id Method

Purges a single alarm as identified by its alarm ID.

Syntax

object.AlarmIds
Table 63. Parameters
Name Data Type Description
AlarmIds Long Alarm ID of the alarm.

Returns

Boolean. Returns TRUE if the alarm is purged.

Example

Dim Status As ihStatus
            Dim ReturnStatus As Boolean
            Dim Alarms() As Long
            Dim NumberOfAlarms As Long
            Dim i As Long
            Status = ihSTATUS_FAILED ReturnStatus = False
            NumberOfAlarms = (UBound(AlarmIds) + 1)
            ReDim Alarms(0 To NumberOfAlarms - 1) As Long
            On Error GoTo errc
            For i = 0 To NumberOfAlarms - 1
            Alarms(i) = AlarmIds(i)
            Next i
            Status = ihPurgeAlarmsById(MyServer.Handle, Alarms(0), NumberOfAlarms, 0)
            If Status <> ihSTATUS_OK Then err.Raise 1, , "Error Purging alarms by Id[" + ErrorDescription(Status) + "," + CS ReturnStatus = True
            PurgeAlarmsById = ReturnStatus errc:
            zLastError = "Purge Alarms By Id>> " + err.Description
            PurgeAlarmsById = ReturnStatus
            End Function

Purge Alarms Method

Purges or deletes the alarms from the Archiver.

Syntax

object.PurgeAlarms

Table 64. Parameters
Name Data Type Description
BackupFile String The file that stores the purged alarm data.
ShouldZipAlarms Boolean Indicates whether the alarms should be zipped into file or not.
StartTime Date Start time of the alarms.
EndTime Date End time of the alarms.

Returns

Boolean. Returns TRUE if the alarms are purged.

Example

Dim Status As ihStatus
                        Dim AlarmsStartTime As ihTimeStruct Dim AlarmsEndTime As ihTimeStruct Dim ShouldZip As ihBoolean
                        Dim ReturnStatus As Boolean 
                        Status = ihSTATUS_FAILED ReturnStatus = False
                        AlarmsStartTime = Date_To_UTC(StartTime) AlarmsEndTime = Date_To_UTC(EndTime)
                        If ShouldZipAlarms = True Then
                        ShouldZip = ihTRUE Else
                        ShouldZip = ihFALSE End If
                        On Error GoTo errc
                        Status = ihPurgeAlarms(MyServer.Handle, BackupFile, ShouldZip, AlarmsStartTime, AlarmsEndTime, 0)
                        If Status <> ihSTATUS_OK Then err.Raise 1, , "Error Purging alarms [" + ErrorDescription(Status) + "," + CStr(St 
                        
                        ReturnStatus = True PurgeAlarms = ReturnStatus errc:
                        zLastError = "Purge Alarms>> " + err.Description
                        PurgeAlarms = ReturnStatus
                        End Function

Method Reference Q-T

Q

QueryArray Method (Archives Object)

This function returns a list of properties of an Archive found on the Historian server.

Syntax

object.QueryArray(ArchiveName, Params, SortAscending, ArrayOrientation, ArraySize, ReturnCount, ReturnArray)

Table 65. Parameters
Name Data Type Description
ArchiveName String Name of the Archive to return information on.
Params Variant A list of the parameters to retrieve on the specified Archive.
SortAscending Boolean Sorting preference for the returned list of properties.
ArrayOrientation Integer The desired orientation of the returned array.
ArraySize Long The desired size of the returned array.
ReturnCount Long The number of rows returned in ReturnArray
ReturnArray Variant A returned array which contains the requested properties.

Returns

Boolean. Success/Failure.

QueryArray Method (Collectors Object)

This function returns a list of properties for a set of Collectors.

Syntax

object.QueryArray(CollectorName, Params, SortAscending, ArrayOrientation, ArraySize, ReturnCount, ReturnArray)

Table 66. Parameters
Name Data Type Description
CollectorName String Name of the Collector to return information on.
Params Variant A list of the parameters to retrieve from the Collectors.
SortAscending Boolean Sorting preference for the returned list of properties.
ArrayOrientation Integer The desired orientation of the returned array.
ArraySize Long The desired size of the returned array.
ReturnCount Long The number of rows returned in ReturnArray
ReturnArray Variant A returned array which contains the requested properties.

Returns

Boolean. Success/Failure.

QueryArray Method (DataRecordset Object)

This function returns an array of data records from the Historian server.

Syntax

object.QueryArray(Params, SortAscending, ArrayOrientation, ArraySize, ReturnCount, ReturnArray)

Table 67. Parameters
Name Data Type Description
Params Variant A list of the parameters to retrieve.
SortAscending Boolean Sorting preference for the returned list of properties.
ArrayOrientation Integer The desired orientation of the returned array.
ArraySize Long The desired size of the returned array.
ReturnCount Long The number of rows returned in ReturnArray
ReturnArray Variant A returned array which contains the requested properties.

Returns

Boolean. Success/Failure.

QueryArray Method (MessageRecordset Object)

This function returns an array of Messages from the Historian server.

Syntax

object.QueryArray(Params, SortAscending, ArrayOrientation, ArraySize, ReturnCount, ReturnArray)

Table 68. Parameters
Name Data Type Description
Params Variant A list of the parameters to retrieve.
SortAscending Boolean Sorting preference for the returned list of properties.
ArrayOrientation Integer The desired orientation of the returned array.
ArraySize Long The desired size of the returned array.
ReturnCount Long The number of rows returned in ReturnArray
ReturnArray Variant A returned array which contains the requested properties.

Returns

Boolean. Success/Failure.

QueryArray Method (TagRecordset Object)

This function returns an array of Tags from the Historian server.

Syntax

object.QueryArray(Params, SortAscending, ArrayOrientation, ArraySize, ReturnCount, ReturnArray)

Table 69. Parameters
Name Data Type Description
Params Variant A list of the parameters to retrieve.
SortAscending Boolean Sorting preference for the returned list of properties.
ArrayOrientation Integer The desired orientation of the returned array.
ArraySize Long The desired size of the returned array.
ReturnCount Long The number of rows returned in ReturnArray.
ReturnArray Variant A returned array which contains the requested properties.

Returns

Boolean. Success/Failure

QueryRecordset Method (DataRecordset Object)

Executes the DataValue query based on the fields and criteria specified.

Syntax

object.QueryRecordset

Parameters

None

Returns

Boolean. Returns whether or not the QueryRecordset operation succeeded.

Example

Dim I As Integer 
Dim J As Integer 
Dim K As Integer 
Dim strComment$
Dim lngInterval As Long
Dim TagCount As Integer
Dim strDataQuality As String
Dim iDataRecordset As iHistorian_SDK.DataRecordset
Dim iDataValue As iHistorian_SDK.DataValue 
Dim lEndTime&, lStartTime&, lNumSamples& 
Dim lNumSeconds, lNumSamplesPerSecond
On Error GoTo Error_Handle
If CheckConnection = True Then
If lbTags.Text = "" Then
MsgBox "No Tag Selected", vbOKOnly, "SDK Sample" Exit Sub
End If
Set iDataRecordset = ConnectedServer.Data.NewRecordset
'reset lstValues.Clear
'build query
With iDataRecordset
'filter code
If txtFilterTag.Text <> "" Then
.Criteria.FilterTagSet = True
.Criteria.FilterTag = txtFilterTag.Text
.Criteria.FilterComparisonModeSet = True
'comparison mode
Select Case cboComparisonMode.Text
Case Is = "Equal"
.Criteria.FilterComparisonMode = 1
Case Is = "NotEqual " 
.Criteria.FilterComparisonMode = 2
Case Is = "LessThan"
.Criteria.FilterComparisonMode = 3
Case Is = "GreaterThan"
.Criteria.FilterComparisonMode = 4
Case Is = "LessThanEqual"
.Criteria.FilterComparisonMode = 5
Case Is = "GreaterThanEqual"
.Criteria.FilterComparisonMode = 6
End Select
.Criteria.FilterModeSet = True
'filter mode
Select Case cboFilterMode.Text
Case Is = "ExactTime"
.Criteria.FilterMode = 1
Case Is = "BeforeTime"
.Criteria.FilterMode = 2
Case Is = "AfterTime"
.Criteria.FilterMode = 3
Case Is = "BeforeAndAfterTime"
.Criteria.FilterMode = 4
End Select
.Criteria.FilterComparisonValue = txtFilterValue.Text
End If
.Criteria.Tagmask = lbTags.Text
.Criteria.StartTime = dtStartTime.Value
.Criteria.EndTime = dtEndTime.Value
'get sample mode
Select Case cboSampleMode.Text
Case Is = "Interpolated"
.Criteria.SamplingMode = 2 'interpolated
Case Is = "Raw By Number"
.Criteria.SamplingMode = 5 'raw by number
Case Is = "Raw By Time"
.Criteria.SamplingMode = 4 'raw by time
Case Is = "Current Value"
.Criteria.SamplingMode = 1 'current value
Case Is = "Calculated"
.Criteria.SamplingMode = 6 'calculation
Case Is = "Trend"
.Criteria.SamplingMode = 3 'trend
End Select
If .Criteria.SamplingMode = 5 Then
'if raw by number get direction
If optDirectionForward.Value = True Then
.Criteria.Direction = 1 'forward
Else
.Criteria.Direction = 2 'backward
End If
End If
'if calculation get calc mode
If .Criteria.SamplingMode = 6 Then
Select Case cboCalculationMode.Text
Case Is = "Average"
.Criteria.CalculationMode = 1 'average
Case Is = "Standard Deviation"
.Criteria.CalculationMode = 2 'standard deviation
Case Is = "Total"
.Criteria.CalculationMode = 3 'total
Case Is = "Minimum" 
.Criteria.CalculationMode = 4 'minimum
Case Is = "Maximum"
.Criteria.CalculationMode = 5 'maximum
Case Is = "Count"
.Criteria.CalculationMode = 6 'count
Case Is = "Raw Average"
.Criteria.CalculationMode = 7 'raw average
Case Is = "Raw Standard Deviation"
.Criteria.CalculationMode = 8 'raw standard deviation
Case Is = "Raw Total"
.Criteria.CalculationMode = 9 'raw total
Case Is = "Minimum Time"
.Criteria.CalculationMode = 10 'minimum time
Case Is = "Maximum Time"
.Criteria.CalculationMode = 11 'maximum time
Case Is = "Time Good"
.Criteria.CalculationMode = 12 'time good
End Select
End If
If optSamplingByNumber.Value = True Then
.Criteria.NumberOfSamples = Int(txtNumSamples.Text) Else
Select Case cboTimeUnits.Text
Case Is = "Milliseconds"
.Criteria.SamplingInterval = Int(txtInterval.Text) Case Is = "Seconds"
.Criteria.SamplingInterval = Int(txtInterval.Text) * 1000
Case Is = "Minutes"
.Criteria.SamplingInterval = Int(txtInterval.Text) * 60000
Case Is = "Hours"
.Criteria.SamplingInterval = Int(txtInterval.Text) * 3600000
Case Is = "Days"
.Criteria.SamplingInterval = Int(txtInterval.Text) * 86400000
End Select
End If
.Fields.AllFields
VB.Screen.MousePointer = vbHourglass 'wait wait wait lStartTime = Timer
'do query
If Not .QueryRecordset Then lEndTime = Timer
MsgBox "Query Failed..." & Chr(13) & iDataRecordset.LastError
VB.Screen.MousePointer = vbDefault
Exit Sub
End If
lEndTime = Timer VB.Screen.MousePointer = vbDefault lNumSamples = 0
TagCount = iDataRecordset.Item(1).Count
For I = 1 To iDataRecordset.Tags.Count
For J = 1 To iDataRecordset.Item(I).Count
Set iDataValue = iDataRecordset.Item(I).Item(J) Select Case iDataValue.DataQuality
Case Is = 1
strDataQuality = "Good" Case Is = 2
strDataQuality = "Bad" Case Is = 3
strDataQuality = "Unknown" 
Case Else
strDataQuality = "ERROR" End Select
strComment = ""
For K = 1 To iDataValue.Comments.Count
strComment = strComment & " " & iDataValue.Comments(K).Comment
Next K
lstValues.AddItem Format(iDataValue.TimeStamp, "MM/dd/yyyy hh:mm:ss") & _
Space(10) & CStr(iDataValue.Value) & vbTab & strDataQuality & vbTab & strComment lNumSamples = lNumSamples + 1
Next J 
Next I
End With
lNumSeconds = lEndTime - lStartTime lNumSamplesPerSecond = lNumSamples If lNumSeconds > 0 Then
lNumSamplesPerSecond = lNumSamples / lNumSeconds
End If
txtReadTime.Caption = lNumSamples & " returned in " & lEndTime - lStartTime & " seconds (" & lNumSamplesPerSec
Caption = "Output values for " & lbTags.Text & " (" & TagCount & ")" VB.Screen.MousePointer = vbDefault 'done
Else
MsgBox "Not Connected" 
End If
Exit Sub
Error_Handle:
VB.Screen.MousePointer = vbDefault
Select Case Err.Number
Case Is = 6 'overflow
MsgBox "Error Number: " & Err.Number & Chr(13) & "Description: " & Err.Description & Chr(13) & "Check numb
Case Is = 13 'type mismatch
MsgBox "Error Number: " & Err.Number & Chr(13) & "Description: " & Err.Description & Chr(13) & "Check numb
Case Is = 91
MsgBox "Error Number: " & Err.Number & Chr(13) & "Check connection to server" 
Case Else
MsgBox "Error Number: " & Err.Number & Chr(13) & Err.Description, vbOKOnly, "Error" 
End Select

QueryRecordset Method (MessageRecordset Object)

Executes the message query based on the fields and criteria specified.

Syntax

object.QueryRecordset

Parameters

None

Returns

Boolean. Success/Failure.

Example

Dim MyRecordset As iHistorian_SDK.MessageRecordset
Dim I As Integer
Dim J As Integer
Dim lEndTime&, lStartTime&, lNumMessages& Dim lNumSeconds&, lNumMessagesPerSecond&
If CheckConnection = True Then
' Get A New Recordset
Set MyRecordset = ConnectedServer.Messages.NewRecordset
' Return Timestamp, Message Number, and Message String Fields In Query
With MyRecordset.Fields
.TimeStamp = True
.MessageNumber = True
.MessageString = True
End With
' Query messages for given start and end time
With MyRecordset.Criteria
.Clear
.StartTime = dtMessageStart.Value
.EndTime = dtMessageEnd.Value
If txtMessageContains.Text <> "" Then
.MessageString = txtMessageContains.Text
End If
End With
VB.Screen.MousePointer = vbHourglass ' wait wait wait
' Run Query lStartTime = Timer
If Not MyRecordset.QueryRecordset Then lEndTime = Timer
MsgBox "Query Failed..." & Chr(13) & MyRecordset.LastError
VB.Screen.MousePointer = vbDefault
Exit Sub
End If
lEndTime = Timer
' reset output list lstRetrievedMessages.Clear
' display all messages lNumMessages = 0
For J = 1 To MyRecordset.Item.Count
lstRetrievedMessages.AddItem Format(MyRecordset.Item(J).TimeStamp, "MM/dd/yyyy hh:mm:ss") & _
vbTab & MyRecordset.Item(J).MessageString lNumMessages = lNumMessages + 1
Next J
' calculate performance statistics lNumSeconds = lEndTime - lStartTime lNumMessagesPerSecond = lNumMessages If lNumSeconds > 0 Then
lNumMessagesPerSecond = lNumMessages / lNumSeconds
End If
VB.Screen.MousePointer = vbDefault
txtReadTime.Caption = lNumMessages & " returned in " & lEndTime - lStartTime & " seconds (" & lNumMessagesP 
End If

QueryRecordset Method (TagRecordset Object)

Executes the tag query based on the fields and criteria specified.

Syntax

object.QueryRecordset

Parameters

None.

Returns

Boolean. Returns whether the QueryRecordset operation succeeded.

Example

Dim MyTags As iHistorian_SDK.Tags
Dim MyRecordset As iHistorian_SDK.TagRecordset
Dim lStartTime&, lEndTime&, lNumSeconds&, lNumTagsPerSecond& Dim I As Integer
On Error GoTo errc lbTags.Clear
' If we are connected to server
If CheckConnection = True Then
' Query all the tagnames
Set MyTags = ConnectedServer.Tags
Set MyRecordset = MyTags.NewRecordset 
MyRecordset.Criteria.Tagname = txtTagMask.Text 
If txtDescriptionMask.Text <> "" Then
MyRecordset.Criteria.Description = txtDescriptionMask.Text
End If MyRecordset.Fields.Clear 
MyRecordset.Fields.Tagname = True 
VB.Screen.MousePointer = vbHourglass  
lStartTime = Timer
If Not MyRecordset.QueryRecordset Then Err.Raise 1, , "Tag Query Failed: " + MyRecordset.LastError 
lEndTime = Timer
For I = 1 To MyRecordset.Item.Count
lbTags.AddItem MyRecordset.Item(I).Tagname
Next I
VB.Screen.MousePointer = vbDefault
' Calculate performance statistics 
lNumSeconds = lEndTime - lStartTime 
lNumTagsPerSecond = MyRecordset.Item.Count 
If lNumSeconds > 0 Then
lNumTagsPerSecond = MyRecordset.Item.Count / lNumSeconds
End If
lblAddTime.Caption = MyRecordset.Item.Count & " tags returned in " & lEndTime - lStartTime & " seconds (" & lN MyRecordset.ClearRecordset
Set MyRecordset = Nothing
Else
MsgBox "Not connected" 
End If
Exit Sub errc:
MsgBox "TestBrowseTags >> " + Err.Description                                                

QueryTagAlias Method (TagRecordset Object )

This function returns a list of tag aliases for the tag name passed in. Pass in the current name of the tag and this function will return if there are any previous names for the tag due to tag rename.

Syntax object.QueryTagAlias(TagNames(), NumberofTags, TagAlias(), NoOfAliases)

Table 70. Parameters
Name Data Type Description
TagNames() String Name of the tags to return information on.
NumberofTags Long Total count of tag names passed in. This must be equal to 1.
TagAlias() String List of 0 or more tag aliases.
NoOfAliases Integer The number of tag aliases returned.

Returns

Boolean. TRUE if successful. FALSE otherwise.

QueryUserDefinedType Method (UserDefinedType Object)

Queries the Historian Server and loads all the User Defined Types that match the query mask.

Syntax

object.QueryUserDefinedType(Server, QueryMask)
Table 71. Parameters
Name Data Type Description
Server Server The reference to the Historian Server object.
QueryMask String A mask string that can be used to search for UserDefinedType on the Historian Server. The string can include wild-card characters like "*" and "?".

Returns

Boolean. Indicates whether the query was successful.

R

Reload Method (Collector Object)

Causes a re-calculation of tags to occur for a specified tag period. You can reload all tags for the time period or specify specific tags that you want to reload.
Note: This method is only supported by ServerToServer and Calculation collectors.

Syntax

object.Reload(StartTime, EndTime, [Tags])

Table 72. Parameters
Name Data Type Description
StartTime Date The time that you want the reload to begin at (read-only).
EndTime Date The time that you want the reload to end at (read-only).
Tags Variant The specified tag names either in an array of tag names, or in a tagRecordset object for tags that you want to reload (optional).

Returns

Boolean. Returns whether or not the Reload operation succeeded.

Remove Method (TagDependencies Object)

Removes a Tag dependency from the current calculation.
CAUTION:
If no Tagname is specified, all the Tag dependencies will be removed.

Syntax

object.Remove([Tagname])

Table 73. Parameters
Name Data Type Description
Tagname Variant Name of the tag to remove (optional), default = "").

Returns

Boolean. Whether the Remove operation succeeded.

RemoveServer Method (ServerManager Object)

Removes the specified server from the list of registered servers on the client.

Syntax

object.RemoveServer(ServerName)

Table 74. Parameters
Name Data Type Description
ServerName String Computer name of the Historian server (read/write).

Returns

Boolean. Whether the server was successfully removed from the list.

Rename Method (Tags Object)

Use this method to rename tag names. You can rename a tag permanently by passing an additional parameter as TRUE or FALSE.
Note: This method is called within the WriteRecordset method. For more information, refer to the Sample Code section.

Syntax

object.Rename(newTagName, (Optional) RenamePermanent)

Table 75. Parameters
Name Data Type Description
newTagName String Name of the new tag to rename.
RenamePermanent (Optional) Boolean Pass TRUE to permanently rename a tag.

Returns

Boolean. Returns whether or not the Rename operation succeeded.

Restore Alarms Method

Restores the alarms.

Syntax

object.RestoreAlarms

Table 76. Parameters
Name Data Type Description
RestoreFileName String The name of the file to be restored to the absolute path.

Returns

Boolean. Returns TRUE if the alarms have been restored.

Example

Dim Status As ihStatus
Dim ReturnStatus As Boolean Status = ihSTATUS_FAILED ReturnStatus = False
On Error GoTo errc
Status = ihRestoreAlarms(MyServer.Handle, RestoreFileName, 0)
If Status <> ihSTATUS_OK Then err.Raise 1, , "Error in restoring the alarms [" + ErrorDescription(Status) + "," ReturnStatus = True
RestoreAlarms = ReturnStatus errc:
zLastError = "Purge Alarms>> " + err.Description
RestoreAlarms = ReturnStatus
End Function

S

SaveSet Method (EnumeratedSets Object)

Saves the Enumerated Set that has been passed into the Historian Server.

Syntax

object.SaveSet(SetTosave)

Table 77. Parameters
Name Data Type Description
SetToSave EnumeratedSet The set that is passed in to be saved.

Returns

None.

SaveSet Method (UserDefinedType Object)

Saves the UserDefinedType that has been passed into the Historian Server.

Syntax

object.SaveSet(Handle, MySet, Datatype)
Table 78. Parameters
Name Data Type Description
Handle Long Server handle.
MySet UserDefinedType The UserDefinedType to be saved.
DataType ihDatatype The data type of the UserDefinedType

Returns

Boolean. Returns TRUE if the UserDefinedType is saved.

SaveToCollectorProperty Method (OPCFilters Object)

Saves the current filter configuration in the Collector object.

Syntax

object.SaveToCollectorProperty(Collector)

Table 79. Parameters
Name Data Type Description
Collector Variant The Collector object in which to save the filtering information.

Returns

Boolean true on success, false otherwise.

SaveUserCalcLibrary Method (Server Object)

Saves the given user calculation library to the Server object. This will update the set of user-created functions and subroutines available for calculations on this Server. The new calculation library must be passed in as an array of UserCalcFunctions.

This list of functions will replace any existing user calculation library on the Server. To save an empty calculation library, pass a non-array value such as Empty.

Syntax

object.SaveUserCalcLibrary(UserCalcFunctions)

Table 80. Parameters
Name Data Type Description
UserCalcFunctions Variant Array of UserCalcFunction objects.

Returns

Boolean. Returns whether or not the calculation library was saved successfully.

Example

Dim MyServer As New iHistorian_SDK.Server
Dim MyUserCalcFunctions() As iHistorian_SDK.UserCalcFunction
Dim MyNewFunction As New iHistorian_SDK.UserCalcFunction
' Connect to the local server
If Not MyServer.Connect("", "", "") Then
err.Raise 1, , "Failed to connect to the local server" End If
' Load the calculation library
MyServer.LoadUserCalcLibrary MyUserCalcFunctions
' Create a new function
MyNewFunction.Name = "Sum"
MyNewFunction.Definition = "Function Sum(a, b)" & vbCrLf & "Sum = a + b" & vbCrLf & "End Function"
' Add it to the loaded library
If IsArray(MyUserCalcFunctions) Then
ReDim Preserve MyUserCalcFunctions(UBound(MyUserCalcFunctions) + 1) Else
ReDim MyUserCalcFunctions(0) End If
Set MyUserCalcFunctions(UBound(MyUserCalcFunctions)) = MyNewFunction
' Save the changes to the calculation library
If Not MyServer.SaveUserCalcLibrary(MyUserCalcFunctions) Then err.Raise 1, , "Failed to save the calculation library"
End If

SelectAll Method (TagRecordset Object)

Selects each tag in the current TagRecordset. Use in conjunction with the Master tag to perform bulk update operations on the selected tags of the TagRecordset.

Syntax

object.SelectAll

Parameters

None.

Returns

None.

Example

' Query for tags
Set MyRecordset = MyServer.Tags.NewRecordset
MyRecordset.QueryRecordset
' Select all tags
MyRecordset.SelectAll
' Update the HiEngineeringUnits for all tags
MyRecordset.Master.HiEngineeringUnits = 300
' Commit changes
MyRecordset.WriteRecordset

SetFields Method (DataRecordset Object)

Sets the DataValue fields to return from the Historian server when a DataRecordset query is executed.

Syntax

object.SetFields(Params)

Table 81. Parameters
Name Data Type Description
Params Variant Array of DataValue fields to set.

Returns

Boolean. Success / Failure

SetFields Method (MessageRecordset Object)

Set a list of desired Fields to be returned for the messages.

Syntax

object.SetFields(Params)

Table 82. Parameters
Name Data Type Description
Params Variant Array of Message fields

Returns

Boolean. Success / Failure

SetFields Method (TagRecordset Object)

Sets the Fields to retrieve in the TagRecordSet.

Syntax

object.SetFields(Params)

Table 83. Parameters
Name Data Type Description
Params Variant The array of field values to set.

Returns

Boolean. Success / failure.

SetNames Method (EnumeratedSets Object)

This function returns an array of names of all the loaded Enumerated Sets within the Historian server object.

Syntax

object.SetNames()

Parameters

None.

Returns

String Array.

ShowErrorListDialog Method (Server Object)

Displays a dialog box that details errors messages accumulated during the current session of the Server object. Each message is timestamped at the time the error generated and includes an error message translated into the locale of the client when possible.

Syntax

object.ShowErrorListDialog

Parameters

None.

Returns

None

Example

ErrorTrap:
' On error display the error list dialog
If MyServer.ErrorList.count > 0 Then
MyServer.ShowErrorListDialog
End If

SubscribeAlerts Method (Messages Object)

Subscribes to alert messages reported by the Historian Server. As the server receives alerts, the Historian server publishes messages to any client signed up for alerts.
  • To subscribe to messages of specific types, supply a topic.
  • To subscribe to all topics, do not supply a topic. Subscribe all is the default.
  • Subscribe to individual topics by making multiple calls to the SubscribeAlerts with different topics.
  • To subscribe to all topics, call SubscribeAlerts and pass 0.
  • To unsubscribe to a specific topic or all topics, call SubscribeAlerts and supply the Subscribe parameter set to False.

The Alert_Received event of the Messages object reports alert messages to the client asynchronously.

Syntax

object.SubscribeAlerts(Topic, Subscribe)

Table 84. Parameters
Name Data Type Description
Topic ihMessageTopic Topics of Alerts to subscribe to (optional, default = All).
Subscribe Boolean Flag to subscribe / unsubscribe to alerts (optional, default = True). Set to False to unsubscribe.

Returns

Boolean. Returns whether or not the SubscribeAlerts operation succeeded.

SubscribeChanges Method (Tags Object)

Subscribes to changes in tag configuration. The Historian server publishes messages to any client signed up for tag configuration changes as modifications are saved to the tag database.

The system reports tag configuration messages asynchronously to the client through the ChangeReceived event of the Tags Object.

To unsubscribe to a specific tag, or all tags, call SubscribeChanges and supply the Subscribe parameter set to False.

Syntax

object.SubscribeChanges(Tagname, Subscribe)

Table 85. Parameters
Name Data Type Description
Tagname String Name of tag to Subscribe for configuration changes (read-only).
Subscribe Boolean Flag to Subscribe/Unsubscribe to tag changes (default = True).

Returns

Boolean. Returns whether or not the SubscribeChanges operation succeeded.

SubscribeData Method (Data Object)

Subscribes to changes in the current value of a specific tag. The Historian server publishes messages as new values are received to any client signed up for current value changes. To qualify as a new current value, any new data point must have a newer timestamp than the previously established current value. Values received by the Historian server have passed a deadband check by the collector reporting the data. Since new current values have not been compressed, however, values reported as current may not exactly match those that reach the archive.

You can use the MinimumElapsedTime, in milliseconds, to throttle the rate at which current values are reported to a specific server connection. If the same tag is subscribed twice, the last supplied MinimumElapsedTime is used. If MinimumElapsedTime is not supplied, or is zero, the system reports all current values.

The system reports current values asynchronously to the client through the DataReceived event of the Data object.

To unsubscribe to a specific tag, or all tags, call SubscribeData and set the Subscribe parameter to False.

Syntax

object.SubscribeData(Tagname, MinimumElapsedTime, Subscribe)

Table 86. Parameters
Name Data Type Description
Tagname String Name of the tag to Subscribe for current values (read-only).
MinimumElapsedTime MinimumElapsedTime Minimum elapsed time (ms) between values (read-only).
Subscribe Boolean Flag to subscribe/unsubscribe to current values (read-only).

Returns

Boolean. Operation success / fail

SubscribeMessages Method (Messages Object)

Subscribes to messages reported by the Historian Server. The Historian Server publishes messages as messages are received to any client signed up for messages. As an option, you may supply a topic to subscribe only to messages of specific types. If you do not supply a topic, all topics are subscribed. You can subscribe to individual topics by making multiple calls to the SubscribeMessages method with different topics, or pass 0 to subscribe to all topics.

The system reports alert messages asynchronously to the client through the Message_Received event of the Messages object.

To unsubscribe to a specific topic, or all topics, call SubscribeMessages and set the Subscribe parameter to False.

Syntax

object.SubscribeMessages(Topic, Subscribe)

Table 87. Parameters
Name Data Type Description
Topic ihMessageTopic Topics of messages to Subscribe to (optional, default = True).
Subscribe Boolean Flag to un/subscribe to a specific topic (optional, default = True).

Returns

Boolean. Operation success / fail

Substitutions Method (MessageFields Object)

Determines whether the Substitutions should be returned in the MessageRecordset query.

Syntax

object.Substitutions

Parameters

None

Returns

None

Example

Dim maMyMessages As iHistorian_SDK.MessageRecordset 
Set MyMessages = GetServer.Messages.NewRecordset With MyMessages.Fields
.Topic = True
.TimeStamp = True
.MessageString = True
.Substitutions = True
End With 

T

TestCalculation Method (Tag Object)

Runs the calculation currently stored in the Calculation property. This calculation will be run with a current time of "Now". The results of the calculation will be stored in the Value and DataQuality parameters.

If an error occurs during the test, a description of the error will be stored in the ErrorMessage parameter.

Syntax

object.TestCalculation(Value, DataQuality, ErrorMessage)

Table 88. Parameters
Name Data Type Description
Value Variant Value of the calculation result.
DataQuality String Quality of the calculation result.
ErrorMessage String Description of any error that occurred during the test.

Returns

Boolean. Operation success / fail

TranslateMessage Method (Server Object)

Returns a translated message or prompt based on the current locale and the MessageNumber specified. If no translation is available for the current locale, the method uses the default message.

To insert context specific information into the generic message string, use substitutions. For example, the generic message string:
Connection To Server:[1] 
Failed With Error Number: [2]
requires two substitutions, the first being the server, and the second being the error number.
The substituted message then reads:
Connection To Server: USGB014 
Failed With Error Number: 65535. 

Syntax

object.TranslateMessage(MessageNumber, DefaultMessage, Substitutions)
Table 89. Parameters
Name Data Type Description
MessageNumber Long Message or prompt number to translate (read-only).
DefaultMessage String Default message to translate (optional, read-only).
Substitutions ParamArray Ordered substitutions into message (optional, read-only).

Returns

String. The translated message text.

Example

Dim MyServer As New iHistorian_SDK.Server
Dim MyPrompt As String
' Connect to the default server
If Not MyServer.Connect Then
err.Raise 1, , "Failed to authenticate on server " + MyServer.ServerName
End If
' Translate the prompt from the connected server
MyPrompt = MyServer.TranslateMessage(549, "User: [1]", MyServer.Username)
' Prompt is translated to "User: Fred"

Method Reference U-Z

U

UnSelectAll Method (TagRecordset Object)

Applies to:

Clears all selections in the current TagRecordset. See the SelectAll method and the Master Tag Property.

Syntax

object.UnSelectAll

Parameters

None

Returns

None

Example

' Clear any current selection MyRecordset.UnSelectAll

UserCalcFunctionsFromString Method (Server Object)

Applies to:

Converts the given string to an array of user calculation functions. The string is assumed to have been generated from a call to UserCalcFunctionsToString.

If no functions exist in the string, UserCalcFunctions will be set to Empty.

Syntax

object.UserCalcFunctionsFromString(FuncStr, UserCalcFunctions)

Table 90. Parameters
Name Data Type Description
FuncStr String String to convert.
UserCalcFunctions Variant Resulting array of UserCalcFunction objects.

Returns

Boolean. Conversion successful / failed.

UserCalcFunctionsToString Method

Applies to:

Converts the given array of user calculation functions to a string.

To convert an empty set of functions, pass a non-array value such as Empty.

Syntax

object.UserCalcFunctionsToString(UserCalcFunctions, FuncStr)

Table 91. Parameters
Name Data Type Description
UserCalcFunctions Variant Array of UserCalcFunction objects.
FuncStr String String resulting from conversion
Returns

Boolean. Conversion successful / failed.

W

WriteArray Method (DataRecordset Object)

Applies to:

Attempt to write a set of Data to the Historian archiver.
Note: This function is not fully implemented yet and will always return false current DataRecordset before it imports the specified file.

Syntax

object.WriteArray(DataArray)

Table 92. Parameters
Name Data Type Description
DataArray Variant Data Array to be written to the Historian archiver.

Returns

Boolean. Write succeeded / failed.

WriteRecordset Method (DataRecordset Object)

Applies to:

Saves changes made to the DataRecordset object to the Historian server. If DataValues have not changed, the method does not write DataValues to the server.

Syntax

object.WriteRecordset

Parameters

None

Returns

Boolean. Write succeeded / failed.

WriteRecordset Method (MessageRecordset Object)

Applies to:

Saves changes made to the MessageRecordset object to the Historian server. Only new messages are written to the server.

Syntax

object.WriteRecordset

Parameters

None

Returns

Boolean. Write succeeded / failed.

WriteRecordset Method (TagRecordset Object)

Applies to:

Saves changes made to the TagRecordset Object to the Historian server. If tags have not changed, they are not re-written to the server.

Syntax

object.WriteRecordset([UseMasterTag])

Table 93. Parameters
Name Data Type Description
UseMasterTag Boolean Whether to apply Master tag changes to all tags (read-only optional).

Returns

Boolean. Write succeeded / failed.

X

XML Method (DataRecordset Object)

Applies to:

Returns an XML document fragment representing the DataValues and DataFields contained in the current DataRecordset.

Syntax

object.XML([XMLHeader], [StartIndex], [EndIndex])

Table 94. Parameters
Name Data Type Description
XMLHeader String XML to include before the DataRecordset XML (optional).
StartIndex Long Index of first tag to include in XML (optional).
EndIndex Long Index of last tag to include in XML (optional).

Returns

String. An XML document fragment string.

Example

Dim Recordset As DataRecordset
' Get A New Data Recordset
Set Recordset = MyServer.Data.NewRecordset
' Fill In Criteria, Get One Tag For Yesterday
With Recordset.Criteria
  .Tagmask = "MyNode.OneTag.F_CV"
  .StartTime = DateAdd("d", -1, Now)
  .EndTime = Now
End With
' Fill In Fields, Timestamp and Value
With Recordset.Fields
  .TimeStamp = True
  .Value = True End With 
Recordset.QueryRecordset
' Print XML to Debug Window
Debug.Print Recordset.XML

XML Method (MessageRecordset Object)

Applies to:

Returns an XML document fragment representing the Messages and MessageFields contained in the current MessageRecordset.

Syntax

object.XML([XMLHeader], [StartIndex], [EndIndex])

Table 95. Parameters
Name Data Type Description
XMLHeader String XML to include before message XML (read-only, optional).
StartIndex Long Index of first message to Include in XML (read-only, optional).
EndIndex Long Index of last message to include in XML (read-only, optional).

Returns

String. An XML document fragment string.

XML Method (TagRecordset Object)

Applies to:

Returns an XML document fragment representing the Tags and TagFields contained in the current TagRecordset.

Syntax

object.XML([XMLHeader], [StartIndex], [EndIndex])

Table 96. Parameters
Name Data Type Description
XMLHeader String XML to include before the TagRecordset XML (read-only, optional).
StartIndex Long Index of first tag to Include in XML (read-only, optional).
EndIndex Long Index of last tag to include in XML (read-only, optional).

Example

Dim Recordset As TagRecordset
' Get a new tag recordset
Set Recordset = MyServer.Tags.NewRecordset
' Fill in criteria, aet all tags
With Recordset.Criteria
.Tagname = "*" 
End With
' Fill in fields, get tagname and description
With Recordset.Fields
  .Tagname = True
  .Description = True 
  End With 
Recordset.QueryRecordset
' Print XML to debug window
Debug.Print Recordset.XML