KEMBAR78
ClearSCADA Advanced Ver0 - 3 | PDF | Windows Registry | Computer File
0% found this document useful (0 votes)
4 views95 pages

ClearSCADA Advanced Ver0 - 3

The ClearSCADA Advanced Training Course, led by instructor Bradley Hosken, spans four days and covers various topics including installation, administration tools, alarm management, and configuration downloads. Participants will learn about licensing, server configuration, and archiving historic data, with practical exercises to reinforce the training. The course aims to equip attendees with the skills to effectively use ClearSCADA for SCADA system management and integration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views95 pages

ClearSCADA Advanced Ver0 - 3

The ClearSCADA Advanced Training Course, led by instructor Bradley Hosken, spans four days and covers various topics including installation, administration tools, alarm management, and configuration downloads. Participants will learn about licensing, server configuration, and archiving historic data, with practical exercises to reinforce the training. The course aims to equip attendees with the skills to effectively use ClearSCADA for SCADA system management and integration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 95

ClearSCADA

Advanced Training
Course

Welcome
Instructor: Bradley Hosken

Times: 8:30am Start


4:30pm Finish

Breaks Morning Tea 10:00am


Lunch 12:30pm
Afternoon Tea 3:00pm

ClearSCADA Advanced Training Course 2

1
Welcome
• Toilets – Where are they!

• Introductions – RTU / PLC / SCADA Experience.


– You should know what a SCADA is?
– What you would like to get from this course?

• Handout Material – Use it! Its yours to keep.

• Safety – Lets look after each other!

ClearSCADA Advanced Training Course 3

ClearSCADA Advanced - Outline


Day 1 Day 2
Installation (15min) Advanced Mimics
eNET Objects 4hrs Layers 2hrs
Good Practice (Time Edit Points 1hrs
Permitting) 1hr Hover/Transparency 1hrs
Administration Tools 1hrs Movement Animations 1hrs
Pick Actions 1hrs

ClearSCADA Advanced Training Course 4

2
ClearSCADA Advanced - Outline
Day 3 Day 4
Alarm Management 2hrs ODBC Excel – 2 hr
Historic Data 1hr Alarm Redirections – 3hrs
SQL Queries 3hrs SMS
Software Communications Command processor
DDE Excel 1hr Calendar
Rosters
Client Side Scripting 2hrs

ClearSCADA Advanced Training Course 5

Installation – What is installed?


When you first install ClearSCADA it is recommended that you
perform a Full (Recommended) Install. This will install the following
components.

• Server Software
• ViewX Client Software
• Shortcuts on the desktop for
– Starting & Stopping the server
– Launch ViewX Client software

• Sample Project
• Presentation Project
• Symbol Library

ClearSCADA Advanced Training Course 6

3
Super User Account
During the first time installation you will be prompted to set-up a
Super User Account that requires a username and password.

The Super User Account has security privileges beyond all other
users on the system.

For training purposes you may choose something simple:


Username: Administrator
Password: Password

Do not loose this information! (Its your get out of jail card)

ClearSCADA Advanced Training Course 7

Configuring the Server to Start Automatically


The ClearSCADA Server runs as a service in the windows
environment.

When you install the demonstration version of the software the


Server, Service will be set to run in manual mode. This means that
each time the PC is started the Server Service will need to be
started.

To change this to Automatic from windows, select Start | Settings |


Control Panel. Navigate to Administrative tools and select services,
locate the ClearSCADA server in the list and double click to edit it.
Change the startup type to “Automatic”. Click “Apply”, then “Ok”
and close the dialog. Your server should now start when windows is
started.
ClearSCADA Advanced Training Course 8

4
Licensing ClearSCADA
Without a license ClearSCADA will run in Demo mode for 2hrs
before shutting down. In Demo mode you will only be able to
access historic data from the current run period.

Licensing is available for both the server and the client machine.
Licensing can take two forms:

Hardware (USB key / dongle) Not PC specific, the license lives on


the dongle so it will move with the dongle. The key / dongle must be
connected to the PC at all times.

Software (.Lic file) Permanently installed on the PC, linked to the


PC’s machine ID. A change of machine ID will require a new .Lic
file to be installed.
ClearSCADA Advanced Training Course 9

Software Features
Some times the Software features or driver requirements may
change.

To modify the installed features from windows, select Start |


Settings | Control Panel | Add / Remove Programs.

Browse the list to find Control Microsystems ClearSCADA and


select change. Follow the wizard to add / remove modules.

ClearSCADA Advanced Training Course 10

5
Exercise – Installation
Time Allowed: 15 Minutes

Aim: To install the latest version of the software for use in this
training course.

Note:
You may need to add the DNP3 ScadaPackES (eNET) feature for
this course.

Exercise: Follow the steps in Chapter 02 of the Training Notes

ClearSCADA Advanced Training Course 11

SCADAPack ES Integration
• ClearSCADA provides the ability to use the RTU object
configurations generated in the SCADA to configure the RTU
with a matching configuration setup.
– This provides a single point of configuration.
– Minimizes errors
– Increases speed of development through ClearSCADA
productivity tools

• Once configuration has been setup in ClearSCADA, it can be


downloaded to the RTU using the DNP3 comms link.
• The RTU will read the downloaded file(s), reconfiguring itself
and restarting if necessary.

ClearSCADA Advanced Training Course 12

6
eNET Objects
• To allow configuration downloads to occur, a set of eNET
specific objects are available in ClearSCADA containing specific
configuration information related to the eNET.
• These objects are an extension on the DNP3 driver and contain
such things as:
– Type of point
– Triggered/Buffered Event Setup
– Event Deviations
– RTU port information

• Extra methods are available on an eNET outstation to perform


such actions as Downloading Configuration.

ClearSCADA Advanced Training Course 13

Analog Alarming
• The eNET contains a point database, similar to that of
ClearSCADA.
• eNET Analog points allow for up to 4 high and 4 low alarms per
point.
– The alarm setpoints are properties of the point in the RTU
database.
– The processing if alarm level transgressions is performed by the
RTU firmware (no user code)
• The RTU point database properties tie in to ClearSCADA point
properties meaning that for a single point in ClearSCADA, up to
8 alarms can be processed with no further code in the RTU or
points in the SCADA.
– Alarm limit changes in ClearSCADA are downloaded to the RTU
for alarm processing.

ClearSCADA Advanced Training Course 14

7
Configuration Downloads
• The eNET outstation objects in ClearSCADA allow extra
configuration files to be attached to the outstation object for
downloading to the RTU
– ISaGRAF programs
– Extra RTU configuration fields
– Licence files
– Profiles

• Once a configuration is complete in ClearSCADA, it can be


downloaded to the RTU (automatically or manually)
• If set for auto download, ClearSCADA will download
configuration specified when the status bit Config Corrupt is
returned from the RTU.

ClearSCADA Advanced Training Course 15

Configuring RTU Append Files


• Sometimes you may need to include an RTU Append file that is used to
configure DNP points that are used by the ISaGRAF application in the
RTU. These points may not be used by the SCADA Software.

#AI 1 # = Comment
PC AI PC = Point Create (Type AI, AO, DI, DO)
PE AI PE = Point Edit
RN 1 RN = Register Number (Point Number)
ER 0 5 0 10000 ER = Engineering Range
CVal = 30 Change Current value to 30
DB = 100 Debounce Time is 100 miliseconds
TE TE = The End
FileName.RTU Full Configuration
FileName.INC Incremental Configuration
More Info can be found in V7_Config_File_Format.PDF
ClearSCADA Advanced Training Course 16

8
Exercise – eNET RTU Configuration
Time Allowed: 90 Minutes

Aim: To configure an RTU using only ClearSCADA and then to


allow ClearSCADA to completely configure a cleared RTU.

Exercise: Follow the steps in Chapter 03 of the Training Notes

ClearSCADA Advanced Training Course 17

Administration Tools - System Recovery


We will examine some of the tools that can be used to backup your
system, and determine what's required to recover from a disaster.

• Import / Export to SDE File

• Archiving historic/event data

• Registry Settings

• Installed Modules

ClearSCADA Advanced Training Course 18

9
Import / Export to SDE File
This allows the Import / Export of database items

• Easy to do…Browse the project using Database Explorer Bar. Your selected location
will provide the destination / source for your Import / Export.

• Initiate using the Edit menu or from the object menu.

• The options are:


– Export (copies group database items to a single file)
– Import (database items are created from a single file)
– Import & Merge (database items are merged from a single file)

• Used to share configuration & update your live system. Use caution when using
security, templates and instances and when database items already exist.

• SDE Files DO NOT contain object ID’s. Object ID’s are used to link points with
history.

ClearSCADA Advanced Training Course 19

Archiving Historic / Event data


Archiving Historic / Event data allows the important process information
retrieved from PLC’s and RTU’s and System messages to be stored away
as a permanent record to an external volume. Once the data is eligible to be
archived it can’t be altered in any way.

Time Now

(52 weeks + possible 4 weeks future data) Historic Data – Online Data
Data Eligible for Archive Writable Data Future Data

These settings are found in the “Server Configuration” | Global Parameters |


Historic.

ClearSCADA Advanced Training Course 20

10
Historic Data Timing – Things to consider
• In a Hot Standby System – If there is a hardware failure, how long
would the servers not see each other?

• If a remote RTU site looses communications with ClearSCADA,


How long (Worst Case) before communications can be
reestablished if a radio or repeater is taken out by lightening etc?

• Time stamp data may contain Forecast data that has a timestamp
some time into the future. If it is beyond the future data setting it will
be rejected.
Time Now
• Is the time clock in the RTU correct?
(52 weeks + possible 4 weeks future data) Historic Data – Online Data
Data Eligible for Archive Writable Data Future Data

ClearSCADA Advanced Training Course 21

Improving Synchronization Performance


• SCADA Systems can store large volumes of Historic information. By Default
ClearSCADA will store 52 weeks of Historic data for every point with Historic
Data enabled. n
za t io

h on i
When ever the connection between the serversris re-established all the
Writeable data must be re-synchronized.ync
S
a s te r
• By altering the Archive after F
r = setting the synchronization time can be reduced
a l le
on large systems.

Sm
• The smaller the Writable data quantity, the faster the synchronization process
will be.

(52 weeks + possible 4 weeks future data) Historic Data – Online Data
Data Eligible for Archive Writable Data Future Data

ClearSCADA Advanced Training Course 22

11
Archiving – What can be archived?
Historic Data – Historic data that is stored for points when enabled.
Each file contains data for one (1) week

Historic Event Journal – System event messages. Such as Users


Logging on, Controls being issued and alarms being raised.

The ClearSCADAArchive.Dat file is the archive index file that is created


when an archive is first created. This file is used to incrementally
archive data. Removing this file will allow the system to create a
new full archive volume.

ClearSCADA Advanced Training Course 23

Mounting a Archive Volume.


Archiving involves incrementally copying the eligible archive data to an external
volume…before this can take place the archive volume needs to be
mounted. The ability to mount an additional volume may be determined by
the “Server Configuration” à Global Parameters à Historic.

Once an Archive Object has been created in you ClearSCADA Database (See
the following slides) you will be able to Mount and Dismount the volume by
using these methods on the Archive object.

Once the volume is mounted the data will appear as historic data on the server
that has the mounted volume only. (The data is not transferred to any other
servers in your system) Make sure your ViewX is connected to the correct
server. If the Archive method is initiated new data ready for archiving will be
appended to the volume.
ClearSCADA Advanced Training Course 24

12
Configuring an Archive Object.
An Archive Object needs to be added and Configured in your ClearSCADA
database. You will find this object in New à Other à Archive

