XControl:Abilities:Facade Ability VI

From LabVIEW Wiki
Jump to: navigation, search
The Facade VI is the running heart and display of any XControl. It decides on which events applied to the XControl should be reacted to in which ways. The front panel of the Facade VI is shown in the owning VI as the control look.
Example XControl Facade VI showing the Timeout frame

Facade Ability VI Data

The Facade Ability VI has several data in- and outputs to fit in the XControl framework. Changing the names (labels) of these data in- and outputs will break the XControl.

Facade Ability data in- and outputs
Name Description Type
Data In Returns last saved value of 'Data Out' Control
Data Out Outputs the value for use inside the containing VI Indicator
Display State In Holds internal data of the XControl Control
Display State Out Placeholder for internal data Indicator
Container State Holds information about the XControl for use inside the XControl Control
Container State.Indicator? Returns True if the XControl is an indicator NA
Container State.Runmode? Returns True if the VI containing the XControl is in Runmode. NA
Container State.Refnum Reference to the control representing the XControl NA
Action Contains commands for LabVIEW about the current XControl event session Indicator
Action.DataChanged? If this boolean is true LabVIEW will save te 'Data Out' value, if false the value will revert to 'Data In' NA
Action.StateChanged? If this boolean is true LabVIEW will save te 'Display State Out' value, if false the value will revert to 'Display State In' NA
Action.Action Name Can be used to track changes made by XControls for undo for instance NA

Facade Ability VI Events

The Facade VI contains an event structure inside a while loop. To be useable inside the XControl framework the VI has to be terminated after each event. To enforce this LabVIEW's template XControl has a timeout of 0 ms which finishes the while loop, the XControl can be ended in any of the event cases.

Special Facade Ability VI events
Event Name Function Called if

Data Change

To keep the representation of the XControl up to date with the data of the XControl On load of the XControl, if a new value to the terminal/local variable/'value' property is written or the 'value (sgl)' property is called

Display State Change

To communicate between XControl parts The XControl is loaded into memory, a custom property or method is used

Direction Change

To inform the XControl of the 'gender' of it's terminal The terminal of the XControl is converted from Control to indicator and visa versa. On initial drop of the XControl, or load into memory

Exec State Change

To inform the XControl of the mode of it's owning VI If the owning VI is started or stopped. If the owning VI is loaded into memory.
Remark: If the VI is in run-mode (ctrl-m), this event is not called when the VI starts/stops, but when it enters/leaves the run-mode.

Facade VI tricks

  • To resize an XControl from within the XControl the following code must be used:

XControl.Bounds.PNG

  • To gain control over the owning VI the property Container State.Refnum:Owning VI can be used, for instance to change the current cursor icon of the owning VI.
  • Make a difference between run-time and edit-time. This allows for setting properties via a context menu for the developer while the user can't access these settings.
  • Remember to update the Action control to store changes in the Data or State value
  • XControls will generate user events (mouse/key) when the XControl is disabled in the owning VI so you might need to check for this