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