Coordinating State Machines with Signal Events

Overview

Similarly to call events, which you learned about in the previous tutorial, signal events enable state machines to interact with each other. Signal events, however, are less direct: they trigger in response to a signal from another state machine instead of being called directly by that state machine. Additionally, these signals can only be sent in a Moxie simulation from within the delegate code. In this section, you will replace the ground station's call to shutdown the UAV with a signal event.

This section covers the following concepts:

public void sendShutDownSignal(UAV target) {
    mStateMachineRemoteControl.sendSignalEvent("Simulation::ShutDown", target);
}

Figure A1: Sending a signal event from a delegate

Prerequisites

Prerequisite Description
Moxie Installation You must have installed Moxie and have the prerequisites for developing delegates for Moxie.
Tutorial Project You must start this section with the UAV Mission simulation project and delegate module project from the previous section. If you did not complete the previous section, you can use the files from the Moxie installation: \documentation\tutorialFiles\03\LoggingAndDebugging, but you may still need to configure the delegate module for your environment.
Recommended Reading Before completing this section, you may want to read the following help topic:

Instructions

Replace the call event with the signal event

  1. Open the UAVMission.mdzip project from the previous section.
  2. In the Containment Tree, right-click the Simulation package and select Create Element (or press CtrlShiftE).
  3. Select Signal and enter ShutDown as its name.
  4. In the UAV State Machine diagram, double-click the transition going from the TransmittingData state to the final pseudostate.
  5. In the Trigger category, set the Event Type to SignalEvent.
  6. Set the Signal to ShutDown and click Close.

Replace the call with the signal

  1. In the System Definition (the BDD), select the GroundStation block, click the Create Element button () on the upper-right corner of the block, and select Operation.
  2. Enter sendShutDownSignal( target : UAV ) as the operation's name and parameter.
  3. Double-click the new operation, set the Visibility to private, and click Close.
  4. In the GroundStation State Machine diagram, double-click the transition going from the ReceivingSensorData state to the final pseudostate.
  5. In the Effect category, set the Body and Language to the string sendShutDownSignal(uav);, (optionally) add a line break before sendShutDownSignal(uav);, and click Close.

Add the supporting delegate code

You can use the StateMachineRemoteControl dependency from the analysis tool controller to send a signal to another state machine, triggering any signal events that expect that signal.

  1. In the GroundStationDelegate class, add the following import statement:
    import com.agi.moxie.api.StateMachineRemoteControl;
  2. Add the following private field:
    private StateMachineRemoteControl mStateMachineRemoteControl;
  3. Add the following dependency injection and field initialization in the constructor:
    public GroundStationDelegate( ...
            @InjectByName("stateMachineRemoteControl") StateMachineRemoteControl stateMachineRemoteControl,
             ... ) {
       mStateMachineRemoteControl = stateMachineRemoteControl;
        ...
    }
  4. Create the following public method:
    public void sendShutDownSignal(UAV target) {
        mStateMachineRemoteControl.sendSignalEvent("Simulation::ShutDown", target);
    }
  5. Save your work and re-install the delegate module.
  6. Run () the simulation and observe that the UAV still shuts down at the end of the simulation.

Next Section >