The Facade ability defines the appearance of an XControl. The Facade ability is represented by the Facade VI. Because the XControl requires the Facade ability, LabVIEW automatically adds the Facade VI to the XControl library when you create an XControl. The Facade VI must be a reentrant VI.
You add LabVIEW controls and indicators to the Facade VI to create the front panel of the XControl. By default, the Facade VI includes data, display state, and container state controls and data, display state, and action indicators. These controls and indicators are hidden and are not part of the XControl appearance. Resize the front panel window to fit only the controls and indicators that make up the appearance of the XControl. Set the window appearance properties of the Facade VI to adjust the size and appearance of the XControl.
The block diagram of the Facade VI handles events for the front panel controls and the Facade VI itself. It contains a While Loop with an Event structure in it. The Facade VI is not a continuously running VI. LabVIEW calls the Facade VI only when there is an event pending for the VI to handle. LabVIEW calls the Facade VI with the current data, display state, and container state. The VI handles the event and returns the updated data, display state, and type of action performed.
Use the Container State cluster to provide information about the instance of the XControl. The Container State cluster includes three elements—Indicator?, Run Mode?, and Refnum. Use Indicator? to determine if the XControl instance is a control or indicator. Use Run Mode? to determine if the VI you are using the XControl in is running or idle. Run Mode? is set to TRUE when the owning VI is running. Refnum is a reference to the XControl instance that you use only to query information about the XControl. Do not use Refnum to modify the XControl instance from the Facade VI.
When the Facade VI changes the data or display state, it should update the Action cluster and inform LabVIEW of the changes. The Action cluster contains three elements—Data changed, State changed, and Action name. Set Data changed to TRUE when the Facade VI changes the Data Out indicator. Set State changed to TRUE when the Facade VI changes the Display State Out indicator. Optionally, use Action name to name the action being performed. This name appears when you select the Edit»Undo option. Typically, the Facade VI changes the data or display state in response to events generated on the front panel controls.
The Facade VI also responds to events generated in response to certain user interactions. These events include the Data Change, Display State Change, Direction Change, and Exec State Change events. The Facade VI must handle the Data Change and Display State Change events in order for the XControl to function properly. Handling the Direction Change and Exec State Change events is optional.
LabVIEW calls the Facade VI to handle these events. For example, when you copy an XControl, LabVIEW generates all four events and calls the Facade VI on the new instance of the XControl. LabVIEW also generates all four events and calls the Facade VI when you load the front panel of a VI that contains the XControl. When the VI that contains the XControl switches from edit Mode to run Mode, and vice versa, LabVIEW generates Exec State Change and calls the Facade VI to respond to the VI execution state change.
When you select Edit»Undo or Edit»Redo, LabVIEW also calls the Facade VI. LabVIEW reverts the display state of the XControl before any action by the Facade VI changes the state. The current display state takes the place of the previous state. LabVIEW generates a Display State Change event and calls the Facade VI to update the XControl after the Undo or Redo action.
Edit each event case to configure how the XControl responds to each event. To create XControls that respond quickly, configure the Facade VI to handle events and finish as quickly as possible. Do not use a Wait function to delay execution in the While Loop within the Event structure.
|Note You also can use the Facade VI to programmatically customize the shortcut menu for an XControl. You cannot use the Shortcut Menu Editor to customize the shortcut menu for an XControl.|