var xpdr_digits = 1; var xpdr_id_timer = 0; var tofromflag = nil; var radios_list = [ '/instrumentation/nav/frequencies/standby-mhz', '/instrumentation/nav[1]/frequencies/standby-mhz', '/instrumentation/nav/frequencies/selected-mhz', '/instrumentation/nav[1]/frequencies/selected-mhz', '/instrumentation/comm/frequencies/standby-mhz', '/instrumentation/comm[1]/frequencies/standby-mhz', '/instrumentation/comm/frequencies/selected-mhz', '/instrumentation/comm[1]/frequencies/selected-mhz', ]; var setNavTune = func { var freq = radios.getNode('nav-freq-mhz', 1); freq.unalias(); freq.alias(radios_list[getprop('/instrumentation/zkv1000/radios/nav-tune')]); } var setCommTune = func { var freq = radios.getNode('comm-freq-mhz', 1); freq.unalias(); freq.alias(radios_list[getprop('/instrumentation/zkv1000/radios/comm-tune') + 4]); } var aliases = { NAV : { 'in-range' : 'in-range', 'course' : 'radials/selected-deg', 'course-deflection' : 'heading-needle-deflection', 'FROM-flag' : 'from-flag', 'TO-flag' : 'to-flag', 'radial' : 'radials/reciprocal-radial-deg', }, GPS : { 'course' : 'desired-course-deg', 'course-deflection' : 'wp/wp[1]/course-error-nm', 'FROM-flag': 'wp/wp[1]/from-flag', 'TO-flag': 'wp/wp[1]/to-flag', } }; var CDIfromSOURCE = func (source) { if (source == 'OFF') { # all the aliases of GPS are included in NAV too foreach (var a; keys(aliases['NAV'])) cdi.getNode(a).unalias(); } else { var s = (source == 'GPS') ? 'gps' : 'nav[' ~ (right(source, 1) - 1) ~ ']'; foreach (var a; keys(aliases[left(source, 3)])) { cdi.getNode(a).unalias(); cdi.getNode(a).alias('/instrumentation/' ~ s ~ '/' ~ aliases[left(source, 3)][a]); } } } var XPDR_change_cursor_position = func (dir) { xpdr_digits = (xpdr_digits == 1)? 100 : 1; xpdr_id_timer += 1; } var XPDR_enter_digits = func (dir) { var code = getprop('/instrumentation/transponder/id-code'); var c = substr(sprintf('%04i', code), (xpdr_digits == 1)? 2 : 0, 2); if (dir > 0) { if (c[0] == `7`and c[1] == `7`) { dir = -77; } elsif (c[1] == `7`) { dir = 3; } } else { if (c[0] == `0` and c[1] == `0`) { dir = 77; } elsif (c[1] == `0`) { dir = -3; } } setprop('/instrumentation/transponder/id-code', code + (dir * xpdr_digits)); xpdr_id_timer += 1; } var XPDR_activate_code = func (timer) { if (timer) { xpdr_id_timer -= 1; return (xpdr_id_timer < 1); } return 1; } var checkMarkerBaecon = func { if (getprop('/instrumentation/marker-beacon/inner')) { alerts.getNode('marker-beacon').setIntValue(1); } elsif (getprop('/instrumentation/marker-beacon/middle')) { alerts.getNode('marker-beacon').setIntValue(2); } elsif (getprop('/instrumentation/marker-beacon/outer')) { alerts.getNode('marker-beacon').setIntValue(3); } else { alerts.getNode('marker-beacon').setIntValue(0); } } foreach (var r; radios_list) props.globals.getNode(r ~ '-dec',1).setIntValue(0);