1 contributor
var main_loop_id = 0;
var loop_check_functions_max_index = 0;
var loop_check_functions = [];
var device = [nil, nil];
var deviceClass = {};
var init_main_loop = func {
loop_check_functions = [
pfdCursors,
checkTrafficProximity,
checkMarkerBaecon,
device[0] == nil ? void : func { moveMap (0) },
checkRollAcquisition,
checkPitchAcquisition,
pfdCursors,
computeAltitudeDiff,
computeAirspeedDiff,
device[1] == nil ? void : func { moveMap(1) },
checkAlerts,
];
loop_check_functions_max_index = size(loop_check_functions);
}
var main_loop = func () {
getData();
FLCcomputation();
loop_check_functions[main_loop_id]();
main_loop_id += 1;
if (main_loop_id == loop_check_functions_max_index) main_loop_id = 0;
settimer(main_loop, 0);
}
# les listeners triggent en permanence sur les fréquences...
var setListeners = func {
setlistener('/instrumentation/nav/nav-id',
func {
device[0].display.updateNAV({'nav-id': 1});
device[0].display.updateNAV({'nav-id': 1});
}, 1, 2);
setlistener('/instrumentation/nav[1]/nav-id',
func {
device[0].display.updateNAV({'nav-id': 2});
device[1].display.updateNAV({'nav-id': 2});
}, 1, 2);
setlistener('/instrumentation/zkv1000/radios/nav-tune',
func {
setNavTune();
device[0].display.updateNAV({tune: 1});
device[1].display.updateNAV({tune: 1});
}, 1, 2);
}
var deviceClass = {
new: func (d) {
var m = { parents: [ deviceClass ] };
m.role = d ? 'MFD' : 'PFD';
m.node = zkv.getNode('device[' ~ d ~ ']', 1);
m.display = displayClass.new(m.node, m.role);
m.display.showInitProgress(m.role);
m.buttons = buttonsClass.new(m.node);
m.knobs = knobsClass.new(m.node);
m.softkeys = softkeysClass.new(m.node, m.role);
m.display.loadsvg();
m.display.loadGroup({
hide : [
'Failures',
'SoftKeysTexts',
'PFD-Widgets',
'COMM',
'XPDR-TIME',
'NAV',
'FlightInstruments',
'VDI',
'OMI',
],
clip : 'PitchScale',
});
zkv.getNode(m.role ~ 'init').setIntValue(0);
m.setstatus(d + 1);
msg(m.role ~ ' switched on!');
return m;
},
status: 0,
role: '',
setstatus: func (s) {
if (s == 1) {
}
elsif (s == 2) {
me.rootmenu = 12;
me.node.getNode('mfd-title',1).setValue('TOPO');
}
me.status = s;
me.node.getNode('status', 1).setIntValue(s);
},
MFD: func {
m.rootmenu = 12;
m.newstatus(2);
m.node.getNode('mfd-title',1).setValue('TOPO');
},
MENUkeyItems: {},
set_MENUkeyItems: func {
me.MENUkeyItems = {
'MAIN MENU': [
[['ROUTE MANAGER'], func { me.MENUsoftkey('ROUTE MANAGER') }],
[['GENERAL OPTIONS'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
],
'ROUTE MANAGER': [
[[sprintf('%sACTIVATE ROUTE MANAGER', getprop('/autopilot/route-manager/active') ? 'DES' : ''), ' '],
func {
getprop('/autopilot/route-manager/route/num') or return;
setprop('/autopilot/route-manager/current-wp', 0);
var v = getprop('/autopilot/route-manager/active');
setprop('/autopilot/route-manager/active', !v);
me.mud.node.getNode('line[' ~ me.mud.selected.first_line ~ ']').setValue(sprintf('%sACTIVATE ROUTE MANAGER', v ? '' : 'DES'));
}],
[['SEARCH AIRPORT'], void],
[['SEARCH NAVAID'], void],
[['SEARCH FIX'], void],
[['BACK'], func { me.MENUsoftkey('MAIN MENU') }],
],
'BACKLIGHT LEVEL': [
[['HIGH'], func { setprop('/instrumentation/zkv1000/emission', 1.0) }],
[['MEDIUM HIGH'], func { setprop('/instrumentation/zkv1000/emission', 0.6) }],
[['MEDIUM LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.4) }],
[['LOW'], func { setprop('/instrumentation/zkv1000/emission', 0.2) }],
[[' ', 'BACK'], func { me.MENUsoftkey('GENERAL OPTIONS') }],
],
'GENERAL OPTIONS': [
[['ADJUST BACKLIGHT'], func { me.MENUsoftkey('BACKLIGHT LEVEL') }],
[['MAX NAVAIDS SHOW'], void],
],
};
},
};
var powerOn = func {
device[0] = deviceClass.new(0);
device[1] = deviceClass.new(1);
setListeners();
}