• In the Archive object the following will need to defined


– Group (The section of your database to archive, $Root is everything)
– Node (In a multi-server system you may need more than 1 archive object)
– Path (Folder name for the archive on the volume)
– Volume Label (Unique Drive label e.g. SVRA_2007-08-14, leave blank to write to
any volume)

ClearSCADA Advanced Training Course 25

Automatic or Manual Archive


Once the Archive is setup it can occur either manually or based on a schedule.
To make the Archive Occur you will need to run a method(s) on the Archive
object.

If the Volume is removable e.g. CD/DVD it is suggested that this should be a


manual operation.

If the Volume is a network drive. The archiving process can be either Manual or
Automatic based on the use of a schedule Object.

ClearSCADA Advanced Training Course 26

13
Methods on the Archive Object
Mount Volume – This will Mount or Load the volume. Data will then be
available on this server

Dismount Volume - Removes the Volume. Data will no longer be available on


this server.

Archive – Running this method will append any data eligible for archiving to the
previously mounted volume.

ClearSCADA Advanced Training Course 27

Practical Exercise
Time Allowed: 60 Minutes

Aim: Follow the steps in Chapter 4 of the training notes.


Part 1. Restore a configuration from a SDE file……This contains a Mimic (pre
configured with Methods for the archive object and a list of all archive
objects in the system) this project also has an Archive Object, Point with
historic enabled and a trend object. The mimic also shows the last archive
alarm and the last time the server was archived.

Part 2. Prove the trend works – No Archived data from January 2007

Part 3. Your Memory sticks have archive data already on them. View your Point
ID and rename the archive folder to match your point ID. Configure your
archive object, mount it – magic. You should be now able to view data from
January 2007.

Part 4. Create a new archive object and archive to the local drive C: This
should be verified by dismounting and removing your memory stick. Note
you will need to review your server configuration before this will work.

ClearSCADA Advanced Training Course 28

14
Archiving Summary
Archiving is not meant for disaster recovery but rather for offsite long term
storage of your historic / event information

For disaster recovery it is recommended that your system architecture be


configured as a hot standby system.

When you have a redundant system the data on all servers should be
synchronized. So that the failure of any one server doesn't affect the day to
day operation of your system.

When recovering from a disaster it may take some time to transfer the history
to your new server…It will depend on the quantity of data and the network
bandwidth between servers.

ClearSCADA Advanced Training Course 29

Registry Settings
HKEY_LOCAL_MACHINE\SOFTWARE\Serck Controls\SCX6

What's stored here?


– Server Configuration Settings
– Client Configuration Settings
– Driver module settings

To back-up these settings use the export function in “regedit”.

To restore these settings run the exported registry file.

These registry settings are unique for each server.

WARNING Do not play in here – You can kill your system.

ClearSCADA Advanced Training Course 30

15
Driver Modules
The installed driver modules need to match your project configuration.

Systems that have multiple servers, should have the same driver modules
installed.

To alter this from windows select Start | Control Panel | Add or Remove
Programs | Control Microsystems ClearSCADA | Change | Next | Modify

ClearSCADA Advanced Training Course 31

Database Files
ClearSCADAConfig.dat – This file contains the configuration for the server.
This file is often overwriten when bulk changes are being made to a
installed system.

ClearSCADAData.dat – This file contains the Current Values of all the Object
Properties in the database. If you do not want current values to be
overwritten (Often the case) DO NOT Overwrite this file.

ClearSCADAMetadata.xml – This file contains the user created custom fields


within the database.

ClearSCADA Advanced Training Course 32

16
System Recovery – Punch List
• Install the ClearSCADA software with the required modules.

• Restore your registry backup

• Restore your database – If one server has failed in a multi server system
this should be transferred from the current servers.

• Restore you history – If one server has failed in a multi server system this
should happen automatically. You will need to set the server configuration |
partners | history synchronization | All Data - so that all the history is
exchanged. Change this back to “writeable data” after the history has been
restored.

ClearSCADA Advanced Training Course 33

Advanced Mimics
Mimics are used in every SCADA System. In this section we will look at
some of the more advanced features.

• Layers
• Import DXF File
• Local Variables
• Hover Animations
• Editing Points – Splitting, Deleting & Curving segments
• Transparency – Fill Alpha
• Movement Animations

ClearSCADA Advanced Training Course 34

17
Advanced Mimics - Layers
Mimics can make use of the layers. This means that mimic content can
be separated by function e.g. Overview, Hyperlink’s, Fresh Water,
Waste Water, Controls etc.

It is sometimes useful to break mimic objects on multiple layers to


prevent the accidental bumping of objects.

Layers are created from the Edit Menu | Layers, the mimic must be in
design mode and in focus.

ClearSCADA Advanced Training Course 35

Advanced Mimics – Layer Order


Layers at the top of the list are in the foreground. Layers at the bottom
of the list are in the background.

In this example Controls are at the front and Overview is at the back.

To alter the order of layers use the Move Up / Move Down Controls

ClearSCADA Advanced Training Course 36

18
Advanced Mimics – Layer Control
The visibility of layers can be controlled (turned on / off) to show the
information that is required at the time.

Examples of Layer Control


• Layer Enable – Disable layers that are not required
• Operator Control. At runtime the operator can turn layers on/off by
right clicking.
• Fixed Layer – The layer doesn't zoom

Example of Visibility Control


• Zoom level (details when zoomed in, de-clutter when zoomed out)
• Expression using Local or Global Variables
– REGISTRY(".DemoMimic.FullName"+'Fresh',0) = 1
– ".LayerControl“

ClearSCADA Advanced Training Course 37

Advanced Mimics – Import DXF Files


It is often useful to be able to import drawings from other systems.

A DXF File (Drawing Exchange File) can be produced by many drawing


packages. This can save time in producing Mimic screens because it allows
the reuse of drawings produced by other systems.

DXF files are imported by having a mimic in focus and selecting Edit | Import
DXF File…the dialog will allow the layers to be selected, colour and even
the size to be altered. During the import the drawing is converted to
ClearSCADA objects that can then be edited and animated in ClearSCADA.

Some drawings are made up of many segments, this can make the PC work
harder than necessary, use the simplify option to reduce this. Selecting
View | Mimic Diagnostics is also another tool that can be useful for this type
of operation.

Also do a query Tables CMimic and check the worst offenders…..Large docs
will consume bandwidth

ClearSCADA Advanced Training Course 38

19
Advanced Mimics – Registry Function
The Registry function is used to read and write to the windows registry on the client
machine only. It is used as local variables to the ViewX client machine.

These variables are stored in the following registry key:


HKEY_LOCAL_MACHINE\SOFTWARE\Serck Controls\SCX6\ViewX/Mimics

E.g.
REGISTRY(‘Name’, 0)
This function will return the value of Name in the registry. If it doesn't exist then it will be
entered with the value 0, and 0 will be returned.

REGISTRY(“.DemoMimic.FULLNAME” + ‘Option’, 0) = 1
This is good for Template instances as it allows a unique registry name.

To write the value 1 using the animation expression.


PickParam = ".DemoMimic.Fullname" + ‘Option' + '(1)‘
PickType = 8
Note: PickParam and PickType are covered in more detail later in this course.

ClearSCADA Advanced Training Course 39

Advanced Mimics – Practical Exercise


Time Allowed: 60 Minutes

Aim:
We will import a DXF file into ClearSCADA and produce a multi
layered mimic.

Use Local and Global variables to control the visibility of Layers.

Use Operator Controlled layers

Exercise: Follow the steps in Chapter 5 of the Training Notes

ClearSCADA Advanced Training Course 40

20
Advanced Mimics – Editing Points
The ClearSCADA mimic editing environment provides tools to draw the
basic shapes: Lines, Circles, rectangles and polygons.

These shapes can all be altered by right clicking and selecting the Edit
Points option.

ClearSCADA Advanced Training Course 41

Advanced Mimics – Practical Exercise


Aim:
We will create a tank similar to the one shown below.

Exercise: Follow the steps in Chapter 06 of the Training Notes

ClearSCADA Advanced Training Course 42

21
Advanced Mimics – Hover Animation
ClearSCADA includes a “Hover” Feature that allows mimic objects to
be animated when the mouse moves above the bounds of the mimic
object.

Typical things that can be done using the hover animation.


Change the FillAlpha (Transparency 100%=0 0%=255)
Change the FillColour
This can be used for a Mimic Navigation aid
Change text Font Style to underline - Hyperlinks

4 = Underline
2 = Italic

ClearSCADA Advanced Training Course 43

Advanced Mimics – Transparency FillAlpha


Objects in ClearSCADA that have the fill colour option also have a
transparency option (FillAlpha). This allows the user to be able to
see through objects.

Some uses of this include Highlighting Navigation links with the mouse
over function.

The transparency of an object can be altered with the animation


property Pen | FillAlpha property expression. To make a object
100% transparent an expression of 0 would be used. To make an
object 0% transparent an expression of 255 would be used.

ClearSCADA Advanced Training Course 44

22
Advanced Mimics – Exercise
Create a rectangle object over your tank that only appears when the
mouse is hovering over this area.

Configure this rectangle to have a pick action to navigate to a new page


in your system called Level Control, we will use this Mimic Later.

Object is
highlighted when
the mouse moves
over it.

ClearSCADA Advanced Training Course 45

Advanced Mimics – Movement Animations


• Movement Animations allow you to move and/or rotate an item
according to the value of an item in the database.

• This is useful for representing rise and fall of a water level or the
rotation of a dial on a gauge.

• ClearSCADA includes default size animations – vertical and


horizontal bars – which are available when dragging an analog point
onto a mimic.

ClearSCADA Advanced Training Course 46

23
Advanced Mimics – Size Animations
• Size Animations allow objects to be sized between two extremes according
to the value of a process variable.

• The animations required to configure a size animation are as follows:


– SizeMin – the minimum range of the size animation ie. the value at which the
object should be its smallest size
– SizeMax - the maximum range of the size animation ie. the value at which the
object should be its largest size
– SizeVal – this is the number that determines what percentage of the maximum
size the object should be.

• The direction of the sizing can be set from the General tab of the objects
properties eg bottom to top, left to right etc.

For example, if SizeMin is 0, SizeMax is 100 and SizeVal is 30 then the object
will be 30% of the size of the maximum.

ClearSCADA Advanced Training Course 47

Advanced Mimics – Position Animations


• Size animations allow objects to be moved around a mimic between two
extremes according to the value of a process variable.

• The animations required to configure a size animation are as follows:


– PosMin – the minimum range of the position animation ie. the value at which the
object should be at its start position.
– PosMax - the maximum range of the position animation ie. the value at which the
object should be its end position.
– PosVal – this is the number that determines what percentage along the path the
object should be.

• The path must be determined by:


– Right clicking on the object and selecting define Path.
– Single clicking to draw the path.
– Double click to end the path.

For example, if PosMin is 0, PosMax is 100 and PosVal is 30 then the object
will be positioned 30% along the defined path.

ClearSCADA Advanced Training Course 48

24
Advanced Mimics – Rotation Animations
• Rotation animations allow objects to be rotated according to the
value of a database property.

• There is only one animation required to configure a rotation


animation:
– Rotation – this is a number that determines the number of degrees the
object should be rotated.

• The pivot point for the rotation can be set from the General tab of
the object properties eg bottom, bottom left, top etc.

For example, if Rotation is set to 90, the object will rotate 90 degrees
from the vertical. ie. an arrow pointing up will turn to the right.

ClearSCADA Advanced Training Course 49

Advanced Mimics – Exercise


• On the mimic Level Control. Using Movement Animations, Create a
Process Instrument Display that shows Process variable as a bar
graph and a set point as a pointer. (These can both be sourced from
AI1)

