Professional Documents
Culture Documents
ABB Oy
Substation Automation Products
NAME
RESP.DEPT.
PREPARED
Visual SCIL
FISUB/RAE
27.08.2007 H.H.
COURSE ID
LANGUAGE
CHECKED
P288
En
05.09.2007 R.K.
REVISION
APPROVED
05.09.2007 M.M.
ABB Oy P288 EN
1MRS751495-MTR
Table of Contents
1
General Information
Introduction
Dialog Editor
Exercises
Contents of Chapter 1
1 General Information
1.1 Course Schedule
1.2 Notice
1.3 Definitions and Abbreviations
1.4 Course Presentation
1.5 Feedback Form
Course Schedule
Day 1
9:00
Introduction
Designing Dialog Systems
Programming Dialog Systems
Dialog Editor
Exercise 1
11:45
Lunch
13:00
16:00
Day ends
Day 2
9:00
Exercises 5 7
11:45
Lunch
13:00
16:00
Course ends
Notice
CAP 505
COM 500
DCP-NET
DDE
DMS
DTU
EDM
FA
Feeder Automation
HMI
IT
Information Technology
LAN
LIB 500
LIB 510
LMS
LNT 505
LON Network Tool for installing and configuring devices to the LonWorks
network
LON
MicroSCADA
The name of the technology used in most of the System and Engineering
products by ABB Oy Distribution Automation, common denominator in
the software kernel
MMC
Man-machine communication
MV
Medium voltage
NCS
NET
ODBC
OLE
OPC
PCLTA
PC-NET
PLC
RAS
RED
REF 543
RTU
SA
SCADA
SCIL
SM
SMS
SPA
SPACOM
SRIO
SYS 500
TCP/IP
Visual SCIL
The method for designing and programming user interface dialogs with
Visual SCIL objects and commands is named Visual SCIL
Course Presentation
The aim of the course is to familiarize the participants with the SCIL syntax and basic
programming techniques.
Objectives
Prerequisites
Topics
Participant profile
System
engineers,
maintenance
engineers and persons who edit, build
or maintain MicroSCADA systems.
Contents of Chapter 2
2 Introduction
2.1 What is Visual SCIL?
2.2 What can you do with Visual SCIL
2.3 Visual SCIL Objects
2.4 Dialog Systems
2.5 Handling Visual SCIL Objects
2.6 Visual SCIL Related Manuals
Introduction
2.1 What is Visual SCIL?
Visual
SCIL
Introduction
2.2 What can you do with Visual SCIL?
operator dialogs
tables
Introduction
2.3 Visual SCIL Objects
In SCIL, the dialogs and dialog items are handled as what is called Visual
SCIL objects.
Images
Introduction
2.4 Dialog Systems
The main dialog and all dialogs opened from it, or from items included,
belong to the same dialog system.
MAIN DIALOG
DIALOG
DIALOG
DIALOG
DIALOG
DIALOG
DIALOG
DIALOG
DIALOG
Introduction
2.5 Handling Visual SCIL Objects
Each Visual SCIL object (dialog, dialog item, image) has an object name
used for referencing the object in SCIL.
Introduction
Contents of Chapter 3
3 Designing Dialog Systems
3.1 Storing Objects
3.2 Designing Dialogs
3.3 Composing Dialog Systems
3.4 Object Hierarchy
3.5 Coordinate System
Choose
object type
Editing
a object
Choose
object
Save file
Dialogs, Images,
Containers, Menus,
Notebooks, etc.
LOAD
DIALOG SYSTEM
A dialog may contain several dialog items, which in turn may contain
dialog items.
Main Dialogs, Dialogs, Containers and Notebook Pages can contain any types
of dialog items.
Menu Bars can contain Menus, which in turn can contain Menu Items.
Menu bar
Menu
Menu Item
Note book
Note book pages
Container
Other dialog
items
Picture container
Picture
The difference between main dialogs and dialogs is that when a dialog is used
its attributes can be read from its parent object.
All objects within the same dialog system have their variables in common.
Visual SCIL objects and attributes are accessed by all objects within the
same dialog system.
Dialog
Main Dialog
Dialog
ROOT
VS_CONTAINER
VS_BUTTON
VS_MAIN_DIALOG
VS_CHECKBOX
CHILD
ROOT /
PARENT
CHILD
PARENT
VS_CONTAINER
CHILD
ROOT /
PARENT
._geometry
A list containing the
following attributes:
X
Y
W(idth)
H(eight)
(0,0)
(0,0)
(0,0)
(0,0)
Contents of Chapter 4
4 Programming Dialog Systems
4.1 Methods
4.2 Cyclic Methods
4.3 Event Methods
4.4 Action Methods
4.5 Help Methods
4.6 Create Method
4.7 Init Method
4.8 Delete Method
4.9 Error Handling Method
4.10
4.11
Attributes
4.12
4.13
4.14
4.15
4.16
4.17
Each dialog and dialog item has its own set of methods.
Methods can contain all SCIL elements, except the picture handling
commands (commands starting with !).
Each dialog and dialog item may have a number of methods executed
cyclically at a user-specific interval (cycle time).
Each object can have a number of event methods started at the activation
of given event objects.
Event Method
is executed
TUTBAY_B1:P10
ROOT
._get_help
PARENT
Execute Help
Method for Check
Box
F1
THIS
ARGUMENT
Help Method
search order
The create method is executed during the creation of the object after the
.LOAD command has been issued.
The create method for the child objects are executed before the parent
objects.
Object references
should generally
be avoided in
create methods.
7. DIALOG
6. Group
5.
Rows
4.
Columns
3. Container
2.
Ok
1.
Cancel
The init method is started automatically after an object and all its parent
objects have been created.
The init method of the parent object is executed before the init methods of
the child objects.
3.
1. DIALOG
2. Group
Rows
4.
Columns
5. Container
6.
Ok
7.
Cancel
When a SCIL error occurs in a object, and the error handling policy is
CONTINUE or STOP, the error handling method is executed.
STATUS
SCIL status code (integer)
METHOD
The method where the error occurred
LINE
SCIL line (text)
POSITION
Position on the line (text)
ERROR POLICY
The error handling policy used when the error occurred
LINE NUMBER
The number of the erroneous line within METHOD
The public methods are accessible by all objects within the dialog system.
The private methods are accessible only within the same object and its
child objects.
DIALOG
Group
Rows
Columns
Container
Ok
Cancel
The basic features given in the Dialog Editor serve as default when a
dialog or dialog item is loaded.
Visibility attribute
._ENABLED
TRUE, FALSE
TRUE, FALSE
._OPEN
._GEOMETRY
Using attribute references, the attribute values can be read and written
from SCIL.
Attribute Reference:
[object].attribute
Object references are used when loading, creating and deleting objects
and when referencing attributes and methods.
2. .set
MAIN
cnt_Cont1
chk_Box1
PARENT
ROOT
cnt_Cont2
chk_Box2
btn_Btn1
ROOT\cnt_Cont1\chk_Box1._enabled=TRUE
or
.set ROOT\\chk_Box1._enabled=TRUE
btn_Btn2
1. .set
PARENT\chk_Box1._enabled=TRUE
Object Path
Attribute
Attribute Value
THIS
1.
2.
Object Name
The user defined attributes always have both read and write access.
Method Call:
[object].method [(argument list)]
Object
ROOT\pcn_Container._new_pic(tutor)
THIS._move_text(1,10)
._set_cell_text(1,1,text)
Text identifiers can be used in the Dialog Editor (for the ._TITLE
attribute) and in SCIL.
Languages accordind to
The ISO 639-1 standard
#set MON:BLA = EN
#set MON:BLA = SV
Contents of Chapter 5
5 Dialog Editor
5.1 General
5.2 Working Procedure
5.3 Geometry Management
Dialog Editor
5.1 General
Test Object
Stop Test
Dialog Editor
5.2 Working Procedure
1.
2.
3.
4.
Dialog Editor
5.2 Working Procedure
5.
6.
8.
7.
Dialog Editor
5.3 Geometry Management
The distance between different objects in various situations and the size
of some dialog items are defined using connections.
Dialog Editor
5.3 Geometry Management
Connection Types Between Objects:
Default color
Natural length connection
Selected connection
Error in connection
BLUE
GREEN
YELLOW
RED
Natural Length
The distance is always 5 points.
Natural Base + Spring The distance will always be at
least 5 points.
Fixed Length
The distance will be the same as
it was at the moment of
choosing a fixed connection.
Fixed Base + Spring
The base distance wil be at least
as long as it was at the moment
of choosing this connection.
Locked Fixed Length The distance will always be the
same as it was at the moment
of choosing a fixed connection.
Zero Length
No distance between objects.
Spring
The distance will change freely
when the objects are moved.
Dialog Editor
5.3 Geometry Management
Connection Types Inside Objects:
Natural Base
Natural Base + Stretch
Fixed Base
Dialog Editor
Contents of Chapter 6
6 Container Group Objects
6.1 General
6.2 Order Items Page
6.3 Dialogs
6.4 Notebooks
6.5 Containers
6.6 Menus
6.7 Picture Containers
6.8 Icon View
Dialogs
Notebooks
Containers
Menus
Picture Containers
Icon View
Dialogs are used when dialog boxes, which are windows appearing
independently on the screen, are needed.
Notebooks are often used to group dialog items that are in some way
related to each other.
There might be that many dialog items in a notebook, that there would not be
enough space for them in a container.
A notebook usually contains several pages, which all have a tab to enter
the page.
6.4 Notebooks
Tabs
Tab Side
6.5 Containers
Containers are mainly used to group dialog items that are in some way
related to each other.
The menus provide a fast way for the user to issue commands.
Menus (VS_MENU)
6.6 Menus
Contents of Chapter 7
7 Other Dialog Items
7.1 Label
7.2 List
7.3 Text
7.4 Buttons
7.5 Check Box
7.6 Option Button
7.7 Combo and Combo Popdown
7.8 Numeric Spinner
7.9 Text Spinner
7.10
7.11
7.12
Tree
7.13
Graph
7.2 List
The Natural Number of Rows and AutoCalculate Column Widths options can
be used to determine the size of a
naturally sized list.
Only One No more than one cell can be selected form the list.
7.3 Text
7.4 Buttons
The ._selected_button_index
attribute is used to determine which
button was clicked in the palette.
;NOTIFY method
.set ROOT\opt_Red._value=0
.set ROOT\opt_Green._value=0
.set ROOT\opt_Blue._value=1
A combo box is a list of texts that the user can choose from.
._get_text_at(4)
._text
The user enters the value selecting the number from the
list or by typing it in the box.
-10
max
Wrap
Value
Max
Max
Min
Min
The line dialog item is used to place horizontal or vertical lines into a
dialog.
Root node
Node
_add_root_node
_add_node
_add_leaf
Leafs
Area graph
Bar graph
Pie graph
Vertical hairlines for determining the intersection points with the datasets
can be added to the graph.
Contents of Chapter 8
8 Using Dialogs in MicroSCADA
8.1 General
8.2 Opening Dialogs from Displays
8.3 Creating an Icon in the Tool Manager
8.4 Opening Dialogs from Pictures
from a Display
2)
3)
5)
2.
1.
3.
2)
Visual SCIL Dialogs (and other objects) can be opened from pictures
(classic monitor) using the SCIL command .LOAD
Contents of Chapter 9
9 Exercises
9.1 Exercise 1
9.2 Exercise 2
9.3 Exercise 3
9.4 Exercise 4
9.5 Exercise 5
9.6 Exercise 6
9.7 Exercise 7
9.8 Exercise 8 Extra
9.9 Exercise 9 Extra
Exercises
Exercise 1
Create a main dialog with
the following features.
Exercises
Exercise 1
1)
2)
Exercises
Exercise 1
3.
4.
ABB Oy, P288(En), 3
1MR751 495-MTR
5.
Exercises
Exercise 1
The name of the Visual SCIL object:
See Programming Language SCIL for
object and variable naming
conventions.
The @-sign in front of the title indicates
that the title will be retrieved from the
text translation data base.
.delete ROOT
Exercises
Exercise 1
6)
7)
8)
Exercises
Exercise 1
The dialogs are tested according to the following procedure:
10)
11)
Exercises
Exercise 1
EXTRA
Add a second language to the Text Translation Database for the button.
Exercises
Exercise 2
Add the following features to the main
dialog edited in the previous exercise.
Product Icon
Exercises
Exercise 2
1)
2)
3)
1.
2.
1.
ABB Oy, P288(En), 9
1MR751 495-MTR
3.
3.
1.
1.
2.
3.
Natural Base: No
Fixed Base: Yes
Value: 0
Stretch: No
Natural Base: Yes
Fixed Base: No
Value:
Stretch: No
Natural Base: No
Fixed Base: Yes
Value: 0
Stretch: Yes
Exercises
Exercise 2
4)
5)
6)
7)
8)
9)
2x
10)
11)
Exercises
Exercise 2
12)
13)
14)
15)
ROOT.On_Exit
Exercises
Exercise 2
16)
17)
18)
19)
LBL_PRODUCT_DESCRIPTION
20)
Exercises
Exercise 2
21)
Add the following programs in the methods described below (the programs can be
found in the Insert SCIL Commands, Functions & Objects).
=
=
=
=
=
#if MON:BEX == "SYS" #then #return APL:BNA + " [" + dec(MON:BAN, 0) + "] - " + ROOT.product_description
#else #return APL:BNA + " - " + ROOT.product_description
Exercises
Exercise 2
22)
Close the main dialog editor, insert a new VS_IMAGE to the object list and name it
Product_Icon_M.
23)
24)
Exercises
Exercise 2
25)
.delete ROOT
26)
ROOT.On_Exit
27)
28)
ROOT.On_Exit
.set ROOT._open=FALSE
.delete ROOT
ABB Oy, P288(En), 15
1MR751 495-MTR
Exercises
Exercise 3
Add the following features to the main dialog and
create a new VS_DIALOG (dlg_Setup) in the object list.
Exercises
Exercise 3
Name: btn_OK
Title: @btn_OK (OK)
Exercises
Exercise 3
Create a private method (On_Exit) in the VS_DIALOG (dlg_Setup)
.set THIS._open=FALSE
.delete THIS
THIS.On_Exit
Exercises
Exercise 3
Close the dialog editor and
Activate the main dialog
editor (Main).
Name: chk_Disable
Title: @chk_Disable (Disable Dialog)
Name: chk_Hide
Title: @chk_Hide (Hide Setup)
Notify methods
Name: btn_Dialog
Title: @btn_Dialog (Dialog)
ROOT.On_Open_Dialog
Exercises
EXTRA
Exercise 3
Add a menu item to the File menu that opens the Setup dialog. Also
add a separator menu item between the two menu items in the File menu.
Exercises
Exercise 4
Add the following features to the main
dialog edited in the previous exercise.
Exercises
Exercise 4
Exercises
Exercise 4
Exercises
Exercise 4
Add the following three sections to the main dialog (Main) Init program.
1.
Sections 1 3 listed
on the next page.
2.
3.
Exercises
Exercise 4
1.
2.
3.
@l_File_Name=fm_split_name(fm_represent(fm_extract(fm_file(._source_file_name),"LAST")))
@t_File_Id=l_File_Name:vName
t_Parameter_File
= "'t_file_id'.ini",t_Parameter_Section = "General",t_Default_Geometry = "list(X=100,Y=010,W=200,H=170)",.set THIS._geometry=evaluate(.Read_Parameter("Geometry",.t_Default_Geometry))
@v_Geo = dump(THIS._geometry)
.Save_Parameter("Geometry",%v_Geo(1))
Exercises
Exercise 5
Add the following features to
the dialog (dlg_Setup)
created in the exercise 3.
Exercises
Exercise 5
1. Insert a VS_TEXT_EDITOR
to the dialog.
2. Add the following two
program sections to
the dialog Init method.
Name: txe_Editor
Title:
Exercises
Exercise 5
3. Add the public method Notify_File_Chooser
to the dialog (dlg_Setup).
@l_File_Attr=argument(1)
#if (l_File_Attr:Vt_event=="APPLY") and (%t_Action=="OPEN") #then.set THIS\txe_Editor._text_vector=read_text(l_File_Attr:Vt_absolute_full_path)
#if (l_File_Attr:Vt_event=="APPLY") and (%t_Action=="SAVE") #then@i_Status=write_text(l_File_Attr:Vt_absolute_full_path,THIS\txe_Editor._text_vector,0)
.set mdl_File_Chooser._open=FALSE
Exercises
Exercise 5
5. Add the programs for opening the file chooser for the Open and Save Buttons.
@t_Action="OPEN"
Name: btn_Open
Title: @btn_Open (Open)
Name: btn_Save
Title: @btn_Save (Save)
@t_Action="SAVE"
PARENT\mdl_File_Chooser.Set_Mode("SAVE")
PARENT\mdl_File_Chooser.Set_Caller_Action("ROOT.File_Save")
Notify methods
PARENT\mdl_File_Chooser.Set_Mode("OPEN")
PARENT\mdl_File_Chooser.Set_Caller_Action("ROOT.File_Open")
PARENT\mdl_File_Chooser.Select_Path_Selection("PATH")
Exercises
Exercise 5
EXTRA
Set the properties for the text editor so, that when a text is
opened the upper left corner of the text will be visible.
Exercises
Exercise 6
Add the following features to
the dialog (dlg_Setup)
created in the exercise 3.
Exercises
Exercise 6
Create the private method Show_Message
in the dialog (dlg_Setup).
Exercises
Exercise 6
Create two private methods (On_Open, On_Exit)
in the dialog (dlg_Setup).
On_Exit
.set THIS._open=FALSE
.delete THIS
On_Open
@t_Action="OPEN"
mdl_File_Chooser.Set_Mode("OPEN")
mdl_File_Chooser.Set_Caller_Action("ROOT.File_Open")
mdl_File_Chooser.Select_Path_Selection("PATH")
.set mdl_File_Chooser._open = TRUE
mdl_File_Chooser.Set_Path("USER_PAR")
Exercises
Exercise 6
Change the NOTIFY methods for the
Open and Save buttons.
@t_Action="SAVE"
PARENT\mdl_File_Chooser.Set_Mode("SAVE")
PARENT\mdl_File_Chooser.Set_Caller_Action("ROOT.File_Save")
Exercises
Exercise 6
Do the changes listed below in the following two
methods.
THIS.On_Exit
PARENT.On_Exit
Exercises
Exercise 6
Make the following changes in the public method
Notify_File_Chooser.
@l_File_Attr=argument(1)
#if (l_File_Attr:Vt_event=="APPLY") and (%t_Action=="OPEN") #then #block
.set THIS\txe_Editor._text_vector=read_text(l_File_Attr:Vt_absolute_full_path)
.set txe_Editor._text_is_modified=FALSE
txe_Editor._scroll_position_into_view(1,1)
#block_end
#if (l_File_Attr:Vt_event=="APPLY") and (%t_Action=="SAVE") #then #block
@i_Status=write_text(l_File_Attr:Vt_absolute_full_path,THIS\txe_Editor._text_vector,0)
.set txe_Editor._text_is_modified=FALSE
#block_end
.set mdl_File_Chooser._open=FALSE
Some of these changes have been made in exercise 5 EXTRA.
Exercises
Exercise 7
Create a VS_DIALOG (dlg_P_Object)
in the object list and add the following
features to the dialog.
Exercises
Exercise 7
Exercises
Exercise 7
Insert the following objects to
the dialog.
Name: btn_Close
Title: @btn_Close (Close)
PARENT.On_Exit
Name: nbk_Notebook
Title:
Exercises
Exercise 7
Edit the VS_NOTEBOOK and add two
VS_NOTEBOOK_PAGEs to it.
2x
Exercises
Exercise 7
Edit the first page and do the following:
Insert these objects on
the nbp_Objects
notebook page.
Name: nbp_Objects
Title: @nbp_Objects (Process Objects)
Name: lst_Objects
Title
Name: hdr_Header
Title:
Exercises
Exercise 7
Edit the second page and do the following:
Name: box_Attr
Title: @box_Attr
(Attributes)
Name: btn_Search
Title: @btn_Search
(Search)
Name: lbl_Count
Title: @lbl_Count
(Objects Found:)
Name: nbp_Setup
Title: @nbp_Setup (Setup)
Name: lbl_Condition
Title: @lbl_Condition (Search Condition)
Name: txt_Condition
Title:
Name: chk_IU
Title: @chk_IU (In Use (IU))
Name: chk_SS
Title: @chk_SS (Switch State (SS))
Name: chk_PT
Title: @chk_PT (Process Object Type (PT))
Name: chk_ZT
Title: @chk_ZT (Modification Time (ZT))
Name: lbl_Found
Title:
Exercises
Exercise 7
Open the nbp_Setup
page and create the
following three private
methods:
Name: Get_Objects
#error ignore
@v_Attributes=vector()
#if THIS\chk_IU._value==1
#if THIS\chk_SS._value==1
#if THIS\chk_PT._value==1
#if THIS\chk_ZT._value==1
#then
#then
#then
#then
@v_Attributes=append(%v_Attributes,"IU")
@v_Attributes=append(%v_Attributes,"SS")
@v_Attributes=append(%v_Attributes,"PT")
@v_Attributes=append(%v_Attributes,"ZT")
@i_Status=status
@l_Objects=application_object_list(0,"IX","A","F","",THIS\txt_Condition._text,%v_Attributes)
@i_Status=status
@v_IU(%i)=dec(l_Objects:VIU(%i))
@v_SS(%i)=dec(l_Objects:VSS(%i))
@v_PT(%i)=dec(l_Objects:VPT(%i))
@v_ZT(%i)=times(l_Objects:VZT(%i))
Exercises
Exercise 7
Name: On_Search
THIS.Reset_Search
THIS.Get_Objects
@v_Attr=("IU","SS","PT","ZT")
.set THIS\lbl_Found._title=dec(%i_Count)
@i_Col=2
#loop_with i=1..4
@t_Tmp=%v_Attr(%i)
#if THIS\chk_'t_Tmp'._value==1 #then #block
PARENT\\lst_Objects._set_cell_text_range(1,%i_Col,"VERTICAL",%v_'t_Tmp')
.create PARENT\\hdr_Header\hdi_'t_Tmp' =VS_HEADER_ITEM(_width=%i_Width, _title=%t_Tmp)
@i_Col=%i_Col+1
#block_end
#loop_end
#block_end
Exercises
Exercise 7
Name: Reset_Search
.set PARENT\\lst_Objects._row_count=0
@v_LN=vector()
@v_IU=vector()
@v_SS=vector()
@v_PT=vector()
@v_ZT=vector()
#error ignore
.delete PARENT\\hdr_Header\hdi_LN
.delete PARENT\\hdr_Header\hdi_IU
.delete PARENT\\hdr_Header\hdi_SS
.delete PARENT\\hdr_Header\hdi_PT
.delete PARENT\\hdr_Header\hdi_ZT
#error stop
PARENT.On_Search
@v_Items=THIS._child_objects
#loop_with i=1.. length(%v_Items)
@t_Tmp=%v_Items(%i)
PARENT\lst_Objects._set_column_width(%i,THIS\'t_Tmp'._width)
#loop_end
Exercises
EXTRA
Exercise 7
Exercises
Exercise 8
Create a main dialog with
the following features.
A tree from where process
objects or command procedures
can be selected.
2x
Exercises
Exercise 8
Create a VS_MAIN_DIALOG
and insert the following
nine objects.
VS_TREE
Name: tre_Objects
Title: <none>
VS_LIST
Name: lst_Objects
Title: <none>
VS_BUTTON
Name: btn_Close
Title: Close
VS_CHECK_BOX
Name: chk_IU
Title: In Use
VS_TEXT
Name: txt_CM
Title: <none>
The objects marked with a green circle
are static objects and they can be named
freely in this exercise.
Exercises
Exercise 8
Exercises
Exercise 8
Create a private method (On_Exit) in the VS_MAIN_DIALOG (main)
.set ROOT._open=FALSE
.delete ROOT
ROOT.On_Exit
ROOT.On_Exit
Exercises
Exercise 8
Write the following program in the Init method of the main dialog.
.load
.load
.load
.load
.load
APL
PO
PO_AI
PO_BI
CP
=
=
=
=
=
Vs_Image("Sys_Tool/Images16.vso",
Vs_Image("Sys_Tool/Images16.vso",
Vs_Image("Sys_Tool/Images16.vso",
Vs_Image("Sys_Tool/Images16.vso",
Vs_Image("Sys_Tool/Images16.vso",
"Apl_Local_Hot")
"Obj_Process_Object")
"Obj_Process_Object")
"Obj_Process_Object")
"Obj_Command_Procedure")
tre_Objects._add_root_node
tre_Objects._set_row_text(1,"Objects")
tre_Objects._set_row_image(1,"ROOT\APL")
tre_Objects._set_row_id(1,"ROOT_NODE")
tre_Objects._expand_node(1)
Exercises
Exercise 8
Create these two private
methods in the main dialog.
Create_Nodes
Create two nodes under the
root node.
Create_Leafs
tre_Objects._add_node(1,1)
tre_Objects._set_row_text(2,"Process Objects")
tre_Objects._set_row_image(2,"ROOT\PO")
tre_Objects._set_row_id(2,"PO")
tre_Objects._add_node(1,2)
tre_Objects._set_row_text(3,"Command Procedures")
tre_Objects._set_row_image(3,"ROOT\CP")
tre_Objects._set_row_id(3,"CP")
tre_Objects._add_leaf(2,1)
tre_Objects._set_row_text(3,"Binary Input (10)")
tre_Objects._set_row_image(3,"ROOT\PO")
tre_Objects._set_row_id(3,"BI")
tre_Objects._add_leaf(2,2)
tre_Objects._set_row_text(4,"Analog Input (10)")
tre_Objects._set_row_image(4,"ROOT\PO")
tre_Objects._set_row_id(4,"AI")
Exercises
Exercise 8
Create the following private methods in the main dialog.
List_AI
Lists the logical names of
all process objects of analog
input type in the list.
List_BI
Lists the logical names of
all process objects of binary
input type in the list.
List_CP
Lists the logical names of
all commandprocedures
in the list.
#local l_Tmp
l_Tmp=application_object_list(0,"ix","A","","","PT==9 and IX==10")
.set ROOT\lst_Objects._row_count=0
ROOT\lst_Objects._set_cell_text_range(1,1,"VERTICAL",l_Tmp.ln)
ROOT\lst_Objects._scroll_position_into_view(1,1)
#local l_Tmp
l_Tmp=application_object_list(0,"ix","A","","","PT==3 and IX==10")
.set ROOT\lst_Objects._row_count=0
ROOT\lst_Objects._set_cell_text_range(1,1,"VERTICAL",l_Tmp.ln)
ROOT\lst_Objects._scroll_position_into_view(1,1)
#local l_Tmp
l_Tmp=application_object_list(0,"c")
.set ROOT\lst_Objects._row_count=0
ROOT\lst_Objects._set_cell_text_range(1,1,"VERTICAL",l_Tmp.ln)
ROOT\lst_Objects._scroll_position_into_view(1,1)
Exercises
Exercise 8
Modify the following action methods in the tree object.
Handle_Expand_Node
This method is activated
when a node is expanded.
Leaf_Selected
This method is activated
when a leaf is selected.
.set ROOT\chk_IU._value=0
.set ROOT\txt_CM._text=""
#if THIS._get_row_id(argument(1))=="BI" #then ROOT.List_BI
#else_if THIS._get_row_id(argument(1))=="AI" #then ROOT.List_AI
#else .set ROOT\lst_Objects._row_count=0
Node_Selected
.set ROOT\chk_IU._value=0
.set ROOT\txt_CM._text=""
#if THIS._get_row_id(argument(1))=="CP" #then ROOT.List_CP
#else .set ROOT\lst_Objects._row_count=0
The list is emptied by setting the
_row_count attribute to 0.
Exercises
Exercise 8
Write the following program in the double_click method in the list.
#local t_Tmp, l_Tmp
t_Tmp=THIS._get_cell_text(THIS._selected_row,1)
#if (ROOT\tre_Objects._get_row_id(ROOT\tre_Objects._selected_row))=="CP"#then #block
l_Tmp=fetch(0,"C",t_Tmp)
.set ROOT\txt_CM._text=l_Tmp.cm
#if l_Tmp.iu==1 #then .set ROOT\chk_IU._value=1
#else .set ROOT\chk_IU._value=0
#block_end
Exercises
EXTRA
Hints:
The data object image name
in the images16.vso file is
obj_data_object.
Exercise 8
Exercises
Exercise 9
Create a main dialog with
the following features.
Exercises
Exercise 9
Create a VS_MAIN_DIALOG
and insert the following
nine objects.
VS_GRAPH
Name: gra_Graph
Title: <none>
VS_LABEL
Name: lbl_Y1
Title: Y1:
VS_LABEL
Name: lbl_Y1
Title: Y1:
VS_CHECK_BOX
Name: chk_Hairline
Title: Y2: Hairline Enabled
The objects marked with a green circle
are static objects and they can be
named freely in this exercise.
Exercises
Exercise 9
.set gra_Graph._background_color="BLACK"
;Add x-axis
gra_Graph._add_x_axis(1,"INTEGER","bottom",2,0)
;Set x-axis properties
@l_x_axis_prop = list(min
= 0,max
= 60,time_unit
= "SECONDS",time_format
= "",annotation_increment
= 10,annotation_font
= ("M",3),annotation_color
= "RED",tick_increment
= 5,axis_color
= "GREEN",axis_title
= "Seconds",axis_title_font
= ("M",2),axis_title_color
= "YELLOW",display_axis_title_enabled=TRUE,grid_mode
= "NONE",grid_line_width
= 1,grid_color
= "BLACK",grid_line_style
= "SOLID")
gra_Graph._set_x_axis_properties(1, %l_x_axis_prop)
Exercises
Exercise 9
Graph_Setup
Create and set the properties
for the graph x- and y-axis.
;Add y-axis
gra_Graph._add_y_axis(2,"INTEGER", "bottom", 1,0)
;Set y-axis properties
@l_y_axis_prop=list(min
=
max
=
annotation_increment
=
annotation_font
=
annotation_color
=
tick_increment
=
axis_color
=
axis_title
=
axis_title_font
=
axis_title_color
=
display_axis_title_enabled
grid_mode
=
grid_line_width
=
grid_color
=
grid_line_style
=
0,100,50,("M",3),"RED",10,"GREEN","",("M",1),"BLACK",= FALSE,"NONE",1,"BLACK","SOLID")
gra_Graph._set_y_axis_properties(2, %l_y_axis_prop)
Exercises
Exercise 9
Create the following
private method in the
main dialog.
Data_Setup
Create and set the properties
for the graph x- and y-axis.
=
=
=
=
=
=
=
"Random 1","RED",TRUE,"DOT","YELLOW","RED","WHITE")
gra_Graph._set_data_set_properties(1,%l_data_set_prop)
@l_data_set_prop2 = list(title
default_color
show_line
marker_shape
marker_color
status_0_color
status_9_color
=
=
=
=
=
=
=
"Random 2","YELLOW",TRUE,"DOT","YELLOW","YELLOW","WHITE")
gra_Graph._set_data_set_properties(2,%l_data_set_prop2)
Exercises
Exercise 9
Create the following
private methods in the
main dialog.
Hairline_Setup
Set the properties for the
graph hairline.
=
=
=
=
=
"GREEN",%b_Enabled,"ONOFFDASH",1,50)
gra_Graph._set_hairline_properties(1,%l_hairline_prop)
Hairline_Value
@l_Data1=gra_Graph._get_hairline_intersection_point(1,1,FALSE)
@l_Data2=gra_Graph._get_hairline_intersection_point(1,2,FALSE)
.set lbl_Y1._title="Y1:
.set lbl_Y2._title="Y2:
#block_end
#else #block
.set lbl_Y1._title="Y1:
.set lbl_Y2._title="Y2:
#block_end
"+dec(l_Data1:vy_value,6,2)
"+dec(l_Data2:vy_value,6,2)
"
"
Exercises
Exercise 9
Create and edit the following
methods in the main dialog.
Cyclic Method (2.00)
Init
Update the data set in the graph and the hairline intersection
points every two seconds.
#loop_with i=1..30
@v_y_axis(%i)=%v_y_axis(%i+1)
#loop_end
@v_y_axis(31)=random(0,100)
#loop_with i=1..31
@v_x_axis(%i)=(%i-1)*2
#loop_end
@v_y_axis(1..31)=(0)
gra_Graph._set_data_set_values(1,%v_x_axis,%v_y_axis,FALSE)
#loop_with i=1..31
@v_x_axis2(%i)=(%i-1)*2
#loop_end
@v_y_axis2(1..31)=(0)
#loop_with i=1..30
@v_y_axis2(%i)=%v_y_axis2(%i+1)
#loop_end
@v_y_axis2(31)=random(0,100)
gra_Graph._set_data_set_values(2,%v_x_axis2,%v_y_axis2,FALSE)
ROOT.Hairline_Value
Exercises
Exercise 9
Notify
Change the hairline properties
when the check box value is
changed.
chk_Hairline
ROOT.Hairline_Setup
Init
Initialize the graph, data set and
the hairline in the graph init
method.
ROOT.Graph_Setup
ROOT.Data_Setup
gra_Graph
THIS._add_hairline(1)
ROOT.Hairline_Setup
Exercises
EXTRA
When the hairline is enabled two
buttons for moving the hairline will
appear.
Add a check box for freezing
the graph.
Hints:
Set the position attribute
in the hairline properties list
to move the hairline.
Exercise 9
Contents of Chapter 9
10 Appendix Image Editor
10.1
General
10.2
Drawing
10.3
Tool Box
Drawing Area
Color Palette
Line Width
Background Color
Foreground Color
A.2 Drawing
Hand
Dropper
Selection
Lasso
Fill
Spray
Eraser
Erases the image. Drag the eraser over the area you want
to erase. Press the shift key before erasing to constrain
the tool horizontally or vertically. To erase the whole
drawing area, click the drawing area and then double-click
the eraser.
Text
Allows you to type text and place it in the image. Click the Text tool and then the
drawing area. A dialog box will appear. Type the text and click OK. Once you click
OK, the text can not be edited. If you want to change the text, you must delete the
old text and type the new text from scratch. The text just entered can be removed
using Edit/Undo menu command. The font style can be changed by choosing Set
Font from the Tool menu.
Pencil
Draws one pixel at the time, using the Foreground color by default.
Line
Draws straight lines. Hold the Shift key down during the dragging to
constrain the line horizontally, vertically or to a 45-degree angle.
Ellipse
Draws an ellipse. Hold the Shift key down during dragging if you want to
form a circle.
Filled Ellipse
Rectangle