zkv1000 / zkv1000.nas /
Newer Older
208 lines | 8.901kb
commit initial
Sébastien MARQUE authored on 2017-03-07
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
Sébastien MARQUE authored on 2017-03-12
5
    'radios.nas',  # all about radios COMM, NAV, XPDR
commit initial
Sébastien MARQUE authored on 2017-03-07
6
    'knobs.nas',   # handles knobs
7
    'buttons.nas', # handles knobs and buttons
8
    'softkeys.nas',# handles softkeys and menus items
separates maps code
Sébastien MARQUE authored on 2017-05-11
9
    'maps/navaids.nas',
10
    'maps/tiles.nas',
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
11
    'map.nas',     # moves the maps
commit initial
Sébastien MARQUE authored on 2017-03-07
12
    'display.nas',
add window management
Sébastien MARQUE authored on 2017-03-28
13
    'menu.nas',    # manage windows
commit initial
Sébastien MARQUE authored on 2017-03-07
14
    'core.nas',    # the scheduler and switch on button
15
];
16
#    'afcs.nas',    # Automatic Flight Control System
17
#    'routes.nas',  # manages flightplans and routes
18
#    'display.nas', # display messages and popups
19
#    'infos.nas',   # get informations from environment
20
#    'alerts.nas',  # in flight tests
21
#    'mud.nas',     # displays simple embedded GUI (Multi-Use Display)
22

            
adds the avaibility to have ...
Sébastien MARQUE authored on 2017-04-07
23
var flightdeck = {};
24

            
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
25
var data = { # set of data common to all devices
26
    roll : 0,
27
    pitch : 0,
28
    vsi : 0,
29
    ias : 0,
30
    alt : 0,
31
    hdg : 0,
32
    wow : 1,
put lat/lon in global data s...
Sébastien MARQUE authored on 2017-04-12
33
    lat : 0,
34
    lon : 0,
adds AOA display
Sébastien MARQUE authored on 2017-04-15
35
    aoa : 0,
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
36
    timers : {
37
        '20Hz': maketimer (
38
            0.05,
39
            func {
40
                data.roll = getprop('/orientation/roll-deg');
41
                data.pitch = getprop('orientation/pitch-deg');
42
                data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
43
                data.ias = getprop('/velocities/airspeed-kt');
44
                data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
45
                data.hdg = getprop('/orientation/heading-deg');
adds AOA display
Sébastien MARQUE authored on 2017-04-15
46
                data.aoa = getprop('/orientation/alpha-deg');
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
47
            }
48
        ),
49
        '1Hz': maketimer (
50
            1,
51
            func {
52
                data.wow = getprop('/gear/gear/wow');
put lat/lon in global data s...
Sébastien MARQUE authored on 2017-04-12
53
                data.lat = getprop('/position/latitude-deg');
54
                data.lon = getprop('/position/longitude-deg');
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
55
            }
56
        ),
57
    },
listeners stored in data str...
Sébastien MARQUE authored on 2017-05-06
58
    listeners : {},
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
59
};
60

            
commit initial
Sébastien MARQUE authored on 2017-03-07
61
var zkv = cdi = radios = alerts = infos = cursors = afcs = eis = nil;
62

            
63
var init_props = func {
64
    zkv = props.globals.getNode('/instrumentation/zkv1000',1);
adds the avaibility to have ...
Sébastien MARQUE authored on 2017-04-07
65
    foreach (var d; zkv.getChildren())
66
        if (d.getNode('status') != nil)
67
            flightdeck[d.getName()] = nil;
commit initial
Sébastien MARQUE authored on 2017-03-07
68
    zkv.getNode('emission',1).setDoubleValue(0.5);
69
    zkv.getNode('body-emission',1).setDoubleValue(0.0);
70
    zkv.getNode('body-texture',1).setValue('');
71
    zkv.getNode('display-brightness-norm',1).setValue(0.5);
72

            
73
    radios = zkv.getNode('radios', 1);
74
    radios.getNode('nav1-selected',1).setIntValue(0);
75
    radios.getNode('nav1-standby',1).setIntValue(0);
76
    radios.getNode('nav2-selected',1).setIntValue(0);
77
    radios.getNode('nav2-standby',1).setIntValue(0);
78
    radios.getNode('nav-tune',1).setIntValue(0);
79
    radios.getNode('nav-freq-mhz',1).alias('/instrumentation/nav/frequencies/standby-mhz');
80
    radios.getNode('comm1-selected',1).setIntValue(1);
81
    radios.getNode('comm2-selected',1).setIntValue(0);
82
    radios.getNode('comm-tune',1).setIntValue(0);
83
    radios.getNode('comm-freq-mhz',1).alias('/instrumentation/comm/frequencies/standby-mhz');
84
    radios.getNode('xpdr-mode',1).setValue('GND');
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
85
    radios.getNode('brg1-source',1).setValue('OFF');
86
    radios.getNode('brg2-source',1).setValue('OFF');
commit initial
Sébastien MARQUE authored on 2017-03-07
87

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
88
    cdi = zkv.getNode('cdi', 1);
89
    cdi.getNode('source', 1).setValue('OFF');
90
    cdi.getNode('no-flag', 1).setBoolValue(0);
91
    cdi.getNode('FROM-flag', 1).alias('no-flag');
92
    cdi.getNode('TO-flag', 1).alias('no-flag');
93
    cdi.getNode('course', 1);
94
    cdi.getNode('course-deflection', 1);
95
    cdi.getNode('radial', 1);
96
    cdi.getNode('in-range', 1);
97

            
commit initial
Sébastien MARQUE authored on 2017-03-07
98
    alerts = zkv.getNode('alerts',1);
99
    alerts.getNode('traffic-proximity',1).setIntValue(0);
100
    alerts.getNode('marker-beacon', 1).setIntValue(0);
101
    alerts.getNode('warning', 1).setBoolValue(0);
102
    alerts.getNode('alert', 1).setBoolValue(0);
103
    alerts.getNode('message', 1).setValue('');
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
104
    foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide', 'Vne']) {
105
        var speed = getprop('/instrumentation/zkv1000/alerts/' ~ v);
106
        data[v] = speed != nil ? speed : 9999;
107
    }
