FileDocCategorySizeDatePackage
ATCDemo.javaAPI DocExample1990Sun Feb 13 18:03:30 GMT 2000None

ATCDemo

public class ATCDemo extends Object implements Observer

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

  if( args.length == 0 )
      {  System.out.println( "You must supply a parameter on the command line\n" +
            "which is the name of a suitable data file.\n" +
            "There are a number of files present in the gui2000 directory:\n\n" +
            "\tDataFile1.dat\tDataFile2.dat\tDataFile3.dat\n\n" +
            "Run the program with, for example:\n\n" +
            "\tjava ATCDemo DataFile1.dat\n\n" +
            "For the more curious among you, look at the code for\n" +
            "gui2000/AircraftFactory.java which defines how the files are created.\n" );
         return;
      }
      AirSpace a = new AirSpace( "gui2000" + File.separator + args[0] );
      ATCDemo t = new ATCDemo();
      a.getRadar().addObserver( new RadarDisplay() );   
      a.getRadar().addObserver( t );
      a.getRadio().addObserver( t );
      a.startSimulation();     
      Thread.sleep( 5000 );  // Wait 5 sec
      // Send some radio messages
      a.getRadio().broadcast( "1234", "CLIMB 150" );
      // The next one is incorrect (lower case command)
      a.getRadio().broadcast( "1234", "left 60" );
      a.getRadio().broadcast( "1234", "LEFT 60" );
      Thread.sleep( 5000 );
      a.getRadio().broadcast( "4567", "CLIMB 500" );
      a.getRadio().broadcast( "4567", "DESCEND 0" );
      a.getRadio().broadcast( "4567", "DESCEND 300" );
   
public voidupdate(java.util.Observable o, java.lang.Object data)

  if( data instanceof Vector )
      {  Vector v = (Vector)data;
         for( int i = 0; i < v.size(); i++ )
         {  System.out.println( "Radar data: " + v.elementAt(i) );
         }
      }
      if( data instanceof String )
      {  System.out.println( "Radio Message >>> " + data );
      }