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