Main Content

ParameterSetButton

Create real-time application parameter set button for instrument panel UI

Since R2024b

Description

hParameterSetButton = slrealtime.ui.control.ParameterSetButton(hFigure) creates a real-time application parameter set button for an instrument panel uifigure figure. This button opens a UI for working with parameter sets for a real-time application loaded on the target computer.

  • At run-time, the parameter set button is disabled if the target computer specified by the TargetSource property is disconnected or not loaded with a real-time application

  • The parameter set button is enabled when the real-time application is loaded on the target computer. The button tooltip specifies the real-time application and the target computer name.

  • Pressing the parameter set button at run-time launches the Parameter Sets dialog box for parameter set management.

For information about control properties, see slrealtime.ui Properties. It is important to set the TargetSource property for this control if you plan on using your app with target computers other than the default target computer.

example

Examples

collapse all

Create a real-time application parameter set button and adjust the position of the button.

  1. % Create figure 
    hFig = uifigure(); 
    % Create parameter set button component 
    hParamSet = slrealtime.ui.control.ParameterSetButton(hFig); 
    % Change position of the component 
    hParamSet.Position = [0 0 200 200]; 
    % Associate with default target 
    hParamSet.TargetSource = []; 
    % Customize 
    hParamSet.ParameterSetIcon = fullfile(pwd, 'paramset.png'); 
    hParamSet.ParameterSetText = 'PARAM SET';
  2. In this example, there are two parameter sets on the target computer associated with this real-time application, ParamSet2 and ParamSet3. The default parameter set is ParamSet2. This parameter set is automatically loaded each time the real-time application loads on the target computer. The current parameter set is the one that was last loaded. In this case, ParamSet2 has been loaded.

    These parameter sets are populated in the list when the pop-up dialog opens. The Update parameter set selection button updates the list. For example, if you created a new parameter set at the command line while this dialog was opened, the new parameter set does not appear in the list until you press the Update parameter set selection button or close and re-open the dialog. Initially, none of the parameter sets are selected.

    The Add parameter set button creates a new parameter set, for example newParamSet, by executing this function:

    saveParamSet(tg,'newParamSet');

    Add parameter set button opens the Parameter Sets dialog box

  3. The Edit parameter sets button opens the Parameter Explorer dialog for the selected parameter set. The parameter set pop-up dialog is blocked by a progress bar until the parameter explorer is closed.

    Edit parameter sets button opens the Parameter Explorer window

  4. The Copy parameter set button copies the selected parameter set by executing a copy command on the target computer. Then, the parameter sets dialog box immediately selects the newly created parameter set.

    Copy parameter set button opens the parameter set name dialog box

  5. The Parameter set load button prompts the user to select a real-time application MLDATX file to load.

    The selected parameter set is imported from the target computer to the development computer and then added to the chosen MLDATX file by executing addParamSet(appObj,paramSetObj). If you re-install the application on the target computer, this imported parameter set is available because it was saved with the MLDATX file. Any other parameter set created on the target computer and not saved to the MLDATX file is deleted (and is no longer available) when the application is re-installed.

    The Set parameter set default button makes the selected parameter set the default parameter set. The parameter set is loaded whenever the real-time application loads on the target computer.

    The Clear parameter set default button clears the default parameter set but leaves the parameter set unchanged and available on the target computer.

    The Delete parameter set button deletes the selected parameter set by executing deleteParamSet(tg,file). You are prompted to confirm the deletion.

  6. The Load parameter set button loads a parameter set by executing loadParamSet(tg,name). The parameter set dialog is blocked until the loadParamSet() command completes. Notice the current parameter set is updated when loading a new parameter set. In this case, ParamSet3 is loaded when the Load Parameter Set button is clicked.

    Load parameter set button loads the selected parameter set

Adding a parameter set button in App Designer requires that you write some MATLAB code to set the TargetSource property. App Generator supports automatically adding a parameter set button to a generated app with all of the necessary MATLAB code. By default, generated apps do not contain a parameter set button.

You can add a parameter set button to the generated app by using the App Generator Options menu.

Enable parameter set button in App Generator

Input Arguments

collapse all

The hFigure argument identifies the uifigure to which you are adding the UI component.

Example: hFig = uifigure()

Data Types: function_handle

Output Arguments

collapse all

The hStartStopButton argument is the handle to the start-stop button component that you create.

Version History

Introduced in R2024b