diff --git a/Models/Instruments/PFD/PFD.nas b/Models/Instruments/PFD/PFD.nas
index cf95ab3d..a004696b 100644
--- a/Models/Instruments/PFD/PFD.nas
+++ b/Models/Instruments/PFD/PFD.nas
@@ -15,6 +15,8 @@ var updateR = 0;
var elapsedtime = 0;
var altTens = 0;
var altPolarity = "";
+var track_diff = 0;
+var AICenter = nil;
# Fetch nodes:
var state1 = props.globals.getNode("/systems/thrust/state1", 1);
@@ -126,6 +128,16 @@ var inner_marker = props.globals.getNode("/instrumentation/marker-beacon/inner",
var flap_config = props.globals.getNode("/controls/flight/flaps-input", 1);
var hundredAbove = props.globals.getNode("/instrumentation/pfd/hundred-above", 1);
var minimum = props.globals.getNode("/instrumentation/pfd/minimums", 1);
+var aoa_1 = props.globals.getNode("/systems/navigation/adr/output/aoa-1", 1);
+var aoa_2 = props.globals.getNode("/systems/navigation/adr/output/aoa-2", 1);
+var aoa_3 = props.globals.getNode("/systems/navigation/adr/output/aoa-3", 1);
+var adr_1_switch = props.globals.getNode("/controls/navigation/adirscp/switches/adr-1", 1);
+var adr_2_switch = props.globals.getNode("/controls/navigation/adirscp/switches/adr-2", 1);
+var adr_3_switch = props.globals.getNode("/controls/navigation/adirscp/switches/adr-3", 1);
+var adr_1_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr-1-fault", 1);
+var adr_2_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr-2-fault", 1);
+var adr_3_fault = props.globals.getNode("/controls/navigation/adirscp/lights/adr-3-fault", 1);
+var air_data_switch = props.globals.getNode("/controls/navigation/switching/air-data", 1);
# Create Nodes:
var alt_diff = props.globals.initNode("/instrumentation/pfd/alt-diff", 0.0, "DOUBLE");
@@ -137,7 +149,7 @@ var horizon_ground = props.globals.initNode("/instrumentation/pfd/horizon-ground
var hdg_diff = props.globals.initNode("/instrumentation/pfd/hdg-diff", 0.0, "DOUBLE");
var hdg_scale = props.globals.initNode("/instrumentation/pfd/heading-scale", 0.0, "DOUBLE");
var track = props.globals.initNode("/instrumentation/pfd/track-deg", 0.0, "DOUBLE");
-var track_diff = props.globals.initNode("/instrumentation/pfd/track-hdg-diff", 0.0, "DOUBLE");
+#var track_diff = props.globals.initNode("/instrumentation/pfd/track-hdg-diff", 0.0, "DOUBLE"); # returns incorrect value
var du1_test = props.globals.initNode("/instrumentation/du/du1-test", 0, "BOOL");
var du1_test_time = props.globals.initNode("/instrumentation/du/du1-test-time", 0.0, "DOUBLE");
var du1_offtime = props.globals.initNode("/instrumentation/du/du1-off-time", 0.0, "DOUBLE");
@@ -200,6 +212,9 @@ var canvas_PFD_base = {
me.AI_horizon_hdg_trans = me["AI_heading"].createTransform();
me.AI_horizon_hdg_rot = me["AI_heading"].createTransform();
+ me.AI_fpv_trans = me["FPV"].createTransform();
+ me.AI_fpv_rot = me["FPV"].createTransform();
+
me.page = canvas_group;
return me;
@@ -212,7 +227,7 @@ var canvas_PFD_base = {
"AI_agl_g","AI_agl","AI_error","AI_group","FD_roll","FD_pitch","ALT_box_flash","ALT_box","ALT_box_amber","ALT_scale","ALT_target","ALT_target_digit","ALT_one","ALT_two","ALT_three","ALT_four","ALT_five","ALT_digits","ALT_tens","ALT_digit_UP",
"ALT_digit_DN","ALT_error","ALT_group","ALT_group2","ALT_frame","VS_pointer","VS_box","VS_digit","VS_error","VS_group","QNH","QNH_setting","QNH_std","QNH_box","LOC_pointer","LOC_scale","GS_scale","GS_pointer","CRS_pointer","HDG_target","HDG_scale",
"HDG_one","HDG_two","HDG_three","HDG_four","HDG_five","HDG_six","HDG_seven","HDG_digit_L","HDG_digit_R","HDG_error","HDG_group","HDG_frame","TRK_pointer","machError","ilsError","ils_code","ils_freq","dme_dist","dme_dist_legend","ILS_HDG_R","ILS_HDG_L",
- "ILS_right","ILS_left","outerMarker","middleMarker","innerMarker","v1_group","v1_text","vr_speed","F_target","S_target","FS_targets","flap_max","clean_speed","ground","ground_ref","spdLimError"];
+ "ILS_right","ILS_left","outerMarker","middleMarker","innerMarker","v1_group","v1_text","vr_speed","F_target","S_target","FS_targets","flap_max","clean_speed","ground","ground_ref","FPV", "fixed_aircraft_outline_1","fixed_aircraft_outline_2","spdLimError"];
},
updateDu1: func() {
var elapsedtime_act = elapsedtime.getValue();
@@ -961,12 +976,15 @@ var canvas_PFD_base = {
me["HDG_target"].hide();
}
- me["TRK_pointer"].setTranslation((math.clamp(track_diff.getValue(), -23.62, 23.62) / 10) * 98.5416, 0);
+
+ var heading_deg = heading.getValue();
+ track_diff = geo.normdeg180(track.getValue() - heading_deg);
+ me["TRK_pointer"].setTranslation(me.getTrackDiffPixels(track_diff),0);
split_ils = split("/", ils_data1.getValue());
if (ap_ils_mode.getValue() == 1 and size(split_ils) == 2) {
magnetic_hdg = ils_crs.getValue();
- magnetic_hdg_dif = geo.normdeg180(magnetic_hdg - heading.getValue());
+ magnetic_hdg_dif = geo.normdeg180(magnetic_hdg - heading_deg);
if (magnetic_hdg_dif >= -23.62 and magnetic_hdg_dif <= 23.62) {
me["CRS_pointer"].setTranslation((magnetic_hdg_dif / 10) * 98.5416, 0);
me["ILS_HDG_R"].hide();
@@ -1010,6 +1028,28 @@ var canvas_PFD_base = {
me.AI_horizon_hdg_rot.setRotation(-roll_cur * D2R, me["AI_center"].getCenter());
me["AI_heading"].update();
},
+
+ # Get Angle of Attack from ADR1 or, depending on Switching panel, ADR3
+ getAOAForPFD1: func() {
+ if (air_data_switch.getValue() != -1 and adr_1_switch.getValue() and !adr_1_fault.getValue()) return aoa_1.getValue();
+ if (air_data_switch.getValue() == -1 and adr_3_switch.getValue() and !adr_3_fault.getValue()) return aoa_3.getValue();
+ return nil;
+ },
+
+ # Get Angle of Attack from ADR2 or, depending on Switching panel, ADR3
+ getAOAForPFD2: func() {
+ if (air_data_switch.getValue() != 1 and adr_2_switch.getValue() and !adr_2_fault.getValue()) return aoa_2.getValue();
+ if (air_data_switch.getValue() == 1 and adr_3_switch.getValue() and !adr_3_fault.getValue()) return aoa_3.getValue();
+ return nil;
+ },
+
+ # Convert difference between magnetic heading and track measured in degrees to pixel for display on PFDs
+ # And set max and minimum values
+ getTrackDiffPixels: func(track_diff_deg) {
+ return ((math.clamp(track_diff_deg, -23.62, 23.62) / 10) * 98.5416);
+ },
+
+
};
var canvas_PFD_1 = {
@@ -1087,6 +1127,26 @@ var canvas_PFD_1 = {
me["FD_pitch"].hide();
}
+ # If TRK FPA selected, display FPV on PFD1
+ if (ap_trk_sw.getValue() == 0 ) {
+ me["FPV"].hide();
+ } else {
+ var aoa = me.getAOAForPFD1();
+ if (aoa == nil or (systems.ADIRS.ADIRunits[0].aligned != 1 and att_switch.getValue() == 0) or (systems.ADIRS.ADIRunits[2].aligned != 1 and att_switch.getValue() == -1)){
+ me["FPV"].hide();
+ } else {
+ var roll_deg = roll.getValue() or 0;
+ AICenter = me["AI_center"].getCenter();
+ var track_x_translation = me.getTrackDiffPixels(track_diff);
+
+ me.AI_fpv_trans.setTranslation(track_x_translation, math.clamp(aoa, -20, 20) * 12.5);
+ me.AI_fpv_rot.setRotation(-roll_deg * D2R, AICenter);
+ me["FPV"].setRotation(roll_deg * D2R); # It shouldn't be rotated, only the axis should be
+ me["FPV"].show();
+ }
+
+ }
+
# ILS
if (ap_ils_mode.getValue() == 1) {
me["LOC_scale"].show();
@@ -1842,6 +1902,25 @@ var canvas_PFD_2 = {
me["FD_pitch"].hide();
}
+ # If TRK FPA selected, display FPV on PFD2
+ if (ap_trk_sw.getValue() == 0 ) {
+ me["FPV"].hide();
+ } else {
+ var aoa = me.getAOAForPFD2();
+ if (aoa == nil or (systems.ADIRS.ADIRunits[1].aligned != 1 and att_switch.getValue() == 0) or (systems.ADIRS.ADIRunits[2].aligned != 1 and att_switch.getValue() == 1)) {
+ me["FPV"].hide();
+ } else {
+ var roll_deg = roll.getValue() or 0;
+ AICenter = me["AI_center"].getCenter();
+ var track_x_translation = me.getTrackDiffPixels(track_diff);
+
+ me.AI_fpv_trans.setTranslation(track_x_translation, math.clamp(aoa, -20, 20) * 12.5);
+ me.AI_fpv_rot.setRotation(-roll_deg * D2R, AICenter);
+ me["FPV"].setRotation(roll_deg * D2R); # It shouldn't be rotated, only the axis should be
+ me["FPV"].show();
+ }
+ }
+
# ILS
if (ap_ils_mode2.getValue() == 1) {
me["LOC_scale"].show();
diff --git a/Models/Instruments/PFD/res/pfd.svg b/Models/Instruments/PFD/res/pfd.svg
index 88060ede..e99d89ea 100644
--- a/Models/Instruments/PFD/res/pfd.svg
+++ b/Models/Instruments/PFD/res/pfd.svg
@@ -1396,9 +1396,10 @@
+ style="fill:none;fill-opacity:1;stroke:#c9d121;stroke-width:3.54375;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
+ inkscape:label="fixed_aircraft_outline_1" />
+ sodipodi:nodetypes="cccccccccccc"
+ inkscape:label="fixed_aircraft_outline_2" />