ClearSCADA Automation Interface Training Rev 3.0 2007 PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

ClearSCADA Automation

Interface
Training Notes
Revision 3.0
30th May, 2007

ClearSCADA Automation Interface Training Notes

Issue Details
Issue
1.0
2.0
2.1
3.0

Date
5th December, 2004
27th June, 2005
6th August, 2005
30th May, 2007

Author
G. Russ
G. Russ
G. Russ
R. Rogers

Comments
Initial Version
Updated for 2005 Edition
Updated for ClearSCADA 2005 Edition
Updated for ClearSCADA 2007 Edition

References
y

ClearSCADA Automation Interface Reference Manual

Required Hardware
y

IBM PC Pentium 4 1Ghz, 256MB RAM

Required Software
y
y
y

Windows 2000 SP2 (or higher), Windows XP SP2 (or higher) or Windows
2003 Server
ClearSCADA 2007 Edition
Microsoft Word, Excel, or Access with Visual Basic for Applications

Revision
3.0

ClearSCADA Automation Interface Training Notes

Table of Contents
Issue Details .................................................................................................................. i
References .................................................................................................................... i
Required Hardware ....................................................................................................... i
Required Software......................................................................................................... i
Table of Contents ..........................................................................................................ii
List of Figures ............................................................................................................... iii
List of Tables ................................................................................................................ iii
1
Object Oriented Concepts.................................................................................. 1
1.1
Properties....................................................................................................... 2
1.2
Methods ......................................................................................................... 3
1.3
Derived Classes and Inheritance ................................................................... 3
2
Introduction to the Automation Interface ............................................................ 5
2.1
What is the Automation Interface ................................................................... 5
2.2
Supported Programming Languages.............................................................. 6
2.3
Required ClearSCADA Components ............................................................. 6
2.4
Adding the Automation Interface to the VBA Project ...................................... 6
2.5
A Simple Example .......................................................................................... 7
2.6
The VB Object Browser.................................................................................. 8
2.7
Automation Interface Classes ........................................................................ 9
3
Connecting to an ClearSCADA System ........................................................... 11
3.1
Security ........................................................................................................ 11
4
Finding Objects in the ClearSCADA Database ................................................ 13
4.1
ScxV6Server.FindObject .............................................................................. 13
4.2
ScxV6Server.LookupObject ......................................................................... 13
4.3
ScxV6Object.Find......................................................................................... 14
5
Reading and Modifying ClearSCADA Object Properties.................................. 15
5.1
ScxV6Object.Property .................................................................................. 15
5.2
ScxV6Object.Class.Name ............................................................................ 16
6
Creating, Renaming and Deleting ClearSCADA Objects ................................. 18
6.1
ScxV6Server.CreateObject and ScxV6Object.Create .................................. 18
6.2
ScxV6Object.Rename .................................................................................. 19
6.3
ScxV6Server.DeleteObject........................................................................... 20
7
Collections ....................................................................................................... 21
7.1
The ScxV6Objects Object ............................................................................ 21
8
Calling Methods on ClearSCADA Objects ....................................................... 23
9
Aggregates ...................................................................................................... 24
9.1
ScxV6Object.Aggregate ............................................................................... 24
9.2
ScxV6Aggregate.Enable .............................................................................. 24
9.3
ScxV6Aggregate.Property and ScxV6Aggregate.Interface .......................... 25
9.4
CHistory.LoadDataValue and CHistory.LoadDataFile .................................. 25
10
Templates and Instances................................................................................. 27
10.1 CTemplateInstance.TemplateId ................................................................... 27
10.2 CScxV6Object.PropertyOverride.................................................................. 27
10.3 Reading and Writing Properties in Instances ............................................... 28
Appendix A
VBScript Example............................................................................... 29
Appendix B
Inserting Historic Data ........................................................................ 30
B.1 PresetTimestamp and PresetQuality............................................................ 30
B.2 CHistory.LoadDataValue.............................................................................. 30

Revision
3.0

ii

ClearSCADA Automation Interface Training Notes

B.3

CHistory.LoadDataFile ................................................................................. 31

List of Figures
Figure 1-1 - Accessing the ClearSCADA Database Schema using Internet Explorer.1
Figure 2-1 - ClearSCADA DatabaseApplication Interfaces .....................................5
Figure 2-2 - ClearSCADA Client Configuration...........................................................6
Figure 2-3 - SCX V6 Automation Interface in VBA Project References ......................7
Figure 2-4 - Automation Interface in the Object Browser............................................8
Figure 2-5 - Properties of ScxV6Object ......................................................................9
Figure 3-1 - Unknown System Name........................................................................11
Figure 3-2 - System Offline.......................................................................................11
Figure 3-3 - Permission Denied ................................................................................12
Figure 3-4 - Insuficient Privideges ............................................................................12
Figure 4-1 - Accessing Property of a Nothing Object................................................13
Figure 5-1 - Attempt to Write to a Read-Only Property.............................................15
Figure 5-2 - Attempt to Read or Write a Non-Existent Property................................16
Figure 6-1 - Non-Existent Class Name .....................................................................18
Figure 6-2 - Non-Creatable Class Name ..................................................................18
Figure 6-3 - Create in Non-Existent Group ...............................................................19
Figure 6-4 - Create in a Template Instance ..............................................................19
Figure 6-5 - Invalid Object Name..............................................................................19
Figure 6-6 - Deleting an Object Referenced by other Objects ..................................20
Figure 7-1 - Calling the List Method on an Object that is not a Group ......................21
Figure 7-2 - Invalid Item Number ..............................................................................21
Figure 8-1 - Invalid Argument to ClearSCADA Method ............................................23
Figure 9-1 - Named Aggregate does not Exist..........................................................24
Figure 9-2 - Using ViewX to Enable an Aggregate ...................................................24
Figure 9-3 - Accessing Properties or Methods of a Disabled Aggregate ..................25
Figure 10-1 - PropertyOverride Called on an Object that is not a Template .............27
Figure 10-2 - Property Override Called with an Object not in the Template .............28
Figure 10-3 - Property Override Called on a Non-Existent Field...............................28
Figure 10-4 - Attempt to Write to a Property in an Instance that is not Overridden...28

List of Tables
Table 9-1 - OPC Quality Values ...............................................................................26

Revision
3.0

iii

ClearSCADA Automation Interface Training Notes

1 Object Oriented Concepts


The ClearSCADA database is object-oriented It is a collection of objects
(outstations and points for example). Each object has a number of
y
y

