Coordinating State Machines with Call Events

Overview

In a complex mission simulation, the systems involved interact with one another as you carry out the mission objectives. So, in SysML, the state machines for those systems must interact with each other. You can achieve this in Moxie in two ways: call events and signal events. However, signal events in Moxie require using the delegate architecture, so you will not use them until the Signal Events section of the next tutorial. Call events enable state machines to invoke operations on their owning instance or on instances that their owning instance refers to. In this section, you will use a call event to have the computer turn on the power system instead of having the power system turn itself on at the start of the simulation.

This section covers the following concept:

Figure A1: A call event between state machines

Prerequisites

Prerequisite Description
Moxie Installation You must have installed Moxie.
Tutorial Project You must start this section with the Moxie simulation project from the previous section. If you did not complete the previous section, you can use the following project from the Moxie installation: \documentation\tutorialFiles\02\ModelValidation.mdzip
Recommended Reading Before completing this section, you may want to read the following help topic:

Instructions

Add a call event to the power system state machine

Recall that you created a powerOn() operation for the power system in the Properties and Operations section of the previous tutorial. This operation can now be used as a call event.

  1. Open the project from the previous section.
  2. In the PowerSystem State Machine diagram, double-click the transition from the PoweredOff state to the choice pseudostate.
  3. In the Trigger category, set the Event Type to CallEvent.
  4. Set the Operation to powerOn().
  5. (Optional) In the Effect Body and Language, add a line break before isPoweredOn = true;. This improves the readability of the transition in the state machine diagram.
  6. Click Close.

Figure B1: The power system call event

Add an effect that calls the event

  1. In the Computer State Machine diagram, double-click the transition from Standby to PoweringOn.
  2. In the Effect category, set the Behavior Type to Opaque Behavior.
  3. Set the Body and Language to the string powerSystem.powerOn(); and click Close.

Create a choice that checks the result

  1. Select Choice from the toolbar to the left of the canvas, click the transition from PoweringOn to PoweredOn, and then click either Before Transition or After Transition.
  2. Double-click the transition from the choice pseudostate to the PoweredOn state, set the Guard to the string powerSystem.isPoweredOn, and click Close.
  3. Select the choice pseudostate, click the Transition button () on the context toolbar, and then click the Standby state.
  4. Double-click the new transition, set the Guard to the string else, and click Close.

Figure B2: The computer state machine

Update the root instance specifications

Since the power system state machine is now dependent on the computer state machine, you should remove it from the simulation instance specification roots slot. Moxie will automatically start the power system state machine when it interrogates the uav.computer instance specification and finds uav.powerSystem as one of its dependencies.

  1. In the Containment Tree, double-click the Simulation > simulation instance specification and select Slots from the left pane of the specification window.
  2. In the center pane, select the roots slot.
  3. In the right pane, select uav.powerSystem, click the Remove button (), and then click Close.
  4. Run () the simulation and observe that the power system does not exit the PoweredOff state until the computer triggers it to do so.
  5. Save your work before continuing.

Next Section >