P287 SCIL Programming Basics.pdf

May 4, 2019 | Author: Oscar Garcia | Category: Scada, Boolean Data Type, Variable (Computer Science), Data Type, String (Computer Science)
Share Embed Donate


Short Description

Download P287 SCIL Programming Basics.pdf...

Description

   A    D    A    C    S   o   r   c    i    M

P287 SCIL Prog ro g rammi ramm i ng Basics

 AB B Oy Dis tr ib ut i on Au to mat io n NAME

RESP.DEPT.

PREPARED

SCIL Programming Basics

FISUB/RAE

24.08.2007 H.H.

COURSE ID

LANGUAGE

CHECKED

P287

En

05.09.2007 R.K.

REVISION

 APPROVED

 A

05.09.2007 M.M.

© ABB Oy P287 EN 1MRS751492-MTR

Table of Cont onte ent nts s 1

General General Infor matio n

2

Introduction

3

Programming Environ ment

4

SCIL SCIL Tools

5

Data Data Types and Objects

6

Variables Variables and Expressions

7

Commands and Functio ns

8

The SCIL SCIL Compi ler

9

Exercises

Contents of Chapter 1 1 General Infor mation 1.1 Course Schedule 1.2 Noti ce 1.3 Definitions and Abbr eviations 1.4 Course Presentation

Course Schedule Day 1 9:00

Introduction Programming environment SCIL tools Data types and objects Variables and expressions Exercises 1 - 3

11:45

Lunch

13:00

Commands and functions Exercises 4 - 8 SCIL compiler

16:00

Course ends

Notice

These documents have been assembled and produced for educational purposes. The contents of your course binder will not be updated to include future amendments. We appreciate your comments on our course documents. On the basis of practical experience and your feedback we can improve our courses in the future. The information in this document is subject to change without notice and should not be construed as a commitment by ABB. ABB assumes no responsibility for any errors that may appear in this document. This document and parts thereof must not be reproduced or copied without ABB’s written permission, and the contents thereof must not be imparted to a third party nor be used for any unauthorized purpose. Participation in a course is not only passive receiving of information but it requires activity on your part. Our courses contain several practical exercises. Make use of these opportunities to test and acquire familiarity with the equipment and aids used.  As a user of our training equipment, you must follow carefully the instructions given during the course. In no event shall ABB be liable for direct, indirect, special, incidental or consequential damages of any nature arising from the use of this document, nor shall ABB be liable for incidental or consequential damages arising from the use of any software or hardware described in this document. With best wishes for a rewarding course.  ABB Oy Distribution Automation Training Team

Copyright © ABB Oy Distribution Au tomation

Definitions and Abbrevations The following concepts and abbreviations appear in the course material. CAP 501

Relay Setting Tool Package

CAP 505

Relay Configuration and Setting Tools Package

COM 500

COM 500 communication server (gateway)

DCP-NET

Communication card with own processor, memory and communicaton software

DDE

Dynamic Data Exchange

DMS

Distribution Management System

DTU

Disconnector Terminal Unit for remotely controllable disconnector substations

EDM

Energy Data Management System

FA

Feeder Automation

HMI

Human-machine interface. The front panel of the relay

IT

Information Technology

LAN

Local Area Network

LIB 500

Standard Application Library, platform supporting the process-specific LIB 5xx packages

LIB 510

Standard Application Library for medium voltage level

LMS

Load Management System

LNT 505

LON Network Tool for installing and configuring devices to the LonWorks network

LON

Local Operating Network

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

Network Control System

NET

Communication unit which can be either software running on the operating system or software running on a separate communication card

ODBC

Open Database Connectivity

OLE

Object Linking and Embedding

OPC

OLE for Process Control is an industry standard based on the OLE/COM/DCOM technology of Microsoft Inc. The standard creates a common interface for communication between various devices controlling technological processes

PCLTA

PC LonTalk Adapter card which functions as a LonWorks network interface card for a PC

PC-NET

Communication software running on the Windows operating system

PLC

Programmable Logic Controller

RAS

Remote Access Service

RED

A relay product family provided by ABB Oy, Distribution Automation

REF 543

Feeder terminal for the protection, control, measurement and supervision of medium voltage networks

RTU

Remote Terminal Unit

SA

Substation Automation System

SCADA

Supervisory control and data acquisition system

SCIL

Supervisory Control Implementation Language

SM

On-Line Substation Monitoring

SMS

Substation Monitoring System

SPA

Strömberg Protection Acquisition. Communication protocol developed for SPACOM relays