Configuration Fields Define the behaviour of the object. For example, all
objects have a Name property which stores the name of the object in the
ClearSCADA database.
Data Fields Define the state of the object. For example, all Points have
a CurrentValue field which stores the current value of the point.
NOTE: Configuration and Data Fields and collectively known as
properties.

Methods Perform actions on objects. For example, all objects which


generate alarms have a Accept method which accepts the current active
alarm on the object.

In ClearSCADA, the available classes are listed in the Schema which can be
accessed using Internet Explorer by browsing to http://<server>/schema. If the
ClearSCADA server is running on the local machine, http://localhost/schema will
access the schema of the local server.
NOTE: If you are running a web server such as Apache, IIS etc on the same
computer as the ClearSCADA server, the ClearSCADA server may not be able to
run its web server, and the schema will not be available.

Figure 1-1 - Accessing the ClearSCADA Database Schema using Internet Explorer

Exercise
1.
2.
3.

List the ClearSCADA classes by browsing to http://localhost/schema


Click on the Internal folder in the schema
Find the Internal Analog Point class

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

When a user creates an object in the ClearSCADA database, they are creating an
instance of one of the classes listed in the schema. For example, an Internal Analog
Point is an instance of the CPointAlgManual class and therefore has all the
properties and methods listed in the schema for the CPointAlgManual class.
Exercise
1.
2.
3.
4.

Follow the CPointAlgManual link


Identify a Configuration Field of CPointAlgManual
Identify a Data Field of CPointAlgManual
Identify a Method of CPointAlgManual

1.1 Properties
Configuration fields are set by the user and define the configuration of the individual
instance of the class (object). The configuration fields are displayed in the object
properties in ViewX
Exercise
1.
2.
3.
4.
5.
6.

Create a new Internal Analog Point using ViewX


Open the Properties dialog on the new point
Compare the Handress property on the Manual tab in ViewX to the
HandressAllowed configuration field in the schema. Note that the Display Name
and Description in the schema match the label and tool-tip in ViewX.
Compare the Confirm property on the Manual tab in ViewX to the
HandressConfirm configuration field in the schema.
Note the Type is Unsigned Byte (a number), but it is displayed in ViewX as a
drop-down list of text values.
Examine the Notes column in the schema It shows that the property is an
Enumeration and lists the mapping of numerical values to text values displayed
in the drop down.

1.1.1 Read-Only Configuration Fields


Some configuration fields are listed as Read Only in the Notes column of the
schema. These fields are set by the ClearSCADA server based on the value of
another configuration field. For example, HighHighColour is based on
HighHighColourId.
Exercise
1.

Find a class with a Read-Only configuration field in the schema

1.1.2 Data Fields


Data fields are modified in real time by the ClearSCADA Server. These represent the
current value and state of the object. The most relevant data fields of an object are
displayed in the View dialog of the object in ViewX
Exercise
1.
2.

Right-Click on the Internal Analog Point in ViewX and select View


Locate the Current Value property

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

1.2 Methods
Methods are built in functions that perform actions on an object. For example Logic
Program classes (such as CLogicSTProgram) define a number of Execute methods.
These methods allow the program to be executed with a different number of
parameters. Methods are covered in more detail in Section 8.
NOTE: The Description column in the schema for Execute0, Execute1, to Execute12
has ** DEPRECATED Use Execute Method instead **. These methods have been
replaced by a new method Execute. Deprecated methods are still implemented in
ClearSCADA for backward compatibility, but should not be used in when creating
new ClearSCADA projects.

1.3 Derived Classes and Inheritance


A key concept of the Object Oriented paradigm is that of the Derived Class. Consider
a class (Class A) which has a number of defined properties and methods. Consider a
seconds class (Class B) which requires the same functionality that is available to
Class A by its properties and methods, but also requires additional properties and
methods that are not defined on Class A. There are two options
1.
2.

Redefine all of the properties and methods defined on Class A on Class B and
then defined the additional properties and methods on Class B
Inherit the properties and methods defined on Class A, and only define the
additional properties and methods on Class B

In the second case


y
y

Class B is Derived From (or is a sub-class of) Class A


Class A is a Base Class of class B

These two expressions are equivalent.


Inheritance can be multi-levelled. Extending the above example, Class B can be
used as the base class for a third class (Class C). Class C would inherit the
properties and methods defined on both Class B and Class A.
In ClearSCADA:
y
y
y
y

A class may have a maximum of one base class


A class may have multiple derived classes
All properties and methods defined on the base class are available on the
derived class
There is no limit to the depth (number of levels) of inheritance

Exercise
1.
2.
3.
4.
5.
6.

Find the CPointAlgManual class in the schema


Identify the base class of the CPointAlgManual class
Follow the link to the base class
Find CPointAlgManual in the list of Sub Classes
Open the properties dialog on the new point in ViewX
Find some properties that are defined in the base class

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

NOTE: Typically, base classes cannot be instantiated (i.e. no object of the class can
be created). There are some exceptions, for example CGroup is the base class for
CTemplate and CTemplateInstance All of these classes can be instantiated. In
ClearSCADA, CDBObject is the base class for nearly every class in the database.
Exercise
1.

Find a class in the schema that is not derived from CDBObject

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

2 Introduction to the Automation Interface


2.1 What is the Automation Interface
The Automation Interface is an application programming interface (API) that allows
the ClearSCADA database to be accessed using a programming language such as
Visual Basic (VB).
Like ViewX (and OPC/ODBC), the automation interface connects to ClearSCADA
servers via the ClearSCADA Data Access Component. Figure 2-1 illustrates how an
application accesses the ClearSCADA database using the automation interface.
Main Server
Computer

Standby Server
Computer

SCX6 Database

SCX6 Database

SCX6 Client
Interface

SCX6
Automation
Interface

Application

Client Computer

Figure 2-1 - ClearSCADA DatabaseApplication Interfaces

Using the automation interface, the programmer can:


y
y
y

Read and modify properties (that are not read-only) of objects in the
ClearSCADA database
Create instances of ClearSCADA classes in the ClearSCADA database
Call methods on objects in the ClearSCADA database

Using the automation interface, the programmer cannot:


y
y

Modify the contents of Mimics


Modify the contents of Logic Programs

The automation interface is typically used to


y
y
y
y

Perform bulk modifications to the ClearSCADA database that are either


