zkv1000 / Nasal / core.nas /
Newer Older
193 lines | 7.161kb
commit initial
Sébastien MARQUE authored on 2017-03-07
1
var main_loop_id = 0;
2
var loop_check_functions_max_index = 0;
3
var loop_check_functions = [];
4
var device = [nil, nil];
5
var deviceClass = {};
6

            
7
var init_main_loop = func {
8
    loop_check_functions = [
9
        pfdCursors,
10
        checkTrafficProximity,
11
        checkMarkerBaecon,
12
        device[0] == nil ? void : func { moveMap (0) },
13
        checkRollAcquisition,
14
        checkPitchAcquisition,
15
        pfdCursors,
16
        computeAltitudeDiff,
17
        computeAirspeedDiff,
18
        device[1] == nil ? void : func { moveMap(1) },
19
        checkAlerts,
20
    ];
21
    loop_check_functions_max_index = size(loop_check_functions);
22
}
23

            
24
var main_loop = func () {
25
    getData();
26
    FLCcomputation();
27
    loop_check_functions[main_loop_id]();
28
    main_loop_id += 1;
29
    if (main_loop_id == loop_check_functions_max_index) main_loop_id = 0;
30
    settimer(main_loop, 0);
31
}
32

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
33
# les listeners triggent en permanence sur les fréquences...
34
var setListeners = func {
35
    setlistener('/instrumentation/nav/nav-id',
correction listeners
Sébastien MARQUE authored on 2017-03-12
36
            func (n) {
37
                var val = n.getValue();
38
                device[0].display.updateNAV({'nav-id': 1, val: val});
39
                device[0].display.updateNAV({'nav-id': 1, val: val});
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
40
            }, 1, 2);
41
    setlistener('/instrumentation/nav[1]/nav-id',
correction listeners
Sébastien MARQUE authored on 2017-03-12
42
            func (n) {
43
                var val = n.getValue();
44
                device[0].display.updateNAV({'nav-id': 2, val: val});
45
                device[1].display.updateNAV({'nav-id': 2, val: val});
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
46
            }, 1, 2);
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
47
    setlistener('/instrumentation/zkv1000/radios/nav-tune',
correction listeners
Sébastien MARQUE authored on 2017-03-12
48
            func (n) {
49
                var val = n.getValue();
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
50
                setNavTune();
correction listeners
Sébastien MARQUE authored on 2017-03-12
51
                device[0].display.updateNAV({tune: val});
52
                device[1].display.updateNAV({tune: val});
53
            }, 1, 2);
54
    setlistener('/instrumentation/zkv1000/radios/comm-tune',
55
            func (n) {
56
                var val = n.getValue();
57
                setCommTune();
58
                device[0].display.updateCOMM({tune: val});
59
                device[1].display.updateCOMM({tune: val});
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
60
            }, 1, 2);
animation HDG bug
Sébastien MARQUE authored on 2017-03-13
61
    setlistener('/instrumentation/zkv1000/afcs/heading-bug-deg',
62
            func (n) {
63
                var val = n.getValue();
64
                if (val != nil) {
65
                    device[0].display.updateHDG(val);
66
                    device[1].display.updateHDG(val);
67
                }
68
            }, 0, 2);
adds CDI
Sébastien MARQUE authored on 2017-03-18
69
    setlistener('/instrumentation/zkv1000/device[0]/knobs/CRS',
anime CRS
Sébastien MARQUE authored on 2017-03-13
70
            func (n) {
71
                var val = n.getValue();
72
                if (val != nil) {
adds CDI
Sébastien MARQUE authored on 2017-03-18
73
                    device[0].display.updateCRS();
74
                    device[1].display.updateCRS();
anime CRS
Sébastien MARQUE authored on 2017-03-13
75
                }
76
            }, 0, 2);
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
77
    setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',
78
            func (n) {
79
                var val = n.getValue();
80
                if (val != nil) {
fix Selected Altitude displa...
Sébastien MARQUE authored on 2017-03-18
81
                    if (! device[0].display.screenElements['SelectedALT'].getVisible()) {
82
                        device[0].display.screenElements['SelectedALT'].show();
83
                        device[0].display.screenElements['SelectedALT-text'].show();
84
                        device[0].display.screenElements['SelectedALT-symbol'].show();
85
                        device[0].display.screenElements['SelectedALT-bug'].show();
86
                        device[0].display.screenElements['SelectedALT-bg'].show();
87
                    }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
88
                    device[0].display.updateSelectedALT();
89
                }
90
            }, 0, 2);
adds transponder
Sébastien MARQUE authored on 2017-03-17
91
    setlistener('/gear/gear/wow',
92
            func device[0].display.updateXPDR(),
93
            0, 0);
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
94
    setlistener('/instrumentation/altimeter/setting-inhg',
95
            func device[0].display.updateBARO(), 0, 2);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