SPACOM

A relay product family provided by ABB Oy, Distribution Automation

SRIO

SRIO 500M/1000M is a data communication and reporting unit for the SPACOM system. The task of the SRIO unit is to form the master unit of the SPA bus and connect the SPACOM system to a host computer

SYS 500

SYS 500 System Server is a system product based on the MicroSCADA technology. The system server contains data acquisition, supervising and controlling functions

TCP/IP

Transmission Control Protocol/Internet Protocol

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

 After this course the participant will be able to:

Basic knowledge of MicroSCADA and programming techniques.





use SCIL in object handling and calculations write simple programs in SCIL

Topics  

Partici pant profi le System engineers, maintenance engineers and persons who edit, build or maintain MicroSCADA systems.

  

SCIL programming environment SCIL commands and functions Data types and objects Variables and expressions Programming exercises

Contents of Chapter 2 2 Introduction 2.1 What is SCIL? 2.2 What can you d o w ith SCIL? 2.3 SCIL related manu als

Introduction 2.1 What is SCIL? engineering of the supervisory control system MicroSCADA.

Supervisory Control Implementation  

   1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

anguage

Introduction 2.2 What can you do wit h SCIL? , system. 



   2  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

 Application related features



Configuration related features



Communication related features

Some examples of what you can do with MicroSCADA: 

Design various forms of process control



Configure, supervise and handle system components

Introduction 2.3 SCIL related manuals programming is the SYS 600 Programming Language SCIL manual 

   3  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

There are also two manuals dealing with Visual SCIL programming, Visual SCIL  A lication Desi n and Visual SCIL Ob ects

Contents of Chapter 3 3 Programmin g Environ ment 3.1 Occurr ence of SCIL pr ogr ams 3.2 SCIL prog ram str uctu re 3.3 SCIL pro gram co mpon ents 3.4 Progr amming in SCIL 3.5 Acti vating SCIL progr ams 3.6 Special c haracters 3.7 SCIL names

Programming Environment 3.1 Occurr ence of SCIL Programs





Command procedures



Dialo s and dialo items Visual SCIL

In Classic Monitor applications, SCIL programs can also occur in picture programs.

   1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Programming Environment 3.2 SCIL Program Structur e , 65535 characters (including spaces). 

 A minus sign (-) at the end of a SCIL line indicates that the statement continues on the next line. 



 A line may be divided anywhere , within text constants.

Comments are preceded with a semicolon ( ; ), which indicates that the rest of the line is a comment. 

   2  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

marks (“;”) it is regarded as text.

comment 1 #loop_with- ;comment 2 i = 1..10 : : #loop_end 

Programming Environment 3.2 SCIL Program Structur e the program. 

Upper and lower case letters may be freely intermixed.



The SCIL programs do not demand any initiating or terminating statements, neither any kind of declarations.

@i_Number=123 #iF %i_nUMBER>100 #Then #bLoCk : : #block_END

   3  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Programming Environment 3.3 SCIL Program Components 

Commands 



These are words with a pre-declared meaning constituting orders to the system about steps to be t aken

Objects ,



Variables 



   4  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Variables are facilities for the temporary storage and use of changing data

Function calls



Expressions are formulas which can contain constants, object notations, variables, function calls and operators

Programming Environment 3.4 Programming in SCIL running. 

During program editing the system does not perform any SCIL syntax error control.



The Test Dialog is the main tool for testing SCIL programs, statements .

   5  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

SCIL editor

Test Dialog

Programming Environment 3.5 Act ivating SCIL Programs . Some of the more common are:

   6  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1



Command procedures started automatically by real or simulated process events, by time or from other SCIL programs



Visual SCIL dialogs can contain programs which are started automatically when a dialo is entered or exited, eriodicall with a certain time interval, and on the occurrence of a process event



User activated function keys in displays or buttons in Visual SCIL dialogs

Programming Environment 3.6 Special characters

* / ( , .. @

continuation of program line multi lication separator in picture paths left bracket marks an enumeration marks an index interval precedes a variable name by assignment precedes a control command recedes a icture command assignment greater than less than not e ual to

# ! = > <

+ ** \ ) . “ % ‘ : ; == >= 10 #then ...

Examples: 5 == 5 “AB” == “CD” ==    4  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

TRUE FALSE oo ean var a e %V is FALSE)

Data Types and Objects 5.5 Tim e CLOCK and various time stamp attributes of objects. 

Time data exists only internally (32-bit unsigned integer) and consists of the number of seconds passed since the beginning of 1978.