too repetitive or prone to human error to do manually in ViewX
Allow an external application to modify the ClearSCADA database (i.e.
configure a ClearSCADA database from an MS Access database)
Allow an external application to modify/control the values of I/O points in
the ClearSCADA database
Allow an external application to add historical data to the ClearSCADA
database

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

The client is configured using the Configure ClearSCADA Connections applet. The
client must be configured with a Type of ClearSCADA Server to allow the automation
interface to connect to the associated server(s) (see Figure 2-2).

Figure 2-2 - ClearSCADA Client Configuration

The ClearSCADA Client handles all connections to redundant servers transparently.


As such, a programmer using the automation interface does not need to write code
based upon if the program will be connecting to a lone server or a pair (or trio) of
standby servers. The code is written as if connecting to a single server.

2.2 Supported Programming Languages


Visual Basic (VB) and Visual Basic for Applications (VBA) are the simplest
programming language to write code which uses the Automation Interface. VBA is
supplied with Microsoft Office and is therefore available to users of Access, Word
and Excel without the necessity of buying additional programming software.
NOTE: When install Microsoft Office, you will need to ensure you install the Visual
Basic for Applications component.
The remainder of this training document will detail the use of the automation
interface using VBA in Microsoft Excel.
The automation interface can be used in VB Script with some minor syntactic
modifications to code written in VB/VBA. An example VB Script is provided in
Appendix A.
NOTE: The automation interface can be used in other languages such as C++ - this
is beyond the scope of this course.

2.3 Required ClearSCADA Components


In order to use the automation interface, the Data Access component must be
installed during the installation of ClearSCADA on the local machine. There is no
need to install the server components.

2.4 Adding the Automation Interface to the VBA Project


1.

Open the Excel Visual Basic Editor (ToolsMacroVisual Basic Editor)

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

2.
3.

In the Visual Basic Editor, select ToolsReferences


Enable Scx V6 Automation Interface

Figure 2-3 - SCX V6 Automation Interface in VBA Project References

2.5 A Simple Example


The following code connects to the ClearSCADA system named MAIN, displays the
current value of the Internal Analog Point New Analog Point, changes the value of
the Point to 10, and finally displays the new value of the point.
Function Main()
' Declare the variable for the ClearSCADA Server
Dim oServer As ScxV6Server
' Declare the variable for an ClearSCADA Object
Dim oObject As ScxV6Object
' Create the automation interface object which is our
' view of the ClearSCADA Server
Set oServer = New ScxV6Server
' Check that the automation interface object was
' successfully created
If (Not oServer Is Nothing) Then
' Establish a connection to the ClearSCADA Server
oServer.Connect "MAIN", "", ""
' Find an object in the ClearSCADA database
Set oObject = oServer.FindObject("New Analog Point")
' Check that the object was found
If (Not oObject Is Nothing) Then
' Display the value of the Point in a Message Box
MsgBox (oObject.Property("CurrentValue"))
' Change the value of the Point
oObject.Property("CurrentValue") = 10
' Display the new value of the Point in a Message Box
MsgBox (oObject.Property("CurrentValue"))
End If
End If
' Tidy up
Set oObject = Nothing
' Disconnect from the ClearSCADA Server

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

oServer.Disconnect
End Function

Exercise
1.
2.
3.
4.
5.

Create a new Internal Analog Point in the ClearSCADA Database using ViewX
Enter the program listed above
Run the program and confirm its results in ViewX
Modify the program to change the point value to 20
Confirm the program by checking the points value in ViewX

Exercise
1.
2.
3.

Create another Internal Analog Point in the ClearSCADA database using ViewX
Modify the program to change the value of the second point to 12.5
Confirm the program by checking the points value in ViewX

Exercise (Advanced)
1.
2.
3.

Create a third Internal Analog Point in the ClearSCADA database using ViewX
Modify the program to set the value of the third point to the sum of the values of
the other two points
Confirm the program by checking the points value in ViewX

2.6 The VB Object Browser


One feature of VBA which makes using the automation interface easier than with
other languages is the availability of the Object Browser. The object browser can be
accessed by selecting Object Browser from the View menu of the Visual Basic
Editor. From the object browser, the automation interface classes can be listed by
selecting ScxV6DbClient from the drop-down list as shown below in Figure 2-4.

Figure 2-4 - Automation Interface in the Object Browser

The object browser can be used to display the properties and methods of classes
available using the automation interface as shown below in Figure 2-5.

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

Figure 2-5 - Properties of ScxV6Object

2.7 Automation Interface Classes


Both the ClearSCADA database and the automation interface are Object Oriented.
They both allow objects to be created that are instances of classes. However, the
classes defined in the automation interface should not be confused with the classes
defined in the ClearSCADA database. They are easily distinguished due to the
automation interface classes all starting with ScxV6 and the ClearSCADA database
classes all starting with C.
The following sections describe the classes provided by the automation interface.
Further information on these classes, and the properties and methods provided by
them, can be found in the ClearSCADA Automation Interface Reference Manual.

2.7.1 ScxV6Server
The ScxV6Server class provides the functionality required to connect to a
ClearSCADA system. Multiple operations can be performed on a ClearSCADA
system using a single instance of this class. If the program connects to multiple
ClearSCADA systems simultaneously, multiple instances of this class are required.
This class also contains methods to allow the programmer to create, delete and
search for objects in the ClearSCADA database.

2.7.2 ScxV6Object
The ScxV6Object class provides the functionality to examine and modify objects in
the ClearSCADA database. This class is used to reference objects of all
ClearSCADA database classes. The automation interface does not provide a class
for each different ClearSCADA database class.
The search functions provided by ScxV6Server return a ScxV6Object

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

ClearSCADA Automation Interface Training Notes

2.7.3 ScxV6Objects
The ScxV6Objects class is a collection class of ScxV6Object objects. Objects of this
class can be treated as an array of ScxV6Object objects. The number of
ScxV6Object objects of the array can be determined using the Count property of the
ScxV6Objects object. Each ScxV6Object object can be retrieved from the array
using the Item property.

2.7.4 ScxV6Aggregate
Some ClearSCADA database objects contain (as briefly mentioned in the
introduction) Aggregates. Each Aggregate class, like all other ClearSCADA classes,
contains properties (configuration fields and data fields) and methods. Aggregates
allow the same set of properties and methods to be provided on multiple
ClearSCADA classes in a consistent manner.
The ScxV6Aggregate automation interface class provides functionality to examine
and modify ClearSCADA aggregate objects.
Aggregates will be examined in more detail in Section 9.

