Operations

The operations of a block are procedures that the block performs in response to the operations being called. In Behavior Execution Engine simulations, you can use operations to trigger call events, execute a simple script, execute ModelCenter workflows, or perform more complicated custom actions through Java delegate code.

You can call an operation from any opaque expression, such as during a transition or during state entry or exit. Just like with opaque expressions, Behavior Execution Engine executes operations in zero simulation time, so if you want to model a delay associated with the operation, you should use a time event immediately before or after the operation.

Implementation

Behavior Execution Engine provides a few different ways for you to implement an operation:

  • You can skip the implementation and just use the operation to trigger call events.
  • You can use an explicit Java delegate implementation for the operation and its owning block to perform complicated custom actions. If you use partial auto-implementation, you can use the operation to trigger call events in addition to its explicit Java implementation. See the Developing Delegates topics for more details on creating and using delegate modules.
  • You can specify an opaque behavior as the Method of the operation to execute a simple script or a ModelCenter workflow. You can use the operation to trigger call events in addition to its opaque behavior implementation without having to configure anything else.
    1. In the Containment Tree, right-click the operation and select Create Method > Behavior > Opaque Behavior.
    2. Double-click the new opaque behavior to open its specification. Then set the Body and Language to your desired implementation:
      • To use a simple script to process the input parameters and return an output value, type the script into the cell. The default language is English, so for the body, use the same Java-like syntax as required by other opaque expressions. You can refer to the input parameters by their names, just like properties, and you can use multiple statements separated by semicolons. If the operation has a return type, the return value will be the result of the final statement.
      • If you have the ModelCenter MBSE plugin installed, you can click the ... button in the right corner of the cell and set the language to ModelCenter. You can then launch the Analysis Editor and use it to connect the operation's parameters and return values to a custom ModelCenter workflow. You can also use a ModelCenter script, but if you only need a simple script, you should use the previous option. ModelCenter MBSE only supports primitive value types (boolean, integer, double/real, and string) for parameters and return types, but it does support multiplicity for all of those types.
    3. In the left sidebar, select Parameters and make sure that all the parameters and return types that you need are specified.