主要内容

变体源

使用Variants的多个输入之间的路由

  • Library:
  • 金宝appSimulink /信号路由

  • 变体源块

描述

变体源块具有一个或多个输入端口和一个输出端口。您可以将变体选项定义为连接到输入端口的块,以便最多一个选择是活动的。

Each input port is associated with a Variant control. The Variant control that evaluates to真的, determines which input port is active.

当。。。的时候变体激活时间块对话框中的选项设置为更新图,然后在模拟simulink期间金宝app®connects the active choice directly to the output port of the变体源阻止并忽略非活动选择。

Note

Sample time for single input变体源blocks can differ with multiple input变体源blocks. For more information on sample time, see什么是样本时间?

港口

输入

展开全部

输入端口与第一变体控制相关联。评估的变体控制真的, determines which input port is active.

数据类型:单身的|双倍的|一半|INT8.|INT16|INT32.|INT64.|uint8.|uint16|UINT32.|UINT64|布尔|固定点|枚举|公共汽车

输入端口与第n个变体控制相关联。评估的变体控制真的, determines which input port is active.

数据类型:单身的|双倍的|一半|INT8.|INT16|INT32.|INT64.|uint8.|uint16|UINT32.|UINT64|布尔|固定点|枚举|公共汽车

Output

展开全部

来自主动变体的输出信号。

数据类型:单身的|双倍的|一半|INT8.|INT16|INT32.|INT64.|uint8.|uint16|UINT32.|UINT64|布尔|固定点|枚举|公共汽车

Parameters

展开全部

  • 表达— To choose the active Variant based on the evaluation of the Variant conditions, use表达模式。必须在全局工作区或数据字典中创建变体条件中使用的变体控制变量。

  • 标签- 根据您指定的变体的名称选择活动变量标签模式有效选择parameter, uselabel模式。Inlabel模式,变体控制是字符串,不需要在任何工作区中创建。

    当你选择label模式,变体徽章表示更改。

    Note

    当你推广时标签模式有效选择参数到a mask,变体控制模式被禁用。

    • 如果块是表达mode while promoting the标签模式有效选择参数到掩码,您可以更改变体控制模式labelby changing the promoted标签模式有效选择来自掩码对话框的参数。

    • 如果块是labelmode while promoting the标签模式有效选择参数到a mask, you cannot change the变体控制模式表达模式。

    有关向掩码推广参数的信息,请参阅促进参数到掩码

  • SIM Codegen切换- 自动在模拟和代码生成工作流程之间切换,使用SIM Codegen切换模式。When you simulate (Normal , Accelerator, Rapid Accelerator) a model, then Simulink automatically chooses thesimbranch as the active choice. Similarly, when you do a Software-in-the-loop (SIL), Processor-In-Loop (PIL) simulation or generate code or use external mode, Simulink automatically chooses theCodegen.分支。

将此参数设置为不同的值时,变体徽章更改如图所示Variant Badges

依赖性

变体激活时间参数仅在您设置时可用变体控制模式参数到表达要么SIM Codegen切换