2.7.5 ScxV6Class
The ScxV6Object and ScxV6Aggregate classes each contain a read-only Class
property of type ScxV6Class. The Name property of the ScxV6Class provides the
programmer with the name of the ClearSCADA class (CPointAlgManual for example)
of the ScxV6Object object.

2.7.6 ScxV6Systems
The ScxV6Systems class is a collection class of strings. Each string in this collection
is the name of a ClearSCADA system defined in the Configure ClearSCADA
Connections applet. The ScxV6Server object class contains a read-only Systems
property which is used to obtain a ScxV6Sytstems object.

Chapter 2 - Introduction to the Automation Interface

Revision 3.0

10

ClearSCADA Automation Interface Training Notes

3 Connecting to an ClearSCADA System


Before any operations can be performed on the ClearSCADA database by the
automation interface, the program using the automation interface must first connect
and authenticate (log on) to the corresponding ClearSCADA System.
To connect to the ClearSCADA system, the program must first create an instance of
the ScxV6Server automation interface object. The syntax for creating the instance of
the ScxV6Server class will be dependant on the programming language used. In
VB/VBA, the New keyword is used to create the instance as shown below.
Set oServer = New ScxV6Server

After the ScxV6Server object has been successfully created, the Connect method
can be called on the ScxV6Server object, providing the System Name, Username
and Password. The following example connects to the ClearSCADA system called
MAIN with no username or password
oServer.Connect "MAIN", "", ""

If the specified system has not been registered in the ClearSCADA Client
Configuration applet (first parameter spelt incorrectly for example), the following error
will be generated in VB

Figure 3-1 - Unknown System Name

If the specified system is offline, or the ClearSCADA Client has not been configured
for ClearSCADA Access, the following error will be generated in VB

Figure 3-2 - System Offline

3.1 Security
The level of access granted to a program using the automation interface using any
given Username/Password is the same as in ViewX using the same
Username/Password. For example, if a given user does not have Configure access
to a given ClearSCADA database object, a program using the automation interface
with the same Username/Password will not be able to modify the properties of that
ClearSCADA database object.
If an operation on the ClearSCADA database (or any ClearSCADA object in the
database) is attempted where the supplied username/password has insufficient

Chapter 3 - Connecting to an ClearSCADA System

Revision
3.0

11

ClearSCADA Automation Interface Training Notes

privileges to perform the operation, one of the errors shown below in Figure 3-3 and
Figure 3-4 will occur.

Figure 3-3 - Permission Denied

Figure 3-4 - Insuficient Privideges

Exercise
1.
2.
3.
4.
5.
6.
7.

Use the ClearSCADA Service Manager to stop the ClearSCADA Server service
Rename the C:\ClearSCADADB folder
Use the ClearSCADA Service Manager to start the ClearSCADA Server service
Right-click on the ClearSCADA system tray icon and select Start Database
Click on Start Database on the warning dialog
Right-click on the ClearSCADA system tray icon and select Configuration
Select Security in the System Configuration folder of the Server Configuration
applet
8. Turn on the Enabled tick-box
9. Right-click on the server in the Server Configuration applet and select Apply
Changes
10. Close the Server Configuration applet
11. Open ViewX and import the file AutmationInterfaceSecurity.sde
NOTE: You will may get an Access is denied error This can be ignored.

The ClearSCADA database will now contain two users admin (password: admin01)
and operator (password: operator01). The admin user has full access to the
ClearSCADA database. The operator user only has Read, Browse, and Control
access to the ClearSCADA database.
Exercise
1.
2.
3.
4.

Logon to the ClearSCADA database in ViewX using the admin user


Repeat the exercise in Section 2.5 using the operator username and password
in the VB program
Repeat the exercise in Section 2.5 using an invalid username and password in
the VB program
Shutdown the ClearSCADA Server, delete the C:\ScxV6DB folder, rename the
old C:\ ClearSCADADB back to C:\ ClearSCADADB and restart the
ClearSCADA Server

Chapter 3 - Connecting to an ClearSCADA System

Revision
3.0

12

ClearSCADA Automation Interface Training Notes

4 Finding Objects in the ClearSCADA Database


In order to examine/modify an object in the ClearSCADA database, an instance of
the ScxV6Object class must be created which references the ClearSCADA database
object. The automation interface provides three methods for obtaining a reference to
an object in the ClearSCADA database:
y
y
y

ScxV6Server.FindObject
ScxV6Server.LookupObject
ScxV6Object.Find

Each of these methods returns an instance of ScxV6Object if the requested object is


in the ClearSCADA database. The returned object will reference the requested
ClearSCADA database object. If the requested object is not in the ClearSCADA
database, these functions return the VB reserved Nothing object.
It is good programming practice to test for Nothing as shown in the following
example
If (Not oObject Is Nothing) Then
...Do Stuff with oObject
End If

If the programmer does not check for Nothing, the error shown below in Figure 4-1 is
likely to occur.

Figure 4-1 - Accessing Property of a Nothing Object

4.1 ScxV6Server.FindObject
This method allows the programmer to obtain a reference to an object in the
ClearSCADA database by providing an absolute object name.
Exercise
1.
2.
3.
4.

Create an Group in the ClearSCADA database using ViewX


Create a new Internal Analog Point in the group created above using ViewX
Use the FindObject method of the ScxV6Server object to obtain a reference to
the new point
Display the current value of the new point

4.2 ScxV6Server.LookupObject
This method allows the programmer to obtain a reference to an object in the
ClearSCADA database by providing an integer Object ID. All objects in the
ClearSCADA database have a unique Object ID which can be obtained using the ID
property of the ScxV6Object class.

Chapter 4 - Finding Objects in the ClearSCADA Database

Revision
3.0

13

ClearSCADA Automation Interface Training Notes

Exercise
1.
2.
3.

Use the ID property of ScxV6Obejct to obtain the ID of the point created in the
previous exercise
Use the LookupObject method of the ScxV6Server object to obtain a reference
to the point using the ID (declare a new ScxV6Obejct in the VB code to store
this reference)
Display the current value of the new point using the ScxV6Object obtained in
step 2

Exercise (Advanced)
1.
2.

In the schema, locate the definition of the object ID


Besides using the ID property of ScxV6Object, how else could the ID of an
ClearSCADA database object be obtained
HINT: Consider the fact that it is a property defined in the schema

