zkv1000 / zkv1000.nas /
Newer Older
188 lines | 8.148kb
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,
31
    timers : {
32
        '20Hz': maketimer (
33
            0.05,
34
            func {
35
                data.roll = getprop('/orientation/roll-deg');
36
                data.pitch = getprop('orientation/pitch-deg');
37
                data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
38
                data.ias = getprop('/velocities/airspeed-kt');
39
                data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
40
                data.hdg = getprop('/orientation/heading-deg');
41
            }
42
        ),
43
        '1Hz': maketimer (
44
            1,
45
            func {
46
                data.wow = getprop('/gear/gear/wow');
47
            }
48
        ),
49
    },
50
};
51

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

            
54
var init_props = func {
55
    zkv = props.globals.getNode('/instrumentation/zkv1000',1);
adds the avaibility to have ...
Sébastien MARQUE authored on 2017-04-07
56
    foreach (var d; zkv.getChildren())
57
        if (d.getNode('status') != nil)
58
            flightdeck[d.getName()] = nil;
commit initial
Sébastien MARQUE authored on 2017-03-07
59
    zkv.getNode('emission',1).setDoubleValue(0.5);
60
    zkv.getNode('body-emission',1).setDoubleValue(0.0);
61
    zkv.getNode('body-texture',1).setValue('');
62
    zkv.getNode('display-brightness-norm',1).setValue(0.5);
63

            
64
    radios = zkv.getNode('radios', 1);
65
    radios.getNode('nav1-selected',1).setIntValue(0);
66
    radios.getNode('nav1-standby',1).setIntValue(0);
67
    radios.getNode('nav2-selected',1).setIntValue(0);
68
    radios.getNode('nav2-standby',1).setIntValue(0);
69
    radios.getNode('nav-tune',1).setIntValue(0);
70
    radios.getNode('nav-freq-mhz',1).alias('/instrumentation/nav/frequencies/standby-mhz');
71
    radios.getNode('comm1-selected',1).setIntValue(1);
72
    radios.getNode('comm2-selected',1).setIntValue(0);
73
    radios.getNode('comm-tune',1).setIntValue(0);
74
    radios.getNode('comm-freq-mhz',1).alias('/instrumentation/comm/frequencies/standby-mhz');
75
    radios.getNode('xpdr-mode',1).setValue('GND');
adds BRG1/2 animation
Sébastien MARQUE authored on 2017-03-16
76
    radios.getNode('brg1-source',1).setValue('OFF');
77
    radios.getNode('brg2-source',1).setValue('OFF');
commit initial
Sébastien MARQUE authored on 2017-03-07
78

            
adds CDI
Sébastien MARQUE authored on 2017-03-18
79
    cdi = zkv.getNode('cdi', 1);
80
    cdi.getNode('source', 1).setValue('OFF');
81
    cdi.getNode('no-flag', 1).setBoolValue(0);
82
    cdi.getNode('FROM-flag', 1).alias('no-flag');
83
    cdi.getNode('TO-flag', 1).alias('no-flag');
84
    cdi.getNode('course', 1);
85
    cdi.getNode('course-deflection', 1);
86
    cdi.getNode('radial', 1);
87
    cdi.getNode('in-range', 1);
88

            
commit initial
Sébastien MARQUE authored on 2017-03-07
89
    alerts = zkv.getNode('alerts',1);
90
    alerts.getNode('traffic-proximity',1).setIntValue(0);
91
    alerts.getNode('marker-beacon', 1).setIntValue(0);
92
    alerts.getNode('warning', 1).setBoolValue(0);
93
    alerts.getNode('alert', 1).setBoolValue(0);
94
    alerts.getNode('message', 1).setValue('');
put Vspeeds in common data s...
Sébastien MARQUE authored on 2017-04-11
95
    foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide', 'Vne']) {
96
        var speed = getprop('/instrumentation/zkv1000/alerts/' ~ v);
97
        data[v] = speed != nil ? speed : 9999;
98
    }
commit initial
Sébastien MARQUE authored on 2017-03-07
99

            
100
    afcs = zkv.getNode('afcs',1);
101
    afcs.getNode('fd-bars-visible',1).setBoolValue(0);
102
    afcs.getNode('alt-bug-visible',1).setBoolValue(0);
103
    afcs.getNode('heading-bug-deg',1).setDoubleValue(getprop('/orientation/heading-magnetic-deg'));
104
    afcs.getNode('target-pitch-deg',1).setDoubleValue(0.0);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
105
    afcs.getNode('selected-alt-ft',1).setIntValue(2000);
commit initial
Sébastien MARQUE authored on 2017-03-07
106
    afcs.getNode('selected-alt-ft-diff',1).setDoubleValue(0.0);
107
    afcs.getNode('selected-ias-kt-diff',1).setDoubleValue(0.0);
108
    afcs.getNode('vertical-speed-fpm',1).setDoubleValue(0.0);
109
    afcs.getNode('roll-armed', 1).setBoolValue(0);
110
    afcs.getNode('pitch-armed', 1).setBoolValue(0);