Time data can be given a readable representation by using the time . . , .

- @i_Hour = hour(clock) @t_Time = time(clock) t_T me_ = t me

; => 10 ; => “02-08-20 10:29” ; => “ - : ”

   5  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Data Types and Objects 5.6 Text , characters (all characters are allowed). 

In Visual SCIL objects a text can be up to 1023 characters.



In expressions text data must be enclosed in quotation marks ( “ ).



s ng e quo e or ou e quo es con a ne n a text must be typed as two single or double quotes. @t_String = “Example text” @t_String_2 = “What’’s this?”  _ _

   6  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Data Types and Objects 5.7 Bit Stri ng anything from 0 to 65535. 

The bits in a string are numbered from 1 to 65535 counting from left to right.



Bit strings have no visible representation, but they can be read as text .

@g_BS = bit_scan(“011001”) ; => 011001 @g_BS2 = bit_string(5,1,3,5); => 10101 t BS = bin % _BS2  _ => ”10101”    7  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Data Types and Objects 5.8 Byte Stri ng 8-bit bytes.

   8  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1



The length of a byte string may be anything between 0 and 8388600 bytes.



Byte strings can be constructed by the PACK_STR function.



Byte strings may be used to exchange binary data between SYS 600 and other (external) applications. @y_BS = pack_str((“a”,”b”,”cd”),”text”) ; => “abcd” (text) @y_BS2 = unpack_str(“abcde”,2) ; => (“ab”,”cd”,”e”) (vector)

Data Types and Objects 5.9 Vector  . 

 All data types are allowed in vectors, even so that different types are included in the same vector.



 A vector may contain up to 1000000 elements numbered from 1 to 1000000 (indexes). 

In Visual SCIL objects the maximum vector length remains at 10000 elements. Syntax: VECTOR [([element1 [,element], …)]

@v_Data = vector(1,1.25,4,”text”) @v_Data2 = (1,1.25,4,”text”) @v_Data3 = vector(10) ;One element

   9  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Data Types and Objects 5.10 List values. 

 A list can hold up to 1000000 attributes and the attributes can be of any data type.

Syntax: LIST(attribute=expression, attribute=expression, ...)

   0    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

@l_Attr = list(iu = 1,;In use oa = 14000,- ;Object addr. ss = 1) ;Switch state

Data Types and Objects 5.11 Object Categories three levels of system engineering: 



System Objects (system configuration and communication) 

Base system objects (B)



Communication system objects (S)

User interface objects 

Pictures



Visual SCIL objects

   1    1  ,    )   n   R    E   T    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Data Types and Objects 5.11 Object Categories  

Process Objects (P)



Event Handling Object (H)



Scale Objects (X)



Data Objects (D)



   2    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1



Time Channels (T)



Event Channels (A)



Free Type Objects (F)



Event Objects (E)



Variable Obe cts V

Data Types and Objects 5.12 Att rib utes and Methods and features of the objects. 

Through the attributes the SCIL programmer can use and change the object properties. also have a number of methods which are predefined programs or user e ne programs written in SCIL.

   3    1  ,    )   n   R    E   T    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Data Types and Objects 5.13 Object Handling .

   4    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1



Provided that write access is allowed, the values and properties can also be written by means of SCIL commands.



Object attributes are accessed through an object notation.



The system objects and most of the application objects are accessible within the entire system (global objects).



Visual SCIL objects are accessible from SCIL only within the same dialog .

Data Types and Objects 5.14 Object Notation System object notation: name:{application}type attribute{index}  Ap pl ic ati on ob jec t n ot ati on : name:{application}type{attribute}{index} ame:

 A

li cat io n:

Type:  At tr ib ut e:    5    1  ,    )   n   R    E   T    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Index:

ystem o ects ave pre e ne names w c are compose of three letters and a sequence number. Application object names can be freely chosen. The lo ical number of the a lication where the ob ect is stored. Generally not needed for system objects.  A character indicating object type (B,S,P,H,X,D,C,T,A,E,V,F) The attribute to be read or written by the notation. Generally two etter com nat ons  A number or a range of numbers.

Data Types and Objects 5.14 Object Notation ;Object Notation Examples

SYS:BUV(2) CB1:P10 DATA:D TASK:COS    6    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

;application 1 ;User defined global variable ; n ex o ;Process object value, index 10 ;Latest registered value in data ;object ;Program execution state ;0 = successful