adds AOA display
Sébastien MARQUE authored on 2017-04-15
108
    var aoa = getprop('/instrumentation/zkv1000/alerts/stall-aoa');
109
    data['stall-aoa'] = (aoa == nil or aoa == 0) ? 9999 : aoa;
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
110
    aoa = getprop('/instrumentation/zkv1000/alerts/approach-aoa');
111
    if (aoa != nil)
112
        data['approach-aoa'] = aoa;
commit initial
Sébastien MARQUE authored on 2017-03-07
113

            
114
    afcs = zkv.getNode('afcs',1);
115
    afcs.getNode('fd-bars-visible',1).setBoolValue(0);
116
    afcs.getNode('alt-bug-visible',1).setBoolValue(0);
117
    afcs.getNode('heading-bug-deg',1).setDoubleValue(getprop('/orientation/heading-magnetic-deg'));
118
    afcs.getNode('target-pitch-deg',1).setDoubleValue(0.0);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
119
    afcs.getNode('selected-alt-ft',1).setIntValue(2000);
commit initial
Sébastien MARQUE authored on 2017-03-07
120
    afcs.getNode('selected-alt-ft-diff',1).setDoubleValue(0.0);
121
    afcs.getNode('selected-ias-kt-diff',1).setDoubleValue(0.0);
122
    afcs.getNode('vertical-speed-fpm',1).setDoubleValue(0.0);
123
    afcs.getNode('roll-armed', 1).setBoolValue(0);
124
    afcs.getNode('pitch-armed', 1).setBoolValue(0);
125
    afcs.getNode('roll-armed-mode-text',1).setValue('');
126
    afcs.getNode('roll-active-mode-text',1).setValue('');
127
    afcs.getNode('roll-armed-mode',1).setIntValue(0);
128
    afcs.getNode('roll-active-mode',1).setIntValue(0);
129
    afcs.getNode('roll-active-mode-blink',1).setBoolValue(0);
130
    afcs.getNode('pit-armed-mode-text',1).setValue('');
131
    afcs.getNode('pit-active-mode-text',1).setValue('');
132
    afcs.getNode('pit-armed-mode',1).setIntValue(0);
133
    afcs.getNode('pit-active-mode',1).setIntValue(0);
134
    afcs.getNode('pit-active-mode-blink',1).setBoolValue(0);
135
    afcs.getNode('route',1);
136

            
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
137
    eis = zkv.getNode('eis',1);
138
    eis.getNode('fuel-qty-at-start', 1).setValue(
139
        getprop('/consumables/fuel/tank/level-gal_us')
140
      + getprop('/consumables/fuel/tank/level-gal_us'));
141

            
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
142
    setprop('/sim/gui/dialogs/map-canvas/draw-APT', 1);
143
    setprop('/sim/gui/dialogs/map-canvas/draw-FIX', 1);
144
    setprop('/sim/gui/dialogs/map-canvas/draw-VOR', 1);
145
    setprop('/sim/gui/dialogs/map-canvas/draw-DME', 1);
146
    setprop('/sim/gui/dialogs/map-canvas/draw-NDB', 1);