ClearSCADA Advanced Training Course 50

25
Using Pick Action Animations
Rather than using the pick action wizard, pick actions can be
configured using animations. The use of animations is required
practically when the PickParam is changed dynamically.

• PickType – a number that specifies the type of pick action to perform


eg. 5 = method, 8 = write to a registry key etc.

• PickParam – this is a string that details the pick action to be


performed. The format of this string varies depending on PickType.

See Online help for a complete list:


Core Reference | Mimics | Animations | Pick Action Animations

The database schema is also a useful resource.


http://localhost/schema/

ClearSCADA Advanced Training Course 51

Using PickType 8 – Write to Registry


The examples bellow will write to the local PC’s registry

• PickType = 8

• PickParam = ‘TestRegistryValue(0)’
– This will write 0 into the registry key TestRegistryValue
– It passes the name of the key and also the number to write into
the key.

• PickParam = ".DemoMimic.Fullname" + ‘.Option(1)‘


– This will write 1 into the registry key determined in part by the
fullname of a database object with the text ‘.Option’. This
technique can be used in template instances to ensure a
meaningful and useful unique name for each instance.

ClearSCADA Advanced Training Course 52

26
Using PickType 1 – Object Menu
The examples bellow use methods on database objects

• PickType = 1

• PickParam = ".Test Point.ObjectLink"


– The object menu for the database object Test Point will be
associated with this object.

• PickParam = ".Test Point.ObjectLink“ + ‘?NoNotes&NoTrends’


– ? Means a method is following
– & used between each pick action to exclude.
– The object menu for the database object Test Point will not
include the notes of the trend options.

ClearSCADA Advanced Training Course 53

Using PickType 5 – Method


The examples bellow use methods on database objects
PickType = 5

• PickParam = ".Test Point 1.ObjectLink" + '?CurrentState&Value="1"'


– Hand control Internal Digital Point (Test Point 1) to 1.

• PickParam = ".Test Point 2.ObjectLink" + '?CurrentValue&Value="123"‘


– Hand control Internal Analog Point (Test Point 2) to 123.

• PickParam = ".Test Point 3.ObjectLink" + '?Control&Value="1"‘


– Control a DNP3 Binary Output Point (Test Point 3) to 1.

• PickParam = ".Test Point 1.ObjectLink" + '?Digital.Accept‘


– Acknowledge the Digital alarm for internal digital point (Test Point 1)

• PickParam = ".Test Point 4.ObjectLink" + '?Accept‘


– Acknowledge all alarms on a DNP3 Analog Input point Alarm (Test Point 4)
- there is multiple alarms – no change, Analog value alarm, out of service..
ClearSCADA Advanced Training Course 54

27
Using PickType 3,10,11 – Hyperlink
The examples bellow use Hyperlinks

• PickType = 3,10,11

The general format for clearSCADA displays is:


SCX:///LOCAL/<Database Class>/<path>

• PickParam = 'SCX:////AlarmList/Area="' + ".FullName" + '"'

– This will display alarms for a section of the database.


– If you have a template for your Waste Water pump station. You may
want to bring up an alarm list for you particular instance, so this will
use the FullName property to select your alarms of interest.

– Punctuation and spacing is important.


ClearSCADA Advanced Training Course 55

Add a Custom Title to a hyperlinked List

SCX:////List/Title="Custom Title"&InitialSQL="SELECT * FROM CMIMIC"

ClearSCADA Advanced Training Course 56

28
Formatting Strings with Special Characters
Some times a string may need to include single or double quotes.

• To include a single quotation, it is entered using two single quotations.

• To include a double quotation, it can simply be added into the string.

An example would be to display the following text. “Play” is the name of an


object in the database.

Don’t “Play” Double Quotes & Single


Quote to finish the string
'Don''t ' + '"' + ".Play.Name" + '"'
or Double Quotes inside
'Don''t "' + ".Play.Name" + '"' single Quotes

Two Single Quotes


ClearSCADA Advanced Training Course 57

Formatting Strings with Special Characters


Using CHR(13) is a good way of improving the appearance of tooltips.

The following example shows a multi line tooltip.

ClearSCADA Advanced Training Course 58

29
Use of the Indirect tag [] Brackets
Sometimes the Indirect tag Square brackets are required.
Indirect tags allow you to use the values of other tags to determine the value of a
tag. This is especially useful when you need a tag to always represent a specific
property, but for different database items.

NOT ["Parameter:MyPointControl.FullName" + '.CheckAccess('‘CTL'')']

In the above example the Item in double quotes is evaluated first, Then a string is
appended, then the items in the square brackets are evaluated and finally the
result is inverted with the NOT Function.

["Parameter:MyPointStatus.ParentGroupName" + '.Name']

This example uses the parent group name (Fullname) to extract the .Name
property.

ClearSCADA Advanced Training Course 59

Custom User Methods


Custom Methods can be configured on objects that appear when the
object menu is displayed.

.$ notation refers to the item itself.


Note: This user method is also selectable
from the pick action configuration wizard.

ClearSCADA Advanced Training Course 60

30
Practical Exercise
Time Allowed: 30 Minutes

Aim:
Part 1. Create a button on a mimic that will display alarms in this area of the
database. (Area as defined by the database structure and location of the
mimic button)

Part 2. Copy and paste the Mimic button to another area in the database
tree structure and confirm that it works.

ClearSCADA Advanced Training Course 61

Alarms
Too often operators and engineers that are managing critical infrastructure
are continually chasing alarms that are generated by their HMI or
SCADA software leaving little time for monitoring the control system and
being proactive about the process. Let’s take a look at the most common
cause for this situation and provide some solutions for improvement.

According to EEMUA 191, 150 alarms per day (one every ten minutes)
presented to an operator are "very likely to be acceptable"; and 300
alarms per day (an alarm every five minutes) is considered
"manageable".

It can be said – “A good operator is a relaxed operator.”

This plants
runs itself!!!

ClearSCADA Advanced Training Course 62

31
Alarm Plan / Specification
Its fundamental to have a overall plan or specification for each step in
building a system for alarms. EEMUA 191 can provide some guidance in
this area.

ClearSCADA Advanced Training Course 63

Nuisance Alarms
These are alarms that trigger when no abnormal condition
exists or when no operator action is required.

For every alarm condition, the operator must know what to


do!

Solution. Get rid of these alarms. If it is important that the


condition is logged for audit trail purposes then log to the
event journal.

ClearSCADA Advanced Training Course 64

32
Shelving Alarms
Shelving is a facility where the operator is able to temporarily prevent an
alarm from being displayed to him when it is causing him nuisance. A
shelved alarm will be removed from the list and will not re-annunciate
until un-shelved.

This removes the clutter from alarm list that may distract the operator from
new alarms that may come in. Remember it is usual that high priority
alarms appear first in the alarm list then medium priority, etc. If a new
medium priority alarm comes in it may appear low in the list when in
reality it needs attention immediately.

Solution. Assuming that long term alarms are valid they could be ‘shelved’
or disabled so that they are removed from the active alarm list. Of
course you should have the ability to view these ‘shelved’ alarms on
separate lists and potentially have them automatically re-enabled after
preset time.

ClearSCADA Advanced Training Course 65

How to Disable Alarms


Alarms can be disabled either individually or by group. If a section of plant
has been removed from service then its easy to disable using the
Database explorer bar tree structure.

Alarms can be removed for a period of time before the reappear in the
system automatically. If equipment is brought back into service ahead of
schedule then it simply a matter of Enabling the alarms again.
Group Actions Individual Actions

Enter your duration in


OPC Time
ClearSCADA Advanced Training Course 66

33
Disable Alarms appearance
EEMUA 191 recommends that it is desirable that ‘shelved’ alarms are
displayed on plant mimic graphics in some low contrast color, so that
they are less obvious than normal alarms. We use the Color Palette to
determine this color.

ClearSCADA Advanced Training Course 67

Alarm Flood / Avalanche


One of the most dangerous and difficult to solve problems with alarm
systems, is the flood of alarms associated to a process event. Take for
example the loss of power at a pump station…...Then consider what
happens when power is lost to a whole region. You may get
consequential alarms from many devices such as motors, valves etc.

Solution. Suppress consequential alarms via PLC/RTU logic or use built-in


functions in SCADA.

! to the source as possible


Its always best to do this as close
0
01
A2
I’ve got 65
AD New

ar SC CRITICAL
Cle alarms
W
NE
ClearSCADA Advanced Training Course 68

34
Chattering Alarms
The definition of a chattering alarm is one that comes in and out of
alarm state 3 times per minute. Examples of this would be a high
level probe/paddle switch in a tank or simply noise on the analog
signal. You want to make sure it is tripped and not foam on top of
liquid that causes the alarm.
Leave
me alone

Alarm Setpoint Process signal

Chattering Alarms

Time

ClearSCADA Advanced Training Course 69

Chattering Alarms
Solution. This is a simple fix, add a dead-band or hold timer in logic in the
RTU or PLC controller.

Alarm Setpoint Process signal

Alarms
Deadband

Time

ClearSCADA Advanced Training Course 70

35
Quality of Alarms
m s!!! in a day, some would
If the operator is dealing with more than 300ralarms
l a
A .
9
argue that the control system is not being managed.
t
benchmarking and analysis is required to determine o r d o ……
Some
cause and
ra
corrective action. e ope
One Common causes. W hat
will th
• Analog points having all the
alarm limits configured because Everything
the SCADA software has the is normal
capability.

ClearSCADA Advanced Training Course 71

Alarm Severities
Ru Critical
le
Cr fT o
ca iti hu
l– mb
Hig .
h– 1p
Increasing 5% High Me
diu
1p
er
er
ev
PriorityL en
m sh t
degree of ow –1 ift
p
–6 pe er
operator pe rh op
rh ou era
15% Medium ou rp tor
response rp er
Priority er op
op era
required era to r
tor

80% Low Priority


Informative

ClearSCADA Advanced Training Course 72

36
Alarm Severities
The severity of a alarm should be decided based on a number of criteria.
Generally the higher the severity the closer to the top of the alarm list it will
appear.
• The likely urgency “How soon do I need to act”
I need all
• The consequences of inaction. the help I
• Loss of equipment, product – Cost to Business $$$ can get
• Safety
• Environmental impact.
Impact Critical Environment
$$$$$
High
Medium
Low

Less Time More


ClearSCADA Advanced Training Course 73

Changing Alarm Severities


Severity levels on alarms can be changed. Using the Alarm Redirection –
Change Priority action.

Generally the action would be to increase the severity of an alarm based


upon time or some change in the process.

Central Control room operators may be handling alarms that are high …
critical severities leaving local operators to action Low … critical alarms.
Elevating the severity level could make the alarm visible to the central
control room operator.
Impact Critical Control
room
High Operator Local
Medium Operator
Low

LessClearSCADA Advanced
Time Training Course
More 74

37
1000! Alarm Severities
Alarm Severities can also be used to group alarms. In addition to the
normal operator alarms the following could be created.

SMS Severity
Email Severity
Environmental Severity
Fresh water Alarms
Plant ABC Alarms
Region XYZ Alarms
...

Just another way of Managing Alarms…….but you must have a plan!


ClearSCADA Advanced Training Course 75

Operator Feedback
Operator feedback is an important tool in management of alarms. The best
way to get this feedback is when acknowledging alarms.
Enforce Acknowledgment with feedback for a period of time with these
comments selectable.

This simple survey over time provides helpful information for managing
your plant.

ClearSCADA Advanced Training Course 76