4.3 ScxV6Object.Find
This method allows the programmer to obtain a reference to an object located in a
Group, (or Template or Instance) in the ClearSCADA database. This method can be
used only if the ClearSCADA database object referred to by the ScxV6Object is a
CGroup, (or an object derived from CGroup). This method cannot find objects more
the one level deep in the Group.
The following code is not valid
Set oObject1 = oServer.FindObject (Group1)
Set oObject2 = oObject1.Find (Group2.Object)

oObject2 will equal Nothing even if the object Group1.Group2.Object exists in the
ClearSCADA database.
The following code is valid (provided the object Group1.Group2.Object exists in the
ClearSCADA database).
Set oObject1 = oServer.FindObject (Group1)
Set oObject2 = oObject1.Find (Group2)
Set oObject3 = oObject2.Find (Object)

Exercise
1.
2.
3.

Use the FindObject method of the ScxV6Server object to obtain a reference to


the group created in the previous exercises
Use the Find method of the ScxV6Object to obtain a reference to the point
created in the group
Display the value of the point

Chapter 4 - Finding Objects in the ClearSCADA Database

Revision
3.0

14

ClearSCADA Automation Interface Training Notes

5 Reading and Modifying ClearSCADA Object Properties


The exercises in the previous sections demonstrated the reading and writing of the
CurrentValue property of an Internal Analog Point. This section will show how any
property of a ClearSCADA database object can be read, and how properties that are
not read-only can be modified using the automation interface.

5.1 ScxV6Object.Property
All properties of and ClearSCADA database object are accessed using
ScxV6Object.Property. The syntax on this automation interface property was shown
in Section 2.5 as:
oObject.Property("CurrentValue")

This statement retrieves the current value of the ClearSCADA database object (a
Point) referenced by oObject. The example also demonstrated that the current value
could be written to:
oObject.Property("CurrentValue") = 10

This statement set the value of the ClearSCADA database object (a Point)
referenced by oObject to 10.
By using the schema to obtain the names and types of the properties of a
ClearSCADA class, the programmer can access any property on a ClearSCADA
database object using the automation interface.
Exercise
1.
2.

Use the FindObject method of the ScxV6Server object to obtain a reference to


the Internal Analog Point created in the previous exercises
Use the automation interface to display the Full Scale of the point
HINT: Full Scale is not defined on CPointAlgManual You will need to look at
the properties of the base class in the schema.

3.

Use the automation interface to change the Full Scale of the point to 200
HINT: There are three Full Scale properties Standard, Current, and Tuned.
Only one of them is read-write. If you pick the wrong one, you will get the error
message shown in Figure 5-1.

Figure 5-1 - Attempt to Write to a Read-Only Property

Exercise (Advanced)

Chapter 5 - Reading and Modifying ClearSCADA Object


Properties

Revision
3.0

15

ClearSCADA Automation Interface Training Notes

1.
2.
3.

Create a new DNP3 Outstation in the ClearSCADA database using ViewX


Create a new DNP3 Analog Input Point in the ClearSCADA database using
ViewX
Use the automation interface to tie the Outstation to the Point.
HINT: You will need to determine the ID of the Outstation.

5.2 ScxV6Object.Class.Name
As shown in the introduction, the properties defined on each of the ClearSCADA
classes are listed in the schema. The schema shows that different ClearSCADA
classes define different properties. However, ScxV6Object is used to reference
database objects of all ClearSCADA classes. If the program using the automation
interface attempts to read from, or write to, a property that does not exist on the
referenced ClearSCADA database object, the error shown in Figure 5-2 will occur.

Figure 5-2 - Attempt to Read or Write a Non-Existent Property

Given a ScxV6Object that references an object in the ClearSCADA database, how


can the program know which properties are valid?
The Class property of ScxV6Object allows the programmer to determine the
ClearSCADA class of the database object referenced by an instance of
ScxV6Object. This property returns an object of class ScxV6Class which, in turn, has
a Name property which returns the name of the ClearSCADA class as a string.
Therefore, the following statement will obtain the class of a ClearSCADA database
object referenced by a ScxV6Obejct
Dim sClass As String
sClass = oObject.Class.Name

Once the ClearSCADA class has been determined, the program can selectively
access the ClearSCADA database object properties applicable to that class.
Exercise
1.
2.
3.

Create a new Link Parameter in the ClearSCADA database using ViewX.


Create a new Internal Digital Point in the ClearSCADA database using ViewX.
Write code to obtain a reference to the object linked to the Link Parameter.
HINT: The link parameter has a property which is the Object ID of the
ClearSCADA object it is linked to.

4.
5.

Write a code that determines the ClearSCADA Class of the object linked to the
Link Parameter.
Write code that will set the State 0 Description of the linked object to Off if it is
an Internal Digital Point.

Chapter 5 - Reading and Modifying ClearSCADA Object


Properties

Revision
3.0

16

ClearSCADA Automation Interface Training Notes

HINT: Use the VB If Then... ElseIf End If statement, or the Select Case
End Select statement.
6.
7.

Write code that will set the Over-range description of the linked object to Too
High if it is an Internal Analog Point.
Test you code by changing the point linked to in the link parameter.

Exercise (Advanced)
1.
2.
3.

Create a String Parameter in the ClearSCADA database using ViewX.


Write code that will set the State 0 Description of the linked object to the string
value of the String Parameter if it is an Internal Digital Point.
Write code that will set the Over-range Description of the linked object to the
string value of the String Parameter if it is an Internal Analog Point.

Exercise (Advanced)
1.
2.

Create another String Parameter in the ClearSCADA database using ViewX.


Write code that tells the user if the ClearSCADA class name of the object tied to
the Link Parameter created in the previous exercise is the same as the string
value of the new String Parameter.

Chapter 5 - Reading and Modifying ClearSCADA Object


Properties

Revision
3.0

17

ClearSCADA Automation Interface Training Notes

6 Creating, Renaming and Deleting ClearSCADA Objects


The automation interface provides two methods for creating new objects in the
ClearSCADA database:
y
y

ScxV6Server.CreateObject
ScxV6Object.Create

One method for renaming objects in the ClearSCADA database


y

ScxV6Object.Rename

And one method for deleting objects from the ClearSCADA database
y

ScxV6Server.DeleteObject

6.1 ScxV6Server.CreateObject and ScxV6Object.Create


These two methods create a new object of the specified ClearSCADA class in the
ClearSCADA database. If the object is successfully created in the ClearSCADA
database, they return an instance of ScxV6Object which references the newly create
object. Refer to the ClearSCADA database schema for a list of class names that can
be created. If the name of a non-existent class is specified, the error shown in Figure
6-1 will occur.

