The ATO Federation

The Portico Subversion repository is intended to contain a small collection of federations and tools that can provide a test bed and act as examples that users can draw on. This repository of federations will be used for some extended form of functional testing, in addition to things like performance testing.

One federation that resided in the library is the ATO Federation, which is discussed here. This federation makes use of the Middlesim library rather than being pure HLA.

Background
The "Air Transport Operations" federation was designed many moons ago to be part of a HLA teaching course delivered at the University of Ballarat. A while ago, I decided to rewrite a slightly simpler version of it using Middlesim. To show it off a little, created a nice graphical client. This article will show you how to get a hold of the code and get it running.

Overview
The ATO federation basically involves aircraft flying from one airport to another. There are two main object classes:  and. The  class provides   and   attribute values that are inherent to both types. An Aircraft has a number of states as listed below:


 * TURNAROUND: The aircraft is currently waiting for a new destination (usually this wait is an uber-realistic 60 seconds)
 * AWAITING_DEPARTURE: The aircraft has a new destination and is waiting to take off.
 * TAKING_OFF: The aircraft is taking off. Just hard-coded to take 60 seconds.
 * CRUISING: In the air and moving towards its target
 * LOITERING: Suspended in mid-air (literally, it just hangs there)
 * LANDING: Has been given the go ahead to land and is on its way down. As with take off, this is hard-coded to take 60 seconds.
 * LANDED: On the ground and off the runway. After this it will go back into TURNAROUND.

Transition between these states is triggered via various interactions. My implementation of the simulation involves five main federates:


 * Aircraft Manager (acm): Creates and alters the attributes of all the Aircraft. Many of these are changes are triggered by interactions sent by other federates.
 * Air Traffic Control (atc): Creates all the airports and controls when Aircraft can take off and land at those airports.
 * Fleet Manager (fm): Tells the Aircraft where to go when they've finished their turnaround. In the main spec it would also put an Aircraft in for maintenance every now and then, but again, time wasn't on my side.
 * Execution Manager (em): Not part of the initial federation, but I put it in to control the execution lifecycle of the other federates.
 * GUI Federate (gui): Just listens to what is going on and displays a little 2D radar-type view of what it happening. This federate is optional.

Getting the Code
First things first, before you can run these federates you will need to have downloaded and installed Portico. After that, you will need to get the code from Subversion. At the moment, this is the only way to access the code. Assuming you are using a *nix of some description, you'll have something like:

[tim@moby tmp]$ svn checkout https://portico.svn.sourceforge.net/svnroot/portico/fedlibrary ... ... [tim@moby tmp]$ cd fedlibrary/ato/ [tim@moby ato]$ ./ant sandbox Buildfile: build.xml

init: [echo] Building ato

_compile.init: [echo] Compiling source code... [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/build [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/build/classes [echo] JAVA VERSION: 1.5.0_06 [echo] debug / debug level: true / lines,vars,source [echo] source compat: 1.5

_compile.production: [javac] Compiling 49 source files to /Users/tim/Documents/workspace/fedlibrary/ato/build/classes

_compile.tests: [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/build/test [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/build/test/classes

_compile: [echo] Source code compile over

compile:

_sandbox.init: [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/dist [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0

_sandbox.binary: [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/lib [copy] Copying 4 files to /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/lib [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/etc [copy] Copying 8 files to /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/etc [copy] Copied 1 empty directory to 1 empty directory under /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/etc [copy] Copying 50 files to /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/etc [mkdir] Created dir: /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/bin [copy] Copying 10 files to /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/bin

_sandbox: [jar] Building jar: /Users/tim/Documents/workspace/fedlibrary/ato/dist/ato-1.0/lib/ato-1.0.jar

sandbox:

BUILD SUCCESSFUL Total time: 4 seconds [tim@moby ato]$ cd dist/ato-1.0/ [tim@moby ato-1.0]$

That will get you the code, get it compiled and get you in a position to run it.

Running the Federation
Having completed the steps above and moved ourselves to the dist/ato-1.0 directory, we are now ready to run the federation. Sadly, you will need a separate terminal window open for to run each federate in (6 at most).

Step One: Start Portico from wherever you installed it

[tim@moby portico-0.5]$ bin/portico WARNING Your RTI_HOME environment variable is not set, using /Users/tim/Documents/workspace/portico/codebase/dist/portico-0.5 INFO [main] jarti:
 * 1)                     Portico Server                     #
 * 2)            Welcome to Portico for the HLA!!            #
 * 3)   portico is distributed by the littlebluefrog labs    #
 * 4)   under the terms of the provided license agreement.   #
 * 5)    For a copy of the license, see the LICENSE file     #
 * 6)     included in the root of the distributable you      #
 * 7)                      downloaded.                       #
 * 8)                    System Information                  #
 * 9) Platform Architecture:    i386                         #
 * 10) CPUs:                     2                            #
 * 11) Operating System:         Mac OS X                     #
 * 12) Operating System Version: 10.4.6                       #
 * 13) Java Version:             1.5.0_06                     #
 * 14) Java Vendor:              Apple Computer, Inc.         #
 * 15) Server Startup Time:      Jun 13, 2006 - 11:56:54 PM   #
 * 1) Operating System:         Mac OS X                     #
 * 2) Operating System Version: 10.4.6                       #
 * 3) Java Version:             1.5.0_06                     #
 * 4) Java Vendor:              Apple Computer, Inc.         #
 * 5) Server Startup Time:      Jun 13, 2006 - 11:56:54 PM   #
 * 1) Server Startup Time:      Jun 13, 2006 - 11:56:54 PM   #

