バリアントの構造
モデル内の構造のバリエーションに対応するコードを生成および管理する
Simulink® のバリアント ブロックを使用すると、コンポーネントのすべての設計バリエーションを 1 つのモデルで表現できます。設計の各選択肢は、単一レイヤーまたは個別の階層内のバリアントの選択肢としてモデルに組み込まれます。このようなモデルには、共通の固定構造と、選択したバリアント制御に応じてアクティブまたは非アクティブになるバリアント選択肢の有限のセットが含まれます。詳細については、バリアントとは、およびどのような場合にそれを使用するかを参照してください。バリアントのアクティベーションのタイミングによって、選択肢をいつアクティブにするかと、生成されたコードにアクティブな選択肢のみを含めるか、アクティブな選択肢と非アクティブな選択肢の両方を含めるかが決まります。アクティベーションのタイミングについては、Activate Variant During Different Stages of Simulation and Code Generation Workflowを参照してください。
トピック
コードの生成
- Generate Code for Variant Subsystem Blocks
Generate code for specific implementation of component represented using Variant Subsystem block. - Generate Code for Variant Source and Variant Sink Blocks
Generate code for specific implementation of component represented using Variant Source and Variant Sink blocks. - Generate Code for Model References Connected to Variant Blocks
Reuse and incrementally load, build, and generate code for multiple variations of a component.
バリアント ブロックのインターフェイス
- Conditionalize Export Function Calls in Code using Variant Blocks
Generate code for export function calls conditionally using variant blocks.
最適化されたコードによるコードの信頼性と安全性の最大化
- Compile Code Conditionally for Variations of Component Represented Using Variant Block
Conditionally compile code for different implementations of a component using variant blocks. - Run Executables for Variant Blocks Without Recompiling Code for Changing Active Choices
Switch between multiple component implementations without the need for recompilation. - Generate Code from Nested Variant Subsystem with Code Compile and Startup Activation
This example illustrates howcode compile
andstartup
variant activation time can be used together in two nested variant subsystems. - Propagate Variant Conditions Outside of Variant Subsystem Blocks to Promote Consistency and Reduce Errors in Generated Code
Synchronize variant conditions across components to minimize manual errors and ensure interface consistency. - Remove Inactive Variant Components from Generated Code at Compile Time When No Active Choices Exist
Exclude inactive variant components from generated code at compile time.
バリアントの制御と管理
- Organize Variant Control Macros in Same Header File
Aggregate variant control macros into a single header file using custom storage classes. - Represent Variant Conditions of Enumerated Type in Generated Code
Represent variant control variables meaningfully in the generated code by using enumerated types. - Generate Code for Variant Elements Within Buses
Generate code for buses with elements having different variant conditions. - Use Simulink.Parameter Type of Variant Control Variables for Code Generation in Variant Blocks
If you intend to generate code for a model containing variant blocks, specify variant control variables as
objects. TheSimulink.Parameter
Simulink.Parameter
objects allow you to specify other attributes, such as data type and storage class, and control the appearance and placement of variant control variables in generated code.