diff --git a/A320-main.xml b/A320-main.xml index 776b33ed..b079684d 100644 --- a/A320-main.xml +++ b/A320-main.xml @@ -1692,7 +1692,7 @@ - 0 + 121.5 123.2 true diff --git a/Models/FlightDeck/a320.flightdeck.xml b/Models/FlightDeck/a320.flightdeck.xml index 944782a3..96196fb3 100644 --- a/Models/FlightDeck/a320.flightdeck.xml +++ b/Models/FlightDeck/a320.flightdeck.xml @@ -1447,14 +1447,32 @@ - - systems/electrical/bus/dc-ess - 25 - + + + systems/electrical/bus/dc-ess + 25 + + property-toggle controls/switches/terr_on_nd_l + + + + + systems/electrical/bus/dc-ess + 25 + + + instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit + 0 + + + + property-toggle + instrumentation/efis/inputs/terr + @@ -1488,14 +1506,32 @@ - - systems/electrical/bus/dc-ess - 25 - + + + systems/electrical/bus/dc-ess + 25 + + property-toggle controls/switches/terr_on_nd_r + + + + + systems/electrical/bus/dc-ess + 25 + + + instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit + 0 + + + + property-toggle + instrumentation/efis[1]/inputs/terr + diff --git a/Models/Instruments/ND/canvas/ND.nas b/Models/Instruments/ND/canvas/ND.nas index d1e73e51..5fe845d3 100644 --- a/Models/Instruments/ND/canvas/ND.nas +++ b/Models/Instruments/ND/canvas/ND.nas @@ -180,6 +180,17 @@ var canvas_nd_base = { }, }; +var ND_change_timer_fn = func { + #me.change_phase += 1; + #if (me.change_phase>2) { # phase 3 - only for older ND? + #if (me.change_phase>1) { # phase 2 hide + me.change_timer.stop(); + me.change_phase = 0; + #} else { + me.map.setVisible(1); # phase 2 + #} +}; + var canvas_ND_1 = { new: func(canvas_group) { var m = {parents: [canvas_ND_1, canvas_nd_base]}; @@ -190,6 +201,8 @@ var canvas_ND_1 = { me.NDCpt.attitude_heading_setting = -1; me.NDCpt.adirs_property = props.globals.getNode("/instrumentation/efis[0]/nd/ir-1",1); me.NDCpt.newMFD(canvas_group); + me.NDCpt.change_phase = 0; + me.NDCpt.change_timer = maketimer(0.6,me.NDCpt,ND_change_timer_fn); me.NDCpt.update(); return m; @@ -213,6 +226,8 @@ var canvas_ND_2 = { me.NDFo.attitude_heading_setting = 1; me.NDFo.adirs_property = props.globals.getNode("/instrumentation/efis[1]/nd/ir-2",1); me.NDFo.newMFD(canvas_group); + me.NDFo.change_phase = 0; + me.NDFo.change_timer = maketimer(0.4,me.NDFo,ND_change_timer_fn); me.NDFo.update(); return m; @@ -357,7 +372,7 @@ setlistener("sim/signals/fdm-initialized", func { }, 1, 0); setlistener("/instrumentation/tcas/inputs/mode", func() { - if (getprop("/instrumentation/efis[1]/nd/canvas-display-mode") != "PLAN") { + if (getprop("/instrumentation/efis[0]/nd/canvas-display-mode") != "PLAN") { canvas_nd.ND_1.NDCpt.trafficGroup.setVisible(pts.Instrumentation.TCAS.Inputs.mode.getValue() >= 2 ? 1 : 0); } if (getprop("/instrumentation/efis[1]/nd/canvas-display-mode") != "PLAN") { @@ -373,6 +388,21 @@ setlistener("sim/signals/fdm-initialized", func { canvas_nd.ND_2.NDFo.trafficGroup.setVisible(getprop("/instrumentation/efis[1]/nd/canvas-display-mode") == "PLAN" ? 0 : 1); }, 1, 0); + setlistener("/instrumentation/efis[0]/nd/display-mode", func { + startChangePhase(canvas_nd.ND_1.NDCpt,"MODE CHANGE"); + },0,0); + + setlistener("/instrumentation/efis[0]/inputs/range-nm", func { + startChangePhase(canvas_nd.ND_1.NDCpt,"RANGE CHANGE"); + },0,0); + setlistener("/instrumentation/efis[1]/nd/display-mode", func { + startChangePhase(canvas_nd.ND_2.NDFo,"MODE CHANGE"); + },0,0); + + setlistener("/instrumentation/efis[1]/inputs/range-nm", func { + startChangePhase(canvas_nd.ND_2.NDFo,"RANGE CHANGE"); + },0,0); + nd_update.start(); if (getprop("systems/acconfig/options/nd-rate") > 1) { rateApply(); @@ -417,14 +447,22 @@ for (i = 0; i < 2; i = i + 1 ) { }); } -setlistener("/instrumentation/efis[0]/nd/terrain-on-nd", func{ - var terr_on_hd = getprop("instrumentation/efis[0]/nd/terrain-on-nd"); - var alpha = 1; - if (terr_on_hd) { - alpha = 0.5; - } - nd_display.main.setColorBackground(0,0,0,alpha); -}); +var startChangePhase = func(nd,txt) { + nd.change_timer.stop(); + nd.map.setVisible(0); + nd.symbols.nd_msg_change.setText(txt); + nd.change_phase = 1; + nd.change_timer.start(); +} + +#setlistener("/instrumentation/efis[0]/nd/terrain-on-nd", func{ +# var terr_on_hd = getprop("instrumentation/efis[0]/nd/terrain-on-nd"); +# var alpha = 1; +# if (terr_on_hd) { +# alpha = 0.5; +# } +# nd_display.main.setColorBackground(0,0,0,alpha); +#}); setlistener("/flight-management/control/capture-leg", func(n) { var capture_leg = n.getValue(); diff --git a/Models/Instruments/ND/canvas/framework/navdisplay.nas b/Models/Instruments/ND/canvas/framework/navdisplay.nas index 7778f57c..01569ad3 100644 --- a/Models/Instruments/ND/canvas/framework/navdisplay.nas +++ b/Models/Instruments/ND/canvas/framework/navdisplay.nas @@ -13,6 +13,110 @@ var assert_m = canvas.assert_m; var wxr_live_tree = "/instrumentation/wxr"; var adirs_3 = props.globals.getNode("/instrumentation/efis[0]/nd/ir-3", 1); +var easeArrow = { + new: func(elem) { + var m = {parents: [easeArrow]}; + m.req_rot_rad = 0; + m.req_rot_deg = 0; + m.last_rot_deg = nil; + m.last_rot_rad = 0; + m.element = elem; + m.time = 0; + m.duration = 0; + m.startval = 0; + m.diffval = 0; + return m; + }, + setVisible: func(v) { + if (v == 1 and me.last_rot_deg == nil) me.reset(); + me.element.setVisible(v); + }, + hide: func { + me.element.hide(); + }, + reset: func { + me.last_rot_deg = 360 - getprop("orientation/heading-deg"); + me.last_rot_rad = me.last_rot_deg * D2R; + me.duration = 0; + print("VOR reset"); + }, + setRotation: func(rad) { + var deg = 0; + var gap = 0; + gap = math.abs(rad - me.req_rot_rad); + if (gap>0.001) { + if (me.duration>0) gap = math.abs(rad - me.last_rot_rad); + if (gap>=180*D2R) gap = 360*D2R - gap; + deg = rad * 57.29578; + me.req_rot_rad = rad; + me.req_rot_deg = deg; + me.duration = 0; + if (gap>0.2) { + if (me.last_rot_deg == nil) me.reset(); + me.startval = me.last_rot_deg; + me.diffval = deg - me.last_rot_deg; + if (me.diffval<0) me.diffval += 360; + me.time = 0; + me.duration = math.round(me.diffval * 0.21); # rad 36/3 + } + if (me.duration < 2) { + me.last_rot_rad = rad; + me.last_rot_deg = deg; + me.element.setRotation(rad); + me.duration = 0; + } + } + if (me.duration > 0) { + var tx = me.time / me.duration; + #thanks to https://easings.net/#easeOutCubic + deg = (1 - math.pow(1 - tx, 3)) * me.diffval + me.startval; + deg = math.mod(deg,360); + #print("DEG: " ~ deg); + me.last_rot_deg = deg; + me.last_rot_rad = deg * D2R; + me.element.setRotation(me.last_rot_rad); + me.time += 1; + if (tx>=1) me.duration = 0; + } + + } +}; + +var symbolDistNM = { + new: func(name, nd) { + var m = {parents: [symbolDistNM] }; + m.group = nd.getElementById(name); + m.expn = nd.getElementById(name ~ "1"); + m.mant = nd.getElementById(name ~ "2"); + return m; + }, + hide: func { + me.group.hide(); + }, + show: func { + me.group.show(); + }, + setText: func(txt) { + var parts = ( txt != "" ) ? split( "." , txt ) : nil; + if ( parts != nil and size(parts) == 2 ) { + me.expn.setText(parts[0]); + me.mant.setText("." ~ parts[1]); + } else { + me.expn.setText(txt); + me.mant.setText(""); + } + }, + setColor: func(r,g,b) { + me.expn.setColor(r,g,b); + me.mant.setColor(r,g,b); + }, + setFloat: func(val) { + var parts = split( "." , sprintf("%03.1f",val) ); + me.expn.setText(parts[0]); + me.mant.setText("." ~ parts[1]); + } +}; + canvas.NavDisplay.set_switch = func(s, v) { var switch = me.efis_switches[s]; if(switch == nil) return nil; @@ -68,19 +172,28 @@ canvas.NavDisplay.newMFD = func(canvas_group, parent=nil, nd_options=nil, update ### this is the "old" method that"s less flexible, we want to use the style hash instead (see above) # because things are much better configurable that way # now look up all required SVG elements and initialize member fields using the same name to have a convenient handle - foreach(var element; ["dmeLDist","dmeRDist","dmeL","dmeR","vorL","vorR","vorLId","vorRId", - "status.wxr","status.wpt","status.sta","status.arpt"]) + foreach(var element; ["dmeL","dmeR","vorL","vorR","vorLId","vorRId", + "status.wxr","status.wpt","status.sta","status.arpt","terrHI","terrLO","TerrLabel","terrAhead"]) me.symbols[element] = me.nd.getElementById(element); + foreach(var element; ["dmeLDist","dmeRDist"]) + me.symbols[element] = symbolDistNM.new( element, me.nd ); + + me.symbols.dmeLDist.setColor(0.195,0.96,0.097); + me.symbols.dmeRDist.setColor(0.195,0.96,0.097); + # load elements from vector image, and create instance variables using identical names, and call updateCenter() on each # anything that needs updatecenter called, should be added to the vector here # - foreach(var element; ["staArrowL2","staArrowR2","staFromL2","staToL2","staFromR2","staToR2", + foreach(var element; ["staFromL2","staToL2","staFromR2","staToR2", "hdgTrk","trkInd","hdgBug","HdgBugCRT","TrkBugLCD","HdgBugLCD","curHdgPtr", "HdgBugCRT2","TrkBugLCD2","HdgBugLCD2","hdgBug2","selHdgLine","selHdgLine2","curHdgPtr2", - "staArrowL","staArrowR","staToL","staFromL","staToR","staFromR"] ) + "staToL","staFromL","staToR","staFromR"] ) me.symbols[element] = me.nd.getElementById(element).updateCenter(); + foreach(var element; ["staArrowL2","staArrowR2","staArrowL","staArrowR"] ) + me.symbols[element] = easeArrow.new( me.nd.getElementById(element).updateCenter() ); + me.map = me.nd.createChild("map","map") .set("clip", "rect(124, 1024, 1024, 0)") .set("screen-range", 700) @@ -499,7 +612,7 @@ canvas.NavDisplay.update = func() # FIXME: This stuff is still too aircraft spec var adf1hdg = getprop("/instrumentation/adf[1]/indicated-bearing-deg"); if(!me.get_switch("toggle_centered")) { - if(me.in_mode("toggle_display_mode", ["PLAN"]) or (me.adirs_property.getValue() != 1 and (adirs_3.getValue() != 1 or att_switch.getValue() != me.attitude_heading_setting))) + if(me.in_mode("toggle_display_mode", ["PLAN"]) or (me.adirs_property.getValue() != 1 or (me.change_phase == 1) and (adirs_3.getValue() != 1 or att_switch.getValue() != me.attitude_heading_setting))) me.symbols.trkInd.hide(); else me.symbols.trkInd.show(); diff --git a/Models/Instruments/ND/canvas/map/TERRAIN.lcontroller b/Models/Instruments/ND/canvas/map/TERRAIN.lcontroller new file mode 100644 index 00000000..4fba3af4 --- /dev/null +++ b/Models/Instruments/ND/canvas/map/TERRAIN.lcontroller @@ -0,0 +1,51 @@ +# See: http://wiki.flightgear.org/MapStructure +# Class things: +var name = 'TERRAIN'; +var parents = [canvas.SymbolLayer.Controller]; +var __self__ = caller(0)[0]; + +canvas.SymbolLayer.Controller.add(name, __self__); +canvas.SymbolLayer.add(name, { + parents: [MultiSymbolLayer], + type: name, # Symbol type + df_controller: __self__, # controller to use by default -- this one + df_options: { # default configuration options + viewport_radius: 670 + } +}); + +var new = func(layer) { + var m = { + parents: [__self__], + layer: layer, + map: layer.map, + listeners: [], + }; + layer.searcher._equals = func(l,r) l.equals(r); + m.addVisibilityListener(); + return m; +}; + +var del = func() { + #print(name~".lcontroller.del()"); + foreach (var l; me.listeners) + removelistener(l); +}; + +var searchCmd = func { + if(me.map.getRange() == nil) return []; + + var pos = geo.aircraft_position(); + lat = pos.lat(); + lon = pos.lon(); + + var result = geo.Coord.new(); + result.set_latlon(lat, lon); + result.rangeNm = me.map.getRange(); + result.fetchRad = 184; # is this number accurate? + result.equals = func(r){ + me.fetchRad == r.fetchRad and me.lat == r.lat and me.lon == r.lon + }; + + return [result]; +}; diff --git a/Models/Instruments/ND/canvas/map/TERRAIN.symbol b/Models/Instruments/ND/canvas/map/TERRAIN.symbol new file mode 100644 index 00000000..6d226040 --- /dev/null +++ b/Models/Instruments/ND/canvas/map/TERRAIN.symbol @@ -0,0 +1,429 @@ +# See: http://wiki.flightgear.org/MapStructure +# Class things: + +## Airbus Terrain on ND by InuYaksa*2021 +## EGPWS device - Applicable to: MSN 0112 +## Ident.: DSC-31-45-00009586.0012001 / 22 MAY 12 +## Ident.: DSC-31-45-00009586.0009001 / 08 AUG 13 + +## inspired from work on 787-family - thanks a lots +## and a great help from legoboyvdlp + +var name = 'TERRAIN'; +var parents = [DotSym]; +var __self__ = caller(0)[0]; +DotSym.makeinstance( name, __self__ ); + +var element_type = "group"; + +var terrain_minalt = props.globals.initNode("/instrumentation/efis[0]/nd/terrain-on-nd/min-altitude", 0,"INT"); +var terrain_maxalt = props.globals.initNode("/instrumentation/efis[0]/nd/terrain-on-nd/max-altitude", -9999,"INT"); +var terrain_maxcol = props.globals.initNode("/instrumentation/efis[0]/nd/terrain-on-nd/max-color", 0,"INT"); # 0= grn, 1= yel, 2= red + +var terrain_alert = props.globals.getNode("/instrumentation/mk-viii/outputs/alert-mode"); + +var tile_list = [ + nil,"tile_gl.png","tile_gh.png","tile_al.png","tile_ah.png","tile_rh.png", # 0-5 low alt - imho real ND displays as amber-ish color than yellow one + "tile_gl.png","tile_gh.png","tile_gh.png","tile_gs.png", # 6-9 hi alt + "tile_ml.png","tile_cl.png", # 10 magenta - 11 cyan-ish/blue (water) + "tile_as.png","tile_rs.png" # 12-13 alert - solid colors + ]; + +var is_terrain = 0; + +var get_elevation = func (lat, lon) { + var info = geodinfo(lat, lon); + var elevation = 0; + if (info != nil) { + elevation = int(info[0] * 3.2808399); + me.is_terrain = (info[1] == nil) ? 1 : info[1].solid; + } + else { elevation = nil; } + return elevation; +} + +var updateTerrain = func { + + if (me.reference == nil) return; + + if(me.fetching) return; + + me.fetching = 1; + + if (me.request_clear == 1) { + me.request_clear = 0; + me.clear(); + me.group.setVisible(1); + } + + var RAD2DEG = 57.2957795; + var DEG2RAD = 0.016774532925; + + var pos_lat = me.reference.lat(); + var pos_lon = me.reference.lon(); + + var heading = me.refheading; + var altitudeft = me.refaltitudeft; + var lowaltft = me.reflowaltft; + var basealtft = me.basealtitudeft; + var alert_level = me.terrain_alert.getValue(); + + var side = (math.mod(me.radar_beacon,2)==0) ? "L" : "R"; + var a = int(me.radar_beacon/2); + var col = a + 0.5; + + if (side == "R") { + col = -col; + } + + var trn = me.terrlayer[side ~ a]; + + var len = size(trn); + var range = me.range; + + var tiles = me.tile_list; + + #var proj_lon = pos_lon + ((col * (range/30) * math.sin(DEG2RAD * (heading - 90))) / 40); + #var proj_lat = pos_lat + ((col * (range/30) * math.cos(DEG2RAD * (heading - 90))) / 40); + + # if me.tileradiusw == 20 + var range_20f = range / 18.75; + var heading_sin = math.sin(DEG2RAD * heading); + var heading_cos = math.cos(DEG2RAD * heading); + + var proj_lon = pos_lon + ((col * range_20f * math.sin(DEG2RAD * (heading - 90))) / 60); + var proj_lat = pos_lat + ((col * range_20f * math.cos(DEG2RAD * (heading - 90))) / 60); + + var elevft = []; + + me.radar_cleared = 0; + + for (var row = 0; row < len; row += 1) { + + if (trn[row] == nil) { + append(elevft,-1); + continue; + } + + var point_lon = proj_lon + ((row * range_20f / 60) * heading_sin); + var point_lat = proj_lat + ((row * range_20f / 60) * heading_cos); + + var elev = me.get_elevation(point_lat, point_lon); + var grad = 0; #black + if (elev != nil) { + if (elev>me.max_altitude) me.max_altitude = elev; + if (me.is_terrain) { + if (elev=0) { + grad = int(diff/1000) + 3; + if (grad>5) grad = 5; + if (alert_level > 0 and a < 6 and grad > 3) { + if (alert_level == 1 and (grad == 3 or grad == 4)) grad = 12; # solid yellow + else if (alert_level == 2 and grad == 5) grad = 13; # solid red + } + } else { + if (me.hialtmode == 0) { + if (diff>=lowaltft) grad = 3; # lite yellow + else { + grad = int(diff/1000) + 2; + if (grad<0) grad = 0; + } + } else { + if (diff>=lowaltft) grad = 3; # lite yellow + else { + if (me.bands_range > 0 and elev > me.bands_minalt) { + grad = 9 - int((me.bands_maxalt - elev) / me.bands_range); + if (grad>9) grad = 9; # solid green + else if (grad<6) grad = 6; #light green + } + } + } + } + } + } else { + grad = 11; #water/cyan + } + append(elevft,grad); # 0-5 + } else { + append(elevft,0); # no data - black (magenta) + } + + } + + if (me.min_altitude > me.max_altitude) me.min_altitude = me.max_altitude; # occurs on sea areas + + for (var r=0; r < len; r+=1) { + var imgx = elevft[r]; + if (imgx == -1) continue; + if (imgx < 1) trn[r].hide(); + else trn[r].setFile(me.imgpath ~ me.tile_list[imgx]).show(); + } + + me.radar_beacon += 1; + if (me.radar_beacon >= (me.tileradiusw*2)) { + me.restart_beacon(); + } + + me.fetching = 0; +}; + +var update_altitudes = func { + + me.terrain_minalt.setValue(me.min_altitude); + me.terrain_maxalt.setValue(me.max_altitude); + + var altdif = me.max_altitude - me.refaltitudeft; + if (altdif <= 0) { + if (altdif >= me.reflowaltft) me.terrain_maxcol.setValue(1); + else me.terrain_maxcol.setValue(0); + } else { + if (altdif>2000) me.terrain_maxcol.setValue(2); + else me.terrain_maxcol.setValue(1); + } + + if (me.min_altitude == 9999) { + me.avg_minalt = me.min_altitude; + me.avg_maxalt = me.max_altitude; + } else { + #if (me.min_altitude < me.avg_minalt) me.avg_minalt = me.min_altitude;else + me.avg_minalt = math.round((me.avg_minalt * 2 + me.min_altitude) / 3); + #if (me.max_altitude > me.avg_maxalt) me.avg_maxalt = me.max_altitude;else + me.avg_maxalt = math.round((me.avg_maxalt * 2 + me.max_altitude) / 3); + } + + me.avg_peakalt = me.avg_maxalt - me.avg_minalt; + + if (me.onground == 0 and (me.max_altitude + 250) < me.refaltitudeft) { # 250 ft tollerance + me.hialtmode = 1; + var range = math.min(2400,(me.avg_maxalt - me.avg_minalt)) - 400; + if (range < 400) { # min elev number + me.bands_range = 0; + } else { + me.bands_range = int(range / 4); + me.bands_maxalt = me.avg_maxalt; + me.bands_minalt = math.max( me.avg_maxalt - range, me.avg_minalt + 400 ); + } + } else { + me.hialtmode = 0; + #me.avg_minalt = 9999; + } + + me.min_altitude = 9999; + me.max_altitude = -9999; + +} + +var restart_beacon = func { + me.radar_beacon = 0; + me.radar_cycle += 1; + me.reference = nil; +}; + +var init = func { + #print('TERRAIN init'); + me.tile = 33; + me.fetching = 0; + me.fetchRad = me.model.fetchRad; # Radius of radar layer to fetch + me.range = me.model.rangeNm; # Range of Navigation Display + me.viewport_radius = me.getOption('viewport_radius', 670); + me.imgpath = get_local_path('res/terrainv2/'); + me.radar_beacon = 0; + me.radar_cycle = 0; + me.radar_cleared = 1; + me.request_clear = 0; + me.min_altitude = 9999; + me.max_altitude = -9999; + me.avg_minalt = 9999; + me.avg_maxalt = -9999; + me.avg_peakalt = nil; + me.maxalt_col = 0; # 0 = grn, 1 = yel, 2 = red + me.bands_minalt = 0; + me.bands_maxalt = 0; + me.bands_range = 0; + me.basealtitudeft = nil; + me.reference = nil; + me.onfailure = 0; + me.hialtmode = 0; # high aircraft relative altitude mode + me.checkarrival = 0; + me.onground = 1; + + var tile = me.tile; + + var gx = int(me.viewport_radius / tile); + me.tileradius = gx; + + var limx = int((512/tile)+0.5); # display width is smaller than height + me.tileradiusw = limx; + + me.terrlayer = {}; + + var centx = 0; + var centy = -me.viewport_radius; + + var group = me.group.createChild("group").set("z-index", -100); #me.element + + for (var c=0; c499) ? 400 : 140; + + var vspeed30s = int(getprop("velocities/vertical-speed-fps") * 30); + if (vspeed30s<-500) me.refaltitudeft = math.max(me.avg_minalt , me.refaltitudeft + vspeed30s); + + if (me.basealtitudeft == nil) { # first basealt set + me.basealtitudeft = me.groundaltft + flatalt; + me.flatalt = flatalt; + me.checkarrival = 1; + print("set REFALT [init]: "~me.basealtitudeft); + } else if (fmgc.FMGCInternal.phase < 2) { # starting at phase < 2 + if (me.flatalt != flatalt) { + me.basealtitudeft = me.groundaltft + flatalt; + me.flatalt = flatalt; + print("set REFALT [flat]: "~me.basealtitudeft); + } + } else if (fmgc.FMGCInternal.phase == 5) { + if (me.checkarrival == 1) { + me.checkarrival = 0; + me.basealtitudeft = nil; + if (fmgc.FMGCInternal.arrApt != nil) { + var airport = airportinfo(fmgc.FMGCInternal.arrApt); + if (airport != nil) me.basealtitudeft = flatalt + int(airport.elevation * M2FT); + print("set REFALT [arrApt]: "~me.basealtitudeft); + } + if (me.basealtitudeft == nil) { + me.basealtitudeft = flatalt + me.avg_minalt; # that's fun + } + } + } else if (fmgc.FMGCInternal.phase == 6) { + if (me.checkarrival == 0) { + me.checkarrival = 1; + #me.basealtitudeft = 0; + } + } else if (fmgc.FMGCInternal.phase == 7) { + if (me.checkarrival == 0) { + me.checkarrival = 1; + me.basealtitudeft = me.groundaltft + flatalt; + print("set REFALT [done]: "~me.basealtitudeft); + } + } else if (fmgc.FMGCInternal.phase == 2) { + var expdaltft = me.groundaltft + flatalt; + if (me.basealtitudeft > expdaltft) { + me.basealtitudeft = expdaltft; + print("set REFALT [blwbase]: "~me.basealtitudeft); + } + } else if (fmgc.FMGCInternal.phase >= 2) { + me.basealtitudeft = math.avg(me.basealtitudeft,flatalt + me.groundaltft,int(flatalt + me.avg_minalt)); + #if (me.basealtitudeft > me.avg_maxalt) { + # if (me.avg_maxalt < 1000) me.basealtitudeft = 0; # 1000ft min elev number + # else me.basealtitudeft = int(400 + me.avg_minalt); + # print("set REFALT [blwmin]: "~me.basealtitudeft); + #} + #else if (me.basealtitudeft == 0 and me.avg_maxalt >= 1000) { # 1000ft min elev number + # me.basealtitudeft = int(400 + me.avg_minalt); + # print("set REFALT [abvmin]: "~me.basealtitudeft); + #} + } + + } + + } else { + + var range = me.layer.map.getRange(); # Range of Navigation Display + var update_size = (range != me.range); + me.range = range; + + if (update_size) { + me.request_clear = 1; + } + + me.updateTerrain(); # left + me.updateTerrain(); # right + + } + +}; \ No newline at end of file diff --git a/Models/Instruments/ND/canvas/res/airbusND.svg b/Models/Instruments/ND/canvas/res/airbusND.svg index 88a9ab49..8197f17a 100644 --- a/Models/Instruments/ND/canvas/res/airbusND.svg +++ b/Models/Instruments/ND/canvas/res/airbusND.svg @@ -26,13 +26,13 @@ inkscape:window-height="1017" id="namedview102" showgrid="false" - inkscape:zoom="1.2732019" - inkscape:cx="406.21664" - inkscape:cy="201.87587" + inkscape:zoom="3.1081105" + inkscape:cx="904.96427" + inkscape:cy="819.41055" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" - inkscape:current-layer="layer3" + inkscape:current-layer="terrGroup" inkscape:object-nodes="true" inkscape:snap-smooth-nodes="true" inkscape:snap-object-midpoints="true" @@ -77,7 +77,34 @@ id="guide3115" />image/svg+xmlGijs de RooyTERRAHEADTERR000000ABCD + style="font-size:36px;line-height:1.25;text-align:end;text-anchor:end">XXXX99X VOR 1 + x="39.859375" + y="919.5495">VOR 1 NM + 99.9 -ABC + x="39.9375" + y="956.56171">ABC VOR 2 NM -99.9 + ABC @@ -1234,16 +1302,8 @@ sodipodi:role="line" style="font-size:32px;line-height:125%;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#af0063;fill-opacity:1">999.99 999999999.9999.9MAP NOT AVAIL + style="font-size:53.3333px;line-height:1.25;fill:#ff0000">MAP NOT AVAILRANGE CHANGE diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_ah.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_ah.png new file mode 100644 index 00000000..5151f582 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_ah.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_al.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_al.png new file mode 100644 index 00000000..595d7d87 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_al.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_as.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_as.png new file mode 100644 index 00000000..ccfa1f20 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_as.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_ch.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_ch.png new file mode 100644 index 00000000..204cdc8f Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_ch.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_cl.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_cl.png new file mode 100644 index 00000000..91e1e0ff Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_cl.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_gh.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_gh.png new file mode 100644 index 00000000..9d8c864f Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_gh.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_gl.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_gl.png new file mode 100644 index 00000000..ab83824e Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_gl.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_gs.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_gs.png new file mode 100644 index 00000000..6c61a2be Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_gs.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_mh.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_mh.png new file mode 100644 index 00000000..0e351066 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_mh.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_ml.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_ml.png new file mode 100644 index 00000000..b908287e Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_ml.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_rh.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_rh.png new file mode 100644 index 00000000..8eb51fd5 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_rh.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_rl.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_rl.png new file mode 100644 index 00000000..5d63f97c Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_rl.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_rs.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_rs.png new file mode 100644 index 00000000..d02e5503 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_rs.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_yh.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_yh.png new file mode 100644 index 00000000..bb536295 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_yh.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_yl.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_yl.png new file mode 100644 index 00000000..54edd9e5 Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_yl.png differ diff --git a/Models/Instruments/ND/canvas/res/terrainv2/tile_ys.png b/Models/Instruments/ND/canvas/res/terrainv2/tile_ys.png new file mode 100644 index 00000000..544c985d Binary files /dev/null and b/Models/Instruments/ND/canvas/res/terrainv2/tile_ys.png differ diff --git a/Models/Instruments/ND/canvas/style.nas b/Models/Instruments/ND/canvas/style.nas index 3e6147f2..037ebaf4 100644 --- a/Models/Instruments/ND/canvas/style.nas +++ b/Models/Instruments/ND/canvas/style.nas @@ -12,6 +12,14 @@ var adirs_3 = props.globals.getNode("/instrumentation/efis[0]/nd/ir-3", 1); var vhdg_bug = props.globals.getNode("/it-autoflight/input/hdg",0); # ND compass position deg +var terrain_minalt = props.globals.getNode("/instrumentation/efis[0]/nd/terrain-on-nd/min-altitude", 0); +var terrain_maxalt = props.globals.getNode("/instrumentation/efis[0]/nd/terrain-on-nd/max-altitude", -9999); +var terrain_maxcol = props.globals.getNode("/instrumentation/efis[0]/nd/terrain-on-nd/max-color", 0); +var terrain_alert = props.globals.getNode("/instrumentation/mk-viii/outputs/alert-mode",0); + +var GREEN = [0.0509,0.7529,0.2941]; +var YELLOW = [0.949,0.949,0.207]; +var RED = [1.0000,0.0000,0.0000]; canvas.NDStyles["Airbus"] = { font_mapper: func(family, weight) { @@ -84,15 +92,36 @@ canvas.NDStyles["Airbus"] = { } }, layers: [ + { + name:"TERRAIN", + isMapStructure: 1, + update_on:[ {rate_hz: 10}, "toggle_range","toggle_display_mode","toggle_terrain"], + predicate: func(nd, layer) { + #print("TERRAIN TOGGLE: " ~ nd.get_switch("toggle_terrain")); + var visible = nd.get_switch("toggle_terrain") and + nd.get_switch("toggle_display_mode") != "PLAN" and (nd.rangeNm() <= 40) and + (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting)); + if (visible) { + layer.update(); + } else { + layer.display_changed = 1; + } + layer.group.setVisible(visible); + }, # end of layer update predicate + options: { + viewport_radius: 670, #512, #706, + }, + "z-index": -100, + }, { name:"WXR_live", isMapStructure:1, always_update: 1, - update_on:[ "toggle_range","toggle_weather","toggle_display_mode","toggle_weather_live"], + update_on:[ "toggle_range","toggle_weather","toggle_display_mode","toggle_weather_live","toggle_terrain"], predicate: func(nd, layer) { var visible=nd.get_switch("toggle_weather") and nd.get_switch("toggle_weather_live") and - nd.get_switch("toggle_display_mode") != "PLAN" and (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting)); + nd.get_switch("toggle_display_mode") != "PLAN" and !nd.get_switch("toggle_terrain") and (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting)); layer.group.setVisible(visible); if (visible) { layer.update(); @@ -891,7 +920,8 @@ canvas.NDStyles["Airbus"] = { id:"hdgBug2ValR", #"hdgBug2ValL"", impl: { init: func(nd,symbol), - predicate: func(nd) nd.in_mode("toggle_display_mode", ["MAP"]) and !nd.get_switch("toggle_centered"), + predicate: func(nd) nd.in_mode("toggle_display_mode", ["MAP"]) and !nd.get_switch("toggle_centered") and + (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting)), is_true: func(nd) { var bugRot = vhdg_bug.getValue(); var diffRot = (bugRot>=nd.userHdgTrk) ? (bugRot-nd.userHdgTrk) : (360+bugRot-nd.userHdgTrk); @@ -909,7 +939,8 @@ canvas.NDStyles["Airbus"] = { id:"hdgBug2ValL", impl: { init: func(nd,symbol), - predicate: func(nd) nd.in_mode("toggle_display_mode", ["MAP"]) and !nd.get_switch("toggle_centered"), + predicate: func(nd) nd.in_mode("toggle_display_mode", ["MAP"]) and !nd.get_switch("toggle_centered") and + (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting)), is_true: func(nd) { var bugRot = vhdg_bug.getValue(); var diffRot = (bugRot>nd.userHdgTrk) ? (360+nd.userHdgTrk-bugRot) : (nd.userHdgTrk-bugRot); @@ -1266,9 +1297,9 @@ canvas.NDStyles["Airbus"] = { impl: { init: func(nd,symbol), predicate: func(nd){ - nd.get_switch("toggle_display_mode") == "MAP" and - !nd.get_switch("toggle_centered") and - ( + nd.get_switch("toggle_display_mode") == "MAP" and !nd.get_switch("toggle_centered") + and (nd.change_phase != 1) + and ( getprop(nd.options.defaults.lat_ctrl) != nd.options.defaults.managed_val or nd.get_switch("toggle_trk_line") ) @@ -1284,6 +1315,7 @@ canvas.NDStyles["Airbus"] = { impl: { init: func(nd,symbol), predicate: func(nd) (nd.in_mode("toggle_display_mode", ["APP","VOR","MAP"]) and nd.get_switch("toggle_centered") + and (nd.change_phase != 1) and (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting))), is_true: func(nd) { nd.symbols.trkInd2.show(); @@ -1297,7 +1329,7 @@ canvas.NDStyles["Airbus"] = { impl: { init: func(nd,symbol), predicate: func(nd) (nd.get_switch("toggle_display_mode") == "MAP" and - nd.get_switch("toggle_centered") and + nd.get_switch("toggle_centered") and (nd.change_phase != 1) and getprop(nd.options.defaults.lat_ctrl) != nd.options.defaults.managed_val and (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting))), is_true: func(nd) { @@ -1310,7 +1342,7 @@ canvas.NDStyles["Airbus"] = { id:"vorCrsPtr", impl: { init: func(nd,symbol), - predicate: func(nd) (nd.in_mode("toggle_display_mode", ["APP","VOR"]) and !nd.get_switch("toggle_centered")), + predicate: func(nd) (nd.in_mode("toggle_display_mode", ["APP","VOR"]) and !nd.get_switch("toggle_centered")) and (nd.change_phase != 1), is_true: func(nd) { nd.symbols.vorCrsPtr.show(); if (is_ils) { @@ -1327,7 +1359,7 @@ canvas.NDStyles["Airbus"] = { id:"vorCrsPtr2", impl: { init: func(nd,symbol), - predicate: func(nd) (nd.in_mode("toggle_display_mode", ["APP","VOR"]) and nd.get_switch("toggle_centered")), + predicate: func(nd) (nd.in_mode("toggle_display_mode", ["APP","VOR"]) and nd.get_switch("toggle_centered")) and (nd.change_phase != 1), is_true: func(nd) { nd.symbols.vorCrsPtr2.show(); var is_ils = (nd.get_switch("toggle_display_mode") == "APP"); @@ -1354,7 +1386,7 @@ canvas.NDStyles["Airbus"] = { id: "gsDiamond", impl: { init: func(nd,symbol), - predicate: func(nd) nd.in_mode("toggle_display_mode", ["APP"]), + predicate: func(nd) nd.in_mode("toggle_display_mode", ["APP"]) and (nd.change_phase != 1), is_true: func(nd) { if(getprop("/instrumentation/nav/gs-needle-deflection-norm") != nil) nd.symbols.gsDiamond.setTranslation(getprop("/instrumentation/nav[0]/gs-needle-deflection-norm")*150,0); @@ -1422,7 +1454,7 @@ canvas.NDStyles["Airbus"] = { var ils_mode = getprop("/Flight-management/freq/ils-mode"); var has_ils = (nav_id != nil and nav_id != ""); (nd.get_switch("toggle_display_mode") == "MAP" and - !nd.get_switch("toggle_centered") and has_ils and ils_mode); + !nd.get_switch("toggle_centered") and has_ils and ils_mode and (nd.change_phase != 1)); }, is_true: func(nd) { nd.symbols.locTrkPointer.show(); @@ -1442,7 +1474,7 @@ canvas.NDStyles["Airbus"] = { var ils_mode = getprop("/Flight-management/freq/ils-mode"); var has_ils = (nav_id != nil and nav_id != ""); (nd.get_switch("toggle_display_mode") == "MAP" and - nd.get_switch("toggle_centered") and has_ils and ils_mode); + nd.get_switch("toggle_centered") and has_ils and ils_mode and (nd.change_phase != 1)); }, is_true: func(nd) { nd.symbols.locTrkPointer2.show(); @@ -1602,15 +1634,15 @@ canvas.NDStyles["Airbus"] = { nd.symbols.vorL.setText("ADF 1"); nd.symbols.vorL.setColor(0.195,0.96,0.097); nd.symbols.vorLId.setColor(0.195,0.96,0.097); - nd.symbols.dmeLDist.setColor(0.195,0.96,0.097); - } - else{ + #nd.symbols.dmeLDist.setColor(0.195,0.96,0.097); + nd.symbols.dmeL.setText(""); + } else { nd.symbols.vorL.setText("VOR 1"); nd.symbols.vorL.setColor(1,1,1); nd.symbols.vorLId.setColor(1,1,1); - nd.symbols.dmeLDist.setColor(1,1,1); + #nd.symbols.dmeLDist.setColor(1,1,1); + nd.symbols.dmeL.setText("NM"); } - nd.symbols.dmeL.setText("NM"); nd.symbols.dmeL.setColor(0,0.59,0.8); }, is_false: func(nd){ @@ -1629,14 +1661,14 @@ canvas.NDStyles["Airbus"] = { nd.symbols.vorR.setText("ADF 2"); nd.symbols.vorR.setColor(0.195,0.96,0.097); nd.symbols.vorRId.setColor(0.195,0.96,0.097); - nd.symbols.dmeRDist.setColor(0.195,0.96,0.097); + nd.symbols.dmeR.setText(""); } else { nd.symbols.vorR.setText("VOR 2"); nd.symbols.vorR.setColor(1,1,1); nd.symbols.vorRId.setColor(1,1,1); - nd.symbols.dmeRDist.setColor(1,1,1); + #nd.symbols.dmeRDist.setColor(1,1,1); + nd.symbols.dmeR.setText("NM"); } - nd.symbols.dmeR.setText("NM"); nd.symbols.dmeR.setColor(0,0.59,0.8); }, is_false: func(nd){ @@ -1692,6 +1724,8 @@ canvas.NDStyles["Airbus"] = { init: func(nd,symbol), predicate: func(nd) (nd.get_switch("toggle_lh_vor_adf") != 0), is_true: func(nd) { + if (nd.get_switch("toggle_lh_vor_adf") < 0) nd.symbols.vorLSym.setColor(0.195,0.96,0.097); + else nd.symbols.vorLSym.setColor(1,1,1); nd.symbols.vorLSym.show(); }, is_false: func(nd){ @@ -1747,6 +1781,8 @@ canvas.NDStyles["Airbus"] = { init: func(nd,symbol), predicate: func(nd) (nd.get_switch("toggle_rh_vor_adf") != 0), is_true: func(nd) { + if (nd.get_switch("toggle_rh_vor_adf") < 0) nd.symbols.vorRSym.setColor(0.195,0.96,0.097); + else nd.symbols.vorRSym.setColor(1,1,1); nd.symbols.vorRSym.show(); }, is_false: func(nd){ @@ -1958,6 +1994,53 @@ canvas.NDStyles["Airbus"] = { nd.symbols.offsetLbl.hide(); } } + }, + { + id: "terrGroup", + impl: { + init: func(nd,symbol), + predicate: func(nd) ( nd.get_switch("toggle_terrain") and + nd.get_switch("toggle_display_mode") != "PLAN" and (nd.rangeNm() <= 40) and + (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting)) ), + is_true: func(nd){ + if (terrain_maxalt.getValue() != -9999) { + var alert = terrain_alert.getValue(); + if (alert == 0) { + nd.symbols.TerrLabel.setVisible(1); + nd.symbols.terrAhead.setVisible(0); + } else { + nd.symbols.TerrLabel.setVisible(0); + nd.symbols.terrAhead.setVisible(1); + if (alert == 1) nd.symbols.terrAhead.setColor(YELLOW[0],YELLOW[1],YELLOW[2]); + else nd.symbols.terrAhead.setColor(RED[0],RED[1],RED[2]); + } + nd.symbols.terrLO.setText(sprintf("%03d",math.round(terrain_minalt.getValue()/100))); + nd.symbols.terrHI.setText(sprintf("%03d",math.round(terrain_maxalt.getValue()/100))); + if (terrain_maxcol.getValue() == 0) nd.symbols.terrHI.setColor(GREEN[0],GREEN[1],GREEN[2]); + else if (terrain_maxcol.getValue() == 1) nd.symbols.terrHI.setColor(YELLOW[0],YELLOW[1],YELLOW[2]); + else nd.symbols.terrHI.setColor(RED[0],RED[1],RED[2]); + nd.symbols.terrGroup.show(); + terrain_maxalt.setValue(-9999); #update visual at radar cycle + } + }, + is_false: func(nd){ + nd.symbols.terrGroup.hide(); + } + } + }, + { + id: "nd_msg_change", + impl: { + init: func(nd, symbol), + predicate: func(nd) ( (nd.change_phase != 0) and + (nd.adirs_property.getValue() == 1 or (adirs_3.getValue() == 1 and att_switch.getValue() == nd.attitude_heading_setting)) ), + is_true: func(nd) { + nd.symbols.nd_msg_change.show(); + }, + is_false: func(nd) { + nd.symbols.nd_msg_change.hide(); + } + } } ], # end of vector with features diff --git a/Models/Instruments/OHpanel/OHpanel.xml b/Models/Instruments/OHpanel/OHpanel.xml index 32492496..ced234bf 100644 --- a/Models/Instruments/OHpanel/OHpanel.xml +++ b/Models/Instruments/OHpanel/OHpanel.xml @@ -1698,6 +1698,41 @@ property-toggle instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit + + + + instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit + 1 + + + property-assign + instrumentation/efis/inputs/terr + 0 + + + + + instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit + 1 + + + property-assign + instrumentation/efis[1]/inputs/terr + 0 + + + + + instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit + 0 + + + nasal + + nasal diff --git a/Nasal/Displays/traffic.nas b/Nasal/Displays/traffic.nas index ae1bdeba..92009a4a 100644 --- a/Nasal/Displays/traffic.nas +++ b/Nasal/Displays/traffic.nas @@ -60,7 +60,7 @@ var drawBlip = func(elem, threatLvl) { .lineTo(0,-14) .lineTo(10,0) .lineTo(0,14) - .close(); + .lineTo(-10,0); } }; @@ -329,9 +329,8 @@ var TrafficLayer = { var color = canvas._getColor(rgb); var (r, g, b) = rgb; if (threatLevel > 0) { - item.elems.blip.setColorFill(r, g, b); - } else { - item.elems.blip.setColorFill(0,0,0); + item.elems.blip.setColorFill(r, g, b); + } else { item.elems.blip.setColor(r, g, b); } item.elems.text.setColor(r, g, b); diff --git a/Nasal/ECAM/ECAM-logic.nas b/Nasal/ECAM/ECAM-logic.nas index c2b687ad..0729979b 100644 --- a/Nasal/ECAM/ECAM-logic.nas +++ b/Nasal/ECAM/ECAM-logic.nas @@ -3569,7 +3569,7 @@ var messages_right_memo = func { wing_aice.active = 0; } - if (getprop("instrumentation/comm[2]/frequencies/selected-mhz") != 0 and (phaseVarMemo3 == 1 or phaseVarMemo3 == 2 or phaseVarMemo3 == 6 or phaseVarMemo3 == 9 or phaseVarMemo3 == 10)) { + if (!getprop("/systems/radio/vhf3-data-mode") and (phaseVarMemo3 == 1 or phaseVarMemo3 == 2 or phaseVarMemo3 == 6 or phaseVarMemo3 == 9 or phaseVarMemo3 == 10)) { vhf3_voice.active = 1; } else { vhf3_voice.active = 0; diff --git a/Nasal/Libraries/libraries.nas b/Nasal/Libraries/libraries.nas index ca04cc96..ece032b0 100644 --- a/Nasal/Libraries/libraries.nas +++ b/Nasal/Libraries/libraries.nas @@ -198,10 +198,12 @@ var systemsLoop = func(notification) { # GPWS var GPWS = { inhibitNode: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/gpws-inhibit"), + tatcfInhibit: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit"), volume: props.globals.getNode("/instrumentation/mk-viii/speaker/volume"), flapAllOverride: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/momentary-flap-all-override"), flap3Override: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/momentary-flap-3-override"), flapOverride: props.globals.getNode("/instrumentation/mk-viii/inputs/discretes/momentary-flap-override"), + alertMode: props.globals.initNode("/instrumentation/mk-viii/outputs/alert-mode",0,"INT"), }; setlistener("/instrumentation/mk-viii/inputs/discretes/gpws-inhibit", func() { @@ -228,6 +230,20 @@ setlistener("/instrumentation/mk-viii/inputs/discretes/momentary-flap-3-override updateGPWSFlap(); }, 0, 0); +# GPWS alert pooling for get mode change - a little esoteric way but it works +var gpws_alert_watch = maketimer(0.8,func { + var alert = 0; + if (getprop("instrumentation/mk-viii/outputs/discretes/gpws-warning")) alert = 2; # MODE2 - warning - RED + else if (getprop("instrumentation/mk-viii/outputs/discretes/gpws-alert")) alert = 1; # MODE1 - caution - YELLOW + if (GPWS.alertMode.getValue()!=alert) GPWS.alertMode.setValue(alert); +}); + +setlistener("/instrumentation/mk-viii/inputs/discretes/ta-tcf-inhibit", func{ # detect GPWS switch status + var failure = GPWS.tatcfInhibit.getBoolValue(); + if (!failure) gpws_alert_watch.start(); + else gpws_alert_watch.stop(); +},1,0); + # Replay var replayState = props.globals.getNode("/sim/replay/replay-state"); setlistener("/sim/replay/replay-state", func() { diff --git a/Nasal/Panels/rmp.nas b/Nasal/Panels/rmp.nas index 06b77d17..2f661011 100644 --- a/Nasal/Panels/rmp.nas +++ b/Nasal/Panels/rmp.nas @@ -96,6 +96,9 @@ var am_mode_rmp3 = props.globals.initNode("/systems/radio/rmp[2]/am-active", 0, var sel_crs_rmp1 = props.globals.initNode("/systems/radio/rmp[0]/select-crs", 1, "BOOL"); var sel_crs_rmp2 = props.globals.initNode("/systems/radio/rmp[1]/select-crs", 1, "BOOL"); +var vhf3_data_mode = props.globals.initNode("/systems/radio/vhf3-data-mode", 1, "BOOL"); +var data_mode_stby_rmp = props.globals.initNode("/systems/radio/data-mode-stby-rmp", 0, "INT"); + var init = func() { chan_rmp1.setValue("vhf1"); chan_rmp2.setValue("vhf2"); @@ -153,57 +156,52 @@ var update_active_vhf = func(vhf) { var sel3 = chan_rmp3.getValue(); if (vhf == 1) { - if (sel1 == "vhf1" or sel2 == "vhf1") { - var act = sprintf("%3.3f", act_vhf1.getValue()); + var act = sprintf("%3.3f", act_vhf1.getValue()); - if (sel1 == "vhf1") { - act_display_rmp1.setValue(act); - } - if (sel2 == "vhf1") { - act_display_rmp2.setValue(act); - } - if (sel3 == "vhf1") { - act_display_rmp3.setValue(act); - } + if (sel1 == "vhf1") { + act_display_rmp1.setValue(act); + } + if (sel2 == "vhf1") { + act_display_rmp2.setValue(act); + } + if (sel3 == "vhf1") { + act_display_rmp3.setValue(act); } } else if (vhf == 2) { - if (sel1 == "vhf2" or sel2 == "vhf2") { - var act = sprintf("%3.3f", act_vhf2.getValue()); + var act = sprintf("%3.3f", act_vhf2.getValue()); - if (sel1 == "vhf2") { - act_display_rmp1.setValue(act); - } - if (sel2 == "vhf2") { - act_display_rmp2.setValue(act); - } - if (sel3 == "vhf2") { - act_display_rmp3.setValue(act); - } + if (sel1 == "vhf2") { + act_display_rmp1.setValue(act); + } + if (sel2 == "vhf2") { + act_display_rmp2.setValue(act); + } + if (sel3 == "vhf2") { + act_display_rmp3.setValue(act); } } else if (vhf == 3) { - if (sel1 == "vhf3" or sel2 == "vhf3") { - var act = sprintf("%3.3f", act_vhf3.getValue()); + var act = sprintf("%3.3f", act_vhf3.getValue()); + var data_mode = vhf3_data_mode.getValue(); - if (sel1 == "vhf3") { - if (act == 0) { - act_display_rmp1.setValue("data"); - } else { - act_display_rmp1.setValue(act); - } + if (sel1 == "vhf3") { + if (data_mode == 1) { + act_display_rmp1.setValue("data"); + } else { + act_display_rmp1.setValue(act); } - if (sel2 == "vhf3") { - if (act == 0) { - act_display_rmp2.setValue("data"); - } else { - act_display_rmp2.setValue(act); - } + } + if (sel2 == "vhf3") { + if (data_mode == 1) { + act_display_rmp2.setValue("data"); + } else { + act_display_rmp2.setValue(act); } - if (sel3 == "vhf3") { - if (act == 0) { - act_display_rmp3.setValue("data"); - } else { - act_display_rmp3.setValue(act); - } + } + if (sel3 == "vhf3") { + if (data_mode == 1) { + act_display_rmp3.setValue("data"); + } else { + act_display_rmp3.setValue(act); } } } else if (vhf == 4) { @@ -283,6 +281,7 @@ var update_displays_nav = func(nav) { } var update_stby_freq = func(rmp_no, freq) { + var data_mode = vhf3_data_mode.getValue(); if (rmp_no == 0) { if (freq == 1) { var stby = sprintf("%3.3f", stby_rmp1_vhf1.getValue()); @@ -296,7 +295,7 @@ var update_stby_freq = func(rmp_no, freq) { var stby = sprintf("%5.0f", stby_rmp1_hf2.getValue()); } - if (stby == 0) { + if (data_mode == 0 and data_mode_stby_rmp.getValue() == 0) { stby_display_rmp1.setValue("data"); } else { stby_display_rmp1.setValue(stby); @@ -314,7 +313,7 @@ var update_stby_freq = func(rmp_no, freq) { var stby = sprintf("%5.0f", stby_rmp2_hf2.getValue()); } - if (stby == 0) { + if (data_mode == 0 and data_mode_stby_rmp.getValue() == 1) { stby_display_rmp2.setValue("data"); } else { stby_display_rmp2.setValue(stby); @@ -332,7 +331,7 @@ var update_stby_freq = func(rmp_no, freq) { var stby = sprintf("%5.0f", stby_rmp3_hf2.getValue()); } - if (stby == 0) { + if (data_mode == 0 and data_mode_stby_rmp.getValue() == 2) { stby_display_rmp3.setValue("data"); } else { stby_display_rmp3.setValue(stby); @@ -399,6 +398,18 @@ var transfer = func(rmp_no) { var sel_crs = getprop("/systems/radio/rmp[" ~ rmp_no ~ "]/select-crs"); if (string.match(sel_chan, "vhf[1-3]")) { + var data_mode = vhf3_data_mode.getValue(); + if (string.match(sel_chan, "vhf3") and ((data_mode_stby_rmp.getValue() == rmp_no and data_mode == 0) or data_mode == 1)) { + if (data_mode == 0) + { + vhf3_data_mode.setValue(1); + } + else + { + vhf3_data_mode.setValue(0); + data_mode_stby_rmp.setValue(rmp_no); + } + } var mod1 = int(string.replace(sel_chan, "vhf", "")); var mod = mod1 - 1; diff --git a/README.md b/README.md index 53eeea83..5710623f 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,9 @@ It is highly reccomended to purchase a NAVIGRAPH subscription and download their To install navdata, create a folder FMSDATA, and add it to your additional scenery folders, at the top of the list. Inside that folder, place all the XXXX.procedures.xml files, in the format FMSDATA/X/X/X/XXXX.procedures.xml. For instance, FMSDATA/Airports/E/G/K/EGKK.procedures.xml. +## Remote MCDU +If you want to run the MCDU on a phone or tablet for better realism and easier input, put mcdu.html into the FGDATA/Phi folder, run FlightGear with enabled HTTP server (i.e. command line --httpd=8080) and open http://your-flightgear-computer:8080/mcdu.html in the browser on your phone or tablet. + ## Installation If you have issues installing, please check INSTALL.MD! Specifically, make sure you remove -dev from the folder name! diff --git a/mcdu.html b/mcdu.html new file mode 100644 index 00000000..28e57ea7 --- /dev/null +++ b/mcdu.html @@ -0,0 +1,211 @@ + + + + MCDU + + + + + + + + + + + + + + + + + + +
  
11
22
33
44
55
66
  
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ABCDE
FGHIJ
KLMNO
PQRST
UVWXY
Z/SPOVFYCLR
+ + + + + + + + + + + + + +
AIR
PORT
+ + + + + + + + + + + + + + + + + + + + + +
123
456
789
.0-
+ + diff --git a/revision.txt b/revision.txt index 801f1801..31ff414b 100644 --- a/revision.txt +++ b/revision.txt @@ -1 +1 @@ -47 \ No newline at end of file +48 \ No newline at end of file