Tech Note 533 ApplicationObject Containment Practices for Wonderware Application Server All Tech Notes and KBCD documents and software are provided "as is" without warranty of any kind. See the Terms of Use for more information. Topic#: 002270 Created: March 2008 Introduction This Tech Note provides a brief overview on the practice of Containment by providing a simple tank example. Containment is the relationship in which one application objects includes another in a parent-child relationship. For example, a tank or vessel may contain inlet and outlet valves. In the Application Server context, the tank is the container object, and the inlet and outlet valves are contained objects. Practicing containment saves engineering time, especially in the scripting area. Objects can be referred to by the name that derives from the containment relationship.this name is called a hierarchical name. Note: For more information on containment, please refer to Creating Contained Templates, in Chapter3 of the IDE documentation. Application Version All versions including Industrial Application Server and Wonderware Application Server 3.0 Containment Example The following example demonstrates how objects are referenced in a plant equipment model such as a tank system. To build a template for a Tank 1. Create a new template toolset called TankApplication. 2. Created a derived template from $UserDefined and rename it to Tank. 3. Create a derived template from $DiscreteDevice and rename it to Inlet. 4. Create a derived template from $DiscreteDevice and rename it to Outlet. 5. Create a derived template from $AnalogDevice and rename it to Level. 6. Create a derived template from $UserDefined and rename it to Agitator. 7. Drag $Tank, $Inlet, $Outlet, $Level and $Agitator to TankApplication toolset. 8. Drag $Inlet, $Outlet, $Level and $Agitator objects to $Tank object in the Template Toolbox (Figure 1 below). Note: Name the derived templates appropriately so that they will be contained names when an instance is created from the $Tank template. Otherwise, it will add more work if you rename the contained name after creating the instance. In addition, you have to update the scripts also. Contained names are not updated automatically in scripts when they are renamed. https://wdnresource.wonderware.com/support/kbcd/html/1/t002270.htm 1/5
FIGURE 1: TANK MODEL Object Referencing The following graphic shows the simple scripting done in container object ($Tank) referencing to contained objects ($Agitator, $Inlet, $Level and $Outlet). UDAs 1-6 are defined as UserDefined Attributes in the $Tank Object. UDAs 1-4 are string types, UDA5 is an Integer, and UDA6 (used for the script Expression) is Boolean. https://wdnresource.wonderware.com/support/kbcd/html/1/t002270.htm 2/5
FIGURE 2: REFERENCE SCRIPTING FOR THE CONTAINER OBJECT Reference Scripting for $Tank me.uda1 = me.outlet.tagname; outlet. me.uda2 = me.inlet.tagname; inlet. me.uda3 = me.level.tagname; level. me.uda4 = me.agitator.tagname; agitator. me.uda5 = me.level.pv; level. 'me.uda6 allows the script to fire when me.uda6 transitions from false to true. The following graphic shows the scripting done in contained object ($Agitator) referencing to container object ($Tank) and also to other contained objects ($Inlet, and $Outlet) belonging to the same parent. UDAs1-4 are defined as UserDefined Attributes in the $Agitator object. UDA1-3 are String types, UDA4 (used for the script Expression) is a Boolean. FIGURE 3: REFERENCE SCRIPTING FOR CONTAINED OBJECTS Reference Script Example for $Agitator Object https://wdnresource.wonderware.com/support/kbcd/html/1/t002270.htm 3/5
me.uda1 = mycontainer.tagname; 'Allows a script running in any of the children to reference to parent object. me.uda2 = mycontainer.inlet.tagname; 'Allows a script running in any of the children to reference another child named Inlet that belongs to the same parent. me.uda3 = mycontainer.outlet.tagname; 'Allows a script running in any of the children to reference another child named outlet that belongs to the same parent. 'me.uda4 allows the script to fire when me.uda4 transitions from false to true. The following graphic shows the snapshot of deployment view showing couple of instances created from $Tank Object. No script modification is required in the instances after creating the new instances, since the scripts reference the contained name. This is one of the main advantages of using containment. FIGURE 4: NEW INSTANCES The following graphic shows the snapshot from the ObjectViewer showing the values for UDAs subscribing to object containment references. Note: A reference to the instance of Tank Template can be accomplished in any other object that is not part of the Tank Containment. In the following graphic UDO.uda2 points to Tank01.Agitator.Tagname. https://wdnresource.wonderware.com/support/kbcd/html/1/t002270.htm 4/5
FIGURE 5: UDA REFERENCE TO TANK01.AGITATOR.TAGNAME Reference Scripting for UDO Object me.uda2 = Tank_001.Agitator.Tagname; 'Allows a script running in any other object that is not part of the Tank Containment. Click the following icon to view this file in.pdf format: S. Mariyala Tech Notes are published occasionally by Wonderware Technical Support. Publisher: Invensys Systems, Inc., 26561 Rancho Parkway South, Lake Forest, CA 92630. There is also technical information on our software products at Wonderware Technical Support For technical support questions, send an e-mail to support@wonderware.com. Back to top 2013 Invensys Systems, Inc. All rights reserved. No part of the material protected by this copyright may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying, recording, broadcasting, or by anyinformation storage and retrieval system, without permission in writing from Invensys Systems, Inc. Terms of Use. https://wdnresource.wonderware.com/support/kbcd/html/1/t002270.htm 5/5