zkv1000 / zkv1000.nas /
Newer Older
122 lines | 5.983kb
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
5
    'menu.nas',    # manages menu entries andd perform some simple actions
6
    'knobs.nas',   # handles knobs
7
    'buttons.nas', # handles knobs and buttons
8
    'softkeys.nas',# handles softkeys and menus items
9
    'display.nas',
10
    'canvas.nas',
11
    'core.nas',    # the scheduler and switch on button
12
];
13
#    'radios.nas',  # all about radios COMM, NAV, XPDR
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
#    'map.nas',     # moves the maps
19
#    'alerts.nas',  # in flight tests
20
#    'mud.nas',     # displays simple embedded GUI (Multi-Use Display)
21

            
22
var zkv = cdi = radios = alerts = infos = cursors = afcs = eis = nil;
23

            
24
var init_props = func {
25
    zkv = props.globals.getNode('/instrumentation/zkv1000',1);
26
    zkv.getNode('emission',1).setDoubleValue(0.5);
27
    zkv.getNode('body-emission',1).setDoubleValue(0.0);
28
    zkv.getNode('body-texture',1).setValue('');
29
    zkv.getNode('display-brightness-norm',1).setValue(0.5);
30

            
31
    radios = zkv.getNode('radios', 1);
32
    radios.getNode('nav1-selected',1).setIntValue(0);
33
    radios.getNode('nav1-standby',1).setIntValue(0);
34
    radios.getNode('nav2-selected',1).setIntValue(0);
35
    radios.getNode('nav2-standby',1).setIntValue(0);
36
    radios.getNode('nav-tune',1).setIntValue(0);
37
    radios.getNode('nav-freq-mhz',1).alias('/instrumentation/nav/frequencies/standby-mhz');
38
    radios.getNode('comm1-selected',1).setIntValue(1);
39
    radios.getNode('comm2-selected',1).setIntValue(0);
40
    radios.getNode('comm-tune',1).setIntValue(0);
41
    radios.getNode('comm-freq-mhz',1).alias('/instrumentation/comm/frequencies/standby-mhz');
42
    radios.getNode('xpdr-mode',1).setValue('GND');
43

            
44
    alerts = zkv.getNode('alerts',1);
45
    alerts.getNode('traffic-proximity',1).setIntValue(0);
46
    alerts.getNode('marker-beacon', 1).setIntValue(0);
47
    alerts.getNode('warning', 1).setBoolValue(0);
48
    alerts.getNode('alert', 1).setBoolValue(0);
49
    alerts.getNode('message', 1).setValue('');
50

            
51
    afcs = zkv.getNode('afcs',1);
52
    afcs.getNode('fd-bars-visible',1).setBoolValue(0);
53
    afcs.getNode('alt-bug-visible',1).setBoolValue(0);
54
    afcs.getNode('heading-bug-deg',1).setDoubleValue(getprop('/orientation/heading-magnetic-deg'));
55
    afcs.getNode('target-pitch-deg',1).setDoubleValue(0.0);
56
    afcs.getNode('selected-alt-ft',1).setDoubleValue(0.0);
57
    afcs.getNode('selected-alt-ft-diff',1).setDoubleValue(0.0);
58
    afcs.getNode('selected-ias-kt-diff',1).setDoubleValue(0.0);
59
    afcs.getNode('vertical-speed-fpm',1).setDoubleValue(0.0);
60
    afcs.getNode('roll-armed', 1).setBoolValue(0);
61
    afcs.getNode('pitch-armed', 1).setBoolValue(0);
62
    afcs.getNode('roll-armed-mode-text',1).setValue('');
63
    afcs.getNode('roll-active-mode-text',1).setValue('');
64
    afcs.getNode('roll-armed-mode',1).setIntValue(0);
65
    afcs.getNode('roll-active-mode',1).setIntValue(0);
66
    afcs.getNode('roll-active-mode-blink',1).setBoolValue(0);
67
    afcs.getNode('pit-armed-mode-text',1).setValue('');
68
    afcs.getNode('pit-active-mode-text',1).setValue('');
69
    afcs.getNode('pit-armed-mode',1).setIntValue(0);
70
    afcs.getNode('pit-active-mode',1).setIntValue(0);
71
    afcs.getNode('pit-active-mode-blink',1).setBoolValue(0);
72
    afcs.getNode('route',1);
73

            
74
    props.globals.getNode('/instrumentation/transponder/id-code',1).setIntValue(1200);
75
    props.globals.getNode('/instrumentation/transponder/serviceable',1).setBoolValue(1);
76
    props.globals.getNode('/autopilot/settings/heading-bug-deg', 1).alias('/instrumentation/zkv1000/afcs/heading-bug-deg');
77
    props.globals.getNode('/autopilot/settings/target-altitude-ft',1).setDoubleValue(0.0);
78
    props.globals.getNode('/autopilot/settings/target-speed-kt',1).setDoubleValue(0.0);
79
    props.globals.getNode('/autopilot/settings/vertical-speed-fpm',1).setDoubleValue(0.0);
80
    props.globals.getNode('/autopilot/internal/target-pitch-deg',1).setDoubleValue(0.0);
81
    props.globals.getNode('/autopilot/internal/flc-altitude-pitch-deg',1).setDoubleValue(0.0);
82
    props.globals.getNode('/autopilot/internal/flc-airspeed-pitch-deg',1).setDoubleValue(0.0);
83
    props.globals.getNode('/autopilot/internal/target-roll-deg',1).setDoubleValue(0.0);
84
    props.globals.getNode('/autopilot/locks/pitch',1).setValue('');
85
    props.globals.getNode('/autopilot/locks/roll',1).setValue('');
86
    props.globals.getNode('/autopilot/locks/passive-mode', 1).setIntValue(1);
87
}
88

            
89
var set_listeners = func {
90
#    setlistener('/instrumentation/nav[0]/radials/selected-deg', popup_course_info,  0, 0);
91
#    setlistener('/instrumentation/nav[1]/radials/selected-deg', popup_course_info,  0, 0);
92
#    setlistener('/instrumentation/zkv1000/afcs/heading-bug-deg',popup_hdg_info,     0, 0);
93
#    setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',popup_selected_alt, 0, 0);
94
#    setlistener('/instrumentation/zkv1000/radios/nav-tune',     setNavTune,         0, 0);
95
#    setlistener('/instrumentation/zkv1000/radios/comm-tune',    setCommTune,        0, 0);
96
}
97

            
98
var load_nasal = func {
99
    var zkv1000_dir = getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Nasal/';
100
    for (var i = 0; i < size(files_to_load); i += 1)
101
        io.load_nasal(zkv1000_dir ~ files_to_load[i], 'zkv1000');
102
    files_to_load = nil;
103
}
104

            
105
var load_multikey = func {
106
    fgcommand('loadxml', props.Node.new({
107
        'filename': getprop('/sim/fg-aircraft') ~ '/Instruments-3d/zkv1000/Systems/multikey.xml',
108
        'targetnode': '/input/keyboard/'
109
    }));
110
    multikey.init();
111
}
112

            
113
var zkv1000_init = func {
114
    load_multikey();
115
    load_nasal();
116
    init_props();
117
    set_listeners();
118
    print('zkv1000 loaded');
119
}
120

            
121
setlistener('/sim/signals/fdm-initialized', zkv1000_init, 0, 0);
122