此参数确定Simulink是否设置了A的活动选择金宝app变体源更新图或代码编译期间的块。该参数还确定哪些可变性包含在生成的eRT目标代码中。如果您选择包含所有变体选项,则在生成的代码中包含C选项在C预处理器条件语句(#if和#endif)中。

When you set this parameter to different values, the variant badge changes as shown inVariant Badges

You can set the变体激活时间parameter as:

  • 更新图- 金宝app Simulink在信号属性传播之前在更新图中设置活动选择。在传播信号属性之前删除非活动选择,因此生成的代码仅包含活动选择。

  • 更新图analyze all choices— Simulink sets the active choice during update diagram after the propagation of signal attributes. Signal attributes are propagated to both active and inactive choices. All choices are analyzed to ensure consistency of all variant branches between the results of simulation and code generation. Inactive choices are removed at the end of update diagram before model start occurs. The generated code contains only active choices. This workflow remains the same for simulation and code generation.

  • 代码编译— For simulation, the workflow is same as the更新图analyze all choices。但是,在代码生成期间不会删除非活动选择。生成的代码包含活动和非活动选项,选择选项在C预处理器条件语句中,#if#万一

  • startup— When you execute the model, both active and inactive choices are analyzed for consistency across the model and the choices participate in the simulation and the code generation workflow. With this option, you can improve the speed of iterative simulations using fast restart. For more information, see重启有多快速提高迭代模拟。从模型生成的代码包含常规附带的活动和非活动选项ifconditions. The executable that you build from the generated code also contains both active and inactive choices.

此图显示了在此参数中指定的不同值的变体激活时间。

有关更多信息,请参阅Represent Variant Source and Sink Blocks in Generated Code(嵌入式编码器)

依赖性

不同变体激活时间的可用性取决于您指定的变体控制模式的类型。这变体激活时间参数确定Simulink设置活动选择时的时间框。金宝app该参数还确定生成的代码中包含哪些可变性。该表介绍了每个变体控制模式支持的变体激活时间。金宝app

变体激活时间
变体控制模式 更新图 更新图analyze all choices 代码编译 startup
表达
label x x x
SIM Codegen切换 x x

Programmatic Use

Block Parameter:variantactivationtime
Type:字符向量
价值观:更新图|更新图analyze all choices|代码编译
Default:更新图

连接到一个变体选择的输入端口的数量变体源堵塞。此值是只读的。

点击到add a port or到delete an existing one.

Displays the Variant controls available in the global workspace. The Variant control can be a Boolean condition expression or a金宝appsimulink.variant.代表布尔条件表达式的对象。如果要为模型生成代码,则必须将控制变量定义为Simulink.Parameter对象。

To enter non-numeric Variant control values, use enumerated data. For information about using enumerated data, seeUse Enumerated Data in Simulink Models

To edit a Variant name, double-click a变体控制表达细胞和类型在变型控制表达式中。点击Applyafter you edit a Variant control name. If you add or delete a Variant control without applying the changes, the previous edits on the Variant control name are lost.

变体控制评估到真的确定必须活动的输入端口。

Programmatic Use

Block Parameter:VariantControls
Type:特区字符向量阵列
Value:与变体选择相关的变体控制
Default:'变体'

Displays theConditionfor the Variant controls that are金宝appsimulink.variant.对象。创建或更改变体条件金宝appsimulink.variant.参数对话框或全局工作空间。

有关更多信息,请参阅Create Variant Controls Programmatically金宝appsimulink.variant.

当你选择变体控制模式as标签,标签模式有效选择option is available. You can select an active Variant choice from标签模式有效选择options. You can also right-click the badge on the变体源块并选择标签模式有效选择

标签模式有效选择下拉列表显示当前在全局工作空间或数据字典中定义的所有变体控件。使用有效的matlab.®identifiers to specify Variant controls. For more information, see金宝appsimulink.variant.

Note

标签模式有效选择选项不可用Expression模式。

依赖性

To enable this parameter, select标签模式。

Programmatic Use

Block Parameter:LabelModeactiveChoice.
Type:字符向量
Value:指定的变体c在trol expression.
Default:选择_1.

To simulate a model (containing a Variant block) without an active Variant choice, select the允许零主动变体控制option. When this option is selected and there is no active Variant choice, Simulink disables all the blocks connected to the input and output stream of变体源堵塞。从更新图或仿真中忽略已删除的块。

如果您未选择此选项,则在没有活动的变体选择时,Simulink会生成金宝app错误。

选择此选项时,Variant Badge表示更改。

依赖性

Expression选择变体控制模式被选中。

Programmatic Use

Block Parameter:allowzerovariantControls.
Type:字符向量
价值观:'离开'|'on'
Default:'离开'

选择此选项时,Simulink会注释每个变体控制(条件表达金宝app式)变体源块端口。

Programmatic Use

Block Parameter:ShowConditionOnBlock
Type:字符向量
Value:'离开'|'on'
Default:'离开'

块特征

数据类型

布尔|公共汽车|双倍的|枚举|固定点|一半|整数|单身的|细绳

直接喂养

多维信号

可变尺寸信号

Zero-Crossing Detection

扩展能力

C / C ++代码生成
使用Simulink®Coder™生成C和C ++代码。金宝app

Fixed-Point Conversion
使用固定点设计器™设计和模拟定点系统。

Introduced in R2016a