Download Untitled
Transcript
Case structure's selector area. This is why the enum is used for the State Machine design patterns discussed in Chapter 8, "Design Patterns." Figure 6-8 shows an example of an instrument driver subVI that configures a digital multimeter. In Figure 6-8A, numeric controls are used to configure the Function and Manual Resolution parameters on the subVI's front panel. These parameters are programmed through terminals on the subVI's connector pane. The subVI call shown to the right uses numeric constants to configure these parameters. The value of 4 for Function is meaningless, and the value of 6.5 for Manual Resolution is risky. Specifically, the range of valid selections and the meaning of each selection is not very clear. In Figure 6-8B, text ring controls are used in place of the numeric controls. The subVI call contains text ring constants that were created from the terminals' context menus. These constants contain a discrete number of text labels that clearly describe each selection and limit the user to valid choices. Hence, the text rings are more functional, intuitive, and reliable than the numeric controls. Figure 6-8A. The front panel of an instrument driver subVI contains numeric controls for programming the measurement function and resolution. The subVI call uses numeric constants for specifying these values, which are not meaningful and prone to error. [View full size image] Figure 6-8B. The instrument driver subVI panel contains text ring controls instead of numeric controls. Constants created from the terminals' shortcut menus provide pull-down lists containing a discrete number of intuitively labeled choices. [View full size image] Rule 6.16 Use enums liberally throughout your applications The text selections for enums and rings form a very important source of documentation on the panel and diagram that is built into these controls. I recommend enums over rings for maximum readability, including the case selector text. However, there are a few exceptions where a ring control must be used over an enum. Use a ring control when the text labels map to nonsequential, negative, or fractional values, or if localization is an issue. Also, use a ring control 180