Merge branch 'dev' into 3D
This commit is contained in:
commit
d5b0099aec
14 changed files with 231 additions and 156 deletions
|
@ -3560,7 +3560,7 @@ var canvas_lowerECAM_test = {
|
|||
},
|
||||
};
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func {
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
lowerECAM_display = canvas.new({
|
||||
"name": "lowerECAM",
|
||||
"size": [1024, 1024],
|
||||
|
|
|
@ -6571,7 +6571,7 @@ var canvas_MCDU_2 = {
|
|||
},
|
||||
};
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func {
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
MCDU1_display = canvas.new({
|
||||
"name": "MCDU1",
|
||||
"size": [1024, 864],
|
||||
|
|
|
@ -323,7 +323,7 @@ var canvas_ND_2_test = {
|
|||
},
|
||||
};
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func {
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
setprop("instrumentation/efis[0]/inputs/plan-wpt-index", -1);
|
||||
setprop("instrumentation/efis[1]/inputs/plan-wpt-index", -1);
|
||||
|
||||
|
|
|
@ -25,58 +25,98 @@ var easeArrow = {
|
|||
m.duration = 0;
|
||||
m.startval = 0;
|
||||
m.diffval = 0;
|
||||
m.nav = "";
|
||||
m.mhz = 0;
|
||||
m.changed = 1;
|
||||
return m;
|
||||
},
|
||||
setVisible: func(v) {
|
||||
if (v == 1 and me.last_rot_deg == nil) me.reset();
|
||||
if (v == 1 and me.last_rot_deg == nil) me.setzero();
|
||||
me.element.setVisible(v);
|
||||
},
|
||||
hide: func {
|
||||
me.element.hide();
|
||||
},
|
||||
reset: func {
|
||||
#me.element.hide();
|
||||
me.duration = 0;
|
||||
me.changed = 1;
|
||||
print("VOR reset");
|
||||
},
|
||||
setzero: func {
|
||||
me.duration = 0;
|
||||
me.last_rot_deg = 360 - getprop("orientation/heading-deg");
|
||||
me.last_rot_rad = me.last_rot_deg * D2R;
|
||||
me.duration = 0;
|
||||
print("VOR reset");
|
||||
me.req_rot_rad = me.last_rot_rad;
|
||||
me.element.setRotation(me.last_rot_rad);
|
||||
},
|
||||
listen: func (path) {
|
||||
me.nav = path ~ "/frequencies/selected-mhz";
|
||||
setlistener(me.nav, func {
|
||||
var freq = getprop(me.nav);
|
||||
if (me.mhz != freq) {
|
||||
me.mhz = freq;
|
||||
me.reset();
|
||||
}
|
||||
});
|
||||
},
|
||||
setRotation: func(rad) {
|
||||
var deg = 0;
|
||||
var gap = 0;
|
||||
if (me.last_rot_deg == nil) me.setzero();
|
||||
rad = math.round(rad * 1000) / 1000;
|
||||
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;
|
||||
#if (gap>=180*D2R) gap = 360*D2R - gap;
|
||||
if (gap>0.0009) {
|
||||
#print("VOR rotation");
|
||||
#else if (me.duration>0) gap = math.abs(rad - me.last_rot_rad);
|
||||
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.duration = 0;
|
||||
if (me.duration > 0) {
|
||||
var add = deg - me.req_rot_deg;
|
||||
if (add>=180) add = add - 360;
|
||||
me.diffval += add;
|
||||
me.duration = math.abs( math.round(me.diffval * 0.19) ); # rad 36/3
|
||||
}
|
||||
else if (me.changed == 1) {
|
||||
#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
|
||||
while (me.diffval<0) me.diffval += 360;
|
||||
if (me.changed == 1 and me.diffval < 180) me.diffval += 360;
|
||||
#print("VOR animation:" ~ me.diffval);
|
||||
#me.time = 0;
|
||||
me.duration = math.abs( math.round(me.diffval * 0.19) ); # rad 36/3
|
||||
} else {
|
||||
me.duration = 0;
|
||||
}
|
||||
if (me.duration < 2) {
|
||||
me.last_rot_rad = rad;
|
||||
me.last_rot_deg = deg;
|
||||
me.element.setRotation(rad);
|
||||
me.duration = 0;
|
||||
me.time = 0;
|
||||
me.changed = 0;
|
||||
}
|
||||
me.req_rot_rad = rad;
|
||||
me.req_rot_deg = deg;
|
||||
}
|
||||
if (me.duration > 0) {
|
||||
var tx = me.time / me.duration;
|
||||
if (tx>1) tx = 1;
|
||||
#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.element.setRotation(deg * D2R);
|
||||
me.time += 1;
|
||||
if (tx>=1) me.duration = 0;
|
||||
if (tx>=1) {
|
||||
me.duration = 0;
|
||||
me.time = 0;
|
||||
me.changed = 0;
|
||||
me.last_rot_deg = deg;
|
||||
me.last_rot_rad = rad;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -173,7 +213,7 @@ canvas.NavDisplay.newMFD = func(canvas_group, parent=nil, nd_options=nil, update
|
|||
# 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; ["dmeL","dmeR","vorL","vorR","vorLId","vorRId",
|
||||
"status.wxr","status.wpt","status.sta","status.arpt","terrHI","terrLO","TerrLabel","terrAhead"])
|
||||
"status.wxr","status.wpt","status.sta","status.arpt","terrHI","terrLO","TerrLabel","terrAhead","terrAltGroup"])
|
||||
me.symbols[element] = me.nd.getElementById(element);
|
||||
|
||||
foreach(var element; ["dmeLDist","dmeRDist"])
|
||||
|
@ -193,7 +233,7 @@ canvas.NavDisplay.newMFD = func(canvas_group, parent=nil, nd_options=nil, update
|
|||
|
||||
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)
|
||||
|
@ -213,6 +253,12 @@ canvas.NavDisplay.newMFD = func(canvas_group, parent=nil, nd_options=nil, update
|
|||
return 0;
|
||||
}
|
||||
|
||||
# listen for (VOR) NAV frequency change
|
||||
me.symbols.staArrowL.listen(vor1_path);
|
||||
me.symbols.staArrowL2.listen(vor1_path);
|
||||
me.symbols.staArrowR.listen(vor2_path);
|
||||
me.symbols.staArrowR2.listen(vor2_path);
|
||||
|
||||
# another predicate for the draw controller
|
||||
var get_course_by_freq = func(freq) {
|
||||
if (freq == getprop(vor1_path~ "frequencies/selected-mhz"))
|
||||
|
@ -610,36 +656,35 @@ canvas.NavDisplay.update = func() # FIXME: This stuff is still too aircraft spec
|
|||
}
|
||||
var adf0hdg = getprop("/instrumentation/adf/indicated-bearing-deg");
|
||||
var adf1hdg = getprop("/instrumentation/adf[1]/indicated-bearing-deg");
|
||||
if(!me.get_switch("toggle_centered"))
|
||||
{
|
||||
if(!me.get_switch("toggle_centered")) {
|
||||
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();
|
||||
if((getprop("/instrumentation/nav[2]/in-range") and me.get_switch("toggle_lh_vor_adf") == 1)) {
|
||||
me.symbols.staArrowL.setVisible(staPtrVis);
|
||||
me.symbols.staToL.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staFromL.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staArrowL.setRotation(nav0hdg*D2R);
|
||||
me.symbols.staArrowL.setVisible(staPtrVis);
|
||||
}
|
||||
elsif(getprop("/instrumentation/adf/in-range") and (me.get_switch("toggle_lh_vor_adf") == -1)) {
|
||||
me.symbols.staArrowL.setVisible(staPtrVis);
|
||||
me.symbols.staToL.setColor(0,0.6,0.85);
|
||||
me.symbols.staFromL.setColor(0,0.6,0.85);
|
||||
me.symbols.staArrowL.setRotation(adf0hdg*D2R);
|
||||
me.symbols.staArrowL.setVisible(staPtrVis);
|
||||
} else {
|
||||
me.symbols.staArrowL.hide();
|
||||
}
|
||||
if((getprop("/instrumentation/nav[3]/in-range") and me.get_switch("toggle_rh_vor_adf") == 1)) {
|
||||
me.symbols.staArrowR.setVisible(staPtrVis);
|
||||
me.symbols.staToR.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staFromR.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staArrowR.setRotation(nav1hdg*D2R);
|
||||
} elsif(getprop("/instrumentation/adf[1]/in-range") and (me.get_switch("toggle_rh_vor_adf") == -1)) {
|
||||
me.symbols.staArrowR.setVisible(staPtrVis);
|
||||
} elsif(getprop("/instrumentation/adf[1]/in-range") and (me.get_switch("toggle_rh_vor_adf") == -1)) {
|
||||
me.symbols.staToR.setColor(0,0.6,0.85);
|
||||
me.symbols.staFromR.setColor(0,0.6,0.85);
|
||||
me.symbols.staArrowR.setRotation(adf1hdg*D2R);
|
||||
me.symbols.staArrowR.setVisible(staPtrVis);
|
||||
} else {
|
||||
me.symbols.staArrowR.hide();
|
||||
}
|
||||
|
@ -671,28 +716,28 @@ canvas.NavDisplay.update = func() # FIXME: This stuff is still too aircraft spec
|
|||
} else {
|
||||
me.symbols.trkInd.hide();
|
||||
if((getprop("/instrumentation/nav[2]/in-range") and me.get_switch("toggle_lh_vor_adf") == 1)) {
|
||||
me.symbols.staArrowL2.setVisible(staPtrVis);
|
||||
me.symbols.staFromL2.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staToL2.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staArrowL2.setRotation(nav0hdg*D2R);
|
||||
} elsif(getprop("/instrumentation/adf/in-range") and (me.get_switch("toggle_lh_vor_adf") == -1)) {
|
||||
me.symbols.staArrowL2.setVisible(staPtrVis);
|
||||
} elsif(getprop("/instrumentation/adf/in-range") and (me.get_switch("toggle_lh_vor_adf") == -1)) {
|
||||
me.symbols.staFromL2.setColor(0,0.6,0.85);
|
||||
me.symbols.staToL2.setColor(0,0.6,0.85);
|
||||
me.symbols.staArrowL2.setRotation(adf0hdg*D2R);
|
||||
me.symbols.staArrowL2.setVisible(staPtrVis);
|
||||
} else {
|
||||
me.symbols.staArrowL2.hide();
|
||||
}
|
||||
if((getprop("/instrumentation/nav[3]/in-range") and me.get_switch("toggle_rh_vor_adf") == 1)) {
|
||||
me.symbols.staArrowR2.setVisible(staPtrVis);
|
||||
me.symbols.staFromR2.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staToR2.setColor(0.195,0.96,0.097);
|
||||
me.symbols.staArrowR2.setRotation(nav1hdg*D2R);
|
||||
} elsif(getprop("/instrumentation/adf[1]/in-range") and (me.get_switch("toggle_rh_vor_adf") == -1)) {
|
||||
me.symbols.staArrowR2.setVisible(staPtrVis);
|
||||
} elsif(getprop("/instrumentation/adf[1]/in-range") and (me.get_switch("toggle_rh_vor_adf") == -1)) {
|
||||
me.symbols.staFromR2.setColor(0,0.6,0.85);
|
||||
me.symbols.staToR2.setColor(0,0.6,0.85);
|
||||
me.symbols.staArrowR2.setRotation(adf1hdg*D2R);
|
||||
me.symbols.staArrowR2.setVisible(staPtrVis);
|
||||
} else {
|
||||
me.symbols.staArrowR2.hide();
|
||||
}
|
||||
|
|
|
@ -16,10 +16,6 @@ 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 = [
|
||||
|
@ -87,17 +83,22 @@ var updateTerrain = func {
|
|||
#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 range_20f = range / 19.70; #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 col_x_range20f = col * range_20f;
|
||||
|
||||
var proj_lon = pos_lon + ((col_x_range20f * math.sin(DEG2RAD * (heading - 90))) / 60);
|
||||
var proj_lat = pos_lat + ((col_x_range20f * math.cos(DEG2RAD * (heading - 90))) / 60);
|
||||
|
||||
var elevft = [];
|
||||
|
||||
me.radar_cleared = 0;
|
||||
|
||||
var altmin = 9999;
|
||||
var altmax = -9999;
|
||||
|
||||
for (var row = 0; row < len; row += 1) {
|
||||
|
||||
if (trn[row] == nil) {
|
||||
|
@ -105,23 +106,25 @@ var updateTerrain = func {
|
|||
continue;
|
||||
}
|
||||
|
||||
var point_lon = proj_lon + ((row * range_20f / 60) * heading_sin);
|
||||
var point_lat = proj_lat + ((row * range_20f / 60) * heading_cos);
|
||||
var row_x_r20f_60th = (row * range_20f / 60);
|
||||
|
||||
var point_lon = proj_lon + (row_x_r20f_60th * heading_sin);
|
||||
var point_lat = proj_lat + (row_x_r20f_60th * 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 (elev>altmax) altmax = elev;
|
||||
if (me.is_terrain) {
|
||||
if (elev<me.min_altitude) me.min_altitude = elev;
|
||||
if (elev<altmin) altmin = elev;
|
||||
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;
|
||||
if (alert_level > 0 and a < 6 and grad > 3) {
|
||||
if (alert_level == 1 and (grad == 3 or grad == 4)) grad = 12; # solid yellow
|
||||
if (alert_level > 0 and a <= 6) {
|
||||
if (alert_level == 1 and grad != 5) grad = 12; # solid yellow
|
||||
else if (alert_level == 2 and grad == 5) grad = 13; # solid red
|
||||
}
|
||||
} else {
|
||||
|
@ -135,9 +138,13 @@ var updateTerrain = func {
|
|||
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
|
||||
if (elev >= me.green_altitude) grad = 9; # solid green
|
||||
else {
|
||||
grad = 8 - int((me.bands_maxalt - elev) / me.bands_range); # 9 -
|
||||
#if (grad>9) grad = 9; # solid green
|
||||
if (grad>8) grad = 8; # high green
|
||||
else if (grad<6) grad = 6; #light green
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,8 +160,6 @@ var updateTerrain = func {
|
|||
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -162,6 +167,20 @@ var updateTerrain = func {
|
|||
else trn[r].setFile(me.imgpath ~ me.tile_list[imgx]).show();
|
||||
}
|
||||
|
||||
if (altmax != -9999) {
|
||||
|
||||
if (altmin > altmax) altmin = altmax; # occurs on sea areas
|
||||
|
||||
if (me.max_altitude == -9999) {
|
||||
me.min_altitude = altmin;
|
||||
me.max_altitude = altmax;
|
||||
} else {
|
||||
if (altmin<me.min_altitude) me.min_altitude = altmin;
|
||||
if (altmax>me.max_altitude) me.max_altitude = altmax;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
me.radar_beacon += 1;
|
||||
if (me.radar_beacon >= (me.tileradiusw*2)) {
|
||||
me.restart_beacon();
|
||||
|
@ -172,47 +191,49 @@ var updateTerrain = func {
|
|||
|
||||
var update_altitudes = func {
|
||||
|
||||
me.terrain_minalt.setValue(me.min_altitude);
|
||||
me.terrain_maxalt.setValue(me.max_altitude);
|
||||
var maxalt = int(me.max_altitude);
|
||||
me.terrain_minalt.setValue(int(me.min_altitude));
|
||||
me.terrain_maxalt.setValue(maxalt);
|
||||
|
||||
var altdif = me.max_altitude - me.refaltitudeft;
|
||||
if (me.avg_maxalt == -9999) {
|
||||
me.avg_minalt = int(me.min_altitude);
|
||||
me.avg_maxalt = maxalt;
|
||||
} else {
|
||||
me.avg_minalt = math.avg(me.avg_minalt,me.min_altitude);
|
||||
me.avg_maxalt = math.avg(me.avg_maxalt,maxalt);
|
||||
}
|
||||
|
||||
var altdif = maxalt - 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);
|
||||
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_diffalt = me.avg_maxalt - me.avg_minalt;
|
||||
|
||||
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);
|
||||
if (me.onground == 0 and (maxalt + 200) < me.refaltitudeft) { # 200 ft tollerance
|
||||
me.hialtmode = 1;
|
||||
var mxrange = math.max(1600,int((me.avg_maxalt - me.basealtitudeft) * 0.3));
|
||||
var range = math.min(mxrange,me.avg_diffalt);
|
||||
if (range < 160) { # min elev number
|
||||
me.bands_range = 0;
|
||||
} else {
|
||||
me.bands_maxalt = me.avg_maxalt;
|
||||
me.bands_minalt = math.max( me.avg_maxalt - range, me.avg_minalt + 400 );
|
||||
me.bands_minalt = math.max( me.avg_maxalt - range, me.avg_minalt + me.basealtitudeft );
|
||||
me.bands_range = int( (me.bands_maxalt - me.bands_minalt) / 4);
|
||||
}
|
||||
me.green_altitude = math.max(maxalt - 1200, me.avg_maxalt - me.bands_range);
|
||||
} else {
|
||||
me.hialtmode = 0;
|
||||
#me.avg_minalt = 9999;
|
||||
}
|
||||
|
||||
me.min_altitude = 9999;
|
||||
me.max_altitude = -9999;
|
||||
me.max_altitude = -9999;
|
||||
me.avg_maxalt = -9999;
|
||||
|
||||
}
|
||||
|
||||
|
@ -223,7 +244,9 @@ var restart_beacon = func {
|
|||
};
|
||||
|
||||
var init = func {
|
||||
#print('TERRAIN init');
|
||||
print('TERRAIN init');
|
||||
#print(me.layer.efis_path);
|
||||
|
||||
me.tile = 33;
|
||||
me.fetching = 0;
|
||||
me.fetchRad = me.model.fetchRad; # Radius of radar layer to fetch
|
||||
|
@ -236,9 +259,10 @@ var init = func {
|
|||
me.request_clear = 0;
|
||||
me.min_altitude = 9999;
|
||||
me.max_altitude = -9999;
|
||||
me.green_altitude = 0; # max altitude for solid green (peak color)
|
||||
me.avg_minalt = 9999;
|
||||
me.avg_maxalt = -9999;
|
||||
me.avg_peakalt = nil;
|
||||
me.avg_diffalt = nil;
|
||||
me.maxalt_col = 0; # 0 = grn, 1 = yel, 2 = red
|
||||
me.bands_minalt = 0;
|
||||
me.bands_maxalt = 0;
|
||||
|
@ -250,6 +274,10 @@ var init = func {
|
|||
me.checkarrival = 0;
|
||||
me.onground = 1;
|
||||
|
||||
me.terrain_minalt = props.globals.initNode(me.layer.efis_path ~ "/nd/terrain-on-nd/min-altitude", 0,"INT");
|
||||
me.terrain_maxalt = props.globals.initNode(me.layer.efis_path ~ "/nd/terrain-on-nd/max-altitude", -9999,"INT");
|
||||
me.terrain_maxcol = props.globals.initNode(me.layer.efis_path ~ "/nd/terrain-on-nd/max-color", -1,"INT"); # 0= grn, 1= yel, 2= red
|
||||
|
||||
var tile = me.tile;
|
||||
|
||||
var gx = int(me.viewport_radius / tile);
|
||||
|
@ -325,12 +353,13 @@ var draw = func {
|
|||
return;
|
||||
}
|
||||
|
||||
if (me.layer.display_changed == 1) {
|
||||
me.layer.display_changed = 0;
|
||||
if (me.layer.display_hidden == 1) {
|
||||
me.layer.display_hidden = 0;
|
||||
me.clear();
|
||||
me.terrain_maxalt.setValue(-9999);
|
||||
me.min_altitude = 9999;
|
||||
me.max_altitude = -9999;
|
||||
terrain_maxalt.setValue(-9999);
|
||||
me.avg_maxalt = -9999;
|
||||
me.reference = nil;
|
||||
}
|
||||
|
||||
|
@ -348,9 +377,9 @@ var draw = func {
|
|||
me.reflowaltft = (pts.Gear.position[1].getValue()) ? -250 : -500;
|
||||
me.onground = pts.Gear.wow[0].getValue();
|
||||
|
||||
if (me.min_altitude != 9999) me.update_altitudes();
|
||||
if (me.max_altitude != -9999) me.update_altitudes();
|
||||
|
||||
var flatalt = (me.avg_peakalt != nil and me.avg_peakalt>499) ? 400 : 140;
|
||||
var flatalt = (me.avg_diffalt == nil or me.avg_diffalt>499) ? 400 : 180;
|
||||
|
||||
var vspeed30s = int(getprop("velocities/vertical-speed-fps") * 30);
|
||||
if (vspeed30s<-500) me.refaltitudeft = math.max(me.avg_minalt , me.refaltitudeft + vspeed30s);
|
||||
|
@ -397,19 +426,10 @@ var draw = func {
|
|||
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);
|
||||
#}
|
||||
if (me.avg_minalt != 9999) me.basealtitudeft = int(math.avg(me.basealtitudeft,flatalt + me.avg_minalt));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
|
|
@ -298,40 +298,41 @@
|
|||
sodipodi:role="line"
|
||||
id="tspan1994"
|
||||
x="952.74292"
|
||||
y="826.34009">TERR</tspan></text><text
|
||||
inkscape:label="#text7243"
|
||||
id="terrHI"
|
||||
y="858.63959"
|
||||
x="965.73273"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;display:inline;fill:#0dc04b;fill-opacity:1;stroke:none"
|
||||
xml:space="preserve"><tspan
|
||||
y="826.34009">TERR</tspan></text><g
|
||||
id="terrAltGroup"><text
|
||||
inkscape:label="#text7243"
|
||||
id="terrHI"
|
||||
y="858.63959"
|
||||
x="965.73273"
|
||||
id="tspan2002"
|
||||
sodipodi:role="line"
|
||||
style="font-size:32px;line-height:1.25;fill:#0dc04b">000</tspan></text><text
|
||||
inkscape:label="#text7243"
|
||||
id="terrLO"
|
||||
y="888.00446"
|
||||
x="965.73273"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;display:inline;fill:#0dc04b;fill-opacity:1;stroke:none"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;display:inline;fill:#0dc04b;fill-opacity:1;stroke:none"
|
||||
xml:space="preserve"><tspan
|
||||
y="858.63959"
|
||||
x="965.73273"
|
||||
id="tspan2002"
|
||||
sodipodi:role="line"
|
||||
style="font-size:32px;line-height:1.25;fill:#0dc04b">000</tspan></text><text
|
||||
inkscape:label="#text7243"
|
||||
id="terrLO"
|
||||
y="888.00446"
|
||||
x="965.73273"
|
||||
id="tspan2006"
|
||||
sodipodi:role="line"
|
||||
style="font-size:32px;line-height:1.25;fill:#0dc04b">000</tspan></text><rect
|
||||
style="fill:none;stroke:#f2f235;stroke-width:3.15591;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect2018"
|
||||
width="67.30439"
|
||||
height="58.673889"
|
||||
x="958.45599"
|
||||
y="833.17212"
|
||||
ry="0" /><path
|
||||
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#f2f235;stroke-width:3.15591;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.9941;stop-color:#000000;stop-opacity:1"
|
||||
d="m 958.38792,861.87476 67.46618,0.61588"
|
||||
id="path2033"
|
||||
sodipodi:nodetypes="cc" /></g><path
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;line-height:0%;font-family:'Liberation Sans';-inkscape-font-specification:'Liberation Sans';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;display:inline;fill:#0dc04b;fill-opacity:1;stroke:none"
|
||||
xml:space="preserve"><tspan
|
||||
y="888.00446"
|
||||
x="965.73273"
|
||||
id="tspan2006"
|
||||
sodipodi:role="line"
|
||||
style="font-size:32px;line-height:1.25;fill:#0dc04b">000</tspan></text><rect
|
||||
style="fill:none;stroke:#f2f235;stroke-width:3.15591;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="rect2018"
|
||||
width="67.30439"
|
||||
height="58.673889"
|
||||
x="958.45599"
|
||||
y="833.17212"
|
||||
ry="0" /><path
|
||||
style="font-variation-settings:normal;opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#f2f235;stroke-width:3.15591;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.9941;stop-color:#000000;stop-opacity:1"
|
||||
d="m 958.38792,861.87476 67.46618,0.61588"
|
||||
id="path2033"
|
||||
sodipodi:nodetypes="cc" /></g></g><path
|
||||
sodipodi:nodetypes="cc"
|
||||
inkscape:label="#path3843"
|
||||
inkscape:transform-center-y="-340.574"
|
||||
|
|
Before Width: | Height: | Size: 144 KiB After Width: | Height: | Size: 144 KiB |
|
@ -12,9 +12,6 @@ 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];
|
||||
|
@ -97,14 +94,15 @@ canvas.NDStyles["Airbus"] = {
|
|||
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"));
|
||||
#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) {
|
||||
if (visible) {
|
||||
layer.update();
|
||||
} else {
|
||||
layer.display_changed = 1;
|
||||
layer.efis_path = nd.efis_path;
|
||||
layer.display_hidden = 1;
|
||||
}
|
||||
layer.group.setVisible(visible);
|
||||
}, # end of layer update predicate
|
||||
|
@ -2003,28 +2001,39 @@ canvas.NDStyles["Airbus"] = {
|
|||
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){
|
||||
var terrain_maxalt = props.globals.initNode(nd.efis_path ~ "/nd/terrain-on-nd/max-altitude", -9999,"INT");
|
||||
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]);
|
||||
}
|
||||
|
||||
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)));
|
||||
var terrain_minalt = getprop(nd.efis_path ~ "/nd/terrain-on-nd/min-altitude");
|
||||
var terrain_maxcol = getprop(nd.efis_path ~ "/nd/terrain-on-nd/max-color");
|
||||
nd.symbols.terrLO.setText(sprintf("%03d",math.round(terrain_minalt/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();
|
||||
if (terrain_maxcol == 0) nd.symbols.terrHI.setColor(GREEN[0],GREEN[1],GREEN[2]);
|
||||
else if (terrain_maxcol == 1) nd.symbols.terrHI.setColor(YELLOW[0],YELLOW[1],YELLOW[2]);
|
||||
else nd.symbols.terrHI.setColor(RED[0],RED[1],RED[2]);
|
||||
terrain_maxalt.setValue(-9999); #update visual at radar cycle
|
||||
}
|
||||
nd.symbols.terrAltGroup.show();
|
||||
}
|
||||
|
||||
if (nd.change_phase == 1) {
|
||||
nd.symbols.terrAltGroup.hide();
|
||||
}
|
||||
|
||||
nd.symbols.terrGroup.show();
|
||||
},
|
||||
is_false: func(nd){
|
||||
nd.symbols.terrGroup.hide();
|
||||
nd.symbols.terrAltGroup.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -2705,7 +2705,7 @@ var canvas_PFD_2_mismatch = {
|
|||
},
|
||||
};
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func {
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
PFD1_display = canvas.new({
|
||||
"name": "PFD1",
|
||||
"size": [1024, 1024],
|
||||
|
|
|
@ -343,7 +343,7 @@ var fbw_loop = func {
|
|||
}
|
||||
}
|
||||
|
||||
setlistener("systems/fctl/sec1", func() {
|
||||
setlistener("/systems/fctl/sec1", func() {
|
||||
if (FBW.Computers.sec1.getBoolValue()) {
|
||||
FBW.Failures.spoilerl3.setBoolValue(0);
|
||||
FBW.Failures.spoilerr3.setBoolValue(0);
|
||||
|
@ -357,7 +357,7 @@ setlistener("systems/fctl/sec1", func() {
|
|||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("systems/fctl/sec2", func() {
|
||||
setlistener("/systems/fctl/sec2", func() {
|
||||
if (FBW.Computers.sec2.getBoolValue()) {
|
||||
FBW.Failures.spoilerl5.setBoolValue(0);
|
||||
FBW.Failures.spoilerr5.setBoolValue(0);
|
||||
|
@ -367,7 +367,7 @@ setlistener("systems/fctl/sec2", func() {
|
|||
}
|
||||
}, 0, 0);
|
||||
|
||||
setlistener("systems/fctl/sec3", func() {
|
||||
setlistener("/systems/fctl/sec3", func() {
|
||||
if (FBW.Computers.sec3.getBoolValue()) {
|
||||
FBW.Failures.spoilerl1.setBoolValue(0);
|
||||
FBW.Failures.spoilerr1.setBoolValue(0);
|
||||
|
|
|
@ -633,6 +633,6 @@ setlistener("/modes/pfd/fma/pitch-mode2-armed", func {
|
|||
}
|
||||
});
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func {
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
init();
|
||||
});
|
||||
|
|
|
@ -71,7 +71,7 @@ var rudderTrim = {
|
|||
rudderTrimDisplayLetter: props.globals.initNode("/controls/flight/rudder-trim-letter-display", "", "STRING"),
|
||||
};
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func {
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
chr.stop();
|
||||
chr.reset();
|
||||
clk.stop();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
var mode = "NAV";
|
||||
var rng = 20;
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func { # Fix completely retarded shit on the ND
|
||||
setlistener("/sim/signals/fdm-initialized", func { # Fix completely retarded shit on the ND
|
||||
pts.Instrumentation.Efis.Mfd.pnlModeNum[0].setValue(2);
|
||||
pts.Instrumentation.Efis.Mfd.pnlModeNum[1].setValue(2);
|
||||
pts.Instrumentation.Efis.Nd.displayMode[0].setValue("NAV");
|
||||
|
|
|
@ -82,6 +82,6 @@ var ground_message = func (string) {
|
|||
setprop("/sim/messages/ground", string);
|
||||
}
|
||||
|
||||
setlistener("sim/signals/fdm-initialized", func {
|
||||
setlistener("/sim/signals/fdm-initialized", func {
|
||||
ground_services.init();
|
||||
});
|
||||
|
|
|
@ -7,7 +7,7 @@ var tyresmoke_1 = aircraft.tyresmoke.new(1, 0, 0.8, 0);
|
|||
var tyresmoke_2 = aircraft.tyresmoke.new(2, 0, 0.8, 0);
|
||||
|
||||
# =============================== listeners ===============================
|
||||
setlistener("gear/gear[0]/position-norm", func {
|
||||
setlistener("/gear/gear[0]/position-norm", func {
|
||||
if (pts.Gear.position[0].getValue()){
|
||||
run_tyresmoke0 = 1;
|
||||
}else{
|
||||
|
@ -15,7 +15,7 @@ setlistener("gear/gear[0]/position-norm", func {
|
|||
}
|
||||
},1,0);
|
||||
|
||||
setlistener("gear/gear[1]/position-norm", func {
|
||||
setlistener("/gear/gear[1]/position-norm", func {
|
||||
if (pts.Gear.position[1].getValue()){
|
||||
run_tyresmoke1 = 1;
|
||||
}else{
|
||||
|
@ -23,7 +23,7 @@ setlistener("gear/gear[1]/position-norm", func {
|
|||
}
|
||||
},1,0);
|
||||
|
||||
setlistener("gear/gear[2]/position-norm", func {
|
||||
setlistener("/gear/gear[2]/position-norm", func {
|
||||
if (pts.Gear.position[2].getValue()){
|
||||
run_tyresmoke2 = 1;
|
||||
}else{
|
||||
|
|
Loading…
Reference in a new issue