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 (n) { var val = n.getValue(); device[0].display.updateNAV({'nav-id': 1, val: val}); device[0].display.updateNAV({'nav-id': 1, val: val}); }, 1, 2); setlistener('/instrumentation/nav[1]/nav-id', func (n) { var val = n.getValue(); device[0].display.updateNAV({'nav-id': 2, val: val}); device[1].display.updateNAV({'nav-id': 2, val: val}); }, 1, 2); setlistener('/instrumentation/zkv1000/radios/nav-tune', func (n) { var val = n.getValue(); setNavTune(); device[0].display.updateNAV({tune: val}); device[1].display.updateNAV({tune: val}); }, 1, 2); setlistener('/instrumentation/zkv1000/radios/comm-tune', func (n) { var val = n.getValue(); setCommTune(); device[0].display.updateCOMM({tune: val}); device[1].display.updateCOMM({tune: val}); }, 1, 2); setlistener('/instrumentation/zkv1000/afcs/heading-bug-deg', func (n) { var val = n.getValue(); if (val != nil) { device[0].display.updateHDG(val); device[1].display.updateHDG(val); } }, 0, 2); setlistener('/instrumentation/zkv1000/cdi/course', func (n) { var val = n.getValue(); if (val != nil) { device[0].display.updateCRS(val); device[1].display.updateCRS(val); } }, 0, 2); setlistener('/instrumentation/zkv1000/afcs/selected-alt-ft', func (n) { print('/instrumentation/zkv1000/afcs/selected-alt-ft'); var val = n.getValue(); if (val != nil) { device[0].display.screenElements['SelectedAlt-bug'].show(); device[0].display.screenElements['SelectedAlt-top'].show(); device[0].display.updateSelectedALT(); } }, 0, 2); setlistener('/gear/gear/wow', func device[0].display.updateXPDR(), 0, 0); } 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, m.role); m.display.showInitProgress(m.role); m.buttons = buttonsClass.new(m.node); m.knobs = knobsClass.new(m.node); m.softkeys = softkeysClass.new(m, m.node, m.role); #m.softkeys.clean(); 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); settimer(setListeners, 5); }