zkv1000 / Nasal / core.nas /
Newer Older
134 lines | 4.535kb
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);
60
        return m;
61
    },
62

            
63
    status: 0,
64

            
65
    role: '',
66

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

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

            
85

            
86
    MENUkeyItems: {},
87

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

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

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