zkv1000 / Nasal / core.nas /
Newer Older
166 lines | 5.851kb
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);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
69
}
70

            
commit initial
Sébastien MARQUE authored on 2017-03-07
71
var deviceClass = {
72
    new: func (d) {
73
        var m = { parents: [ deviceClass ] };
74
        m.role = d ? 'MFD' : 'PFD';
75
        m.node = zkv.getNode('device[' ~ d ~ ']', 1);
76
        m.display  = displayClass.new(m.node, m.role);
77
        m.display.showInitProgress(m.role);
78
        m.buttons  = buttonsClass.new(m.node);
79
        m.knobs    = knobsClass.new(m.node);
80
        m.softkeys = softkeysClass.new(m.node, m.role);
81
        m.display.loadsvg();
AI disponible
Sébastien MARQUE authored on 2017-03-10
82
        m.display.loadGroup({
83
            hide : [
commit initial
Sébastien MARQUE authored on 2017-03-07
84
                'Failures',
85
                'SoftKeysTexts',
86
                'PFD-Widgets', 
87
                'COMM',
88
                'XPDR-TIME', 
89
                'NAV',
90
                'FlightInstruments', 
91
                'VDI',
92
                'OMI',
AI disponible
Sébastien MARQUE authored on 2017-03-10
93
            ],
94
            clip : 'PitchScale',
95
        });
commit initial
Sébastien MARQUE authored on 2017-03-07
96
        zkv.getNode(m.role ~ 'init').setIntValue(0);
97
        m.setstatus(d + 1);
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
98
        msg(m.role ~ ' switched on!');
commit initial
Sébastien MARQUE authored on 2017-03-07
99
        return m;
100
    },
101

            
102
    status: 0,
103

            
104
    role: '',
105

            
106
    setstatus: func (s) {
107
        if (s == 1) {
108
        }
109
        elsif (s == 2) {
110
            me.rootmenu = 12;
111
            me.node.getNode('mfd-title',1).setValue('TOPO');
112
        }
113
        me.status = s;
114
        me.node.getNode('status', 1).setIntValue(s);
115
    },
116

            
117
    
118
    MFD: func {
119
        m.rootmenu = 12;
120
        m.newstatus(2);
121
        m.node.getNode('mfd-title',1).setValue('TOPO');
122
    },
123

            
124

            
125
    MENUkeyItems: {},
126

            
127
    set_MENUkeyItems: func {
128
        me.MENUkeyItems = {
129
            'MAIN MENU': [
130
                    [['ROUTE MANAGER'],   func { me.MENUsoftkey('ROUTE MANAGER') }],
131
                    [['GENERAL OPTIONS'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
132
                ],
133
            'ROUTE MANAGER': [
134
                    [[sprintf('%sACTIVATE ROUTE MANAGER', getprop('/autopilot/route-manager/active') ? 'DES' : ''), ' '],
135
                        func { 
136
                            getprop('/autopilot/route-manager/route/num') or return;
137
                            setprop('/autopilot/route-manager/current-wp', 0);
138
                            var v = getprop('/autopilot/route-manager/active');
139
                            setprop('/autopilot/route-manager/active', !v);
140
                            me.mud.node.getNode('line[' ~ me.mud.selected.first_line ~ ']').setValue(sprintf('%sACTIVATE ROUTE MANAGER', v ? '' : 'DES'));
141
                        }],
142
                    [['SEARCH AIRPORT'], void],
143
                    [['SEARCH NAVAID'], void],
144
                    [['SEARCH FIX'], void],
145
                    [['BACK'], func { me.MENUsoftkey('MAIN MENU') }],
146
                ],
147
            'BACKLIGHT LEVEL': [
148
                    [['HIGH'], func { setprop('/instrumentation/zkv1000/emission', 1.0) }],
149
                    [['MEDIUM HIGH'], func { setprop('/instrumentation/zkv1000/emission', 0.6) }],
150
                    [['MEDIUM LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.4) }],
151
                    [['LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.2) }],
152
                    [[' ', 'BACK'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
153
                ],
154
            'GENERAL OPTIONS': [
155
                    [['ADJUST BACKLIGHT'], func { me.MENUsoftkey('BACKLIGHT LEVEL') }],
156
                    [['MAX NAVAIDS SHOW'], void],
157
                ],
158
        };
159
    },
160
};
161

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