38
Operator Feedback
Action Required – Useful alarm, something is required.
Check Required – Useful, Operator alerted to give some close attention to
plant.
Noted – Useful, Operator is made aware of a potential situation.
Little Use – No real use, reassess these alarms
Nuisance – No use, reassess these alarms.

That’s what I think!!!

ClearSCADA Advanced Training Course 77

Management tools
Monitor your 10 minute alarm raised count and trend this so that you can
review this KPI.

Monitor the time to acknowledge alarms. The ones that take the longest
time are probably ambiguous….Does the operator know what to do?

Monitor the most frequently occurring alarms…..Do they need rethinking?

Number of standing alarms and Duration in alarm…..Why?

Benchmark you system using the above KPI’s….then you can make
informed decisions.

Remember these are only tools….To be really useful they must be used.

ClearSCADA Advanced Training Course 78

39
Alarm Management
This is an ongoing task.
Be proactive…..recognize trends, replace old equipment, grow your system
carefully.
Alarm Management is everyone’s responsibility…not just one person.

ClearSCADA Advanced Training Course 79

Alarm Presentation
• Understand Operator Tasks
– Enlist Help of Operators
– Operators Look at Things Differently from Engineers
– OK to Have Same Info on Multiple Displays

• Make Displays Readable


– Consistent Color Scheme and Layout
– Keep Simple - Not Too Busy
– NO ANIMATION (When Status is OK)

ClearSCADA Advanced Training Course 80

40
Gray Backgrounds for DCS Operating Displays?
• http://www.controleng.com/industry-news/top-stories/single-article/gray-backgrounds-for-dcs-operating-
displays/f93ecf3002.html
• LOTS OF INFORMATION HERE
• http://colorusage.arc.nasa.gov/

• With all the sophisticated and cool graphic capabilities available today, why does the ASM Consortium
recommend such muted and boring colors? The human factors behind the selections.
• Peter Bullemer, Dal Vernon Reising, and Jason Laberge, ASM Consortium

• 02/17/2011

• In a control room environment, operating displays serve an important role in supporting operator situation awareness and
executing actions to prevent and respond to abnormal plant situations. Operator situation awareness involves orienting
one’s self to several factors:
• • The presence and location of a disturbance;
• Comprehending the nature of the underlying plant conditions;
• Projecting the impact of the disturbance into the immediate future; and
• Analyzing all these to determine the appropriate course of action.
• The operator display design directly impacts the speed and accuracy of an operator performing these abnormal situation
management activities.
• The recent evolution of distributed control systems (DCS) to PC-based computer platforms has been accompanied by a
significant change in capabilities to present data and
ClearSCADA information
Advanced to operators.
Training Course In particular, the ability to render those 81
first-generation color schematic displays has evolved from the limited use of eight colors with full and half intensity to

A Busy Graphic
ON OFF ON OFF ON OFF
ON OFF ON Alarm
OFF ON Presentation
OFF
81FC2105 10
Z
ON OFF ON OFF ON OFF 100 81PI2102
Z 890 V-310 81LC2102 75 81FC2109
51 81PI2103 Z
81FC2101 800 FC2106 5

Z 650 81FC2103 C V-320


52
200 FC2110 LC2104
81FC2102 3 390
150 1240
81FC2107
C
81PI2101 1 Z
V-301 3
50
81LC2101 48
0 150
2
81LC2103
81FC2111 Z
81FC2104 46
0
Z 81FC2112 Z
81LC2105
300
640
81FC2108
840

41
Now What’s Changed?
ON OFF ON OFF ON OFF 10
81FC2104
ON OFF ON OFF ON OFF Z
ON OFF ON OFF ON OFF 100 81PI2103
Z 890 V-310 81LC2103 75 81FC2104
51 81PI2104 Z
81FC2104 750 FC2106 5

Z 890 81FC2104 C V-320


52
200 FC2110 LC2104
81FC2104 3 390
150 1240
81FC2104
C
81PI2101 1 Z
V-301 3
50
81LC2101 48
0 150
2
81LC2102
81FC2104 Z
81FC2104 46
0
Z 81FC2104 Z
81LC2105
300
640
81FC2104
840

Improved for Alarm Management


10
Interlock Status OK Z

Z 890 100
5
143
800 51 Z
220
A 75
Z 650 247
200 52
1240 350
390
A
150
Z
135 840
50 440 150

Z
48 550
Z
A 300
50 Z

Show Show Show B 640


Tags Units Eq. Nos

42
Anything get your attention?
10
Interlock Status OK Z

Z 890 100
5
143
900 51 Z
220
A 75
Z 650 247
100 52
1240 350
390
A
150
Z
135 840
50 440 150

Z
48 550
Z
A 300
50 Z

Show Show Show B 640


Tags Units Eq. Nos

Alarm OPC Properties


OPC Group properties provide some valuable information regarding alarm
conditions that may be present in the database tree structure.

A good place to start is to


look at what happens
during a drag and drop
operation.

ClearSCADA Advanced Training Course 86

43
Alarm OPC Group Properties
OPC Group properties provide some valuable information regarding alarm
conditions that may be present in the database tree structure.

ClearSCADA Advanced Training Course 87

Alarm Summary
In summary, alarms are a critical component for the SCADA system and if
poorly configured give operators grief. I hope some of these concepts
help you with alarm management.

ClearSCADA Advanced Training Course 88

44
Alarm Practical
List Disabled alarms.
Consequential alarms
Alarm Statistics
Alarm acknowledge with feedback
Create a severity level that’s only visible to user AlarmMan

ClearSCADA Advanced Training Course 89

The Historian
ClearSCADA has its own proprietary database that is optimised to suit time
stamped data.

When a system is configured as a multi-server system the database items


are replicated automatically.

The database is open and can be accessed using ODBC/SQL,


COM/Automation and XML/SOAP.

Things that are stored in the historian are:


Configuration (Points, Mimics, RTU Configurations, Alarms Logic)
Current data from the field
History of data Values
History of events

ClearSCADA Advanced Training Course 90

45
Overview
Accessing Current Values and Configurations have already been covered.
In this section we will look at accessing historic data and events from
within the ClearSCADA environment.

Trends are a primary use of historic data. Some things can’t be presented
using a Trend object. An example may be comparing the Pump Runtime
in the last 24hrs from all the sewerage pump station in the system.

This historic information is not usually used by operational people. It is


often the Management / Administration staff that want this type of
information. It is possible that this data will be analysed on the
permanent standby server in the system. It is also possible that this
server may keep the historic data online for a longer period of time.

ClearSCADA Advanced Training Course 91

KPI’s
KPI – Key Performance Indicator

Both of these are terms that Managers like to use. The SCADA system is
an ideal way to present this information and it needs to be considered as
an investment not a cost.

They are methods of Benchmarking your operation weather it be the total


number of widgets produced or the performance of a single pump
station.

The key things to remember, have real-time accurate data and present it in
a clear manner so that everyone can understand it. If this is achieved It
means organisations can make accurate reliable decisions about the
future, focusing efforts to overcome weaknesses.

ClearSCADA Advanced Training Course 92

46
KPI – Key Performance Indicators
For this data to be of any use it must:
– Quantify the success of the organisation
– Identify weaknesses
– Be measurable
– Be able to be compared to goals

Many organisations/departments/personnel will have different KPI’s


School – Ex Students in the workforce, Ex Students at University, Number
of enrolments.
Manufacture – Number of Widgets produced, Quality.
Service – Number of Faults, Downtime
Accounting – Cost per Hour.

It has been said: You cannot manage something you cannot control, and
you cannot control something you cannot measure

ClearSCADA Advanced Training Course 93

Collected Data must be easily Understood

Number of Alarms at Sewer Pump Stations yesterday.

The numbers are meaningful but the bar-graph may give an immediate
indication of the area for Maintenance personnel to target.

ClearSCADA Advanced Training Course 94

47
Collected Data must be easily Understood

ClearSCADA Advanced Training Course 95

Make it easy for users to retrieve the Data


Using the Historian its easy to get
accurate information.

This data was extracted from just a


single digital point (Pump Running)

Queries are run on the historian that


the user is able to dynamically
adjust. In this case clicking on the
spanner alters the Interval.

ClearSCADA Advanced Training Course 96

48
Be consistent
This is an example that extracts historic
information regarding a tank level.

The information being returned is


different but the operator dialog is
the same.

ClearSCADA Advanced Training Course 97

How to extract the historic data


There are several ways to extract information:
• Displaying the information directly.
<Item>.<Aggregate>:<Start Date>:<Interval>
".DriveRun;Range;D;1D"
This will result in the difference between the Min and Max Value for
the time specified.
The configuration of this is via the a expression wizard.
This will provide a list of all aggregates.

".DriveRun.Historic.ProcessedValue (‘D-1D', ‘D+0D', 14)“


This will give the same result using an alternative method.

Online Help:
Core Reference | Mimics | Animations | Animations for Historic data

ClearSCADA Advanced Training Course 98

49
Practical Exercise
Time Allowed: 15 Minutes

Aim:
Part 1. Using AI1 display the Max and Min Values in the last minute.

Part 2. Using DI1 display a “count of values” in the last minute.

Part 3. If we wanted display the number of starts for a pump DI1 in the last
minute. What needs to be done?

ClearSCADA Advanced Training Course 99

How to extract the historic data


There are several ways to extract information Cont:

• Use a SQL query and present the information in a list.


• An SQL Query can be performed from with in the ST Logic
• An SQL Query can be performed from within client side scripting.

• Custom Historic Aggregates


• A customizable view

ClearSCADA Advanced Training Course 100

50
What Is the SQL Language?
• It is a standard computer language for accessing and
manipulating databases.
• stands for Structured Query Language
• allows you to access a database
• can execute queries against a database
• can retrieve data from a database
• can insert new records in a database
• can delete records from a database
• can update records in a database

ClearSCADA Advanced Training Course 101

