zkv1000 / zkv1000.nas /
Newer Older
202 lines | 8.698kb
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
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
9
    'map.nas',     # moves the maps
commit initial
Sébastien MARQUE authored on 2017-03-07
10
    'display.nas',
add window management
Sébastien MARQUE authored on 2017-03-28
11
    'menu.nas',    # manage windows
commit initial
Sébastien MARQUE authored on 2017-03-07
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 ...
Sébastien MARQUE authored on 2017-04-07
21
var flightdeck = {};
22

            
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
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...
Sébastien MARQUE authored on 2017-04-12
31
    lat : 0,
32
    lon : 0,
adds AOA display
Sébastien MARQUE authored on 2017-04-15
33
    aoa : 0,
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
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
Sébastien MARQUE authored on 2017-04-15
44
                data.aoa = getprop('/orientation/alpha-deg');
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
45
            }
46
        ),
47
        '1Hz': maketimer (
48
            1,
49
            func {
50
                data.wow = getprop('/gear/gear/wow');
put lat/lon in global data s...
Sébastien MARQUE authored on 2017-04-12
51
                data.lat = getprop('/position/latitude-deg');
52
                data.lon = getprop('/position/longitude-deg');
just moves data structure to...
Sébastien MARQUE authored on 2017-04-11
53
            }
54
        ),
55
    },
56
};
57

            
commit initial
Sébastien MARQUE authored on 2017-03-07
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 ...
Sébastien MARQUE authored on 2017-04-07
62
    foreach (var d; zkv.getChildren())
63
        if (d.getNode('status') != nil)
64
            flightdeck[d.getName()] = nil;
commit initial
Sébastien MARQUE authored on 2017-03-07
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
Sébastien MARQUE authored on 2017-03-16
82
    radios.getNode('brg1-source',1).setValue('OFF');
83
    radios.getNode('brg2-source',1).setValue('OFF');
commit initial
Sébastien MARQUE authored on 2017-03-07
84

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
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
Sébastien MARQUE authored on 2017-03-07
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...
Sébastien MARQUE authored on 2017-04-11
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
Sébastien MARQUE authored on 2017-04-15
105
    var aoa = getprop('/instrumentation/zkv1000/alerts/stall-aoa');
106
    data['stall-aoa'] = (aoa == nil or aoa == 0) ? 9999 : aoa;
nicer AOA display
Sébastien MARQUE authored on 2017-04-16
107
    aoa = getprop('/instrumentation/zkv1000/alerts/approach-aoa');
108
    if (aoa != nil)
109
        data['approach-aoa'] = aoa;
commit initial
Sébastien MARQUE authored on 2017-03-07
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...
Sébastien MARQUE authored on 2017-03-15
116
    afcs.getNode('selected-alt-ft',1).setIntValue(2000);
commit initial
Sébastien MARQUE authored on 2017-03-07
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 ...
Sébastien MARQUE authored on 2017-03-19
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
Sébastien MARQUE authored on 2017-03-20
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...
Sébastien MARQUE authored on 2017-04-13
149
    setprop('/sim/gui/dialogs/map-canvas/aircraft-heading-up', 1);
moves some map infos in data...
Sébastien MARQUE authored on 2017-04-11
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
Sébastien MARQUE authored on 2017-03-20
160

            
commit initial
Sébastien MARQUE authored on 2017-03-07
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 ...
Sébastien MARQUE authored on 2017-04-17
174

            
175
    data.zkv1000_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/';
176
    data.zkv1000_reldir = 'Aircraft/Instruments-3d/zkv1000/';
commit initial
Sébastien MARQUE authored on 2017-03-07
177
}
178

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

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

            
194
var zkv1000_init = func {
init listener needed only on...
Sébastien MARQUE authored on 2017-03-13
195
    removelistener(init);
commit initial
Sébastien MARQUE authored on 2017-03-07
196
    init_props();
path and relpath to zkv1000 ...
Sébastien MARQUE authored on 2017-04-17
197
    load_multikey();
adds AOA display
Sébastien MARQUE authored on 2017-04-15
198
    load_nasal();
commit initial
Sébastien MARQUE authored on 2017-03-07
199
    print('zkv1000 loaded');
200
}
201

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