Figure 6-1 - Non-Existent Class Name

The programmer must also ensure that the specified class is one of the Creatable
Classes. Creatable classes have a description string in parentheses after the class
name in the schema. If a non-creatable class is specified, an error similar to the one
shown in Figure 6-2 will occur.

Figure 6-2 - Non-Creatable Class Name

Exercise
1.
2.

Name a creatable class.


Name a non-creatable class.

ScxV6Server.CreateObject requires the absolute name of a Group or Template


object in the ClearSCADA database to be specified. The new object will be created
in the specified Group or Template. If the named Group or Template does not exist

Chapter 6 - Creating, Renaming and Deleting ClearSCADA


Objects

Revision
3.0

18

ClearSCADA Automation Interface Training Notes

in the ClearSCADA Database the error shown in Figure 6-3 will occur. If the named
object is a Template Instance, the error in Figure 6-4 will occur.

Figure 6-3 - Create in Non-Existent Group

Figure 6-4 - Create in a Template Instance

The behaviour of ScxV6Object.Create depends on if the ClearSCADA object


referenced by the ScxV6Object is a Group/Template or not as follows:
y
y
y

If the ScxV6Object references a Group or Template, the new object will be


created in the ClearSCADA database inside the referenced
Group/Template.
If the ScxV6Object references a Template Instance, the error shown in
Figure 6-4 will occur.
Otherwise, the new object will be created in the Group/Template that
ClearSCADA object referenced by the ScxV6Object is located in.

6.2 ScxV6Object.Rename
This method allows the programmer to rename objects in the ClearSCADA
database. This method is typically used to rename objects created with the object
creating methods described above.
The programmer must ensure that the new name adheres to the ClearSCADA object
naming rules. If the supplied name is invalid, an error similar to the one shown in
Figure 6-5 will occur.

Figure 6-5 - Invalid Object Name

Chapter 6 - Creating, Renaming and Deleting ClearSCADA


Objects

Revision
3.0

19

ClearSCADA Automation Interface Training Notes

Exercise
1.
2.
3.
4.

Using the automation interface, create a new Group in the ClearSCADA


database.
Using the automation interface, rename the Group created in step 1.
Use ScxV6Object.Create to create a new object in the Group created in step 1.
Use ScxV6Server.CreateObject to create a new object in the Group created in
step 1.

6.3 ScxV6Server.DeleteObject
This method allows objects in the ClearSCADA database to be deleted. If the Force
parameter is not set to True, and the object in the ClearSCADA database that is
being deleted is referenced by other objects, an error similar to the one shown in
Figure 6-6 will occur.

Figure 6-6 - Deleting an Object Referenced by other Objects

Exercise
1.

Use the automation interface to delete one of the groups (and all objects inside
the group) created in the previous exercises
HINT: ScxV6Server.DeleteObject will delete all objects within a Group if the
Object ID of a Group in the ClearSCADA database is supplied.

Chapter 6 - Creating, Renaming and Deleting ClearSCADA


Objects

Revision
3.0

20

ClearSCADA Automation Interface Training Notes

7 Collections
The methods ScxV6Server.Objects and ScxV6Object.List both return a collection of
instances of ScxV6Object. Each instance will reference an object in the ClearSCADA
database that is either an instance of the specified ClearSCADA class, or an
instance of any class derived from the specified ClearSCADA class.
ScxV6Server.Objects returns all objects in the ClearSCADA database of the
specified class.
ScxV6Object.List can only be called on ScxV6Object objects that reference an
instance of CGroup, (or instances of classes derived from CGroup) in the
ClearSCADA database. If the ScxV6Object reference an object which is not an
instance of CGroup (or one of its derived classes), the error shown in Figure 7-1 will
occur.

Figure 7-1 - Calling the List Method on an Object that is not a Group

NOTE: ScxV6Object.List only return objects inside the group, it does not return
objects that are contained in groups within the referenced Group.

7.1 The ScxV6Objects Object


The ScxV6Server.Objects and ScxV6Object.List methods both return an instance of
the automation interface collection class ScxV6Objects. Instances of ScxV6Objects
are essentially an array of ScxV6Object objects.
The number of objects in the ScxV6Objects instance can be determined using the
ScxV6Objects.Count property. The ScxV6Objects.Item property returns the instance
of the ScxV6Obejct at the given index. Index numbers start at 1. If the requested
index is less the 1, or greater than the number of objects in the collection, the error
shown in Figure 7-2 will occur.

Figure 7-2 - Invalid Item Number

Chapter 7 - Collections

Revision
3.0

21

ClearSCADA Automation Interface Training Notes

Exercise
1.
2.
3.
4.
5.
6.

Create a new group in the ClearSCADA database using ViewX


Create a new Internal Analog Point in the ClearSCADA database
Create a new Internal Digital Point in the ClearSCADA database
Use ScxV6Objects.Count to determine the number of CPointAlgManual objects
exist in the new group
Use ScxV6Objects.Count to determine the number of CPointDigitalManual
objects exist in the new group
Use ScxV6Objects.Count to determine the number of CDBObject objects exist
in the new group

One of the most common ways of using the ScxV6Objects class is with a For/Next
loop
Dim oObjects as ScxV6Objects
Dim oObject as ScxV6Object
Dim iCurrentObject as Integer
Set oObjects = oServer.Objects (CPointAlgManual)
If (Not oObjects Is Nothing) Then
For iCurrentObject = 1 to oObjects.Count
Set oObject = oObjects.Item (iCurrentObject)
...Do something with oObject...
Next
End If

Exercise
1.

Use the automation interface to set the State 0 Description of all Internal Digital
Points in the ClearSCADA database to On

Exercise (Advanced)
1.
2.
3.
4.

Create a new group in the ClearSCADA database


Create another new group inside the group created in step 1
Create a number of Internal Digital Points in the groups created in steps 1 and 2
Use the automation interface to set the State 0 Description of all Internal Digital
Points created in step 3 Do so without directly referencing the group created
in step 2 (i.e. Assume that the name of the group created in step 2 is not
known)
HINT: You will need to use the automation interface to find instances of CGroup

Exercise (Advanced)
1.

Repeat the previous exercise, this time creating multiple groups (and multiple
levels).
HINT: The easiest way to do this is with a recursive function.

Chapter 7 - Collections

