Wonderware Application Server - Best Practice Scripting

quicksandwalleyeInternet and Web Development

Oct 31, 2013 (5 years and 16 days ago)

7,746 views

© 2010 Invensys. All Rights Reserved. The names, logos, and taglines identifying the products and services of Invensys are pr
opr
ietary marks of Invensys or its subsidiaries. All third party
trademarks and service marks are the proprietary marks of their respective owners.

© Invensys 00/00/00

Invensys proprietary & confidential

Slide
2

Wonderware Application Server:

Best Practice in Scripting

PBWW232


Presented by:


Oliver Varosanec


Andrea Sartori


11/11/2011

Slide
3

Invensys Enterprise Control Offerings

Manufacturing / Production Operations

Corporate


Integration and

Collaboration Platform

Automation

Invensys and Third Party


Software Applications

Invensys and Third Party


Enterprise Control System


IT

Platform

Corporate Systems

Industry
Solutions


Services:

Consulting,
Project

Execution,

Learning,

Operational
Improvement,
Maintenance &
Support


Partner
Ecosystem



Slide
4

Integration &
Collaboration

Platform

Enterprise

Integration

Workflow

Open Device

Integration

Web
Portal

Application

Toolkit

Historian

Third
-
Party Offerings

Software Applications

Execution

Manufacturing Execution


Systems

Batch

Enterprise Asset
Management

Mobile Workforce
Management

Performance

Enterprise Manufacturing
Intelligence

Performance Measurement

and Reporting

Visualization

Quality

Asset
Performance

Optimization

Operator Training

Design

Advanced Process
Control

Simulation /
Optimization

Control

DCS

PAC

SCADA

HMI

Safety

Safety Instrumented Systems

General
Purpose

Safety

Turbomachinery Control


Measurement &


Instrumentation

Instrumentation

Controllers

Recorders

Automation

Software Applications

Where The Offerings We Will Discuss Fit Within The

InFusion Enterprise Control System

Slide
5

Introduction page

Oliver Varosanec, Technical Account Manager, Austria (Europe)



Slide
6

Introduction page

Andrea Sartori, Technical Account Manager, Italy (Europe)



Slide
7

Agenda

Scripting in Application Server

Use of .NET in Application Server

Best practices for Scripting in Objects

Best practices for Scripting in Graphics

Using Script Function Libraries

Using SQL Data Script Libraries

Questions

Slide
8

The Use of .NET in Scripting


What is .NET, a quick overview



.NET usage in Application Server


Object Scripts


ArchestrA Graphics


Custom Script Libraries

Slide
9

What is .NET and Why is it Useful for You?


The Microsoft .NET Framework is a software framework
that can be installed on computers running Microsoft
Windows operating systems.


It includes a large library of code solutions to common
programming problems and a virtual machine that
manages the execution of programs written specifically for
the framework.


The .NET Framework supports multiple programming
languages in a manner that allows language
interoperability.


Slide
10

What is .NET Framework

Common Language Runtime (CLR)


It is the foundation of the .NET Framework.

You can think of the runtime as an agent that manages code at execution time,
providing core services such as memory management, thread management, and
remoting, while also enforcing strict type safety and other forms of code accuracy
that promote security and robustness.

Class Library


The class library, the other main component of the .NET Framework, is a
comprehensive, object
-
oriented collection of reusable types that you can use to
develop applications.

The .NET Framework has two main components

Slide
11

What is .NET Framework

For further details:

http://msdn.microsoft.com/en
-
us/library/zw4w595w.aspx

Slide
12

How does it work?

Slide
13

Possibilities to use .NET Framework in
Wonderware Application Server.

QuickScript .NET
is the scripting language component that is an
enhanced version of InTouch QuickScript with and integration with
Microsoft .NET.

It can be add as an
ApplicationObject

(template or instance) using
the IDE Script Editor.

The editor exposes five script types:


Startup


Shutdown


Execute


OnScan


OffScan






Slide
14

SQL Server

AOS

Retrieve Data

System.Data.DataSet

XML File

DEMO

How to read data from Database and write it in a XML

