new analysis for array references that create no new reachability is in, and correctl...
[IRC.git] / Robust / src / Benchmarks / mlp / directto / mlp-small-for-testing / FlightList.java
1 // This is the class that manages all the flights
2
3 //import java.util.*;
4
5 public class FlightList {
6   public  int noFlights;
7   public  Vector f;
8
9   public FlightList() {
10     noFlights=0;
11     f=new Vector(100);
12   }
13
14   public  void addFlightPlan(D2 d2, int time, StringTokenizer st) { 
15     Flight newFlight=/*disjoint flightAdd*/ new Flight(st.nextToken());
16     noFlights++;
17     f.addElement(newFlight);
18
19     FlightPlan fAux=new FlightPlan();
20     Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());      
21     newFlight.setAircraftType(aAux);
22   
23     newFlight.setFlightType(st.nextToken());
24     Route rAux=new Route(Integer.parseInt(st.nextToken()));
25     for (int i=0;i<rAux.noFixes;i++)
26       rAux.addFix(d2,i,st.nextToken());           
27     fAux.setRoute(rAux);
28     fAux.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
29     newFlight.setFlightPlan(fAux);
30   }
31
32   public  String getFlightName(int index) {
33     Flight fAux=(Flight) f.elementAt(index);
34     return fAux.flightID;
35   }
36
37   public  void amendFlightPlan(D2 d2, int time, StringTokenizer st) {
38     Flight fAux=getFlight(st.nextToken());
39     Route rAux=new Route(Integer.parseInt(st.nextToken()));    
40
41
42     //////////////////////////////
43     // do this once    
44     //for (int i=0;i<rAux.noFixes;i++)
45     //  rAux.addFix(d2,i,st.nextToken());      
46     //////////////////////////////
47     rAux.addFix(d2,0,st.nextToken());      
48
49
50     fAux.fPlan.setRoute(rAux);
51     fAux.fPlan.setCruiseParam(Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()));
52   }
53
54     public  void amendFlightInfo(D2 d2, int time, StringTokenizer st) {
55     Flight fAux=getFlight(st.nextToken());
56     Aircraft aAux=d2.getAircraftList().getAircraft(st.nextToken());      
57     fAux.setAircraftType(aAux);
58     fAux.setFlightType(st.nextToken());
59   }
60
61     public  void sendingAircraft(D2 d2, int time, StringTokenizer st) {
62     int noF=Integer.parseInt(st.nextToken());
63     String id;
64     Point4d pos;
65     Velocity vel;
66     Track t;
67     String nameFix;
68     Flight fAux;
69     for (int counter=0; counter<noF; counter++) {
70       id=st.nextToken();
71       pos=new Point4d(time,
72                       Double.valueOf(st.nextToken()).doubleValue(),
73                       Double.valueOf(st.nextToken()).doubleValue(),
74                       Double.valueOf(st.nextToken()).doubleValue());
75       vel=new Velocity(Double.valueOf(st.nextToken()).doubleValue(),
76                        Double.valueOf(st.nextToken()).doubleValue(),
77                        Double.valueOf(st.nextToken()).doubleValue());
78       t=new Track(pos, vel);
79       nameFix=st.nextToken();
80       fAux=getFlight(id);
81       System.out.println(id+" Flight id: "+fAux.flightID);
82       fAux.setTrack(t);
83       System.out.println("Setting current fix ...");
84       fAux.fPlan.setCurrentFix(nameFix);
85       System.out.println("Sent flight "+
86                          fAux.flightID+
87                          "; position: "+
88                          fAux.track.pos);
89       d2.getTrajectorySynthesizer().updateTrajectory(d2, time, fAux);
90       fAux.traject.printInfo();      
91     }
92   }  
93
94   public  void removeFlightPlan(int time, StringTokenizer st) {
95     String id=st.nextToken();
96     int i=0;
97     while ((i<noFlights) && (((Flight) f.elementAt(i)).hasID(id))) i++;
98     if (i<noFlights) f.removeElementAt(i);
99   }
100
101   public  Flight getFlight(String id) {
102     for( int i = 0; i < f.size(); ++i ) {
103       Flight fAux=(Flight) f.elementAt(i);
104       if (fAux.hasID(id))
105         return fAux;
106     }
107     System.out.println("Flight not found - "+id);
108     System.exit(-1);
109     return null;
110   }
111
112   public  boolean anyPlanesAlive() {
113     for( int i = 0; i < f.size(); ++i ) {
114       Flight aAux=(Flight) f.elementAt(i);
115       Vector p1=aAux.traject.p;
116       Point4d pAux= (Point4d) p1.elementAt(0);
117       if (!pAux.outOfRange())
118         return true;
119     }
120     return false;
121   }
122
123   public  void printInfo() {
124     System.out.println("\n\nThe number of flights:"+noFlights);
125     System.out.println("The flights are:");
126     for( int i = 0; i < f.size(); ++i ) {
127       Flight fAux=(Flight) f.elementAt(i);
128       System.out.println(fAux);
129     }
130   }
131 }