zkv1000 / Nasal / core.nas /
Newer Older
132 lines | 4.508kb
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();
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
44
        m.display.loadGroup({hide : [ 
commit initial
Sébastien MARQUE authored on 2017-03-07
45
                'Failures',
46
                'SoftKeysTexts',
47
                'PFD-Widgets', 
48
#                'MFD-Widgets',
49
                'COMM',
50
                'XPDR-TIME', 
51
                'NAV',
52
                'FlightInstruments', 
53
                'VDI',
54
                'OMI',
écriture du wrapper pour le ...
Sébastien MARQUE authored on 2017-03-10
55
        ]});
commit initial
Sébastien MARQUE authored on 2017-03-07
56
        zkv.getNode(m.role ~ 'init').setIntValue(0);
57
        m.setstatus(d + 1);
58
        return m;
59
    },
60

            
61
    status: 0,
62

            
63
    role: '',
64

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

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

            
83

            
84
    MENUkeyItems: {},
85

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

            
121
var powerOn = func (d) {
122
    device[d] = deviceClass.new(d);
123
#    device[d].display.show(device[d].role);
124
    msg(device[d].role ~ ' switched on!');
125

            
126
#    if (device[abs(d - 1)] == nil) {
127
#setlistener('/gear/gear/wow', inAirCheckings, 0, 0);
128
#        fgcommand('reinit', props.Node.new({subsytem : 'xml-autopilot'}));
129
#        settimer(main_loop, 0);
130
#    }
131
#    init_main_loop();
132
}