Device-Channels and Device-Channel Arrays
As the name implies, a device-channel (DEVCHAN) is a combination of a device and a channel. It is represented internally as a DEVCHAN structure.
This structure combines the fields of a DEV structure representing the device with a field representing the channel number.
Syntax
The first component of a device-channel pair represents the device number, port, and system can be specified as either a single device number, a constant DEV structure or as a D:P:S specification (see explanation under Devices). Each device specified in a device-channel pair should be defined in the DEFINE_DEVICE section.
Channels are expressed as integer constants. A DEVCHAN is declared in the DEFINE_VARIABLE or DEFINE_CONSTANT section.
For example, "[128, 1]", "[ CONSTANTDPS, 9]" and "[128:1:0, 5]" are all valid representations
of device-channel pairs.
A DEVCHAN enclosed within square brackets implies an evaluation, whereas a DEVCHAN enclosed within curly braces does not, as illustrated below:
An array of DEVCHANs, a DEVCHAN array, is declared in the DEFINE_VARIABLE or DEFINE_CONSTANT section in one of two ways:
-
Declare a DEVCHAN array whose maximum length is determined by the number of elements in the initialization array on the right-hand side, as shown below:
-
Use
MAXLENto specify the maximum length of the array, as shown below:
In either case, the number of elements in the initialization array determines the effective length
of the array. That value can be determined at run-time by calling LENGTH_ARRAY.
The maximum length available for a DEVCHAN[] array can be determined by calling
MAX_LENGTH_ARRAY.
The individual elements of a DEVCHAN array can be referenced by their defined names (Dev1, Chan1, Dev2, Chan2, etc.) or alternatively, by using array notation with the device-channel array name.
For example, the third element in the device-channel array, MyDCSet would be referenced by
MyDCSet[3].
Furthermore, since a DEVCHAN array is an array of DEVCHAN structures,
DEVCHAN members can be referenced using the dot Operator notation such as
MyDCSet[3].Device or MyDCSet[1].Channel.
A DEVCHAN array can be used anywhere a [Device, Channel] specification is required
with the result of providing a range of targets for the command or instruction where it is used.
This implies an alternate form for the following commands:
Button[(DEVCHAN)]DO_PUSH[(DEVCHAN)]DO_RELEASE[(DEVCHAN)]OFF[(DEVCHAN)]ON[(DEVCHAN)]PULSE[(DEVCHAN)]PUSH[(DEVCHAN)]RELEASE[(DEVCHAN)]TO[(DEVCHAN)]
The index of the last member of the array for which an event notification was triggered can be
determined by calling Get_Last(MyDCSet). This is useful for determining which device and channel
in an array is referenced to in a particular notification message.