0% found this document useful (0 votes)
20 views22 pages

T306-04 Calculations - RevE

Chapter 4 of the System 800xA Training document focuses on calculations, detailing how to create, configure, and schedule calculations within the system. It covers the use of VBScript for defining calculation logic, the management of input/output variables, and various scheduling options including cyclic and time-based schedules. Additionally, it provides guidance on debugging, handling bulk changes, and monitoring calculation status information.

Uploaded by

rubhernandez
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)
20 views22 pages

T306-04 Calculations - RevE

Chapter 4 of the System 800xA Training document focuses on calculations, detailing how to create, configure, and schedule calculations within the system. It covers the use of VBScript for defining calculation logic, the management of input/output variables, and various scheduling options including cyclic and time-based schedules. Additionally, it provides guidance on debugging, handling bulk changes, and monitoring calculation status information.

Uploaded by

rubhernandez
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/ 22

System 800xA Training

Chapter 4 Calculations

TABLE OF CONTENTS

Chapter 4 Calculations ................................................................................................................................................................... 1


4.1 General Information ............................................................................................................................................................. 2
4.1.1 Objectives ..................................................................................................................................................................... 2
4.1.2 Legend .......................................................................................................................................................................... 2
4.1.3 Reference Documentation ............................................................................................................................................. 2
4.2 Overview ............................................................................................................................................................................. 3
4.2.1 Calculation Aspect ........................................................................................................................................................ 5
4.3 Create and Configure Calculations ...................................................................................................................................... 9
4.3.1 Adding a Calculation Aspect to an Object .................................................................................................................... 9
4.3.2 Editing the Code ......................................................................................................................................................... 12
4.3.3 Toolbar........................................................................................................................................................................ 15
4.3.4 Debugging................................................................................................................................................................... 16
4.4 Schedule a Calculation....................................................................................................................................................... 17
4.4.1 Cyclic Schedule .......................................................................................................................................................... 17
4.4.2 Time Based Schedule .................................................................................................................................................. 18
4.5 Handling of Calculations ................................................................................................................................................... 19
4.5.1 Bulk Changes .............................................................................................................................................................. 19
4.5.2 Reading Calculations Status Information ................................................................................................................... 20
4.5.3 Enable and Disable Calculations ................................................................................................................................ 21
4.5.4 Distributing Calculations on Different Servers ........................................................................................................... 21

Chapter 4 - 1
T306-04 Calculations - RevE.doc

4.1 General Information

4.1.1 Objectives
On completion of this chapter you will be able to:
 Create and configure Calculations
 Schedule Calculations

4.1.2 Legend
> Indicates when you go from one menu to a sub-menu
Italic Indicates object and file names
“ “ Indicates dialog box buttons, tabs, menus etc.
Bold Indicates important topics
Indicates start/explanation of student activity

4.1.3 Reference Documentation


3BUF001092 IndustrialIT 800xA Information Management
Configuration

Chapter 4 - 2
System 800xA Training

4.2 Overview
Calculations Services is used to configure and schedule calculations that are applied to
real-time database objects, including both softpoints and actual process points.
Calculations may also be applied to object types allowing the calculation to be re-used
each time a new object is instantiated from the object type. Calculations also have the
ability to update/insert a historically stored value into a numeric log.
Calculations can be triggered by changes to the inputs, or be scheduled to execute
cyclically or at a given date and time. A calculation aspect may be applied to any
aspect object such as a unit, vessel, pump, or softpoint. Inputs can be any aspect object
property, and outputs can be any writable point in the system. Input/output definitions
can be made relative to the object for which the calculation is defined. Data quality
and alarm generation are supported. Calculation logic is written in VBScript. The
ability to write a timestamp to a softpoint or a log is provided to align calculations
along with the inputs so they have the same timestamp for retrieval. Administrative
rights are required to add, configure, or modify calculations.

Input No. 1

Input No. 2
Calculation Output No. 1
Input No. 4

Input No. 4

NOTE! This shows a calculation with one output. Other


calculations may be configured with multiple inputs and
outputs.

Chapter 4 - 3
T306-04 Calculations - RevE.doc

The following calculation example finds the average value for up to four input
variables and writes the average to the output.

The main characteristics are:


 User-defined executable code (Visual Basic Script)
 Configurable input/output variables
 Simple schedule configuration
 Trace output window for debugging

Chapter 4 - 4
System 800xA Training

4.2.1 Calculation Aspect


All the Calculation process is programmed in a single Aspect.
Calculation aspects are typically added to a process or softpoint object in the realtime
database (in the Control structure) or an object type in the Object Type structure.
From these Calculation aspects, we can add the input Properties, the Output
Properties, and the Calculation script

Calculations can be run


on Cycle and on Event

O
I U
N T
Scripting
P P
U U
T T
S S
Standard Libraries
Data Transformation
to Non ABB data
Custom Libraries destination
(3rd party systems)

Requires no programming to access


Aspect Object Properties
Configuration only

Chapter 4 - 5
T306-04 Calculations - RevE.doc

