Introduction To Programming 13
Traversing the Command Tree
Figure 2-2 shows a portion of the subsystem command tree (you can see the complete tree in Figure 3-2). Note the location
of the ROOT node at the top of the tree. The SCPI interface is at this location when:
The power module is powered on.
A device clear (DCL) is sent to the power module.
The interface encounters a message terminator.
The interface encounters a root specifier.
Figure 2-2. Partial Command Tree
Active Header Path
In order to properly traverse the command tree, you must understand the concept of the active header path. When the power
module is turned on (or under any of the other conditions listed above), the active path is at the root. That means the
interface is ready to accept any command at the root level, such as OUTPUT or STATUS in Figure 2-2. Note that you do not
have to proceed either command with a colon; there is an implied colon in front of every root-level command.
If you enter OUTPUT, the active header path moves one colon to the right. The interface is now ready to accept :STATE,
:PROTECTION, or :RELAY as the next header. Note that you must include the colon, because it is required between headers.
If you now enter :PROTECTION, the active path again moves one colon to the right. The interface is now ready to accept
either :CLEAR or :DELAY as the next header.
If you now enter :CLEAR, you have reached the end of the command string. The active header path remains at :CLEAR. If
you wished, you could have entered :CLEAR; DELAY 20 and it would be accepted. The entire message would be
OUTPUT:PROTECTION:CLEAR;DELAY 20. The message terminator after DELAY 20 returns the path to the root.
The Effect of Optional Headers
If a command includes optional headers, the interface assumes they are there. For example, if you enter OUTPUT OFF, the
interface recognizes it as OUTPUT: STATE OFF (see Figure 2-2). This returns the active path to the root (:OUTPUT). But if
you enter OUTPUT: STATE OFF, then the active path remains at :STATE. This allows you to send OUTPUT: STATE OFF;
PROTECTION: CLEAR in one message. If you tried to send OUTPUT OFF;PROTECTION:CLEAR, the header path would return
to :OUTPUT instead of :PROTECTION.