commit initial
|
1 |
# Nasal files to be loaded at start |
2 |
# the order could be important as some files need other one to be loaded first |
|
3 |
files_to_load = [ |
|
4 |
'lib.nas', # some useful functions, should stay first loaded |
|
Correction swap NAV tuning
|
5 |
'radios.nas', # all about radios COMM, NAV, XPDR |
commit initial
|
6 |
'knobs.nas', # handles knobs |
7 |
'buttons.nas', # handles knobs and buttons |
|
8 |
'softkeys.nas',# handles softkeys and menus items |
|
adds route display on map
|
9 |
'maps/route.nas', |
separates maps code
|
10 |
'maps/navaids.nas', |
11 |
'maps/tiles.nas', |
|
add TCAS
|
12 |
'maps/tcas.nas', |
topo display is now availabl...
|
13 |
'maps/topo.nas', |
add track display
|
14 |
'maps/track.nas', |
adds Map on MFD
|
15 |
'map.nas', # moves the maps |
commit initial
|
16 |
'display.nas', |
add window management
|
17 |
'menu.nas', # manage windows |
commit initial
|
18 |
'core.nas', # the scheduler and switch on button |
adds AFCS
|
19 |
'afcs.nas', # Automatic Flight Control System |
adds alerting system
|
20 |
'annunciations.nas', # in flight tests |
commit initial
|
21 |
]; |
22 |
# 'routes.nas', # manages flightplans and routes |
|
23 |
# 'display.nas', # display messages and popups |
|
24 |
# 'infos.nas', # get informations from environment |
|
25 |
# 'mud.nas', # displays simple embedded GUI (Multi-Use Display) |
|
26 | ||
adds the avaibility to have ...
|
27 |
var flightdeck = {}; |
28 | ||
adds AFCS
|
29 |
var autopilot = {}; |
30 | ||
adds alerting system
|
31 |
var annunciations = {}; |
32 | ||
settings now have effect
|
33 |
var units = { |
34 |
speed : { |
|
35 |
from_kt : 1, |
|
36 |
from_kmh : MPS2KT * 3.6, |
|
37 |
}, |
|
38 |
altitude : { |
|
39 |
from_ft : 1, |
|
40 |
from_m : M2FT, |
|
41 |
}, |
|
42 |
vspeed : { |
|
43 |
from_fpm : 1, |
|
44 |
from_mpm : M2FT, |
|
45 |
}, |
|
46 |
distance : { |
|
47 |
from_m : M2NM / 1000, |
|
48 |
from_nm : 1, |
|
49 |
}, |
|
adds temperature units setti...
|
50 |
temperature : { |
51 |
from_C : func (c) return c, |
|
52 |
from_F : func (f) return (f -32) / 1.8, |
|
53 |
}, |
|
adds volume settings
|
54 |
volume: { |
55 |
from_l: 1, |
|
56 |
from_gal: 3.78541178, |
|
57 |
from_m3: 1000, |
|
58 |
}, |
|
settings now have effect
|
59 |
}; |
60 | ||
just moves data structure to...
|
61 |
var data = { # set of data common to all devices |
62 |
roll : 0, |
|
63 |
pitch : 0, |
|
64 |
vsi : 0, |
|
65 |
ias : 0, |
|
66 |
alt : 0, |
|
67 |
hdg : 0, |
|
add periodicly updated track...
|
68 |
trk : 0, |
just moves data structure to...
|
69 |
wow : 1, |
put lat/lon in global data s...
|
70 |
lat : 0, |
71 |
lon : 0, |
|
adds AOA display
|
72 |
aoa : 0, |
change way of time display
|
73 |
time : '23:59:59', |
adds flight plan catalog loa...
|
74 |
fpSize : 0, |
add TCAS
|
75 |
tcas: [], |
traffic alert and display
|
76 |
tcas_level: 0, |
makes Vspeeds free and adapt...
|
77 |
Vspeeds : {}, |
creates settings management
|
78 |
settings: { |
79 |
units: { |
|
80 |
pressure: 'inhg', |
|
81 |
altitude: 'ft', |
|
82 |
speed: 'knots', |
|
83 |
distance: 'nm', |
|
84 |
vertical: 'fpm', |
|
85 |
}, |
|
adds time display setting
|
86 |
time: { |
87 |
label: 'GMT', |
|
88 |
actual: ' GMT >', |
|
89 |
}, |
|
creates settings management
|
90 |
}, |
just moves data structure to...
|
91 |
timers : { |
92 |
'20Hz': maketimer ( |
|
93 |
0.05, |
|
94 |
func { |
|
95 |
data.roll = getprop('/orientation/roll-deg'); |
|
96 |
data.pitch = getprop('orientation/pitch-deg'); |
|
settings now have effect
|
97 |
data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm') * units.vspeed.from_fpm; |
98 |
data.ias = getprop('/velocities/airspeed-kt') * units.speed.from_kt; |
|
99 |
data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft') * units.altitude.from_ft; |
|
just moves data structure to...
|
100 |
data.hdg = getprop('/orientation/heading-deg'); |
add periodicly updated track...
|
101 |
data.trk = data.wow ? data.hdg : getprop('/orientation/track-deg'); |
adds AOA display
|
102 |
data.aoa = getprop('/orientation/alpha-deg'); |
just moves data structure to...
|
103 |
} |
104 |
), |
|
105 |
'1Hz': maketimer ( |
|
106 |
1, |
|
107 |
func { |
|
108 |
data.wow = getprop('/gear/gear/wow'); |
|
put lat/lon in global data s...
|
109 |
data.lat = getprop('/position/latitude-deg'); |
110 |
data.lon = getprop('/position/longitude-deg'); |
|
just moves data structure to...
|
111 |
} |
112 |
), |
|
113 |
}, |
|
listeners stored in data str...
|
114 |
listeners : {}, |
just moves data structure to...
|
115 |
}; |
116 | ||
fix setlistener on tied prop...
|
117 |
var zkv = cdi = radios = alerts = infos = cursors = afcs = eis = misc = nil; |
commit initial
|
118 | |
119 |
var init_props = func { |
|
120 |
zkv = props.globals.getNode('/instrumentation/zkv1000',1); |
|
adds the avaibility to have ...
|
121 |
foreach (var d; zkv.getChildren()) |
122 |
if (d.getNode('status') != nil) |
|
123 |
flightdeck[d.getName()] = nil; |
|
commit initial
|
124 |
zkv.getNode('emission',1).setDoubleValue(0.5); |
125 |
zkv.getNode('body-emission',1).setDoubleValue(0.0); |
|
126 |
zkv.getNode('body-texture',1).setValue(''); |
|
add brightness and lights co...
|
127 |
zkv.getNode('display-brightness-norm',1).setDoubleValue(0.5); |
128 |
zkv.getNode('lightmap',1).setIntValue(0); |
|
add possibility to resize th...
|
129 |
if (zkv.getNode('size-factor').getValue() == nil) |
130 |
zkv.getNode('size-factor',1).setDoubleValue(1.0); |
|
adds flight plan catalog loa...
|
131 |
if (zkv.getValue('flightplans') != nil and io.stat(zkv.getValue('flightplans')) == "dir") |
132 |
data.flightplans = zkv.getValue('flightplans'); |
|
133 |
else |
|
134 |
data.flightplans = getprop('/sim/fg-home') ~ '/Export'; |
|
commit initial
|
135 | |
136 |
radios = zkv.getNode('radios', 1); |
|
137 |
radios.getNode('nav1-selected',1).setIntValue(0); |
|
138 |
radios.getNode('nav1-standby',1).setIntValue(0); |
|
139 |
radios.getNode('nav2-selected',1).setIntValue(0); |
|
140 |
radios.getNode('nav2-standby',1).setIntValue(0); |
|
141 |
radios.getNode('nav-tune',1).setIntValue(0); |
|
142 |
radios.getNode('nav-freq-mhz',1).alias('/instrumentation/nav/frequencies/standby-mhz'); |
|
143 |
radios.getNode('comm1-selected',1).setIntValue(1); |
|
144 |
radios.getNode('comm2-selected',1).setIntValue(0); |
|
145 |
radios.getNode('comm-tune',1).setIntValue(0); |
|
146 |
radios.getNode('comm-freq-mhz',1).alias('/instrumentation/comm/frequencies/standby-mhz'); |
|
147 |
radios.getNode('xpdr-mode',1).setValue('GND'); |
|
adds BRG1/2 animation
|
148 |
radios.getNode('brg1-source',1).setValue('OFF'); |
149 |
radios.getNode('brg2-source',1).setValue('OFF'); |
|
commit initial
|
150 | |
adds CDI
|
151 |
cdi = zkv.getNode('cdi', 1); |
152 |
cdi.getNode('source', 1).setValue('OFF'); |
|
153 |
cdi.getNode('no-flag', 1).setBoolValue(0); |
|
154 |
cdi.getNode('FROM-flag', 1).alias('no-flag'); |
|
155 |
cdi.getNode('TO-flag', 1).alias('no-flag'); |
|
156 |
cdi.getNode('course', 1); |
|
157 |
cdi.getNode('course-deflection', 1); |
|
158 |
cdi.getNode('radial', 1); |
|
159 |
cdi.getNode('in-range', 1); |
|
160 | ||
commit initial
|
161 |
alerts = zkv.getNode('alerts',1); |
162 |
alerts.getNode('traffic-proximity',1).setIntValue(0); |
|
163 |
alerts.getNode('marker-beacon', 1).setIntValue(0); |
|
164 |
alerts.getNode('warning', 1).setBoolValue(0); |
|
165 |
alerts.getNode('alert', 1).setBoolValue(0); |
|
166 |
alerts.getNode('message', 1).setValue(''); |
|
makes Vspeeds free and adapt...
|
167 |
foreach (var v; alerts.getChildren()) |
168 |
if (string.match(v.getName(), 'V[a-z0-9]*')) |
|
169 |
data.Vspeeds[v.getName()] = v.getValue(); |
|
170 | ||
remove hardcoded properties ...
|
171 |
var aoa = alerts.getValue('stall-aoa'); |
adds AOA display
|
172 |
data['stall-aoa'] = (aoa == nil or aoa == 0) ? 9999 : aoa; |
remove hardcoded properties ...
|
173 |
aoa = alerts.getValue('approach-aoa'); |
nicer AOA display
|
174 |
if (aoa != nil) |
175 |
data['approach-aoa'] = aoa; |
|
commit initial
|
176 | |
177 |
afcs = zkv.getNode('afcs',1); |
|
178 |
afcs.getNode('fd-bars-visible',1).setBoolValue(0); |
|
179 |
afcs.getNode('alt-bug-visible',1).setBoolValue(0); |
|
fix heading bug deg previous...
|
180 |
afcs.getNode('heading-bug-deg',1).setDoubleValue(int(getprop('/orientation/heading-deg'))); |
commit initial
|
181 |
afcs.getNode('target-pitch-deg',1).setDoubleValue(0.0); |
adds OAT, TAS, GSPD, WindDat...
|
182 |
afcs.getNode('selected-alt-ft',1).setIntValue(2000); |
commit initial
|
183 |
afcs.getNode('selected-alt-ft-diff',1).setDoubleValue(0.0); |
184 |
afcs.getNode('selected-ias-kt-diff',1).setDoubleValue(0.0); |
|
185 |
afcs.getNode('vertical-speed-fpm',1).setDoubleValue(0.0); |
|
186 |
afcs.getNode('roll-armed', 1).setBoolValue(0); |
|
187 |
afcs.getNode('pitch-armed', 1).setBoolValue(0); |
|
188 |
afcs.getNode('roll-armed-mode-text',1).setValue(''); |
|
189 |
afcs.getNode('roll-active-mode-text',1).setValue(''); |
|
190 |
afcs.getNode('roll-armed-mode',1).setIntValue(0); |
|
191 |
afcs.getNode('roll-active-mode',1).setIntValue(0); |
|
192 |
afcs.getNode('roll-active-mode-blink',1).setBoolValue(0); |
|
193 |
afcs.getNode('pit-armed-mode-text',1).setValue(''); |
|
194 |
afcs.getNode('pit-active-mode-text',1).setValue(''); |
|
195 |
afcs.getNode('pit-armed-mode',1).setIntValue(0); |
|
196 |
afcs.getNode('pit-active-mode',1).setIntValue(0); |
|
197 |
afcs.getNode('pit-active-mode-blink',1).setBoolValue(0); |
|
198 |
afcs.getNode('route',1); |
|
199 | ||
adds flight plan catalog loa...
|
200 |
data.flightplans = getprop('/sim/fg-home') ~ '/Export'; |
201 | ||
fix setlistener on tied prop...
|
202 |
misc = zkv.getNode('misc',1); |
203 |
misc.getNode('alt-setting-inhg',1).setDoubleValue(getprop('/instrumentation/altimeter/setting-inhg')); |
|
204 | ||
animation texts EIS + power ...
|
205 |
eis = zkv.getNode('eis',1); |
206 |
eis.getNode('fuel-qty-at-start', 1).setValue( |
|
207 |
getprop('/consumables/fuel/tank/level-gal_us') |
|
208 |
+ getprop('/consumables/fuel/tank/level-gal_us')); |
|
209 | ||
moves some map infos in data...
|
210 |
var tiles_defaults = { |
211 |
# see https://www.wikimedia.org/wiki/Maps |
|
212 |
server: 'maps.wikimedia.org', |
|
213 |
type: 'osm-intl', |
|
214 |
apikey: '', |
|
add options for online tiles
|
215 |
format: 'png', |
216 |
template: 'https://{server}/{type}/{z}/{x}/{y}.{format}{apikey}', |
|
moves some map infos in data...
|
217 |
}; |
218 |
foreach (var v; keys(tiles_defaults)) { |
|
219 |
var val = getprop('/sim/online-tiles-' ~ v); |
|
220 |
data['tiles-' ~ v] = val != nil ? val : tiles_defaults[v]; |
|
221 |
} |
|
adds Map on MFD
|
222 | |
commit initial
|
223 |
props.globals.getNode('/instrumentation/transponder/id-code',1).setIntValue(1200); |
224 |
props.globals.getNode('/instrumentation/transponder/serviceable',1).setBoolValue(1); |
|
remove hardcoded properties ...
|
225 |
props.globals.getNode('/autopilot/settings/heading-bug-deg', 1).alias(afcs.getNode('heading-bug-deg').getPath()); |
afcs improvements
|
226 |
props.globals.getNode('/autopilot/settings/target-alt-ft',1).alias(afcs.getNode('selected-alt-ft').getPath()); |
commit initial
|
227 |
props.globals.getNode('/autopilot/settings/target-speed-kt',1).setDoubleValue(0.0); |
228 |
props.globals.getNode('/autopilot/settings/vertical-speed-fpm',1).setDoubleValue(0.0); |
|
229 |
props.globals.getNode('/autopilot/internal/target-pitch-deg',1).setDoubleValue(0.0); |
|
230 |
props.globals.getNode('/autopilot/internal/flc-altitude-pitch-deg',1).setDoubleValue(0.0); |
|
231 |
props.globals.getNode('/autopilot/internal/flc-airspeed-pitch-deg',1).setDoubleValue(0.0); |
|
232 |
props.globals.getNode('/autopilot/internal/target-roll-deg',1).setDoubleValue(0.0); |
|
233 |
props.globals.getNode('/autopilot/locks/pitch',1).setValue(''); |
|
234 |
props.globals.getNode('/autopilot/locks/roll',1).setValue(''); |
|
235 |
props.globals.getNode('/autopilot/locks/passive-mode', 1).setIntValue(1); |
|
path and relpath to zkv1000 ...
|
236 | |
allows zkv1000 to be install...
|
237 |
data.zkv1000_reldir = io.dirname(getprop('/nasal/zkv1000/file')); |
238 |
data.zkv1000_dir = string.normpath( |
|
239 |
io.dirname(getprop('/sim/aircraft-dir')) |
|
240 |
~ '/' |
|
241 |
~ string.replace(data.zkv1000_reldir, split('/', data.zkv1000_reldir)[0], '') |
|
242 |
) ~ '/'; |
|
commit initial
|
243 |
} |
244 | ||
245 |
var load_nasal = func { |
|
path and relpath to zkv1000 ...
|
246 |
var nasal_dir = data.zkv1000_dir ~ 'Nasal/'; |
commit initial
|
247 |
for (var i = 0; i < size(files_to_load); i += 1) |
path and relpath to zkv1000 ...
|
248 |
io.load_nasal(nasal_dir ~ files_to_load[i], 'zkv1000'); |
commit initial
|
249 |
files_to_load = nil; |
250 |
} |
|
251 | ||
252 |
var load_multikey = func { |
|
253 |
fgcommand('loadxml', props.Node.new({ |
|
path and relpath to zkv1000 ...
|
254 |
'filename': data.zkv1000_dir ~ 'Systems/multikey.xml', |
commit initial
|
255 |
'targetnode': '/input/keyboard/' |
256 |
})); |
|
257 |
multikey.init(); |
|
258 |
} |
|
259 | ||
adds settings storage and re...
|
260 |
var load_settings = func { |
261 |
var settings_file = getprop('/sim/fg-home') ~ '/aircraft-data/zkv1000.xml'; |
|
262 |
if (io.stat(settings_file) != nil) { |
|
263 |
fgcommand('loadxml', props.Node.new({ filename: settings_file, targetnode: zkv.getNode('save', 1).getPath() })); |
|
264 |
var xmlsettings = zkv.getNode('save/' ~ getprop('/sim/aircraft')); |
|
265 |
if (xmlsettings != nil) { |
|
266 |
foreach (var domain; keys(units)) |
|
267 |
foreach (var from; keys(units[domain])) { |
|
268 |
if (xmlsettings.getNode(domain) != nil) { |
|
269 |
var unit_value = xmlsettings.getNode(domain).getValue(from); |
|
270 |
if (unit_value != nil) { |
|
271 |
if (typeof(units[domain][from]) == 'scalar') |
|
272 |
units[domain][from] = unit_value; |
|
273 |
if (typeof(units[domain][from]) == 'func') { |
|
274 |
units[domain][from] = compile(unit_value); |
|
275 |
units[domain][from](0); |
|
276 |
} |
|
277 |
} |
|
278 |
} |
|
279 |
} |
|
280 |
data.settings.units.pressure = xmlsettings.getNode('pressure').getValue(); |
|
281 |
} |
|
282 |
zkv.getNode('save').remove(); |
|
283 |
} |
|
makes Vspeeds free and adapt...
|
284 |
foreach (var V; keys(data.Vspeeds)) |
285 |
data.Vspeeds[V] *= units.speed.from_kt; |
|
adds settings storage and re...
|
286 |
} |
287 | ||
commit initial
|
288 |
var zkv1000_init = func { |
init listener needed only on...
|
289 |
removelistener(init); |
commit initial
|
290 |
init_props(); |
adds settings storage and re...
|
291 |
load_settings(); |
path and relpath to zkv1000 ...
|
292 |
load_multikey(); |
adds AOA display
|
293 |
load_nasal(); |
improve auto-power
|
294 |
msg('loaded'); |
295 |
if (zkv.getValue('auto-power')) { |
|
296 |
var prop = zkv.getNode('serviceable',1).getPath(); |
|
297 |
data.listeners[prop] = setlistener(prop, zkv1000.powerOn, 0, 0); |
|
298 |
} |
|
commit initial
|
299 |
} |
300 | ||
init listener needed only on...
|
301 |
var init = setlistener('/sim/signals/fdm-initialized', zkv1000_init, 0, 0); |