zkv1000 / Nasal / core.nas /
Newer Older
116 lines | 4.353kb
make some data common to all...
Sébastien MARQUE authored on 2017-04-07
1
data = { # set of data common to all devices
2
    roll : 0,
3
    pitch : 0,
4
    vsi : 0,
5
    ias : 0,
6
    alt : 0,
7
    hdg : 0,
8
    wow : 1,
9
    timers : {
10
        '20Hz': maketimer (
11
            0.05,
12
            func {
13
                data.roll = getprop('/orientation/roll-deg');
14
                data.pitch = getprop('orientation/pitch-deg');
15
                data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
16
                data.ias = getprop('/velocities/airspeed-kt');
17
                data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
18
                data.hdg = getprop('/orientation/heading-deg');
19
            }
20
        ),
21
        '1Hz': maketimer (
22
            1,
23
            func {
24
                data.wow = getprop('/gear/gear/wow');
25
            }
26
        ),
27
    },
28
};
29

            
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
30
var setListeners = func {
31
    setlistener('/instrumentation/nav/nav-id',
correction listeners
Sébastien MARQUE authored on 2017-03-12
32
            func (n) {
33
                var val = n.getValue();
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
34
                foreach (var c; keys(flightdeck))
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
35
                    flightdeck[c].display.updateNAV({'nav-id': 1, val: val});
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
36
            }, 1, 2);
37
    setlistener('/instrumentation/nav[1]/nav-id',
correction listeners
Sébastien MARQUE authored on 2017-03-12
38
            func (n) {
39
                var val = n.getValue();
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
40
                foreach (var c; keys(flightdeck))
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
41
                    flightdeck[c].display.updateNAV({'nav-id': 2, val: val});
NAV disponible (hors CDI)
Sébastien MARQUE authored on 2017-03-11
42
            }, 1, 2);
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
43
   # keep this listener as long as the code is to heavy to be modified in multiple places
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
44
    setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',
45
            func (n) {
46
                var val = n.getValue();
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
47
                if (val != nil)
48
                    foreach (var c; keys(flightdeck))
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
49
                        if (flightdeck[c].role == 'PFD') {
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
50
                            if (! flightdeck[c].display.screenElements['SelectedALT'].getVisible()) {
51
                                flightdeck[c].display.screenElements['SelectedALT'].show();
52
                                flightdeck[c].display.screenElements['SelectedALT-text'].show();
53
                                flightdeck[c].display.screenElements['SelectedALT-symbol'].show();
54
                                flightdeck[c].display.screenElements['SelectedALT-bug'].show();
55
                                flightdeck[c].display.screenElements['SelectedALT-bg'].show();
56
                            }
57
                            flightdeck[c].display.updateSelectedALT();
58
                        }
adds OAT, TAS, GSPD, WindDat...
Sébastien MARQUE authored on 2017-03-15
59
            }, 0, 2);
adds transponder
Sébastien MARQUE authored on 2017-03-17
60
    setlistener('/gear/gear/wow',
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
61
            func foreach (var c; keys(flightdeck))
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
62
                if (flightdeck[c].role == 'PFD')
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
63
                    flightdeck[c].display.updateXPDR(),
adds transponder
Sébastien MARQUE authored on 2017-03-17
64
            0, 0);
adds BARO settings
Sébastien MARQUE authored on 2017-03-20
65
    setlistener('/instrumentation/altimeter/setting-inhg',
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
66
            func foreach (var c; keys(flightdeck))
removes unecessary listeners
Sébastien MARQUE authored on 2017-04-08
67
                if (flightdeck[c].role == 'PFD')
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
68
                    flightdeck[c].display.updateBARO(), 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 = {
new var organistaion (and fi...
Sébastien MARQUE authored on 2017-03-26
72
    new: func (role) {
commit initial
Sébastien MARQUE authored on 2017-03-07
73
        var m = { parents: [ deviceClass ] };
new var organistaion (and fi...
Sébastien MARQUE authored on 2017-03-26
74
        m.role = role;
75
        m.node = zkv.getNode(role, 1);
add V-speeds bugs
Sébastien MARQUE authored on 2017-04-04
76
        m.data = {};
77
        foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
78
            m.data[v] = alerts.getNode(v).getValue();
79
            m.data[v ~ '-visible'] = 1;
80
        }
pass device pointer to displ...
Sébastien MARQUE authored on 2017-03-14
81
        m.display  = displayClass.new(m, m.role);
commit initial
Sébastien MARQUE authored on 2017-03-07
82
        m.display.showInitProgress(m.role);
softkeys are available now
Sébastien MARQUE authored on 2017-03-14
83
        m.softkeys = softkeysClass.new(m, m.node, m.role);
XPDR settings via knob or so...
Sébastien MARQUE authored on 2017-03-22
84
        m.buttons  = buttonsClass.new(m.node);
85
        m.knobs    = knobsClass.new(m);
commit initial
Sébastien MARQUE authored on 2017-03-07
86
        m.display.loadsvg();
AI disponible
Sébastien MARQUE authored on 2017-03-10
87
        m.display.loadGroup({
88
            hide : [
commit initial
Sébastien MARQUE authored on 2017-03-07
89
                'Failures',
90
                'SoftKeysTexts',
91
                'PFD-Widgets', 
92
                'COMM',
93
                'XPDR-TIME', 
94
                'NAV',
95
                'FlightInstruments', 
96
                'VDI',
97
                'OMI',
AI disponible
Sébastien MARQUE authored on 2017-03-10
98
            ],
99
            clip : 'PitchScale',
100
        });
TMR/REF window
Sébastien MARQUE authored on 2017-03-28
101
        m.windows  = pageClass.new(m);
commit initial
Sébastien MARQUE authored on 2017-03-07
102
        zkv.getNode(m.role ~ 'init').setIntValue(0);
new var organistaion (and fi...
Sébastien MARQUE authored on 2017-03-26
103
        setprop('/instrumentation/zkv1000/' ~ m.role ~ '/status', 1);
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
104
        msg(m.role ~ ' switched on!');
commit initial
Sébastien MARQUE authored on 2017-03-07
105
        return m;
106
    },
107
};
108

            
PFD+MFD allumés ensemble
Sébastien MARQUE authored on 2017-03-11
109
var powerOn = func {
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
110
    foreach (var role; keys(flightdeck))
new var organistaion (and fi...
Sébastien MARQUE authored on 2017-03-26
111
        if (zkv.getNode(role) != nil)
112
#            thread.newthread(func {
creates flightdeck hash to p...
Sébastien MARQUE authored on 2017-04-07
113
                flightdeck[role] = deviceClass.new(role);
new var organistaion (and fi...
Sébastien MARQUE authored on 2017-03-26
114
#            });
correction listeners
Sébastien MARQUE authored on 2017-03-12
115
    settimer(setListeners, 5);
commit initial
Sébastien MARQUE authored on 2017-03-07
116
}