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