SQL Databases
• The ClearSCADA database contains more than one SQL
table. Each table is identified by a name (e.g. “Cmimic"
or “CPointAlg"). Tables contain records (rows) with
data.
• Below is an example of an ClearSCADA table called
“CDBSERVER":

ClearSCADA Advanced Training Course 102

51
Selecting Data from a Table
The select statement is used to query a database table.
Here is the format of a simple select statement:

select "column1" ,"column2" from "tablename“

The column names that follow the select keyword determine


which columns will be returned in the results.

select * from "tablename“

A "*" to select all columns.

The table name that follows the keyword from specifies the
table that will be queried to retrieve the desired results.
ClearSCADA Advanced Training Course 103

Selecting Data from a Table


The following Example when entered into a embedded list
will display a list of all (*) the columns from the table
CMIMIC

SELECT
*
FROM
CMIMIC

An easy way to bring up this query is to change the Explorer Bar to


the Query view | Browse the tables section for CMIMIC. Press Ctrl
and Double Mouse Click. The query results should be displayed.
The SQL query can by copied by selecting View | SQL and placed
into an embedded list.
ClearSCADA Advanced Training Course 104

52
Altering the SELECT Statement
If we wanted to specify the columns to be displayed the
SELECT portion of the query needs to be altered.

The database field or Column names can be found browsing


the Schema. http://localhost/schema
SELECT
"FullName", "Size“
FROM
CMIMIC

The altered query will provide a display similar to the example


above. Note the column names are different, Why?

ClearSCADA Advanced Training Course 105

Using an Alias Name


The query can be altered so that the column names / tables
use an Alias. This allows a customized Column name that
has spaces.
SELECT
M."FullName" AS “Mimic Name", M."Size" AS “Bytes used“
FROM
CMIMIC AS M

The altered query will provide a display similar to the example


below.

ClearSCADA Advanced Training Course 106

53
Static Columns
If your query has a large number of columns, you may
require the left hand column(s) to be static. This can be
done by adding the tilda ~ symbol to the alias name.

SELECT
"FullName" AS “Mimic Name", "Size" AS “~Bytes used“
FROM
CMIMIC

The altered query will provide a display similar to the example


below.

ClearSCADA Advanced Training Course 107

Formatting Column Names


A new line can be entered in an alias name using a \n. This
allows the column header to span multiple lines.

SELECT
"FullName" , "Size" AS "The size of\nthe Document"
FROM
CMIMIC

The altered query will as follows.

ClearSCADA Advanced Training Course 108

54
Right-Justify Row Values
Row Values can be right-justified by appending the greater
then symbol to the alias.

SELECT
"FullName" , "Size" AS “>The size of\nthe Document"
FROM
CMIMIC

The altered query will as follows.

ClearSCADA Advanced Training Course 109

CASE Statement
The following Query uses the case statement to indicate Yes or No if the
objects configuration is valid or not.

SELECT TOP( 5 )
"Name" AS "~Name", "Id",
CASE "ConfigValid" WHEN TRUE THEN 'Yes' ELSE 'NO' END AS
"Configuration Valid"
FROM
CDBOBJECT
ORDER BY
"Configuration Valid" ASC

ClearSCADA Advanced Training Course 110

55
CASE Statement
By adding an additional CASE statement we could manipulate the
Background colour of the item’s of interest. Note that this must appear in
the query prior to the Yes/No writing to the cell with the Yes/No.

SELECT TOP(8)
"Name" AS "~Name",
CASE "ConfigValid" WHEN TRUE THEN 65280 ELSE 255 END AS "{Background}“,
CASE "ConfigValid" WHEN TRUE THEN 'Yes' ELSE 'NO' END AS "ConfigValid"
FROM
CDBOBJECT
ORDER BY
"ConfigValid" ASC

ClearSCADA Advanced Training Course 111

Displaying Hidden Metadata Column


Sometimes your query may be required to show hidden
metadata column. For example the object ID. The following
query can be used to display the ID Column.

SELECT
FULLNAME, ID, ID
FROM
CDBPOINT

ClearSCADA Advanced Training Course 112

56
Hide a Column
Sometimes your query may be required to hide a column.
This can be used if the column is required for the query but
you don’t want to display this information. To hide a column
use the underscore character as the first character of the
alias name. The following example hides the Fullname
Column.

SELECT
"FullName" AS "_FullName", "CurrentValueFormatted"
FROM
CDBPOINT

ClearSCADA Advanced Training Course 113

Limiting the number of rows


You may want to have a query that returns only a few items
eg The last 10 alarms. Returning 1 mimics can be done by
adding TOP(1) to the select statement.

SELECT TOP(1)
"FullName" AS “Mimic Name", "Size" AS “~Bytes used“
FROM
CMIMIC

The altered query will provide a display similar to the example


below.

ClearSCADA Advanced Training Course 114

57
The ORDER BY Statement
The returned table of information can be ordered. This
could be an alphabetical, size, or time sort and can include
multiple columns. The ORDER BY Statement is used for this.
DESC will provide a descending list, ASC will be ascending.

SELECT TOP(1)
"FullName" AS “Mimic Name", "Size" AS “~Bytes used“
FROM Note: “~Bytes used” could be
CMIMIC replaced by the column number 2
ORDER BY
"~Bytes used" DESC

The altered query will provide a display similar to the example


above. Showing the largest Mimic in the system.
ClearSCADA Advanced Training Course 115

The WHERE Statement


The WHERE Statement allows a filter to be applied to the table,
limiting the rows of information returned. The filter can operate on
any of the columns of information eg time for a query on the
CDBEVENTJORNAL. The example below return the 5 largest sized
Mimics that have Training in the FullName field in the database.

SELECT TOP(5)
"FullName" AS “Mimic Name", "Size" AS “~Bytes used“
FROM Note: % is used to
CMIMIC allow any characters
WHERE before or after
( "Mimic Name" LIKE '%Training%' ) Training.
ORDER BY
"~Bytes used" DESC

The altered query will provide a list showing the 5 largest Mimic’s in the
system. ClearSCADA Advanced Training Course 116

58
Wildcards
In the WHERE statement expressions are often used to filter. It is
often the case that a string value is compared to a pattern.

Valid Wildcards are:

% (Percent) - Stands for any sequence of characters

_ (Underscore) - Stands for any single character

Examples
WHERE ( “FullName" LIKE '%Training%' )
WHERE ( “FullName" LIKE 'Training%' )
WHERE ( "Name" LIKE 'Drive ____ RUN' )

4 Underscores = Any 4 character / Number drive


ClearSCADA Advanced Training Course 117

Changing the SQL Query using an animation expression


Every Static configuration option is able to be overwritten
using an animation expression, the SQL query is no
exception.

This is often done if the expression needs to change


dynamically.

The query needs to be entered as a string. It is


recommended to use the following approach:
– Make sure that the query is working firstly.
– Convert the query to a string – remove enter, single
quotations need to have 2 single quotations, place single
quotes at the start and end of the string.
– Change the query dynamically (See the following slides)

ClearSCADA Advanced Training Course 118

59
Changing the SQL Query using an animation expression
The following query will list mimics that contain “Training”
in the full name.

SELECT
"FullName", "Size"
FROM
CMIMIC
WHERE
( “FullName" LIKE '%Training%' )

When altered to a string and used as a animation


expression it would as follows.

'SELECT "FullName", "Size" FROM CMIMIC WHERE (


"FullName" LIKE ''%Training%'')'
ClearSCADA Advanced Training Course 119

Changing the SQL Query using an animation expression


Even easier….Right mouse click and choose Generate
Animation and the Animation expression will be populated
with the correctly formatted expression.
Ti p
:R
igh
tM
ou
se
Cl
ic k

ClearSCADA Advanced Training Course 120

60
Improving the Readability of the SQL Expression.
When the SQL query is entered as a single string it can be
difficult to understand because new lines cant be entered.

However a new line can be entered between the + symbol.

Construct the query into separate lines and join the strings
together using the +.

Joining the query lines together as shown below can


improve the readability.

ClearSCADA Advanced Training Course 121

Changing the SQL Query dynamically


To change the animation expression string dynamically it
could be altered as follows:

Original SQL Query String

'SELECT "FullName", "Size" FROM CMIMIC WHERE (


"FullName" LIKE ''%Training%'')‘

Modified SQL Query String. This string will dynamically change


depending on the location with the database.

'SELECT "FullName", "Size" FROM CMIMIC WHERE (


"FullName" LIKE ''%' + ''.FullName'' + '%'')'

ClearSCADA Advanced Training Course 122

61
Practical Exercise
Time Allowed: 60 Minutes

Aim:
Part 1. Display a list of Events in the system from CDBEVENTJOURNAL
Part 2. Column Name & Record time to be fixed
Part 3. Filter the Events as follows:
The Training section of the database
Events that occurred in the last minute
Events that include the text “Alarm raised” in the message field
Part 4. Order the results by Record time and SeqNo

Part 5. Optional. Display a list of Disabled Alarms using a SQL animation


expression. Note: You will need to use the CALARMOBJECT Table.

ClearSCADA Advanced Training Course 123

SQL Syntax commands


Aggregate functions (Simple Functions)
Return a single value based upon a set of other values. If used among
many other expressions in the item list of a SELECT statement, the
SELECT must have a GROUP BY clause. No GROUP BY clause is
required if the aggregate function is the only value retrieved by the
SELECT statement

Function Usage
Computes the average value of a column by the
AVG(expression)
expression
COUNT(*) Counts all rows in the specified table or view
MIN(expression) Finds the minimum value in a column by the expression
MAX(expression) Finds the maximum value in a column by the expression
SUM(expression) Computes the sum of column values by the expression
ClearSCADA Advanced Training Course 124

62
Count Function
In order to count the number of items returned by a query
the Count function can be used.

SELECT
COUNT(*) AS "Number of Mimics"
FROM
CMIMIC

The altered query will provide a display similar to the example


Below. Showing the number of Mimics in the System.

ClearSCADA Advanced Training Course 125

Grouping
Usefull for counting the number of items within Groups of
things that have something in common.

SELECT
PARENTGROUPNAME, COUNT(*) AS "Number"
FROM
CMIMIC
WHERE
( "FullName" LIKE '%SQL Training Group%' )
GROUP BY
PARENTGROUPNAME
ORDER BY
"Number" DESC

ClearSCADA Advanced Training Course 126

63
Grouping Example 1

ClearSCADA Advanced Training Course 127

Grouping Example 2

ClearSCADA Advanced Training Course 128

64
Expressions
In order to count the number of items returned by a query
the Count function can be used.

SELECT
"Name", "Id", "LastLogonTime", "LastLogoffTime", ( { FN
TIMESTAMPDIFF( SQL_TSI_SECOND, "LastLogonTime",
"LastLogoffTime" ) } ) AS "Duration (sec)"
FROM More Work Here

CDBUSER
SELECT TOP( 10 )
"RecordId", "SeverityDesc" AS "~SeverityDesc", "RecordTime" AS "~Occured Time", "ReceiptTime", ( { FN
TIMESTAMPDIFF( SQL_TSI_SECOND, "ReceiptTime", "ReceiptTime" ) } ) AS "Delay (sec)", "Source", "Message"
FROM
CDBEVENTJOURNAL
WHERE
( "~Occured Time" BETWEEN { OPC 'H-11H' } AND { OPC 'H+1H' } ) AND ( "Message" LIKE '%Alarm raised%' )

The altered query will provide a display similar to the example


Below. Showing the number of Mimics in the System.
ClearSCADA Advanced Training Course 129

Practical Exercise
Time Allowed: 20 Minutes

Aim:
Part 1. Using the material learn so far, Count the number of Pump Starts
during the last minute. Note: Pump Starts could be any one of your
digital input points previously configured.

Part 2. Count the number of Alarms Raised in the training section of your
database during the last minute.

ClearSCADA Advanced Training Course 130

65
SQL Query in ST Code
Some times it may be required to perform a query on the database and not
have the results placed in a list object.

For Example
You may be required to count the number of Alarms raised each day for
each sector of your organization and provide this information to an
internal analog point.

This could be done using the IEC61131.3 Logic language ST (Structured


Text)

The Scan time of the ST Logic should also be considered…the default of 1


Second may not be the most efficient use of computing resources.

ClearSCADA Advanced Training Course 131

Using SQL to Count Mimics


The following SQL Code will return a number of the mimics in the system.

SELECT
COUNT(*)
FROM
CMIMIC

The following slide will demonstrate how this code can be placed into ST
Logic

ClearSCADA Advanced Training Course 132

66
SQL Query in ST Logic
TYPE
Table : STRUCT
Count : DINT;
END_STRUCT;
END_TYPE

PROGRAM MimicCount

VAR
MyCount AT %S(SELECT COUNT(*) FROM CMIMIC) :RESULTSET OF Table;
END_VAR

VAR
MyMimicCount AT %M(.Mimic Count) : DINT;
END_VAR

MyMimicCount := MyCount.Value.Count;

END_PROGRAM ClearSCADA Advanced Training Course 133

SQL Query in ST Logic with Parameters


To enter multiple parameters in an SQL query within an ST program, you need to
use the ? character to represent the value of each parameter and the
WITH_PARAMS keyword to define the parameters
TYPE
Table : STRUCT
Count : DINT;
END_STRUCT;
END_TYPE

PROGRAM MimicCount

VAR_INPUT
MimicName : STRING;
END_VAR

VAR
MyCount AT %S(SELECT COUNT(*) FROM CMIMIC WHERE Name LIKE ?) :RESULTSET OF Table WITH_PARAMS MimicName;
END_VAR

VAR
MyMimicCount AT %M(.Mimic Count) : DINT;
END_VAR

MyMimicCount := MyCount.Value.Count;

END_PROGRAM

ClearSCADA Advanced Training Course 134

67
Practical Exercise
Time Allowed: 20 Minutes

Aim:
Part 1. Using the material learn so far, Count the number of Alarms Raised
in the training section of your database during the last minute using
Structured text.

Part 2. Display the number on a mimic.

ClearSCADA Advanced Training Course 135

Other Tools
The SCX/ClearSCADA Database can be connected remotely.

One free tool that can be used is Database Browser.

ClearSCADA Advanced Training Course 136

68
Database Browser Exercise
Time Allowed: 20 Minutes

Aim:
Explore the Database tables remotely and construct a simple Query.

Exercise: Follow the steps in Chapter 08 of the Training Notes

ClearSCADA Advanced Training Course 137

SQL Advanced Functions


Joins and Keys (Advanced Functions)
Sometimes we have to select data from two or more tables to make our
result complete. We have to perform a join.
Tables in a database can be related to each other with keys. A primary
key is a column with a unique value for each row. Each primary key value
must be unique within the table. The purpose is to bind data together,
across tables, without repeating all of the data in every table.
Join Syntax
(Type of join ) JOIN (table 1/2) ON (table 1/2).keyfield =
(table 1/2).foreign_keyfield
Joins two separate tables together with a common key (column) to
form one table.

ClearSCADA Advanced Training Course 138

69
Data Grids or Data Tables
These are two different objects within ClearSCADA

Data Grid: Provide summaries of data already located within the


database. (Links to data within the database)

Data Table: Contain data fields that are updated from logic

Need to have some practical built around these!!!

ClearSCADA Advanced Training Course 139

Example Tables
When Joining Tables in the following slides we will be using these
Tables. These simple tables can be easily made using New | Other |
Data Grid.

Table A Table B
ID Name ID Name
1 Pirate 1 Joker
2 Monkey 2 Pirate
3 Ninja 3 Yoda
4 Captain 4 Ninja

ClearSCADA Advanced Training Course 140

70
INNER JOIN
Inner Join produces only the set of records that match both Table A and Table B.
The Join type keyword is optional. When its not used the default is INNER.

ID Name ID Name
1 Pirate 2 Pirate Table A Table B
3 Ninja 4 Ninja

Select
*
FROM
TableA JOIN TableB ON TableA.”Name” = TableB.”Name”

ClearSCADA Advanced Training Course 141

LEFT OUTER JOIN


All rows from the left hand and right hand table where the constraint clause(s)
are true plus all rows in the left hand table not matching the constraint
clause.

ID Name ID Name
1 Pirate 2 Pirate
2 Monkey ---------- ----------
Table A Table B
3 Ninja 4 Ninja
4 Captain ---------- ----------

Select
*
FROM
TableA LEFT OUTER JOIN TableB ON A.”Name” = B.”Name”

ClearSCADA Advanced Training Course 143

71
LEFT OUTER JOIN
To produce the set of records only in Table A, but not in Table B, we perform the
same Left outer join, then exclude the records we don’t want from the right
side via a where clause.

ID Name ID Name
2 Monkey ---------- ---------- Table A Table B
4 Captain ---------- ----------

Select
*
FROM
TableA LEFT OUTER JOIN TableB ON TableA.”Name” = TableB.”Name”
WHERE
Tableb.”Id” IS null
ClearSCADA Advanced Training Course 144

CROSS JOIN
A cartesian product join, returning each row from the left hand table
combined with each row from the right hand table. The number of
rows returned is the product of the number of rows in the left hand
table and the number of rows in the right hand table.

Because this joins everything to everything the resulting table would be


4 * 4 = 16 Rows. This could be a very dangerous join for large
tables.

Select
*
FROM
TableA CROSS JOIN TableB

ClearSCADA Advanced Training Course 146

72
The -> dereference operator
The -> is a dereference operator and so allows you to follow a reference field,
such as the CDBHistoric.Id field, to the table that it references (CDBObject
in this case) and then use any of the properties on that new table.
• It's a simpler version of an SQL JOIN however has more restrictions, for
example:
• * Only works on reference fields (but you can use multiple, e.g. Id-
>ParentGroupId->ParentGroupId->ParentGroupId->Name, as Name is not
a reference you must end it there)
• * Doesn't dynamically update in SQL lists on display
• * Only works for properties on the table it references, or tables above (up
towards CDBObject). For example in the query you're using you couldn't
use CurrentValueAsReal instead of FullName as the Id references the
CDBObject table and CurrentValueAsReal is at the lower CDBPoint table.
• (There may be others, these are just off the top of my head)
• An SQL join is not hindered with the first two, the third one just requires to
you be a bit more careful with the SQL JOIN functionality.
ClearSCADA Advanced Training Course 147

SQL Query – Extra Table Query


An extra Table Query can be added to the server configuration. This query
would then be available throughout the system on the object menu.

ClearSCADA Advanced Training Course 148

73
SQL Query – Extra Table Query
SELECT
Display Columns from the appropriate table indicated by the alias P or H

"P"."FullName", "H"."RecordId", "H"."RecordTime", "H"."FormattedValue", "H"."StateDesc",


"H"."QualityDesc", "H"."ReasonDesc", "H"."Foreground", "H"."Background", "H"."Blink"

FROM
CDBHISTORIC AS H JOIN CDBOBJECT AS P ON H.ID = P.ID

Inner Join: All rows from the Left Table and Right Table where the constraint clause is TRUE

WHERE
( "P"."FullName" LIKE '$FullName$%' ) AND "H"."RecordTime" BETWEEN {OPC 'H - 23 H'
} AND { OPC 'H - 23 H+1 D' }

The $FullName$ trip character instructs the system to insert the relevant value for the defined
field.

ClearSCADA Advanced Training Course 149

SQL Query – Extra Table Query


• Extra Table Queries allow filtered lists to be called from the context-sensitive
menu. These filtered lists can be tuned using Trip characters to refine the list
based on some property value of the object selected.
• Configure the Extra Table Queries in the Server Configuration Tool.
• Note:
• The server requires restarting before the configuration can be used.
• Trip characters are not supported in the Name property (text that appears on the
context-sensitive menu)

• Example
• I have created an Extra Table Query with the following settings:
• Property
Setting
Table CDBPoint Name Display all points with this name Title $Name$ Points
Query SELECT FullName AS "~FullName", Id, Foreground, Blink, Background,
CurrentStateDesc, CurrentValueFormatted, CurrentTime, CurrentQualityDesc,
SourceName, Source, ProcessCount, TypeDesc
FROM CDBPoint
WHERE Name = '$Name$'
This allows me to display a list of all points with the same name as the point that
I click on in the database structure (or mimic). I have named all the firmware
points "Firmware", using this Extra Table Query I can quickly get a list of all the
firmware points, showing me the various RTU firmware versions.
• This is what the context-sensitive menu looks like with the Extra Table Query
ClearSCADA Advanced Training Course 150
highlighted:

74
SQL Query – UNION Function
The UNION command is used to select related information from two tables,
much like the JOIN command. However, when using the UNION
command all selected columns need to be of the same data type.

( SELECT
*
Table A FROM
TableA)

UNION

( SELECT
Table B *
FROM
TableB)

ClearSCADA Advanced Training Course 151

Practical Exercise
Time Allowed: 20 Minutes

Aim:
Reproduce the alarm banner as a list on a mimic.

Exercise: Follow the steps in Chapter 07 of the Training Notes

ClearSCADA Advanced Training Course 152

75
DDE
DDE stands for Dynamic Data Exchange

It’s a protocol built into Microsoft Windows that


allows users to share data between
applications.

In our exercise we will use MS Excel

ClearSCADA Advanced Training Course 153

DDE
The data communication is established by a
simple, three-segment model.

Application – Service Name eg Excel


Topic – Group of information eg Sheet1
Item – Individual item of data eg R1C1

Excel|Sheet1!R1C1
ClearSCADA Advanced Training Course 154

76
DDE - Practical
Time Allowed: 20 Minutes

Aim:
Read and write to a Excel Spreadsheet using DDE.

Exercise: Follow the steps in Chapter 9 of the Training Notes

ClearSCADA Advanced Training Course 155

ODBC
ODBC is an abbreviation for Open Database Connectivity.

Its an interface for accessing databases using SQL Queries.

For us it a mechanism that allows ClearSCADA to read/write to other


databases.

Examples include:
MS Access
Excel
dBase
DB2
CSV or Text files

ClearSCADA Advanced Training Course 156

77
ODBC
The first step in configuring an ODBC Connection is done using the ODBC
Data Source Administrator that can be found under Administrative tools
in the control panel.

ClearSCADA Advanced Training Course 157

ODBC Objects
The following objects are available to be used.

Connection – This defines the access properties for the other database
that is being accessed. Note the DSN must be a System DSN.

Query – This SQL Query is used to define the requested data block and
how often that request occurs.

Point – This object defines an individual point of data.

Note: These Objects all link together in a similar method to configuring a


PLC or RTU Point in the database.

ClearSCADA Advanced Training Course 158

78
ODBC - Practical
Time Allowed: 60 Minutes

Aim:
Part 1 – Read and write to a CSV Text file

Part 2 – Read from an Excel file into ClearSCADA and using Excel read
from our ClearSCADA Database.

Exercise: Follow the steps in Chapter 10 of the Training Notes

ClearSCADA Advanced Training Course 159

SMS - Alarm Redirections


The Pager driver has the ability to Send SMS messages via a GSM Modem
attached to the server serial port.

These messages can be received by a normal mobile phone that most


people in the modern society carry and use.

This provides a mechanism for the mobile user to be informed by the


SCADA system wherever they may be located.

Alarm redirections can be initiated from individual objects or from Group


objects. When configured on a group object all alarms within the group
are redirected.

ClearSCADA Advanced Training Course 160

79
Command Processor
The command processor provides a mechanism for the remote user to
send commands via SMS into the SCADA system.

Examples:
Acknowledge an alarm
Tune a high level alarm threshold from 80% to 85%
Start an flood pump
Execute some logic
Request System information

Any Method on any object can be performed….So what do you need to do!

ClearSCADA Advanced Training Course 161

Command Processor Security


Commands received by the SCADA system are subject to the normal
Security permissions and user profile.

SMS phone number must be known by the system otherwise the Guest
user profile is used.

User profile must have the ability to process SMS commands.

User Profile or User Group must have the required Security permissions to
be able to perform the Action on the database objects.

The Event log will track these actions.

ClearSCADA Advanced Training Course 162

80
Calendar Objects

The calendar object allows special days to be programmed in a very visual


environment…Alarms that occur on these days can be handled
differently. ClearSCADA Advanced Training Course 163

User Rosters
A User Roster is a list of Users or User groups that can be selected as the
Duty User.

Methods are available on the User Roster object that allow the selection of
the Duty User.

OPC Properties are available on User Roster objects that reference the
Duty User. These can be used on mimics or in logic as required.

Alarms can then be redirected to the Duty User or User Group.

ClearSCADA Advanced Training Course 164

81
Alarm Flow in System
Alarm Conditions within Group

Alarm Group Redirection

Calendar

Work Hours Roster Non-Work Hours Roster


Phone1 Phone1
Phone2 Phone2
Phone3 Phone3
Phone4 Phone4
All Phones All Phones
ClearSCADA Advanced Training Course 165

Alarm Redirections & Command Processor


Alarm Redirections is a powerful tool that can be utilized within the product.

Key Points
Simple alarm redirection to GSM Phone.
Phone number +61
Security on Objects
Modem Choice

Redirection to User Group.

Calendar Object

Command processor

ClearSCADA Advanced Training Course 166

82
SMS Redirection - Practical
Time Allowed: 60 Minutes

Aim:
Send SMS Alarm information to a Mobile Phone.
Receive SMS commands from a mobile phone.
Configure a calendar object so that alarms are processed depending on the
day type.
Implement a User Roster to select the Duty User (SMS Recipient).

Exercise: Follow the steps in Chapter 11 of the Training Notes

ClearSCADA Advanced Training Course 167

Chapter ??

Client Side Scripting

ClearSCADA Advanced Training Course 168

83
Scripting
• Allows creation of more customized user interface
• Executed on the Client
• Uses the VBScript language
• Supported in both ViewX and WebX clients
• Called from a Pick Action
• Stored
– In the Mimic as Defined Functions
– In the Pick Action as a Code Fragment
– In a Script Library object
• Supports run-time debugging

ClearSCADA Advanced Training Course 169

Scripting (continued)
• Uses the Windows Scripting Engine
– Supports all standard VBScript objects and functions
• Additional functionality provided by ClearSCADA using VBScript
objects:
– Server – Interaction with the ClearSCADA Server
– Menu – Creation of custom menus
– Form – Creation of custom forms
– Mimic – Mimic navigation functions
– App – ViewX commands
– Globals – Registry commands and other global functions

Help on these functions is found in the online help.


Core Reference | Mimics | Scripting

ClearSCADA Advanced Training Course 170

84
Scripting – Example Server Functionality
• Reading from and writing to server object properties is simple

sub Main()
‘Read the state description of point named .Pump Running and display in a message
box

sValue = Server.GetOPCValue(“.Pump Running.CurrentStateDesc”)


MsgBox “The current state is “ + sValue

‘Set the on state description for the same point


Server.SetOPCValue “.Pump Running.State1Desc”, “Not Stopped”

end sub

ClearSCADA Advanced Training Course 171

Scripting – Example Menu Functionality


Creation of a custom menu.
sub MenuExample()

Menu.Init()
Set SubMenu1 = Menu.AddMenu("Option 1")
Submenu1.AddItem("Option 1 Item 1")
SubMenu1.AddItem("Option 1 Item 2")

Menu.AddSeparator

Set SubMenu2 = Menu.AddMenu("Option 2")


SubMenu2.AddItem("Option 2 Item 3")
SubMenu2.AddItem("Option 2 Item 4")

Menu.AddSeparator

Menu.AddItem("Item 5")
Note: A Case statement could
MsgBox "You Selected Item :" & Menu.Display(), 0, "Result"
be used here! (See Next Slide)

end sub
ClearSCADA Advanced Training Course 172

85
Scripting – Example Menu Functionality Cont.
Using the Case function to evaluate the custom menu.
'Menu.Display - displays menu, and returns integer value for selected item.
'Message box (0 - Ok button) (Message Box title will be Result)

Select Case Menu.Display()


Case 1
MsgBox "You Selected Item 1", 0, "Result"
Case 2
MsgBox "You Selected Item 2", 0, "Result"
Case 3
MsgBox "You Selected Item 3", 0, "Result"
Case 4
MsgBox "You Selected Item 4", 0, "Result"
Case 5
MsgBox "You Selected Item 5", 0, "Result"
End Select

ClearSCADA Advanced Training Course 173

Scripting – Example Form Functionality.


sub Control()
Using the Form function for data entry – Part 1.
'Initialize a form with the title "Change Point Value"
Form.Init("Change Point Value")

'Put some text on the form at x y position


Form.AddStaticText 2, 1, “Enter a new value for the Analog Point"

'Place a data entry box on the form at x y position with a width


set edtAO = Form.AddEditBox(46, 1, 8)

'Display a value in the data entry box


edtAO.Value = Server.GetOPCValue(".A1")

'Place some buttons on the form


set btnOk = Form.AddPushButton( 10, 4, "OK" )
set btnCancel = Form.AddPushButton( 30, 4, "Cancel" )

'Display the form


Form.Show()
ClearSCADA Advanced Training Course 174

86
Scripting – Example Form Functionality.
Using the Form function for data entry – Part 2.
'When OK is pressed update the value
if Form.Selection = "OK" then
‘Has the value changed
if Server.GetOPCValue(".A1") <> edtAO.Value then
‘Is the new value a Number
if IsNumeric(edtAO.Value) then
‘Write the new value (CDbl is a Conversion to data type Double)
Server.SetOPCValue ".A1", CDbl(edtAO.Value)
‘Confirmation message box regarding the change
MsgBox "Hand Control executed Value Change too " & Server.GetOPCValue(".A1")
else
‘Non Numeric information was entered
MsgBox "You must enter a number"
end if
else
‘You didn’t enter a new value
MsgBox "Value hasn't changed"
end if
end if
end sub ClearSCADA Advanced Training Course 175

Scripting – Using Arguments .


Control of point using arguments.
‘Pass in Arguments “Point FullName” and “Control Value” to this function to control a point
sub CtrlPoint(PointName, Value)

‘Locate PointName in the database


Set objPoint = Server.findobject(PointName)

‘Check the current users security permission for control on this object
If objPoint.CheckAccess("CTL") = FALSE then
MsgBox "Security Problem - Logged on user cant control this point“

else
‘Control the Point to the required Value
objPoint.interface.CurrentValue=Value ‘OR Server.SetOPCValue PointName, Value
end if
end sub

ClearSCADA Advanced Training Course 176

87
Scripting – Using Arguments .
Slider Control of point using argument. Part 1
‘Function Name and Argument to be passed into the function
Sub X_Slider(TextX)

'Initialise the form.


Form.Init("Click to move the Slider..")
Set Slider = Form.AddSlider( 1, 2, 50, 0)

‘Configure the form, We will enhance this soon! (Part 2)


Set OkButton = Form.AddPushButton(18, 6, "Ok")

'Place some text on the slider. We will add this soon! (Part 3)

'Display the form.


Form.Show()

'Check if the form was shut or close was pressed.


If Form.Selection = "" OR Form.Selection = "Ok" Then
Server.SetOPCValue TextX, CDbl(Slider.Value)
Exit Sub
End If
End Sub

ClearSCADA Advanced Training Course 177

Scripting – Using Arguments .


Slider Control of point using arguments. Part 2
'Configure the form – These enhancements make the slider range dynamic. As the ZeroScale and
FullScale of the point changes so does the slider.

‘The slider is added to the form Horizontal Position, Vertical Position, Width, Initial position
Set Slider = Form.AddSlider( 1, 2, 50, 0)

‘Adjust the slider Min & Max parameter to the points ZeroScale and FullScale value.
Slider.Minimum = Server.GetOPCValue(TextX & ".HanddressMinimum")
Slider.Maximum = Server.GetOPCValue(TextX & ".HanddressMaximum")

‘Add markers to the slider & set the width of the slider.
Slider.TickFrequency = 5
Slider. Width = 50

‘Position the slider


Slider.Value = Server.GetOPCValue(TextX)

‘Place an Button on the form Horizontal position, vertical position and text to display.
Set OkButton = Form.AddPushButton(18, 6, "Ok")
ClearSCADA Advanced Training Course 178

88
Scripting – Using Arguments .
Slider Control of point using arguments. Part 3
'Place some text on the slider….It looks a bit boring without it!

‘The text value will change dynamically depending on the ZeroScale & FullScale of the point.
Set text = Form.AddStaticText(3, 5, Slider.Minimum)
Set text = Form.AddStaticText(14, 5, Slider.Maximum*0.25)
Set text = Form.AddStaticText(25, 5, Slider.Maximum*0.5)
Set text = Form.AddStaticText(36, 5, Slider.Maximum*0.75)
Set text = Form.AddStaticText(47, 5, Slider.Maximum)

‘A short description and the name of the point being controlled.


Set text = Form.AddStaticText(5, 1, "Slider Control for point: " & Server.GetOPCValue(TextX &
".Name"))

ClearSCADA Advanced Training Course 179

Scripting – System Command.


Touch Screen Log on… Example.
‘This Cool Example of a System command activates a Windows screen based keyboard.
‘Use this on systems that have touch screen control!

Sub LogOn()
System("c:\windows\system32\osk.exe")
App.Logon()
‘Try App.ChangePassword
End Sub

ClearSCADA Advanced Training Course 180

89
Scripting - Exercise
Time Allowed: 60 Minutes

Aim:
Part 1 - We will use a script library object to perform methods on
multiple objects. Pass into the Script two digital point names and
two control values.

Part 2 (Optional)
Does the range change dynamically with the control limits (Both
Min & Max).

Exercise: Follow the steps in Chapter ?? of the Training Notes


ClearSCADA Advanced Training Course 181

Alt Scripting - Exercise


Time Allowed: 60 Minutes

Aim:
Trendspec…..Suggest start with the example project code and add
some functionality to it – Refine it!!!

Ideas….
a)Trend with alternative scaling ie Level Meter Vs Level Volume.
b)Bring up trend from alarm banner.