Revision
3.0

22

ClearSCADA Automation Interface Training Notes

8 Calling Methods on ClearSCADA Objects


The ScxV6Object.Interface method allows the automation interface to call methods
on objects in the ClearSCADAV6 database. The format for calling methods in objects
in the ClearSCADA database is as follows:
oObj.Interface.<Method> <Arg1> <Arg2> ... <ArgN>

Where <Method> is the method defined by the ClearSCADA class and <ArgX> are
the arguments required by the method defined on the ClearSCADA class (refer to
the schema for the number and type of the arguments)
The following example will accept the current active alarm on the ClearSCADA
database object Analog Point with the comment This is a Comment
Set oObject = oServer.FindObject("Analog Point")
If (Not oObject Is Nothing) Then
oObj.Interface.AcceptWithComment This is a Comment
End If

The following example will execute the logic program ST Program


Set oObject = oServer.FindObject("ST Program")
If (Not oObject Is Nothing) Then
oObject.Interface.Execute
End If

If the arguments supplied to the ClearSCADA method are incorrect (wrong number
of arguments, or wrong data type) the error shown below in Figure 23 will occur

Figure 8-1 - Invalid Argument to ClearSCADA Method

Exercise
1.
2.
3.
4.

Use the automation interface to disable alarms on an Internal Analog Point in


the ClearSCADA database that is not in an active alarm state
In ViewX, Hand Control the Internal Analog Point to a value above its overrange limit Confirm that alarm is not generated
Use the automation interface to enable alarms on the Internal Analog Point
Confirm that an alarm is generated

Chapter 8 - Calling Methods on ClearSCADA Objects

Revision
3.0

23

ClearSCADA Automation Interface Training Notes

9 Aggregates
An Aggregate is a collection of related ClearSCADA properties and methods that can
be included in a ClearSCADA class. The most common aggregate accessed using
the automation interface is the Historic (CHistory) aggregate. The Single and Dual
Network (CSingleNetwork and CDualNetwork) aggregates are also used frequently
when configuring network outstations. The PSTN (CAdvPSTN) and its derived class
are used when configuring dial-up outstations.

9.1 ScxV6Object.Aggregate
The Aggregate property of ScxV6Object returns an instance of the ScxV6Aggregate
class which references the named aggregate of the ClearSCADA database object
referenced by the ScxV6Object object. If the named aggregate does not exist on the
referenced object, the error shown in Figure 9-1 will occur.

Figure 9-1 - Named Aggregate does not Exist

Exercise
1.

Use the automation interface to display the class name of the Historic
aggregate of any internal point created in the previous exercises.
HINT: The Class property of the ScxV6Aggregate class is not the same as
ScxV6Object Use the object browser to determine the data type of this
property.

9.2 ScxV6Aggregate.Enable
Before the properties and methods defined on the aggregate can be accessed, the
aggregate must be enabled. The aggregate may be enabled in ViewX be checking
the Enable check box in the aggregates configuration as shown in Figure 9-2.

Figure 9-2 - Using ViewX to Enable an Aggregate

Chapter 9 - Aggregates

Revision
3.0

24

ClearSCADA Automation Interface Training Notes

The aggregate can also be enabled using the automation interface by setting the
Enable property of the ScxV6Aggregate object to True as shown in the following
example
Set oAgg = oObject.Aggregate ("Historic")
If (Not oAgg Is Nothing) Then
oAgg.Enable = True
End If

Similarly, aggregates can be disabled by setting the Enable property of the


ScxV6Aggregate object to False.
Exercise
1.
2.
3.

Use ViewX to disable the Historic aggregate of any internal point created in the
previous exercises
Use the automation interface to enable the Historic aggregate disabled in step 1
Confirm the aggregate is enabled in ViewX
NOTE: You will need to close the properties dialog on the ClearSCADA object
in ViewX and open it again

If an attempt is made to access the properties and methods of an aggregate that is


not enabled, the error shown in Figure 9-3 will occur.

Figure 9-3 - Accessing Properties or Methods of a Disabled Aggregate

9.3 ScxV6Aggregate.Property and ScxV6Aggregate.Interface


ScxV6Aggregate.Property and ScxV6Aggregate.Interface are identical in
functionality to ScxV6Object.Property and ScxV6Object.Interface. Refer to Sections
5 and 8.
Exercise
1.

Use the automation interface to enable historic compression of the point that
had its Historic aggregate enabled in the previous exercise.

9.4 CHistory.LoadDataValue and CHistory.LoadDataFile


The CHistory aggregates define the methods LoadDataValue and LoadDataFile
which allow the automation interface to be used to load historic data into the
ClearSCADA database for a ClearSCADA database object which has its Historic
aggregate enabled.
The following example stores the value 12.3 with a timestamp of one second past
1pm on the 10th December, 2004 with good quality into the point New Analog Point.

Chapter 9 - Aggregates

Revision
3.0

25

ClearSCADA Automation Interface Training Notes

Dim oHis As ScxV6Aggregate


Dim oObj As ScxV6Object
Set oObj = oServer.FindObject ("New Analog Point")
Set oHis = oObject.Aggregate ("Historic")
oHis.Enable = True
oHis.Interface.LoadDataValue 192, "2004-12-10 13:00:01", 12.3

The first argument to LoadDataValue is the data values Point Quality which has the
same numeric values as OPC Point Qualities. The following qualities are defined in
ClearSCADA
Quality
Bad
Uncertain
Good
Bad Configuration
Not Connected
Device Failure
Sensor Failed
Last Known
Communication Failed
Out of Service
Last Useable
Bad Sensor Calibration
Engineering Units Exceeded
Sub Normal

Value
0
64
192
4
8
12
16
20
24
28
68
80
84
88

Table 9-1 - OPC Quality Values

The format of the data file read by LoadDataFile is detailed in Appendix B


CAUTION: Data that is logged by the device drivers on the ClearSCADA Server is
archived more efficiently that data that is logged via the automation interface. This is
due to the fact that data logged by the device driver is practically guaranteed to be in
chronological order (most protocols enforce this). Therefore, performance issues
may arise if large amounts of historic data are logged using the automation interface.

Chapter 9 - Aggregates

Revision
3.0

26

ClearSCADA Automation Interface Training Notes

10 Templates and Instances


The automation interface allows the creation of instances of CTemplate and
CTemplateInstance in the ClearSCADA database. The same rules apply in the
automation interface as in ViewX when dealing with templates and instances in the
ClearSCADA database (i.e. object cannot be created in instances, only overridden
properties can be modified in instances etc).

