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