Exercise: Follow the steps in Chapter ?? of the Training Notes

ClearSCADA Advanced Training Course 182

90
TrendSpec Scripting - Exercise
sub MyAdHocTrend2
dim S
S = "SCX:////Trend/"
S = S & "TREND("
S = S & "TRACE(PROCESSEDHISTORIC, 'Y Axis 1',"
S = S & "LabelExpr = '""My Projects new.AI 0 - 100""',"
S = S & "ShowAnnotations = True,"
S = S & "SOURCE('My Projects new.AI 0 - 100.Historic')),"
S = S & "XAXIS(RELATIVENOW,"
S = S & "Offset = 'MINUTE - 3 SECONDS',"
S = S & "INTERVAL = '1M'),"
S = S & "YAXIS('Y Axis 1' , Label = 'Point Value',"
S = S & "LabelPos = CENTRE, LabelStyle = ROTATED),"
S = S & "TitleExpr = '""My Projects new.AI 0 - 100.NAME""',"
S = S & "ShowTitle = True, ShowKey = True,"
S = S & "AlarmLimitLabelPos = LIMITLABELOVERRIGHT,"
S = S & "TitleFont = 'Arial', TitleFontHeight = 10,"
S = S & "TitleFontStyle = FONTSTYLEBOLD, MainFont = 'Tahoma',"
S = S & "MainFontHeight = 8, MainFontStyle = FONTSTYLEBOLDITALIC,"
S = S & "LabelFont = 'Tahoma', LabelFontHeight = 8, LabelFontStyle = 0)“
‘Option 1 App.OpenWindow( S )
‘Option 2 Mimic.OpenInset S, 20, 20, 100, 100
End Sub

