Section 7: Command reference
Models 707B and 708B Switching Matrix Reference Manual
7-34
707B-901-01 Rev. A / August 2010
channel.getstate()
Queries the state indicators of the channels in the instrument.
Type
TSP-Link accessible
Affected by
Where saved
Default value
Function Yes
System
reset
Channel reset
Not saved
0
Usage
state = channel.getstate(channelList)
state = channel.getstate(channelList, indicatorMask)
state
Return string listing the comma-delimited states for the channels in
channelList
channelList
String specifying the channels to query, using normal channel list syntax
indicatorMask
Value to specify only certain indicators; if omitted, all indicators are returned
Details
Each bit in the
state
represents a different indicator. Therefore, multiple indicators can be present (the OR
operation is performed bitwise). The optional state
indicatorMask
can be used to return only certain
indicators. If there is no
indicatorMask
, then all indicators are returned.
Indicators can be latched or unlatched, depending on other system settings. Latched indicators mean that the
condition has occurred since the last reset command (or power cycle). Unlatched indicators mean that the
condition has occurred when the
channel.getstate()
command was issued.
Although the
channel.getstate()
command returns a string representing a number, this can be easily
changed to a number and then compared to one of the provided Lua constants.
The only state information is an indicator of relay state (
channel.IND_CLOSED
).
Example
print(channel.getstate("4A01:4B08"))
channel.pattern.setimage("1A01,2B02,3C03",
"Path")
print(channel.getstate("Path"))
print(channel.getstate("3C03"))
-- Unmasking the return value must be done
-- one channel at a time.
if bit.bitand(channel.IND_CLOSED,
tonumber(channel.getstate("4A10"))) == 1
then
print("CLOSED")
else
print("OPENED")
end
Queries the state of the first 20 channels on
Slot 4.
See the state of channels in channel pattern
called
"PathList"
.
The
channel.IND_CLOSED
command equates
to the number 1. Because the state is a bit-
oriented value, you must perform a logical AND
operation on the state to the overload constant to
isolate it from other indicators.
The
tonumber()
command only works with a
single channel. When multiple channels are
returned (for example,
channel.getstate("slot4")
), this string
must be parsed by the comma delimiter to find
each value.
Also see
(on page 7-27)