You are on page 1of 3

8/23/13

Activating InTouch I/O Tags

Tech Note 292

Activating InTouch I/O Tags


All Tech Notes and KBC D documents and software are provided "as is" without warranty of any kind. See the
Terms of Use for more information.
Topic#: 001089
C reated: January 2003

This Tech Note outlines some aspects of activation of I/O tags and presents options to properly
handle I/O tag activation from a script.

Introduction
I/O Tags get their values from an external source defined via an Access Name. An InTouch I/O
tag is said to be active when WindowViewer opens a communication channel with the I/O server
and requests the value of the tag to be send. The I/O server will respond to the client with the
value, timestamp, and quality data. After that, the I/O server will only update the client (the
InTouch application) whenever changes in value or quality occur; this functionality is commonly
known as "Report By Exception." For more information please refer to Tech Note 116, Overview
of How Wonderware I/O Servers Operate.

Activation of I/O Tags


The following conditions will cause a tag to be active inside an InTouch application:
The tag is displayed in an active InTouch window.
The tag is referenced in a data change, condition, application, key script, ActiveX event
script, or quick function (even if the script does not execute or the quick function is not
called). The exceptions are window and action scripts, where the window must be open
for referenced tags to become active.
The tag is being alarmed.
The tag is being trended (historical or real-time trends).
The tag is being logged (log events enabled).
The tag is being accessed by another node (for example via SuiteLink).
The tag uses an Access Name set to "Advise all items."
Other conditions that are not as common but also cause a tag to become active include:
The tag is used in an SPC Dataset for Auto Collection. See details below.
The tag is used in a BindList and a call is made to a script function that uses the BindList
as one of its arguments (see details below).
The tag is referenced from an external application that uses SuiteLink, DDE, TagAccess,
InTouchCOM, ITEdit OCX control, or the IDEA toolkit to read/write from/to the tag (for
example, PtAccActivate() function in the IDEA toolkit library).
The tag is bound to a property for an ActiveX control that resides in an active window.
The tag is assigned to an indirect tag by concatenating strings that represent its name.
For example IOTag1 will become active after this line is executed: IndirectTag.Name=
"IOTag"+Text(Index,"#"); {Index is an integer tag set to one}.

Recipe Manager and I/O Tags


The Recipe Manager allows InTouch programmers to load/save values into/from tags in a single
operation. I/O tags referenced in a recipe (under Unit Definition) do not become active when the
https://wdnresource.wonderware.com/support/kbcd/html/1/t001089.htm

1/3

8/23/13

Activating InTouch I/O Tags

recipe is used in a script function such as RecipeLoad(). It is then necessary to activate those
I/O tags beforehand.

SQL Access Manager and I/O Tags


SQL Access Manager allows InTouch programmers to access database management systems
such as MS SQL or Oracle. I/O Tags used in SQL Access Manager related script functions will
follow the activation rules described above for the different script types. Additionally, tags that
are referenced in BindLists and are not otherwise activated will become active when the BindList
is called from a script functions like SQLInsert() or SQLSelect().

SPC and I/O Tags


Tags used as the "Collection Tag" in SPCDatasets that are configured for auto-collection (based
on time or events) will become active when the SPC User that is associated with such datasets
is logged on via the SPCConnect() function. These collection tags will remain active even after
the SPCDisconnect() function is called.

Indirect Tags Triggering Activation of I/O Tags


A popular use of indirect tags is to process other tags inside a loop. Activation of I/O tags inside
such loops if the tags are not otherwise active present a challenge for InTouch programmers.
The typical problem with indirect tags being assigned to I/O and not getting the correct value
because the I/O tags don't get activated immediately. For example, the following quick
function loops through 10 I/O tags (tag1..tag10) to get the sum of their values
QuickFunction GetSum
{IndTag is an indirect analog; Tag1, Tag2, Tag3, Tag4, ......., Tag10
are I/O Real Tags }
DIM Tot AS INTEGER;
DIM i AS INTEGER;
Sum =0;
FOR i = 1 TO 10
IndTag.Name = "Tag" + Text(i, "#");
Sum = Sum + IndTag.Value;
NEXT;
Return Sum;
The problem with this loop is that if any of the tags (Tag1 through Tag10) being assigned to the
indirect tag is not active, the indirect tag will be have either the initial value or the tag value
from last time the tag was active.
Possible solutions:
- The trivial solution, and the one that Tech Support recommends, is to make sure that all tags
in the loop are active beforehand. The I/O tags could use an access name that has those tags
always active, or they could be activated by one of the other methods listed above. A simple
solution is to have a script or quick function that references the tags, even if the script never
executes. For example, write a QuickFunction that sets all tags to themselves or to zero (the
function won't be called so it will not execute).
If it is a requirement that tags be active only for the loop execution and inactive otherwise,
here are some other solutions:
https://wdnresource.wonderware.com/support/kbcd/html/1/t001089.htm

2/3

8/23/13

Activating InTouch I/O Tags

- Open a window that references the tags that are part of the loop before executing the code
in the loop (and allow time for the tags to read from I/O). If the Window script on Show is used,
the script will execute; if an Action script for a push button is used, the script won't execute
unless the button is clicked. In both cases, though, the tags will become active while the
window is open and will deactivate upon closing it.
- Control the loop in a time basis instead of using a For/Next loop. For example, a condition
script "While True every Xmsec" (where X is long enough to assure items are active).
- Add a delay from the time the indirect gets assigned to the time the indirect is used. For
example, set a flag (discrete tag) and create a while true script every Xmsec for that flag
(again with X long enough to make sure that the item is active); once the indirect is used then
reset the flag.
- Replace the For-Next loop and use a different logic based on the .ReferenceComplete dot field.
Two different Data Change scripts are required:
Data Change for "IndTag.ReferenceComplete":
IF IndTag.ReferenceComplete THEN
{Reference is complete means that the indirect has the value of
the I/O tag}
Sum = Sum + IndTag.Value;
{Now increment tag that controls loop or reset if exceeding the
limit of 10}
IF i < 10 THEN
i = i + 1;
ELSE
i = 0;
ENDIF;
ENDIF;
Data Change for i:
IF i > 0 THEN
{Change reference for indirect tag}
IndTag.Name = "Tag" + Text(i, "#");
ENDIF;
This code requires that "i" and "sum" are defined as tags and that Tag1 through Tag10 are not
otherwise active (if they are, the dot reference complete Data Change script will not execute).
F. Gonzalez / B. Good
Tech Notes are published occasionally by Wonderware Technical Support. Publisher: Invensys Systems, Inc.,
26561 Rancho Parkway South, Lake Forest, C A 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/t001089.htm

3/3

You might also like