zkv1000 / zkv1000.nas /
Newer Older
201 lines | 9.226kb
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('');
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
95
    var v = getprop('/instrumentation/zkv1000/alerts/Vx');
96
    alerts.getNode('Vx', 1).setIntValue(v != nil ? v : 999);
97
    v = getprop('/instrumentation/zkv1000/alerts/Vy');
98
    alerts.getNode('Vy', 1).setIntValue(v != nil ? v : 999);
99
    v = getprop('/instrumentation/zkv1000/alerts/Vr');
100
    alerts.getNode('Vr', 1).setIntValue(v != nil ? v : 999);
101
    v = getprop('/instrumentation/zkv1000/alerts/Vglide');
102
    alerts.getNode('Vglide', 1).setIntValue(v != nil ? v : 999);
add Vne Vspeed specific to a...
Sébastien MARQUE authored on 2017-04-04
103
    v = getprop('/instrumentation/zkv1000/alerts/Vne');
104
    alerts.getNode('Vne', 1).setIntValue(v != nil ? v : 999);
commit initial
Sébastien MARQUE authored on 2017-03-07
105

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

            
animation texts EIS + power ...
Sébastien MARQUE authored on 2017-03-19
129
    eis = zkv.getNode('eis',1);
130
    eis.getNode('fuel-qty-at-start', 1).setValue(
131
        getprop('/consumables/fuel/tank/level-gal_us')
132
      + getprop('/consumables/fuel/tank/level-gal_us'));
133

            
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
134
    setprop('/sim/gui/dialogs/map-canvas/draw-APT', 1);
135
    setprop('/sim/gui/dialogs/map-canvas/draw-FIX', 1);
136
    setprop('/sim/gui/dialogs/map-canvas/draw-VOR', 1);
137
    setprop('/sim/gui/dialogs/map-canvas/draw-DME', 1);
138
    setprop('/sim/gui/dialogs/map-canvas/draw-NDB', 1);
139
    setprop('/sim/gui/dialogs/map-canvas/draw-TFC', 1);
140
    setprop('/sim/gui/dialogs/map-canvas/draw-data', 1);
141
    setprop('/sim/gui/dialogs/map-canvas/draw-FLT', 1);
142
    setprop('/sim/gui/dialogs/map-canvas/draw-WXR', 1);
143
    setprop('/sim/gui/dialogs/map-canvas/draw-TUT', 1);
144
    setprop('/sim/gui/dialogs/map-canvas/aircraft-heading-up', 0);
145
    mfd = zkv.getNode('mfd', 1);
146
    var tiles_server = getprop('/sim/online-tiles-server');
147
    var tiles_type = getprop('/sim/online-tiles-type');
fix tiles server
Sébastien MARQUE authored on 2017-03-22
148
    # see https://www.wikimedia.org/wiki/Maps
149
    mfd.getNode('online-tiles-server', 1).setValue(tiles_server != nil ? tiles_server : 'maps.wikimedia.org');
adds Map on MFD
Sébastien MARQUE authored on 2017-03-20
150
    mfd.getNode('online-tiles-type', 1).setValue(tiles_type != nil ? tiles_type : 'osm-intl');
151

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

            
167
var set_listeners = func {
168
#    setlistener('/instrumentation/nav[0]/radials/selected-deg', popup_course_info,  0, 0);
169
#    setlistener('/instrumentation/nav[1]/radials/selected-deg', popup_course_info,  0, 0);
170
#    setlistener('/instrumentation/zkv1000/afcs/heading-bug-deg',popup_hdg_info,     0, 0);
171
#    setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',popup_selected_alt, 0, 0);
172
#    setlistener('/instrumentation/zkv1000/radios/nav-tune',     setNavTune,         0, 0);
173
#    setlistener('/instrumentation/zkv1000/radios/comm-tune',    setCommTune,        0, 0);
174
}
175

            
176
var load_nasal = func {
177
    var zkv1000_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/';
178
    for (var i = 0; i < size(files_to_load); i += 1)
179
        io.load_nasal(zkv1000_dir ~ files_to_load[i], 'zkv1000');
180
    files_to_load = nil;
181
}
182

            
183
var load_multikey = func {
184
    fgcommand('loadxml', props.Node.new({
185
        'filename': getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Systems/multikey.xml',
186
        'targetnode': '/input/keyboard/'
187
    }));
188
    multikey.init();
189
}
190

            
191
var zkv1000_init = func {
init listener needed only on...
Sébastien MARQUE authored on 2017-03-13
192
    removelistener(init);
commit initial
Sébastien MARQUE authored on 2017-03-07
193
    load_multikey();
194
    load_nasal();
195
    init_props();
196
    set_listeners();
197
    print('zkv1000 loaded');
198
}
199

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