IWS
tags can consist of a single value or an array of values.
Note: The
maximum array size is 16384 as long as it does not exceed the
maximum number of tags supported by the license (Product Type)
selected for the project. Each array position (including the
position 0) counts as one tag for licensing restrictions, because
each position has an independent value.
An array tag is a set of tags with the same name,
which is identified by indexes (a matrix of
n lines and 1
column). The maximum array size depends on the product
specification. You can use the following syntax to access an array
tag:
ArrayTagName[ArrayIndex]
For example: tank[0],
tank[1], tank[2], and tank[500].
CAUTION:
You must specify a maximum index for each
array tag in the size column of
any datasheet. You can specify n to indicate the array tag has
positions from 0 to n. For
example, if the size of TagA is 3, the tag elements could be
TagA[0], TagA[1], TagA[2],
and TagA[3].
Use the array tag whenever possible because it
optimizes memory use and simplifies the configuration task. For
example, if you want a display to monitor each tank, you could use
array tags to configure a single display containing tags linked to
any tank. For example (using the tk
tag as an index containing the number of the tank): pressure[tk], temperature[tk], and temperature[tk+1].
An array index can be a tag, a numeric value, or an
expression with the arithmetic operator "+".
Note: When
you refer to an array with an index using the
+ arithmetic operation, you must use the
following syntax:
ArrayTagName[NumValue1+NumValue2]
Where NumValue1 and NumValue2 can
be an integer tag or a numerical constant. For example:
temperature[tk+2] or temperature[tk+6].
Using array tags in any
IWS task can save a
signification amount of project development time. For example, if
you needed tag points related to the temperature of four tanks. The
conventional configuration method is the following:
- temperature1: high
temperature on tank 1
- temperature2: high
temperature on tank 2
- temperature3: high
temperature on tank 3
- temperature4: high
temperature on tank 4
Using array tags simplifies this task, as follows:
- temperature[j]: high
temperature on tank {j}
Note: When
you create a four-position array tag, the system creates five
positions (from 0 to 4). For example:
tag_example[15] //start position=0, end position=15
Therefore, the tag_example[15] array has 16 elements.
When using another tag to reference the index of an
array, if the value of the tag is outside the size of the array,
then the following results are given:
- If IndexTag is greater than the size of
the array, then MyArray[IndexTag] will point to the end
position of the array; and
- If IndexTag is less than 0, then
MyArray[IndexTag] will point to the start
position of the array.
Array Tags
An array tag consists of a set
of tags that all have the same name, but use unique array indexes
(a matrix of n lines and one
column) to differentiate between each tag. An array index can be a fixed value, another tag or an
expression. Maximum array sizes are determined by product
specifications.
You can use array tags to:
- Simplify configurations
- Enable multiplexing in screens, recipes, and
communication interfaces
- Save development time during tag declaration
You specify array tags in one of two formats:
Note:
- You must specify a maximum index for each array tag
by typing a value (n)
in the Array Size column of an Project Tags datasheet or in the Array
Size field on a New Tag
dialog. (See "Creating project database
Tags").
When you create an n-position array tag, IWS actually creates
n+1 positions (from 0 to
n). For example, if you specify
ArrayTag[15], the array will have
16 elements, where 0 is the start position and 15 is the end
position.
- You must not use spaces in an array tag.
When IWS reads a tag it begins with the first
character and continues until it finds the first space or null
character. Consequently, the system does not recognize any
characters following the space as part of the array tag.
For example, if you type a[second + 1], IWS regards a[second as the tag and considers it invalid
because IWS does
not find (recognize) the closing bracket. However, if you type
a[second+1], this is a valid array
tag.
You can specify an array tag wherever you would use a
variable name. Also, because array tags greatly simplify
configuration tasks and can save development time, we suggest using
them whenever possible.
For example, suppose you want to monitor the
temperature of four tanks. The conventional configuration method
is:
- temperature1 — high
temperature on tank 1
- temperature2 — high
temperature on tank 2
- temperature3 — high
temperature on tank 3
- temperature4 — high
temperature on tank 4
You can use array tags to simplify this task as
follows (where [
n] represents
the tank number):
- temperature[n] — high temperature on tank
[n]
The following table contains some additional
examples of an array tag:
Table 1. Array Tag Examples
Array Tag
Example |
Description |
Tank[1], Tank[2],
Tank[500] |
Simple arrays,
where the array indexes (1,
2, and 500) are numerical constants. For example, tank
numbers. |
Tank[tk]
|
A simple
array, where the array index (tk) is
a tag. For example, a tag representing the tank number. |
Tank[tk+1]
|
A complex
array, where the array index (tk+1)
is an expression. For example, the value of tk (tank number) plus 1. |
Note: When
using another tag to reference the index of an array, if the value
of the tag is outside the size of the array, then the following
results are given:
- If IndexTag is greater than the size of
the array, then MyArray[IndexTag] will point to the end
position of the array; and
- If IndexTag is less than 0, then
MyArray[IndexTag] will point to the start
position of the array (i.e., MyArray[0]).