Contents of Chapter 6 6 Variables and Expressions 6.1 Variables – General 6.2 Global v ariables 6.3 Local v ariables 6.4 Variable naming 6.5 SCIL co ntext 6.6 Variable expansion 6.7 Expressions – General 6.8 Expression composit ion 6.9 Arithm etical operators 6.10

Relation al operators

6.11

Logi cal operators

Variables and Expressions 6.1 Variables - General be assigned any value. 

 A variable has no fixed value and can be of any data type.



Variable value and data type can be changed at any time.



SCIL has two types of variables: 

Global



Local

   1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Variables and Expressions 6.2 Global Variables . 

 A global variable is created the first time a value is assigned to it.



 A global variable exists as long as the SCIL context .



Global variables are assigned new values usin the character and referred to with the % character.

Syntax: @name[component] = expression %name[component]

@i_Value = 123 @t_Text = “Text” %i_Value + 321

   2  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Variables and Expressions 6.3 Local Variables #LOCAL statement. 



Local variables are destroyed when the program is terminated. Identical variable names can be

Syntax: #LOCAL name [= value] [.name[=value]]

#local i_Value = 100 #local b_Value

a local variable is only visible in the program it is declared. 

Within a SCIL program the variable is referred to by its name (no special .

 b_Value = FALSE

   3  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Variables and Expressions 6.4 Variable Naming convention. , 444 => ;=> 1

Variables and Expressions 6.10 Relational Operators comparing expressions. 

The result of a comparison is always a Boolean value.



The relational operators have

Relational operators: == equal to > greater t an < less than unequal = >= greater than or equal to

the arithmetical.

123 > 321 2.17 FALSE ;=> TRUE ;=> FALSE

Variables and Expressions 6.11 Logical Operators on Boolean values. 

Logical operators: con unc on OR disjunction XOR exclusive or  og ca nega on

If an expression contains two or more different logical operators parentheses are required to specify the order. of type Boolean.



The result of lo ical o erations are of Boolean type.

 A TRUE FALSE

   2    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

FALSE

   

B

A AND B

A OR B

A XOR B

F ALSE

FA LSE

 

TRUE

TRUE

FALSE

 

TRUE

TRUE

FALSE

FALSE

TRUE FALSE

 

FALSE

NOT A  

FALSE TRUE  

TRUE

Contents of Chapter 7 7 Commands and Functio ns 7.1 SCIL comm and c ategories 7.2 Condit ional s tatements 7.3 Loops 7.4 Compoun d st atements 7.5 Object handlin g comm ands 7.6 Error handling p olicies 7.7 Funct ion s 7.8 Examples

Commands and Functions 7.1 SCIL Command Categories 

General SCIL commands 



Visual SCIL commands 





   1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

characterized by a starting # and can be used in all types of SCIL programs.

characterized by a starting dot (.) and can be used in dialogs and pictures

 Picture commands 

characterized by a starting ! and allowed only in pictures



can be used in pictures and Visual SCIL objects

Motif widget commands 

can be used in pictures and Motif widgets displayed in a X monitor 

Commands and Functions 7.2 Cond iti onal Statements executions.

   2  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

#case

#if

 

@i_Obj_Val = TUTOUT6_B1:P10

@i_Obj_Val = TUTOUT6_B1:P10

#case %i_Obj_Val #when 0 @i_Text = “Intermediate” #when 1 @i_Text = “Closed” #when 2 @i_Text = “Open” #when 3 @i_Text = “Faulty” #case_end 

#if %i_Obj_Val==0 #then @i_Text = “Intermediate” #else_if %i_Obj_Val==1 #then @i  _  Text = “Closed” #else_if %i_Obj_Val==2 #then @i_Text = “Open” #else @i_Text = “Faulty”

Commands and Functions 7.3 Loops  _ 

, one without (#loop). #loop

#loop_with

#local i_Number = 0 @i  _  Number = 0 #loop @i_Number = %i_Number + 1 #if %i  _  Number > 50 #then – #loop_exit #loop_end 100

   3  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

#loop_with i = 1..10 @v  _  Vector(%i) = “value_” + dec(%i) #loop_end 

#loo (even(second)) i_Number = i_Number + 1 #loop_end ;default value 1000

Commands and Functions 7.4 Comp oun d Statements  _  into one statement.

#block

#block

#if %var1 == 10 #then #block

#on cb1:E10 #block

@var3=%var1+10 #block_end  #else #block

@var3=%var1+25 #block_end 

@var3=%var1+25 #block_end 

   4  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Commands and Functions 7.5 Object Handl ing Commands , , system and application objects. #create, #set, #modify, #delete @l_Attributes = list(IU OX SS PT

= = = =

1,“Breaker” 1,1)

create CB1:P10 = %l  _ Attributes

;In use Ob ect text ;Switch state ;Process object type Create ob ect

#set CB1:PIU10=0 l Modified = list OX = “Disconnector”  _ #modify CB1:P10 = %l_Modified     5  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

#delete CB1:P10

SS = 0

;Delete object

Commands and Functions 7.6 Error handling poli cies #error command. #error ignore ERROR  #do …

#on error – @i_Status = console_output(“Error”)

#error continue ERROR  #do …

Error message displayed

ERROR  #do …

   6  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

error even ERROR  #do …

If no error handling policy is defined a default policy is applied (SCIL manual p.86).

Commands and Functions 7.7 Func tions , according to a predetermined algorithm. 





The argument list contains one or more expressions separated by commas. The expected data types of the , type of the result, are fixed by the function. Function calls are used as operands in expressions.

   7  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Commands and Functions 7.7 Func tions according to their functionality. E.g.:  

   8  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Generic Functions  Arithmetic Functions



Time Functions



String Functions



Bit Functions

function(argument(s))

LENGTH(“ABC”) == 3  MAX(1.0, 5, 3) == 5.0 ” - -



Commands and Functions 7.8 Examples . @i_ECode = status

** Error on this line**  _ #if %i_ECode0 #then@i_Status = console_output("Error code:"+dec(%i_ECode))

   9  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Commands and Functions 7.8 Examples . @v_Names = vector() “ ” “ ” #loop @l_Attr = next(1)  _ _  @v_Names = append(%v_Names, l_Attr:VLN) #loop_end   _

   0    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

=

_



_

.

”,

_

If there are no more objects to be found in the object database the next function returns only the IU attribute with the value -1

,

Commands and Functions 7.8 Examples . @v_Obj_Type = vector(“P”,”H”,”X”,”F”,”D”,”C”,”T”,”A”)  _  #loop_with i=1.. Length(%v_Obj_Type) @i_Count=%i_Count+application_object_count(0,%v_Obj_Type(%i))  _  @i_Status = console_output(dec(%i_Count))

   1    1  ,    )   n   R    E   T    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Commands and Functions 7.8 Examples . @l_Attr = fetch(0,”C”,”bgu_al”) #if l_Attr:VIU-1 #then #block #set l_Attr:VLN = ”bgu_al_new” #set l_Attr:VCM = ”New bgu_al command procedure” @l_temp = fetch(0,”c”,”bgu_al_new”) #if l_Temp:VIU==-1 #then #create bgu_al_new:c = %l_Attr #block_end 

   2    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Contents of Chapter 8 8 SCIL Compi ler 8.1 General 8.2 Perform ance impr ovement 8.3 Impact on SCIL prog rams 8.4 Avoiding pr oblems wi th SCIL co mpiler

