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 |
}, |
|
settings now have effect
|
51 |
}; |
52 | ||
just moves data structure to...
|
53 |
var data = { # set of data common to all devices |
54 |
roll : 0, |
|
55 |
pitch : 0, |
|
56 |
vsi : 0, |
|
57 |
ias : 0, |
|
58 |
alt : 0, |
|
59 |
hdg : 0, |
|
60 |
wow : 1, |
|
put lat/lon in global data s...
|
61 |
lat : 0, |
62 |
lon : 0, |
|
adds AOA display
|
63 |
aoa : 0, |
change way of time display
|
64 |
time : '23:59:59', |
adds flight plan catalog loa...
|
65 |
fpSize : 0, |
add TCAS
|
66 |
tcas: [], |
traffic alert and display
|
67 |
tcas_level: 0, |
creates settings management
|
68 |
settings: { |
69 |
units: { |
|
70 |
pressure: 'inhg', |
|
71 |
altitude: 'ft', |
|
72 |
speed: 'knots', |
|
73 |
distance: 'nm', |
|
74 |
vertical: 'fpm', |
|
75 |
}, |
|
adds time display setting
|
76 |
time: { |
77 |
label: 'GMT', |
|
78 |
actual: ' GMT >', |
|
79 |
}, |
|
creates settings management
|
80 |
}, |
just moves data structure to...
|
81 |
timers : { |
82 |
'20Hz': maketimer ( |
|
83 |
0.05, |
|
84 |
func { |
|
85 |
data.roll = getprop('/orientation/roll-deg'); |
|
86 |
data.pitch = getprop('orientation/pitch-deg'); |
|
settings now have effect
|
87 |
data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm') * units.vspeed.from_fpm; |
88 |
data.ias = getprop('/velocities/airspeed-kt') * units.speed.from_kt; |
|
89 |
data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft') * units.altitude.from_ft; |
|
just moves data structure to...
|
90 |
data.hdg = getprop('/orientation/heading-deg'); |
adds AOA display
|
91 |
data.aoa = getprop('/orientation/alpha-deg'); |
just moves data structure to...
|
92 |
} |
93 |
), |
|
94 |
'1Hz': maketimer ( |
|
95 |
1, |
|
96 |
func { |
|
97 |
data.wow = getprop('/gear/gear/wow'); |
|
put lat/lon in global data s...
|
98 |
data.lat = getprop('/position/latitude-deg'); |
99 |
data.lon = getprop('/position/longitude-deg'); |
|
just moves data structure to...
|
100 |
} |
101 |
), |
|
102 |
}, |
|
listeners stored in data str...
|
103 |
listeners : {}, |
just moves data structure to...
|
104 |
}; |
105 | ||
fix setlistener on tied prop...
|
106 |
var zkv = cdi = radios = alerts = infos = cursors = afcs = eis = misc = nil; |
commit initial
|
107 | |
108 |
var init_props = func { |
|
109 |
zkv = props.globals.getNode('/instrumentation/zkv1000',1); |
|
adds the avaibility to have ...
|
110 |
foreach (var d; zkv.getChildren()) |
111 |
if (d.getNode('status') != nil) |
|
112 |
flightdeck[d.getName()] = nil; |
|
commit initial
|
113 |
zkv.getNode('emission',1).setDoubleValue(0.5); |
114 |
zkv.getNode('body-emission',1).setDoubleValue(0.0); |
|
115 |
zkv.getNode('body-texture',1).setValue(''); |
|
add brightness and lights co...
|
116 |
zkv.getNode('display-brightness-norm',1).setDoubleValue(0.5); |
117 |
zkv.getNode('lightmap',1).setIntValue(0); |
|
add possibility to resize th...
|
118 |
if (zkv.getNode('size-factor').getValue() == nil) |
119 |
zkv.getNode('size-factor',1).setDoubleValue(1.0); |
|
adds flight plan catalog loa...
|
120 |
if (zkv.getValue('flightplans') != nil and io.stat(zkv.getValue('flightplans')) == "dir") |
121 |
data.flightplans = zkv.getValue('flightplans'); |
|
122 |
else |
|
123 |
data.flightplans = getprop('/sim/fg-home') ~ '/Export'; |
|
commit initial
|
124 | |
125 |
radios = zkv.getNode('radios', 1); |
|
126 |
radios.getNode('nav1-selected',1).setIntValue(0); |
|
127 |
radios.getNode('nav1-standby',1).setIntValue(0); |
|
128 |
radios.getNode('nav2-selected',1).setIntValue(0); |
|
129 |
radios.getNode('nav2-standby',1).setIntValue(0); |
|
130 |
radios.getNode('nav-tune',1).setIntValue(0); |
|
131 |
radios.getNode('nav-freq-mhz',1).alias('/instrumentation/nav/frequencies/standby-mhz'); |
|
132 |
radios.getNode('comm1-selected',1).setIntValue(1); |
|
133 |
radios.getNode('comm2-selected',1).setIntValue(0); |
|
134 |
radios.getNode('comm-tune',1).setIntValue(0); |
|
135 |
radios.getNode('comm-freq-mhz',1).alias('/instrumentation/comm/frequencies/standby-mhz'); |
|
136 |
radios.getNode('xpdr-mode',1).setValue('GND'); |
|
adds BRG1/2 animation
|
137 |
radios.getNode('brg1-source',1).setValue('OFF'); |
138 |
radios.getNode('brg2-source',1).setValue('OFF'); |
|
commit initial
|
139 | |
adds CDI
|
140 |
cdi = zkv.getNode('cdi', 1); |
141 |
cdi.getNode('source', 1).setValue('OFF'); |
|
142 |
cdi.getNode('no-flag', 1).setBoolValue(0); |
|
143 |
cdi.getNode('FROM-flag', 1).alias('no-flag'); |
|
144 |
cdi.getNode('TO-flag', 1).alias('no-flag'); |
|
145 |
cdi.getNode('course', 1); |
|
146 |
cdi.getNode('course-deflection', 1); |
|
147 |
cdi.getNode('radial', 1); |
|
148 |
cdi.getNode('in-range', 1); |
|
149 | ||
commit initial
|
150 |
alerts = zkv.getNode('alerts',1); |
151 |
alerts.getNode('traffic-proximity',1).setIntValue(0); |
|
152 |
alerts.getNode('marker-beacon', 1).setIntValue(0); |
|
153 |
alerts.getNode('warning', 1).setBoolValue(0); |
|
154 |
alerts.getNode('alert', 1).setBoolValue(0); |
|
155 |
alerts.getNode('message', 1).setValue(''); |
|
put Vspeeds in common data s...
|
156 |
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide', 'Vne']) { |
settings now have effect
|
157 |
var speed = alerts.getValue(v) * units.speed.from_kt; |
put Vspeeds in common data s...
|
158 |
data[v] = speed != nil ? speed : 9999; |
159 |
} |
|
remove hardcoded properties ...
|
160 |
var aoa = alerts.getValue('stall-aoa'); |
adds AOA display
|
161 |
data['stall-aoa'] = (aoa == nil or aoa == 0) ? 9999 : aoa; |
remove hardcoded properties ...
|
162 |
aoa = alerts.getValue('approach-aoa'); |
nicer AOA display
|
163 |
if (aoa != nil) |
164 |
data['approach-aoa'] = aoa; |
|
commit initial
|
165 | |
166 |
afcs = zkv.getNode('afcs',1); |
|
167 |
afcs.getNode('fd-bars-visible',1).setBoolValue(0); |
|
168 |
afcs.getNode('alt-bug-visible',1).setBoolValue(0); |
|
afcs improvements
|
169 |
afcs.getNode('heading-bug-deg',1).setDoubleValue(int(getprop('/orientation/heading-magnetic-deg'))); |
commit initial
|
170 |
afcs.getNode('target-pitch-deg',1).setDoubleValue(0.0); |
adds OAT, TAS, GSPD, WindDat...
|
171 |
afcs.getNode('selected-alt-ft',1).setIntValue(2000); |
commit initial
|
172 |
afcs.getNode('selected-alt-ft-diff',1).setDoubleValue(0.0); |
173 |
afcs.getNode('selected-ias-kt-diff',1).setDoubleValue(0.0); |
|
174 |
afcs.getNode('vertical-speed-fpm',1).setDoubleValue(0.0); |
|
175 |
afcs.getNode('roll-armed', 1).setBoolValue(0); |
|
176 |
afcs.getNode('pitch-armed', 1).setBoolValue(0); |
|
177 |
afcs.getNode('roll-armed-mode-text',1).setValue(''); |
|
178 |
afcs.getNode('roll-active-mode-text',1).setValue(''); |
|
179 |
afcs.getNode('roll-armed-mode',1).setIntValue(0); |
|
180 |
afcs.getNode('roll-active-mode',1).setIntValue(0); |
|
181 |
afcs.getNode('roll-active-mode-blink',1).setBoolValue(0); |
|
182 |
afcs.getNode('pit-armed-mode-text',1).setValue(''); |
|
183 |
afcs.getNode('pit-active-mode-text',1).setValue(''); |
|
184 |
afcs.getNode('pit-armed-mode',1).setIntValue(0); |
|
185 |
afcs.getNode('pit-active-mode',1).setIntValue(0); |
|
186 |
afcs.getNode('pit-active-mode-blink',1).setBoolValue(0); |
|
187 |
afcs.getNode('route',1); |
|
188 | ||
adds flight plan catalog loa...
|
189 |
data.flightplans = getprop('/sim/fg-home') ~ '/Export'; |
190 | ||
fix setlistener on tied prop...
|
191 |
misc = zkv.getNode('misc',1); |
192 |
misc.getNode('alt-setting-inhg',1).setDoubleValue(getprop('/instrumentation/altimeter/setting-inhg')); |
|
193 | ||
animation texts EIS + power ...
|
194 |
eis = zkv.getNode('eis',1); |
195 |
eis.getNode('fuel-qty-at-start', 1).setValue( |
|
196 |
getprop('/consumables/fuel/tank/level-gal_us') |
|
197 |
+ getprop('/consumables/fuel/tank/level-gal_us')); |
|
198 | ||
moves some map infos in data...
|
199 |
var tiles_defaults = { |
200 |
# see https://www.wikimedia.org/wiki/Maps |
|
201 |
server: 'maps.wikimedia.org', |
|
202 |
type: 'osm-intl', |
|
203 |
apikey: '', |
|
add options for online tiles
|
204 |
format: 'png', |
205 |
template: 'https://{server}/{type}/{z}/{x}/{y}.{format}{apikey}', |
|
moves some map infos in data...
|
206 |
}; |
207 |
foreach (var v; keys(tiles_defaults)) { |
|
208 |
var val = getprop('/sim/online-tiles-' ~ v); |
|
209 |
data['tiles-' ~ v] = val != nil ? val : tiles_defaults[v]; |
|
210 |
} |
|
adds Map on MFD
|
211 | |
commit initial
|
212 |
props.globals.getNode('/instrumentation/transponder/id-code',1).setIntValue(1200); |
213 |
props.globals.getNode('/instrumentation/transponder/serviceable',1).setBoolValue(1); |
|
remove hardcoded properties ...
|
214 |
props.globals.getNode('/autopilot/settings/heading-bug-deg', 1).alias(afcs.getNode('heading-bug-deg').getPath()); |
afcs improvements
|
215 |
props.globals.getNode('/autopilot/settings/target-alt-ft',1).alias(afcs.getNode('selected-alt-ft').getPath()); |
commit initial
|
216 |
props.globals.getNode('/autopilot/settings/target-speed-kt',1).setDoubleValue(0.0); |
217 |
props.globals.getNode('/autopilot/settings/vertical-speed-fpm',1).setDoubleValue(0.0); |
|
218 |
props.globals.getNode('/autopilot/internal/target-pitch-deg',1).setDoubleValue(0.0); |
|
219 |
props.globals.getNode('/autopilot/internal/flc-altitude-pitch-deg',1).setDoubleValue(0.0); |
|
220 |
props.globals.getNode('/autopilot/internal/flc-airspeed-pitch-deg',1).setDoubleValue(0.0); |
|
221 |
props.globals.getNode('/autopilot/internal/target-roll-deg',1).setDoubleValue(0.0); |
|
222 |
props.globals.getNode('/autopilot/locks/pitch',1).setValue(''); |
|
223 |
props.globals.getNode('/autopilot/locks/roll',1).setValue(''); |
|
224 |
props.globals.getNode('/autopilot/locks/passive-mode', 1).setIntValue(1); |
|
path and relpath to zkv1000 ...
|
225 | |
allows zkv1000 to be install...
|
226 |
data.zkv1000_reldir = io.dirname(getprop('/nasal/zkv1000/file')); |
227 |
data.zkv1000_dir = string.normpath( |
|
228 |
io.dirname(getprop('/sim/aircraft-dir')) |
|
229 |
~ '/' |
|
230 |
~ string.replace(data.zkv1000_reldir, split('/', data.zkv1000_reldir)[0], '') |
|
231 |
) ~ '/'; |
|
commit initial
|
232 |
} |
233 | ||
234 |
var load_nasal = func { |
|
path and relpath to zkv1000 ...
|
235 |
var nasal_dir = data.zkv1000_dir ~ 'Nasal/'; |
commit initial
|
236 |
for (var i = 0; i < size(files_to_load); i += 1) |
path and relpath to zkv1000 ...
|
237 |
io.load_nasal(nasal_dir ~ files_to_load[i], 'zkv1000'); |
commit initial
|
238 |
files_to_load = nil; |
239 |
} |
|
240 | ||
241 |
var load_multikey = func { |
|
242 |
fgcommand('loadxml', props.Node.new({ |
|
path and relpath to zkv1000 ...
|
243 |
'filename': data.zkv1000_dir ~ 'Systems/multikey.xml', |
commit initial
|
244 |
'targetnode': '/input/keyboard/' |
245 |
})); |
|
246 |
multikey.init(); |
|
247 |
} |
|
248 | ||
249 |
var zkv1000_init = func { |
|
init listener needed only on...
|
250 |
removelistener(init); |
commit initial
|
251 |
init_props(); |
path and relpath to zkv1000 ...
|
252 |
load_multikey(); |
adds AOA display
|
253 |
load_nasal(); |
improve auto-power
|
254 |
msg('loaded'); |
255 |
if (zkv.getValue('auto-power')) { |
|
256 |
var prop = zkv.getNode('serviceable',1).getPath(); |
|
257 |
data.listeners[prop] = setlistener(prop, zkv1000.powerOn, 0, 0); |
|
258 |
} |
|
commit initial
|
259 |
} |
260 | ||
init listener needed only on...
|
261 |
var init = setlistener('/sim/signals/fdm-initialized', zkv1000_init, 0, 0); |