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');
}
),
},
};
# les listeners triggent en permanence sur les fréquences...
var setListeners = func {
setlistener('/instrumentation/nav/nav-id',
func (n) {
var val = n.getValue();
foreach (var c; keys(flightdeck))
if (flightdeck[c] != nil)
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))
if (flightdeck[c] != nil)
flightdeck[c].display.updateNAV({'nav-id': 2, val: val});
}, 1, 2);
setlistener('/instrumentation/zkv1000/radios/nav-tune',
func (n) {
var val = n.getValue();
setNavTune();
foreach (var c; keys(flightdeck))
if (flightdeck[c] != nil)
flightdeck[c].display.updateNAV({tune: val});
}, 1, 2);
setlistener('/instrumentation/zkv1000/radios/comm-tune',
func (n) {
var val = n.getValue();
setCommTune();
foreach (var c; keys(flightdeck))
if (flightdeck[c] != nil)
flightdeck[c].display.updateCOMM({tune: val});
}, 1, 2);
setlistener('/instrumentation/zkv1000/afcs/heading-bug-deg',
func (n) {
var val = n.getValue();
if (val != nil) {
foreach (var c; keys(flightdeck))
if (flightdeck[c] != nil and flightdeck[c].role == 'PFD')
flightdeck[c].display.updateHDG(val);
}
}, 0, 2);
setlistener('/instrumentation/zkv1000/PFD/knobs/CRS',
func (n) {
var val = n.getValue();
if (val != nil) {
foreach (var c; keys(flightdeck))
if (flightdeck[c] != nil and flightdeck[c].role == 'PFD')
flightdeck[c].display.updateCRS();
}
}, 0, 2);
setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft',
func (n) {
var val = n.getValue();
if (val != nil)
foreach (var c; keys(flightdeck))
if (flightdeck[c] != nil and 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] != nil and flightdeck[c].role == 'PFD')
flightdeck[c].display.updateXPDR(),
0, 0);
setlistener('/instrumentation/altimeter/setting-inhg',
func foreach (var c; keys(flightdeck))
if (flightdeck[c] != nil and flightdeck[c].role == 'PFD')
flightdeck[c].display.updateBARO(), 0, 2);
}
var deviceClass = {
new: func (role) {
var m = { parents: [ deviceClass ] };
m.role = role;
m.node = zkv.getNode(role, 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.role);
m.display.showInitProgress(m.role);
m.softkeys = softkeysClass.new(m, m.node, m.role);
m.buttons = buttonsClass.new(m.node);
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.role ~ 'init').setIntValue(0);
setprop('/instrumentation/zkv1000/' ~ m.role ~ '/status', 1);
msg(m.role ~ ' switched on!');
return m;
},
};
var powerOn = func {
foreach (var role; keys(flightdeck))
if (zkv.getNode(role) != nil)
# thread.newthread(func {
flightdeck[role] = deviceClass.new(role);
# });
settimer(setListeners, 5);
}