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 | |
poweroff improved
|
108 |
if (zkv.getChild('serviceable') != nil) { |
109 |
prop = zkv.getPath() ~ '/serviceable'; |
|
110 |
data.listeners[prop] = setlistener(prop, |
|
111 |
func (n) { |
|
112 |
var type = n.getType(); |
|
113 |
if (type == 'BOOL') { |
|
114 |
if (n.getBoolValue()) |
|
115 |
zkv1000.powerOn(); |
|
116 |
else |
|
117 |
zkv1000.powerOff(); |
|
118 |
} |
|
119 |
elsif (type == 'INT' or type == 'LONG' or type == 'FLOAT' or type == 'DOUBLE') { |
|
120 |
if (n.getValue() > 12) |
|
121 |
zkv1000.powerOn(); |
|
122 |
else |
|
123 |
zkv1000.powerOff(); |
|
124 |
} |
|
125 |
}, 0, 0); |
|
126 |
} |
|
add a way to power off
|
127 | |
128 |
# the timer isn't necessary anymore |
|
129 |
data.timers.listeners.stop(); |
|
130 |
delete(data.timers, 'listeners'); |
|
NAV disponible (hors CDI)
|
131 |
} |
132 | ||
commit initial
|
133 |
var deviceClass = { |
improves role/name variables...
|
134 |
new: func (name) { |
commit initial
|
135 |
var m = { parents: [ deviceClass ] }; |
improves role/name variables...
|
136 |
m.name = name; |
137 |
m.role = substr(name, 0, 3); |
|
138 |
m.node = zkv.getNode(name, 1); |
|
add V-speeds bugs
|
139 |
m.data = {}; |
first attempt to centralize ...
|
140 |
m.timers = {}; |
makes Vspeeds free and adapt...
|
141 |
foreach (var v; keys(data.Vspeeds)) |
add V-speeds bugs
|
142 |
m.data[v ~ '-visible'] = 1; |
configurable display size, v...
|
143 |
foreach (var v; ['screen-object', 'screen-view', 'screen-size']) |
remove hardcoded properties ...
|
144 |
m.data[v] = getprop(zkv.getPath() ~ '/' ~ name ~ '/' ~ v); |
massive code reorganisation ...
|
145 | |
improves role/name variables...
|
146 |
m.display = displayClass.new(m); |
147 |
m.softkeys = softkeysClass.new(m); |
|
148 |
m.buttons = buttonsClass.new(m); |
|
XPDR settings via knob or so...
|
149 |
m.knobs = knobsClass.new(m); |
just a alignment
|
150 |
m.map = mapClass.new(m); |
TMR/REF window
|
151 |
m.windows = pageClass.new(m); |
massive code reorganisation ...
|
152 | |
fix setlistener on tied prop...
|
153 |
if (! contains(data.timers, 'alt-setting-inhg')) { |
154 |
data.timers['alt-setting-inhg'] = maketimer(0.1, m, func { |
|
155 |
var inhg = getprop('/instrumentation/altimeter/setting-inhg'); |
|
156 |
if (inhg != misc.getValue('alt-setting-inhg')) |
|
157 |
misc.getNode('alt-setting-inhg').setValue(inhg); |
|
158 |
}); |
|
159 |
data.timers['alt-setting-inhg'].start(); |
|
160 |
} |
|
massive code reorganisation ...
|
161 |
if (! contains(data.timers, 'map')) { |
162 |
data.timers.map = maketimer(1, m, func { |
|
163 |
foreach (var d; keys(flightdeck)) |
|
164 |
flightdeck[d].map.update(); |
|
165 |
var gspd = getprop('/velocities/groundspeed-kt'); |
|
166 |
if (gspd != 0) |
|
167 |
var next = (me.data['range-nm']/(gspd/3600))/(me.display.display.get('view[1]')/2); |
|
168 |
else |
|
169 |
var next = 10; |
|
170 |
if (next > 10) |
|
171 |
next = 10; |
|
172 |
data.timers.map.restart(next); |
|
173 |
}); |
|
174 |
data.timers.map.singleShot = 1; |
|
175 |
data.timers.map.start(); |
|
176 |
} |
|
traffic alert and display
|
177 |
if (!contains(data.timers, 'tcas')) { |
178 |
data.timers.tcas = maketimer ( 5, func { |
|
179 |
var traffic_displayed = 0; |
|
180 |
foreach (var name; keys(flightdeck)) |
|
removes traffic from PFD ins...
|
181 |
if (contains(flightdeck[name].map.layers, 'tcas')) |
182 |
traffic_displayed += flightdeck[name].map.layers.tcas.group.getVisible(); |
|
traffic alert and display
|
183 |
var tcas_dirty = []; |
184 |
var level_dirty = 0; |
|
185 |
foreach (var AItype; [ 'aircraft', 'multiplayer' ]) |
|
186 |
foreach (var ac; props.globals.getNode("/ai/models").getChildren(AItype)) { |
|
187 |
if (ac.getValue("valid")) { |
|
188 |
var lat = ac.getNode("position/latitude-deg").getValue(); |
|
189 |
var lon = ac.getNode("position/longitude-deg").getValue(); |
|
190 |
var alt = ac.getNode("position/altitude-ft").getValue(); |
|
191 |
var vs = ac.getNode("velocities/vertical-speed-fps").getValue(); |
|
192 |
if (isnum(lat) and isnum(lon) and isnum(vs) and isnum(alt)) { |
|
193 |
alt = math.floor(((alt - data.alt) / 100) + 0.5); |
|
194 |
var (course, dist) = courseAndDistance(lat, lon, |
|
195 |
geo.Coord.new().set_latlon(data.lat, data.lon)); |
|
196 |
if (dist < 50) { |
|
197 |
var dir = ac.getNode('orientation/true-heading-deg').getValue() - course; |
|
198 |
if (dist < 5 and abs(alt) < 10) |
|
199 |
level = 3; |
|
200 |
elsif (dist < 10 and alt * vs < 0 and abs(dir) < 10) |
|
201 |
level = 3; |
|
202 |
elsif (dist < 15 and abs(alt) < 5) |
|
203 |
level = 2; |
|
204 |
elsif (dist < 15 and abs(alt) < 50) |
|
205 |
level = 1; |
|
206 |
else |
|
207 |
level = 0; |
|
208 |
level_dirty = level > level_dirty ? level : level_dirty; |
|
209 |
if (traffic_displayed) |
|
210 |
append(tcas_dirty, { |
|
211 |
lat: lat, |
|
212 |
lon: lon, |
|
213 |
vs: vs, |
|
214 |
alt: alt, |
|
215 |
level: level, |
|
216 |
callsign: ac.getValue('callsign') |
|
217 |
}); |
|
218 |
} |
|
219 |
} |
|
220 |
} |
|
add TCAS
|
221 |
} |
traffic alert and display
|
222 |
data.tcas = tcas_dirty; |
223 |
data.tcas_level = level_dirty; |
|
224 |
}); |
|
225 |
data.timers.tcas.start(); |
|
add TCAS
|
226 |
} |
massive code reorganisation ...
|
227 |
m.display.showInitProgress(); |
228 | ||
remove hardcoded properties ...
|
229 |
setprop(zkv.getPath() ~ '/' ~ m.name ~ '/status', 1); |
improves role/name variables...
|
230 |
msg(m.name ~ ' switched on!'); |
commit initial
|
231 |
return m; |
232 |
}, |
|
add a way to power off
|
233 |
off: func { |
poweroff improved
|
234 |
var name = me.name; |
add a way to power off
|
235 |
foreach (var timer; keys(me.timers)) { |
236 |
me.timers[timer].stop(); |
|
237 |
delete(me.timers, timer); |
|
238 |
} |
|
239 |
foreach (var member; keys(me)) { |
|
poweroff improved
|
240 |
if (member == 'parents') |
241 |
continue; |
|
242 |
if (contains(me[member], 'parents')) { |
|
243 |
if (contains(me[member].parents[0], 'new') |
|
244 |
and typeof(me[member].parents[0].new) == 'func') { |
|
245 |
if (contains(me[member].parents[0], 'removeAllChildren') |
|
246 |
and !contains(me[member].parents[0], 'setVisible')) # this one is a props node, but not canvas |
|
247 |
me[member].removeAllChildren(); |
|
248 |
elsif (contains(me[member].parents[0], 'off') |
|
249 |
and typeof(me[member].parents[0].off) == 'func') |
|
250 |
me[member].off(); |
|
251 |
} |
|
252 |
} |
|
253 |
} |
|
254 |
foreach (var member; keys(me)) { |
|
255 |
if (member == 'parents') |
|
256 |
continue; |
|
add a way to power off
|
257 |
delete(me, member); |
258 |
} |
|
poweroff improved
|
259 |
zkv.getNode(name).setValue('status', 0); |
260 |
msg(name ~ ' switched off'); |
|
add a way to power off
|
261 |
}, |
commit initial
|
262 |
}; |
263 | ||
add a way to power off
|
264 |
var powerOff = func { |
poweroff improved
|
265 |
foreach (var listener; keys(data.listeners)) { |
266 |
if (listener == '/instrumentation/zkv1000/serviceable') |
|
267 |
continue; |
|
add autopwer
|
268 |
removelistener(data.listeners[listener]); |
poweroff improved
|
269 |
delete(data.listeners, listener); |
270 |
} |
|
add autopwer
|
271 | |
add a way to power off
|
272 |
foreach (var timer; keys(data.timers)) { |
273 |
data.timers[timer].stop(); |
|
poweroff improved
|
274 |
if (timer == '20Hz' or timer == '1Hz') |
275 |
continue; |
|
add a way to power off
|
276 |
delete(data.timers, timer); |
277 |
} |
|
add autopwer
|
278 | |
poweroff improved
|
279 |
foreach (var k; keys(autopilot)) |
280 |
delete(autopilot, k); |
|
281 | ||
add a way to power off
|
282 |
foreach (var name; keys(flightdeck)) { |
283 |
flightdeck[name].off(); |
|
poweroff improved
|
284 |
flightdeck[name] = nil; |
add a way to power off
|
285 |
} |
286 |
} |
|
287 | ||
PFD+MFD allumés ensemble
|
288 |
var powerOn = func { |
add a way to power off
|
289 |
if (!zkv.getValue('serviceable')) { |
290 |
msg('not yet serviceable (check power)!'); |
|
291 |
return; |
|
292 |
} |
|
293 | ||
poweroff improved
|
294 |
if (contains(data.listeners, '/instrumentation/zkv1000/serviceable')) { |
295 |
removelistener(data.listeners['/instrumentation/zkv1000/serviceable']); |
|
296 |
delete(data.listeners, '/instrumentation/zkv1000/serviceable'); |
|
297 |
} |
|
add autopwer
|
298 | |
global timers started at pow...
|
299 |
foreach (var freq; keys(data.timers)) |
300 |
data.timers[freq].start(); |
|
301 | ||
improves role/name variables...
|
302 |
foreach (var name; keys(flightdeck)) |
303 |
if (zkv.getNode(name) != nil) |
|
poweroff improved
|
304 |
if (zkv.getNode(name).getValue('status') == nil or zkv.getNode(name).getValue('status') == 0) |
new var organistaion (and fi...
|
305 |
# thread.newthread(func { |
improves role/name variables...
|
306 |
flightdeck[name] = deviceClass.new(name); |
new var organistaion (and fi...
|
307 |
# }); |
replace settimer by maketime...
|
308 | |
poweroff improved
|
309 |
if (! contains(autopilot, 'parents')) |
310 |
autopilot = APClass.new(); |
|
makes autopilot up after all...
|
311 | |
replace settimer by maketime...
|
312 |
if (! contains(data.timers, 'listeners')) { |
poweroff improved
|
313 |
data.timers.listeners = maketimer(1, setListeners); |
replace settimer by maketime...
|
314 |
data.timers.listeners.singleShot = 1; |
315 |
data.timers.listeners.start(); |
|
316 |
} |
|
commit initial
|
317 |
} |