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 = {}; |
put Vspeeds in common data s...
|
141 |
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) |
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)) |
|
181 |
traffic_displayed += flightdeck[name].map.layers.tcas.group.getVisible(); |
|
182 |
var tcas_dirty = []; |
|
183 |
var level_dirty = 0; |
|
184 |
foreach (var AItype; [ 'aircraft', 'multiplayer' ]) |
|
185 |
foreach (var ac; props.globals.getNode("/ai/models").getChildren(AItype)) { |
|
186 |
if (ac.getValue("valid")) { |
|
187 |
var lat = ac.getNode("position/latitude-deg").getValue(); |
|
188 |
var lon = ac.getNode("position/longitude-deg").getValue(); |
|
189 |
var alt = ac.getNode("position/altitude-ft").getValue(); |
|
190 |
var vs = ac.getNode("velocities/vertical-speed-fps").getValue(); |
|
191 |
if (isnum(lat) and isnum(lon) and isnum(vs) and isnum(alt)) { |
|
192 |
alt = math.floor(((alt - data.alt) / 100) + 0.5); |
|
193 |
var (course, dist) = courseAndDistance(lat, lon, |
|
194 |
geo.Coord.new().set_latlon(data.lat, data.lon)); |
|
195 |
if (dist < 50) { |
|
196 |
var dir = ac.getNode('orientation/true-heading-deg').getValue() - course; |
|
197 |
if (dist < 5 and abs(alt) < 10) |
|
198 |
level = 3; |
|
199 |
elsif (dist < 10 and alt * vs < 0 and abs(dir) < 10) |
|
200 |
level = 3; |
|
201 |
elsif (dist < 15 and abs(alt) < 5) |
|
202 |
level = 2; |
|
203 |
elsif (dist < 15 and abs(alt) < 50) |
|
204 |
level = 1; |
|
205 |
else |
|
206 |
level = 0; |
|
207 |
level_dirty = level > level_dirty ? level : level_dirty; |
|
208 |
if (traffic_displayed) |
|
209 |
append(tcas_dirty, { |
|
210 |
lat: lat, |
|
211 |
lon: lon, |
|
212 |
vs: vs, |
|
213 |
alt: alt, |
|
214 |
level: level, |
|
215 |
callsign: ac.getValue('callsign') |
|
216 |
}); |
|
217 |
} |
|
218 |
} |
|
219 |
} |
|
add TCAS
|
220 |
} |
traffic alert and display
|
221 |
data.tcas = tcas_dirty; |
222 |
data.tcas_level = level_dirty; |
|
223 |
}); |
|
224 |
data.timers.tcas.start(); |
|
add TCAS
|
225 |
} |
massive code reorganisation ...
|
226 |
m.display.showInitProgress(); |
227 | ||
remove hardcoded properties ...
|
228 |
setprop(zkv.getPath() ~ '/' ~ m.name ~ '/status', 1); |
improves role/name variables...
|
229 |
msg(m.name ~ ' switched on!'); |
commit initial
|
230 |
return m; |
231 |
}, |
|
add a way to power off
|
232 |
off: func { |
poweroff improved
|
233 |
var name = me.name; |
add a way to power off
|
234 |
foreach (var timer; keys(me.timers)) { |
235 |
me.timers[timer].stop(); |
|
236 |
delete(me.timers, timer); |
|
237 |
} |
|
238 |
foreach (var member; keys(me)) { |
|
poweroff improved
|
239 |
if (member == 'parents') |
240 |
continue; |
|
241 |
if (contains(me[member], 'parents')) { |
|
242 |
if (contains(me[member].parents[0], 'new') |
|
243 |
and typeof(me[member].parents[0].new) == 'func') { |
|
244 |
if (contains(me[member].parents[0], 'removeAllChildren') |
|
245 |
and !contains(me[member].parents[0], 'setVisible')) # this one is a props node, but not canvas |
|
246 |
me[member].removeAllChildren(); |
|
247 |
elsif (contains(me[member].parents[0], 'off') |
|
248 |
and typeof(me[member].parents[0].off) == 'func') |
|
249 |
me[member].off(); |
|
250 |
} |
|
251 |
} |
|
252 |
} |
|
253 |
foreach (var member; keys(me)) { |
|
254 |
if (member == 'parents') |
|
255 |
continue; |
|
add a way to power off
|
256 |
delete(me, member); |
257 |
} |
|
poweroff improved
|
258 |
zkv.getNode(name).setValue('status', 0); |
259 |
msg(name ~ ' switched off'); |
|
add a way to power off
|
260 |
}, |
commit initial
|
261 |
}; |
262 | ||
add a way to power off
|
263 |
var powerOff = func { |
poweroff improved
|
264 |
foreach (var listener; keys(data.listeners)) { |
265 |
if (listener == '/instrumentation/zkv1000/serviceable') |
|
266 |
continue; |
|
add autopwer
|
267 |
removelistener(data.listeners[listener]); |
poweroff improved
|
268 |
delete(data.listeners, listener); |
269 |
} |
|
add autopwer
|
270 | |
add a way to power off
|
271 |
foreach (var timer; keys(data.timers)) { |
272 |
data.timers[timer].stop(); |
|
poweroff improved
|
273 |
if (timer == '20Hz' or timer == '1Hz') |
274 |
continue; |
|
add a way to power off
|
275 |
delete(data.timers, timer); |
276 |
} |
|
add autopwer
|
277 | |
poweroff improved
|
278 |
foreach (var k; keys(autopilot)) |
279 |
delete(autopilot, k); |
|
280 | ||
add a way to power off
|
281 |
foreach (var name; keys(flightdeck)) { |
282 |
flightdeck[name].off(); |
|
poweroff improved
|
283 |
flightdeck[name] = nil; |
add a way to power off
|
284 |
} |
285 |
} |
|
286 | ||
PFD+MFD allumés ensemble
|
287 |
var powerOn = func { |
add a way to power off
|
288 |
if (!zkv.getValue('serviceable')) { |
289 |
msg('not yet serviceable (check power)!'); |
|
290 |
return; |
|
291 |
} |
|
292 | ||
poweroff improved
|
293 |
if (contains(data.listeners, '/instrumentation/zkv1000/serviceable')) { |
294 |
removelistener(data.listeners['/instrumentation/zkv1000/serviceable']); |
|
295 |
delete(data.listeners, '/instrumentation/zkv1000/serviceable'); |
|
296 |
} |
|
add autopwer
|
297 | |
global timers started at pow...
|
298 |
foreach (var freq; keys(data.timers)) |
299 |
data.timers[freq].start(); |
|
300 | ||
improves role/name variables...
|
301 |
foreach (var name; keys(flightdeck)) |
302 |
if (zkv.getNode(name) != nil) |
|
poweroff improved
|
303 |
if (zkv.getNode(name).getValue('status') == nil or zkv.getNode(name).getValue('status') == 0) |
new var organistaion (and fi...
|
304 |
# thread.newthread(func { |
improves role/name variables...
|
305 |
flightdeck[name] = deviceClass.new(name); |
new var organistaion (and fi...
|
306 |
# }); |
replace settimer by maketime...
|
307 | |
poweroff improved
|
308 |
if (! contains(autopilot, 'parents')) |
309 |
autopilot = APClass.new(); |
|
makes autopilot up after all...
|
310 | |
replace settimer by maketime...
|
311 |
if (! contains(data.timers, 'listeners')) { |
poweroff improved
|
312 |
data.timers.listeners = maketimer(1, setListeners); |
replace settimer by maketime...
|
313 |
data.timers.listeners.singleShot = 1; |
314 |
data.timers.listeners.start(); |
|
315 |
} |
|
commit initial
|
316 |
} |