Geo SCADA Expert

It is possible to enter history to any point in your database. This can be done by using the "LoadDataValue" method of the Historic aggregate.

This method is of the form:

LoadDataValue Reason(long), Quality(Long), Time Stamp(Time), Value(Variant)


Some example code is shown below.

Set objServer = New ScxV6Server
objServer.Connect "system name", "username", "pwd"
Set obj = objServer.FindObject("test")

Set His = obj.Aggregate("Historic")
His.Interface.LoadDataValue 1, 192, "27 Nov 2003 17:23:23", "1"

Set obj = Nothing
objServer.Disconnect


In this example 192 corresponds to a "Good" quality. ClearSCADA uses OPC standard quality definitions.

The parameter Reason determines the Reason For Logging field available in the historic database. The possible values for this field include:

  • 0 - Current Data
  • 1 - Value Change
  • 2 - State Change
  • 3 - Timed Report
  • 4 - End of Period
  • 5 - End of Period Reset
  • 6 - Override
  • 7 - Release Override
  • 8 - Modified/Inserted

A "LoadDataFile" method is available that takes in a file name (String). This method allows entire files of information to be added into history for points in the database.

Each line of the file is required to be in the following format:

[YYYY,MM,DD,HH,MM,SS,Value,Quality]


A "LoadDataValues" method is also available that allows arrays of times, values and qualities to be added to the historian. See the database schema CHistory class for more information (http://your-server-name/schema).

Note that where possible, historic entries should be added into the database in time series order (oldest first) to reduce the load on the server as it sorts the data into time order.
Note also that all times entered through this automation interface mechanism are in UTC format.
Internal Points
For internal points you can also use the mechanisms described in Adding Historic Data to Internal Points
  1. Nov 25, 2011

    Peter Sysak says:

    SQL query to export data in correct format for LoadDataFile SELECT EXTRACT( YEA...

    SQL query to export data in correct format for LoadDataFile

    SELECT EXTRACT( YEAR FROM "RecordTime" ) AS "Year", EXTRACT( MONTH FROM "RecordTime" ) AS "Month", EXTRACT( DAY FROM "RecordTime" ) AS "Day", EXTRACT( HOUR FROM "RecordTime" ) AS "Hour", EXTRACT( MINUTE FROM "RecordTime" ) AS "Minute", EXTRACT( SECOND FROM "RecordTime" ) AS "second", "FormattedValue", "Quality"
    FROM CDBHISTORIC
    WHERE "Id" = xxxx