Aconditionally executed referenced model, orconditional model, allows you to control its execution with an external signal. The external signal, called the控制信号, is attached to thecontrol input port. Conditional models are useful when you create complex model hierarchies that contain components whose execution depends on other components.
You can set up referenced models to execute conditionally, similar to conditional subsystems. For information about conditional subsystems, seeConditionally Executed Subsystems Overview.
金宝app®software supports these conditional model types:
Conditional Model | Description |
---|---|
Enabled | An enable port executes a referenced model at each simulation step for which the control signal has a positive value. To add an enable port to aModelblock, insert anEnableblock in the referenced model. This image displays the contents of a simple enabled referenced model. For an example of an enabledsubsystem, seeEnabled Subsystems. A corresponding enabled referenced model uses the same blocks as are in the enabled subsystem. |
Triggered | A trigger port executes a referenced model each time a trigger event occurs. To add a trigger port to aModelblock, insert aTriggerblock in the referenced model. This image displays the contents of a simple triggered referenced model. For an example of a triggered model, seeIntroduction to Managing Data with Model Reference. |
Triggered and Enabled | AModelblock can have both trigger and enable ports. If the enable control signal has a positive value at the time step for which a trigger event occurs, a triggered and enabled model executes once. |
函数调用 | A function-call port executes a referenced model each time a function-call event occurs. To add a function-call port to aModelblock, insert aTriggerblock in the referenced model. Then, open the Block Parameters dialog box and set theTrigger typeto A Stateflow®chart, a函数调用Generatorblock, aHit Crossingblock, or an appropriately configured custom S-function can provide function-call events. SeeUsing Function-Call Subsystems. This image displays the contents of a simple function-call referenced model. For an example of a function-call model, seeModel Reference Function-Call. |
Conditional models must meet the requirements for:
Conditional subsystems (seeConditionally Executed Subsystems and Models)
Referenced models (seeReference Existing Models)
Conditional models must also meet the requirements specific to each type of conditional model.
Conditional Model | Requirements |
---|---|
Enabled |
|
Triggered | Signal attributes of the trigger port in the referenced model must be consistent with the input that theModelblock provides to that trigger port. |
Triggered and Enabled | See requirements for triggered models and enabled models. |
函数调用 |
|
At the root level of the referenced model, insert one of the following blocks:
Type of Model | Blocks to Insert |
---|---|
Enabled |
|
Triggered |
|
Triggered and Enabled |
Trigger and Enable |
函数调用 |
Trigger |
For an enabled model, go to Step 3.
For theTriggerblock, set theTrigger typeparameter:
Type of Model | Trigger Type Parameter Setting |
---|---|
Triggered Triggered and enabled |
One of the following:
|
函数调用 |
|
Use theModelblock ports to connect the referenced model to other ports in the parent model.
的顶部Modelblock displays an icon that corresponds to the control signal type expected by the referenced model. For a triggered model, the top of theModelblock displays this icon.