Action Port

Implement Action subsystems used in if and switch control flow statements

Library

Ports & Subsystems

Description

Action Port blocks implement action subsystems used in if and switch control flow statements. The If Action Subsystem and the Switch Case Action Subsystem blocks each contain an Action Port block.

Convert a Subsystem into an Action Subsystem

Use an Action Port block to convert a subsystem that has no control ports (such as an enable port, trigger port, or a function-call port) into an action subsystem.

  1. Open the subsystem you want to convert.

  2. Drag an If Action Subsystem or a Switch Case Action Subsystem block from the Ports & Subsystems library into your subsystem.

  3. Open the action subsystem and copy the Action Port block.

  4. Go up a level to your subsystem and paste the Action Port block.

  5. Delete the action subsystem you dragged into your model.

The subsystem icon in your model will change to include an Action port. The resulting action subsystem is atomic and executes in response to the conditional outputs of an If or Switch Case block. The diagram shows an if-else control flow statement using action subsystems connected to an If block.

When you connect an If or Switch Case block to an action subsystem, the action port label on the subsystem icon changes to match the output port of the driving block (i.e. if{ }, else{ }, elseif{ }, case{ }, or default{ }).

    Note:   All blocks in an action subsystem must run at the same rate as the driving If or Switch Case block, or should have their sample time set to -1 (inherited).

Data Type Support

Action Port blocks do not have data inputs or outputs.

Parameters and Dialog Box

States when execution is resumed

Specify how to handle internal states when a subsystem with an Action Port block reenables.

Settings

Default: held

held

When the subsystem reenables, retains the states of the Action subsystem with their previous values. Retains the previous values of states between calls even if calling other member Action subsystems of an if-else or switch control flow statement.

reset

Reinitializes the states of the Action subsystem to initial values when the subsystem reenables.

Reenablement of a subsystem occurs when called and the condition of the call is true after having been previously false. In the following example, the Action Port blocks for both Action subsystems A and B have the States when execution is resumed parameter set to reset.

If case[1] is true, call Action subsystem A. This result implies that the default condition is false. When later calling B for the default condition, its states are reset. In the same way, Action subsystem A states are reset when calling A right after calling Action subsystem B.

Repeated calls to the Action subsystem of a case does not reset its states. If calling A again right after a previous call to A, this action does not reset the states of A. This behavior is because the condition of case[1] was not previously false. The same applies to B.

Command-Line Information

Parameter: InitializeStates
Type: string
Value: 'held' | 'reset' |
Default: 'held'

Propagate sizes of variable-size signals

Specify when to propagate a variable-size signal.

Settings

Default: Only when execution is resumed

Only when execution is resumed

Propagates variable-size signals only when reenabling the subsystem containing the Action Port block.

During execution

Propagates variable-size signals at each time step.

Command-Line Information

Parameter: PropagateVarSize
Type: string
Value: 'Only when execution is resumed' | 'During execution'
Default: 'Only when execution is resumed'

Characteristics

Sample Time

Inherited from driving If or Switch Case block

See Also

If, If Action Subsystem, Switch Case, and Switch Case Action Subsystem blocks for examples using Action Port blocks

Was this topic helpful?