In this example, the Calculations are created as aspects of objects in the Control
Structure.

The user interface for Calculations Services is comprised of aspect views that are
accessed via the Plant Explorer. The following aspect views are provided:
 Special Configuration for configuration of global parameters on the
Configuration Server level. In the Service Structure, The “Special
Configuration” tab on the Service Provider Definition aspect, supports
configuration of OPC update rate, scan rate for cyclic schedules, and cyclic offset
to stagger the start of cyclically scheduled calculations

Chapter 4 - 6
System 800xA Training

 Calculation Editor for configuring calculations. (the Script area in the


Calculation Aspect)

 Calculation Scheduler for scheduling calculations either cyclically or according


to a schedule. (In the Calculation Aspect, clicking the Toggle button between
calculation editor and scheduler views)

Chapter 4 - 7
T306-04 Calculations - RevE.doc

 Calculation Status Viewer for monitoring and managing calculations. To access


this viewer, go to the Service structure, select the Calculation Server, Service,
and then select the Calculation Status Viewer Aspect

Chapter 4 - 8
System 800xA Training

4.3 Create and Configure Calculations


Calculations are defined using VBScript. Any capabilities within VBScript or COM
technologies can be used to manipulate data. External functions and libraries may also
be used. Certain calculation properties are exposed for access by OPC client
applications. Once configured, calculations can be managed via the Calculations
Status Viewer.

4.3.1 Adding a Calculation Aspect to an Object


Calculation aspects are typically added to a process or softpoint object in the realtime
database (in the Control structure) or an object type in the Object Type structure.
In case of instances, for example, in the Control Structure

Select Calculation aspect type

Chapter 4 - 9
T306-04 Calculations - RevE.doc

In the Object Type Structure, A calculation added to an object type can be reused
each time an object is created from the object type. To do this, specify that the
calculation be copied when a new object is created.

Select Calculation aspect type

Chapter 4 - 10
System 800xA Training

Use the <object name> type definition aspect and check “copy to all instances” option
for the new calculation aspect. This aspect will be added in all new instances

NOTE! Remember to enable the calculation aspect for the


instantiated object. Use the “Enable” button on the
calculation aspect Tool Bar, or the Calculation Status
Viewer
A Calculation aspect can be applied to any object. They can be used to access process
data, databases and computer information.
The calculation aspect has two views - an editor and a scheduler. The editor is
displayed by default. This is where calculation variables are defined, VBScript written
and the trace feature enabled for debugging the calculation script offline.
Begin configuration by using the calculation editor to define variables and write the
script as described in Editing the Calculation. When the calculation is ready, use the

“Calculation/schedule” toggle button on the Tool Bar to switch to the scheduler


view.
Other procedures that can be performed via the editor include:
 Tracing the execution of a calculation.
 Forcing the execution of a calculation. The calculation can run on line or offline
for simulations when run manually.
 Enabling/disabling the execution.

Chapter 4 - 11
T306-04 Calculations - RevE.doc

4.3.2 Editing the Code


The calculation editor view is divided in to 3 parts.
The top part is a variable grid. This is used to map calculation input and output
variables to their respective OPC tags.
The middle part is an edit window for writing the VBScript.
The bottom part is a trace window. When tracing is enabled, trace statements in the
VBScript are processed, and the results are displayed in the trace window. Enable or
disable tracing via the editor’s context menu, or programmatically within the
VBScript. The trace window has a limit of about 20Kbytes which is equivalent to
about 10,000 characters.

NOTE! ”Settings.UpdateStatus = False” increases performance


by not updating the Aspect Server with status

In the Edit window you can write the VB code. “If” statement example

Chapter 4 - 12
System 800xA Training

In the Debug window messages are displayed

Variable Grid
The variable grid, is used to map calculation input and output variables to their
respective OPC tags. In addition to specifying the OPC data points for the variables,
use this map to specify:
 Whether to use the online data point value or a configured offline value.
 Whether to trigger the execution of the calculation when an input variable
changes.
Do not use analog variables to trigger the execution of a calculation.
The Variable grid consists of the following:

 Variable Name of the variable to be referenced in the script


 Object Name of the target aspect object
 Property Name of the target object property
 Direction Either input or output
 Online Value The current process value for the referenced aspect object and
(read only) property
 State Indicates whether Online or Offline value should be used at
runtime
 Event True indicates that changes to the referenced value should trigger
the calculation to execute
Variables can be divided in:
 On-line Variables Variables mapped to an outside property
 Off-line Variables Internal Variables
 Result Variable Variable showing the result value.

Chapter 4 - 13
T306-04 Calculations - RevE.doc

Writing VB Script
Calculation logic is written in VBScript. Use the edit window in the middle part of the
Calculation Editor to write the VBScript. Any capabilities within VBScript or COM
technologies can be used to manipulate data. External functions and libraries may also
be used. “If” statement example

The “Settings.UpdateStatus” defaults to False. This is to optimize performance.


Certain properties, mostly related to debugging, will not be updated when the
calculation is run on line.

