Académique Documents
Professionnel Documents
Culture Documents
Training Manual
Revision A
August 2009
Part Number 11-GM-10014
ArchestrA Object
Toolkit 3.1
INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE.
2009 by Invensys Systems, Inc. All rights reserved. No part of this document may be reproduced, stored in
or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical,
photocopying, recording or otherwise), or for any purpose, without the express written permission of Invensys
Systems, Inc. Except where noted, the companies, organizations, products, domain names, e-mail
addresses, logos, people, places and events depicted herein are fictitious and no association with any real
company, organization, product, domain name, e-mail address, logo, person, place or event is intended or
should be inferred.
Invensys and the author(s) assume no responsibility for errors or omissions and no liability is assumed for
damages resulting from the use of the information contained herein. Use of the Invensys software described
in this document is subject to the terms of the applicable Invensys Systems, Inc. / Wonderware license.
These terms include provisions that limit your rights such as use restrictions, disclaimers of warranties and
limitations of Wonderware / Invensys liability. By installing or using the Invensys software, you agree to accept
all of the terms of the applicable Invensys Systems, Inc. / Wonderware license. A copy of the applicable
license will be displayed upon initial installation of the software. If a copy of the license is not displayed or you
require an additional copy of the license, you may obtain one from Invensys' Wonderware business unit by
calling 1.949.727.3200 or by sending an e-mail to support@wonderware.com.
Table of Contents
Module 1 Introduction .................................................................................1-1
Section 1 Course Introduction......................................................................... 1-3
Section 2 System Platform Review............................................................... 1-15
Lab 1 Creating the Galaxy...................................................................... 1-17
Section 3 ArchestrA Object Toolkit Overview ............................................... 1-23
Section 4 System Requirements, Licensing, and Support............................ 1-29
Wonderware Training
Module 1
Introduction
Section 1 Course Introduction 1-3
Section 2 System Platform Review 1-15
Lab 1 Creating the Galaxy 1-17
Section 3 ArchestrA Object Toolkit Overview 1-23
Section 4 System Requirements, Licensing, and Support 1-29
1-2 Module 1 Introduction
Module Objectives
List the objectives of the course and describe the agenda
Describe what the ArchestrA Object Toolkit is used for and list its main features
Wonderware Training
Section 1 Course Introduction 1-3
Section Objectives
Describe the objectives of the course.
Summarize the product offerings provided with the Wonderware Software Solutions.
This section describes the ArchestrA Object Toolkit course and agenda, and it provides an
overview of Wonderware solutions and product offerings.
Course description
The ArchestrA Object Toolkit course is a 3-day, instructor-led class that provides lectures and
hands-on labs designed to demonstrate the creation and development of Application Objects
using the ArchestrA Object Toolkit 3.1 software. In this course, you will create, configure, and
deploy Application Objects using the ArchestrA Object Toolkit, Microsoft Visual Studio, and
Wonderware System Platform. You will learn about the general object development cycle, and you
will leverage the power of reusable code through the use of object-oriented building blocks, such
as utility primitives provided with the software and custom primitives you will create. You will also
create and customize you own object editor.
Objectives
Upon completion of this course, you will be able to:
Create custom ArchestrA Application Objects using the ArchestrA Object Toolkit and
Microsoft Visual Studio
Take advantage of the code reusability features in the ArchestrA Object Toolkit
Audience
Current Wonderware System Platform users who want to extend the capabilities of their System
Platform through the creation of custom ArchestrA Application Objects.
Prerequisites
The prerequisites for this course are:
Wonderware System Platform Part 1 course
Knowledge of C# and Microsoft Visual Studio .NET
Manufacturing industry experience
Agenda
Module 1 Introduction
Section 1 Course Introduction
This section describes the ArchestrA Object Toolkit course and agenda, and it provides an
overview of Wonderware solutions and product offerings.
Section 2 System Platform Review
This section describes the fundamental concepts and architecture of the Wonderware System
Platform.
Lab 1 Creating the Galaxy
Section 3 ArchestrA Object Toolkit Overview
This section provides a high-level overview of the ArchestrA Object Toolkit and describes its
features and components. It also includes an overview of ArchestrA objects.
Section 4 System Requirements, Licensing, and Support
This section describes the hardware recommendations and software requirements for the
ArchestrA Object Toolkit. It also explains how to access product support.
Wonderware Training
Section 1 Course Introduction 1-5
Wonderware Training
Section 1 Course Introduction 1-7
These solutions leverage a powerful, layered software architecture that enables a variety of
features and capabilities, such as visualization, optimization and control of plant floor data
collection, and data storage and analysis.
Dev
InteSystem Engelopm
grato inee ent Con
r r
Opetrol R
Infr
rato oom
r P
Suproducti
Ope astru
ervis on
or
P
Eng rocess
Pla
rat ctur
IT inee
.F Bu i n &
r Ope Line Mo
bile
.P acilit
rato
i on e
r Use
ld r
owe ies s O pe
Tra M
.T n rG an rate Q
Eng uality
sm en ag inee
.W ransp issio eratio emen
r
P
ate o n n& t Eng rocess
.E r & rtatio
inee
r
t c. Wa n Ma
Opeintena
ste rato nce
wat Ma
i
r
er Evo ntain Ma
lve & IT
Sup intena
ervis nce
or
Ma
n
per ctu O ufa
Machin
.D
.F iscre atio ring
ns
e
.M odo t eM
a
.O ining & Beve nufac
Sys .S il& & r a turin
t
Con em & pec Gas Meta ge g
nec Dev P ls
.E harm ialty C
Line
tivi ice
ty tc. ace hem
/ De
utic
al ical &
par
tm
nt e
Plan
t / Sit
es
E n te rp ris e
historian solution is unlike any other data archiving and reporting solution found in the
market today. With blazing speed, broad scalability, highly efficient data storage and
retrieval, high availability and simple one-click historization setup, the Wonderware
Historian software has an industry reputation for low total cost of ownership.
Preconfigured Web-based reports and data analysis capabilities drive immediate value
from data captured by the Wonderware Historian.
Batch Management Wonderware batch management solutions perform repeatable and
consistent execution of batching processes across all hybrid industries, whether it is
electronic batch records (EBR) systems in regulated industries, Paper-On-Glass
capabilities in paperless production environments, or automated recipe management for
supervisory systems. From simple batch processes, where only the formula changes for
different products, to the most complex batch processes requiring dynamic allocation of
shared equipment, Wonderware has a solution. Each of these solutions ensures reduced
lifecycle costs and investment protection by leveraging the ArchestrA architecture.
Product Quality Management and SPC Delivering products with high quality defined
as meeting specifications at the lowest possible cost is a top priority for manufacturers
and industrial operations, and Wonderware software applications meet these quality
needs. InTouch HMI offers real-time data monitoring and alarming; Wonderware Historian
stores voluminous process data for quality analysis; Wonderware QI Analyst software
provides enterprise-wide SPC; Wonderware ActiveFactory software trends data;
Operations & Performance software provides spec management, genealogy, BOM
enforcement, OEE and Downtime monitoring; the Wonderware System Platform monitors
data levels, and application templates can help deliver nearly any quality capability;
InBatch software collects information on batch quality and recipe settings; and the list
goes on.
Mobile Solutions Wonderware mobile solutions feature the industry's leading Mobile
Workforce & Decision Support System. Wonderware IntelaTrac enables the delivery of
Best Practices to field workers improving Asset Management for the leading refiners,
chemical manufacturers, and power generators globally.
For more information on Wonderware software solutions and products, visit the Wonderware Web
site at http://www.wonderware.com.
Wonderware Training
Section 1 Course Introduction 1-9
ArchestrA technology
ArchestrA technology, or architecture, helps reduce application engineering effort and deployment,
increase efficiency, provide optimization and standardization, and enable integration of distributed
automation systems and applications from virtually any vendor. Geographically dispersed
applications (from a few hundred to one million I/O, and from a single node to hundreds of
stations) can be rapidly and securely implemented.
The ArchestrA architecture leverages advanced software technologies to fill the gap between ERP
systems and control systems. This architecture provides the following:
Framework which supports common services and a core set of system objects
Domain Objects which are industry-specific objects
Object Development Toolkit which enables third parties to create new domain objects
customized for specific needs
The supervisory control and manufacturing information environment is served by a variety of
systems, including (HMI), Distributed Control Systems (DCS), Supervisory Control and Data
Acquisition systems (SCADA), Process Information Management systems (PIM), Manufacturing
Execution Systems (MES), batch and recipe management systems, and advanced control/
simulation systems. The ArchestrA Framework supports core services that are required by most of
these different types of supervisory control and manufacturing information systems.
These core services include the following:
Integrated Development Environment (IDE)
Version management
License management and centralized deployment
System diagnostics and system administration
Internationalization
Data visualization and monitoring
Event-based processing, scripting, and calculation capabilities
Alarm and event management, historization and security
Data acquisition and field device integration
Inter-object communications and name service
Reporting and ad-hoc query capability
Support for industry standards such as OPC and SQL
The ArchestrA architecture consists of the following:
Configuration and Deployment Related Components that are required for centralized
deployment of the runtime components. These components are installed just like any
other Windows application and include the following:
Centralized object repository (called Galaxy Repository)
Integrated Development Environment (IDE)
Object deployment services (called Bootstrap)
Runtime Components that are centrally deployed and administered. These components
include the following:
PCs with core infrastructure (called Platforms)
Key software applications (Engines)
Objects (Framework Objects) that expose framework related functionality
Wonderware Historian
The Wonderware Historian component of the System Platform is a high-performance, real-time
database for historical information. It combines the power and flexibility of a relational database
with the speed and compression of a true process historian, integrating the office with the factory
floor or any industrial operation. The Wonderware Historian is designed to collect a wide variety of
plant data, at full resolution and very high data rates.
Wonderware ActiveFactory
The Wonderware ActiveFactory software provides data-trend analysis, sophisticated numerical-
data analysis using Microsoft Excel, comprehensive data reporting using Microsoft Word, and the
capability to publish real-time and historical plant information to the Web or company intranet site
using Wonderware Information Server. Plant knowledge workers using ActiveFactory information
can quickly troubleshoot problems, study potential process inefficiencies, and eliminate the time-
consuming process of locating the data.
Wonderware Training
Section 1 Course Introduction 1-11
Wonderware QI Analyst
Wonderware QI Analyst Statistical Process Control (SPC) software is an important part of any
quality management program. Performing both online and historical SPC, QI Analyst supports
real-time process monitoring and alarms, as well as historical reports to view process health over
any period of time. Real-time SPC, analysis, and reporting are equally easy. By storing process
data in the QI Analyst database and linking to external data sources, users can leverage
enterprise-wide SPC to reduce variation, reduce costs of manufacturing, and increase productivity.
Wonderware SCADAlarm
SCADAlarm alarm and event-notification software provides a telecommunications link to industrial
automation software systems. It seamlessly integrates with the comprehensive Wonderware
product family and has built-in browsers to enable fast configuration of information from
Wonderware System Platform and InTouch HMI software.
Wonderware Toolkits
Wonderware Toolkits provide powerful extensibility to InTouch HMI and System Platform
applications by enabling developers to extend the capabilities of Wonderware products to meet
specific system integration needs. The Toolkits promote adherence to industry standards, provide
additional customization and intellectual property protection, and enhance the ability to interface
Wonderware products with other software and hardware.
Wonderware offers the following Toolkits:
Wonderware Training
Section 1 Course Introduction 1-13
Wonderware IntelaTrac
Wonderware IntelaTrac is a suite of configurable software and ruggedized mobile hardware
products that provides workflow management, procedural and general task management
capabilities typically focused around plant operations, maintenance management, and production
tracking and compliance applications to mobile field workers.
Wonderware Training
Section 2 System Platform Review 1-15
Section Objectives
Explain what components comprise the Wonderware System Platform
Describe the benefits of an integrated ArchestrA architectural environment
This section describes the fundamental concepts and architecture of the Wonderware System
Platform.
Introduction
The Wonderware System Platform is a strategic industrial application platform built on ArchestrA
technology which uses Wonderware Application Server as its foundation. Designed to suit the
needs of industrial automation and information personnel, the System Platform provides a single,
scalable software platform for Geographically Distributed SCADA (Geo-SCADA), Supervisory
HMI, and Production and Performance Management software solutions. The System Platform is a
unified bundle of previously available Wonderware software products, including: Wonderware
Application Server, Wonderware Historian, Wonderware Information Server, and Device
Integration products.
The Wonderware System Platform contains an integral core set of capabilities and services to
support sustainable production and operations performance improvement through a
comprehensive set of six capability areas:
Industrial domain services for industrial computing functions that are not provided by
commercial operating systems or products
Software and device connectivity services for easy communication to virtually any
plant or business information source
Information and data management services for management of real-time and historical
information
Information delivery and visualization services for functions that provide information to
the right user at the right time, and in the form in which they expect it
Application development services that provide easy and intuitive development of
modular industrial software solutions that can be easily changed to meet future needs
System management and extensibility services that provide easy management,
expansion, and modification of the application or the computing architecture
The ArchestrA technology that the System Platform is built on is a comprehensive plant
automation and information architecture designed from the outset to extend the life of legacy
systems by leveraging the latest software technologies. For more information, see ArchestrA
technology on page 1-9.
In the ArchestrA environment, software applications can be rapidly assembled rather than
programmed. New applications also can be created simply through the reassembly of existing
applications. The ArchestrA Integrated Development Environment (IDE) provides a centralized
environment for development, deployment, and maintenance of scalable, secure, and
standardized information and automation applications.
WonderwareClients
InTouch ActiveFactory InformationServerCAL
(Visualization) (AnalysisClient) (ReportClient)
WonderwareSystemPlatform
ApplicationServer InformationServer
Historian
DeviceIntegrationProducts
Wonderware Training
Lab 1 Creating the Galaxy 1-17
Objectives
Upon completion of this lab, you will be able to:
Set up the Galaxy required for testing the objects in subsequent labs
Wonderware Training
Lab 1 Creating the Galaxy 1-19
4. Click Create.
5. After the Galaxy is created, click Close.
6. When the Connect to Galaxy dialog box reappears, click Connect.
Wonderware Training
Lab 1 Creating the Galaxy 1-21
13. In the Network address field, enter the node name of your local computer.
17. In the Deploy dialog box, verify that Cascade Deploy is checked
Wonderware Training
Section 3 ArchestrA Object Toolkit Overview 1-23
Section Objectives
Describe the features and components of the ArchestrA Object Toolkit
Summarize the characteristics of an ArchestrA object
This section provides a high-level overview of the ArchestrA Object Toolkit and describes its
features and components. It also includes an overview of ArchestrA objects.
Note: DIObjects are not supported in this release of the ArchestrA Object Toolkit.
The Toolkit tightly integrates with the Microsoft Visio Studio 2008 development environment and
provides easy-to-use tools to integrate development for ArchestrA base template objects.
With the Toolkit, developers can:
Configure an objects general properties, attributes, and primitives using an easy-to-use
object designer while maintaining synchronization with the underlying code
Graphically visualize an objects shape and easily navigate to all sections of an objects
code using a hierarchical, collapsible tree structure
Create a custom editor for an application object that allows end-users to easily configure
the objects attributes
Quickly enter code leveraging Microsofts Intellisense feature
Create standardized reusable primitives (compiled code modules that can be reused in
multiple custom application objects)
Build encapsulated .aaPDF files and automatically import them into the Galaxy for testing
Debug all aspects of the base template object leveraging Microsoft Visual Studio
debuggers and the ArchestrA aaLogger
Toolbar
Wonderware Training
Section 3 ArchestrA Object Toolkit Overview 1-25
Options
Deploy/Undeploy
Restart Processes
Dependent File Manager
Migrate
Validate
Logger View
Debug
Help
Build Mode
ArchestrA Object Toolkit menu commands
The ArchestrA Object Toolkit menu commands are located under the Tools menu in Visual
Studio.
Logger View
The Logger View allows you to check for any errors and warnings that may be reported by the
ArchestrA Object Toolkit. The Logger View shows the same ArchestrA Logger messages that you
see in the ArchestrA Log Viewer. The Logger View is intended for quick reference; it does not offer
the full functionality of the ArchestrA Log Viewer.
Wonderware Training
Section 3 ArchestrA Object Toolkit Overview 1-27
Object Designer
The Object Designer allows you to edit and configure the properties for your object template and
configure the objects attributes, primitives, and supported methods and properties.
This data is always synchronized with the objects underlying code. For example, when you use
the Object Designer to change the properties of an attribute, you will see the updated property
values in the code, and vice versa.
Although you can edit all aspects of your object directly in the underlying code, it is easier, and is
recommended, to edit your objects using the Object Designer. The Object Designer also allows
you to perform tasks that impact multiple code sections simultaneously (such as renaming
attributes, adding local primitives, and changes associated with modifying an objects major
version).
The Object Designer window contains the following panes:
Shape Shows the structure (shape) of your object. You can edit your object here by
adding and deleting attributes and primitives.
Configuration Allows you to set and modify parameters for the application object,
attributes, and primitives. The parameters in this pane change according to which item is
currently selected in the Shape pane. For example, with the top-level object item selected,
you can configure the global properties for the object.
Attributes Shows a list of all custom attributes in your object, including their
configuration.
Configuration
Shape
Attributes
Wonderware Training
Section 4 System Requirements, Licensing, and Support 1-29
Section Objectives
Describe the hardware recommendations and software requirements for the ArchestrA
Object Toolkit
Explain how to access product support
This section describes the hardware recommendations and software requirements for the
ArchestrA Object Toolkit. It also explains how to access product support.
Hardware recommendations
The following are the hardware requirements and recommendations for ArchestrA Object Toolkit
version 3.1.
The Windows Vista operating system imposes hardware requirements that may exceed the
minimum requirements for Application Server version 3.1. If you intend to install the ArchestrA
Object Toolkit on a computer running Windows Vista, see the following Microsoft Web site for
hardware requirements:
www.microsoft.com/windows/products/windowsvista/editions/systemrequirements.mspx
Software requirements
Note the following requirements, compatibilities, and prerequisites that must be met for the proper
operation of ArchestrA Object Toolkit 3.1.
Note: For the most recent Vista restrictions, refer to the documentation included with
Wonderware Application Server.
Software prerequisites
The ArchestrA Object Toolkit requires that the following software be installed:
Microsoft Visual Studio 2008 with the following components:
Visual C#
The Tools and Runtime libraries of Visual C++
Application Server version 3.1 with all the features of Bootstrap, IDE, and Galaxy
Repository
Microsoft .NET Framework 2.0
Internationalization
The Object Designer is supported only in English. Development of objects with localized external
names is supported using localized versions of Visual Studio 2008 for Simplified Chinese,
Japanese, French, and German locales.
All tools and examples provided by the ArchestrA Object Toolkit work with English, French,
German, Japanese, and Simplified Chinese Locale operating systems and the matching versions
of Visual Studio 2008.
Licensing
For information on licensing and licensing requirements, contact your local distributor.
Installation
For instructions on installing ArchestrA Object Toolkit, see the Readme.html file located in the root
folder of the installation CD.
Product support
Wonderware provides responsive, award-winning teams of specialists committed to delivering
world-class customer support, training, and consulting services. For information on the various
customer support programs, contact your local distributor or access the Wonderware Technical
Support site online at http://www.wonderware.com/support/mmi/
You will find a variety of information on the Technical Support site including the Wonderware
Developer Network (WDN) Library, Documentation, FAQs, Tech Alerts, Tech Articles, Tech Notes,
and Tech Support Forums. When you first enter the site, you will have limited access. To gain
access to the different areas and services, you must first register.
Also on the Technical Support site is the Technical Support Policies, Terms & Conditions guide
which provides information on how to contact Technical Support, information on the support
policies and procedures, and much more.
Wonderware Training
Module 2
Module Objectives
Explain the concepts of ArchestrA application object design
Using the ArchestrA Object Toolkit and Microsoft Visual Studio, create a simple
application object and configure it with basic functionality
Wonderware Training
Section 1 Application Objects Design Overview 2-3
Section Objectives
Discuss the concepts of an application object and identify its pieces
Describe a typical workflow for developing ArchestrA application objects
Explain how to use the ArchestrA Object Toolkit to define an object and its attributes
Describe the Counter object that will be built in this course
This section describes the concepts, development workflow, and best practices for designing
ArchestrA application objects. It also provides an overview of the Counter object, which will be built
in this course.
Overview of objects
Application objects represent plant equipment and instrumentation such as pumps, valves, They
usually get their source data from other objects, such as device integration objects. To the end
user, the application object seems monolithic. It has attributes and behaviors, and the ArchestrA
IDE is used to configure the attributes by means of an object editor or a Galaxy Load.
The object's state is validated and the object can be deployed. During runtime, the object exhibits
interesting behavior and operators can interact with it through its attributes. However, an object is
not monolithic. It has several pieces, as shown below:
The Attribute Definitions piece is an XML file containing all the information that defines the
shape of the object. It contains a list of all the attributes an object contains, and their data types,
default values, specifications, and so on. Your job as a developer is to define, using Object
Designer or directly in code, the various attributes your object will have and the configuration for
those attributes.
The Runtime piece is a DLL file containing the code that defines the behavior of the object when it
is deployed and executing in runtime. Your job as a developer is to customize this runtime code to
make the object execute in runtime whatever custom logic you want it to execute.
The Configtime piece is a DLL file containing all the code necessary for configuration validation.
This code ensures that when a user enters configuration information in the ArchestrA IDE, the
information is valid, has the right format, and that it makes good sensethat it is consistent with
the configuration of the rest of the object. Your job as a developer is to customize this validation
logic in Visual Studio using C#.
The Editor piece is a DLL file containing a form for the objects editor (graphical interface) in the
ArchestrA IDE. Users will use this editor to configure the objects parameters. Your job as a
developer is to customize this editor by placing .NET controls on the form for UI elements, like
check boxes and text boxes, to enable users to configure the information the object needs to
execute the logic.
As stated above, the Runtime code, Configtime code, and Editor are separate DLL files. This
means that they can be loaded individually by the different processes provided by the System
Platform, for example, by the Galaxy Repository (GR) process, ArchestrA IDE process, or
Application Engine process.
All of these pieces within an object are needed because in reality your object does not run in one
single place. The code for your object can run in different places, and potentially, depending on the
architecture of your Galaxy, can run in different computers.
For example, as shown below, you may have a highly distributed Galaxy where you have a node
dedicated for the Galaxy Repository, and you run the ArchestrA IDE in a separate engineering
station dedicated to configuration and application development, and then you run the Application
Engine and Platform (the runtime) in a separate Automation Object Server (AOS).
(aaGR.exe)
App Engine
Configtime IDE (aaEngine.exe)
(aaIDE.exe)
Editor Platform
MS SQL
Server DB
Attribute
Bootstrap
Definition
In this configuration, when you first import your object template using the ArchestrA IDE on the
engineering station, the IDE connects to the GR on the GR node, and the GR stores the Attribute
Definition information in the Microsoft SQL Server database. The GR is responsible for managing
all the configuration information in the Galaxy and will store and retrieve information from Microsoft
SQL Server as needed.
When you use the ArchestrA IDE on the engineering station to configure the objects derived
templates and instances, the IDE will load the Editor (the graphical UI) so you can configure the
object. Every time you enter a value in the editor and save it, the GR loads your Configtime code
in the GR, and the Configtime code executes your custom validation logic.
Note: The editor is just a graphical interface used to configure your objects. The editor is not
supposed to have any validation logic; the Configtime code does the validation.
Wonderware Training
Section 1 Application Objects Design Overview 2-5
Then, when you go to the ArchestrA IDE and send the command to deploy the object, the
command goes to the GR, and the GR retrieves all the custom configuration information coming
from Microsoft SQL Server and attaches the information to your Runtime code. This logic then
goes to the Application Engine on the AOS to be executed in runtime.
So ultimately, your object, which seems monolithic, is not one single piece in reality. From the
developers perspective, the code is split into pieces that run in different places and may
potentiality run in different computers.
Primitives
The Attributes Definition, Editor, and Runtime pieces are delivered by smaller implementation
pieces called primitives. Primitives are the building blocks of an object. They have their own
attributes and behaviors. By modularizing your object into primitives, you can create a clear,
logical structure and dynamically enable or disable functionality as needed.
For an overview of primitives, see page 3-3.
Also see the following sections for information on the different types of primitives:
Local primitives This type of primitive is defined and used in one single object. See
Local Primitives Overview on page 6-3.
Reusable primitives This type of primitive can be reused in multiple objects. See
Reusable Primitives Overview on page 6-19.
Virtual primitives Both local and reusable primitives can be made virtual. A virtual
primitive allows you to dynamically add and delete instances of the primitive at configtime.
See Virtual Primitives Overview on page 5-3.
Utility primitives A utility primitive is a predefined reusable primitive that provides
common functionality. See Utility Primitives Overview on page 3-7.
Plan
Before you start defining your object, you should plan its features and structure. You should decide
how to design the objects structure by using primitives. You should make a list of the attributes
that your object and any of its primitives will need, and develop a naming structure.
Create Project
You create a project for every application object or reusable primitive that you want to create.
ArchestrA Object Toolkit projects are simply Visual Studio projects of a special type. You create
and manage them just like other Visual Studio projects.
When you first create an object, the ArchestrA Object Toolkit creates a solution folder containing
four projects. One project corresponds to the object. It contains a general definition of the object
and is responsible for packaging the object into a base template that can be imported into the
Galaxy. The other three projects contain the files for the configtime, runtime, and editor code.
Define
This step typically involves the tasks listed below.
Configure your objects basic properties, such as name and description (see Object
configuration on page 2-7)
Define the shape of your object by adding attributes (see Attribute configuration on page
2-8)
Structure your object by adding primitives (see Primitives on page 3-3)
Customize code for your objects configtime and runtime events and set handlers (see
Sections 2, 3, and 4 in this Module)
Create a custom object editor that your users can use to configure the objects properties
in the ArchestrA IDE (see Editor Design on page 7-3)
Configure associated files in case your object uses any external files or assemblies (see
Dependent Files on page 8-21)
Configure other object properties, including Advise Only Active support, the objects
behavior in the ArchestrA IDE, and dump/load or failover support for dynamic attributes
Add object help that end users can access from the ArchestrA IDE (see Application
Objects Documentation on page 8-3)
Localize text strings and create a central repository for user messages (see Object
Dictionary on page 8-5)
Build
When you build your object, the ArchestrA Object Toolkit creates an .aaPDF object file that
contains your custom application object (or an .aaPRI file if youre developing a reusable
primitive). You can then import your object into the Galaxy, instantiate it, and deploy it to runtime.
You can also import, instantiate, and deploy the object automatically as part of the build process,
and you can configure various build options.
Wonderware Training
Section 1 Application Objects Design Overview 2-7
Object configuration
Once you have created an ArchestrA Object Toolkit project in Visual Studio, you can start defining
your object in the Object Designer.
If the Object Designer is not open, click the Object Designer button ( ) on the ArchestrA
Object toolbar.
Selecting the top-level object item in the Shape pane allows you to configure the objects global
properties in the Configuration pane shown below.
The parameters you can configure for the object are described below.
External Name Name of the object that will be exposed in the ArchestrA IDE, must be
ArchestrA compliant (Unicode), maximum length 31 characters
Internal Name Name of the object that represents the instance of the class in code,
must be C# compliant (ANSI), maximum length 329 characters
Dump/Load support For Dynamic Attributes & Virtual Primitives Preserves the
current configtime status and configuration of dynamic attributes and virtual primitives in
derived templates and instances
Failover support for Runtime Dynamic Attributes In a redundant application engine
environment, preserves any dynamic attributes created at runtime if a failover occurs
Advise only Active supported Stops individual attributes from updating if no one is
subscribing to them. This reduces the processing and network load. Individual attributes
also need to be configured for Advise Only Active support
Category Type of object (Application Object or Reusable Primitive)
Version Current build version of the object, defaults to 0 and can be manually set or
automatically incremented according to the parameters set in the Options window (see
Version on page 2-15)
Min IAS Version Minimum version (and patch) of Application Server for which the
object is designed, prevents users from importing the object into earlier versions
Vendor String identifier for vendor name, used internally to organize the code in the GR,
must not contain double-byte characters or any characters that are invalid in Windows file
names
Toolset Toolset to place the object in when importing into the ArchestrA IDE, the list of
toolsets displayed in the drop-down list can be specified in the Options window (see
Toolset Names on page 2-16)
Description Short description of the object (for example you could describe the purpose
and usage of the object), corresponds to the ShortDesc attribute in runtime, maximum
length 1024 characters
YOu can also configure the following parameters when you use the expandable sections found at
the bottom of the Configuration pane:
Associated Files Files that are automatically associated with building the set of
assemblies and the .aaPDF or .aaPRI file
Configuration Event Handlers Adds a section for configtime event handlers in the
source code so you can add code
IDE Behavior Controls various aspects of the objects behavior in the ArchestrA IDE,
such as hiding the object from certain views and disabling some commands
Advanced Configuration Determines the execution order of primitives within the
object, and specifies that a primitive should use assemblies other than the ones
automatically generated
Attribute configuration
Attributes are the data items of an application object or primitive. By reading from and writing to
attributes, objects can exchange data with each other. In addition, your objects can also have
Inputs and Outputs to communicate with other attributes in the ArchestrA environment.
Note: Unless specifically noted, attributes in this manual mean ArchestrA attributes, not C#
attributes.
Wonderware Training
Section 1 Application Objects Design Overview 2-9
Once you create your object, you can start adding attributes to it. The easiest way to add attributes
to an object is by using the Object Designer. In the Shape pane, select the location in the tree
you want to add the attribute, click the Add button ( ),and then click Attribute.
When you create an attribute, the ArchestrA Object Toolkit will create a variable in code so that
later you can use it in your custom configtime and runtime code.
As you add attributes to your object, you will see them in the hierarchical list in the Shape pane.
You can also see all the attributes in the Attributes pane, shown below. This shows a flat list of all
the attributes in your object (as you would see in Object Viewer). You can expand this pane to see
more information. Also, you can filter the list to show configtime or runtime attributes only.
The abbreviated column headings in the Attributes pane are described in the following table:
Heading Description
FA Frequently Accessed option is enabled
CQ Calculated Quality option is enabled
Cfg Configtime set handler is enabled
Run Runtime set handler is enabled
Al Attribute is alarmed
His Attribute is historized
Selecting an attribute in either the Shape pane or Attribute pane allows you to configure the
attributes properties in the Configuration pane shown below. (You can also configure attributes
directly in code.)
The parameters you can configure for the attributes are described below.
External Name Name by which other objects can access the attribute, must be
ArchestrA compliant (Unicode), maximum length 31 characters
Note: Using the dot (period) is often used to create a hierarchy of related attributes. This
is acceptable for the external name, but not for the internal name. If you enter a dot in an
external name, the ArchestrA Object Toolkit substitutes the dot with an underscore in the
internal name. For guidelines on naming attributes and primitives, see Appendix B in the
ArchestrA Object Toolkit Developers Guide.
Internal Name Name used in code to refer to the attribute, must be C# compliant
(ANSI), maximum length 329 characters
Type Corresponds to the ArchestrA data type (see Data Types on page 2-13)
Category Determines who can write to the attribute and whether it is lockable in the
template (see Attribute Categories on page 2-11)
Configuration Set Handler Allows you to create custom configtime set handlers for the
attribute (see Configtime set handler event on page 2-37)
Runtime Set Handler Allows you to create custom runtime set handlers for the attribute
(see Runtime set handler event on page 2-38)
Support Calculated Quality and Calculated Time Enables the object to set the
attributes quality (for example, Bad or Uncertain) and timestamp (see Quality and
Timestamp Handling on page 3-37)
Frequently Accessed Marks the attribute as Frequently Accessed which is used as a
special filter in the Galaxy Browser to display only Frequently Accessed runtime attributes
Wonderware Training
Section 1 Application Objects Design Overview 2-11
Note: You should mark only key runtime attributes as frequently accessed. For example,
the standard $FieldReference object has just one frequently accessed attribute.
Advise only Active Enables Advise Only Active support for the attribute, which allows
you to configure the attribute to stop updating if no one is subscribing to it, thus reducing
the processing and network load
Value Allows you to set a default value for the attribute, and for user writeable attributes,
set the security classification
You can also expand the sections at the bottom of the Configuration pane to make the attribute
an array and configure default values for the array elements, and to enable and configure history
and alarms for the attribute.
Attribute Categories
Whether an attribute appears in an objects configtime namespace, runtime namespace, or both is
mainly controlled by the attributes Category.
An attributes category provides the ArchestrA framework with a great deal of information. In
addition to determining which namespaces an attribute appears in (configtime, runtime, or both),
an attributes category determines whether the attribute can be written to, and what type of client
(users, scripts, etc.) can write to it.
Lockable Attributes
Some attributes categories allow an attribute to be locked. The value of a locked attribute cannot
be modified, not even internally by the objects configtime or runtime code.
Attributes in primitives that are used by an object can be locked in the Object Designer. In addition,
ArchestrA IDE users can lock attributes to protect the configured values within a template from
being changed by other engineers who derive instances or templates from it.
In general, make attributes lockable whenever possible. Lockable attributes allow users to enforce
standards and can simplify system maintenance. Locking data also helps minimize the size of a
systems configuration database, which improves the speed of configuration tasks.
Note: An exception will be raised if an objects logic attempts to modify a locked attribute. This
must be taken into account when coding the object. Before modifying a lockable attribute, always
examine it to see if it is locked. This will not be necessary for a lockable attributes SetHandler
method, which will never be executed if the attribute is locked.
Security Classifications
Some attribute categories allow an attribute to be written to by users (operators, engineers, etc.) at
runtime. These attributes have an additional configurable property called a Security
Classification which determines what permissions an operator needs in order to write to the
attribute, such as Tuning, Operate, Config, and so on. (See the ArchestrA Object Toolkit
Developers Guide for a list of all security classifications.)
Security classifications can be changed in the Object Designer. They can also be modified later by
an ArchestrA IDE user to enforce site-specific security rules. By default, new attributes are created
with the Free Access security classification, which means that any user can write to them.
Note: Security classifications are only effective if security is enabled in the Galaxy.
It is important to select a category that only allows as much access to an attribute as necessary.
For example:
An attribute that is used only by configuration logic to add or remove virtual primitives (see
page 5-3) should be given a category that prevents it from becoming part of the runtime
namespace (for example. PackageOnly).
An attribute that does not need to be configured in an editor should be given a category
that prevents it from becoming part of the configtime namespace, and the objects editor
(for example, Calculated).
An attribute that needs to be configured and deployed but is not allowed to be modified at
runtime should be given a category that prevents users or other objects from writing to it
(for example, Writeable_C_Lockable).
Wonderware Training
Section 1 Application Objects Design Overview 2-13
Data Types
Objects you create using the ArchestrA Object Toolkit can have attributes of any standard data
type that is supported in the ArchestrA environment. The following table lists the available data
types. For more information on data types, see Appendix D in the ArchestrA Object Toolkit
Developers Guide.
Equivalent C#
Data Type Valid Values Notes
Data Type
Boolean bool True, False (default:
False)
Integer int -2147483648 to
2147483647, signed
(default: 0)
Float float 3.40282 E+38 to - 32-bit IEEE single-precision floating point, used
3.40282 E+38, signed when 6-7 significant digits are needed. Smallest
(default: NaN) representable absolute value is 1.175 E-38.
Double double 1.79769 E+308 to - 64-bit IEEE double-precision floating point,
1.79769 E+308, used when 15-16 significant digits are needed.
signed (default: NaN) Smallest representable absolute value is 2.23
E-308.
String string 0 to 1024 characters, Variable-length Unicode string, size: 4 + 2*n
default: empty string bytes (n = number of characters)
Time DateTime Microsoft FILETIME 64-bit FILETIME value in UTC (Coordinated
values (default: zero Universal Time). Represents the number of
time) 100-millisecond ticks since January 1, 1601,
00:00:00 (zero time).
Elapsed Time TimeSpan Number of 100-ms Stored as a 64-bit FILETIME structure. For
ticks, signed (default: example, -1 corresponds to a duration of -
0) 00:00:00.0000001.
Attribute string Valid reference strings Standard structure containing a reference string
Reference (default: empty string and MxHandle (bound or unbound). A string of
and null handle) --- results in a null handle, and no warning is
generated when the object is validated (i. e.
when the user saves the object configuration).
A string of ---.--- results in a null handle, but a
warning is generated on validation.
MxStatus ArchestrA.Core Default: Success Standard structure containing access status
.MxStatus information for a Message Exchange call.
Data Type ArchestrA.Core Enumeration, see Data type of an attribute. Valid enumeration
.MxDataType notes (default: values are: MxNoData, MxBoolean, MxInteger,
MxNoData) MxFloat, MxDouble, MxString, MxTime,
MxElapsedTime, MxReference, MxStatus,
MxDataType, MxSecurityClassification,
MxQuality, MxCustomEnum, MxCustomStruct,
MxInternationalizedString and MxBigString.
Custom string array Default: ordinal=1, Enumerations start at the value 1. Zero is not a
Enumeration String=String1 valid ordinal value for an enumeration.
Custom ArchestrA.Core Default: GUID = 0, Provides support for custom data in the form of
Structure .MxCustomStruct length = 0. a GUID and byte array.
Internationalized 0 to 1024 characters, A vector of strings and corresponding locale IDs
String default: empty string in the configuration database. An MxString at
runtime.
Equivalent C#
Data Type Valid Values Notes
Data Type
Big String string 0 to 2147483647 Variable-length Unicode string, size: 4 + 2*n
characters, default: bytes (n = number of characters)
empty string
Variant CMxValue N/A Use this data type if the actual type of an
attribute cannot be determined in advance.
The options are separated by categories, shown on the left side of the dialog box.
Build
In the Build category, you can specify options for debugging and copying build-generated files.
You can choose to attach the following debuggers to debug your object:
IDE Debugger to debug custom editor code
Configuration Debugger to debug configtime code
Runtime Debugger to debug runtime code
Note: Once the build is finished, Visual Studio switches into debugging mode. To stop
debugging, click the Debug button ( ) on the ArchestrA Object toolbar.
Wonderware Training
Section 1 Application Objects Design Overview 2-15
Also, you can specify to copy the following build-generated files to different folders:
The build output files to a custom folder instead of the \Output subfolder of your project
folder. This allows you to use a common location for all objects.
Reusable primitives to a subfolder of the ArchestrA C:\Program Files\Common
Files\ArchestrA\ReusablePrimitives folder. The folder will be created using the reusable
primitives vendor name.
Version
In the Version category of the Options dialog box, you can specify to keep the current version
number when you build your object, or you can automatically increment the major or minor
version. (You can also specify the version number of the object manually in the Object Designer.)
Galaxy
In the Galaxy category of the Options dialog box, you can specify which Galaxy to use when you
use the automated import, instantiate, and deploy build modes. You can also set the default Area
to assign the object instances to.
Note: In most cases, it is best to use a Galaxy on the local machine. Otherwise, the build process
cannot automatically restart the Application Server processes to make sure that the latest object
version gets used.
Toolset Names
In the Toolset Names category of the Options dialog box, you can configure the toolset names
that appear in the drop-down list in the Object Designer in the Configuration pane for the object.
Toolset names are saved in an XML file and can be saved in a central network location to share
across multiple systems.
Wonderware Training
Section 1 Application Objects Design Overview 2-17
Search Paths
In the Search Paths category of the Options dialog box, you can specify one or more additional
locations for dependent files. This gives you more flexibility because you can store your
development files in multiple locations.
Note: If you want your end users to be able to configure your attributes in the ArchestrA IDE, you
need to add the necessary UI elements for the attributes on your custom object editor form. Users
cannot use the User-Defined Attributes (UDAs) tab in the standard editor to configure these
attributes.
To begin creating the custom editor, double-click Editor in the Object Design View. An Editor
form appears in the Visual Studio Design view. It already contains a tab page. This is the first
custom tab page that appears when you edit your object in the ArchestrA IDE.
Tab pages
You can create multiple custom tab pages for your object editor. In the ArchestrA IDE, these
custom tab pages appear alongside the standard tab pages that are shown for every object
(Object Information, Scripts, UDAs, etc.). You can hide these standard editor tabs if you do not
need them (in Object Designer, check the option under IDE Behavior).
To rename a tab, change its Text property in the Visual Studios Properties window.
To add a new tab, right-click the forms tab control and click Add Tab.
Tab control
Placing controls
To place controls onto your custom editor, you can simply drag attributes from the Object Design
View onto the tab page. The ArchestrA Object Toolkit then automatically adds a standard label as
well as ArchestrA controls for editing the value, security classification, and lock status of that
attribute.
You can also use the standard controls from the Visual Studio toolbox and special ArchestrA
controls that you add to the toolbox. For information on using the ArchestrA controls, see Editor
Design on page 7-3.
Wonderware Training
Section 1 Application Objects Design Overview 2-19
Once a control is placed on the tab page, you can use the Visual Studios Properties window to
set its properties, such as label or internal name. You can also double-click on a control to edit its
source code.
The graphic below illustrates the final Counter object you will build in the upcoming labs.
Count
INPUTPRIM
Count.Input
VIRTHISTORYPRIM
CountHistory
MaxCount
ResetOnScan
EngUnits
TimeSinceChange
Timeout.Limit
Timeout.Condition
VIRTALARMPRIM
TimeoutAlarm
Reset
Counter Reset.InputEnabled
VIRTINPUTPRIM
Reset.Input
Stats.Enabled
RolloverCnt
VIRTPRIM
BadInputCnt
Stats
Reset
CountRate.Enabled
Legend
ExistingAttrib DataTypes:
PRIMTYPE Boolean
ArchestrA PrimitiveName Integer
Object NewAttrib Float
Implemented String
method Time
ADDITIONAL ElapsedTime
Wonderware Training
Section 1 Application Objects Design Overview 2-21
if (EngUnits.Value.Length < 1)
{
//EngUnits is empty. Generate a warning
AddWarningMessage("Engineering Units is empty");
status = EPACKAGESTATUS.ePackageWarning;
}
else
{
//Object is good.
status = EPACKAGESTATUS.ePackageGood;
}
Wonderware Training
Lab 2 Developing the Counter Object 2-23
Count
Note: See page 2-19 for
Counter
Execute() a legend to this graphic.
Objectives
Upon completion of this lab, you will be able to:
Create an ArchestrA Object project in Microsoft Visual Studio
Use Object Designer to configure and shape an object
Edit the source code to implement an objects runtime behavior
Configure the Galaxy options for a project
Use the Build Mode and Build commands to build, instantiate, and deploy a developed
object
f. Test the connection to the Galaxy, and set the parameters as default.
g. Ensure that the Version options are set to Increment Major Version and Delete all
templates with the same vendor and object name, and then set as default.
h. Use the ArchestrA Object toolbar to build, import, and instantiate the Counter object.
i. In the ArchestrA IDE, deploy the Counter_001 instance.
j. Open Object Viewer from within the ArchestrA IDE and rename the default watch window to
Counter Info.
Wonderware Training
Lab 2 Developing the Counter Object 2-25
l. Save the watch list to your training folder (C:\Wonderware Training) with the name Dev
Watch Windows.
Wonderware Training
Lab 2 Developing the Counter Object 2-27
8. In the Shape pane, click the Add button , and then click Attribute.
Note: You can dock the Logger View and Object Design View windows if you want.
Wonderware Training
Lab 2 Developing the Counter Object 2-29
12. Modify the Counter_RuntimeExecute method to make it look exactly like this:
private void Counter_RuntimeExecute(object sender)
{
//Code in this method is executed in runtime every scan
//while the object is On Scan
16. Click the Test button to test the connection to the Galaxy.
A success message appears:
Wonderware Training
Lab 2 Developing the Counter Object 2-31
The Build dialog box appears and shows the progress as the object is being built, imported
into the Galaxy, and instantiated.
Wonderware Training
Lab 2 Developing the Counter Object 2-33
31. Right-click in the watch window (bottom pane), and click Rename Tab.
Wonderware Training
Lab 2 Developing the Counter Object 2-35
36. In the Save As dialog box, browse to your training folder (C:\Wonderware Training) and
enter Dev Watch Windows as the File name.
Wonderware Training
Section 2 Attribute Set Handlers 2-37
Section Objective
Describe the configtime, runtime, and GetStatusDesc attribute set handlers
Explain how to enable attribute event handlers in the Object Designer
This section describes and explains how to configure the configtime, runtime, and GetStatusDesc
event set handlers for attributes.
ConfigtimeSetHandlerEventArgs class
ConfigtimeSetHandlerEventArgs is a class that provides configtime set handlers with the
information they need when called.
Syntax
public class ConfigtimeSetHandlerEventArgs : SetHandlerEventArgs
Members
Message A string that the user can set to write a message back to the set handler
caller when an error or warning is needed. The message must be empty for the set
handler to be successful.
Syntax
string Message
Wonderware Training
Section 2 Attribute Set Handlers 2-39
RuntimeSetHandlerEventArgs class
RuntimeSetHandlerEventArgs is a class that provides runtime set handlers with the information
they need when called.
Syntax
public class RuntimeRuntimeSetHandlerEventArgs : RuntimeSetHandlerEventArgs
Members
attributeInfo the SetInfo of the current set
Syntax
SetInfo attributeInfo
status A status to report the status of the set handler back to the caller
Syntax
MxStatus status
Time The timestamp of the value being set
Syntax
DateTime Time
Quality The data quality of the value being set
Syntax
CMxDataQuality Quality
RuntimeGetStatusDescEventArgs class
This class is the argument to the GetStatusDescription event.
Syntax
public class RuntimeGetStatusDescEventArgs : EventArgs
Members
status A string describing the detailed error code.
Syntax
string status
detailedErrorCode The detailed error code to look up for a description.
Syntax
short detailedErrorCode
Wonderware Training
Lab 3 Implementing Set Handlers 2-41
Count
MaxCount
Reset
MaxCount_ConfigtimeSH() Note: See page 2-19 for
Counter MaxCount_RuntimeSH() a legend to this graphic.
Reset_RuntimeSH()
Execute()
GetStatusDesc()
EDITOR
Objectives
Upon completion of this lab, you will be able to:
Add and implement runtime and configuration time set handlers
Modify the GetStatusDesc runtime method to return detailed error messages to users
Implement a simple editor for an object
Wonderware Training
Lab 3 Implementing Set Handlers 2-43
f. Modify the GetStatusDesc method of the Runtime project to make it look exactly like this:
private void CounterRuntime_RuntimeGetStatusDesc(object sender, ref
RuntimeGetStatusDescEventArgs e)
{
//Return the correct error message based on the
//detailed error code passed by the Set Handler
switch (e.detailedErrorCode)
{
case 10001:
g. Modify the Runtime Set Handler for the Reset attribute to make it look exactly like this:
private void ResetSetHandler(object sender, ref RuntimeSetHandlerEventArgs e)
{
//If the attribute is set to true, reset Count
if (e.Value)
{
//Reset Count
Count = 0;
}
Wonderware Training
Lab 3 Implementing Set Handlers 2-45
Wonderware Training
Lab 3 Implementing Set Handlers 2-47
switch (e.detailedErrorCode)
{
case 10001:
e.status = "MaxCount must be greater than 0";
break;
default:
e.status = GetText((int)e.detailedErrorCode);
break;
}
}
13. In Object Design View, under Runtime, double-click Reset Set Handler.
Note: You could also open the code by expanding Attributes and Reset, and then double-
clicking Runtime Set Handler.
14. Modify the ResetSetHandler method to make it look exactly like this:
private void ResetSetHandler(object sender, ref RuntimeSetHandlerEventArgs e)
{
//If the attribute is set to true, reset Count
if (e.Value)
{
//Reset Count
Count = 0;
}
Wonderware Training
Lab 3 Implementing Set Handlers 2-49
19. In Object Design View, expand Attributes and drag the MaxCount attribute onto the
General tab.
25. On the General tab, verify that MaxCount must be greater than zero.
Wonderware Training
Lab 3 Implementing Set Handlers 2-51
29. If the watch window (bottom pane) you created in the previous lab is not opened, right-click in
the watch window, click Open, and open Dev Watch Windows.
30. Add the following attributes to the watch window:
MaxCount
Reset
Wonderware Training
Section 3 Runtime Events 2-53
Section Objectives
Describe how runtime event handlers are used and when they are triggered
List the runtime event handlers that are enabled on all application objects
This section describes how to add and implement runtime event handlers.
Runtime
events
Event Occurs
Execute On every scan cycle of the hosting AppEngine while the object is On Scan
GetStatusDesc When the runtime component requests a detailed message for an error, for example,
after a set handler returns a failure
Initialize After the object is created in runtime (usually after deployment, but also after a failover
or after the bootstrap is restarted). Occurs before the Startup event. No attribute
information is available at this time
SetScanState When the objects scan state (On Scan/Off Scan) is changed
Shutdown When the object is shutting down (usually after the object is set to Off Scan, but during
a failover Off Scan may not be set). This event does not occur if the object goes off the
network during a network failure
Startup When the object is being started (after the Initialize event and before it goes On Scan).
You can use the events startup context to find out whether the object is starting up
after a failover or other reasons.
[attribute]SetHandler When the value of an attribute is changed at runtime.
Note: Set handlers run independently from the Execute method. They do not need to be
called during the execution of the object or only when the object is On Scan. As long as the
object is instantiated, the set handlers get called every time the engine receives a request to
write. This can be between scans, or even if the object is Off Scan.
At this point, you can leave the object On Scan, and the object will execute continuously, or you
can set the object Off Scan and undeploy the object.
7. Before the object is undeployed, the system calls Shutdown. Here you can run any shutdown
logic you may have, for example you could close any opened files to free resources you have
allocated during the execution of the object.
Wonderware Training
Section 3 Runtime Events 2-55
DeployinganObject
Initialize 1
Startup 2
FALSE
TRUE
SetScanState 3 4
Execute 5
[Attribute]SetHandler 6
Shutdown 7
Wonderware Training
Lab 4 Enhancing the Counter Object 2-57
Count
MaxCount
Reset
Note: See page 2-19 for
Counter ResetOnScan a legend to this graphic.
SetScanState()
Startup()
EDITOR
Objectives
Upon completion of this lab, you will be able to:
Implement runtime event handlers, such as Startup and SetScanState
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
}
}
d. Modify the Startup method of the Runtime project to make it look exactly like this:
private void Counter_RuntimeStartup(object sender,
RuntimeStartupEventArgs e)
{
//Code in this method is executed in runtime
//when object is starting
Wonderware Training
Lab 4 Enhancing the Counter Object 2-59
//RestoreDynamicAttributes();
Wonderware Training
Lab 4 Enhancing the Counter Object 2-61
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
}
}
//RestoreDynamicAttributes();
Wonderware Training
Lab 4 Enhancing the Counter Object 2-63
19. In the watch window, verify the following runtime behavior of the Counter object:
When ResetOnScan is false, the Count value does not restart at zero when the object is
set Off Scan and then back On Scan.
When you set ResetOnScan to true, the Count value restarts at zero when the object is
set Off Scan and then back On Scan.
Note: The object must be set Off Scan before the ResetOnScan attribute can be modified
because you configured the attribute with a Security Classification of Configure in step 2.
Wonderware Training
Section 4 Configtime Events 2-65
Section Objectives
Describe how configtime event handlers are used and when they are triggered
List the configtime event handlers that are enabled on all application objects
List the optional configtime event handlers
This section describes how to add and implement configtime event handlers.
Event Occurs
Initialize When the object is initialized. Use this event handler for any custom initialization
code.
Migrate When derived templates or instances are migrated.
PostCreate After the object (instance or derived template) is created
PreValidate Before the object is validated (when the user has edited its configuration and saves it)
Validate When the object is validated. Use this event handler for any custom validation code
(for example, checking for invalid combinations of attribute values)
[attribute]SetHandler When the value of an attribute is changed at configtime.
Initialize 1 1 1 1
PostCreate 2 2
[Attribute]SetHandler 2 3 2
PreValidate 3 3 4 3
Validate 4 4 5 4
Wonderware Training
Section 4 Configtime Events 2-67
Wonderware Training
Module 3
Utility Primitives
Section 1 Primitives Overview 3-3
Section 2 Utility Primitives Overview 3-7
Lab 5 Adding a Counter Input 3-11
Lab 6 Adding Counter Alarms and History 3-21
Section 3 Quality and Timestamp Handling 3-37
Lab 7 Handling Quality in the Counter Object 3-41
3-2 Module 3 Utility Primitives
Module Objectives
Using the utility primitives included with the ArchestrA Object Toolkit, configure an
application object with alarming, history, input, and quality handling capabilities
Wonderware Training
Section 1 Primitives Overview 3-3
Section Objectives
Explain what primitives are and how they are structured in an application object
Identify the different types of primitives
This section provides an overview of primitives and describes the different types of primitives.
Primitives
Primitives are building blocks of code containing specific functionality for an application object.
Like the main application object, primitives have their own attributes and their own configtime and
runtime behaviors. In addition, a primitive can leverage the attributes and behaviors of other
primitives by including the other primitive as a child primitive. A primitive can be contained locally
in one object, or it can be standalone and reused in multiple objects.
By using primitives to separate your code into different blocks or layers, you can write your code
easier, create a more logical structure for your code, isolate where the code is coming from if
something is not working, and reuse your code in other projects.
Attribute
Runtime Configtime Editor
Definition
As shown in the previous graphic, a primitive consists of a set of Attribute Definitions (stored in
an aaDEF file), and one or more components that implement behavior associated with those
attributes. The configuration behavior is implemented as a primitive Configtime component (DLL
file), and the runtime behavior is implemented as a primitive Runtime component (DLL file).
At a minimum, an object always includes the Common primitive (which contains attributes
common to all objects), and the topmost Local primitive (which contains attributes and behaviors
unique to the object). The topmost Local primitive is special. Its icon in the Object Designer
represents a primitive as well as the overall object. It will normally be the only primitive containing
editor implementation files, since objects provide a single unified editor to users.
All attributes combine to form the Namespace of the object. Everything is done by getting and
setting an objects attributes.
Note: Editors Get or Set attributes by name. They do not know anything about primitives.
Object primitives have a hierarchical relationship to one another: Parents know about the children,
but child primitives (especially reusable ones) typically do not know about their parents. This
relationship enables complex primitives to be built out of simpler ones. For example, ArchestrA
application objects leverage (child) Input/Output primitives to communicate with other objects or
field devices.
A primitives logic refers to its attributes or to the attributes of its child primitives. If necessary, a
primitive can refer to the attributes of parents and siblings (more rare).
A primitive is an implementation detail. At most it is visible to the user as a dotted prefix common to
the names of the attributes within it. Within the ArchestrA IDE, some visible primitives are called
extensions. One example of an extension primitive is a script attached to an object.
Types of primitives
There are three main types of primitives, which are discussed below and in other sections of this
manual.
Common primitive
Every application object automatically has a common primitive, which provides the set of attributes
(Tagname, ScanState, ShortDesc, etc.) and behaviors required by all application objects. This
common primitive is included as support for the ArchestrA framework. This primitive is hidden and
cannot be modified or removed.
Note: The Common primitive has no representative icon in the Object Designer, although its
attributes can be seen in the Object Viewer when the hidden attributes option is enabled.
Local primitives
Local primitives provide unique functionality for a single application object. They are defined and
used in only that single object. Every object contains at least one local primitive (the topmost Local
primitive). Other local primitives (children of the topmost) will typically be used to define optional
attributes and will usually be marked as Virtual.
A virtual primitive allows you to dynamically add and delete instances of the primitive at configtime.
Primitives can be marked Virtual when they are configured and added to an object. These
primitives are designed and implemented in the same way as other primitives. For more
information, see Virtual Primitives Overview on page 5-3.
Wonderware Training
Section 1 Primitives Overview 3-5
For more information on local primitives, see Local Primitives Overview on page 6-3.
Reusable primitives
Reusable primitives are standalone primitives that can be reused in multiple application objects,
providing a mechanism for component-level code sharing across objects. Organizing common
functionality into reusable primitives makes it easier to maintain code.
The ArchestrA Object Toolkit includes predefined reusable primitives called Utility primitives.
These primitives allow objects created from your templates to access ArchestrA framework
features such as alarms, history, and inter-object communication by simply accessing the
attributes of those primitives. For more information, see Utility Primitives Overview on page 3-7.
You develop reusable primitives independently, similar to developing an object. You create a
separate Microsoft Visual Studio project for every reusable primitive you create.
For more information on reusable primitives, see Reusable Primitives Overview on page 6-19.
Both reusable primitives and local primitives (see above) can be made as Virtual primitives. For
more information, see Virtual Primitives Overview on page 5-3
Wonderware Training
Section 2 Utility Primitives Overview 3-7
Section Objectives
Summarize what utility primitives are and how they are used
This section describes the utility primitives that are included with the ArchestrA Object Toolkit.
Utility primitives
Utility primitives are predefined reusable primitives that are included with the ArchestrA Object
Toolkit. They provide historization, alarming, input, and output capabilities for your object. A typical
application object will use one or more of these utility primitives.
Utility primitives are added within the Object Designer, by either adding the primitive in the Shape
pane (I/O primitives) or checking the Alarmable or Historizable check boxes in the
Configuration pane for a Boolean attribute.
Input primitives
The Input primitive provides the hosting primitive the capability of collecting data from another
ArchestrA object. There is only one generic Input primitive, and it is used for all data types.
The Input primitive performs the key function of reading data from an attribute in an application
object. The Input primitive is usually configured by the end user with a reference string that
indicates the input source location. Any attribute within any application object can be configured as
the input source.
Use this primitive to read one piece of data of any data type. If you know the expected data type,
then specify it and lock it within the Object Designer after you add the Input primitive. Give the
primitive a useful external name that indicates its purpose to the end user.
Output primitives
The Output primitive provides the hosting primitive the capability to request that a value of any
data type be written to an attribute of another ArchestrA object.
There is only one generic Output primitive, and one or more Output primitives can be used in a
template. You define the data type of the output when the Output primitive is embedded in the host
primitive.
The Output primitive performs the key function of writing data to an attribute in an application
object. The Output primitive is configured by the end user with a reference string that indicates the
output destination. Any attribute within any application object can be configured as the output
destination.
Use this primitive to write one piece of data of any data type. If you know the expected data type
(this will typically be the case), then specify it and lock it within the Object Designer after you add
the Output primitive. Give the primitive a useful external name that indicates its purpose to the end
user.
Input/Output primitives
The Input/Output primitive performs the key functions of reading data from and writing data to an
attribute in an application object. The Input/Output primitive is configured by the end user with
either one or two reference strings that indicate the input source and output destination locations.
Two locations are used in the case when the input is read back from a secondary source location
that is different from the output destination location. Some field devices may be set up with
separate input and output locations for security or robustness purposes.
Use this primitive to read and write data of any data type. If you know the expected data type, then
specify it and lock it within the Object Designer once you add the Input/Output primitive. Give the
primitive a useful external name that indicates its purpose to the end user.
Alarm primitives
The Alarm primitive performs the key function of generating an alarm report once an alarm
condition has been detected. The Alarm primitive is added within the Object Designer by indicating
that a Boolean attribute is Alarmable. The Boolean attribute thereby indicates an Alarm condition,
and if the Alarm primitive is enabled, then an Alarm is generated at runtime when the Boolean
attribute transitions from false to true. Likewise, the Alarm is cleared (returned-to-normal) when the
Boolean attribute returns to false. The object or primitive that contains the Boolean attribute is
responsible for setting the attribute false or true.
Behind the scenes, the following happens when an attribute is marked alarmable:
A virtual Alarm primitive is added to the object and associated with the specified attribute.
An associated Boolean attribute .Alarmed is added which will appear in the object's
editor. This allows System Engineers to specify whether alarming that attribute is actually
required or not.
ArchestrA Object Toolkit automatically generates the set handler logic for the .Alarmed attribute
which adds or removes the actual non-virtual alarm primitive.
Once added, the Alarm primitive can be configured in the Object Designer to indicate other pieces
of information that are to be reported with the alarm. These pieces of information include the
current value that triggered the alarm, the limit value that was violated, the alarm category, the
engineering units string, and the alarm message string. The alarm message defaults to the
object's ShortDesc attribute in the Common primitive. However, it can be reconfigured by the end
user to refer to any String or InternationalString attribute within the ArchestrA IDE by use of the
editor. Thereby, the capability of specifying custom alarm message text is provided.
The Alarm primitive can be either concrete or virtual. If concrete, it is always deployed with the
object. If virtual, it is deployed only if the end user enables it. Make Alarm primitives virtual if you
want to allow the System Engineer to specify whether a condition should be reported to the alarm
subsystem. If virtual, the object's Package code is responsible for adding or removing the alarm
primitive when the end user indicates to do so. The Alarm Primitive is configured by the end user
with an alarm priority and an alarm message attribute that contains a custom alarm message
string.
Lock down any attributes (such as Category, Engineering Units) that are not to be changed. The
Object Designer automatically gives the primitive a useful external name that corresponds to the
Boolean attribute being alarmed.
Wonderware Training
Section 2 Utility Primitives Overview 3-9
If this option is enabled when the object is designed, it will make it easier for engineers to set up
alarm reporting for an attribute, but it also introduces more choices that must be made when the
object is configured.
History primitives
The History primitive performs the key function of recording history for an attribute. The History
primitive is added within the Object Designer by indicating that an attribute is Historizable.
Behind the scenes, the following happens when an attribute is marked historizable:
A virtual History primitive is added to the object and associated with the specified attribute.
An associated Boolean attribute .Historized is added which will appear in the object's
editor. This allows System Engineers to specify whether historization of that attribute is
actually required or not.
ArchestrA Object Toolkit automatically generates the package's set handler logic for the
.Historized attribute which adds or removes the actual non-virtual history primitive.
Once added, the History primitive can be configured in the Object Designer to indicate other
pieces of information that are to be stored within the history. These pieces of information include
the engineering units string attribute and default values for trend limits, value deadband, and force
storage period. Generally, those latter three attributes are configured by the end user.
The History primitive is always virtual and is only deployed if the end user enables it. The object's
Package code is responsible for adding or removing the history primitive when the end user
indicates to do so. The History primitive is configured by the end user with value deadband, force
storage period, and trend limits. Value deadband and trend limits are always in the engineering
units of the attribute being historized.
Wonderware Training
Lab 5 Adding a Counter Input 3-11
Objectives
Upon completion of this lab, you will be able to:
Add and manipulate Input primitives in an application object
#endregion Declarations
d. Modify the Execute method of the Runtime project to make it look exactly like this:
private void Counter_RuntimeExecute(object sender)
{
//Code in this method is executed in runtime every scan
//while the object is On Scan
lastInputValue = CounterInput.Value.Value;
}
}
Wonderware Training
Lab 5 Adding a Counter Input 3-13
Wonderware Training
Lab 5 Adding a Counter Input 3-15
#endregion Declarations
lastInputValue = CounterInput.Value.Value;
}
}
Wonderware Training
Lab 5 Adding a Counter Input 3-17
20. Open the editor for Counter_001, and set Count.Input.InputSource to Blinker_001.Bit.
Wonderware Training
Lab 5 Adding a Counter Input 3-19
Note: You can stop the input from changing by setting the Blinker to Off Scan.
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-21
Count
INPUTPRIMITIVE
Count.Input
HISTORYPRIM
CountHistory
TimeSinceChange
Timeout.Limit
Timeout.Condition
ALARMPRIMITIVE
Note: See page 2-19 for a
TimeoutAlarm
legend to this graphic.
Counter
EngUnits
MaxCount
Reset
ResetOnScan
SetScanState()
Execute()
Timeout_Limit_ConfigtimeSH()
Timeout_Limit_RuntimeSH()
GetStatusDesc()
EDITOR
Objectives
Upon completion of this lab, you will be able to:
Make an attribute historizable, and configure the corresponding History Primitive
parameters
Make an attribute alarmable, and configure the corresponding Alarm Primitive parameters
c. For the Timeout.Condition attribute, check the Alarmable check box and configure the alarm
information as follows:
d. For the Count attribute, check the Historizable check box and configure the history
information as follows:
#endregion Declarations
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-23
f. Modify the SetScanState method of the Runtime project to make it look exactly like this:
private void Counter_RuntimeSetScanState(object sender,
RuntimeSetScanStateEventArgs e)
{
//Code in this method is executed in runtime
//every time the Scan State of the object changes
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
}
}
g. Modify the Execute method of the Runtime project to make it look exactly like this:
private void Counter_RuntimeExecute(object sender)
{
//Code in this method is executed in runtime every scan
//while the object is On Scan
lastInputValue = CounterInput.Value.Value;
i. Modify the Runtime Set Handler for the Timeout.Limit attribute to make it look exactly like
this:
private void Timeout_LimitSetHandler(object sender, ref
RuntimeSetHandlerEventArgs e)
{
//Verify that the set value is greater than zero
if (e.Value > 0)
{
//Valid set value. Set Timeout Limit.
Timeout_Limit.SetHandlerValue = e;
}
else
{
//Invalid set value. Return error information
e.status.Category =
MxStatusCategory.MxCategoryOperationalError;
e.status.detectedBy =
MxStatusSource.MxSourceRespondingAutomationObject;
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-25
j. Modify the GetStatusDesc method of the Runtime project to make it look exactly like this:
private void CounterRuntime_RuntimeGetStatusDesc(object sender, ref
RuntimeGetStatusDescEventArgs e)
{
//Return the correct error message based on the
//detailed error code passed by the Set Handler
switch (e.detailedErrorCode)
{
case 10001:
e.status = "MaxCount must be greater than 0";
break;
case 10002:
e.status = "Timeout Limit cannot be negative";
break;
default:
e.status = GetText((int)e.detailedErrorCode);
break;
}
}
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-27
3. In the Shape pane, click the Timeout.Condition attribute, and then in the Configuration
pane, check the Alarmable check box and configure the alarm information as follows:
4. Click the Count attribute, and then check the Historizable check box and configure the
history information as follows:
#endregion Declarations
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-29
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
}
}
lastInputValue = CounterInput.Value.Value;
14. In Object Design View, under Runtime, double-click Timeout.Limit Set Handler.
15. In the CounterRuntime.cs file, modify the Timeout_LimitSetHandler method to make it look
exactly like this:
private void Timeout_LimitSetHandler(object sender, ref
RuntimeSetHandlerEventArgs e)
{
//Verify that the set value is greater than zero
if (e.Value > 0)
{
//Valid set value. Set Timeout Limit.
Timeout_Limit.SetHandlerValue = e;
}
else
{
//Invalid set value. Return error information
e.status.Category =
MxStatusCategory.MxCategoryOperationalError;
e.status.detectedBy =
MxStatusSource.MxSourceRespondingAutomationObject;
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-31
switch (e.detailedErrorCode)
{
case 10001:
e.status = "MaxCount must be greater than 0";
break;
case 10002:
e.status = "Timeout Limit cannot be negative";
break;
default:
e.status = GetText((int)e.detailedErrorCode);
break;
}
}
Tab control
23. From Object Design View, drag the following attributes onto the Alarms tab:
Timeout.Limit
Timeout.Condition
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-33
24. Remove the Attribute Category not supported in label and move the
Timeout.Condition label so the form looks similar to the following:
25. Add a new tab and change its Text property to History and its Name property to historyTab.
26. From Object Design View, drag the following attributes onto the History tab:
EngUnits
Count
27. Change the default controls and labels as needed to make the form look similar to the
following:
Hint: To change the EngUnits text box control to single line, change the Multiline property to
False.
34. On the Alarms tab, verify that the alarm timeout limit cannot be set to a negative number.
35. On the History tab, enter a valid value for engineering units and set the desired historization
parameters.
36. Save and close the editor.
37. Deploy the Counter_001 instance.
38. Right-click Counter_001 and click View in Object Viewer.
39. If not already opened, open the watch window you have used in previous labs.
40. Add a new watch window and rename it to Alarms.
41. Add the following attributes to the new watch window:
Object Attribute
Counter_001 TimeSinceChange
Counter_001 Timeout.Limit
Counter_001 Timeout.Condition
Counter_001 InAlarm
DevArea AlarmOnCnt
Blinker_001 ScanState
Blinker_001 ScanStateCmd
Wonderware Training
Lab 6 Adding Counter Alarms and History 3-35
Note: You can stop the input from changing by setting the Blinker to Off Scan.
Now you will use ActiveFactory Trend to verify that the count is being historized.
44. On the Start menu, click All Programs / Wonderware / ActiveFactory / Trend.
The Server List Configuration window appears.
45. In the Server field, enter LOCALHOST.
46. Check Use Integrated security, and then click Add.
Wonderware Training
Section 3 Quality and Timestamp Handling 3-37
Section Objectives
Describe how to configure an object to support calculated quality and calculated time
List the guidelines for using calculated quality and time
This section describes and provides guidelines for calculated quality and calculated time usage.
Select the Supports Calculated Quality and Calculated Time check box if the object should be
able to set the attributes quality and timestamp. This inserts the appropriate code into the
attributes declaration statement. As the developer, you are responsible for writing code that
inspects the Quality states of source values and sets a resulting Quality state for the defined
attribute.
If you clear this check box, the attributes quality is always Good, and the timestamp is always the
objects startup time.
Calculated Quality
When an object calculates the value of an attribute, it usually is appropriate to also calculate that
value's quality. The quality of a calculated value is defined as the 16-bit OPC quality that can be
set to Good, Bad, or Uncertain. The ArchestrA environment additionally treats one substate of the
OPC Bad state as the special quality of Initializing. Initializing quality is Bad quality with the
Initializing bit set.
Before you use data values in calculations and logic, always check their quality. For example, it
does not make sense to calculate the average of two values if one or both values have Bad
quality, since Bad quality indicates that the value is not to be used or trusted. Instead, in this case,
you should skip the calculation of the average and set the resulting attribute to Bad quality itself.
The ArchestrA infrastructure does not automatically enforce a specific value (such as IEEE NaN)
when quality is Bad, or a specific quality (such as Bad) when a value is NaN. Your object must
check for these conditions before using any values in logic or calculations. For example, a float
value read from a field device may have a value of NaN but Good quality. In that case, the object
must be aware that the value may be unusable for a calculation. Conversely, a value read from a
UDA attribute may be 4.3 but Bad quality. Again, the object must inspect the quality first, realize it
is Bad, and take appropriate action.
Wonderware Training
Section 3 Quality and Timestamp Handling 3-39
Do not trigger any other alarms when the quality of an attribute goes Bad. For example, do
not trigger a PV change-of-state alarm when the PV goes to some default state after its
quality goes Bad. Instead, always use a separate alarm for bad value reporting.
Inputs with Uncertain quality can be used with care. Set the result to Uncertain quality also
to indicate its questionable status.
Do not generate Logger messages when setting an attribute to Bad quality in the cases
outlined above.
Do not attempt to change the quality of an input, output, or input/output by using its
wrapper. This is not supported and may result in unexpected I/O values being written.
Calculated Time
Wonderware Training
Lab 7 Handling Quality in the Counter Object 3-41
To test the runtime behavior of the Counter, you will change the quality of the Bit attribute in the
provided Blinker object by using a series of runtime command attributes.
Count
INPUTPRIMITIVE
Count.Input
HISTORYPRIM
CountHistory
TimeSinceChange Bit
Timeout.Limit GoodQualityCmd
Blinker
Timeout.Condition (Providedby InitializingQualityCmd
Counter ALARMPRIMITIVE Instructor) UncertainQualityCmd
TimeoutAlarm
BadQualityCmd
EngUnits
MaxCount
Reset
ResetOnScan
SetScanState() Note: See page 2-19 for a
Execute() legend to these graphics.
EDITOR
Objectives
Upon completion of this lab, you will be able to:
Add support for calculated quality and calculated time to an attribute
Handle attribute quality in runtime
Wonderware Training
Lab 7 Handling Quality in the Counter Object 3-43
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
}
else
{
//Object is set Off Scan. Set quality to BAD
//but leave value unchanged
Count.Quality = DataQuality.DataQualityBad;
}
}
d. Modify the Execute method of the Runtime project to make it look exactly like this:
private void Counter_RuntimeExecute(object sender)
{
//Code in this method is executed in runtime every scan
//while the object is On Scan
switch(inputQuality)
{
case DataQuality.DataQualityGood :
//If input quality is GOOD
case DataQuality.DataQualityUncertain :
//or input quality is UNCERTAIN
lastInputValue = CounterInput.Value.Value;
break;
case DataQuality.DataQualityInitializing :
//If input quality is INITIALIZING
//Leave Count value and quality unchanged
break;
case DataQuality.DataQualityBad :
//If input quality is BAD
default :
//or input quality is unknown
//Leave Count value unchanged
//and set quality to UNCERTAIN
Count.Quality = DataQuality.DataQualityUncertain;
break;
}
}
Wonderware Training
Lab 7 Handling Quality in the Counter Object 3-45
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
Wonderware Training
Lab 7 Handling Quality in the Counter Object 3-47
}
else
{
//Object is set Off Scan. Set quality to BAD
//but leave value unchanged
Count.Quality = DataQuality.DataQualityBad;
}
}
switch(inputQuality)
{
case DataQuality.DataQualityGood :
//If input quality is GOOD
case DataQuality.DataQualityUncertain :
//or input quality is UNCERTAIN
lastInputValue = CounterInput.Value.Value;
break;
case DataQuality.DataQualityInitializing :
Wonderware Training
Lab 7 Handling Quality in the Counter Object 3-49
19. In the watch window, verify the following runtime behaviors of the Counter object:
When the object goes On Scan, the Count quality is INITIALIZING
When the object goes Off Scan, the Count quality is BAD
While the object it being executed, the Count quality depends on the input value quality as
shown in the following table:
Input Quality Count Quality Count Value
INITIALIZING Does not increment Does not increment
GOOD GOOD Increments as expected
UNCERTAIN UNCERTAIN Increments as expected
BAD UNCERTAIN Does not increment
Note: You can control the input value quality by using the runtime command attributes in
the Blinker object.
Wonderware Training
Module 4
Module Objectives
Add the necessary logic to an object to implement configuration validation
In the context of the ArchestrA Object Toolkit., explain how to troubleshoot and debug
application objects
Wonderware Training
Section 1 ArchestrA Logger Message Methods 4-3
Section Objectives
Explain how to use the ArchestrA Object Toolkit Logger View
List the methods available for writing messages to the ArchestrA Logger
This section describes the Logger View, and provides information on using the methods provided
by the ArchestrA Object Toolkit to write messages to the ArchestrA Logger.
The Logger View displays errors and warnings reported by the ArchestrA Object Toolkit.
Note: You can clear all messages from the view by pressing Ctrl+R to reset the start time.
The Logger View can be shown or hidden by clicking the Logger View button on the ArchestrA
Object toolbar.
The Logger View window shows the same ArchestrA Logger messages that you see in the
ArchestrA Log Viewer in the ArchestrA System Management Console (SMC). The Logger View is
intended for quick reference; it does not offer the full functionality of the ArchestrA Log Viewer.
Note: By default, trace logger messages are not displayed in the Logger. To display these, you
need to enable the trace log flag in the Log Flag Editor. See page 4-5.
Use the Logger only for tracing trapped software errors or diagnostics, and only use it sparingly in
production objects. Do not use it to provide information that is intended for operators. Operators
dont typically look at the Logger information, but rely on alarm and quality information instead.
If you use the Logger to trace diagnostic information, make sure that the logging does not continue
indefinitely (for example, on every Application Engine scan). Otherwise, performance issues
occur.
If you use the Logger to provide debugging information during development, either remove the
logging calls before releasing the object to production, or change them so that logging only occurs
when a custom log flag is set.
LogError
Writes an error message to the Logger. Errors are considered serious software problems such
as unhandled exceptions or errors.
Syntax
public void LogError(string _message);
Parameters
_message
string value that holds the error message to be logged.
LogException
Writes a formatted exception (message and stacktrace) to the Logger as a LogError message.
If desired, an optional message can be included.
Syntax
public void LogException(Exception ex);
Parameters
ex
Exception value to be logged.
LogInfo
Writes an information message to the Logger. Information messages indicate a piece of
information that is useful to log for end users. Use sparingly to avoid Logger noise.
Syntax
public void LogInfo(string _message);
Parameters
_message
string value that holds information to be logged.
Wonderware Training
Section 1 ArchestrA Logger Message Methods 4-5
LogTrace
Writes a trace message to the Logger. Trace messages describe internal object states,
variable values, and other low-level data from the component.
Syntax
public void LogTrace(string _message);
Parameters
_message
string value that holds trace message to be logged.
LogWarning
Writes a warning message to the Logger. Warnings indicate an unexpected problem occurred.
Syntax
public void LogWarning(string _message);
Parameters
_message
string value that holds warning message to be logged.
Note: You can open the Log Flag Editor directly, bypassing the Log Viewer, by using the following
run command: logflgeditor
The following figure summarizes how log flags control whether component messages are logged
or not. Also, you can use log flags to assign message categories to other ArchestrA components.
Log ArchestrA
ArchestrA Component Components
Flags
Message Categories
Error Messages
ArchestrA
Logger
Warning Messages
SQL Messages
Connection Messages
Most categories of messages are not logged. Typically, a component issues only error, warning,
and informational messages. Most other message categories remain inactive.
The ArchestrA Log Flag Editor is primarily a troubleshooting tool. When a component begins
logging error messages, you can use log flags to activate other message categories and begin
saving additional diagnostic messages to the ArchestrA Logger.
Wonderware Training
Section 2 Configtime Validation 4-7
Section Objectives
Explain how to use the Validate event handler to include configuration validation for an
object
Example code
The following code shows an example of performing configtime validation with the
ConfigtimeValidate() method and putting the object in a warning or error state by using
EPACKAGESTATUS enum.
private void
AOTObject4Configtime_ConfigtimeValidate(object
sender, ref EPACKAGESTATUS status)
{
// By default set the object status to Good
if (HiLimit < LoLimit)
{
status = EPACKAGESTATUS.ePackageBad;
AddErrorMessage("Hi Limit must be greater
than or equal to Lo Limit");
}
else
{
status = EPACKAGESTATUS.ePackageGood;
}
}
Wonderware Training
Lab 8 Implementing Configuration Validation 4-9
Count
INPUTPRIMITIVE
Count.Input
HISTORYPRIM
CountHistory
TimeSinceChange
Timeout.Limit
Timeout.Condition
ALARMPRIMITIVE
Counter TimeoutAlarm
EngUnits
MaxCount
Reset
ResetOnScan
Validate() Note: See page 2-19 for a
Execute() legend to this graphic.
SetScanState()
EDITOR
Objectives
Upon completion of this lab, you will be able to:
Implement the Validate configtime event handler to verify object configuration
Generate object errors and warnings based on the validation result
Write messages to the ArchestrA Logger
Example code
if (string.IsNullOrEmpty(EngUnits.Value))
{
//EngUnits is empty. Generate a warning
AddWarningMessage("Engineering Units is empty");
status = EPACKAGESTATUS.ePackageWarning;
}
}
Wonderware Training
Lab 8 Implementing Configuration Validation 4-11
switch(inputQuality)
{
case DataQuality.DataQualityGood :
//If input quality is GOOD
case DataQuality.DataQualityUncertain :
//or input quality is UNCERTAIN
lastInputValue = CounterInput.Value.Value;
break;
case DataQuality.DataQualityInitializing :
//If input quality is INITIALIZING
//Leave Count value and quality unchanged
break;
case DataQuality.DataQualityBad :
//If input quality is BAD
default :
//or input quality is unknown
//Leave Count value unchanged
//and set quality to UNCERTAIN
Count.Quality = DataQuality.DataQualityUncertain;
LogWarning(string.Format(
"{0}: Input source quality is bad or unknown", Tagname));
break;
}
}
d. Modify the SetScanState method of the Runtime project to make it look exactly like this:
private void Counter_RuntimeSetScanState(object sender,
RuntimeSetScanStateEventArgs e)
{
//Code in this method is executed in runtime
//every time the Scan State of the object changes
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
else
{
//Object is set Off Scan. Set quality to BAD
//but leave value unchanged
Count.Quality = DataQuality.DataQualityBad;
}
}
Wonderware Training
Lab 8 Implementing Configuration Validation 4-13
i. Open Object Viewer and, if not opened yet, open the watch window you have used in previous
labs.
j. Verify the runtime behavior of the Counter object by monitoring the ArchestrA Logger
messages when quality of the input source is bad. Also, enable the trace Log Flag for the
counter in the Log Viewer to verify that a trace message is generated when the object is set
On Scan.
Example code
if (string.IsNullOrEmpty(EngUnits.Value))
{
//EngUnits is empty. Generate a warning
AddWarningMessage("Engineering Units is empty");
status = EPACKAGESTATUS.ePackageWarning;
}
}
Wonderware Training
Lab 8 Implementing Configuration Validation 4-15
switch(inputQuality)
{
case DataQuality.DataQualityGood :
//If input quality is GOOD
case DataQuality.DataQualityUncertain :
//or input quality is UNCERTAIN
lastInputValue = CounterInput.Value.Value;
break;
case DataQuality.DataQualityInitializing :
//If input quality is INITIALIZING
//Leave Count value and quality unchanged
break;
case DataQuality.DataQualityBad :
//If input quality is BAD
default :
//or input quality is unknown
//Leave Count value unchanged
//and set quality to UNCERTAIN
Count.Quality = DataQuality.DataQualityUncertain;
break;
}
}
if (e.onScan)
{
//Object is set On Scan. Check whether ResetOnScan is true
if (ResetOnScan)
{
//Reset count to zero
Count = 0;
}
else
{
//Object is set Off Scan. Set quality to BAD
//but leave value unchanged
Count.Quality = DataQuality.DataQualityBad;
}
}
Wonderware Training
Lab 8 Implementing Configuration Validation 4-17
14. Click Cancel, and then click the History tab and enter any value in the EngUnits field.
15. Save and close the editor.
16. Deploy the Counter_001 instance.
You will now verify the runtime behavior of the Counter object.
17. Right-click Counter_001 and click View in Object Viewer.
18. If not already opened, open the watch window you have used in previous labs.
19. Set the quality of the Blinker_001.Bit attribute to bad, and then monitor the messages in the
Logger View window in Visual Studio.
Note: If the Logger View window in Visual Studio is not open, click the Tools menu, point to
ArchestrA Object, and click Logger View.
By default, trace Logger messages are not displayed. In the next steps you will enable the
trace log flag in Log Viewer.
24. Close the Log Flag Editor and click Yes to apply the changes.
25. In Object Viewer, set the Counter object to Off Scan, and then back to On Scan.
26. In the Logger View window, verify that a trace message is generated.
Wonderware Training
Lab 8 Implementing Configuration Validation 4-19
Wonderware Training
Section 3 Debugging 4-21
Section 3 Debugging
Section Objectives
Describe how to attach the debugger in the ArchestrA Object Toolkit
This section describes debugging objects and how to attach the Visual Studio debugger in the
ArchestrA Object Toolkit.
Debugging objects
The following information is intended to explain debugging in the context of the ArchestrA Object
Toolkit. The material is not intended to be a complete overview of a debugging phase.
Each component of an application object includes its own debugging characteristics. In other
words, the Runtime, Package (Configtime), and Editor components of an object are debugged in
different ways.
Caution: Never debug objects on a production system. Always use a development node with a
local Galaxy for debugging.
Caution: Never ship an object that was created from a debug build. These objects may require
debug modules and may not function correctly in a production environment.
Attaching the debugger to the processes running the current object version
If you want to debug the current version of an object that you have already instantiated or
deployed on the local system, you can attach the debugger to the Application Server processes
running the current object version. There are two prerequisites for this:
You must have created the required PDB (Program Database) files as part of the current
build.
Visual Studio must be able to find the PDB files. If necessary, set up the search paths in
Visual Studio accordingly.
For help on these points, refer to the Visual Studio documentation.
To attach the debugger, click the Debug button on the ArchestrA Object toolbar.
The Options dialog box appears with the Build category selected.
Wonderware Training
Section 3 Debugging 4-23
Then build your object using a build mode on the ArchestrA Object toolbar. For example, to debug
configtime or custom editor code, Build & Instantiate is convenient.
Once the build is finished, Visual Studio switches into debugging mode. You can now work with
your object and use the debugging features as required.
To stop debugging, click the highlighted Debug button.
Wonderware Training
Module 5
Virtual Primitives
Section 1 Virtual Primitives Overview 5-3
Lab 9 Adding a Counter Reset Input 5-9
5-2 Module 5 Virtual Primitives
Module Objectives
Explain what virtual primitives are and how they are used
Create a virtual primitive
Wonderware Training
Section 1 Virtual Primitives Overview 5-3
Section Objectives
Summarize what virtual primitives are and how they can be used
Explain how to designate a primitive as virtual
Describe some of the methods used with virtual primitives
This section describes virtual primitives and gives examples of how they can be used. It also
describes methods that can be used in logic for working with virtual primitives.
Virtual primitives
Virtual primitives are primitives that are added and removed on demand. You can use a virtual
primitive to implement a block of optional functionality that can be enabled as required by an end
user. This ensures that only required primitives are actually deployed at runtime, reducing
overhead and processing load.
A virtual primitive is like other primitives with the following exceptions:
They are added to the Galaxy database, but do not get added to the global Object
Namespace, which is browsable from within the ArchestrA IDE
Special Add and Remove methods called by configtime logic or runtime logic, typically
within set handler code, use the virtual primitive as a template to create instances of the
primitive that are contained within the parent object instance
You design and implement a virtual primitive in the same way as any other primitive. However,
from the end users perspective, a virtual primitive does not appear to be part of the object by
default. Instead, it is only made real at configuration time by programmatically adding instances
of the virtual primitive to the object as needed.
For example, you might want to provide an optional Hi alarm for an objects PV (process value). To
do this, you would add a virtual primitive that contains the alarming functionality, and an attribute
that enables or disables the Hi alarm. When the user enables that attribute at configtime, you
create an instance of the virtual primitive by means of a call in the attributes configtime set
handler. If the attribute stays disabled, you never create an instance of the primitive, and the
primitive never gets deployed.
You can create multiple instances of a virtual primitive in the same object. Each instance behaves
like a separate primitive. For example, you could re-use the same Hi alarm primitive for multiple
attributes by simply creating multiple instances of it. However, when you add the instances, you
must provide a unique external and internal name for each instance to avoid naming conflicts.
You can also use virtual primitives to define optional attributes and arrays of related primitives.
Defining optional attributes using virtual primitives
Using virtual primitives, you can include primitives (and their attributes) in an object only when they
are really necessary. For example, if the monitoring of a particular input is optional, you can mark
the input primitive as virtual and include it in the object only when a certain attribute (for example,
EnableInputMonitoring) is set to true. To do this, you would include logic for creating or removing
an instance of the virtual primitive in that attributes configtime set handler.
Arrays of related primitives
Using the same technique as described above, you can easily monitor a variable number of inputs
(for example, 0 to 4). The only difference is that you create more than one instance of the virtual
primitive. Each primitive instance must have unique internal and external names so its attribute
names do not collide with those of the other primitive instances.
GetValue(PrimitiveExternalName.AttributeExternalName)
You can use several other common attribute methods with virtual primitives to access attribute
data at configtime. These include:
Get Gets the value of an attributes property
GetValue Gets the value of an attribute
GetName Gets the name of an attribute
GetType Gets the type of an attribute
GetIsLocked Gets the lock status of an attribute
GetSecurityClassification Gets the security classification of an attribute
You can also use the following runtime attribute methods with virtual primitives to access attribute
data at runtime:
GetAttributeProperties Gets all the properties of an attribute
GetQuality Gets the quality of an attribute
GetTimeStamp Gets the time of an attribute
GetMxStatus Gets the value of a MxStatus attribute
Wonderware Training
Section 1 Virtual Primitives Overview 5-5
When you make an alarm or history primitive virtual, you also have the option to add an attribute to
enable and disable the primitive, as shown in the example below.
AddPrimitive
Syntax
public bool AddPrimitive(
string virtualPrimitiveName,
string internalName,
string externalName
);
Parameters
virtualPrimitiveName Name of the virtual primitive
internalName New Internal name of the instance
externalName New External name of the instance
Return Value
true if the Primitive instance addition is successful
false if the user tries to add a primitive with the same name of an existing primitive or if
the user tries to create an instance of the non-virtual primitive
DeletePrimitive
Syntax
public bool DeletePrimitive(string internalName);
Parameters
internalName Internal name of the virtual primitive instance
Return Value
bool
true if Primitive instance deletion is successful
false if the user tries to delete a non-existing primitive instance or the user tries to
delete a non-virtual primitive
RenamePrimitive
Syntax
public bool RenamePrimtive(
string primitiveInternalName,
string newInternalName,
string newExternalName
);
Parameters
primitiveInternalName Internal name of the virtual primitive instance
newInternalName New Internal name of the virtual primitive instance
newExternalName New External name of the virtual primitive instance
Return Value
bool
true if the primitive internal and external names are renamed
You can also test the ability to add, delete, or rename an instance of a virtual primitive by using the
following methods:
CanAddPrimitive
Syntax
public bool CanAddPrimitive(string virtualPrimitiveName, string internalName,
string externalName)
Parameters
virtualPrimitiveName Internal name of the virtual primitive
internalName New Internal name of the virtual primitive instance
externalName New External name of the virtual primitive instance
Return Value
bool
true if the primitive instance can be added with the Internal and External names
Wonderware Training
Section 1 Virtual Primitives Overview 5-7
CanDeletePrimitive
Syntax
public bool CanDeletePrimitive(string internalName)
Parameters
internalName Internal name of the virtual primitive instance
Return Value
bool
true if the primitive instance can be deleted with the Internal name
CanRenamePrimitive
Syntax
public bool CanRenamePrimtive(string primitiveInternalName, string
newExternalName
Parameters
primitiveInternalName Internal name of the virtual primitive instance
newExternalName New External name of the virtual primitive instance
Return Value
bool
true if the primitive instance can be renamed with the External name
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-9
Count
INPUTPRIMITIVE
Count.Input
HISTORYPRIM
CountHistory
TimeSinceChange
Bit
Timeout.Limit
GoodQualityCmd
Timeout.Condition
InitializingQualityCmd
ALARMPRIMITIVE Blinker
TimeoutAlarm UncertainQualityCmd
(Providedby
EngUnits Instructor) BadQualityCmd
Counter ResetTrigger
MaxCount
ResetOnScan
Reset
INPUTPRIMITIVE
Reset.Input
Reset.InputEnabled
Reset_InputEnabled_ConfigtimeSH()
Execute()
Reset_RuntimeSH()
Note: See page 2-19 for a
GetStatusDesc() legend to this graphic.
EDITOR
Objectives
Upon completion of this lab, you will be able to:
Add virtual primitives to an application object
Write the necessary logic to add and remove virtual primitives dynamically
bool success;
if (e.Value)
{
//Value set to true. Add input primitive
success =
AddPrimitive("ResetInput", "ResetInput1", "Reset.Input");
}
else
{
//Value set to false. Delete input primitive
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-11
success = DeletePrimitive("ResetInput1");
}
if (success)
{
//Virtual primitive was added/deleted. Set value
Reset_InputEnabled.SetHandlerValue = e;
}
else
{
//Primitive could not be added/deleted
//Generate an error and do not set value
e.Message = PrimitiveResult.message;
}
}
#endregion Declarations
h. Modify the Execute method of the Runtime project to make it look exactly like this:
private void Counter_RuntimeExecute(object sender)
{
//Code in this method is executed in runtime every scan
//while the object is On Scan
Count.Quality = DataQuality.DataQualityInitializing;
}
switch(inputQuality)
{
case DataQuality.DataQualityGood :
//If input quality is GOOD
case DataQuality.DataQualityUncertain :
//or input quality is UNCERTAIN
lastInputValue = CounterInput.Value.Value;
break;
case DataQuality.DataQualityInitializing :
//If input quality is INITIALIZING
//Leave Count value and quality unchanged
break;
case DataQuality.DataQualityBad :
//If input quality is BAD
default :
//or input quality is unknown
//Leave Count value unchanged
//and set quality to UNCERTAIN
Count.Quality = DataQuality.DataQualityUncertain;
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-13
break;
}
}
i. Modify the Runtime Set Handler for the Reset attribute to make it look exactly like this:
private void ResetSetHandler(object sender, ref RuntimeSetHandlerEventArgs e)
{
//If the reset input is enabled, return an error
if (Reset_InputEnabled)
{
//Return error information
e.status.Category =
MxStatusCategory.MxCategoryOperationalError;
e.status.detectedBy =
MxStatusSource.MxSourceRespondingAutomationObject;
e.status.detail = 10003;
return;
}
j. Modify the GetStatusDesc method of the Runtime project to make it look exactly like this:
private void CounterRuntime_RuntimeGetStatusDesc(object sender, ref
RuntimeGetStatusDescEventArgs e)
{
//Return the correct error message based on the
//detailed error code passed by the Set Handler
switch (e.detailedErrorCode)
{
case 10001:
e.status = "MaxCount must be greater than 0";
break;
case 10002:
e.status = "Timeout Limit cannot be negative";
break;
case 10003:
e.status =
"Reset cannot be modified because Reset Input is enabled";
break;
default:
e.status = GetText((int)e.detailedErrorCode);
break;
}
}
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-15
3. Click the Timeout.Condition attribute, expand the Alarmable section, and check the
following parameters:
Virtual
Add Attribute to enable/disable Alarm (automatically checked after checking Virtual)
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-17
bool success;
if (e.Value)
{
//Value set to true. Add input primitive
success =
AddPrimitive("ResetInput", "ResetInput1", "Reset.Input");
}
else
{
//Value set to false. Delete input primitive
success = DeletePrimitive("ResetInput1");
}
if (success)
{
//Virtual primitive was added/deleted. Set value
Reset_InputEnabled.SetHandlerValue = e;
}
else
{
//Primitive could not be added/deleted
//Generate an error and do not set value
e.Message = PrimitiveResult.message;
}
}
#endregion Declarations
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-19
{
//The reset input has become true. Initialize Counter
Count = 0;
Count.Quality = DataQuality.DataQualityInitializing;
}
switch(inputQuality)
{
case DataQuality.DataQualityGood :
//If input quality is GOOD
case DataQuality.DataQualityUncertain :
//or input quality is UNCERTAIN
lastInputValue = CounterInput.Value.Value;
break;
case DataQuality.DataQualityInitializing :
//If input quality is INITIALIZING
//Leave Count value and quality unchanged
break;
case DataQuality.DataQualityBad :
//If input quality is BAD
default :
//or input quality is unknown
//Leave Count value unchanged
break;
}
}
16. In Object Design View, under Runtime, double-click Reset Set Handler.
17. Modify the ResetSetHandler method to make it look exactly like this:
private void ResetSetHandler(object sender, ref RuntimeSetHandlerEventArgs e)
{
//If the reset input is enabled, return an error
if (Reset_InputEnabled)
{
//Return error information
e.status.Category =
MxStatusCategory.MxCategoryOperationalError;
e.status.detectedBy =
MxStatusSource.MxSourceRespondingAutomationObject;
e.status.detail = 10003;
return;
}
switch (e.detailedErrorCode)
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-21
{
case 10001:
e.status = "MaxCount must be greater than 0";
break;
case 10002:
e.status = "Timeout Limit cannot be negative";
break;
case 10003:
e.status =
"Reset cannot be modified because Reset Input is enabled";
break;
default:
e.status = GetText((int)e.detailedErrorCode);
break;
}
}
23. From Object Design View, drag the following attribute onto the Alarms tab:
Timeout.Condition.Alarmed
24. From Object Design View, drag the following attribute onto the History tab:
Count.Historized
Wonderware Training
Lab 9 Adding a Counter Reset Input 5-23
Note: The controls on the editor tab will be enabled and disabled when the primitive is
added and deleted.
31. Repeat the previous step to verify the virtual primitives on the Alarms and History tabs.
(Leave the check boxes unchecked when done.)
32. On the General tab, set the count input source to Blinker_001.Bit.
33. Check Reset.InputEnabled and set the reset input source to Blinker.ResetTrigger.
Note: You can change the reset input by using the ResetTrigger signal in the Blinker
object.
When the reset input is enabled, you cannot modify the Reset attribute from Object
Viewer
No attributes related to the alarm and history primitives are available in runtime when the
virtual primitives are unloaded
Wonderware Training
Module 6
Custom Primitives
Section 1 Local Primitives Overview 6-3
Lab 10 Adding Counter Statistics 6-7
Section 2 Reusable Primitives Overview 6-19
Lab 11 Creating a Rate Calculator Reusable Primitive 6-21
6-2 Module 6 Custom Primitives
Module Objectives
Explain what local and reusable primitives are and how they are used
Create a local primitive and a reusable primitive
Wonderware Training
Section 1 Local Primitives Overview 6-3
Section Objectives
Summarize what local primitives are and how to configure them
This section describes local primitives and explains how to configure them.
Local primitives
Local primitives are custom primitives that are local to your object. They contain all the logic and
attributes unique to the object. Local primitives are usually created to be virtual primitives.
Local primitives are created and maintained using the Object Designer. You can configure
custom code for the primitives events and set handlers in the same way as you would configure it
for the object itself.
In the Object Design View, local primitives are shown with a special icon, and they have their own
subentries for Attributes, Configtime events, and Runtime events.
Local primitive
Primitive hierarchies
When you add a local primitive to an application object, the ArchestrA Object Toolkit adds a
subfolder to the solution folder that contains the code files for that primitive. The primitive folder, in
turn, has different subfolders for configtime and runtime code. When you add another primitive to
that primitive, the ArchestrA Object Toolkit creates a subfolder in the primitive subfolder, and so
on.
Primitive embedded
in object
Primitive embedded
in primitive
Note: There is a limit to how many levels of primitives you can use. However, the current
Windows operating system imposes a limit of 260 characters for the complete file path. Therefore,
no path to any code file in any ArchestrA Object Toolkit project folder may exceed this limitation.
The exact number of levels you can use depends on the path length of the base ArchestrA Object
Toolkit solution folder and on the length of the primitive names. The shorter the primitive names,
the shorter the folder names, and the more levels you can use.
You can then configure the local primitive in the Configuration pane. The available parameters
are listed in the table below.
Parameter/Option Description
External Name The unique name by which other objects can access the primitives
attributes. The name must be ArchestrA compliant.
Internal Name The unique name by which you can refer to the primitive in the objects
code. The name must be C# compliant.
Dump/Load support for Dynamic attributes and virtual primitives are added and configured at
Dynamic Attributes & Virtual configtime, so their status & configuration may be different in each object.
Primitives This option preserves the configuration and allows the object to be
processed by the Galaxy Dump/Load feature without generating warnings.
Failover support for Runtime In a redundant environment with dual ApplicationEngines configured for
Dynamic Attributes failover, this option preserves any dynamic attributes created on your
object during runtime in case of a failover.
Virtual Designates that the primitive should be virtual.
You can also configure additional parameters by expanding the sections for Associated Files and
Advanced Configuration.
Associated Files is used for manually associating files with your object that are not set up as
project references in Visual Studio (for example, custom data files). Files listed here are included
in the object package file when you build the object, and optionally registered on the target system
when you import the object.
Advanced Configuration is used for configuring the order in which the primitive should be
executed relative to other primitives in the object, and for specifying that the primitive should use
other assemblies than the ones automatically generated by the ArchestrA Object Toolkit
Wonderware Training
Section 1 Local Primitives Overview 6-5
As stated in the previous module, the GetValue and SetValue methods use the primitive external
name and attribute external name, as shown in the following example:
GetValue(PrimitiveExternalName.AttributeExternalName)
Local references Use the attribute name with no prefixes or scope. Using the me prefix
explicitly sets the reference to local and can be used to make it clear what type of reference is
required.
Either of the following statements in Child2 gets the value of AOTObjectx1.Child2.Attribute1:
GetValue("Attribute1");
GetValue("me.Attribute1");
Referencing Down (child) Prefix the reference string with the name of the child primitives.
The following statement in Child2 gets the value of AOTObjectx1.Child2.Child4.Attribute1:
GetValue("Child4.Attribute1");
The following statement in AOTobjectx1 gets the value of AOTObjectx1.Child2.Child4.Attribute1:
GetValue("Child2.Child4.Attribute1");
Referencing Up (parent) Use the myparent prefix.
The following statement in Child2 gets the value of AOTObjectx1.Attribute1:
GetValue("myparent.Attribute1");
The following statement in Child4 gets the value of AOTObjectx1.Child2.Attribute1
GetValue("myparent.Attribute1");
The myparent prefix cannot be used more than once in a reference. To reference attributes of
objects or primitives more than one level higher, you must use myobject to locate the reference to
the top of the hierarchy and then work relative to that location.
The following statement in Child4 gets the value of AOTObjectx1.Attribute1:
GetValue("myobject.Attribute1");
The following statement in Child4 gets the value of AOTObjectx1.Child1.Child3.Attribute1:
GetValue("myobject.Child1.Child3.Attribute1");
Wonderware Training
Lab 10 Adding Counter Statistics 6-7
Count
Stats.Enabled
RolloverCnt
VIRTUALPRIMITIVE BadInputCnt
Counter
Stats Reset
Execute()
ResetCmd_RuntimeSH()
Objectives
Upon completion of this lab, you will be able to:
Add and implement local primitives within an application object
bool success;
if (e.Value)
{
//Value set to true. Add virtual primitive
success =
AddPrimitive("Stats", "Stats1", "Stats");
}
else
{
//Value set to false. Delete virtual primitive
success = DeletePrimitive("Stats1");
Wonderware Training
Lab 10 Adding Counter Statistics 6-9
if (success)
{
//Virtual primitive was added/deleted. Set value
Stats_Enabled.SetHandlerValue = e;
}
else
{
//Primitive could not be added/deleted
//Generate an error and do not set value
e.Message = PrimitiveResult.message;
}
}
Implement the runtime logic for the local primitive (page 6-14)
f. Modify the Declarations region of the Runtime project of the Stats primitive to make it look
exactly like this:
#region Declarations
//Declare Runtime Class Variables here.
//Variables declared in this region are available to all methods
//in the Runtime Class.
#endregion Declarations
g. Modify the Execute method of the Runtime project of the Stats primitive to make it look
exactly like this:
private void StatsRuntime_RuntimeExecute(object sender)
{
//Code written in this method is executed every scan
//while the object is On Scan
//only if the Stats primitive is loaded
//If current Count is less than previous value, a rollover has happened
if (currentCount < lastCount)
{
RolloverCnt++;
}
lastCount = currentCount;
lastInputQuality = currentInputQuality;
}
h. Modify the Runtime Set Handler for the Reset attribute of the Stats primitive to make it look
exactly like this:
private void ResetSetHandler(object sender, ref
RuntimeSetHandlerEventArgs e)
{
//If the attribute is set to true, reset stats
if (e.Value)
{
//Reset stats
RolloverCnt = 0;
BadInputCnt = 0;
}
Wonderware Training
Lab 10 Adding Counter Statistics 6-11
Wonderware Training
Lab 10 Adding Counter Statistics 6-13
bool success;
if (e.Value)
{
//Value set to true. Add virtual primitive
success =
AddPrimitive("Stats", "Stats1", "Stats");
}
else
{
if (success)
{
//Virtual primitive was added/deleted. Set value
Stats_Enabled.SetHandlerValue = e;
}
else
{
//Primitive could not be added/deleted
//Generate an error and do not set value
e.Message = PrimitiveResult.message;
}
}
#endregion Declarations
10. In Object Design View, under Stats and Runtime, double-click Execute.
11. Modify the StatsRuntime_RuntimeExecute method to make it look exactly like this:
private void StatsRuntime_RuntimeExecute(object sender)
{
//Code written in this method is executed every scan
//while the object is On Scan
//only if the Stats primitive is loaded
//If current Count is less than previous value, a rollover has happened
if (currentCount < lastCount)
{
RolloverCnt++;
Wonderware Training
Lab 10 Adding Counter Statistics 6-15
lastCount = currentCount;
lastInputQuality = currentInputQuality;
}
12. In Object Design View, under the Stats local primitive, expand Attributes, expand Reset,
and then double-click Runtime Set Handler.
13. Modify the ResetSetHandler method to make it look exactly like this:
private void ResetSetHandler(object sender, ref
RuntimeSetHandlerEventArgs e)
{
//If the attribute is set to true, reset stats
if (e.Value)
{
//Reset stats
RolloverCnt = 0;
BadInputCnt = 0;
}
Wonderware Training
Lab 10 Adding Counter Statistics 6-17
Hint: You can force the count to roll over by using the Reset attribute.
Whenever the counter input has a bad quality, it causes the Stats.BadInputCnt attribute
to increase
Hint: You can force the input to bad quality using the quality command attributes in the
Blinker object.
Wonderware Training
Section 2 Reusable Primitives Overview 6-19
Section Objectives
Describe what reusable primitives are and how they are beneficial
Explain how to create a reusable primitive
This section describes reusable primitiveswhat they are, how they are used, and how to create
and configure them.
Reusable primitives
Reusable primitives are primitives that are intended to be included in multiple objects. By
implementing common features as reusable primitives, you can share component-level code
across objects and avoid code duplication. The Input and Output primitives that you can add in the
Object Designer are good examples of how reusable primitives are beneficial.
From a development perspective, creating a reusable primitive is the same as creating an object,
except that there is no information describing the overall object, there is no editor (since only
objects have editors), and the final file created by the development process is an aaPRI file, not an
aaPDF. Reusable primitives must be added to an object before it can be imported into a Galaxy (a
reusable primitive cannot be imported alone). You can also add multiple instances of a reusable
primitive to the same object.
Using the ArchestrA Object Toolkit, you can create your own custom reusable primitives and use
them in other objects. Also, standard reusable primitives installed by Wonderware Application
Server are available in the following folder:
C:\Program Files\Common Files\ArchestrA\ReusablePrimitives\ ArchestrA
Technically, the Inputs and Outputs as well as the Alarm and History extensions that you can add
in the Object Designer are reusable primitives as well. (See Utility Primitives Overview on page
3-7.) However, there are separate mechanisms in the Object Designer for adding and configuring
these primitives.
As shown below, select Reusable Primitive from the Category drop-down list to create a
reusable primitive.
You can switch between Reusable Primitive and Application Object at any time. Any properties
and features that are not relevant to the current mode are blocked from access in the Object
Designer and Object Design View. However, they are still preserved in the project code, so when
you switch back to the other mode, they are available again.
Developing a reusable primitive is very similar to creating an application object; however, there are
certain differences.
The Object Designer does not have fields for editing the minor version, toolset name, or
description. These settings are irrelevant for a reusable primitive.
The Configuration Event Handlers and IDE Behavior sections are removed from the
Object Designer. Both are irrelevant for a reusable primitive. (The standard configtime
event handlers are still available via the Object Design View.)
A reusable primitive does not have its own setting for Advise Only Active support.
Advise Only Active support is determined by the object that the primitive is used in.
Reusable primitives do not have their own custom editor. Any required configuration UI
must be implemented in the editor of the object that contains it.
The Build & Import, Build & Instantiate, and Build & Deploy build modes are not
available. They are not applicable to a reusable primitive.
The Increment Minor Version versioning option is not applicable to reusable primitives.
The output file created by the build process is an .aaPRI file, not an .aaPDF file. You must
add the reusable primitive to an object before you can import it into a Galaxy. You cannot
import a reusable primitive alone.
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-21
Count
Count.RateEnabled
Rate
CalcPeriod
Counter REUSABLE RateReset
PRIMITIVE
Startup()
Count
Execute()
RateResetCmd_RuntimeSH()
CalcPeriod_ConfigtimeSH()
Count_RateEnabled_ConfigtimeSH()
Note: See page 2-19 for a
EDITOR legend to this graphic.
Objectives
Upon completion of this lab, you will be able to:
Add and implement reusable primitives within an application object
f. Modify the Declarations region of the Runtime project of the RateCalculator primitive to
make it look exactly like this:
#region Declarations
//Declare Runtime Class Variables here.
//Variables declared in this region are available to all methods
//in the Runtime Class.
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-23
#endregion Declarations
g. Modify the Startup method of the Runtime project of the RateCalculator primitive to make it
look exactly like this:
private void RateCalculator_RuntimeStartup(object sender,
RuntimeStartupEventArgs e)
{
//This code assumes that the external name of this primitive
//as assigned within an application object
//is equal to the source attribute name.
//RestoreDynamicAttributes();
h. Modify the Execute method of the Runtime project of the RateCalculator primitive to make it
look exactly like this:
private void RateCalculator_RuntimeExecute(object sender)
{
//Code written in this method is executed every scan
//while the object is On Scan
//only if this primitive is loaded
//Calculate rate
Rate = (float)((currentValue - lastValue)
/ timeSinceCalc.Seconds);
i. Modify the Runtime Set Handler for the RateReset attribute of the RateCalculator primitive
to make it look exactly like this:
private void RateResetSetHandler(object sender, ref
RuntimeSetHandlerEventArgs e)
{
//If the attribute is set to true, reset rate
if (e.Value)
{
Rate = 0.0f;
}
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-25
bool success;
if (e.Value)
{
//Value set to true. Add virtual primitive
success =
AddPrimitive("CountRate", "CountRate1", "Count");
}
else
{
//Value set to false. Delete virtual primitive
success = DeletePrimitive("CountRate1");
}
if (success)
{
//Virtual primitive was added/deleted. Set value
Count_RateEnabled.SetHandlerValue = e;
}
else
{
//Primitive could not be added/deleted
//Generate an error and do not set value
e.Message = PrimitiveResult.message;
}
}
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-27
3. Click OK.
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-29
#endregion Declarations
//RestoreDynamicAttributes();
//Calculate rate
Rate = (float)((currentValue - lastValue)
/ timeSinceCalc.Seconds);
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-31
15. In Object Design View, under Runtime, double-click RateReset Set Handler.
16. Modify the RateResetSetHandler method to make it look exactly like this:
private void RateResetSetHandler(object sender, ref
RuntimeSetHandlerEventArgs e)
{
//If the attribute is set to true, reset rate
if (e.Value)
{
Rate = 0.0f;
}
24. In the Shape pane, under the Count reusable primitive, click CalcPeriod.
25. In the Configuration pane, change the Value to 00:00:05.000 (5 seconds).
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-33
bool success;
if (e.Value)
{
//Value set to true. Add virtual primitive
success =
AddPrimitive("CountRate", "CountRate1", "Count");
}
else
{
//Value set to false. Delete virtual primitive
success = DeletePrimitive("CountRate1");
}
if (success)
{
//Virtual primitive was added/deleted. Set value
Count_RateEnabled.SetHandlerValue = e;
}
else
{
//Primitive could not be added/deleted
//Generate an error and do not set value
e.Message = PrimitiveResult.message;
}
}
Wonderware Training
Lab 11 Creating a Rate Calculator Reusable Primitive 6-35
Hint: You can make the count stop by using the Blinker object.
Wonderware Training
Module 7
Object Editor
Section 1 Editor Design 7-3
Lab 12 Enhancing the Counter Editor 7-11
7-2 Module 7 Object Editor
Module Objectives
Use Archestra controls in a custom object editor
Wonderware Training
Section 1 Editor Design 7-3
Section Objectives
Describe the process of designing a custom object editor in the ArchestrA Object Toolkit
Explain how to add ArchestrA controls to the Visual Studio Toolbox
This section describes how to design a custom object editor to provide users with a graphical
interface for configuring an application objects attributes in the ArchestrA IDE.
Adding tabs
You can create multiple custom tab pages for your object editor. In the ArchestrA IDE, these
custom tab pages appear alongside the standard tab pages that are shown for every object
(Object Information, Scripts, UDAs, etc.).
You can hide these standard editor tabs if you do not need them. To hide these tabs, open Object
Designer, select the object in the Shape pane, and check the Hide Standard Editor Tabs option
under IDE Behavior.
To add a new tab, right-click the forms tab control and click Add Tab.
Tab control
To rename a tab, change its Text property in the Visual Studios Properties window.
To delete a tab, bring it to focus and then right-click the forms tab control and click Remove Tab.
Embedding controls
Your editor should have controls to allow the user to configure all configurable attributes of the
object and its primitives. Your editor can also include controls for configuring attributes of virtual
primitives. In the ArchestrA IDE, these controls are automatically enabled or disabled depending
on whether the virtual primitive instance exists or not.
To place controls in your custom object editor, drag controls and items onto a tab page on the
Editor form. You can use the following types of controls and items:
Attributes from the Object Design View (The ArchestrA Object Toolkit automatically adds
a standard label as well as ArchestrA controls for editing the value, security classification,
and lock status of that attribute.)
Standard UI design controls and items from the Visual Studio Toolbox
Special ArchestrA controls that have been added to the Visual Studio Toolbox
Wonderware Training
Section 1 Editor Design 7-5
Object dictionary items from the Object Design View (The ArchestrA Object Toolkit
automatically adds a label that will show the correct localized value at runtime.)
Binding controls
After you have added controls to your object editor, you can associate (link) them with an attribute
in code. To do this, set the controls Attribute property (in the Properties window) to the external
name of the attribute.
You can also do this programmatically from configtime code. This allows you, among other things,
to configure multiple primitive instances using the same editor page. For example, to set the
attribute reference of the control instance aaTextBox1 to Prim1.Attr1, use this statement:
aaTextBox1.Attribute = "Prim1.Attr1";
Framework Controls
Most framework controls are designed to easily bind to and automatically display a single attribute
value. Although the presentation of the attribute values vary with each control, the basic design
pattern for all of these controls is consistent and share the following characteristics:
The controls derive from a standard WinForm control. That control's properties and events
are therefore available in the associated editor framework control.
The controls implement the interface IaaControl. These methods are normally called only
by the containing editor's base class.
The controls expose the standard properties and events, as discussed below.
Properties
Attribute: The name of the attribute that the control is bound to. The control will subscribe
for data associated with this attribute.
ControlStyle: Provides some information to the editor infrastructure about how to process
the control. This value will always be AACONTROLSTYLE_TabPageContent for user
defined controls.
Enabled: Each control overrides the base class defined Enabled property. This is needed
to manage how controls are enabled in response to user and system interactions with the
form. The rules for enabling and disabling are as follows:
Any enabled control can be disabled by the editor code or the system.
A control that has been disabled by the editor can only be enabled by the editor. The
system cannot enable an editor disabled control.
A control that has been disabled by the system can only be enabled by the system.
The editor cannot enable a system disabled control.
If the editor is opened in read-only mode neither the editor nor the system can enable
a disabled/read-only control.
Dictionary & PhraseID (optional): These properties only apply to controls which can
display localizable text. Specifies the Dictionary file (.aaDCT) to use and the PhraseID
identifying the localized text within it. If the dictionary is left blank, the default dictionary for
the editor will be assumed.
Events
These events are raised when the controls associated IaaControl methods are processed. This
allows editors, for example, to react to data changes for a specific control.
Initialized
Syntax
private void Initialized(object sender, EventArgs e);
Remarks
Called early in the loading process, before the Editor is completely loaded and functional.
This method can be overridden in order to handle custom initialization tasks.
DataChanged
Syntax
private void DataChanged(object sender, DataChangeEventArgs e);
Remarks
This method is called when a subscribed attribute's value has changed. The form will then
pass on the event to all controls that have subscribed to the data.
Applied
Syntax
private void Applied(object sender, EventArgs e);
Remarks
This method is called when the current Editor values are saved, for example, when the
user clicks the Save button in the ArchestrA IDE. The form will then pass on the event to
all controls currently enabled.
Editor Methods
GetData
Syntax
public object GetData(string sAttribute, string sProperty);
Parameters
sAttribute Attribute external name. In addition, GetData() supports reading individual
elements of arrays using the syntax: attributename[index].
sProperty Property to access. Possible values are:
value The attribute's value. The type of object returned will depend on the
attribute's type. Bools are returned as System.Booleans, Integers are returned as
System.Int32s. All other non-array datatypes are returned as a System.Strings.
Arrays are returned as System.Object[] containing elements for the attribute's
datatype.
securityclassification The attribute's security classification. Returned as
one of the following System.Strings:
MxSecurityFreeAccess
Wonderware Training
Section 1 Editor Design 7-7
MxSecurityOperate
MxSecuritySecuredWrite
MxSecurityVerifiedWrite
MxSecurityTune
MxSecurityConfigure
MxSecurityReadOnly
MxSecurityUndefined
lock The attribute's lock status. Returned as one of the following
System.Strings:
MxUnLocked
MxLockedInMe
MxLockedInParent
MxSecurityUndefined
valuereadonly, lockreadonly, and securityclassificationreadonly
These are not true ArchestrA attribute properties. They indicate whether the
specified property is writeable. Controls that modify attributes should monitor
these items and enable/disable themselves (or change to a readonly mode)
based on their value, but only if the editor itself is not ReadOnly and the control
was not disabled via its Enabled property. In those situations the control should
remain disabled.
The value returned is a System.Boolean.
attributecategory Returned as a System.Int32
type Returned as a System.Int32
upperbounddim1 The length of a attribute containing an array. Returned as a
System.Int32
enumstringarray Returns a System.String[] defining an attribute of type
"custom enumeration"
isenum Returns a System Boolean. True if attribute is an enumeration
Remarks
Returns the value of an attribute or one of its other properties. Value will be null if not
present.
SetData
Syntax
public void SetData(string sAttribute, string sProperty, object sVal);
Parameters
sAttribute Attribute external name
sProperty Property to access. Possible values are those listed for GetData, or:
add Valid only if attribute is "beo:UDAs" or "beo:ScriptExtension". sVal specifies
name of UDA or script extension to add.
delete Valid only if attribute is "beo:UDAs" or "beo:ScriptExtension". sVal
specifies name of UDA or script extension to remove.
Remarks
This function is used to set data into a specific attribute. If not passed, the property is
assumed to be the attribute's value.
If the set fails, a message will be displayed to the user via a message box. The success or
failure of the SetData() call can also be checked by calling the editor's IsSuccess()
method.
GetLocalizedText
Syntax
public object GetLocalizedText(string sPhraseID, string sDictionary);
Parameters
sPhraseID The PhraseID within the dictionary to retrieve
sDictionary The associated aaDCT file to retrieve the text from (If blank, the editor's
Dictionary property is used instead.)
Remarks
This function returns localized text for the specified Phrase ID from the specified
dictionary.
LogError
Syntax
public void LogError(string strMsg);
Parameters
strMsg The string to add to the ArchestrA log file
Remarks
This function adds the string to the Archestra logger as a LogError message.
LogWarning
Syntax
public void LogWarning(string strMsg);
Parameters
strMsg The string to add to the ArchestrA log file
Remarks
This function adds the string to the Archestra logger as a LogWarning message.
LogInfo
Syntax
public void LogInfo(string strMsg);
Parameters
strMsg The string to add to the ArchestrA log file
Remarks
This function adds the string to the Archestra logger as a LogInfo message.
Wonderware Training
Section 1 Editor Design 7-9
LogException
Syntax
public void LogException(Exception ex);
public void LogException(Exception ex, string str);
Parameters
ex The exception to be logged
str Optional text to add to the log entry
Remarks
This function will format the exception (message and stacktrace) into a string and add the
formatted string to the ArchestrA logger as a LogError message. If desired, an optional
message can be included.
Wonderware Training
Lab 12 Enhancing the Counter Editor 7-11
Objectives
Upon completion of this lab, you will be able to:
Add ArchestrA controls to the Visual Studio Toolbox
Use ArchestrA controls to implement a custom object editor
Wonderware Training
Lab 12 Enhancing the Counter Editor 7-13
Wonderware Training
Lab 12 Enhancing the Counter Editor 7-15
8. Click Open.
All the ArchestrA controls in the library are added and selected in the Choose Toolbox Items
dialog box.
9. Click OK to add the controls to the Toolbox (it will take a few moments to populate).
10. Right-click on the ArchestrA tab and click Sort Items Alphabetically.
Note: To ensure that the aaLockGroupIcon control will lock the controls in the group, do
not move it outside the group.
15. Move the alarm Timeout Condition and Limit controls (the remaining controls) to inside the
group, and then change their labels as necessary.
Wonderware Training
Lab 12 Enhancing the Counter Editor 7-17
16. For the alarm priority, place the following controls inside the group, and then change the label
as necessary:
aaLabel
aaTextBox
aaLockIcon
aaSecurityClassification
17. For the alarm message, place the following controls inside the group, and then change the
label as necessary:
aaLabel
aaTextBoxMxReference
aaLockIcon
aaSecurityClassification
18. Arrange the controls to look like the Alarms tab shown on the previous page.
Next you will configure the properties of the ArchestrA controls so they will be bound to the
Counter attributes.
19. On the Alarms tab, select the Priority text box, lock icon, and security classification icon.
20. In the Properties window, locate the Attribute property and change it to
Timeout.Condition.Priority.
21. Repeat the previous steps to change the Alarm Message attribute properties to
Timeout.Condition.DescAttrName.
Note: The lock group icon control is not bound to any attribute, but it is bound to all controls
within the same group.
24. Repeat the previous steps to change the following name properties:
Editor Element (Name) Property
Limit text box aaTimeoutLimit
Limit lock icon aaTimeoutLimitLock
Limit security classification icon aaTimeoutLimitSC
Now you will implement the DataChanged event of the aaTimeoutConditionAlarmed control.
25. Click the Timeout Alarm check box control.
26. On the toolbar of the Properties window, click Events.
Wonderware Training
Lab 12 Enhancing the Counter Editor 7-19
aaTimeoutLimit.Enabled = alarmEnabled;
Wonderware Training
Module 8
Advanced Features
Section 1 Application Objects Documentation 8-3
Section 2 Object Dictionary 8-5
Lab 13 Using the Object Dictionary 8-7
Section 3 Version Management 8-13
Section 4 Dependent Files 8-21
8-2 Module 8 Advanced Features
Module Objectives
Describe how to add object help to a custom object template
Configure the object dictionary file to contain user error messages that can be retrieved
by runtime and configtime set handlers
Explain the object versioning options and migration features
Describe dependent file management
Wonderware Training
Section 1 Application Objects Documentation 8-3
Section Objectives
Explain how to include object help with a custom application object.
This section describes how to add object help to your custom application object so that end users
can access it from the ArchestrA IDE.
Help documentation
You should provide documentation with your application objects that includes help on object
usage, configuration, runtime behavior, and attributes. The help should be in the form of an
Object Help page so that end users can access it from the ArchestrA IDE.
The .aaPDF file that Visual Studio generates contains only the configuration data and
implementation code for your base object template; it does not contain an object help file. To
provide object help for your end users, you need to package your object in an .aaPKG file, as
described in the procedure below.
Important: Before using this procedure, you should ensure that your systems file association for
.htm files is set to a proper HTML editor.
c. Click No to open a predefined template, or click Yes to browse for a pre-existing help file.
d. Add your custom text to the object help file.
e. Save the file.
This is the path and file name that will be used for your object help file after it is added using the
ArchestrA IDE. If you have images in your help file, place them in the proper folder and use a
relative path to those images in the HTML file. For example, place them in the \1033 folder or
create an images folder under it.
To test that your object can find the help file, right-click on the object in the ArchestrA IDE and
select Object Help.
Wonderware Training
Section 2 Object Dictionary 8-5
Section Objectives
Specify the purpose of the object dictionary file
Explain how to use the object dictionary for internationalizing objects
This section provides an overview of the object dictionary, including what it is used for, how to edit
the dictionary file, and how to use it for internationalizing objects.
There is a single Phrase_Index element for every translatable string. Its PhraseID attribute
defines the ID by which you can access the string.
Each Phrase_Index element contains one Language element for each language-specific
translation of the string. The LangID attribute of the Language element specifies the locale that the
translation applies to.
Each Language element contains a single VALUE element with the translated string for the
specified locale.
Internationalization
If your object will be used in localized environments, you can internationalize it by defining a
multilingual dictionary that contains translated strings for the target locales. At runtime, the object
can retrieve the appropriate strings for the locale it is used in, and show those translated strings to
the end user.
By internationalizing an object, you enable it to run in various language environments and use
different translated text messages, prompts, etc. in each case. For example, assume that you
develop a complex object with its own custom editor pages. Customers in North America would
expect to see English editor pages. On the other hand, customers in South America might use the
object on a Spanish operating system and expect to see the editor pages in Spanish.
One way to do this is to create and maintain separate language versions of the object. However,
this makes it very hard to maintain and update your code. A better way is to maintain one object
version that will use the correct translated strings depending on the locale it is used in.
To do this, you separate the objects code (which works identically in all locales) from the
translatable text phrases (which are different for each locale). The translatable content in the code
is replaced with abstract phrase IDs. The object then retrieves the appropriate translated content
for whatever phrase ID it needs, when it needs it.
GetText("idsWelcome"); GetText("idsWelcome");
If an application object contains local primitives, all local primitives use the objects main
dictionary. Reusable primitives, on the other hand, have their own dictionary.
Wonderware Training
Lab 13 Using the Object Dictionary 8-7
Count
GetStatusDesc()
Counter MaxCount_ConfigtimeSH()
Timeout_Limit_ConfigtimeSH()
Note: See page 2-19 for a
DICTIONARY legend to this graphic.
Objectives
Upon completion of this lab, you will be able to:
Modify the object dictionary file and use it to retrieve user error messages
Modify the runtime logic to use the dictionary file (page 8-11)
c. Modify the GetStatusDesc method of the Runtime project to make it look exactly like this:
private void CounterRuntime_RuntimeGetStatusDesc(object sender, ref
RuntimeGetStatusDescEventArgs e)
{
//Return the correct error message based on the
//detailed error code passed by the Set Handler
switch (e.detailedErrorCode)
{
//All error codes will be retrieved from the dictionary
//using the GetText() method
default:
e.status = GetText((int)e.detailedErrorCode);
break;
}
}
Wonderware Training
Lab 13 Using the Object Dictionary 8-9
Modify the configtime logic to use the dictionary file (page 8-11)
d. Modify the Configtime Set Handler for the MaxCount attribute to make it look exactly like
this:
private void MaxCountSetHandler(object sender, ref
ConfigtimeSetHandlerEventArgs e)
{
//Verify that the set value is greater than zero
if (e.Value > 0)
{
//Valid set value. Set MaxCount.
MaxCount.SetHandlerValue = e;
}
else
{
//Invalid set value. Return error message.
e.Message = GetText(10001);
}
}
e. Modify the Configtime Set Handler for the Timeout.Limit attribute to make it look exactly like
this:
private void Timeout_LimitSetHandler(object sender, ref
ConfigtimeSetHandlerEventArgs e)
{
//Verify that the set value is greater than zero
if (e.Value > 0)
{
//Valid set value. Set MaxCount.
Timeout_Limit.SetHandlerValue = e;
}
else
{
//Invalid set value. Return error message.
e.Message = GetText(10002);
}
}
Wonderware Training
Lab 13 Using the Object Dictionary 8-11
switch (e.detailedErrorCode)
{
//All error codes will be retrieved from the dictionary
//using the GetText() method
default:
e.status = GetText((int)e.detailedErrorCode);
break;
}
}
else
{
//Invalid set value. Return error message.
e.Message = GetText(10002);
}
}
Wonderware Training
Section 3 Version Management 8-13
Section Objectives
Identify the different object versioning options and summarize how they are used
Explain how to use the Migrate tool and enter migration code
This section describes object versioning for major and minor builds of an object. It also provides
information about migration of new object versions into an application in the Wonderware
Application Server.
Object versioning
An application object has a version number that consists of a major version and a minor version.
For example, 1.3 where 1 is the major version and 3 is the minor version. This version number
helps Application Server distinguish object versions and detect any migration requirements.
When you build your object, you can keep the current version number, or you can automatically
increment the minor or major version. You can also specify the version numbers manually in the
object properties.
While developing an object, it is safest to have the major version number increment automatically
on new builds. This helps avoid problems if you change the object shape but forget to increment
the major version accordingly. Once there is a stable build and successful test, you can reset the
major revision number back to the desired number and do a final Build.
Wonderware Training
Section 3 Version Management 8-15
Migration
When you import a new major version of an object template into Wonderware Application Server,
existing instances of that object can be automatically migrated. This allows you to preserve their
configuration in the new object version.
This is very easy if the new object version uses the same attributes as the previous version. In this
case, all attribute values are automatically copied over from the old versions instances to the new
versions instances.
However, you must create custom migration code if:
The new version has attributes that the old version does not have, and vice versa; and/or
The security classification of an attribute has changed in the new version.
In this scenario, the custom migration code handles the mapping of attribute values between the
old and new version. For example, if you have changed an attributes name from Attribute1 to
AttributeA, but the attribute still has the same purpose, the migration code could copy the value
of Attribute1 (in the old version) to AttributeA (in the new version). This code has to be written in
the Migrate event handler in configtime. See page 8-18 for an example of the migration code.
Wonderware Training
Section 3 Version Management 8-17
Use the following steps to create a migration code section for a previous version:
a. On the ArchestrA Object toolbar, click the Migrate button.
b. Open the .aaPDF file of the previous object version (or the .aaPRI file if you are developing a
reusable primitive), and then click Open. You can now view the auto-generated migration
analysis results.
c. In Object Design View, expand the Configtime folder, and then double-click Migrate. The
migration results section opens in the code editor.
Note that the ArchestrA Object Toolkit has inserted a new code region showing the differences
between the two versions. Enter any required migration code for the previous version here.
The ArchestrA Object Toolkit has also automatically updated the ObjectAttributes.Migrate property
to include the version number of the object that you selected in step b above. This tells Application
Server that your application object supports migrating from that version. For more information on
this property, see the ArchestrA Object Toolkit Reference Guide.
You can repeat this process for multiple previous versions of an object. The ArchestrA Object
Toolkit generates a separate code region for each previous version. This allows you to have
migration code for multiple previous versions in the same object.
ConfigtimeMigrate event
The ConfigtimeMigrate event is triggered when importing a template into a Galaxy that contains
a previous version (major) of the template. The template of the previous version must be derived
or instantiated for Migrate to execute. This event handler is where you can write any code to
implement custom migration of attributes.
The ArchestrA Object Toolkit automatically generates code to register the delegate
<objectname>Configtime_ConfigtimeMigrate for this event. Using the MigrateHandler parameter,
a user can access the previous version's attribute information in this delegate.
Syntax
public event MigrateDelegate ConfigtimeMigrate;
Note the if condition at the beginning of the code. Using similar conditions, you can have
additional, separate migration code sections for other previous major versions of the object.
migrate.GetValue(migrate.OriginalPrimitiveFullName + ".Attribute1")
Wonderware Training
Section 3 Version Management 8-19
The options in this dialog box are divided into three sections. When migrating a new major version
of your object template, you need to pay attention to the middle section.
Top section Specifies whether an object (derived template or instance) can be imported
if an object with the same tagname already exists in the Galaxy and that object is derived
from the same Codebase (same base template). This basically deals with importing
different configuration versions of derived templates and instances.
Middle section Specifies whether a base template can be imported if it has a different
revision number in its Codebase than a related template in the Galaxy (new minor or
major version of the same base template) and importing it would require objects to be
migrated to a newer implementation version.
If you select Migrate and an object requires migration, older versions of the objects
being imported or already existing in the Galaxy will be migrated to the newer version:
If an imported object has an older implementation version than an existing related
object in the Galaxy, it will be migrated to the newer version when it is imported.
If an imported object has a newer implementation version than existing related
objects in the Galaxy, they will be migrated to the newer implementation that was
just imported.
If you select Skip, objects that require migration will not be imported.
Bottom section Specifies how to resolve a name conflict if an object being imported has
the same tagname as an existing one in the Galaxy but is derived from a different
Codebase. This basically deals with name conflicts when importing an entirely different
object.
Wonderware Training
Section 4 Dependent Files 8-21
Section Objectives
Explain how set up dependent file associations by using rules and by setting the
associations manually
Explain how to configure additional search paths for dependent files
This section provides an overview of dependent files and explains how to configure them in the
ArchestrA Object Toolkit.
You can set up rules before or after you have added the relevant references to your project in
Visual Studio.
If you have added references to your project, the references automatically appear in the
Dependent Files list at the bottom of the window. You can create rules for these very easily
without having to type the reference again. To set up a rule for these, select the file and click either
the All Objects or This Object button, depending on where you want the rule to apply. A new rule
for this reference then appears in the corresponding section of the Rules list and you can
configure it as described on the next page.
Note: Files shown in gray are already covered by a rule. References not currently covered by a
rule are shown in black.
To set up a new rule for files that you have not yet added as references in Visual Studio, click
either This Object or All Objects in the Rules list, depending on where you want the rule to apply,
and then click the Add button ( ). You can then configure the rule as describe on the next
page.
Note: The System folder of the Dependent File Manager always contains a set of default rules for
references to core system libraries. You cannot edit the rules in this folder.
Wonderware Training
Section 4 Dependent Files 8-23
Configuring rules
The following parameters are available for setting up rules for dependent files in the Dependent
File Manager.
Parameter Description
Reference The referenced dependent file(s) to which this rule should apply. You can enter a .NET regular
expression. For example, if you are using references to MyMathLib.Core.dll and
MyMathLib.Data.dll, you can enter MyMathLib* to cover both.
Select the Ignore check box if you do not want to add the dependent files(s) to the object
package file generated by the build process. You would select this option if the files will already
be present on the target system. A red X appears in the Rules list for these references.
Vendor The name of the vendor
Type The file type
One of the following file types which determine if and how files covered by this rule are
registered on the target system:
Dictionary An ArchestrA Dictionary (.aaDCT) file
NETFrameworkAssembly Strongly named .NET Framework Assembly. The file is
installed into the Global Assembly Cache (GAC)
ComDLL COM in-proc server DLL. The file is registered on the target system using
regsvr32.
Normal A normal file. Nothing is done on the target system except install the file.
ComEXE COM local server EXE. The file is executed on the target system with the /
RegServer parameter.
NTService A file that runs as a Windows service
MergeRegistryScript A .reg file with registry information. The file is imported into the
registry.
MsiMergeModule A bundled subcomponent of an installer.
NETFrameworkAssemblyNIG NET Framework Assembly. The file is not installed into
the Global Assembly Cache.
Unknown Only applicable if you selected the Ignore check box
To add an associated file click the Add button, and then configure the file in the Associated File
dialog box, shown below.
Note: For descriptions of the files types you can select, see Configuring rules on page 8-23.
Wonderware Training
Section 4 Dependent Files 8-25
Wonderware Training
Appendix A
SimpleAnalog Object
A-2 Appendix A SimpleAnalog Object
Wonderware Training
Appendix A SimpleAnalog Object A-3
Objectives
Upon completion of this lab, you will be able to:
Apply the most important concepts in the development of an application object using the
ArchestrA Object Toolkit
PV
INPUTPRIM
PV.Input
VIRTUALHISTPRIM
PVHistory
PV.EngUnits
PV.Deadband
PV.LevelAlarmed
Hi.Limit
Hi.Condition
VIRTUAL VIRTUALALMPRIM
LOCAL HiAlarm
PRIMITIVE Lo.Limit AnalogMeter Level
SimpleAnalog LevelAlarms Lo.Condition (Providedby
VIRTUALALMPRIM Instructor)
LoAlarm
PV.Scaled
RawMin
VIRTUAL RawMax
REUSABLE EngUnitsMin
PRIMITIVE EngUnitsMax
Scaling
_RawAttrName
_CalcEUVal
CUSTOMEDITOR
Wonderware Training
Appendix A SimpleAnalog Object A-5
Note: There are no detailed steps for this lab on the following pages. Only general guidance is
given to allow you to put into practice the concepts learned until now.
Create a new solution for the SimpleAnalog object, and following the figure on the previous page,
design the object and write the necessary configtime and runtime logic to implement a behavior
similar to that of the $AnalogDevice object. More specifically, the SimpleAnalog object should
behave as described below.
To test the behavior of the object, you can use the provided AnalogMeter object, which can be
imported from C:\Wonderware Training\AnalogMeter.aaPKG. This object contains an attribute
called Level, which represents the measurement of a level meter in counts, ranging from 0 to
4095. Use this attribute as an input source to your SimpleAnalog object, scaling this raw count
value into an engineering units range of your choosing.
Runtime behavior
Configuration behavior
The user should be able to configure all attributes writable in configtime using a custom
editor in the ArchestrA IDE.
Adding and deleting virtual primitives should be possible using the custom editor in the
ArchestrA IDE.
Development Considerations
There are several ways to implement the required functionality, but in this section some
suggestions and considerations are discussed.
Since the Scaling primitive is reusable, a different Visual Studio solution must be created for it.
There are two main challenges in this primitive:
1. Find a way to obtain the raw input value from the container object.
2. Give the scaled value back to the container in a way that it will allow it to apply the deadband.
To solve the first problem, the easiest and most flexible way to do this is to create an attribute in
the Scaling primitive that will hold the name of the attribute in the container object providing the
raw value. The idea here is that the developer of the container object should explicitly provide the
raw value attribute name to the reusable primitive, similar to the way it is done in the alarm and
history primitives. This way, the reusable primitive can avoid having to look for this name using
restrictive naming conventions, or predefined assumptions. For this purpose, a hidden attribute
_RawAttrName has been added to the Scaling primitive on page A-4. It is the responsibility of the
container object's developer to set this attribute during configtime.
Regarding the second problem, the challenge here is to enforce the deadband. For example, it
would be fairly easy for the Scaling primitive to scale the value and then assign this result to the
parent's PV attribute. But then, how does the deadband get enforced in this case? To do this, the
reusable primitive would need to know the deadband, which starts complicating things, and adds
one more assumption to the development of the Scaling primitive. Remember that a reusable
primitive can potentially be used in several objects, so it should be fairly generic. In this case, the
easiest and more generic way to provide the scaled result to the container object is to go the other
way around: allow the container object to grab the scaled result from the reusable primitive. In that
way, the parent object can take care of enforcing the deadband. What this means for the Scaling
primitive, is that the only thing it needs to do is to calculate the scaled value, and store it in an
attribute that the container object can access. For this purpose, a hidden attribute _CalcEUValue
has been added to the Scaling primitive on page A-4. It is the responsibility of the container
object's code to obtain this value in runtime and use it to populate the PV.
There is one very important point of attention needed when assigning the PV value: when the
object goes On Scan, the PV has a value of NaN and a quality of Initializing. From the deadband
calculation standpoint, that means there is no previous value to compare against. So typically, if
the quality of the PV is Initializing, there is no need to check the new PV value against the
deadband.
Be careful about the execution order of the different primitives in the object. For the object to
exhibit the above behavior, the primitives should execute in the following order:
1. Input
2. Scaling
3. SimpleAnalog (topmost primitive)
4. LevelAlarms
In this regard, remember that:
By default, the Input primitives are always executed first.
By default, the topmost primitive always executes last. This means that, by default,
Scaling will execute before SimpleAnalog.
The previous point means that LevelAlarms also executes before SimpleAnalog by
default. Therefore, you may need to configure the LevelAlarms primitive to force it to
execute in the desired order.
Wonderware Training