Slide
15

Best Practices for Scripting

in Application Server Quick Script

Considerations to take into account…



Synchronous Scripts and Scan Overruns


Best practices for working with Asynchronous scripts


Useful Engine Attributes


Read/Write Interrupts


Standard, Full Interrupt, best practice how to use it


Slide
16

Scheduler Execution

NMX / LMX Output

DDE / Suitlink msg pump

Checkpoint

NMX / LMX Input and Idle time

0 1000 2000 3000


4000 5000

3650 4650

SuiteLink / DDE / OPC

LMX / NMX

Synchronous/Asynchronous Scripts

Slide
17

Synchronous/Asynchronous Scripts


The
synchronous

mode is the default choice and represents serial script execution by
the ApplicationEngine in the course of calling the Execute method of all ApplicationObjects
that are on
-
scan in the ApplicationEngine. For satisfactory determinism, this mode
requires that all scripts execute deterministically and quickly enough to prevent an
ApplicationEngine over
-
scan condition.



The
asynchronous

mode is used for the class of scripts that perform operations that
don’t meet the above speed and determinism criteria. These scripts will be executed on a
worker pool of separate, lower priority threads than the Application Engine’s primary
thread.

Slide
18

Scheduler Scan period


Idle Time



DI Objects sends any write requests to the external device



DI Objects process any updates from the external devices



Send all DI Object outputs (pokes and published subscriptions) to Off
-
engines



Off
-
engine inputs (pokes and subscription updates) are processed and sent
to all objects hosted by the AppEngine





Slide
19

Scheduler 3.0

Execute App
Objects

Send changes to
other engines

Prepare check
-
point data

Read Queued Input

Write checkpoint data
in separate thread

Read Inputs /

Idle

All Inputs are up to date at the
start of the next scan.

Execute DI’s


read/write values to server

Read/Write
interrupts

Read/Write
interrupts

Interrupts

Standard

Idle
-

Fixed

Slide
20

AppEngine R/W Interrupts


Standard: # Configurable


Full

Slide
21

Standard R/W Interrupts


DI Objects process Off
-
engine/On
-
engine write requests and
forward to DA/IO Server


Send write request originating from On
-
engine AppObjects to
Off
-
engine DI Objects


Benefits:
Send writes to field multiple times within a scan, as objects
are executing, rather than waiting until the idle period.

Writes to field occur more quickly.



Slide
22

Full R/W Interrupts: The Benefits

Same as Standard Mode, plus:


DI Objects receive new updates from DA/IO Server and update
AppObjects On
-
engine, Off
-
engine subscribers


Process incoming (Off
-
engine) writes (sets) or subscription updates
to AppObjects (On
-
engine)


Process updates from On
-
engine AppObjects to Off
-
engine
AppObjects


Publish data changes to visualization nodes and anonymous engines

Benefits:
Data gets updated quickly on visualization nodes.




Slide
23

R/W Interrupts


Monitoring

The following attributes are available:



Historize
R/W Interrupts time average

(
Scheduler.ExecInterruptsTimeAvg.Historized)

If enabled, the system will historize the average number of milliseconds
required to perform execution interrupts per engine scan cycle.



Scheduler.ExecInterruptsTimeAvg

The average number of milliseconds required to perform execution interrupts
per engine scan cycle.




Slide
24

SQL Server

AOS

Retrieve Data

System.Data.DataSet

Xml File

DEMO

Synchronous and Asynchronous execution of Scripts

See the different behavior of

Synchronous and Asynchronous scripts
when execution time exceeds the scan

Slide
25

Best practice of scripting in

ArchestrA Graphics


How to work with Client Controls, and expose Properties to the Data
Binding List


How to avoid performance Issues when using scripting in ArchestrA
Graphics


Slide
26

Introduction



What are ArchestrA Graphics



Overview


ArchestrA symbols are graphics you can
create to visualize data in an InTouch HMI
system.


You can re
-
use ArchestrA symbols that you
create in the Graphic Toolbox in
AutomationObject templates,
AutomationObject instances, or in InTouch
windows. This is called embedding.

