zkv1000 / Nasal / core.nas /
Newer Older
185 lines | 6.659kb
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);
anime CRS
Sébastien MARQUE authored on 2017-03-13
69
    setlistener('/instrumentation/zkv1000/cdi/course',
70
            func (n) {
71
                var val = n.getValue();
72
                if (val != nil) {
73
                    device[0].display.updateCRS(val);
74
                    device[1].display.updateCRS(val);
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
            print('/instrumentation/zkv1000/afcs/selected-alt-ft');
80
                var val = n.getValue();
81
                if (val != nil) {
82
                    device[0].display.screenElements['SelectedAlt-bug'].show();
83
                    device[0].display.screenElements['SelectedAlt-top'].show();
84
                    device[0].display.updateSelectedALT();
85
                }
86
            }, 0, 2);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
87
}
88

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

            
121
    status: 0,
122

            
123
    role: '',
124

            
125
    setstatus: func (s) {
126
        if (s == 1) {
127
        }
128
        elsif (s == 2) {
129
            me.rootmenu = 12;
130
            me.node.getNode('mfd-title',1).setValue('TOPO');
131
        }
132
        me.status = s;
133
        me.node.getNode('status', 1).setIntValue(s);
134
    },
135

            
136
    
137
    MFD: func {
138
        m.rootmenu = 12;
139
        m.newstatus(2);
140
        m.node.getNode('mfd-title',1).setValue('TOPO');
141
    },
142

            
143

            
144
    MENUkeyItems: {},
145

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

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