Reuse Mask Parameters and Dialog Controls Across Multiple Masked Blocks
This example shows how to create and save mask parameters and dialog controls in an XML file and reuse them across multiple masked blocks using the Mask Part Reference container in the Mask Editor.
Reusing mask parameters and dialog controls from an XML enables you to:
Reduce the effort in creating same parameters across multiple blocks.
Modify parameters and dialog controls easily by changing the XML file's contents from any instance of the block.
Propagate changes to the XML file and make it available across all the blocks referring to the file.
Override the default values of a parameter populated from the XML file. This default value is specific to the block instance and it will not override the values of the parameter in the XML file.
Explore the Model
The library contains three blocks Stereo mod
, Video mod
, and Stereo mod_diff_override_part_file_values
. The two blocks Stereo mod
, Video mod
shares few parameters in common. Instead of repeatedly creating the common parameters in individual blocks, use the Mask Part Reference container to save the common mask parameters and dialog controls in XML files main_mask_part_ref.xml
and impairment_mask_part_ref.xml
. The block Stereo mod_diff_override_part_file_values
overrides the default values of the mask parameters using the Mask Part Reference XML file main_mask_part_ref.xml
. The overridden default values are specific to the block Stereo mod_diff_override_part_file_values
.
open_system("slexMaskPartReferenceLib.slx")
Create Mask Parameters and Dialog Controls in an XML File Using Mask Part Reference Container
The XML files main_mask_part_ref.xml
and impairment_mask_part_ref.xml
contains common mask parameters and dialog controls that is reused across multiple masked blocks.
1. Open the mask editor of the Subsystem block Stereo mod
.
2. In the Mask Editor, from Container panel, create Tab container and add a Tab.
4. Create a Mask Part Reference container, MainPartRef
under the Tab container Main
.
5. Double-click the File Name property and click the plus sign in the dialog box to create a new XML file. Enter the File Name as main_mask_part_ref
and click Save.
Note: The Mask Part Reference XML files must be added to the MATLAB® path. These files can also be created inside a MATLAB package.
6. Create the necessary parameters, containers, and dialog controls in the required hierarchy inside the Mask Part Reference container MainPartRef
.
7. Create another Tab container Impairments
and create an another Mask Part Reference container Impairmentref
. Enter the File Name as impairment_mask_part_ref
as explained in step number 5.
8. Create the necessary parameters, containers, and dialog controls in the required hierarchy inside the Mask Part Reference container Impairmentref
.
9. Click Save Mask to save the mask as well as the contents of the Mask Part Reference containers to their respective XML files.
The mask parameters and dialog controls created inside the Mask Part Reference container are available to all the blocks that refer to the XML files.
Reuse Mask Parameters and Dialog Controls in a Masked Block
To reuse the mask parameters and dialog controls created in the XML files main_mask_part_ref.xml
and impairment_mask_part_ref.xml
in the Subsystem block Video mod
:
1. Open the mask editor of the Subsystem block Video mod
.
2. In the Mask Editor, from Container panel, create Tab container and a Tab.
3. Create a Mask Part Reference container, MainPartRef
under the Tab container Main
.
4. Double-click the File Name property and Browse for the file main_mask_part_ref.xml
in the dialog box. The contents of the XML file are populated in MainPartRef
.
5. Similarly, create another Tab container Impairments
and create an another Mask Part Reference container Impairmentref
.
6. Double-click the File Name property and browse for the file impairment_mask_part_ref.xml
in the dialog box. The contents of the XML file are populated in Impairmentref
.
7. Click Save Mask to save the mask.
Override Default Values of Mask Parameters Sourced from XML File
You can override the default values of mask parameters in Stereo mod_diff_override_part_file_values
coming from the XML file.
1. Follow the steps 1 to 6 from the previous section.
2. Select the Mask Part Reference container MainPartRef
.
3. In the Property Editor, double-click Instance Values.
4. In the dialog box, click the plus sign to select the mask parameter available in the Mask Part Reference container. Select the mask parameter input
and channelSelect
from Parameter Name and enter the default values as 10
and off
, respectively in Parameter Value. Click Save to save the block specific instance values.
5. Click Save Mask to save the mask.
When you open the mask dialog box of the block Stereo mod_diff_override_part_file_values
, the default values of the parameters input
and channelSelect
is set as 10
and off
, respectively. The default values of these parameters from the XML file main_mask_part_ref.xml
is overridden.