111
    afcs.getNode('roll-armed-mode-text',1).setValue('');
112
    afcs.getNode('roll-active-mode-text',1).setValue('');
113
    afcs.getNode('roll-armed-mode',1).setIntValue(0);
114
    afcs.getNode('roll-active-mode',1).setIntValue(0);
115
    afcs.getNode('roll-active-mode-blink',1).setBoolValue(0);
116
    afcs.getNode('pit-armed-mode-text',1).setValue('');
117
    afcs.getNode('pit-active-mode-text',1).setValue('');
118
    afcs.getNode('pit-armed-mode',1).setIntValue(0);
119
    afcs.getNode('pit-active-mode',1).setIntValue(0);
120
    afcs.getNode('pit-active-mode-blink',1).setBoolValue(0);
121
    afcs.getNode('route',1);
122

            
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
123
    eis = zkv.getNode('eis',1);
124
    eis.getNode('fuel-qty-at-start', 1).setValue(
125
        getprop('/consumables/fuel/tank/level-gal_us')
126
      + getprop('/consumables/fuel/tank/level-gal_us'));
127

            
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
128
    setprop('/sim/gui/dialogs/map-canvas/draw-APT', 1);
129
    setprop('/sim/gui/dialogs/map-canvas/draw-FIX', 1);
130
    setprop('/sim/gui/dialogs/map-canvas/draw-VOR', 1);
131
    setprop('/sim/gui/dialogs/map-canvas/draw-DME', 1);
132
    setprop('/sim/gui/dialogs/map-canvas/draw-NDB', 1);
133
    setprop('/sim/gui/dialogs/map-canvas/draw-TFC', 1);
134
    setprop('/sim/gui/dialogs/map-canvas/draw-data', 1);
135
    setprop('/sim/gui/dialogs/map-canvas/draw-FLT', 1);
136
    setprop('/sim/gui/dialogs/map-canvas/draw-WXR', 1);
137
    setprop('/sim/gui/dialogs/map-canvas/draw-TUT', 1);
138
    setprop('/sim/gui/dialogs/map-canvas/aircraft-heading-up', 0);
moves some map infos in data...
Sébastien MARQUE authored on 2017-04-11
139
    var tiles_defaults = {
140
        # see https://www.wikimedia.org/wiki/Maps
141
        server: 'maps.wikimedia.org',
142
        type:   'osm-intl',
143
        apikey: '',
144
    };
145
    foreach (var v; keys(tiles_defaults)) {
146
        var val = getprop('/sim/online-tiles-' ~ v);
147
        data['tiles-' ~ v] = val != nil ? val : tiles_defaults[v];
148
    }
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
149

            
commit initial
Sébastien MARQUE authored on 2017-03-07
150
    props.globals.getNode('/instrumentation/transponder/id-code',1).setIntValue(1200);
151
    props.globals.getNode('/instrumentation/transponder/serviceable',1).setBoolValue(1);
152
    props.globals.getNode('/autopilot/settings/heading-bug-deg', 1).alias('/instrumentation/zkv1000/afcs/heading-bug-deg');
153
    props.globals.getNode('/autopilot/settings/target-altitude-ft',1).setDoubleValue(0.0);
154
    props.globals.getNode('/autopilot/settings/target-speed-kt',1).setDoubleValue(0.0);
155
    props.globals.getNode('/autopilot/settings/vertical-speed-fpm',1).setDoubleValue(0.0);
156
    props.globals.getNode('/autopilot/internal/target-pitch-deg',1).setDoubleValue(0.0);
157
    props.globals.getNode('/autopilot/internal/flc-altitude-pitch-deg',1).setDoubleValue(0.0);
158
    props.globals.getNode('/autopilot/internal/flc-airspeed-pitch-deg',1).setDoubleValue(0.0);
159
    props.globals.getNode('/autopilot/internal/target-roll-deg',1).setDoubleValue(0.0);
160
    props.globals.getNode('/autopilot/locks/pitch',1).setValue('');
161
    props.globals.getNode('/autopilot/locks/roll',1).setValue('');
162
    props.globals.getNode('/autopilot/locks/passive-mode', 1).setIntValue(1);
163
}
164

            
165
var load_nasal = func {
166
    var zkv1000_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/';
167
    for (var i = 0; i < size(files_to_load); i += 1)
168
        io.load_nasal(zkv1000_dir ~ files_to_load[i], 'zkv1000');
169
    files_to_load = nil;
170
}
171

            
172
var load_multikey = func {
173
    fgcommand('loadxml', props.Node.new({
174
        'filename': getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Systems/multikey.xml',
175
        'targetnode': '/input/keyboard/'
176
    }));
177
    multikey.init();
178
}
179

            
180
var zkv1000_init = func {
init listener needed only on...
Sébastien MARQUE authored on 2017-03-13
181
    removelistener(init);
commit initial
Sébastien MARQUE authored on 2017-03-07
182
    load_multikey();
183
    load_nasal();
184
    init_props();
185
    print('zkv1000 loaded');
186
}
187

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