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, |
|
just moves data structure to...
|
33 |
timers : { |
34 |
'20Hz': maketimer ( |
|
35 |
0.05, |
|
36 |
func { |
|
37 |
data.roll = getprop('/orientation/roll-deg'); |
|
38 |
data.pitch = getprop('orientation/pitch-deg'); |
|
39 |
data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm'); |
|
40 |
data.ias = getprop('/velocities/airspeed-kt'); |
|
41 |
data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft'); |
|
42 |
data.hdg = getprop('/orientation/heading-deg'); |
|
43 |
} |
|
44 |
), |
|
45 |
'1Hz': maketimer ( |
|
46 |
1, |
|
47 |
func { |
|
48 |
data.wow = getprop('/gear/gear/wow'); |
|
put lat/lon in global data s...
|
49 |
data.lat = getprop('/position/latitude-deg'); |
50 |
data.lon = getprop('/position/longitude-deg'); |
|
just moves data structure to...
|
51 |
} |
52 |
), |
|
53 |
}, |
|
54 |
}; |
|
55 | ||
commit initial
|
56 |
var zkv = cdi = radios = alerts = infos = cursors = afcs = eis = nil; |
57 | ||
58 |
var init_props = func { |
|
59 |
zkv = props.globals.getNode('/instrumentation/zkv1000',1); |
|
adds the avaibility to have ...
|
60 |
foreach (var d; zkv.getChildren()) |
61 |
if (d.getNode('status') != nil) |
|
62 |
flightdeck[d.getName()] = nil; |
|
commit initial
|
63 |
zkv.getNode('emission',1).setDoubleValue(0.5); |
64 |
zkv.getNode('body-emission',1).setDoubleValue(0.0); |
|
65 |
zkv.getNode('body-texture',1).setValue(''); |
|
66 |
zkv.getNode('display-brightness-norm',1).setValue(0.5); |
|
67 | ||
68 |
radios = zkv.getNode('radios', 1); |
|
69 |
radios.getNode('nav1-selected',1).setIntValue(0); |
|
70 |
radios.getNode('nav1-standby',1).setIntValue(0); |
|
71 |
radios.getNode('nav2-selected',1).setIntValue(0); |
|
72 |
radios.getNode('nav2-standby',1).setIntValue(0); |
|
73 |
radios.getNode('nav-tune',1).setIntValue(0); |
|
74 |
radios.getNode('nav-freq-mhz',1).alias('/instrumentation/nav/frequencies/standby-mhz'); |
|
75 |
radios.getNode('comm1-selected',1).setIntValue(1); |
|
76 |
radios.getNode('comm2-selected',1).setIntValue(0); |
|
77 |
radios.getNode('comm-tune',1).setIntValue(0); |
|
78 |
radios.getNode('comm-freq-mhz',1).alias('/instrumentation/comm/frequencies/standby-mhz'); |
|
79 |
radios.getNode('xpdr-mode',1).setValue('GND'); |
|
adds BRG1/2 animation
|
80 |
radios.getNode('brg1-source',1).setValue('OFF'); |
81 |
radios.getNode('brg2-source',1).setValue('OFF'); |
|
commit initial
|
82 | |
adds CDI
|
83 |
cdi = zkv.getNode('cdi', 1); |
84 |
cdi.getNode('source', 1).setValue('OFF'); |
|
85 |
cdi.getNode('no-flag', 1).setBoolValue(0); |
|
86 |
cdi.getNode('FROM-flag', 1).alias('no-flag'); |
|
87 |
cdi.getNode('TO-flag', 1).alias('no-flag'); |
|
88 |
cdi.getNode('course', 1); |
|
89 |
cdi.getNode('course-deflection', 1); |
|
90 |
cdi.getNode('radial', 1); |
|
91 |
cdi.getNode('in-range', 1); |
|
92 | ||
commit initial
|
93 |
alerts = zkv.getNode('alerts',1); |
94 |
alerts.getNode('traffic-proximity',1).setIntValue(0); |
|
95 |
alerts.getNode('marker-beacon', 1).setIntValue(0); |
|
96 |
alerts.getNode('warning', 1).setBoolValue(0); |
|
97 |
alerts.getNode('alert', 1).setBoolValue(0); |
|
98 |
alerts.getNode('message', 1).setValue(''); |
|
put Vspeeds in common data s...
|
99 |
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide', 'Vne']) { |
100 |
var speed = getprop('/instrumentation/zkv1000/alerts/' ~ v); |
|
101 |
data[v] = speed != nil ? speed : 9999; |
|
102 |
} |
|
commit initial
|
103 | |
104 |
afcs = zkv.getNode('afcs',1); |
|
105 |
afcs.getNode('fd-bars-visible',1).setBoolValue(0); |
|
106 |
afcs.getNode('alt-bug-visible',1).setBoolValue(0); |
|
107 |
afcs.getNode('heading-bug-deg',1).setDoubleValue(getprop('/orientation/heading-magnetic-deg')); |
|
108 |
afcs.getNode('target-pitch-deg',1).setDoubleValue(0.0); |
|
adds OAT, TAS, GSPD, WindDat...
|
109 |
afcs.getNode('selected-alt-ft',1).setIntValue(2000); |
commit initial
|
110 |
afcs.getNode('selected-alt-ft-diff',1).setDoubleValue(0.0); |
111 |
afcs.getNode('selected-ias-kt-diff',1).setDoubleValue(0.0); |
|
112 |
afcs.getNode('vertical-speed-fpm',1).setDoubleValue(0.0); |
|
113 |
afcs.getNode('roll-armed', 1).setBoolValue(0); |
|
114 |
afcs.getNode('pitch-armed', 1).setBoolValue(0); |
|
115 |
afcs.getNode('roll-armed-mode-text',1).setValue(''); |
|
116 |
afcs.getNode('roll-active-mode-text',1).setValue(''); |
|
117 |
afcs.getNode('roll-armed-mode',1).setIntValue(0); |
|
118 |
afcs.getNode('roll-active-mode',1).setIntValue(0); |
|
119 |
afcs.getNode('roll-active-mode-blink',1).setBoolValue(0); |
|
120 |
afcs.getNode('pit-armed-mode-text',1).setValue(''); |
|
121 |
afcs.getNode('pit-active-mode-text',1).setValue(''); |
|
122 |
afcs.getNode('pit-armed-mode',1).setIntValue(0); |
|
123 |
afcs.getNode('pit-active-mode',1).setIntValue(0); |
|
124 |
afcs.getNode('pit-active-mode-blink',1).setBoolValue(0); |
|
125 |
afcs.getNode('route',1); |
|
126 | ||
animation texts EIS + power ...
|
127 |
eis = zkv.getNode('eis',1); |
128 |
eis.getNode('fuel-qty-at-start', 1).setValue( |
|
129 |
getprop('/consumables/fuel/tank/level-gal_us') |
|
130 |
+ getprop('/consumables/fuel/tank/level-gal_us')); |
|
131 | ||
adds Map on MFD
|
132 |
setprop('/sim/gui/dialogs/map-canvas/draw-APT', 1); |
133 |
setprop('/sim/gui/dialogs/map-canvas/draw-FIX', 1); |
|
134 |
setprop('/sim/gui/dialogs/map-canvas/draw-VOR', 1); |
|
135 |
setprop('/sim/gui/dialogs/map-canvas/draw-DME', 1); |
|
136 |
setprop('/sim/gui/dialogs/map-canvas/draw-NDB', 1); |
|
137 |
setprop('/sim/gui/dialogs/map-canvas/draw-TFC', 1); |
|
138 |
setprop('/sim/gui/dialogs/map-canvas/draw-data', 1); |
|
139 |
setprop('/sim/gui/dialogs/map-canvas/draw-FLT', 1); |
|
140 |
setprop('/sim/gui/dialogs/map-canvas/draw-WXR', 1); |
|
141 |
setprop('/sim/gui/dialogs/map-canvas/draw-TUT', 1); |
|
no heading up for maps by de...
|
142 |
setprop('/sim/gui/dialogs/map-canvas/aircraft-heading-up', 1); |
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: '', |
|
148 |
}; |
|
149 |
foreach (var v; keys(tiles_defaults)) { |
|
150 |
var val = getprop('/sim/online-tiles-' ~ v); |
|
151 |
data['tiles-' ~ v] = val != nil ? val : tiles_defaults[v]; |
|
152 |
} |
|
adds Map on MFD
|
153 | |
commit initial
|
154 |
props.globals.getNode('/instrumentation/transponder/id-code',1).setIntValue(1200); |
155 |
props.globals.getNode('/instrumentation/transponder/serviceable',1).setBoolValue(1); |
|
156 |
props.globals.getNode('/autopilot/settings/heading-bug-deg', 1).alias('/instrumentation/zkv1000/afcs/heading-bug-deg'); |
|
157 |
props.globals.getNode('/autopilot/settings/target-altitude-ft',1).setDoubleValue(0.0); |
|
158 |
props.globals.getNode('/autopilot/settings/target-speed-kt',1).setDoubleValue(0.0); |
|
159 |
props.globals.getNode('/autopilot/settings/vertical-speed-fpm',1).setDoubleValue(0.0); |
|
160 |
props.globals.getNode('/autopilot/internal/target-pitch-deg',1).setDoubleValue(0.0); |
|
161 |
props.globals.getNode('/autopilot/internal/flc-altitude-pitch-deg',1).setDoubleValue(0.0); |
|
162 |
props.globals.getNode('/autopilot/internal/flc-airspeed-pitch-deg',1).setDoubleValue(0.0); |
|
163 |
props.globals.getNode('/autopilot/internal/target-roll-deg',1).setDoubleValue(0.0); |
|
164 |
props.globals.getNode('/autopilot/locks/pitch',1).setValue(''); |
|
165 |
props.globals.getNode('/autopilot/locks/roll',1).setValue(''); |
|
166 |
props.globals.getNode('/autopilot/locks/passive-mode', 1).setIntValue(1); |
|
167 |
} |
|
168 | ||
169 |
var load_nasal = func { |
|
170 |
var zkv1000_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/'; |
|
171 |
for (var i = 0; i < size(files_to_load); i += 1) |
|
172 |
io.load_nasal(zkv1000_dir ~ files_to_load[i], 'zkv1000'); |
|
173 |
files_to_load = nil; |
|
174 |
} |
|
175 | ||
176 |
var load_multikey = func { |
|
177 |
fgcommand('loadxml', props.Node.new({ |
|
178 |
'filename': getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Systems/multikey.xml', |
|
179 |
'targetnode': '/input/keyboard/' |
|
180 |
})); |
|
181 |
multikey.init(); |
|
182 |
} |
|
183 | ||
184 |
var zkv1000_init = func { |
|
init listener needed only on...
|
185 |
removelistener(init); |
commit initial
|
186 |
load_multikey(); |
187 |
load_nasal(); |
|
188 |
init_props(); |
|
189 |
print('zkv1000 loaded'); |
|
190 |
} |
|
191 | ||
init listener needed only on...
|
192 |
var init = setlistener('/sim/signals/fdm-initialized', zkv1000_init, 0, 0); |