96
}
97

            
commit initial
Sébastien MARQUE authored on 2017-03-07
98
var deviceClass = {
99
    new: func (d) {
100
        var m = { parents: [ deviceClass ] };
101
        m.role = d ? 'MFD' : 'PFD';
102
        m.node = zkv.getNode('device[' ~ d ~ ']', 1);
pass device pointer to displ...
Sébastien MARQUE authored on 2017-03-14
103
        m.display  = displayClass.new(m, m.role);
commit initial
Sébastien MARQUE authored on 2017-03-07
104
        m.display.showInitProgress(m.role);
105
        m.buttons  = buttonsClass.new(m.node);
106
        m.knobs    = knobsClass.new(m.node);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
107
        m.softkeys = softkeysClass.new(m, m.node, m.role);
commit initial
Sébastien MARQUE authored on 2017-03-07
108
        m.display.loadsvg();
AI disponible
Sébastien MARQUE authored on 2017-03-10
109
        m.display.loadGroup({
110
            hide : [
commit initial
Sébastien MARQUE authored on 2017-03-07
111
                'Failures',
112
                'SoftKeysTexts',
113
                'PFD-Widgets', 
114
                'COMM',
115
                'XPDR-TIME', 
116
                'NAV',
117
                'FlightInstruments', 
118
                'VDI',
119
                'OMI',
AI disponible
Sébastien MARQUE authored on 2017-03-10
120
            ],
121
            clip : 'PitchScale',
122
        });
commit initial
Sébastien MARQUE authored on 2017-03-07
123
        zkv.getNode(m.role ~ 'init').setIntValue(0);
124
        m.setstatus(d + 1);
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
125
        msg(m.role ~ ' switched on!');
commit initial
Sébastien MARQUE authored on 2017-03-07
126
        return m;
127
    },
128

            
129
    status: 0,
130

            
131
    role: '',
132

            
133
    setstatus: func (s) {
134
        if (s == 1) {
135
        }
136
        elsif (s == 2) {
137
            me.rootmenu = 12;
138
            me.node.getNode('mfd-title',1).setValue('TOPO');
139
        }
140
        me.status = s;
141
        me.node.getNode('status', 1).setIntValue(s);
142
    },
143

            
144
    
145
    MFD: func {
146
        m.rootmenu = 12;
147
        m.newstatus(2);
148
        m.node.getNode('mfd-title',1).setValue('TOPO');
149
    },
150

            
151

            
152
    MENUkeyItems: {},
153

            
154
    set_MENUkeyItems: func {
155
        me.MENUkeyItems = {
156
            'MAIN MENU': [
157
                    [['ROUTE MANAGER'],   func { me.MENUsoftkey('ROUTE MANAGER') }],
158
                    [['GENERAL OPTIONS'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
159
                ],
160
            'ROUTE MANAGER': [
161
                    [[sprintf('%sACTIVATE ROUTE MANAGER', getprop('/autopilot/route-manager/active') ? 'DES' : ''), ' '],
162
                        func { 
163
                            getprop('/autopilot/route-manager/route/num') or return;
164
                            setprop('/autopilot/route-manager/current-wp', 0);
165
                            var v = getprop('/autopilot/route-manager/active');
166
                            setprop('/autopilot/route-manager/active', !v);
167
                            me.mud.node.getNode('line[' ~ me.mud.selected.first_line ~ ']').setValue(sprintf('%sACTIVATE ROUTE MANAGER', v ? '' : 'DES'));
168
                        }],
169
                    [['SEARCH AIRPORT'], void],
170
                    [['SEARCH NAVAID'], void],
171
                    [['SEARCH FIX'], void],
172
                    [['BACK'], func { me.MENUsoftkey('MAIN MENU') }],
173
                ],
174
            'BACKLIGHT LEVEL': [
175
                    [['HIGH'], func { setprop('/instrumentation/zkv1000/emission', 1.0) }],
176
                    [['MEDIUM HIGH'], func { setprop('/instrumentation/zkv1000/emission', 0.6) }],
177
                    [['MEDIUM LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.4) }],
178
                    [['LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.2) }],
179
                    [[' ', 'BACK'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
180
                ],
181
            'GENERAL OPTIONS': [
182
                    [['ADJUST BACKLIGHT'], func { me.MENUsoftkey('BACKLIGHT LEVEL') }],
183
                    [['MAX NAVAIDS SHOW'], void],
184
                ],
185
        };
186
    },
187
};
188

            
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
189
var powerOn = func {
190
    device[0] = deviceClass.new(0);
191
    device[1] = deviceClass.new(1);
correction listeners
Sébastien MARQUE authored on 2017-03-12
192
    settimer(setListeners, 5);
commit initial
Sébastien MARQUE authored on 2017-03-07
193
}