1
0
Fork 0

ADIRS - altitude

This commit is contained in:
legoboyvdlp R 2019-11-08 19:19:46 +00:00
parent 67091ed35d
commit 4a2476a3f4
4 changed files with 279 additions and 78 deletions

View file

@ -673,69 +673,6 @@ var canvas_PFD_base = {
me["AI_stick_pos"].setTranslation(aileron_input.getValue() * 196.8, elevator_input.getValue() * 151.5);
# Altitude
me.altitude = altitude.getValue();
me.altOffset = me.altitude / 500 - int(me.altitude / 500);
me.middleAltText = roundaboutAlt(me.altitude / 100);
me.middleAltOffset = nil;
if (me.altOffset > 0.5) {
me.middleAltOffset = -(me.altOffset - 1) * 243.3424;
} else {
me.middleAltOffset = -me.altOffset * 243.3424;
}
me["ALT_scale"].setTranslation(0, -me.middleAltOffset);
me["ALT_scale"].update();
me["ALT_five"].setText(sprintf("%03d", abs(me.middleAltText+10)));
me["ALT_four"].setText(sprintf("%03d", abs(me.middleAltText+5)));
me["ALT_three"].setText(sprintf("%03d", abs(me.middleAltText)));
me["ALT_two"].setText(sprintf("%03d", abs(me.middleAltText-5)));
me["ALT_one"].setText(sprintf("%03d", abs(me.middleAltText-10)));
if (altitude.getValue() < 0) {
altPolarity = "-";
} else {
altPolarity = "";
}
me["ALT_digits"].setText(sprintf("%s%d", altPolarity, altitude_pfd.getValue()));
altTens = num(right(sprintf("%02d", altitude.getValue()), 2));
me["ALT_tens"].setTranslation(0, altTens * 1.392);
ap_alt_cur = ap_alt.getValue();
alt_diff_cur = alt_diff.getValue();
if (alt_diff_cur >= -565 and alt_diff_cur <= 565) {
me["ALT_target"].setTranslation(0, (alt_diff_cur / 100) * -48.66856);
me["ALT_target_digit"].setText(sprintf("%03d", math.round(ap_alt_cur / 100)));
me["ALT_digit_UP"].hide();
me["ALT_digit_DN"].hide();
me["ALT_target"].show();
} else if (alt_diff_cur < -565) {
if (alt_std_mode.getValue() == 1) {
if (ap_alt_cur < 10000) {
me["ALT_digit_DN"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
} else {
me["ALT_digit_DN"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
}
} else {
me["ALT_digit_DN"].setText(sprintf("%5.0f", ap_alt_cur));
}
me["ALT_digit_DN"].show();
me["ALT_digit_UP"].hide();
me["ALT_target"].hide();
} else if (alt_diff_cur > 565) {
if (alt_std_mode.getValue() == 1) {
if (ap_alt_cur < 10000) {
me["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
} else {
me["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
}
} else {
me["ALT_digit_UP"].setText(sprintf("%5.0f", ap_alt_cur));
}
me["ALT_digit_UP"].show();
me["ALT_digit_DN"].hide();
me["ALT_target"].hide();
}
# Vertical Speed
me["VS_pointer"].setRotation(vs_needle.getValue() * D2R);
@ -854,20 +791,10 @@ var canvas_PFD_1 = {
# Errors
if ((adirs0_active.getValue() == 1) or (air_switch.getValue() == -1 and adirs2_active.getValue() == 1)) {
me["ALT_group"].show();
me["ALT_group2"].show();
me["ALT_scale"].show();
me["VS_group"].show();
me["ALT_error"].hide();
me["ALT_frame"].setColor(1,1,1);
me["VS_error"].hide();
} else {
me["ALT_error"].show();
me["ALT_frame"].setColor(1,0,0);
me["VS_error"].show();
me["ALT_group"].hide();
me["ALT_group2"].hide();
me["ALT_scale"].hide();
me["VS_group"].hide();
}
@ -1050,6 +977,85 @@ var canvas_PFD_1 = {
} else {
me["machError"].show();
}
# Altitude
if (dmc.DMController.DMCs[0].outputs[1] != nil) {
me["ALT_error"].hide();
me["ALT_frame"].setColor(1,1,1);
me["ALT_group"].show();
me["ALT_group2"].show();
me["ALT_scale"].show();
me.altitude = dmc.DMController.DMCs[0].outputs[1].getValue();
me.altOffset = me.altitude / 500 - int(me.altitude / 500);
me.middleAltText = roundaboutAlt(me.altitude / 100);
me.middleAltOffset = nil;
if (me.altOffset > 0.5) {
me.middleAltOffset = -(me.altOffset - 1) * 243.3424;
} else {
me.middleAltOffset = -me.altOffset * 243.3424;
}
me["ALT_scale"].setTranslation(0, -me.middleAltOffset);
me["ALT_scale"].update();
me["ALT_five"].setText(sprintf("%03d", abs(me.middleAltText+10)));
me["ALT_four"].setText(sprintf("%03d", abs(me.middleAltText+5)));
me["ALT_three"].setText(sprintf("%03d", abs(me.middleAltText)));
me["ALT_two"].setText(sprintf("%03d", abs(me.middleAltText-5)));
me["ALT_one"].setText(sprintf("%03d", abs(me.middleAltText-10)));
if (altitude.getValue() < 0) {
altPolarity = "-";
} else {
altPolarity = "";
}
me["ALT_digits"].setText(sprintf("%s%d", altPolarity, dmc.DMController.DMCs[0].outputs[3].getValue()));
altTens = num(right(sprintf("%02d", me.altitude), 2));
me["ALT_tens"].setTranslation(0, altTens * 1.392);
ap_alt_cur = ap_alt.getValue();
alt_diff_cur = alt_diff.getValue();
if (alt_diff_cur >= -565 and alt_diff_cur <= 565) {
me["ALT_target"].setTranslation(0, (alt_diff_cur / 100) * -48.66856);
me["ALT_target_digit"].setText(sprintf("%03d", math.round(ap_alt_cur / 100)));
me["ALT_digit_UP"].hide();
me["ALT_digit_DN"].hide();
me["ALT_target"].show();
} else if (alt_diff_cur < -565) {
if (alt_std_mode.getValue() == 1) {
if (ap_alt_cur < 10000) {
me["ALT_digit_DN"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
} else {
me["ALT_digit_DN"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
}
} else {
me["ALT_digit_DN"].setText(sprintf("%5.0f", ap_alt_cur));
}
me["ALT_digit_DN"].show();
me["ALT_digit_UP"].hide();
me["ALT_target"].hide();
} else if (alt_diff_cur > 565) {
if (alt_std_mode.getValue() == 1) {
if (ap_alt_cur < 10000) {
me["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
} else {
me["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
}
} else {
me["ALT_digit_UP"].setText(sprintf("%5.0f", ap_alt_cur));
}
me["ALT_digit_UP"].show();
me["ALT_digit_DN"].hide();
me["ALT_target"].hide();
}
} else {
me["ALT_error"].show();
me["ALT_frame"].setColor(1,0,0);
me["ALT_group"].hide();
me["ALT_group2"].hide();
me["ALT_scale"].hide();
}
me.updateCommonFast();
},
};
@ -1276,6 +1282,83 @@ var canvas_PFD_2 = {
me["machError"].show();
}
if (dmc.DMController.DMCs[1].outputs[1] != nil) {
me["ALT_error"].hide();
me["ALT_frame"].setColor(1,1,1);
me["ALT_group"].show();
me["ALT_group2"].show();
me["ALT_scale"].show();
me.altitude = dmc.DMController.DMCs[1].outputs[1].getValue();
me.altOffset = me.altitude / 500 - int(me.altitude / 500);
me.middleAltText = roundaboutAlt(me.altitude / 100);
me.middleAltOffset = nil;
if (me.altOffset > 0.5) {
me.middleAltOffset = -(me.altOffset - 1) * 243.3424;
} else {
me.middleAltOffset = -me.altOffset * 243.3424;
}
me["ALT_scale"].setTranslation(0, -me.middleAltOffset);
me["ALT_scale"].update();
me["ALT_five"].setText(sprintf("%03d", abs(me.middleAltText+10)));
me["ALT_four"].setText(sprintf("%03d", abs(me.middleAltText+5)));
me["ALT_three"].setText(sprintf("%03d", abs(me.middleAltText)));
me["ALT_two"].setText(sprintf("%03d", abs(me.middleAltText-5)));
me["ALT_one"].setText(sprintf("%03d", abs(me.middleAltText-10)));
if (altitude.getValue() < 0) {
altPolarity = "-";
} else {
altPolarity = "";
}
me["ALT_digits"].setText(sprintf("%s%d", altPolarity, dmc.DMController.DMCs[1].outputs[3].getValue()));
altTens = num(right(sprintf("%02d", me.altitude), 2));
me["ALT_tens"].setTranslation(0, altTens * 1.392);
ap_alt_cur = ap_alt.getValue();
alt_diff_cur = alt_diff.getValue();
if (alt_diff_cur >= -565 and alt_diff_cur <= 565) {
me["ALT_target"].setTranslation(0, (alt_diff_cur / 100) * -48.66856);
me["ALT_target_digit"].setText(sprintf("%03d", math.round(ap_alt_cur / 100)));
me["ALT_digit_UP"].hide();
me["ALT_digit_DN"].hide();
me["ALT_target"].show();
} else if (alt_diff_cur < -565) {
if (alt_std_mode.getValue() == 1) {
if (ap_alt_cur < 10000) {
me["ALT_digit_DN"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
} else {
me["ALT_digit_DN"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
}
} else {
me["ALT_digit_DN"].setText(sprintf("%5.0f", ap_alt_cur));
}
me["ALT_digit_DN"].show();
me["ALT_digit_UP"].hide();
me["ALT_target"].hide();
} else if (alt_diff_cur > 565) {
if (alt_std_mode.getValue() == 1) {
if (ap_alt_cur < 10000) {
me["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
} else {
me["ALT_digit_UP"].setText(sprintf("%s", "FL " ~ ap_alt_cur / 100));
}
} else {
me["ALT_digit_UP"].setText(sprintf("%5.0f", ap_alt_cur));
}
me["ALT_digit_UP"].show();
me["ALT_digit_DN"].hide();
me["ALT_target"].hide();
}
} else {
me["ALT_error"].show();
me["ALT_frame"].setColor(1,0,0);
me["ALT_group"].hide();
me["ALT_group2"].hide();
me["ALT_scale"].hide();
}
me.updateCommonFast();
},
};

View file

@ -10,14 +10,16 @@ var DMC = {
activeADIRS: -9,
airspeeds: [props.globals.getNode("/systems/navigation/adr/output/cas-1", 1), props.globals.getNode("/systems/navigation/adr/output/cas-2", 1), props.globals.getNode("/systems/navigation/adr/output/cas-3", 1)],
altitudes: [props.globals.getNode("/systems/navigation/adr/output/baro-alt-corrected-1-capt", 1), props.globals.getNode("/systems/navigation/adr/output/baro-alt-corrected-2-capt", 1), props.globals.getNode("/systems/navigation/adr/output/baro-alt-corrected-3-capt", 1)],
machs: [props.globals.getNode("/systems/navigation/adr/output/mach-1", 1), props.globals.getNode("/systems/navigation/adr/output/mach-2", 1), props.globals.getNode("/systems/navigation/adr/output/mach-3", 1)],
altitudesPfd: [props.globals.getNode("/instrumentation/altimeter[0]/indicated-altitude-ft-pfd", 1), props.globals.getNode("/instrumentation/altimeter[1]/indicated-altitude-ft-pfd", 1), props.globals.getNode("/instrumentation/altimeter[2]/indicated-altitude-ft-pfd", 1)],
outputs: [nil, nil, nil], # airspeed, altitude, mach
outputs: [nil, nil, nil, nil], # airspeed, altitude, mach, pfd altitude
new: func(num) {
var d = { parents:[DMC] };
d.activeADIRS = num;
d.outputs = [nil, nil, nil];
d.outputs = [nil, nil, nil, nil];
return d;
},
changeActiveADIRS: func(newADIRS) {
@ -26,12 +28,15 @@ var DMC = {
},
setOutputs: func(ADIRS) {
me.outputs[0] = me.airspeeds[ADIRS];
me.outputs[1] = me.altitudes[ADIRS];
me.outputs[2] = me.machs[ADIRS];
me.outputs[3] = me.altitudesPfd[ADIRS];
},
setOutputsNil: func() {
me.outputs[0] = nil;
me.outputs[1] = nil;
me.outputs[2] = nil;
me.outputs[3] = nil;
},
update: func() {
if (systems.ADIRSnew.ADIRunits[me.activeADIRS].operative and systems.ADIRSnew.ADIRunits[me.activeADIRS].outputOn) {
@ -59,6 +64,11 @@ var DMController = {
init: func() {
if (!me._init) {
me.DMCs = [DMC.new(0), DMC.new(1), DMC.new(2)];
# update DMC2 to correct properties for first officer PFD
me.DMCs[1].altitudes = [props.globals.getNode("/systems/navigation/adr/output/baro-alt-corrected-1-fo", 1), props.globals.getNode("/systems/navigation/adr/output/baro-alt-corrected-2-fo", 1), props.globals.getNode("/systems/navigation/adr/output/baro-alt-corrected-3-fo", 1)];
me.DMCs[1].altitudesPfd = [props.globals.getNode("/instrumentation/altimeter[3]/indicated-altitude-ft-pfd", 1), props.globals.getNode("/instrumentation/altimeter[4]/indicated-altitude-ft-pfd", 1), props.globals.getNode("/instrumentation/altimeter[5]/indicated-altitude-ft-pfd", 1)];
me._init = 1;
}
},

View file

@ -837,7 +837,7 @@
<gain>/systems/navigation/adr/operating-1</gain>
</pure_gain>
<pure_gain name="/systems/navigation/adr/output/baro-alt-corrected-2-capt">
<pure_gain name="/systems/navigation/adr/output/baro-alt-corrected-2-fo">
<input>/systems/navigation/adr/computation/baro-alt-corrected-2-fo</input>
<gain>/systems/navigation/adr/operating-2</gain>
</pure_gain>

View file

@ -121,13 +121,121 @@
<expression>
<floor>
<div>
<abs><property>/instrumentation/altimeter/indicated-altitude-ft</property></abs>
<abs><property>/instrumentation/altimeter[0]/indicated-altitude-ft</property></abs>
<value>100</value>
</div>
</floor>
</expression>
</input>
<output>/instrumentation/altimeter/indicated-altitude-ft-pfd</output>
<output>/instrumentation/altimeter[0]/indicated-altitude-ft-pfd</output>
</filter>
<filter>
<name>Altitude PFD</name>
<type>gain</type>
<gain>1.0</gain>
<update-interval-secs type="double">0.05</update-interval-secs>
<input>
<expression>
<floor>
<div>
<abs><property>/instrumentation/altimeter[1]/indicated-altitude-ft</property></abs>
<value>100</value>
</div>
</floor>
</expression>
</input>
<output>/instrumentation/altimeter[1]/indicated-altitude-ft-pfd</output>
</filter>
<filter>
<name>Altitude PFD</name>
<type>gain</type>
<gain>1.0</gain>
<update-interval-secs type="double">0.05</update-interval-secs>
<input>
<expression>
<floor>
<div>
<abs><property>/instrumentation/altimeter[2]/indicated-altitude-ft</property></abs>
<value>100</value>
</div>
</floor>
</expression>
</input>
<output>/instrumentation/altimeter[2]/indicated-altitude-ft-pfd</output>
</filter>
<filter>
<name>Altitude PFD</name>
<type>gain</type>
<gain>1.0</gain>
<update-interval-secs type="double">0.05</update-interval-secs>
<input>
<expression>
<floor>
<div>
<abs><property>/instrumentation/altimeter[3]/indicated-altitude-ft</property></abs>
<value>100</value>
</div>
</floor>
</expression>
</input>
<output>/instrumentation/altimeter[3]/indicated-altitude-ft-pfd</output>
</filter>
<filter>
<name>Altitude PFD</name>
<type>gain</type>
<gain>1.0</gain>
<update-interval-secs type="double">0.05</update-interval-secs>
<input>
<expression>
<floor>
<div>
<abs><property>/instrumentation/altimeter[4]/indicated-altitude-ft</property></abs>
<value>100</value>
</div>
</floor>
</expression>
</input>
<output>/instrumentation/altimeter[4]/indicated-altitude-ft-pfd</output>
</filter>
<filter>
<name>Altitude PFD</name>
<type>gain</type>
<gain>1.0</gain>
<update-interval-secs type="double">0.05</update-interval-secs>
<input>
<expression>
<floor>
<div>
<abs><property>/instrumentation/altimeter[5]/indicated-altitude-ft</property></abs>
<value>100</value>
</div>
</floor>
</expression>
</input>
<output>/instrumentation/altimeter[5]/indicated-altitude-ft-pfd</output>
</filter>
<filter>
<name>Altitude PFD</name>
<type>gain</type>
<gain>1.0</gain>
<update-interval-secs type="double">0.05</update-interval-secs>
<input>
<expression>
<floor>
<div>
<abs><property>/instrumentation/altimeter[6]/indicated-altitude-ft</property></abs>
<value>100</value>
</div>
</floor>
</expression>
</input>
<output>/instrumentation/altimeter[6]/indicated-altitude-ft-pfd</output>
</filter>
<filter>