commit initial
|
1 |
var vs_gearup = 300; |
2 |
var ias_gearup = 90; |
|
3 |
var agl_geardown = 1000; |
|
4 |
var ias_geardown = 100; |
|
5 |
var VNE = 240; |
|
6 | ||
7 |
# hash table which contains informations needed to display warning messages and alerts messages |
|
8 |
# alerts and warnings keys should be 'alert|warning.message', the keys priority and msg_id are |
|
9 |
# placed here for convenience. |
|
10 |
# each key is associated with a 2 elements array: |
|
11 |
# 0: the text to be displayed |
|
12 |
# 1: priority of the message should be <= 20, also used for display duration |
|
13 |
# cooked_duration = 21 - priority |
|
14 |
var alerts_table = { |
|
15 |
'warning.gears_up': ['GEARS UP', 10], |
|
16 |
'warning.gears_down': ['GEARS DOWN', 0 ], |
|
17 |
'warning.traffic': ['TRAFFIC', 20], |
|
18 |
'warning.overspeed': ['OVER SPEED', 15], |
|
19 |
'warning.stall': ['STALL', 18], |
|
20 |
'warning.push_down': ['PUSH DOWN', 17], |
|
21 |
'warning.pull_up': ['PULL UP', 15], |
|
22 |
'warning.ground': ['GROUND', 15], |
|
23 |
'alert.traffic': ['TRAFFIC', 20], |
|
24 |
'alert.overspeed': ['OVER SPEED', 20], |
|
25 |
'priority': 0, |
|
26 |
'msg_id': '', |
|
27 |
}; |
|
28 | ||
29 |
var getAircraftDefaultSpecs = func () { |
|
30 |
var d = props.globals.getNode('/instrumentation/zkv1000/defaults'); |
|
31 |
d != nil or return; |
|
32 |
if (d.getNode('vs-gearup') != nil) vs_gearup = d.getNode('vs-gearup').getValue(); |
|
33 |
if (d.getNode('ias-gearup') != nil) ias_gearup = d.getNode('ias-gearup').getValue(); |
|
34 |
if (d.getNode('agl-geardown') != nil) agl_geardown = d.getNode('agl-geardown').getValue(); |
|
35 |
if (d.getNode('ias-geardown') != nil) ias_geardown = d.getNode('ias-geardown').getValue(); |
|
36 |
if (d.getNode('VNE') != nil) VNE = d.getNode('VNE').getValue(); |
|
37 |
} |
|
38 |
|
|
39 |
var inAirCheckings = func { |
|
40 |
if (getprop('/gear/gear/wow')) { |
|
41 |
alerts.getNode('traffic-proximity').setIntValue(0); |
|
42 |
checkTrafficProximity = void; |
|
43 |
checkAlerts = void; |
|
44 |
GND(); # set XPDR mode |
|
45 |
} |
|
46 |
else { |
|
47 |
if (props.globals.getNode('/sim/multiplay/online').getBoolValue()) |
|
48 |
checkTrafficProximity = _checkTrafficProximity; |
|
49 |
checkAlerts = _checkAlerts; |
|
50 |
ALT(); # set XPDR mode |
|
51 |
} |
|
52 |
init_main_loop(); |
|
53 |
} |
|
54 | ||
55 |
var _checkTrafficProximity = func { |
|
56 |
var ttc = 0; # Time To Conflict |
|
57 |
var self = geo.aircraft_position(); |
|
58 |
foreach (var mp; multiplayer.model.list) { |
|
59 |
var n = mp.node; |
|
60 |
var x = n.getNode('position/global-x').getValue(); |
|
61 |
var y = n.getNode('position/global-y').getValue(); |
|
62 |
var z = n.getNode('position/global-z').getValue(); |
|
63 |
var ac = geo.Coord.new().set_xyz(x, y, z); |
|
64 |
if (ac == nil) continue; |
|
65 |
ttc = self.direct_distance_to(ac) * 0.5144 / ias; # ias in kt, distance in m, ttc in seconds |
|
66 |
if (ttc < 20) { |
|
67 |
set_alert('alert.traffic'); |
|
68 |
return; |
|
69 |
} |
|
70 |
else if (ttc < 60) { |
|
71 |
set_alert('warning.traffic'); |
|
72 |
} |
|
73 |
} |
|
74 |
} |
|
75 | ||
76 |
var checkAlerts = void; |
|
77 |
var _checkAlerts = func { |
|
78 |
if (stall) set_alert('warning.stall'); |
|
79 |
if (pitch > 50) set_alert('warning.push_down'); |
|
80 |
if (pitch < -30) set_alert('warning.pull_up'); |
|
81 |
if (agl < 1500 and vs < -800) set_alert('warning.ground'); |
|
82 |
if (vs < -3000) set_alert('warning.pull_up'); |
|
83 |
if (gear and ias > ias_gearup and agl > agl_geardown) set_alert('warning.gears_down'); |
|
84 |
elsif (agl < agl_geardown and ias < ias_geardown) set_alert('warning.gears_up'); |
|
85 |
} |
|
86 |