4.3.2.1 Data Type Conversions


Variable1 = Variable2
In this example both variables must be of the same type. If not use Conversions
functions like:
Variable1 = CStr(Variable2), converts a number to a string
Variable1 = CDbl(Variable2), converts a string to a number

Chapter 4 - 14
System 800xA Training

4.3.3 Toolbar
The tool bar provides access to Calculation Editor Functions

NOTE! The Calculation Editor View does not prompt the user
when exiting and changes are pending. Use Save button
before leaving the display or pin the aspect.

Notes Icon
Saving changes completely replaces the original calculation. To preserve the original,
make a second copy to edit

Enable/Disable. Each Calculation must be assigned to a specific Service Provider


BEFORE enabling the calculation.
Run Calculation on the Server (Online). The calculation must be saved and enabled
before it is run

Run Calculation on the client (offline). The calculation must be saved before it is run.

Toggle between calculation editor and scheduler views.

Chapter 4 - 15
T306-04 Calculations - RevE.doc

4.3.4 Debugging
Tracing may be enabled when the Update Status is set to True. When tracing is
enabled, trace statements in the VBScript are processed, and the results are displayed
in the trace window. Enable or disable tracing via the editor’s context menu, or
programmatically within the VBScript.
The trace can be fine tuned by keying on one or more specific variables. The syntax is:
debug.trace <argument>. Use any argument that VBScript can convert to a string,
for example: debug.trace input1.quality. An error occurs when using an argument
which cannot be converted to a string. The example below shows how to enter a text
string in the trace window, and then append a variable property. The text string must
be entered in double quotation marks, and the variable.property specification must use
the & prefix to append it to the text string.

NOTE! Debug. Clear clears the trace window.

Chapter 4 - 16
System 800xA Training

4.4 Schedule a Calculation


The following scheduling options are supported for Calculation aspects:
 Calculations may be triggered by changes to input variables. Configuring an event
trigger for the calculation is done via the Event column in the Variable Grid.
 Calculations may be scheduled via the Scheduler view in the Calculation Editor.
This supports cyclical or periodic scheduling (date and time).
 Calculations may be scheduled via the Application Scheduler.
 Calculations may be run manually (one-time execution).
The complexity and scheduling frequency of a calculation may put an excessive load
on the system. For example, the time required to open the Plant Explorer may take
longer. This type of performance problems can happen when the UpdateStatus is
enabled.

4.4.1 Cyclic Schedule


To specify a cyclic schedule, make sure the Schedule check box is unchecked, and
then check the Cycle check box. In the corresponding fields specify the interval unit
(hours, minutes, seconds), and the number of intervals. The following example shows
a one-second cycle.

Chapter 4 - 17
T306-04 Calculations - RevE.doc

4.4.2 Time Based Schedule


To specify a time-based schedule, make sure the Cycle check box is unchecked, and
then check the Schedule check box. In the corresponding fields specify the time
components (year, month, day, hour, minute, second). The * character is a wildcard
entry which means every. The following example shows a time-based schedule that
will execute at 12:01:01 (one minute and one second after noon) on every day of every
month, for every year.

Chapter 4 - 18
System 800xA Training

4.5 Handling of Calculations

4.5.1 Bulk Changes


After creating several instances of an object type containing a calculation, it may
become necessary at some point to modify all calculations belonging to the objects of
that type. For example, a defect may be found in the source code of the calculation.
Opening and editing each calculation by hand to make the same fix could be time
consuming and introduce additional defects. The Clone function of the Calculation
Status Viewer is used to make such changes quickly and consistently.
Open the Calculation Status Viewer in the Service Structure.

Use the Calculation Status Viewer to select the group of calculations to be modified

Chapter 4 - 19
T306-04 Calculations - RevE.doc

Select the Master Calculation (C3) and choose the property to be cloned (Tracing
Enabled).

4.5.2 Reading Calculations Status Information


The Status View displays information about each calculation.

 Name Name of the calculation aspect


 Object Name Calculation owner object name
 Object Type Calculation owner object type
 Enabled Indicates whether the calculation is online
 Status Error code for the last execution (0 = SUCCESS)
 Message Error message for the last execution
 Last Execution Time at which the calculation was last executed
 Service Name of the service on which the calculation will
execute
 Execution Time Time in milliseconds the calculation required to execute
 Trace Indicates whether tracing is ON of OFF

Chapter 4 - 20
System 800xA Training

4.5.3 Enable and Disable Calculations


To enable or disable one or more calculations, select the calculations in the viewer,
then right click and choose Enable (or Disable) from the context menu,
Group operations are available from the context menu:
 Enable
 Disable
 Run (only for enabled or online calculations)
 Services (only for disabled or offline calculations)

4.5.4 Distributing Calculations on Different Servers


Assign each calculation to a specific Calculation Service Provider. First disable the
calculation, the click right and select “Services”.

NOTE! The Calculation Services are not redundant.


Select the server where the calculations should be run.

Chapter 4 - 21
T306-04 Calculations - RevE.doc

Chapter 4 - 22

You might also like