1
0
Fork 0

high/low aircraft relative altitude modes

This commit is contained in:
Inuyaksa 2021-02-17 00:30:26 +01:00
parent ca09f258c2
commit b601fd7c2c
14 changed files with 85 additions and 48 deletions

View file

@ -10,7 +10,11 @@ var element_type = "group";
var terrain_minalt = props.globals.initNode("/custom/terrain/min-altitude", 0,"INT");
var terrain_maxalt = props.globals.initNode("/custom/terrain/max-altitude", -9999,"INT");
var tile_list = ["*black*","tile_01.png","tile_02.png","tile_03.png","tile_04.png","tile_06.png","tile_09.png","tile_s1.png"];
var tile_list = [
nil,"tile_gl.png","tile_gh.png","tile_yl.png","tile_yh.png","tile_rh.png", # 0-5 low alt
"tile_gl.png","tile_gh.png","tile_gs.png",nil, # 6-9 hi alt
"tile_ml.png","tile_cl.png" # 10 magenta - 11 cyan (water)
];
var is_terrain = 0;
@ -36,6 +40,7 @@ var updateTerrain = func {
if (me.request_clear == 1) {
me.request_clear = 0;
me.clear();
me.group.setVisible(1);
}
var RAD2DEG = 57.2957795;
@ -44,15 +49,17 @@ var updateTerrain = func {
var pos_lat = me.reference.lat();
var pos_lon = me.reference.lon();
var heading = me.reference.heading;
var altitudeft = me.reference.altitudeft;
var heading = me.refheading;
var altitudeft = me.refaltitudeft;
var lowaltft = me.reflowaltft;
var basealtft = me.basealtitudeft;
var side = (math.mod(me.radar_beacon,2)==0) ? "L" : "R";
var a = int(me.radar_beacon/2);
var col = a;
var col = a + 0.5;
if (side == "R") {
col = -1 + (-1 * a);
col = -col;
}
var trn = me.terrlayer[side ~ a];
@ -67,6 +74,8 @@ var updateTerrain = func {
var elevft = [];
me.radar_cleared = 0;
for (var row = 0; row < len; row += 1) {
if (trn[row] == nil) {
@ -80,36 +89,44 @@ var updateTerrain = func {
var elev = me.get_elevation(point_lat, point_lon);
var grad = 0; #black
if (elev != nil) {
if (me.is_terrain) {
if (elev<me.min_altitude) me.min_altitude = elev;
else if (elev>me.max_altitude) me.max_altitude = elev;
if (elev < me.basealtitudeft) grad = 0; # < 400 near runway use blank
if (elev<me.min_altitude) me.min_altitude = elev;
else if (elev>me.max_altitude) me.max_altitude = elev;
if (me.is_terrain) {
if (elev < basealtft) grad = 0; # < 400 near runway use blank
else {
var diff = elev - altitudeft;
if (diff>=0) {
grad = int(diff/1000) + 3;
if (grad>5) grad = 5;
} else {
if (diff>-500) grad = 3; # lite yellow
else {
grad = 2 + int(diff/1000);
if (grad<0) grad = 0;
}
if (me.hialtmode == 0) {
if (diff>=lowaltft) grad = 3; # lite yellow
else {
grad = 2 + int(diff/1000);
if (grad<0) grad = 0;
}
} else {
if (diff>=lowaltft) grad = 3; # lite yellow
else {
if (me.bands_range > 0 and elev > me.bands_minalt) {
elev -= me.bands_minalt;
grad = int(elev / (me.bands_range / 3)) + 6;
if (grad>8) grad = 8; # solid green
}
}
}
}
}
} else {
var diff = elev - altitudeft;
if (diff>=-2000) grad = 7; #sea
grad = 11; #water
}
append(elevft,grad); # 0-5
} else {
append(elevft,6); # magenta
append(elevft,0); # no data - black (magenta)
}
}
me.radar_cleared = 0;
for (var r=0; r < len; r+=1) {
var imgx = elevft[r];
if (imgx == -1) continue;
@ -122,21 +139,31 @@ var updateTerrain = func {
me.update_altitudes();
me.restart_beacon();
}
#me.last_request = getprop("sim/time/elapsed-sec");
me.fetching = 0;
};
var update_altitudes = func {
me.terrain_minalt.setValue(me.min_altitude);
me.terrain_maxalt.setValue(me.max_altitude);
if (me.max_altitude < me.refaltitudeft) {
me.hialtmode = 1;
} else {
me.hialtmode = 0;
}
}
var restart_beacon = func {
me.radar_beacon = 0;
me.radar_cycle += 1;
me.min_altitude = 9999;
me.bands_minalt = me.min_altitude;
me.bands_maxalt = math.max(1000,me.max_altitude); # band min limit to 1000 ft - trivial
me.bands_range = me.bands_maxalt - me.bands_minalt;
me.min_altitude = 9999;
me.max_altitude = -9999;
me.reference = nil;
};
var init = func {
@ -155,9 +182,13 @@ var init = func {
me.visible = 0;
me.min_altitude = 9999;
me.max_altitude = -9999;
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
var tile = me.tile;
@ -196,14 +227,10 @@ var init = func {
me.terrlayer["L" ~ c] = grplx;
me.terrlayer["R" ~ c] = grprx;
}
setlistener("/controls/switches/terr_on_nd_l", func{
me.request_clear = 1;
});
setlistener("/ECAM/warnings/timer/nav-gpws-terr-fault", func{
me.onfailure = getprop("/ECAM/warnings/timer/nav-gpws-terr-fault");
});
#setlistener("/ECAM/warnings/timer/nav-gpws-terr-fault", func{ # TODO need further investigations
# me.onfailure = getprop("/ECAM/warnings/timer/nav-gpws-terr-fault");
#});
};
@ -236,19 +263,20 @@ var draw = func {
return;
}
if (me.radar_beacon == 0) { # update aircraft reference
if (me.reference == nil) { # update aircraft reference
var ref = geo.aircraft_position();
me.reference = ref;
if (ref != nil) {
me.reference.heading = getprop("orientation/heading-magnetic-deg");
me.reference.altitudeft = ref.alt() * 3.2808399;
me.refheading = getprop("orientation/heading-magnetic-deg");
if (me.basealtitudeft == nil) {
var refalt = ref.alt() * 3.2808399;
me.refaltitudeft = refalt;
me.reflowaltft = (pts.Gear.position[1].getValue()) ? -250 : -500;
if (fmgc.FMGCInternal.phase<2) {
#var basealtft = me.get_elevation(ref.lat,ref.lon);
var basealtft = ref.alt() * 3.2808399;
if (basealtft == nil) basealtft = 0;
me.basealtitudeft = basealtft + 400;
me.basealtitudeft = refalt + 400;
}
#if (fmgc.FMGCInternal.phase >= 5 and me.basealtitudeft == 0) {
@ -260,19 +288,26 @@ var draw = func {
#else if ((fmgc.FMGCInternal.phase > 1 and fmgc.FMGCInternal.phase < 5) and (me.basealtitudeft != 0)) {
# me.basealtitudeft = 0;
#}
}
} else {
if (me.layer.display_changed == 1) {
me.layer.display_changed = 0;
me.request_clear = 1;
}
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
if (math.mod(me.radar_beacon,2)==1) me.updateTerrain(); # right
}
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
if (math.mod(me.radar_beacon,2)==1) me.updateTerrain(); # right
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

View file

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 182 B

View file

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View file

Before

Width:  |  Height:  |  Size: 182 B

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 2 KiB

View file

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 181 B

View file

@ -97,6 +97,8 @@ canvas.NDStyles["Airbus"] = {
(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