SCIL Compiler  8.1 General command procedures can be compiled for better performance. 

Once a SCIL program is compiled, the compiled version is automatically used instead of the ori inal SCIL code.



The compilation function is selected from the picture editor or from the comman proce ure oo .

   1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

SCIL Compiler  8.2 Performance Improvement , between no improvement at all and up to 50 times faster. 

The average picture change time of a typical LIB 500 picture is reduced to about 2/3.

#loop_with i = 1..1000 : : #loop_end     2  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

 About 50 times faster when compiled.

#pause 10 : : : No performance improvement although compiled.

SCIL Compiler  8.3 Impact on SCIL Programs programs (except for the performance). 

There are however a few cases when compiled programs execute differently compared to uncompiled programs:  





 A vali d SCIL pr og ram may be i mp os si bl e to co mp il e. program may comp e u genera es a run- me error when executed.  A SCIL pro gr ams pr od uc es d if fer ent res ul ts w hen compiled compared to the uncompiled program.

Due to these possible incompatibilities the compiled SCIL program has to .

   3  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

SCIL Compiler  8.4 Avoiding Problems w ith Compilation variable expansion. 

To avoid potential problems the following recommendations on the use of variable expansion are given: 

Use direct variable access instead of expansion whenever possible. ' ' ' ', Instead of "'A'", write %A ( if A has a text value ) Instead of "X'A'Z", write "X" + %A + "Z" ( if A has a text value ) .



   4  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

When variable expansions are used as recommended above, the com iled and uncom iled ro ram alwa s behave identicall .

   5  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

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

