zkv1000 / Nasal / core.nas /
Newer Older
128 lines | 4.306kb
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

            
33
var deviceClass = {
34
    new: func (d) {
35
        var m = { parents: [ deviceClass ] };
36
        m.role = d ? 'MFD' : 'PFD';
37
        m.node = zkv.getNode('device[' ~ d ~ ']', 1);
38
        m.display  = displayClass.new(m.node, m.role);
39
        m.display.showInitProgress(m.role);
40
        m.buttons  = buttonsClass.new(m.node);
41
        m.knobs    = knobsClass.new(m.node);
42
        m.softkeys = softkeysClass.new(m.node, m.role);
43
        m.display.loadsvg();
AI disponible
Sébastien MARQUE authored on 2017-03-10
44
        m.display.loadGroup({
45
            hide : [
commit initial
Sébastien MARQUE authored on 2017-03-07
46
                'Failures',
47
                'SoftKeysTexts',
48
                'PFD-Widgets', 
49
                'COMM',
50
                'XPDR-TIME', 
51
                'NAV',
52
                'FlightInstruments', 
53
                'VDI',
54
                'OMI',
AI disponible
Sébastien MARQUE authored on 2017-03-10
55
            ],
56
            clip : 'PitchScale',
57
        });
commit initial
Sébastien MARQUE authored on 2017-03-07
58
        zkv.getNode(m.role ~ 'init').setIntValue(0);
59
        m.setstatus(d + 1);
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
60
        msg(m.role ~ ' switched on!');
commit initial
Sébastien MARQUE authored on 2017-03-07
61
        return m;
62
    },
63

            
64
    status: 0,
65

            
66
    role: '',
67

            
68
    setstatus: func (s) {
69
        if (s == 1) {
70
        }
71
        elsif (s == 2) {
72
            me.rootmenu = 12;
73
            me.node.getNode('mfd-title',1).setValue('TOPO');
74
        }
75
        me.status = s;
76
        me.node.getNode('status', 1).setIntValue(s);
77
    },
78

            
79
    
80
    MFD: func {
81
        m.rootmenu = 12;
82
        m.newstatus(2);
83
        m.node.getNode('mfd-title',1).setValue('TOPO');
84
    },
85

            
86

            
87
    MENUkeyItems: {},
88

            
89
    set_MENUkeyItems: func {
90
        me.MENUkeyItems = {
91
            'MAIN MENU': [
92
                    [['ROUTE MANAGER'],   func { me.MENUsoftkey('ROUTE MANAGER') }],
93
                    [['GENERAL OPTIONS'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
94
                ],
95
            'ROUTE MANAGER': [
96
                    [[sprintf('%sACTIVATE ROUTE MANAGER', getprop('/autopilot/route-manager/active') ? 'DES' : ''), ' '],
97
                        func { 
98
                            getprop('/autopilot/route-manager/route/num') or return;
99
                            setprop('/autopilot/route-manager/current-wp', 0);
100
                            var v = getprop('/autopilot/route-manager/active');
101
                            setprop('/autopilot/route-manager/active', !v);
102
                            me.mud.node.getNode('line[' ~ me.mud.selected.first_line ~ ']').setValue(sprintf('%sACTIVATE ROUTE MANAGER', v ? '' : 'DES'));
103
                        }],
104
                    [['SEARCH AIRPORT'], void],
105
                    [['SEARCH NAVAID'], void],
106
                    [['SEARCH FIX'], void],
107
                    [['BACK'], func { me.MENUsoftkey('MAIN MENU') }],
108
                ],
109
            'BACKLIGHT LEVEL': [
110
                    [['HIGH'], func { setprop('/instrumentation/zkv1000/emission', 1.0) }],
111
                    [['MEDIUM HIGH'], func { setprop('/instrumentation/zkv1000/emission', 0.6) }],
112
                    [['MEDIUM LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.4) }],
113
                    [['LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.2) }],
114
                    [[' ', 'BACK'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
115
                ],
116
            'GENERAL OPTIONS': [
117
                    [['ADJUST BACKLIGHT'], func { me.MENUsoftkey('BACKLIGHT LEVEL') }],
118
                    [['MAX NAVAIDS SHOW'], void],
119
                ],
120
        };
121
    },
122
};
123

            
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
124
var powerOn = func {
125
    device[0] = deviceClass.new(0);
126
    device[1] = deviceClass.new(1);
127
    setListeners();
commit initial
Sébastien MARQUE authored on 2017-03-07
128
}