Slide
27

Importing .NET Controls and Libraries


Import .NET
System.Windows.Forms


System.Windows.Forms.dll
resides in
C:
\
Windows
\
Microsoft.NET
\
Framework
\
v2.0.50727
\


Embedded WebBrowser
Client Control


Create Action Script to
Navigate URL


Embedded Symbol in
Intouch

Slide
28

Access Tree Control standard properties

Properties


Appearance


Modify position and size of
control


Runtime Behavior


Modify visibility and tab order


Layout


Access dock properties.

Slide
29

Exposing Custom Properties

Custom Properties


Misc


Build custom properties
for .NET


Code Sample

Slide
30

Binding to Properties of Client Control

Data Binding

You can bind the properties of an embedded client control to
attributes or element references.

Slide
31

Binding to Properties of Client Control

Slide
32

Scripting

Utilizing .NET Script Function library


.NET class library available within the Script Browser


By default, the System library is already included in the script function library.

Slide
33

Possibilities to use .NET Framework in
Wonderware Application Server.

Custom .NET Script Library's
import capability.

A
Custom DLL (Shared Library) is simply compiled code
that
contains
functions and data
which can
be used by another module
like a
application, DLL or in our case by QuickScript in Wonderware
Application Server.

Custom Script Libraries are integrated with System Platform by:


Importing multiple, independent DLL’s, or;


Importing multiple DLL’s that have dependencies into the Galaxy

Application Server support the import of .NET Script Libraries up to
.NET Framework 3.5 SP1




Slide
34

Import Multiple Custom DLL’s with
Dependencies.

All DLL’s with dependencies need to be imported as a aaSLIB File.


How do I create a aaSLIB File of my DLL’s



Use the
aaSLIB Utility
can be downloaded for free on ArchestrA
BIZ.


Technote 566
Ensuring Accurate and Consistent Deployment of
Custom Script Function Libraries


Technote 518
Managing Custom Script Function Libraries for Use
in Application Server

Slide
35

SQLData Components


SQLData Components


The Components

ArchestrA SQLDataGrid Symbol:

ArchestrA Symbol hosted in InTouch to enable user
interaction with SQL database


SQLData Object:
Application Object that facilitates
simple mapping of SQLData to Galaxy Attributes


SQLData Script Library:
Provide a set of Methods
and Properties to enable scripting of complex SQL
operations in Application Objects

Slide
36

Wonderware SQL Script Function
Library


Main Features

Provides database integration through ArchestrA scripting


Provides a simplified scripting interface to execute complex SQL
operations


Supports Asynchronous execution mode


Asynchronous execution prevents blocking the hosting App Engine

Supports Database Transactions


Developers have the option to rollback or commit transactions

Optimizes database interaction


Connection pooling minimizes connections to the Database

Provides advanced diagnostics


Provides a large set of diagnostic parameters to monitor execution

Slide
37

Accessing the SQLData Script Library


If you are using Application
Server 3.0 or later, it is
available in any new Galaxy


If you have upgraded your
Galaxy from a previous
version of Application Server,
you need to import the
aaDBIntegration.aaSLIB

library into the IDE


It can be downloaded on
WDN.wonderware.com for
free

Slide
38

Architecture

aaDBAccess

aaDBConnection

aaDBCommand

aaDBRow

aaDBTransaction

aaDBCommand

aaDBRow

CreateConnection()

CreateCommand()

CreateTransaction()

GetRow()

GetRow()

CreateCommand()

ExecuteSync()

ExecuteASync()

Slide
39

Transaction Support


Transactions are provided by the
aaDBTransaction

object



aaDBTransaction allows you to execute multiple commands as a
single unit: all commands either run as a whole, or not at all



If only one of the configured commands fails, the whole transaction
is rolled back

Slide
40

Questions ???

© 2010 Invensys. All Rights Reserved. The names, logos, and taglines identifying the products and services of Invensys are pr
opr
ietary marks of Invensys or its subsidiaries. All third party
trademarks and service marks are the proprietary marks of their respective owners.

Thank You