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.
- Open the project from the previous section.
-
In the PowerSystem State Machine diagram,
double-click the transition from the
PoweredOff
state to the choice pseudostate. - In the Trigger category, set the Event Type to CallEvent.
-
Set the Operation to
powerOn()
. -
(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. - Click .
Figure B1: The power system call event
Add an effect that calls the event
-
In the Computer State Machine diagram,
double-click the transition from
Standby
toPoweringOn
. - In the Effect category, set the Behavior Type to Opaque Behavior.
-
Set the Body and Language to the string
powerSystem.powerOn();
and click .
Create a choice that checks the result
-
Select Choice from the toolbar to the left of the canvas,
click the transition from
PoweringOn
toPoweredOn
, and then click either or . -
Double-click the transition from the choice pseudostate to the
PoweredOn
state, set the Guard to the stringpowerSystem.isPoweredOn
, and click . -
Select the choice pseudostate,
click the Transition button () on the context toolbar,
and then click the
Standby
state. -
Double-click the new transition,
set the Guard to the string
else
, and click .
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.
- In the Containment Tree, double-click the Simulation > simulation instance specification and select Slots from the left pane of the specification window.
-
In the center pane,
select the
roots
slot. -
In the right pane,
select
uav.powerSystem
, click the Remove button (), and then click . -
Run () the simulation
and observe that the power system does not exit the
PoweredOff
state until the computer triggers it to do so. - Save your work before continuing.
Next Section >