26
Scripting

Scripting in InduSoft Web Studio

Embed Size (px)

Citation preview

Page 1: Scripting in InduSoft Web Studio

Scripting

Page 2: Scripting in InduSoft Web Studio

Agenda• Introduction• Built-in Language• VBScript• Q&A

Page 3: Scripting in InduSoft Web Studio

Introduction

Page 4: Scripting in InduSoft Web Studio

Introduction

InduSoft Web Studio (IWS) is an easy-to-use configuration interface to designs projects for data communication (interoperability), data manipulation (portability), and data presentation (mobility).

Furthermore, when you need extra flexibility for data manipulation, it offers a complete set of tools for scripting, with full support for IntelliSense and debugging tools to increase productivity.

Page 5: Scripting in InduSoft Web Studio

Native LanguagesBuilt-In Language

Portability across all platforms, including Linux/VxWorks (IoTView)

Support for all tags, and built-in functions

Simplest syntax

Graphic: Screen Attributes Graphic: All animations (including

command) Task: All tasks (including Math and

Scheduler)

VBScript Language Flexible standard, supported by

different platforms Wide range of documentation and

examples Support for all tags, built-in

functions, variables, VBScript functions, and COM objects.

Simple syntax

Graphic: Graphic Scripts, Screen Scripts

Graphic: Command, ActiveX, .NET Controls, Custom Widgets

Task: Script

Page 6: Scripting in InduSoft Web Studio

Internal Architecture

Viewer.exe

Studio Manager.exe

TagsEngineDriver Runtime

DDE Client

DDE Server OPC Client

OPC Server

Database Client Runtime

ODBC Runtime Background Task

TCP/IP ClientTCP/IP Server

Viewer

AlarmsTrendsRecipesReportsMathScriptScheduler

Page 7: Scripting in InduSoft Web Studio

Tasks ExecutionStart BGTask

ExecutionGroup 1

Execute Group 1

ExecutionGroup 2

Execute Group 2

ExecutionGroup N

Execute Group N

F

F

F

T

T

T

Same algorithm for Math Task and Script Task

Math Task and Script Task are independent threads, so they can run “concurrently”. The execution of each thread is independent from each other.

The execution field either returns FALSE (0 or blank) or TRUE (any value different from 0). When it is true while the thread is checking the state of the Execution field, the respective Group is executed.

The state of the execution field during its respective Group execution is irrelevant.

Page 8: Scripting in InduSoft Web Studio

Built-In Language

Page 9: Scripting in InduSoft Web Studio

Built-in Language Main Characteristics

Support for all tags and 400+ built-n functions (Arithmetic, Statistical, String, File, Loop, etc)

Syntax for each field: Tag and/or Expression fields: Just write the expression. E.g.: Abs(TagA) Label, Caption, Hyperlink, Message, or File Name fields: Just write the expression

between curly brackets. E.g.: {Abs(TagA)}

Value attribution: The equal sign (=) is NEVER used to assign a value. The equal sign (=) is ALWAYS used for comparison. In order to assign a value, write the expression in the EXPRESSION field and the tag that should receive the value in the TAG field (Math and Scheduler groups).

Page 10: Scripting in InduSoft Web Studio

VBScript Language

Page 11: Scripting in InduSoft Web Studio

VBScript Scope Diagram

Page 12: Scripting in InduSoft Web Studio

Interface

Library ExecutionScope and Lifetime of

variables and proceduresVariables Procedures BGTask

(Server)Viewer(Local)

Global Procedures Yes Yes** Yes** Global

Graphic Scripts Yes Yes YesGraphic Script*Screen Script*Screen Controls

Screen Scripts Yes Yes Yes Screen ScriptScreen Controls

Screen Controls(Command, ActiveX, .NET) Yes Yes Screen Control itself

Startup Script Yes Yes Yes Startup ScriptScript Groups

Script Groups Yes Yes Script Group itself

* Using the Graphics.<Variable_or_Procedure_name> syntax.** Global Procedures is a repository (library) of user-defined sub-routines and functions, which can be called from any VBScript interface in the project. It is not an execution module (thread) by itself.

VBScript Scope Summary

Page 13: Scripting in InduSoft Web Studio

User $ as a prefix to access tags and built-in functions

Declaring variables (Dim) and constants (Const)

Calling Procedures (Call) and defining parameters (ByRef, ByVal)

IntelliSense

VBScript Editor

Page 14: Scripting in InduSoft Web Studio

Built-in $Trace() function

VBScript MsgBox function

Error Handling with On Error Resume Next / On Error Goto 0

Output Window messages

Troubleshooting – Basic tools

Page 15: Scripting in InduSoft Web Studio

Troubleshooting – Debug Tools

Page 16: Scripting in InduSoft Web Studio

If…Then statement executes a set of code when a condition is true

If...Then...Else statement selects one of two sets of lines to execute

If...Then...ElseIf statementselects one of many sets of lines to execute

Select Case statement selects one of many sets of lines to execute

Conditional Statements

Page 17: Scripting in InduSoft Web Studio

For…Next statement runs code a specified number of times

For each...Next statement selects one of two sets of lines to execute

Do...Loop statementselects one of many sets of lines to execute

Looping Statements

Page 18: Scripting in InduSoft Web Studio

Date/Time functions (DateAdd, DateDiff, etc)

Conversion functions (Asc, Chr, etc)

Format Functions (FormatDateTime, etc)

Math Functions (Rnd, Sqr, etc)

Array Functions (Ubound, etc)

String Functions (LCase, Ucase, etc)

Other Functions (MsgBox, InputBox, CreateObject, etc)

VBScript functions

Page 19: Scripting in InduSoft Web Studio

$RunGlobalProcedureOnServer()

$RunGlobalProcedureASync()

$RunGlobalProcedureASyncGetStatus()

$RunGlobalProcedureOnFalse()

$RunGlobalProcedureOnTrue()

$RunGlobalProcedureOnTrigger()

Advanced built-in functions

Page 20: Scripting in InduSoft Web Studio

InduSoft Web Studio main Database/ERP built-in functions:

$DBExecute()

$DBCursorOpenSQL()$DBCursorClose()$DBCursorRowCount$DBCursorGetValue()$DBCursorNext()

Database Interface

Page 21: Scripting in InduSoft Web Studio

ActiveX interface (properties, methods, and events)

COM Server interface (CreateObject statement)

ActiveX and COM Servers

Page 22: Scripting in InduSoft Web Studio

InduSoft Web Studio Technical Reference Manual (Help)

W3SCHOOLS Web Site (http://w3schools.com/vbscript/default.asp)

Microsoft MSDN

(http://msdn.microsoft.com/en-us/library/t0aew7h6)

Additional References

Page 23: Scripting in InduSoft Web Studio

Q & A

Page 24: Scripting in InduSoft Web Studio

How to contact InduSoft

Page 25: Scripting in InduSoft Web Studio

Email(US) [email protected](Brazil) [email protected](Germany) [email protected]

Support [email protected] site

(English) www.indusoft.com(Portuguese) www.indusoft.com.br(German) www.indusoft.com.de

Phone +1 (512) 349-0334 (US) +55 (11) 3293-9139 (Brazil) +49 (0) 6227-732510 (Germany)

Toll-Free 877-INDUSOFT (877-463-8763) Fax +1 (512) 349-0375

Contact InduSoft Today

Germany

USA

Brazil

Page 26: Scripting in InduSoft Web Studio

Thank you!