147
    setprop('/sim/gui/dialogs/map-canvas/draw-TFC', 1);
148
    setprop('/sim/gui/dialogs/map-canvas/draw-data', 1);
149
    setprop('/sim/gui/dialogs/map-canvas/draw-FLT', 1);
150
    setprop('/sim/gui/dialogs/map-canvas/draw-WXR', 1);
151
    setprop('/sim/gui/dialogs/map-canvas/draw-TUT', 1);
no heading up for maps by de...
Sébastien MARQUE authored on 2017-04-13
152
    setprop('/sim/gui/dialogs/map-canvas/aircraft-heading-up', 1);
moves some map infos in data...
Sébastien MARQUE authored on 2017-04-11
153
    var tiles_defaults = {
154
        # see https://www.wikimedia.org/wiki/Maps
155
        server: 'maps.wikimedia.org',
156
        type:   'osm-intl',
157
        apikey: '',
158
    };
159
    foreach (var v; keys(tiles_defaults)) {
160
        var val = getprop('/sim/online-tiles-' ~ v);
161
        data['tiles-' ~ v] = val != nil ? val : tiles_defaults[v];
162
    }
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
163

            
commit initial
Sébastien MARQUE authored on 2017-03-07
164
    props.globals.getNode('/instrumentation/transponder/id-code',1).setIntValue(1200);
165
    props.globals.getNode('/instrumentation/transponder/serviceable',1).setBoolValue(1);
166
    props.globals.getNode('/autopilot/settings/heading-bug-deg', 1).alias('/instrumentation/zkv1000/afcs/heading-bug-deg');
167
    props.globals.getNode('/autopilot/settings/target-altitude-ft',1).setDoubleValue(0.0);
168
    props.globals.getNode('/autopilot/settings/target-speed-kt',1).setDoubleValue(0.0);
169
    props.globals.getNode('/autopilot/settings/vertical-speed-fpm',1).setDoubleValue(0.0);
170
    props.globals.getNode('/autopilot/internal/target-pitch-deg',1).setDoubleValue(0.0);
171
    props.globals.getNode('/autopilot/internal/flc-altitude-pitch-deg',1).setDoubleValue(0.0);
172
    props.globals.getNode('/autopilot/internal/flc-airspeed-pitch-deg',1).setDoubleValue(0.0);
173
    props.globals.getNode('/autopilot/internal/target-roll-deg',1).setDoubleValue(0.0);
174
    props.globals.getNode('/autopilot/locks/pitch',1).setValue('');
175
    props.globals.getNode('/autopilot/locks/roll',1).setValue('');
176
    props.globals.getNode('/autopilot/locks/passive-mode', 1).setIntValue(1);
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
177

            
178
    data.zkv1000_reldir = 'Aircraft/Instruments-3d/zkv1000/';
/sim/fg-aircraft isn't alway...
Sébastien MARQUE authored on 2017-04-18
179
    if (getprop('/sim/fg-aircraft') != nil)
180
        data.zkv1000_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/';
181
    else
182
        data.zkv1000_dir = getprop('/sim/fg-root') ~ '/' ~ data.zkv1000_reldir;
commit initial
Sébastien MARQUE authored on 2017-03-07
183
}
184

            
185
var load_nasal = func {
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
186
    var nasal_dir = data.zkv1000_dir ~ 'Nasal/';
commit initial
Sébastien MARQUE authored on 2017-03-07
187
    for (var i = 0; i < size(files_to_load); i += 1)
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
188
        io.load_nasal(nasal_dir ~ files_to_load[i], 'zkv1000');
commit initial
Sébastien MARQUE authored on 2017-03-07
189
    files_to_load = nil;
190
}
191

            
192
var load_multikey = func {
193
    fgcommand('loadxml', props.Node.new({
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
194
        'filename': data.zkv1000_dir ~ 'Systems/multikey.xml',
commit initial
Sébastien MARQUE authored on 2017-03-07
195
        'targetnode': '/input/keyboard/'
196
    }));
197
    multikey.init();
198
}
199

            
200
var zkv1000_init = func {
init listener needed only on...
Sébastien MARQUE authored on 2017-03-13
201
    removelistener(init);
commit initial
Sébastien MARQUE authored on 2017-03-07
202
    init_props();
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
203
    load_multikey();
adds AOA display
Sébastien MARQUE authored on 2017-04-15
204
    load_nasal();
commit initial
Sébastien MARQUE authored on 2017-03-07
205
    print('zkv1000 loaded');
206
}
207

            
init listener needed only on...
Sébastien MARQUE authored on 2017-03-13
208
var init = setlistener('/sim/signals/fdm-initialized', zkv1000_init, 0, 0);