创建模块封装
自定义模块外观、用户界面和模块图
Simulink® 允许您创建模块封装。封装是用于模块的一种自定义用户界面。
通过封装模块,可以将模块图封装起来,使其拥有自己的参数对话框,以及自己的模块描述、参数提示和帮助文本。
您可以封装独立的自定义模块以作为独特模块重复使用,就像 Simulink 中定义的模块一样。
要了解如何创建模块封装,请参阅创建简单封装。
类
主题
封装简介
封装编辑器用户界面
- 封装编辑器概述
使用封装编辑器界面创建和自定义封装。 - 设计封装对话框
创建一个封装对话框。 - Handling Large Number of Mask Parameters
Add a large number of mask parameters in a table programmatically. - Customize Tables for Masked Blocks
Add custom tables to a mask dialog box. - Control Custom Table Programmatically
Use a programmatic interface to control custom tables. - 以编程方式控制封装
Simulink® 定义了一组有助于设置和编辑封装的 API。要从 MATLAB® 命令行设置和编辑封装,您可以使用Simulink.Mask
和Simulink.MaskParameter
类方法。也可以使用get_param
和set_param
函数来设置和编辑封装。但是,由于这些函数使用的分隔符不支持 Unicode®(非英文)字符,建议您使用Simulink.Mask
方法和Simulink.MaskParameter
类方法来控制封装。
封装功能
- Validating Mask Parameters Using Constraints
Add validation to mask parameters using constraints. - Custom Constraint for Mask Parameter
Validate input to mask parameters using custom constraints. - Share Parameter Constraints Across Multiple Block Masks
Create a parameter constraint and share it across masks of different blocks in the same model or different models. - Validate Input and Output Port Signals Using Port Constraints
Validate compile-time signal attributes on the input and output ports of a masked block by using port constraints. - Validate Port Signals Among Ports of the Same Masked Block
Validate cross port constraints to validate compile-time signal attributes among ports of the same masked block. - Share Port Constraints Across Multiple Masked Blocks
Create a port constraint and share it across masks of different blocks in the same model or different models. - Author Parameter and Port Constraints Using Standalone Constraint Manager
Manage multiple shared constraint files independently of a block context. - Promote Block Parameters on a Mask
Promote an underlying block or subsystem parameter to its mask. - 使用数据类型参数指定编辑参数的数据类型
您可以使用数据类型参数为封装编辑参数指定可接受的数据类型。为编辑参数关联数据类型可为通过封装对话框提供的输入值定义规则。您还可以使用数据类型参数来关联编辑参数的最小值和最大值。您可以使用数据类型参数进行定点分析。 - 将值传递给封装下的模块
使用封装对话框指定输入值。 - Mask Linked Blocks
Add a custom interface to linked blocks. - Approaches to Control Active Variant Choice of a Variant Block Using Mask or Model Workspace
Control the active choice of inline variant and Variant Subsystem blocks from a mask or a model workspace. - Define Measurement Units for Masked Blocks
Set measurement units for output and input ports of a masked block. - 在掩膜中添加图像
添加图像作为掩膜图标并将其保存在 SLX 文件中。 - Create Hierarchical List in Mask Dialog
Use the hierarchical list of data on a mask. - Tune Mask Enumeration Parameters - Popup and Radio Button
Reference an external enumeration file to assign numerical values to popup parameter. - Visualize and Plot N-Dimensional Data Using Mask Lookup Table Control
Look-Up Table control refers to a block or a set of blocks that use pre-defined data to map input values to output values. - Preserve Tunability of Parameters That Are Modified or Created in Mask Initialization
Preserve the tunability of mask parameters in generated code. - Reuse Mask Parameters and Dialog Controls Across Multiple Masked Blocks
Use the Mask Part Reference container of the Mask Editor to create and save the parameters and dialog controls in an XML file.
图形图标编辑器
- Graphical Icon Editor Overview
Graphical Icon Editor helps to create and edit mask block icon in a graphical environment. - Create and Edit Block Mask Icon
Create block mask icon using Graphical Icon Editor and Mask Drawing commands. - Add Dynamic Behavior to Masked Icons
Add dynamic behavior to masked icons using Graphical Icon Editor.
封装回调
- 封装初始化和参数回调代码简介
使用 MATLAB® 代码初始化模块封装。 - Author Mask Initialization and Callbacks
Write MATLAB code in the Mask Editor for mask initialization and callbacks. - Organize Mask Initialization and Callbacks in a MATLAB File
Organize mask initialization and mask callback code in a separate MATLAB® class file. - 动态封装对话框
为封装模块创建对话框,这些对话框的显示会根据用户输入而发生变化。 - 动态封装子系统
创建可以修改其结构性内容的封装库模块。 - Debug Masks That Use MATLAB Code
Troubleshoot errors in the mask initialization code.
系统封装
- Introduction to System Mask
Learn about masking a model. - 以编程方式控制封装
Simulink® 定义了一组有助于设置和编辑封装的 API。要从 MATLAB® 命令行设置和编辑封装,您可以使用Simulink.Mask
和Simulink.MaskParameter
类方法。也可以使用get_param
和set_param
函数来设置和编辑封装。但是,由于这些函数使用的分隔符不支持 Unicode®(非英文)字符,建议您使用Simulink.Mask
方法和Simulink.MaskParameter
类方法来控制封装。 - Create and Reference a Masked Model
Mask a model interactively. - Create and Display System Mask Programmatically
Apply a system mask to a model or a subsystem block diagram.
示例模型
- Masking Example Models
View Simulink models that demonstrate masking capabilities.