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