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