Download Untitled

Transcript
Figure 8-27C. This diagram contains the same functionality implemented with the Classic State Machine design pattern.
[View full size image]
In this example, it is noteworthy that there is a one-to-one correspondence between Boolean controls and application
states, with three exceptions: Initialize, Blank, and Idle, Default. Also, each state is called in response to a Boolean
control's value change. Therefore, this VI can be implemented more efficiently using an Event-Handling Loop, as shown
in Figure 8-27D. The Event structure is the most efficient method of processing user interface activity. Event cases
configured to respond to each Boolean control's Value Change event contain the code from the corresponding cases of
the Classic State Machine. The Idle, Default state that polls the Boolean controls within the Classic State Machine
is eliminated by the Event-Handling Loop's Event structure. The Initialize state containing an initialization routine
is replaced by the Event-Handling Loop's Timeout event case. Per Rule 8.8, continuous Timeout events are to be avoided.
In Figure 8-27D, a shift register is wired to the Event structure's Timeout terminal. The shift register is initialized
to 0, forcing the Timeout event to fire immediately. After the Timeout event case runs the initialization routine, the
shift register is set to –1, disabling the Timeout event. Hence, the Timeout event case functions similar to the Initialize
application state.
Figure 8-27D. The VI is implemented using the Event-Handling Loop design pattern. The states are replaced with event
cases corresponding to the Value Change event for each Boolean control. The Timeout event is used to perform an
initialization routine.
[View full size image]
289