-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathWCVTable.java
More file actions
349 lines (293 loc) · 8.44 KB
/
WCVTable.java
File metadata and controls
349 lines (293 loc) · 8.44 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
/*
* Copyright (c) 2012-2021 United States Government as represented by
* the National Aeronautics and Space Administration. No copyright
* is claimed in the United States under Title 17, U.S.Code. All Other
* Rights Reserved.
*/
package gov.nasa.larcfm.ACCoRD;
import java.util.HashMap;
import java.util.Map;
import gov.nasa.larcfm.Util.ParameterData;
import gov.nasa.larcfm.Util.Units;
import gov.nasa.larcfm.Util.f;
public class WCVTable implements ParameterTable {
protected double DTHR; // Distance threshold
protected double ZTHR; // Vertical threshold
protected double TTHR; // Time threshold
protected double TCOA; // Time to co-altitude threshold
private Map<String,String> units_;
/**
* DWC Standard Thresholds in RTCA DO-365
*/
public WCVTable() {
DTHR = Units.from("nmi",0.66);
ZTHR = Units.from("ft",450);
TTHR = 35; // [s]
TCOA = 0; // [s]
units_ = new HashMap<String,String>();
units_.put("WCV_DTHR","nmi");
units_.put("WCV_ZTHR","ft");
units_.put("WCV_TTHR","s");
units_.put("WCV_TCOA","s");
}
/**
* Copy constructor -- returns a fresh copy
* @param tab
*/
public WCVTable(WCVTable tab) {
units_ = new HashMap<String,String>();
copyFrom(tab);
}
/**
* Table containing specified values (internal units)
*/
public WCVTable(double dthr, double zthr, double tthr, double tcoa) {
DTHR = Math.abs(dthr);
ZTHR = Math.abs(zthr);
TTHR = Math.abs(tthr);
TCOA = Math.abs(tcoa);
units_ = new HashMap<String,String>();
units_.put("WCV_DTHR","m");
units_.put("WCV_ZTHR","m");
units_.put("WCV_TTHR","s");
units_.put("WCV_TCOA","s");
}
/**
* Table containing specified values (specified units)
*/
public WCVTable(double dthr, String udthr, double zthr, String uzthr,
double tthr, String utthr, double tcoa, String utcoa) {
DTHR = Units.from(udthr,dthr);
ZTHR = Units.from(uzthr,zthr);
TTHR = Units.from(utthr, tthr);
TCOA = Units.from(utcoa,tcoa);
units_ = new HashMap<String,String>();
units_.put("WCV_DTHR",udthr);
units_.put("WCV_ZTHR",uzthr);
units_.put("WCV_TTHR",utthr);
units_.put("WCV_TCOA",utcoa);
}
public WCVTable copy() {
return new WCVTable(this);
}
/**
* Copy from tab into this object
*/
public void copyFrom(WCVTable tab) {
DTHR = tab.DTHR;
ZTHR = tab.ZTHR;
TTHR = tab.TTHR;
TCOA = tab.TCOA;
units_.clear();
units_.putAll(tab.units_);
}
/**
* DO-365 preventive thresholds Phase I (en-route), i.e., DTHR=0.66nmi, ZTHR=700ft,
* TTHR=35s, TCOA=0.
*/
public static final WCVTable DO_365_Phase_I_preventive =
new WCVTable(0.66,"nmi",700,"ft",35,"s",0,"s");
/**
* DO-365 Well-Clear thresholds Phase I (en-route), i.e., DTHR=0.66nmi, ZTHR=450ft,
* TTHR=35s, TCOA=0.
*/
public static final WCVTable DO_365_DWC_Phase_I = new WCVTable();
/**
* DO-365 Well-Clear thresholds Phase II (DTA), i.e., DTHR=1500ft, ZTHR=450ft,
* TTHR=0, TCOA=0.
*/
public static final WCVTable DO_365_DWC_Phase_II =
new WCVTable(1500,"ft",450,"ft",0,"s",0,"s");
/**
* DO-365 Well-Clear thresholds Non-Cooperative, i.e., DTHR=2200ft, ZTHR=450ft,
* TTHR=0, TCOA=0.
*/
public static final WCVTable DO_365_DWC_Non_Coop =
new WCVTable(2200,"ft",450,"ft",0,"s",0,"s");
/**
* Buffered preventive thresholds Phase I (en-route), i.e., DTHR=1.0nmi, ZTHR=750ft,
* TTHR=35s, TCOA=20.
*/
public static final WCVTable Buffered_Phase_I_preventive =
new WCVTable(1.0,"nmi",750,"ft",35,"s",20,"s");
/**
* Buffered Well-Clear thresholds Phase I (en-route), i.e., DTHR=1.0nmi, ZTHR=450ft,
* TTHR=35s, TCOA=20.
*/
public static final WCVTable Buffered_DWC_Phase_I =
new WCVTable(1.0,"nmi",450,"ft",35,"s",20,"s");
/**
* Return horizontal distance threshold DTHR in internal units
*/
public double getDTHR() {
return DTHR;
}
/**
* Return horizontal distance threshold DTHR in u units
*/
public double getDTHR(String u) {
return Units.to(u,DTHR);
}
/**
* Return vertical distance threshold ZTHR in internal units
*/
public double getZTHR() {
return ZTHR;
}
/**
* Return vertical distance threshold ZTHR in u units
*/
public double getZTHR(String u) {
return Units.to(u,ZTHR);
}
/**
* Return horizontal time threshold TTHR in seconds
*/
public double getTTHR() {
return TTHR;
}
public double getTTHR(String u) {
return Units.to(u, TTHR);
}
/**
* Return vertical time threshold TCOA in seconds
*/
public double getTCOA() {
return TCOA;
}
public double getTCOA(String u) {
return Units.to(u,TCOA);
}
/*
* Set horizontal distance threshold DTHR to val, which is specified in internal units
*/
public void setDTHR(double val) {
DTHR = Math.abs(val);
}
/*
* Set horizontal distance threshold DTHR to val, which is specified in u units
*/
public void setDTHR(double val, String u) {
setDTHR(Units.from(u,val));
units_.put("WCV_DTHR",u);
}
/*
* Set vertical distance threshold ZTHR to val, which is specified in u units
*/
public void setZTHR(double val) {
ZTHR = Math.abs(val);
}
/*
* Set vertical distance threshold ZTHR to val, which is specified in internal units
*/
public void setZTHR(double val, String u) {
setZTHR(Units.from(u,val));
units_.put("WCV_ZTHR",u);
}
/*
* Set horizontal time threshold TTHR to val, which is specified in seconds
*/
public void setTTHR(double val) {
TTHR = Math.abs(val);
}
public void setTTHR(double val, String u) {
setTTHR(Units.from(u,val));
units_.put("WCV_TTHR",u);
}
/*
* Set vertical time threshold TCOA to val, which is specified in seconds
*/
public void setTCOA(double val) {
TCOA = Math.abs(val);
}
public void setTCOA(double val, String u) {
setTCOA(Units.from(u,val));
units_.put("WCV_TCOA",u);
}
public ParameterData getParameters() {
ParameterData p = new ParameterData();
updateParameterData(p);
return p;
}
public void updateParameterData(ParameterData p) {
p.setInternal("WCV_DTHR",DTHR,getUnits("WCV_DTHR"));
p.setInternal("WCV_ZTHR",ZTHR,getUnits("WCV_ZTHR"));
p.setInternal("WCV_TTHR",TTHR,getUnits("WCV_TTHR"));
p.setInternal("WCV_TCOA",TCOA,getUnits("WCV_TCOA"));
}
public void setParameters(ParameterData p) {
if (p.contains("WCV_DTHR")) {
setDTHR(p.getValue("WCV_DTHR"));
units_.put("WCV_DTHR",p.getUnit("WCV_DTHR"));
}
if (p.contains("WCV_ZTHR")) {
setZTHR(p.getValue("WCV_ZTHR"));
units_.put("WCV_ZTHR",p.getUnit("WCV_ZTHR"));
}
if (p.contains("WCV_TTHR")) {
setTTHR(p.getValue("WCV_TTHR"));
units_.put("WCV_TTHR",p.getUnit("WCV_TTHR"));
}
if (p.contains("WCV_TCOA")) {
setTCOA(p.getValue("WCV_TCOA"));
units_.put("WCV_TCOA",p.getUnit("WCV_TCOA"));
}
}
public String getUnits(String key) {
String u = units_.get(key);
if (u == null) {
return "unspecified";
}
return DaidalusParameters.get_overriden_unit(u);
}
public String toString() {
return "WCV_DTHR = "+Units.str(getUnits("WCV_DTHR"),DTHR)+
", WCV_ZTHR = "+Units.str(getUnits("WCV_ZTHR"),ZTHR)+
", WCV_TTHR = "+Units.str(getUnits("WCV_TTHR"),TTHR)+
", WCV_TCOA = "+Units.str(getUnits("WCV_TCOA"),TCOA);
}
protected String toPVS_() {
return "DTHR := "+f.FmPrecision(DTHR)+", ZTHR := "+f.FmPrecision(ZTHR)+
", TTHR := "+f.FmPrecision(TTHR)+", TCOA := "+f.FmPrecision(TCOA);
}
public String toPVS() {
return "(# "+toPVS_()+" #)";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(DTHR);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(TCOA);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(TTHR);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(ZTHR);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
WCVTable other = (WCVTable) obj;
if (Double.doubleToLongBits(DTHR) != Double.doubleToLongBits(other.DTHR))
return false;
if (Double.doubleToLongBits(TCOA) != Double.doubleToLongBits(other.TCOA))
return false;
if (Double.doubleToLongBits(TTHR) != Double.doubleToLongBits(other.TTHR))
return false;
if (Double.doubleToLongBits(ZTHR) != Double.doubleToLongBits(other.ZTHR))
return false;
return true;
}
public boolean contains(WCVTable tab) {
return DTHR >= tab.DTHR && TCOA >= tab.TCOA && TTHR >= tab.TTHR && ZTHR >= tab.ZTHR;
}
}