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 | |
85 |
prop = zkv.getPath() ~ '/serviceable'; |
|
fix intempestive power off
|
86 |
data.listeners[prop] = setlistener(prop, func (n) if (!n.getValue()) zkv1000.powerOff, 0, 0); |
add a way to power off
|
87 | |
88 |
# the timer isn't necessary anymore |
|
89 |
data.timers.listeners.stop(); |
|
90 |
delete(data.timers, 'listeners'); |
|
NAV disponible (hors CDI)
|
91 |
} |
92 | ||
commit initial
|
93 |
var deviceClass = { |
improves role/name variables...
|
94 |
new: func (name) { |
commit initial
|
95 |
var m = { parents: [ deviceClass ] }; |
improves role/name variables...
|
96 |
m.name = name; |
97 |
m.role = substr(name, 0, 3); |
|
98 |
m.node = zkv.getNode(name, 1); |
|
add V-speeds bugs
|
99 |
m.data = {}; |
first attempt to centralize ...
|
100 |
m.timers = {}; |
put Vspeeds in common data s...
|
101 |
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) |
add V-speeds bugs
|
102 |
m.data[v ~ '-visible'] = 1; |
configurable display size, v...
|
103 |
foreach (var v; ['screen-object', 'screen-view', 'screen-size']) |
remove hardcoded properties ...
|
104 |
m.data[v] = getprop(zkv.getPath() ~ '/' ~ name ~ '/' ~ v); |
massive code reorganisation ...
|
105 | |
improves role/name variables...
|
106 |
m.display = displayClass.new(m); |
107 |
m.softkeys = softkeysClass.new(m); |
|
108 |
m.buttons = buttonsClass.new(m); |
|
XPDR settings via knob or so...
|
109 |
m.knobs = knobsClass.new(m); |
just a alignment
|
110 |
m.map = mapClass.new(m); |
TMR/REF window
|
111 |
m.windows = pageClass.new(m); |
massive code reorganisation ...
|
112 | |
fix setlistener on tied prop...
|
113 |
if (! contains(data.timers, 'alt-setting-inhg')) { |
114 |
data.timers['alt-setting-inhg'] = maketimer(0.1, m, func { |
|
115 |
var inhg = getprop('/instrumentation/altimeter/setting-inhg'); |
|
116 |
if (inhg != misc.getValue('alt-setting-inhg')) |
|
117 |
misc.getNode('alt-setting-inhg').setValue(inhg); |
|
118 |
}); |
|
119 |
data.timers['alt-setting-inhg'].start(); |
|
120 |
} |
|
massive code reorganisation ...
|
121 |
if (! contains(data.timers, 'map')) { |
122 |
data.timers.map = maketimer(1, m, func { |
|
123 |
foreach (var d; keys(flightdeck)) |
|
124 |
flightdeck[d].map.update(); |
|
125 |
var gspd = getprop('/velocities/groundspeed-kt'); |
|
126 |
if (gspd != 0) |
|
127 |
var next = (me.data['range-nm']/(gspd/3600))/(me.display.display.get('view[1]')/2); |
|
128 |
else |
|
129 |
var next = 10; |
|
130 |
if (next > 10) |
|
131 |
next = 10; |
|
132 |
data.timers.map.restart(next); |
|
133 |
}); |
|
134 |
data.timers.map.singleShot = 1; |
|
135 |
data.timers.map.start(); |
|
136 |
} |
|
add TCAS
|
137 |
if (getprop('/instrumentation/tcas/serviceable') != nil) { |
138 |
m.data.tcas = 0; |
|
139 |
if (!contains(data.timers, 'tcas')) { |
|
140 |
data.timers.tcas = maketimer ( 1, |
|
141 |
func { |
|
142 |
var tcas_dirty = []; |
|
143 |
var _range = 6; |
|
144 |
var _minLevel = -1; |
|
145 |
foreach (var ac; props.globals.getNode("/ai/models").getChildren("multiplayer")) { |
|
146 |
if (ac.getValue("valid")) { |
|
147 |
var range = ac.getNode("radar/range-nm").getValue(); |
|
148 |
if (range != nil) { |
|
149 |
if (debug.isnan(range) == 0) { |
|
150 |
if ( (range > 0) and (range <= _range) ) { |
|
151 |
var nTcasThreat = ac.getNode("tcas/threat-level"); |
|
152 |
if (nTcasThreat != nil) { |
|
153 |
var level = nTcasThreat.getValue(); |
|
154 |
if (level > _minLevel) { |
|
155 |
var lat = ac.getNode("position/latitude-deg").getValue(); |
|
156 |
var lon = ac.getNode("position/longitude-deg").getValue(); |
|
157 |
var aAlt = ac.getNode("position/altitude-ft").getValue(); |
|
158 |
var vs = ac.getNode("velocities/vertical-speed-fps").getValue(); |
|
159 |
var alt = math.floor(((aAlt - data.alt) / 100) + 0.5); |
|
160 |
if (debug.isnan(lat) == 0 and |
|
161 |
debug.isnan(lon) == 0 and |
|
162 |
debug.isnan(vs) == 0 and |
|
163 |
debug.isnan(alt) == 0) { |
|
164 |
append(tcas_dirty, { |
|
165 |
lat: lat, |
|
166 |
lon: lon, |
|
167 |
vs: vs, |
|
168 |
alt: alt, |
|
169 |
level: level, |
|
170 |
}); |
|
171 |
} } } } } } } } |
|
172 |
data.tcas = tcas_dirty; |
|
173 |
} |
|
174 |
); |
|
175 |
data.timers.tcas.start(); |
|
176 |
} |
|
177 |
} |
|
178 |
else { |
|
179 |
delete(m.softkeys.bindings.PFD.INSET, 'TRAFFIC'); |
|
180 |
delete(m.softkeys.bindings.MFD.MAP, 'TRAFFIC'); |
|
181 |
} |
|
massive code reorganisation ...
|
182 |
m.display.showInitProgress(); |
183 | ||
remove hardcoded properties ...
|
184 |
setprop(zkv.getPath() ~ '/' ~ m.name ~ '/status', 1); |
improves role/name variables...
|
185 |
msg(m.name ~ ' switched on!'); |
commit initial
|
186 |
return m; |
187 |
}, |
|
add a way to power off
|
188 |
off: func { |
189 |
foreach (var timer; keys(me.timers)) { |
|
190 |
me.timers[timer].stop(); |
|
191 |
delete(me.timers, timer); |
|
192 |
} |
|
193 |
foreach (var member; keys(me)) { |
|
194 |
if (contains(me[member], 'off')) me[class].off(); |
|
195 |
delete(me, member); |
|
196 |
} |
|
197 |
}, |
|
commit initial
|
198 |
}; |
199 | ||
add a way to power off
|
200 |
var powerOff = func { |
add autopwer
|
201 |
foreach (var listener; keys(data.listeners)) |
202 |
removelistener(data.listeners[listener]); |
|
203 | ||
add a way to power off
|
204 |
foreach (var timer; keys(data.timers)) { |
205 |
data.timers[timer].stop(); |
|
206 |
delete(data.timers, timer); |
|
207 |
} |
|
add autopwer
|
208 | |
add a way to power off
|
209 |
foreach (var name; keys(flightdeck)) { |
210 |
flightdeck[name].off(); |
|
211 |
delete(flightdeck, name); |
|
212 |
setprop(zkv.getPath() ~ '/' ~ name ~ '/status', 0); |
|
213 |
} |
|
214 |
} |
|
215 | ||
PFD+MFD allumés ensemble
|
216 |
var powerOn = func { |
add a way to power off
|
217 |
if (!zkv.getValue('serviceable')) { |
218 |
msg('not yet serviceable (check power)!'); |
|
219 |
return; |
|
220 |
} |
|
221 | ||
add autopwer
|
222 |
if (contains(data.listeners, 'autopower')) |
223 |
removelistener(data.listeners.autopower); |
|
224 | ||
global timers started at pow...
|
225 |
foreach (var freq; keys(data.timers)) |
226 |
data.timers[freq].start(); |
|
227 | ||
adds AFCS
|
228 |
autopilot = APClass.new(); |
229 | ||
improves role/name variables...
|
230 |
foreach (var name; keys(flightdeck)) |
231 |
if (zkv.getNode(name) != nil) |
|
new var organistaion (and fi...
|
232 |
# thread.newthread(func { |
improves role/name variables...
|
233 |
flightdeck[name] = deviceClass.new(name); |
new var organistaion (and fi...
|
234 |
# }); |
replace settimer by maketime...
|
235 | |
236 |
if (! contains(data.timers, 'listeners')) { |
|
237 |
data.timers.listeners = maketimer(5, setListeners); |
|
238 |
data.timers.listeners.singleShot = 1; |
|
239 |
data.timers.listeners.start(); |
|
240 |
} |
|
commit initial
|
241 |
} |