NAV disponible (hors CDI)
|
1 |
var setListeners = func { |
listeners stored in data str...
|
2 |
var prop = '/instrumentation/nav/nav-id'; |
3 |
data.listeners[prop] = setlistener(prop, |
|
correction listeners
|
4 |
func (n) { |
5 |
var val = n.getValue(); |
|
creates flightdeck hash to p...
|
6 |
foreach (var c; keys(flightdeck)) |
removes unecessary listeners
|
7 |
flightdeck[c].display.updateNAV({'nav-id': 1, val: val}); |
NAV disponible (hors CDI)
|
8 |
}, 1, 2); |
listeners stored in data str...
|
9 | |
10 |
prop = '/instrumentation/nav[1]/nav-id'; |
|
11 |
data.listeners[prop] = setlistener(prop, |
|
correction listeners
|
12 |
func (n) { |
13 |
var val = n.getValue(); |
|
creates flightdeck hash to p...
|
14 |
foreach (var c; keys(flightdeck)) |
removes unecessary listeners
|
15 |
flightdeck[c].display.updateNAV({'nav-id': 2, val: val}); |
NAV disponible (hors CDI)
|
16 |
}, 1, 2); |
listeners stored in data str...
|
17 | |
adds ILS glideslope
|
18 |
prop = '/instrumentation/nav/has-gs'; |
19 |
data.listeners[prop] = setlistener(prop, |
|
20 |
func (n) { |
|
21 |
if (n.getValue()) { |
|
22 |
foreach (var c; keys(flightdeck)) { |
|
23 |
if (flightdeck[c].role == 'PFD') { |
|
24 |
flightdeck[c].display.screenElements['VDI-scale'].show(); |
|
25 |
flightdeck[c].display.screenElements['GS-ILS'].show(); |
|
26 |
flightdeck[c].display.timers.updateGS.start(); |
|
27 |
} |
|
28 |
} |
|
29 |
} |
|
30 |
else { |
|
31 |
foreach (var c; keys(flightdeck)) { |
|
32 |
if (flightdeck[c].role == 'PFD') { |
|
33 |
flightdeck[c].display.screenElements['VDI-scale'].hide(); |
|
34 |
flightdeck[c].display.screenElements['GS-ILS'].hide(); |
|
35 |
flightdeck[c].display.timers.updateGS.stop(); |
|
36 |
} |
|
37 |
} |
|
38 |
} |
|
39 |
}, 1, 0); |
|
40 | ||
listeners stored in data str...
|
41 |
# keep this listener as long as the code is to heavy to be modified in multiple places |
remove hardcoded properties ...
|
42 |
prop = afcs.getNode('selected-alt-ft').getPath(); |
listeners stored in data str...
|
43 |
data.listeners[prop] = setlistener(prop, |
adds OAT, TAS, GSPD, WindDat...
|
44 |
func (n) { |
45 |
var val = n.getValue(); |
|
creates flightdeck hash to p...
|
46 |
if (val != nil) |
47 |
foreach (var c; keys(flightdeck)) |
|
removes unecessary listeners
|
48 |
if (flightdeck[c].role == 'PFD') { |
creates flightdeck hash to p...
|
49 |
if (! flightdeck[c].display.screenElements['SelectedALT'].getVisible()) { |
50 |
flightdeck[c].display.screenElements['SelectedALT'].show(); |
|
51 |
flightdeck[c].display.screenElements['SelectedALT-text'].show(); |
|
52 |
flightdeck[c].display.screenElements['SelectedALT-symbol'].show(); |
|
53 |
flightdeck[c].display.screenElements['SelectedALT-bug'].show(); |
|
54 |
flightdeck[c].display.screenElements['SelectedALT-bg'].show(); |
|
55 |
} |
|
56 |
flightdeck[c].display.updateSelectedALT(); |
|
57 |
} |
|
adds OAT, TAS, GSPD, WindDat...
|
58 |
}, 0, 2); |
listeners stored in data str...
|
59 | |
60 |
prop = '/gear/gear/wow'; |
|
61 |
data.listeners[prop] = setlistener(prop, |
|
creates flightdeck hash to p...
|
62 |
func foreach (var c; keys(flightdeck)) |
removes unecessary listeners
|
63 |
if (flightdeck[c].role == 'PFD') |
creates flightdeck hash to p...
|
64 |
flightdeck[c].display.updateXPDR(), |
adds transponder
|
65 |
0, 0); |
listeners stored in data str...
|
66 | |
fix setlistener on tied prop...
|
67 |
prop = misc.getNode('alt-setting-inhg').getPath(); |
listeners stored in data str...
|
68 |
data.listeners[prop] = setlistener(prop, |
creates flightdeck hash to p...
|
69 |
func foreach (var c; keys(flightdeck)) |
removes unecessary listeners
|
70 |
if (flightdeck[c].role == 'PFD') |
creates flightdeck hash to p...
|
71 |
flightdeck[c].display.updateBARO(), 0, 2); |
adds route display on map
|
72 | |
73 |
prop = '/autopilot/route-manager/signals/edited'; |
|
74 |
data.listeners[prop] = setlistener(prop, |
|
75 |
func foreach (var c; keys(flightdeck)) |
|
76 |
flightdeck[c].map.layers.route.onFlightPlanChange(), |
|
77 |
0, 1); |
|
78 | ||
79 |
prop = '/autopilot/route-manager/current-wp'; |
|
80 |
data.listeners[prop] = setlistener(prop, |
|
fix map display makes FG to ...
|
81 |
func (n) { |
add a way to power off
|
82 |
var wp_idx = n.getValue(); |
83 |
if (wp_idx > 0) { |
|
84 |
var wp_path = '/autopilot/route-manager/route/wp[' ~ wp_idx ~ ']/'; |
|
85 |
var wp = findNavaidsByID(getprop(wp_path ~ 'latitude-deg'), |
|
86 |
getprop(wp_path ~ 'longitude-deg'), |
|
87 |
getprop(wp_path ~ 'id')); |
|
88 |
call(func {return wp[0].frequency}, [], nil, nil, var errors = []); |
|
89 |
# if (!size(errors)) debuginfo ~ sprintf('; freq: %d', wp[0].frequency); |
|
90 |
call(func {return wp[0].type}, [], nil, nil, var errors = []); |
|
91 |
# if (!size(errors)) debuginfo ~ sprintf('; type: %s', wp[0].type); |
|
92 |
} |
|
fix map display makes FG to ...
|
93 |
var delay = maketimer(2, func { |
94 |
foreach (var c; keys(flightdeck)) |
|
95 |
flightdeck[c].map.layers.route.onCurrentWaypointChange( |
|
96 |
props.globals.getNode('/autopilot/route-manager/current-wp')); |
|
97 |
}); |
|
98 |
delay.singleShot = 1; |
|
99 |
delay.start(); |
|
100 |
}, 0, 1); |
|
adds route display on map
|
101 | |
102 |
prop = '/autopilot/route-manager/active'; |
|
103 |
data.listeners[prop] = setlistener(prop, |
|
104 |
func foreach (var c; keys(flightdeck)) |
|
105 |
flightdeck[c].map.layers.route.onCurrentWaypointChange(props.globals.getNode('/autopilot/route-manager/current-wp')), |
|
106 |
0, 1); |
|
add a way to power off
|
107 | |
108 |
# the timer isn't necessary anymore |
|
109 |
data.timers.listeners.stop(); |
|
110 |
delete(data.timers, 'listeners'); |
|
NAV disponible (hors CDI)
|
111 |
} |
112 | ||
commit initial
|
113 |
var deviceClass = { |
improves role/name variables...
|
114 |
new: func (name) { |
commit initial
|
115 |
var m = { parents: [ deviceClass ] }; |
improves role/name variables...
|
116 |
m.name = name; |
117 |
m.role = substr(name, 0, 3); |
|
118 |
m.node = zkv.getNode(name, 1); |
|
add V-speeds bugs
|
119 |
m.data = {}; |
first attempt to centralize ...
|
120 |
m.timers = {}; |
makes Vspeeds free and adapt...
|
121 |
foreach (var v; keys(data.Vspeeds)) |
add V-speeds bugs
|
122 |
m.data[v ~ '-visible'] = 1; |
configurable display size, v...
|
123 |
foreach (var v; ['screen-object', 'screen-view', 'screen-size']) |
remove hardcoded properties ...
|
124 |
m.data[v] = getprop(zkv.getPath() ~ '/' ~ name ~ '/' ~ v); |
massive code reorganisation ...
|
125 | |
improves role/name variables...
|
126 |
m.display = displayClass.new(m); |
127 |
m.softkeys = softkeysClass.new(m); |
|
128 |
m.buttons = buttonsClass.new(m); |
|
XPDR settings via knob or so...
|
129 |
m.knobs = knobsClass.new(m); |
just a alignment
|
130 |
m.map = mapClass.new(m); |
TMR/REF window
|
131 |
m.windows = pageClass.new(m); |
massive code reorganisation ...
|
132 | |
fix setlistener on tied prop...
|
133 |
if (! contains(data.timers, 'alt-setting-inhg')) { |
134 |
data.timers['alt-setting-inhg'] = maketimer(0.1, m, func { |
|
135 |
var inhg = getprop('/instrumentation/altimeter/setting-inhg'); |
|
136 |
if (inhg != misc.getValue('alt-setting-inhg')) |
|
137 |
misc.getNode('alt-setting-inhg').setValue(inhg); |
|
138 |
}); |
|
139 |
data.timers['alt-setting-inhg'].start(); |
|
140 |
} |
|
massive code reorganisation ...
|
141 |
if (! contains(data.timers, 'map')) { |
142 |
data.timers.map = maketimer(1, m, func { |
|
143 |
foreach (var d; keys(flightdeck)) |
|
144 |
flightdeck[d].map.update(); |
|
145 |
var gspd = getprop('/velocities/groundspeed-kt'); |
|
146 |
if (gspd != 0) |
|
147 |
var next = (me.data['range-nm']/(gspd/3600))/(me.display.display.get('view[1]')/2); |
|
148 |
else |
|
149 |
var next = 10; |
|
150 |
if (next > 10) |
|
151 |
next = 10; |
|
152 |
data.timers.map.restart(next); |
|
153 |
}); |
|
154 |
data.timers.map.singleShot = 1; |
|
155 |
data.timers.map.start(); |
|
156 |
} |
|
traffic alert and display
|
157 |
if (!contains(data.timers, 'tcas')) { |
158 |
data.timers.tcas = maketimer ( 5, func { |
|
159 |
var traffic_displayed = 0; |
|
160 |
foreach (var name; keys(flightdeck)) |
|
removes traffic from PFD ins...
|
161 |
if (contains(flightdeck[name].map.layers, 'tcas')) |
162 |
traffic_displayed += flightdeck[name].map.layers.tcas.group.getVisible(); |
|
traffic alert and display
|
163 |
var tcas_dirty = []; |
164 |
var level_dirty = 0; |
|
165 |
foreach (var AItype; [ 'aircraft', 'multiplayer' ]) |
|
166 |
foreach (var ac; props.globals.getNode("/ai/models").getChildren(AItype)) { |
|
167 |
if (ac.getValue("valid")) { |
|
168 |
var lat = ac.getNode("position/latitude-deg").getValue(); |
|
169 |
var lon = ac.getNode("position/longitude-deg").getValue(); |
|
170 |
var alt = ac.getNode("position/altitude-ft").getValue(); |
|
171 |
var vs = ac.getNode("velocities/vertical-speed-fps").getValue(); |
|
172 |
if (isnum(lat) and isnum(lon) and isnum(vs) and isnum(alt)) { |
|
173 |
alt = math.floor(((alt - data.alt) / 100) + 0.5); |
|
174 |
var (course, dist) = courseAndDistance(lat, lon, |
|
175 |
geo.Coord.new().set_latlon(data.lat, data.lon)); |
|
176 |
if (dist < 50) { |
|
177 |
var dir = ac.getNode('orientation/true-heading-deg').getValue() - course; |
|
178 |
if (dist < 5 and abs(alt) < 10) |
|
179 |
level = 3; |
|
180 |
elsif (dist < 10 and alt * vs < 0 and abs(dir) < 10) |
|
181 |
level = 3; |
|
182 |
elsif (dist < 15 and abs(alt) < 5) |
|
183 |
level = 2; |
|
184 |
elsif (dist < 15 and abs(alt) < 50) |
|
185 |
level = 1; |
|
186 |
else |
|
187 |
level = 0; |
|
188 |
level_dirty = level > level_dirty ? level : level_dirty; |
|
189 |
if (traffic_displayed) |
|
190 |
append(tcas_dirty, { |
|
191 |
lat: lat, |
|
192 |
lon: lon, |
|
193 |
vs: vs, |
|
194 |
alt: alt, |
|
195 |
level: level, |
|
196 |
callsign: ac.getValue('callsign') |
|
197 |
}); |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
add TCAS
|
201 |
} |
traffic alert and display
|
202 |
data.tcas = tcas_dirty; |
203 |
data.tcas_level = level_dirty; |
|
204 |
}); |
|
205 |
data.timers.tcas.start(); |
|
add TCAS
|
206 |
} |
massive code reorganisation ...
|
207 |
m.display.showInitProgress(); |
208 | ||
remove hardcoded properties ...
|
209 |
setprop(zkv.getPath() ~ '/' ~ m.name ~ '/status', 1); |
improves role/name variables...
|
210 |
msg(m.name ~ ' switched on!'); |
commit initial
|
211 |
return m; |
212 |
}, |
|
add a way to power off
|
213 |
off: func { |
poweroff improved
|
214 |
var name = me.name; |
add a way to power off
|
215 |
foreach (var timer; keys(me.timers)) { |
216 |
me.timers[timer].stop(); |
|
217 |
delete(me.timers, timer); |
|
218 |
} |
|
219 |
foreach (var member; keys(me)) { |
|
poweroff improved
|
220 |
if (member == 'parents') |
221 |
continue; |
|
222 |
if (contains(me[member], 'parents')) { |
|
223 |
if (contains(me[member].parents[0], 'new') |
|
224 |
and typeof(me[member].parents[0].new) == 'func') { |
|
225 |
if (contains(me[member].parents[0], 'removeAllChildren') |
|
226 |
and !contains(me[member].parents[0], 'setVisible')) # this one is a props node, but not canvas |
|
227 |
me[member].removeAllChildren(); |
|
228 |
elsif (contains(me[member].parents[0], 'off') |
|
229 |
and typeof(me[member].parents[0].off) == 'func') |
|
230 |
me[member].off(); |
|
231 |
} |
|
232 |
} |
|
233 |
} |
|
234 |
foreach (var member; keys(me)) { |
|
235 |
if (member == 'parents') |
|
236 |
continue; |
|
add a way to power off
|
237 |
delete(me, member); |
238 |
} |
|
poweroff improved
|
239 |
zkv.getNode(name).setValue('status', 0); |
240 |
msg(name ~ ' switched off'); |
|
add a way to power off
|
241 |
}, |
commit initial
|
242 |
}; |
243 | ||
add a way to power off
|
244 |
var powerOff = func { |
poweroff improved
|
245 |
foreach (var listener; keys(data.listeners)) { |
improve power on and off usi...
|
246 |
if (listener == '/instrumentation/zkv1000/serviceable') { |
247 |
var prop = zkv.getNode('serviceable',1).getPath(); |
|
248 |
data.listeners[prop] = setlistener(prop, zkv1000.powerOn, 0, 0); |
|
poweroff improved
|
249 |
continue; |
improve power on and off usi...
|
250 |
} |
add autopwer
|
251 |
removelistener(data.listeners[listener]); |
poweroff improved
|
252 |
delete(data.listeners, listener); |
253 |
} |
|
add autopwer
|
254 | |
add a way to power off
|
255 |
foreach (var timer; keys(data.timers)) { |
256 |
data.timers[timer].stop(); |
|
poweroff improved
|
257 |
if (timer == '20Hz' or timer == '1Hz') |
258 |
continue; |
|
improve power on and off usi...
|
259 |
if (timer == 'serviceable') { |
260 |
data.timers[timer] = maketimer(1, func { |
|
261 |
if (zkv.getNode('serviceable').getValue() != 0) |
|
262 |
zkv1000.powerOn(); |
|
263 |
}); |
|
264 |
data.timers.serviceable.restart(); |
|
265 |
continue; |
|
266 |
} |
|
add a way to power off
|
267 |
delete(data.timers, timer); |
268 |
} |
|
add autopwer
|
269 | |
poweroff improved
|
270 |
foreach (var k; keys(autopilot)) |
271 |
delete(autopilot, k); |
|
272 | ||
add a way to power off
|
273 |
foreach (var name; keys(flightdeck)) { |
274 |
flightdeck[name].off(); |
|
poweroff improved
|
275 |
flightdeck[name] = nil; |
add a way to power off
|
276 |
} |
277 |
} |
|
278 | ||
PFD+MFD allumés ensemble
|
279 |
var powerOn = func { |
add a way to power off
|
280 |
if (!zkv.getValue('serviceable')) { |
281 |
msg('not yet serviceable (check power)!'); |
|
282 |
return; |
|
283 |
} |
|
284 | ||
poweroff improved
|
285 |
if (contains(data.listeners, '/instrumentation/zkv1000/serviceable')) { |
improve power on and off usi...
|
286 |
var prop = zkv.getNode('serviceable',1).getPath(); |
287 |
data.listeners[prop] = setlistener(prop, zkv1000.powerOff, 0, 0); |
|
288 |
} |
|
289 |
if (contains(data.timers, 'serviceable')) { |
|
290 |
data.timers.serviceable = maketimer(1, func { |
|
291 |
if (zkv.getNode('serviceable').getValue() == 0) |
|
292 |
zkv1000.powerOff(); |
|
293 |
}); |
|
294 |
data.timers.serviceable.start(); |
|
poweroff improved
|
295 |
} |
add autopwer
|
296 | |
global timers started at pow...
|
297 |
foreach (var freq; keys(data.timers)) |
298 |
data.timers[freq].start(); |
|
299 | ||
improves role/name variables...
|
300 |
foreach (var name; keys(flightdeck)) |
301 |
if (zkv.getNode(name) != nil) |
|
poweroff improved
|
302 |
if (zkv.getNode(name).getValue('status') == nil or zkv.getNode(name).getValue('status') == 0) |
new var organistaion (and fi...
|
303 |
# thread.newthread(func { |
improves role/name variables...
|
304 |
flightdeck[name] = deviceClass.new(name); |
new var organistaion (and fi...
|
305 |
# }); |
replace settimer by maketime...
|
306 | |
poweroff improved
|
307 |
if (! contains(autopilot, 'parents')) |
308 |
autopilot = APClass.new(); |
|
makes autopilot up after all...
|
309 | |
adds alerting system
|
310 |
if (! contains(annunciations, 'parents')) |
311 |
annunciations = annunciationsClass.new(); |
|
312 | ||
replace settimer by maketime...
|
313 |
if (! contains(data.timers, 'listeners')) { |
poweroff improved
|
314 |
data.timers.listeners = maketimer(1, setListeners); |
replace settimer by maketime...
|
315 |
data.timers.listeners.singleShot = 1; |
316 |
data.timers.listeners.start(); |
|
317 |
} |
|
commit initial
|
318 |
} |