1 contributor
data = { # set of data common to all devices
roll : 0,
pitch : 0,
vsi : 0,
ias : 0,
alt : 0,
hdg : 0,
wow : 1,
timers : {
'20Hz': maketimer (
0.05,
func {
data.roll = getprop('/orientation/roll-deg');
data.pitch = getprop('orientation/pitch-deg');
data.vsi = getprop('/instrumentation/vertical-speed-indicator/indicated-speed-fpm');
data.ias = getprop('/velocities/airspeed-kt');
data.alt = getprop('/instrumentation/altimeter/indicated-altitude-ft');
data.hdg = getprop('/orientation/heading-deg');
}
),
'1Hz': maketimer (
1,
func {
data.wow = getprop('/gear/gear/wow');
}
),
},
};
var setListeners = func {
setlistener('/instrumentation/nav/nav-id',
func (n) {
var val = n.getValue();
foreach (var c; keys(flightdeck))
flightdeck[c].display.updateNAV({'nav-id': 1, val: val});
}, 1, 2);
setlistener('/instrumentation/nav[1]/nav-id',
func (n) {
var val = n.getValue();
foreach (var c; keys(flightdeck))
flightdeck[c].display.updateNAV({'nav-id': 2, val: val});
}, 1, 2);
# keep this listener as long as the code is to heavy to be modified in multiple places
setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',
func (n) {
var val = n.getValue();
if (val != nil)
foreach (var c; keys(flightdeck))
if (flightdeck[c].role == 'PFD') {
if (! flightdeck[c].display.screenElements['SelectedALT'].getVisible()) {
flightdeck[c].display.screenElements['SelectedALT'].show();
flightdeck[c].display.screenElements['SelectedALT-text'].show();
flightdeck[c].display.screenElements['SelectedALT-symbol'].show();
flightdeck[c].display.screenElements['SelectedALT-bug'].show();
flightdeck[c].display.screenElements['SelectedALT-bg'].show();
}
flightdeck[c].display.updateSelectedALT();
}
}, 0, 2);
setlistener('/gear/gear/wow',
func foreach (var c; keys(flightdeck))
if (flightdeck[c].role == 'PFD')
flightdeck[c].display.updateXPDR(),
0, 0);
setlistener('/instrumentation/altimeter/setting-inhg',
func foreach (var c; keys(flightdeck))
if (flightdeck[c].role == 'PFD')
flightdeck[c].display.updateBARO(), 0, 2);
}
var deviceClass = {
new: func (name) {
var m = { parents: [ deviceClass ] };
m.name = name;
m.role = substr(name, 0, 3);
m.node = zkv.getNode(name, 1);
m.data = {};
foreach (var v; ['Vx', 'Vy', 'Vr', 'Vglide']) {
m.data[v] = alerts.getNode(v).getValue();
m.data[v ~ '-visible'] = 1;
}
m.display = displayClass.new(m);
m.display.showInitProgress(m.name);
m.softkeys = softkeysClass.new(m);
m.buttons = buttonsClass.new(m);
m.knobs = knobsClass.new(m);
m.display.loadsvg();
m.display.loadGroup({
hide : [
'Failures',
'SoftKeysTexts',
'PFD-Widgets',
'COMM',
'XPDR-TIME',
'NAV',
'FlightInstruments',
'VDI',
'OMI',
],
clip : 'PitchScale',
});
m.windows = pageClass.new(m);
zkv.getNode(m.name ~ '-init').setIntValue(0);
setprop('/instrumentation/zkv1000/' ~ m.name ~ '/status', 1);
msg(m.name ~ ' switched on!');
return m;
},
};
var powerOn = func {
foreach (var name; keys(flightdeck))
if (zkv.getNode(name) != nil)
# thread.newthread(func {
flightdeck[name] = deviceClass.new(name);
# });
settimer(setListeners, 5);
}