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