10.1 CTemplateInstance.TemplateId
An instance of ScxV6Object referencing a CTemplateInstance object in the
ClearSCADA database has a property, TemplateId which is a reference to a
template in the ClearSCADA database.
Exercise
1.
2.
3.

Use the automation interface to create a new template in the ClearSCADA


database
Use the automation interface to create a new instance in the ClearSCADA
database
Use the automation interface to tie the instance created in step 2 to the
template created in step 1

10.2 CScxV6Object.PropertyOverride
If the instance of ScxV6Object references a template object in the ClearSCADA
database, the PropertyOverride property can be used to query the state of, and
enable/disable the property overrides of the referenced template. PropertyOverride is
called in the ScxV6Object referencing the template, and requires the ClearSCADA
object id of the object located in the template, and the name of a configuration field
(of the object within the template) to be specified.
If the object in the ClearSCADA database referenced by the ScxV6Object is not a
template, the error shown in Figure 10-1 will occur.

Figure 10-1 - PropertyOverride Called on an Object that is not a Template

If the object id of the object within the template is not the object id of an object within
the template (or the object does not exist), the error shown in Figure 10-2 will occur.

Chapter 10- Templates and Instances

Revision
3.0

27

ClearSCADA Automation Interface Training Notes

Figure 10-2 - Property Override Called with an Object not in the Template

If the requested configuration field does not exist on the ClearSCADA database
object with the specified object id the error shown in Figure 10-3 will occur

Figure 10-3 - Property Override Called on a Non-Existent Field

Exercise
1.
2.
3.

Create a new Internal Analog Point in the template created the previous
exercise
Use the automation interface to enable the property override for the Full Scale
configuration field of the internal Analog point created in step 1
Confirm the property override in ViewX

10.3 Reading and Writing Properties in Instances


As with ClearSCADA database objects that are not contained in instances, the
automation interface can be used to read from, and write to, configuration fields of
objects contained in Template Instatances. However, like ViewX, the ClearSCADA
will not allow the automation interface to set the value of a configuration field that is
not property overridden. If an attempt to write to a property that has not been
overridden is attempted, the error shown below in Figure 30 will occur

Figure 10-4 - Attempt to Write to a Property in an Instance that is not Overridden

Chapter 10- Templates and Instances

Revision
3.0

28

ClearSCADA Automation Interface Training Notes

Appendix A

VBScript Example

The following code is the VBScript equivalent of to the example provided in Section
2.5. The only differences are
1.
2.

VBScript is type-less (has no data types) Dim statements have no As clause


VBScript does not support New Objects in VBScript are created using
CreateObject ()
' Declare the variable for the ClearSCADA Server
Dim oServer
' Declare the variable for an ClearSCADA Object
Dim oObject
' Create the automation interface object which is our
' view of the ClearSCADA Server
Set oServer = CreateObject ("Serck.ScxV6Server")
' Check that the automation interface object was
' successfully created
If (Not oServer Is Nothing) Then
' Establish a connection to the ClearSCADA Server
oServer.Connect "MAIN", "", ""
' Find an object in the ClearSCADA database
Set oObject = oServer.FindObject("New Analog Point")
' Check that the object was found
If (Not oObject Is Nothing) Then
' Display the value of the Point in a Message Box
MsgBox (oObject.Property("CurrentValue"))
' Change the value of the Point
oObject.Property("CurrentValue") = 10
' Display the new value of the Point in a Message Box
MsgBox (oObject.Property("CurrentValue"))
End If
End If
' Tidy up
Set oObject = Nothing
' Disconnect from the ClearSCADA Server
oServer.Disconnect

Appendix A- Inserting Historic Data

Revision
3.0

29

ClearSCADA Automation Interface Training Notes

Appendix B

Inserting Historic Data

There are three methods if inserting historical data into the ClearSCADA database
using the automation interface.

B.1 PresetTimestamp and PresetQuality


The CPointAlgManual, CPointDigitalManual, CPointStringManual, and
CPointTimeInternal classes provide the PresetTimestamp and PresetQuality
properties.
If these properties are set before setting the CurrentValue property, the value will be
added to the historic database with the Timestamp and Quality provided.
The timestamp provided by PresetTimestamp is interpreted by the server as being
UTC No translation is performed to account for time zones by the server
The following example stores a value of 10 at 10th December 2004, 1:00:01PM
(UTC) with Good Quality (192) in the history of the point New Analog Point
Dim oObj As ScxV6Object
Set oObj = oServer.FindObject ("New Analog Point")
oObj.Property ("PresetQuality") = 192
oObj.Property ("PresetTimeStamp") = "2004-12-10 13:00:01"
oObj.Property ("CurrentValue") = 10

B.2 CHistory.LoadDataValue
The Chistory aggregate defines the LoadDataValue method which allows a historic
value to be added to the history of a point.
The following example stores a value of 10 at 10th December 2004, 1:00:01PM
(Local Time) with Good Quality (192) in the history of the point New Analog Point
Dim oHis As ScxV6Aggregate
Dim oObj As ScxV6Object
Set oObj = oServer.FindObject ("New Analog Point")
Set oHis = oObj.Aggregate ("Historic")
oHis.Enable = True
oHis.Interface.LoadDataValue 192, "2004-12-10 13:00:01", 10

Appendix A- Inserting Historic Data

Revision
3.0

30

ClearSCADA Automation Interface Training Notes

B.3 CHistory.LoadDataFile
The Chistory aggregate defines the LoadDataFile method which allows a series of
historic values to be added to the history of a point from data stored in a file on the
servers file system.
The data file is series of comma separated data. Each row in the data file represents
a single historic value. The format of each row is:
<year>,<month>,<day>,<hour>,<minute>,<second>,<value>,<quality>

For example, the following line represents a value of 12.3 with good quality at
1:15:30PM on the 15th December 2004.
2004,12,15,13,15,30,12.3,192

The following example loads the historic data file C:\Temp\History.dat into the history
of the point New Analog Point
Dim oHis As ScxV6Aggregate
Dim oObj As ScxV6Object
Set oObj = oServer.FindObject ("New Analog Point")
Set oHis = oObject.Aggregate ("Historic")
oHis.Enable = True
oHis.Interface.LoadDataFile "C:\Temp\History.DAT"

Appendix A- Inserting Historic Data

Revision
3.0

31

You might also like