ClearSCADA Advanced Training Course 183

TrendSpec Scripting - Exercise


S = "SCX:////Trend/"
S = S & "TREND("
S = S & "TRACE(RAWHISTORIC, 'Y Axis 1' ,"
S = S & "Label = 'Test.A1'," S = S & "SOURCE('Test.A1.Historic'),"
S = S & "TraceStyle = TRACELINE, RawOverlay = False,"
S = S & "LineColour = RGB(200,0,0),"
S = S & "LineStyle = DASHSOLID, LineWidth = 0.000000),"
S = S & "TRACE(RAWHISTORIC, 'Y Axis 2' ,"
S = S & "Label = 'Test.A1',"
S = S & "SOURCE('Test.A1.Historic',YOffset=20),"
S = S & "TraceStyle = TRACELINE, RawOverlay = True,"
S = S & "LineColour = RGB(0,0,200),"
S = S & "LineStyle = DASHSOLID, LineWidth = 0.250000),"
S = S & "XAXIS(RELATIVENOW),"
S = S & "YAXIS('Y Axis 1' , Label='No Change',Position = LEFT,"
S = S & "Visible = True, Colour = RGB(0,0,0)),"
S = S & "YAXIS('Y Axis 2' , Label='Changed', Position = RIGHT,"
S = S & "Visible = True, Colour = RGB(0,128,0)),"
S = S & "Title = 'Point 1')"

