# mfd.nas to drive gauges of the VMD MFD # ### Original code copied from EC130.nas, original author Melchior Franz ### ### adopted by litzi for Helionix VMD-, NAVD-, DMAP- and FND-displays ### # ==== NAVDISPLAY ===== # calculate bearing and distances of navaids for navdisplay (navd). # the last and the next 4 waypoints of the flightplan are # shown on the navd. var navdisplay = { new: func () { var m = { parents: [Timerloop.new(), navdisplay] }; m.maxrng = 40; m.maxn = 20; m.navlist = []; m.usedids = std.Vector.new(); m.navdfilter = 1; m.rr = 5; m.id = 99; return m; }, addsym: func (i, x) { setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/sym", x.symbol); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/distance-norm", x.reldst); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/distance-nm", x.distance_nm); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/rel-bearing", x.relbearing); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/bearing-deg", x.bearing_deg); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/rel-course", x.relcourse); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/id", x.id); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/ils-course", x.course); var info = ""; # generate the info string for VOR and ILS if (x.symbol == 0 or x.symbol == 5) var info = sprintf("%-8.8s %6.2f", x.name, x.frequency/100); #..for waypoints if (x.symbol == 1 or x.symbol == 4) var info=sprintf("%-11.11s", x.name); if (x.symbol == 2) var info = sprintf("%-11.11s %3.0f", x.name, x.frequency/100); if (x.symbol == 3) var info = sprintf("%-8.8s %4.0fft", x.name, x.elevation*M2FT); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/info", info); if (x.type == "ILS" or x.type == "VOR" or x.type == "NDB") setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/frequency", x.frequency); else setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/frequency", 0); return x.id; }, delsym: func (i) { setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/sym", -1); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/distance-norm", 99); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/distance-nm", ""); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/rel-bearing", 0); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/rel-course", 0); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/bearing-deg", ""); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/ils-course", 0); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/frequency", 0); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/id", ""); setprop(mfdroot ~ "navd/sym[" ~ i ~ "]/info", ""); }, update: func() { me.navlist = []; me.usedids = std.Vector.new(); me.navdfilter = getprop(datafltr); me.rr = (getprop(rngprop) or 1) * (getprop(scaleprop) or 1); me.maxrng = (getprop(rngprop) or 5) * 1.4; if (me.navdfilter==2) { # add flightplan waypoints on top of list var fplan = flightplan(); var fplans = fplan.getPlanSize(); # for mode 1 show only 4 next wypts var first = max(0, fplan.current - 1); var n = (me.navdfilter!=1) ? fplans : min(5 + first, fplans); for (var i=first; i