-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAircraftFeeder.java
More file actions
160 lines (143 loc) · 5.36 KB
/
AircraftFeeder.java
File metadata and controls
160 lines (143 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package cas;
import java.util.*;
import Ertsys.*;
public class AircraftFeeder implements IAircraftFeeder
{
private int[] _Xboundary;
private int[] _Yboundary;
private Random random = new Random();
private static final int minZ = 8000; //9144; //meters
private static final int maxZ = 16000; //12192; //meters
public AircraftFeeder(int atcMaxX, int atcMaxY)
{
_Xboundary = new int[] {0, atcMaxX};
_Yboundary = new int[] {0, atcMaxY};
}
private double getRandom(int rangeMax)
{
return getRandom(0, rangeMax);
}
private double getRandom(int rangeMin, int rangeMax)
{
return rangeMin + (double) (rangeMax - rangeMin) * random.nextDouble();
}
private int getRandomInt(int rangeMin, int rangeMax)
{
return rangeMin + random.nextInt(rangeMax);
}
private double getRandomHeight()
{
return getRandom(minZ, maxZ);
}
private Vector getAPositionForInitialAircraft()
{
return new Vector(getRandom(_Xboundary[1]),
getRandom(_Yboundary[1]), getRandomHeight(), VectorType.Position,
(VectorType) null);
}
private Vector getAPositionForInjectedAircraft()
{
int randDecider = getRandomInt(1, 4);
switch (randDecider)
{
case(1) : return new Vector(0,
getRandom(_Yboundary[1]), getRandomHeight(), VectorType.Position,
(VectorType) null);
case(2) : return new Vector(_Xboundary[1],
getRandom(_Yboundary[1]), getRandomHeight(), VectorType.Position,
(VectorType) null);
case(3) : return new Vector(getRandom(_Xboundary[1]),
0, getRandomHeight(), VectorType.Position,
(VectorType) null);
default : return new Vector(getRandom(_Xboundary[1]),
_Yboundary[1], getRandomHeight(), VectorType.Position,
(VectorType) null);
}
}
private static final int _velocityLower = 243; //m/s
private static final int _velocityUpper = 257; //m/s
private Vector getRandomVelocity()
{
return new Vector(getRandom(_velocityLower, _velocityUpper) * getRandom(-1, 1)
,getRandom(_velocityLower, _velocityUpper) * getRandom(-1, 1),
VectorType.Velocity, (VectorType) null);
}
private static int _identifierCounter = 9;
private String getIdentifier()
{
String identifier = "";
int n = _identifierCounter / 26;
identifier += String.valueOf((char)(65 + n));
int k = _identifierCounter % 26;
identifier += String.valueOf((char)(65 + k));
_identifierCounter++;
return identifier;
}
private int getRandomAircraftModel()
{
return getRandomInt(0, 13);
}
public Aircraft getAircraftToInject()
{
return new Aircraft(getAPositionForInjectedAircraft(),
getRandomVelocity(),
getRandom(4, 50),
_eSystem._lString(getIdentifier()),
(char) 0,
getRandomAircraftModel(),
(AircraftModel) null);
}
public _eSeq getInitialSeqOfAircrafts() {
int maxX = _Xboundary[1];
int maxY = _Yboundary[1];
return new _eSeq()._lAppend(
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(234.0, -93.0, 0.0,
VectorType.Velocity, (VectorType) null), 50.0,
_eSystem._lString("A"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)),
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(54.0, 146.0, 0.0,
VectorType.Velocity, (VectorType) null), 20.0,
_eSystem._lString("B"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)),
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(-265.0, 86.0, 0.0,
VectorType.Velocity, (VectorType) null), 30.0,
_eSystem._lString("C"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)),
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(342.0, 134.0, 0.0,
VectorType.Velocity, (VectorType) null), 25.0,
_eSystem._lString("D"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)),
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(57.0, -75.0, 0.0,
VectorType.Velocity, (VectorType) null), 35.0,
_eSystem._lString("E"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)),
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(23.0, 105.0, 0.0,
VectorType.Velocity, (VectorType) null), 10.0,
_eSystem._lString("F"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)),
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(-364.0, 63.0, 0.0,
VectorType.Velocity, (VectorType) null), 5.0,
_eSystem._lString("G"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)),
((_eAny) new Aircraft(new Vector(getRandom(maxX),
getRandom(maxY), 9144.0, VectorType.Position,
(VectorType) null), new Vector(-12.0, 230.0, 0.0,
VectorType.Velocity, (VectorType) null), 5.0,
_eSystem._lString("H"), (char) 0, AircraftModel.Boeing777200, (
AircraftModel) null)));
}
}