ClearSCADA Advanced Training Course 184

91
TrendSpec Scripting - Exercise
dim S S = "SCX:////Trend/"
S = S & "TREND("
S = S & "TRACE(PROCESSEDHISTORIC, 'Y Axis 1' ,"
S = S & "Label = 'Main New Analogue Point',"
S = S & "System='Main'," S = S & "SOURCE('New Analogue Point.Historic'),"
S = S & "TraceStyle = TRACELINE, RawOverlay = False,"
S = S & "LineColour = RGB(0,0,0),"
S = S & "LineStyle = DASHSOLID, LineWidth = 0.000000),"
S = S & "TRACE(PROCESSEDHISTORIC, 'Y Axis 2' ,"
S = S & "Label = 'Main 3 New Analogue Point',"
S = S & "System='Main3',"
S = S & "SOURCE('New Analogue Point.Historic'),"
S = S & "TraceStyle = TRACELINE, RawOverlay = False,"
S = S & "LineColour = RGB(0,128,0),"
S = S & "LineStyle = DASHDASH, LineWidth = 0.250000),"
S = S & "XAXIS(RELATIVELATEST, Interval = '6H'),"
S = S & "YAXIS('Y Axis 1' , Position = LEFT,"
S = S & "Visible = True, Colour = RGB(0,0,0)),"
S = S & "YAXIS('Y Axis 2' , Position = RIGHT,"
S = S & "Visible = True, Colour = RGB(0,128,0)),"
S = S & "YAXIS('Y Axis 3' , Position = RIGHT,"
S = S & "Visible = True, Colour = RGB(75,0,255)),"
S = S & "Title = 'Sensors 1 to 3')"
App.OpenWindow( S )

S = S & "LabelFont = 'Chiller',LabelFontHeight = 18,LabelFontHeight = 3, LabelFontStyle = FONTSTYLEBOLD


ClearSCADA Advanced Training Course 185

TrendSpec Scripting – Easy Creation


•From the ViewX menu bar’s Edit menu, the Copy Shortcut option is used to paste the ad hoc Trend’s definition into the
clipboard.
•The content of the clipboard is then pasted into Notepad.

•The content is adjusted as required. In this particular case, line breaks are used to separate the various sections of the ad
hoc Trend’s definition:

•Minor modifications are made to the definition. For instance, the Label identifier for the first trace is replaced with an
appropriate LabelExpr expression. Similarly, the Trend’s TitleExpr identifier is replaced with a Title identifier. (The TitleExpr
derives its value from the ad hoc Trend’s original data source—the sensor from which the Trend was originally accessed.)
•Note that although the ad hoc Trend’s definition contains three TRACE sections, it only contains two YAXIS sections. This is
because two of the sensors, Sensor 11 and Sensor 13, have the same point value range (0 to 100) and can therefore be
assigned the same y-axis (‘Y Axis 1’). Sensor 12 has a different point value range (0 to 120), so is assigned a different y-axis
for that range. To make this association clearer, a Colour identifier is added to the YAXIS section for ‘Y Axis 2’. The Colour
identifier is allocated the same color as that used for Sensor 12’s trace.
•The ‘custom’ ad hoc Trend is to be accessed via a button on a Mimic. Script is to be used to display the Trend whenever the
button is selected.
•Scripting is enabled on the relevant Mimic (see Enable the Scripting Feature on a Mimic in the ClearSCADA Guide to
Scripting).
•The basic script structure is entered into the Mimic’s Script Editor. The ad hoc Trend’s definition is then pasted from Notepad
into the script subroutine.

•The Mimic is saved.


•Users can display the ‘custom’ ad hoc Trend at any time, by selecting the relevant button on the Mimic.

ClearSCADA Advanced Training Course 186

92
TrendSpec Scripting – Easy Creation
SCX:////Trend/
TREND(TRACE(RAWHISTORIC, 'Right' ,LabelExpr = '''ClearSCADA - Training.Training.08)
Trends.Examples.04b) Sine Wave''' ,
SOURCE('ClearSCADA - Training.Training.08) Trends.Examples.04b) Sine Wave.Historic' ),
RawOverlay = False, UpdateMode = INTERVAL, LineColour = RGB(0,0,255),
LineWidth = 2.000000),
TRACE(RAWHISTORIC, 'Left' ,LabelExpr = '''ClearSCADA - Training.Training.08) Trends.Examples.04d)
Walk''' ,
SOURCE('ClearSCADA - Training.Training.08) Trends.Examples.04d) Walk.Historic' ),
RawOverlay = False, UpdateMode = INTERVAL, LineColour = RGB(255,0,0),
LineWidth = 2.000000), XAXIS(RELATIVENOW, Offset = 'H - 23H', Interval = '1D'),
YAXIS('Left' ,LabelExpr = '''%25''' , Format = '0.%23%23%23%23%23%23',
MinorTicks = 1, Colour = RGB(255,0,0)),YAXIS('Right' , Position = RIGHT,
MinorTicks = 1, Colour = RGB(0,0,255), StateSystem = '.'),
TitleExpr = '''ClearSCADA - Training.Training.08) Trends.Examples.04d) Walk''' ,
BackgroundColour = RGB(255,255,255))

This is from the previous Notes!!

ClearSCADA Advanced Training Course 187

Conclusion
• What did you hope to learn from this course?
• Did you learn what you had hoped?

Thankyou...

ClearSCADA Advanced Training Course 188

93
Dongle License missing on restart using Remote
Desktop
Question:
I have 2009 R2.2 running on HP servers with Windows Server 2003 R2. With ClearSCADA dongle licences.
Servers are remote to me so I use RDP to connect. On occasions when I need to shutdown and restart
ClearSCADA the licence becomes invalid and server requires full restart to fix.
Problem does not occur if done from Console.
Anyone else? Any ideas?

Answer:
The dongle is recognised correctly if the database service is remotely started using "psservice", rather than by
the
Service Manager via a Remote Desktop session.

For example "psservice \\\prpc11 start "ClearSCADA Server"".

psservice is part of the Sysinternals pstools package


(http://technet.microsoft.com/e...ternals/bb896649.aspx)

ClearSCADA Advanced Training Course 189

Use of $

( ".$.CurrentValue" + 1 ) is the argument used for the above method. (In this case, the
argument specifies that the value of the above method is to be set to Test Point 4’s
current value plus one. (".$.CurrentValue" stipulates the current value of the custom
action’s source—the database item on which the custom action is configured—which
in this example is Test Point 4.))
In certain situations, you may need to define a method using an expression that references the item on which the
expression is being configured. A common example of this is on point user methods where a point’s
Method may use an expression that references the point. If the point is specifically named in the
expression, the expression will only work as desired if the point’s name remains the same. This can be a
problem if the point is renamed or is copied and the copy used in another location. To prevent the need for
re-defining the method expressions on renamed items and copies, you can use .$ notation. This allows you
to use a dollar $ to represent the item being referenced. As the dollar does not define a specific item, it can
be used with items that are to be renamed or copied without breaking the expression (as ClearSCADA will

substitute the item’s name for the $).

ClearSCADA Advanced Training Course 190

94
ClearSCADA Command Line Utility
ClearSCADA provides a command line utility that allows users to start and stop the
server, as well as perform a number of other management tasks. This utility, named
scxcmd.exe, can be found in the program installation directory.

scxcmd Options
-s server[:port]Connect to specified server and port. Defaults to localhost:5481

Commands
START - DBStart or repair the database if necessary (i.e. when in Invalid Configuration state).
START driver - Start the specified driver.
START DRIVERS - Start all drivers.
STOP SERVER - Stop the server.
STOP driver - Stop the specified driver.
STOP DRIVERS - Stop all drivers
RESTART driver - Restart the specified driver.
RESTART DRIVERS - Restart all drivers.
COMPRESS DB - Compress the database.
SETLOG {DB | driver} options - Set the logging options for the database or specified driver
ADDLOG {DB | driver} options - Add logging options to the database or specified driver
REMLOG {DB | driver} options - Remove logging options from the database or specified driver
SHOWLOG {DB | driver} options - Show logging options for the database or specified driver.
SHOWDIAG diag - Show the specified diagnostic
ClearSCADA page. UseTraining
Advanced SHOWDIAG
CourseHELP to display a list of available 191
diagnostics.

Equate Server Configuration to Registry Settings


• For copying changes between servers it's common to just export the entire HKLM\Software\Control Microsystems\ and import it onto the new server.
The downside of this is that if you have multiple servers and there are often changes that need to be made on those servers once imported (such as
the Parter details) so you either need to dig about in the Registry and work out what or start up the database, perhaps off the network, to allow the
ServerConfig.exe tool to connect and so you can make the changes.
• Also, if you control some settings via Window's Group Policy you need to know it's Registry location.
• You can usually save some time and effort by using the following to work out which settings are changed in the Registry from the corresponding
settings in ServerConfig.
• 1. Start up ServerConfig and successfully connect to a server. Sadly you can't do this with an offline server.
• 2. Expand the selections and change a setting that you're interested in. Just to see how this works pick a simple change such as the archive period
of historic data. You won't be applying the changes unless you tell it to.
• 3. Note that the system name, server address and dialogue name (Historic Data) all change to red text to indicate a change has occurred.
• 4. Collapse the Historic Configuration branch (or whatever it's called in the older versions). Do not collapse down to the server address group as it'll
ask you to apply the changes.
• 5. The Historic Configuration name changes back to black however the Registry key below how now changed to red.
• 6. Expand the Registry branch and then select the key that also has the red text.
• 7. In the right hand panel you should see at least one entry that is red, this has been changed.
• 8. Close ServerStatus or disconnect without applying the changes and the changes you make above will not be applied to the server.
• In this scenario two settings have actually changed; there isn't always a one-to-one relationship between a setting in ServerConfig and what is
recorded in the Registry.
• You could have also exported the Registry before and after and done a 'diff' on them, although some diff tools struggle with the special binary
encoding at the start of the file, and you'd also have to have applied the settings before the second export which might be wrong/dangerous/incorrect
on the server you're using.
• Some entries in the Registry have nothing in ServerConfig and are either auto-generated by ClearSCADA or in a few cases such as the logging
options and debug settings controlled via ServerStatus.exe. You can't use the same tactic with ServerStatus.
• If you make a change to the Registry directly whilst ClearSCADA is running it will not usually take effect until the server is restarted, however for
settings which do not need a restart when they are changed via ServerConfig you can trick the database to reload these settings. This is very useful
when you may have imported many settings. To trick the database just change a setting that doesn't need a restart (my favourite is the historic cache
size, just increase/decrease it by a value of 1), apply the changes and the database will reprocess the settings from the Registry. Then change your
trick setting back to what it was and just apply those changes again. Settings such as partner configuration can't be tricked like this even though it's
also stored in the Registry so you will need to restart the database for those.
• As usually, when messing with the Registry ensure you have backups to ensure that you can revert if needed, use at own risk :) For information from
Microsoft of how to backup and edit the Registry refer to http://support.microsoft.com/kb/322755
• Adam

ClearSCADA Advanced Training Course 192

95

You might also like