Exercises Exercise 1 types and objects using the Test Dialog. Open the Test Dialog from the Tool Manager  .  After pressing the inspect button, the data type and value of the expression appears beneath the line.

Change the contents of the line to -2147483647 and press the inspect button. The integer range is from -2147483647 to 2147483647.

Change the last digit (7) to 8 (-> -2147483648) and press the inspect button. The data type changes from Integer to Real.    1  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Change the contents of the line to 321.123 and press the inspect button.

Exercises Exercise 1 ange

e ec ma s o .

->

.

an press

e nspec

u on.

Beneath the line the value 321.1111 is shown. A real number can only have seven significant digits.

Change the decimals to .77777 (-> 321.77777) and press the inspect button. .

.

.

Change the contents of the line to TRUE and press the inspect button. Beneath the line the data type (Boolean) and the value (TRUE) is show.

Change the contents of the line to CLOCK and check the Update check box. When the check box is checked the line will be updated every second. The CLOCK function shows the number of seconds passed since the beginning of 1978. The Test Dialog converts the value into a readable format (yy-mm-dd hh:mm:ss).

Uncheck the check box, change the contents of the line to “Exercise” the inspect button. Beneath the line the data type (TEXT), the length (8) and the value is shown.

 _     2  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1



 All the lower case letters are converted in to upper case letters.



.

Exercises Exercise 1 ange

e con en s o

e ne o

 _ 

” an press



e nspec

u on.

The BIT_SCAN function converts character strings to bit strings. The data type is BIT_STRING and the value is 101011.

 _ 



.



The BIN function converts bit strings, integers and vectors to texts and text vectors.

Change the contents of the line to BIT_STRING(4,1,4) and press the inspect button.  A bit strin with the value 1001 is created. The first ar ument is the number of bits in the bit strin and the following are the numbers of the bits that are to be set to one.

Change the contents of the line to PACK_STR((“1” ,”AB” ,”34”),” TEXT” ) and press the inspect button. The data type will be TEXT and the value will be “1AB34”. The PACK_STR function converts text vector to text or integer vector to bit or byte string.

Change the contents of the line to UNPACK_STR(“ AB CDEFG” ,2) and press the inspect .    3  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

The UNPACK_STR function creates a vector with the following elements : “AB”,”CD”,EF”,”G”.

Exercises Exercise 1 ange

e con en s o

e ne o



,

,

, , ,

an press

e nspec

u on.

 A vector with 6 different elements is created.

Change the contents of the line to (“A”,”B”,”C”,1,2,3) and press the inspect button. .

Go to the Examine page and write (“A”,”B”,”C”,1,2,3) on the command line and press the examine button. Change the contents of the line on the Examine page to LIST(LN="CB2",IX=11,OA=5) and press the inspect button.  A list with attributes and their expressions appear below the line.

   4  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Exercises Exercise 2 expressions using the Test Dialog.

Create the following two variables on lines 1 and 2 on the Commands page :  _  = @v_B=(2,4,6,8,10)

Vector 

Press the Execute button for each line. Write %i_A on line 1 on the Fields page and check the update check box. Change the value for i_A to 4321 and press the execute button. update check box is checked.    5  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Write %v_B on line 2 on the fields page and press the inspect button.

Exercises Exercise 2 ange

e con en s o

ne

o

v_ 

an press

e nspec

u on.

This will show the third element in vector v_B.

Change the contents of line 2 to %v_B(1..3) and press the inspect button. _ .

Create the following variables on lines 1 and 2 on the Commands page :  _ @t_B=“exercise” Remember to press the execute button after each line.

Write %t_A on line 1 and %t_B on line 2 on the fields page, then press the inspect button on both lines. Both variables are of data type TEXT, but the letters in variable t_A are in upper case.

Change the value of t_B to 4 and on line 3 on the commands page. Write    6  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

@t_C=“ ’t_A’_’t_B’” on line 4 on the commands page.

Exercises Exercise 2 r e

 _  on ne

on

e e s page an press

e nspec

u on.

By using the variable expansion a text variable with the value EXERCISE_4 has been created.

Select New from the file menu of the Test Dialog or press Ctrl- N. Evaluate the following arithmetical expressions on the Fields page : “Exer”+”cise” ** 100 DIV 3 100 MOD 3 5*10-10/2 * -

   7  ,    )   n   R    T    E    (    7   M      8   2    P   4  ,   y   1    5    O    7    B   R    B   M    A   1

Exercises Exercise 2 va ua e

e o ow ng re a ona opera ors on

e

e s page :

“A”==“B” “A”
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF