zkv1000 / Nasal / core.nas /
Newer Older
148 lines | 5.059kb
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',
36
            func {
37
                device[0].display.updateNAV({'nav-id': 1});
38
                device[0].display.updateNAV({'nav-id': 1});
39
            }, 1, 2);
40
    setlistener('/instrumentation/nav[1]/nav-id',
41
            func {
42
                device[0].display.updateNAV({'nav-id': 2});
43
                device[1].display.updateNAV({'nav-id': 2});
44
            }, 1, 2);
Correction swap NAV tuning
Sébastien MARQUE authored on 2017-03-12
45
    setlistener('/instrumentation/zkv1000/radios/nav-tune',
46
            func {
47
                setNavTune();
48
                device[0].display.updateNAV({tune: 1});
49
                device[1].display.updateNAV({tune: 1});
50
            }, 1, 2);
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
51
}
52

            
commit initial
Sébastien MARQUE authored on 2017-03-07
53
var deviceClass = {
54
    new: func (d) {
55
        var m = { parents: [ deviceClass ] };
56
        m.role = d ? 'MFD' : 'PFD';
57
        m.node = zkv.getNode('device[' ~ d ~ ']', 1);
58
        m.display  = displayClass.new(m.node, m.role);
59
        m.display.showInitProgress(m.role);
60
        m.buttons  = buttonsClass.new(m.node);
61
        m.knobs    = knobsClass.new(m.node);
62
        m.softkeys = softkeysClass.new(m.node, m.role);
63
        m.display.loadsvg();
AI disponible
Sébastien MARQUE authored on 2017-03-10
64
        m.display.loadGroup({
65
            hide : [
commit initial
Sébastien MARQUE authored on 2017-03-07
66
                'Failures',
67
                'SoftKeysTexts',
68
                'PFD-Widgets', 
69
                'COMM',
70
                'XPDR-TIME', 
71
                'NAV',
72
                'FlightInstruments', 
73
                'VDI',
74
                'OMI',
AI disponible
Sébastien MARQUE authored on 2017-03-10
75
            ],
76
            clip : 'PitchScale',
77
        });
commit initial
Sébastien MARQUE authored on 2017-03-07
78
        zkv.getNode(m.role ~ 'init').setIntValue(0);
79
        m.setstatus(d + 1);
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
80
        msg(m.role ~ ' switched on!');
commit initial
Sébastien MARQUE authored on 2017-03-07
81
        return m;
82
    },
83

            
84
    status: 0,
85

            
86
    role: '',
87

            
88
    setstatus: func (s) {
89
        if (s == 1) {
90
        }
91
        elsif (s == 2) {
92
            me.rootmenu = 12;
93
            me.node.getNode('mfd-title',1).setValue('TOPO');
94
        }
95
        me.status = s;
96
        me.node.getNode('status', 1).setIntValue(s);
97
    },
98

            
99
    
100
    MFD: func {
101
        m.rootmenu = 12;
102
        m.newstatus(2);
103
        m.node.getNode('mfd-title',1).setValue('TOPO');
104
    },
105

            
106

            
107
    MENUkeyItems: {},
108

            
109
    set_MENUkeyItems: func {
110
        me.MENUkeyItems = {
111
            'MAIN MENU': [
112
                    [['ROUTE MANAGER'],   func { me.MENUsoftkey('ROUTE MANAGER') }],
113
                    [['GENERAL OPTIONS'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
114
                ],
115
            'ROUTE MANAGER': [
116
                    [[sprintf('%sACTIVATE ROUTE MANAGER', getprop('/autopilot/route-manager/active') ? 'DES' : ''), ' '],
117
                        func { 
118
                            getprop('/autopilot/route-manager/route/num') or return;
119
                            setprop('/autopilot/route-manager/current-wp', 0);
120
                            var v = getprop('/autopilot/route-manager/active');
121
                            setprop('/autopilot/route-manager/active', !v);
122
                            me.mud.node.getNode('line[' ~ me.mud.selected.first_line ~ ']').setValue(sprintf('%sACTIVATE ROUTE MANAGER', v ? '' : 'DES'));
123
                        }],
124
                    [['SEARCH AIRPORT'], void],
125
                    [['SEARCH NAVAID'], void],
126
                    [['SEARCH FIX'], void],
127
                    [['BACK'], func { me.MENUsoftkey('MAIN MENU') }],
128
                ],
129
            'BACKLIGHT LEVEL': [
130
                    [['HIGH'], func { setprop('/instrumentation/zkv1000/emission', 1.0) }],
131
                    [['MEDIUM HIGH'], func { setprop('/instrumentation/zkv1000/emission', 0.6) }],
132
                    [['MEDIUM LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.4) }],
133
                    [['LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.2) }],
134
                    [[' ', 'BACK'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
135
                ],
136
            'GENERAL OPTIONS': [
137
                    [['ADJUST BACKLIGHT'], func { me.MENUsoftkey('BACKLIGHT LEVEL') }],
138
                    [['MAX NAVAIDS SHOW'], void],
139
                ],
140
        };
141
    },
142
};
143

            
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
144
var powerOn = func {
145
    device[0] = deviceClass.new(0);
146
    device[1] = deviceClass.new(1);
147
    setListeners();
commit initial
Sébastien MARQUE authored on 2017-03-07
148
}