INFO [main] portico: RTI_HOME: /Users/tim/Documents/workspace/portico/codebase/dist/portico-0.5 INFO [main] portico.main: ATTEMPT process default configuration file [etc/portico-default.xml] INFO [main] portico.main: SUCCESS process default configuration file [etc/portico-default.xml] INFO [main] portico.rtiexec: ATTEMPT Start RTIExec [rtiexec] INFO [main] portico.rtiexec: SUCCESS Start RTIExec [rtiexec]

Step Two: Start the execution manager federate

From the dist/ato-1.0 directory:

[tim@moby ato-1.0]$ bin/exmanager Starting exman.ATOExecutionManager INFO [main] ato.exmanager: Create federation with fed file [etc/ato.fed] INFO [main] ato.exmanager: Published interaction class [InteractionRoot.Management.StopSimulation] INFO [main] ato.exmanager: Press to START simulation (when all federates have joined)

The execution manager will hold everything up until you press enter, thus allowing you to start the other federates.

Step Three: Start the other federates

In other windows (but from the same dist/ato-1.0 directory) run the startup scripts for the other federates:

Air Traffic Control [tim@moby tim]$ cd Documents/workspace/fedlibrary/ato/dist/ato-1.0/ [tim@moby ato-1.0]$ bin/atc Starting atc.ATC INFO [main] ato.ATC: SUCCESS join( atoFederation, ATC, etc/ato.fed ) INFO [main] ato.ATC: STATUS  preSimulation: Setting up simulation INFO [main] ato.ATC: SUCCESS published and subscribed INFO [main] ato.ATC: STATUS  waiting for other federates to join

Aircraft Manager [tim@moby tim]$ cd Documents/workspace/fedlibrary/ato/dist/ato-1.0/ [tim@moby ato-1.0]$ bin/acm Starting acm.ACM INFO [main] ato.ACM: SUCCESS join( atoFederation, ACM, etc/ato.fed ) INFO [main] ato.ACM: STATUS  preSimulation: Setting up simulation INFO [main] ato.ACM: SUCCESS published and subscribed INFO [main] ato.ACM: STATUS  waiting for other federates to join

Fleet Manager [tim@moby tim]$ cd Documents/workspace/fedlibrary/ato/dist/ato-1.0/ [tim@moby ato-1.0]$ bin/fm Starting fm.FM INFO [main] ato.FM: SUCCESS join( atoFederation, FM, etc/ato.fed ) INFO [main] ato.FM: STATUS  preSimulation: Setting up simulation INFO [main] ato.FM: SUCCESS published and subscribed INFO [main] ato.FM: STATUS  cached relevant metadata INFO [main] ato.FM: STATUS  waiting for other federates to join

GUI Federate [tim@moby tim]$ cd Documents/workspace/fedlibrary/ato/dist/ato-1.0/ [tim@moby ato-1.0]$ bin/gui Starting gui.GUI INFO [Thread-0] ato.GUI: SUCCESS join( atoFederation, GUI, etc/ato.fed ) INFO [Thread-0] ato.GUI: STATUS  preSimulation: Setting up simulation INFO [Thread-0] ato.GUI: SUCCESS published and subscribed INFO [Thread-0] ato.GUI: STATUS  cached relevant metadata INFO [Thread-0] ato.GUI: STATUS  waiting for other federates to join

With the GUI federate, the interface will start up when the federate is started. You will need to click on the big "tick" button in the top left corner to get it ready.

Now that all the federates are up and ready to run, bring up the execution manager window and hit enter. With that, the simulation should start and you will see some stuff pop up on the GUI.

NOTE: There is a known, sometimes occurring bug in the Portico bindings that may cause the federation to lock up at the start of the federation (this is mainly due to the slow response time of the GUI given the "high performance" of the Java graphics classes :P). If nothing appears to be happening, check the federate windows for a message like "JSOP Handoff Timeout". If you see that, sadly the only option you have it to Ctrl-C everything and try again. This mainly comes up on slower machines that can't handle running all the federates and the RTI during the initial burst of activity when the federation starts. This will generally only occur on a system that is under some load.

Ending the Federation
The ATO federation will just keep running as long as you let it, so to stop everything, just hit enter in the execution manager window again and all the federates should shutdown.