2020-04-27 13:58:38 +00:00
# A3XX FCU
2020-04-18 05:36:46 +00:00
# Copyright (c) 2020 Josh Davidson (Octal450), Jonathan Redpath (legoboyvdlp)
2019-10-27 20:54:00 +00:00
# Nodes
2020-07-09 01:12:02 +00:00
var altSetMode = props.globals.getNode("/it-autoflight/config/altitude-dial-mode", 1);
2021-06-09 16:20:19 +00:00
var apOffSound = [props.globals.getNode("/it-autoflight/sound/apoffsound"),props.globals.getNode("/it-autoflight/sound/apoffsound2")];
var apWarningNode = props.globals.getNode("/it-autoflight/output/ap-warning");
var athrWarningNode = props.globals.getNode("/it-autoflight/output/athr-warning");
var apDiscBtn = props.globals.getNode("/sim/sounde/apdiscbtn");
2020-01-01 21:30:13 +00:00
var FCUworkingNode = props.globals.initNode("/FMGC/FCU-working", 0, "BOOL");
2019-10-27 20:54:00 +00:00
var FCU = {
elecSupply: "",
failed: 0,
2019-10-29 14:03:36 +00:00
condition: 100,
2019-10-27 20:54:00 +00:00
new: func(elecNode) {
var f = { parents:[FCU] };
f.elecSupply = elecNode;
return f;
},
2021-10-27 17:31:27 +00:00
elec: nil,
powerOffTime: -99,
loop: func(notification) {
me.elec = me.elecSupply.getValue();
if (me.elec < 25) {
if (me.powerOffTime == -99) {
me.powerOffTime = notification.elapsedTime;
}
} else {
me.powerOffTime = -99;
}
me.failed = ((notification.elapsedTime > (me.powerOffTime + 0.25) and me.elec < 25) or me.condition == 0) ? 1 : 0;
2019-10-29 14:03:36 +00:00
},
setFail: func() {
me.condition = 0;
},
restore: func() {
me.condition = 100;
2019-10-27 20:54:00 +00:00
},
};
var FCUController = {
FCU1: nil,
FCU2: nil,
2020-11-28 17:33:44 +00:00
activeFMGC: props.globals.getNode("/FMGC/active-fmgc-channel"),
2019-10-27 20:54:00 +00:00
FCUworking: 0,
2019-10-29 14:03:36 +00:00
_init: 0,
2019-10-27 20:54:00 +00:00
init: func() {
2019-12-28 17:38:20 +00:00
me.FCU1 = FCU.new(systems.ELEC.Bus.dcEss);
2019-10-27 20:54:00 +00:00
me.FCU2 = FCU.new(systems.ELEC.Bus.dc2);
2019-10-29 14:03:36 +00:00
me._init = 1;
2019-10-27 20:54:00 +00:00
},
2021-02-08 15:45:57 +00:00
loop: func(notification) {
2019-10-29 14:03:36 +00:00
if (me._init == 0) { return; }
2019-10-27 20:54:00 +00:00
# Update FCU Power
2021-10-27 17:31:27 +00:00
me.FCU1.loop(notification);
me.FCU2.loop(notification);
2019-10-27 20:54:00 +00:00
2020-01-01 21:30:13 +00:00
if (!me.FCU1.failed or !me.FCU2.failed) {
2019-10-27 20:54:00 +00:00
me.FCUworking = 1;
2020-01-01 21:30:13 +00:00
FCUworkingNode.setValue(1);
2019-10-27 20:54:00 +00:00
} else {
me.FCUworking = 0;
2020-01-01 21:30:13 +00:00
FCUworkingNode.setValue(0);
2019-10-27 20:54:00 +00:00
}
2019-11-30 13:39:53 +00:00
foreach (var update_item; me.update_items) {
2021-02-08 15:45:57 +00:00
update_item.update(notification);
2019-11-30 13:39:53 +00:00
}
2019-10-27 20:54:00 +00:00
},
2019-11-30 13:39:53 +00:00
update_items: [
2021-02-08 15:45:57 +00:00
props.UpdateManager.FromPropertyHashList(["/it-autoflight/output/fd1","/it-autoflight/output/fd2", "/it-autoflight/output/ap1", "/it-autoflight/output/ap2"], nil, func(notification)
2019-11-30 13:39:53 +00:00
{
updateActiveFMGC();
}
),
],
2019-10-29 14:03:36 +00:00
resetFail: func() {
if (me._init == 0) { return; }
me.FCU1.restore();
me.FCU2.restore();
},
2019-10-27 20:54:00 +00:00
AP1: func() {
2020-11-28 17:33:44 +00:00
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (!fmgc.Output.ap1.getBoolValue() and fbw.FBW.apOff == 0) {
fmgc.Input.ap1.setValue(1);
2020-05-16 20:04:03 +00:00
ecam.apWarnNode.setValue(0);
2020-07-16 18:50:01 +00:00
pts.Controls.Flight.rudderTrim.setValue(0);
2019-10-27 20:54:00 +00:00
} else {
apOff("hard", 1);
}
}
},
AP2: func() {
2020-11-28 17:33:44 +00:00
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (!fmgc.Output.ap2.getBoolValue() and fbw.FBW.apOff == 0) {
fmgc.Input.ap2.setValue(1);
2020-11-28 17:33:44 +00:00
ecam.apWarnNode.setValue(0);
2020-07-16 18:50:01 +00:00
pts.Controls.Flight.rudderTrim.setValue(0);
2019-10-27 20:54:00 +00:00
} else {
apOff("hard", 2);
}
}
},
ATHR: func() {
2020-11-28 17:33:44 +00:00
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (!fmgc.Output.athr.getBoolValue() and !pts.FMGC.CasCompare.casRejectAll.getBoolValue() and fbw.FBW.apOff == 0) {
fmgc.Input.athr.setValue(1);
2019-10-27 20:54:00 +00:00
} else {
athrOff("hard");
}
}
},
FD1: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (!fmgc.Output.fd1.getBoolValue()) {
2021-06-19 00:46:57 +00:00
fmgc.Input.fd1.setValue(1);
2019-10-27 20:54:00 +00:00
} else {
2021-06-19 00:46:57 +00:00
fmgc.Input.fd1.setValue(0);
2019-10-27 20:54:00 +00:00
}
}
},
FD2: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (!fmgc.Output.fd2.getBoolValue()) {
2021-06-19 00:46:57 +00:00
fmgc.Input.fd2.setValue(1);
2019-10-27 20:54:00 +00:00
} else {
2021-06-19 00:46:57 +00:00
fmgc.Input.fd2.setValue(0);
2019-10-27 20:54:00 +00:00
}
}
},
APDisc: func() {
2020-04-18 15:39:55 +00:00
# physical button sound - so put it outside here as you get a sound even if it doesn't work!
2021-06-09 16:20:19 +00:00
apDiscBtn.setValue(1);
2020-04-18 15:39:55 +00:00
settimer(func {
2021-06-09 16:20:19 +00:00
apDiscBtn.setValue(0);
2020-04-18 15:39:55 +00:00
}, 0.5);
2019-10-27 20:54:00 +00:00
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.ap1.getBoolValue() or fmgc.Output.ap2.getBoolValue()) {
2019-10-27 20:54:00 +00:00
apOff("soft", 0);
} else {
2021-06-09 16:20:19 +00:00
if (apOffSound[0].getValue() or apOffSound[1].getValue()) {
apOffSound[0].setValue(0);
apOffSound[1].setValue(0);
2019-10-27 20:54:00 +00:00
}
2021-06-09 16:20:19 +00:00
if (apWarningNode.getValue() != 0) {
apWarningNode.setValue(0);
2020-09-15 17:41:40 +00:00
ecam.lights[0].setValue(0);
2019-12-28 15:53:17 +00:00
}
2019-10-27 20:54:00 +00:00
}
}
},
ATDisc: func() {
2020-04-18 15:39:55 +00:00
# physical button sound - so put it outside here as you get a sound even if it doesn't work!
2021-06-09 16:20:19 +00:00
apDiscBtn.setValue(1);
2020-04-18 15:39:55 +00:00
settimer(func {
2021-06-09 16:20:19 +00:00
apDiscBtn.setValue(0);
2020-04-18 15:39:55 +00:00
}, 0.5);
2019-10-27 20:54:00 +00:00
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.athr.getBoolValue()) {
2019-10-27 20:54:00 +00:00
athrOff("soft");
2020-09-15 17:41:40 +00:00
ecam.lights[1].setValue(1);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
if (athrWarningNode.getValue() == 1) {
athrWarningNode.setValue(0);
2020-09-15 17:41:40 +00:00
ecam.lights[1].setValue(0);
2019-10-27 20:54:00 +00:00
}
}
}
},
IASMach: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Input.ktsMach.getBoolValue()) {
fmgc.Input.ktsMach.setBoolValue(0);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.ktsMach.setBoolValue(1);
2019-10-27 20:54:00 +00:00
}
}
},
SPDPush: func() {
if (me.FCUworking) {
2020-07-10 19:54:13 +00:00
if (fmgc.FMGCInternal.crzSet and fmgc.FMGCInternal.costIndexSet) {
2021-06-09 16:20:19 +00:00
fmgc.Custom.Input.spdManaged.setBoolValue(1);
2019-10-27 20:54:00 +00:00
fmgc.ManagedSPD.start();
}
}
},
2021-06-09 16:20:19 +00:00
ias: nil,
mach: nil,
2019-10-27 20:54:00 +00:00
SPDPull: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
fmgc.Custom.Input.spdManaged.setBoolValue(0);
2019-10-27 20:54:00 +00:00
fmgc.ManagedSPD.stop();
2021-06-09 16:20:19 +00:00
me.ias = fmgc.Velocities.indicatedAirspeedKt.getValue();
me.mach = fmgc.Velocities.indicatedMach.getValue();
if (!fmgc.Input.ktsMach.getBoolValue()) {
2021-06-16 12:36:36 +00:00
if (me.ias >= 100 and me.ias <= 399) {
2021-06-09 16:20:19 +00:00
fmgc.Input.kts.setValue(math.round(me.ias));
} else if (me.ias < 100) {
fmgc.Input.kts.setValue(100);
2021-06-16 12:36:36 +00:00
} else if (me.ias > 399) {
fmgc.Input.kts.setValue(399);
2019-10-27 20:54:00 +00:00
}
2021-06-09 16:20:19 +00:00
} else if (fmgc.Input.ktsMach.getBoolValue()) {
2021-06-16 12:36:36 +00:00
if (me.mach >= 0.10 and me.mach <= 0.99) {
2021-06-09 16:20:19 +00:00
fmgc.Input.mach.setValue(math.round(me.mach, 0.001));
2021-06-16 12:36:36 +00:00
} else if (me.mach < 0.10) {
fmgc.Input.mach.setValue(0.10);
} else if (me.mach > 0.99) {
fmgc.Input.mach.setValue(0.99);
2019-10-27 20:54:00 +00:00
}
}
}
},
2021-06-09 16:20:19 +00:00
machTemp: nil,
iasTemp: nil,
2019-10-27 20:54:00 +00:00
SPDAdjust: func(d) {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (!fmgc.Custom.Input.spdManaged.getBoolValue()) {
if (fmgc.Input.ktsMach.getBoolValue()) {
me.machTemp = fmgc.Input.mach.getValue();
2019-10-27 20:54:00 +00:00
if (d == 1) {
2021-06-09 16:20:19 +00:00
me.machTemp = math.round(me.machTemp + 0.001, 0.001); # Kill floating point error
2019-10-27 20:54:00 +00:00
} else if (d == -1) {
2021-06-09 16:20:19 +00:00
me.machTemp = math.round(me.machTemp - 0.001, 0.001); # Kill floating point error
2019-10-27 20:54:00 +00:00
} else if (d == 10) {
2021-06-09 16:20:19 +00:00
me.machTemp = math.round(me.machTemp + 0.01, 0.01); # Kill floating point error
2019-10-27 20:54:00 +00:00
} else if (d == -10) {
2021-06-09 16:20:19 +00:00
me.machTemp = math.round(me.machTemp - 0.01, 0.01); # Kill floating point error
2019-10-27 20:54:00 +00:00
}
2021-06-16 12:36:36 +00:00
if (me.machTemp < 0.10) {
fmgc.Input.mach.setValue(0.10);
} else if (me.machTemp > 0.99) {
fmgc.Input.mach.setValue(0.99);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.mach.setValue(me.machTemp);
2019-10-27 20:54:00 +00:00
}
} else {
2021-06-09 16:20:19 +00:00
me.iasTemp = fmgc.Input.kts.getValue();
2019-10-27 20:54:00 +00:00
if (d == 1) {
2021-06-09 16:20:19 +00:00
me.iasTemp = me.iasTemp + 1;
2019-10-27 20:54:00 +00:00
} else if (d == -1) {
2021-06-09 16:20:19 +00:00
me.iasTemp = me.iasTemp - 1;
2019-10-27 20:54:00 +00:00
} else if (d == 10) {
2021-06-09 16:20:19 +00:00
me.iasTemp = me.iasTemp + 10;
2019-10-27 20:54:00 +00:00
} else if (d == -10) {
2021-06-09 16:20:19 +00:00
me.iasTemp = me.iasTemp - 10;
2019-10-27 20:54:00 +00:00
}
2021-06-09 16:20:19 +00:00
if (me.iasTemp < 100) {
fmgc.Input.kts.setValue(100);
2021-06-16 12:36:36 +00:00
} else if (me.iasTemp > 399) {
fmgc.Input.kts.setValue(399);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.kts.setValue(me.iasTemp);
2019-10-27 20:54:00 +00:00
}
}
}
}
},
HDGPush: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.fd1.getBoolValue() or fmgc.Output.fd2.getBoolValue() or fmgc.Output.ap1.getBoolValue() or fmgc.Output.ap2.getBoolValue()) {
2022-01-19 11:04:37 +00:00
var wp = fmgc.flightPlanController.flightplans[2].getWP(fmgc.flightPlanController.currentToWptIndex.getValue() + 1);
if (wp != nil and wp.wp_type != "discontinuity") {
fmgc.Input.lat.setValue(1);
}
2019-10-27 20:54:00 +00:00
}
}
},
HDGPull: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.fd1.getBoolValue() or fmgc.Output.fd2.getBoolValue() or fmgc.Output.ap1.getBoolValue() or fmgc.Output.ap2.getBoolValue()) {
if (fmgc.Output.lat.getValue() == 0 or !fmgc.Custom.showHdg.getBoolValue()) {
fmgc.Input.lat.setValue(3);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.lat.setValue(0);
2019-10-27 20:54:00 +00:00
}
}
}
},
2021-06-09 16:20:19 +00:00
hdgTemp: nil,
2019-10-27 20:54:00 +00:00
HDGAdjust: func(d) {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.lat.getValue() != 0) {
2019-10-27 20:54:00 +00:00
hdgInput();
}
2021-06-09 16:20:19 +00:00
if (fmgc.Custom.showHdg.getBoolValue()) {
me.hdgTemp = fmgc.Input.hdg.getValue();
2019-10-27 20:54:00 +00:00
if (d == 1) {
2021-06-09 16:20:19 +00:00
me.hdgTemp = me.hdgTemp + 1;
2019-10-27 20:54:00 +00:00
} else if (d == -1) {
2021-06-09 16:20:19 +00:00
me.hdgTemp = me.hdgTemp - 1;
2019-10-27 20:54:00 +00:00
} else if (d == 10) {
2021-06-09 16:20:19 +00:00
me.hdgTemp = me.hdgTemp + 10;
2019-10-27 20:54:00 +00:00
} else if (d == -10) {
2021-06-09 16:20:19 +00:00
me.hdgTemp = me.hdgTemp - 10;
2019-10-27 20:54:00 +00:00
}
2021-06-09 16:20:19 +00:00
if (me.hdgTemp < 0.5) {
fmgc.Input.hdg.setValue(me.hdgTemp + 360);
} else if (me.hdgTemp >= 360.5) {
fmgc.Input.hdg.setValue(me.hdgTemp - 360);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.hdg.setValue(me.hdgTemp);
2019-10-27 20:54:00 +00:00
}
}
}
},
2021-06-09 16:20:19 +00:00
vertTemp: nil,
2019-10-27 20:54:00 +00:00
LOCButton: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
me.vertTemp = fmgc.Output.vert.getValue();
if ((fmgc.Output.locArm.getBoolValue() or fmgc.Output.lat.getValue() == 2) and !fmgc.Output.apprArm.getBoolValue() and me.vertTemp != 2 and me.vertTemp != 6) {
if (fmgc.Output.lat.getValue() == 2) {
fmgc.Input.lat.setValue(0);
2019-10-27 20:54:00 +00:00
} else {
fmgc.ITAF.disarmLOC();
}
2021-06-09 16:20:19 +00:00
if (me.vertTemp == 2 or me.vertTemp == 6) {
2019-10-27 20:54:00 +00:00
me.VSPull();
} else {
fmgc.ITAF.disarmGS();
}
} else {
2021-06-09 16:20:19 +00:00
if (pts.Position.gearAglFt.getValue() >= 400 and me.vertTemp != 7) {
fmgc.Input.lat.setValue(2);
if (me.vertTemp == 2 or me.vertTemp == 6) {
2020-07-16 00:05:41 +00:00
me.VSPull();
} else {
fmgc.ITAF.disarmGS();
}
2019-10-27 20:54:00 +00:00
}
}
}
},
TRKFPA: func() {
if (me.FCUworking) {
fmgc.ITAF.toggleTrkFpa();
}
},
ALTPush: func() {
if (me.FCUworking) {
2020-09-15 17:41:40 +00:00
# setprop("/it-autoflight/input/vert", 8); # He don't work yet m8
2019-10-27 20:54:00 +00:00
}
},
ALTPull: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
fmgc.Input.vert.setValue(4);
2019-10-27 20:54:00 +00:00
}
},
2021-06-09 16:20:19 +00:00
altTemp: nil,
2019-10-27 20:54:00 +00:00
ALTAdjust: func(d) {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
me.altTemp = fmgc.Input.alt.getValue();
2019-10-27 20:54:00 +00:00
if (d == 1) {
if (altSetMode.getBoolValue()) {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp + 1000;
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp + 100;
2019-10-27 20:54:00 +00:00
}
} else if (d == -1) {
if (altSetMode.getBoolValue()) {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp - 1000;
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp - 100;
2019-10-27 20:54:00 +00:00
}
} else if (d == 2) {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp + 100;
2019-10-27 20:54:00 +00:00
} else if (d == -2) {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp - 100;
2019-10-27 20:54:00 +00:00
} else if (d == 10) {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp + 1000;
2019-10-27 20:54:00 +00:00
} else if (d == -10) {
2021-06-09 16:20:19 +00:00
me.altTemp = me.altTemp - 1000;
2019-10-27 20:54:00 +00:00
}
2021-06-09 16:20:19 +00:00
if (me.altTemp < 100) {
fmgc.Input.alt.setValue(100);
} else if (me.altTemp > 49000) {
fmgc.Input.alt.setValue(49000);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.alt.setValue(me.altTemp);
2019-10-27 20:54:00 +00:00
}
}
},
VSPush: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Custom.trkFpa.getBoolValue()) {
fmgc.Input.vert.setValue(5);
fmgc.Input.fpa.setValue(0);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.vert.setValue(1);
fmgc.Input.vs.setValue(0);
2021-06-16 11:39:59 +00:00
fmgc.Custom.Output.vsFCU.setValue(left(sprintf("%+05.0f",0),3));
2019-10-27 20:54:00 +00:00
}
}
},
VSPull: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Custom.trkFpa.getBoolValue()) {
fmgc.Input.vert.setValue(5);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.vert.setValue(1);
2019-10-27 20:54:00 +00:00
}
}
},
2021-06-09 16:20:19 +00:00
vsTemp: nil,
fpaTemp: nil,
2019-10-27 20:54:00 +00:00
VSAdjust: func(d) {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.vert.getValue() == 1) {
me.vsTemp = fmgc.Input.vs.getValue();
2019-10-27 20:54:00 +00:00
if (d == 1) {
2021-06-09 16:20:19 +00:00
me.vsTemp = me.vsTemp + 100;
2019-10-27 20:54:00 +00:00
} else if (d == -1) {
2021-06-09 16:20:19 +00:00
me.vsTemp = me.vsTemp - 100;
2019-10-27 20:54:00 +00:00
} else if (d == 10) {
2021-06-09 16:20:19 +00:00
me.vsTemp = me.vsTemp + 1000;
2019-10-27 20:54:00 +00:00
} else if (d == -10) {
2021-06-09 16:20:19 +00:00
me.vsTemp = me.vsTemp - 1000;
2019-10-27 20:54:00 +00:00
}
2021-06-09 16:20:19 +00:00
if (me.vsTemp < -6000) {
fmgc.Input.vs.setValue(-6000);
} else if (me.vsTemp > 6000) {
fmgc.Input.vs.setValue(6000);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.vs.setValue(me.vsTemp);
2019-10-27 20:54:00 +00:00
}
2021-06-16 11:39:59 +00:00
fmgc.Custom.Output.vsFCU.setValue(left(sprintf("%+05.0f",fmgc.Input.vs.getValue()),3));
2021-06-09 16:20:19 +00:00
} else if (fmgc.Output.vert.getValue() == 5) {
me.fpaTemp = fmgc.Input.fpa.getValue();
2019-10-27 20:54:00 +00:00
if (d == 1) {
2021-06-09 16:20:19 +00:00
me.fpaTemp = math.round(me.fpaTemp + 0.1, 0.1);
2019-10-27 20:54:00 +00:00
} else if (d == -1) {
2021-06-09 16:20:19 +00:00
me.fpaTemp = math.round(me.fpaTemp - 0.1, 0.1);
2019-10-27 20:54:00 +00:00
} else if (d == 10) {
2021-06-09 16:20:19 +00:00
me.fpaTemp = me.fpaTemp + 1;
2019-10-27 20:54:00 +00:00
} else if (d == -10) {
2021-06-09 16:20:19 +00:00
me.fpaTemp = me.fpaTemp - 1;
2019-10-27 20:54:00 +00:00
}
2021-06-09 16:20:19 +00:00
if (me.fpaTemp < -9.9) {
fmgc.Input.fpa.setValue(-9.9);
} else if (me.fpaTemp > 9.9) {
fmgc.Input.fpa.setValue(9.9);
2019-10-27 20:54:00 +00:00
} else {
2021-06-09 16:20:19 +00:00
fmgc.Input.fpa.setValue(me.fpaTemp);
2019-10-27 20:54:00 +00:00
}
}
2021-06-09 16:20:19 +00:00
if ((fmgc.Output.vert.getValue() != 1 and !fmgc.Custom.trkFpa.getBoolValue()) or (fmgc.Output.vert.getValue() != 5 and fmgc.Custom.trkFpa.getBoolValue())) {
2019-10-27 20:54:00 +00:00
me.VSPull();
}
}
},
APPRButton: func() {
if (me.FCUworking) {
2021-06-09 16:20:19 +00:00
me.vertTemp = fmgc.Output.vert.getValue();
if ((fmgc.Output.locArm.getBoolValue() or fmgc.Output.lat.getValue() == 2) and (fmgc.Output.apprArm.getBoolValue() or me.vertTemp == 2 or me.vertTemp == 6)) {
if (fmgc.Output.lat.getValue() == 2) {
fmgc.Input.lat.setValue(0);
2019-10-27 20:54:00 +00:00
} else {
fmgc.ITAF.disarmLOC();
}
2021-06-09 16:20:19 +00:00
if (me.vertTemp == 2 or me.vertTemp == 6) {
2019-10-27 20:54:00 +00:00
me.VSPull();
} else {
fmgc.ITAF.disarmGS();
}
} else {
2021-06-09 16:20:19 +00:00
if (pts.Position.gearAglFt.getValue() >= 400 and me.vertTemp != 7) {
fmgc.Input.vert.setValue(2);
2020-07-16 11:32:26 +00:00
}
2019-10-27 20:54:00 +00:00
}
}
},
2021-08-04 16:17:35 +00:00
MetricAlt: func() {
if (me.FCUworking) {
2021-09-11 15:57:20 +00:00
canvas_pfd.A320PFD1.MainScreen.showMetricAlt = !canvas_pfd.A320PFD1.MainScreen.showMetricAlt;
canvas_pfd.A320PFD2.MainScreen.showMetricAlt = !canvas_pfd.A320PFD2.MainScreen.showMetricAlt;
2021-08-04 16:17:35 +00:00
}
},
2019-10-27 20:54:00 +00:00
};
2019-11-30 13:39:53 +00:00
# Master / slave principle of operation depending on the autopilot / flight director engagement
var updateActiveFMGC = func {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.ap1.getBoolValue()) {
2019-11-30 13:39:53 +00:00
FCUController.activeFMGC.setValue(1);
2021-06-09 16:20:19 +00:00
} elsif (fmgc.Output.ap2.getBoolValue()) {
2019-11-30 13:39:53 +00:00
FCUController.activeFMGC.setValue(2);
2021-06-09 16:20:19 +00:00
} elsif (fmgc.Output.fd1.getBoolValue()) {
2019-11-30 13:39:53 +00:00
FCUController.activeFMGC.setValue(1);
2021-06-09 16:20:19 +00:00
} elsif (fmgc.Output.fd2.getBoolValue()) {
2019-11-30 13:39:53 +00:00
FCUController.activeFMGC.setValue(2);
} else {
FCUController.activeFMGC.setValue(1);
}
}
2019-10-27 20:54:00 +00:00
# Autopilot Disconnection
var apOff = func(type, side) {
2021-06-09 16:20:19 +00:00
if ((fmgc.Input.ap1.getValue() and (side == 1 or side == 0)) or (fmgc.Input.ap2.getValue() and (side == 2 or side == 0))) {
2020-05-16 20:04:03 +00:00
ecam.doApWarn(type);
2020-01-02 21:13:18 +00:00
}
2019-10-27 20:54:00 +00:00
if (side == 0) {
2021-06-09 16:20:19 +00:00
fmgc.Input.ap1.setValue(0);
fmgc.Input.ap2.setValue(0);
2019-10-27 20:54:00 +00:00
} elsif (side == 1) {
2021-06-09 16:20:19 +00:00
fmgc.Input.ap1.setValue(0);
2019-10-27 20:54:00 +00:00
} elsif (side == 2) {
2021-06-09 16:20:19 +00:00
fmgc.Input.ap2.setValue(0);
2019-10-27 20:54:00 +00:00
}
2022-01-28 22:13:39 +00:00
var radarft = (side == 2) ? getprop("/instrumentation/radar-altimeter[1]/radar-altitude-ft-corrected") : getprop("/instrumentation/radar-altimeter[0]/radar-altitude-ft-corrected");
setprop("/instrumentation/pfd/logic/autoland/ap-disc-ft",radarft);
2019-10-27 20:54:00 +00:00
}
# Autothrust Disconnection
var athrOff = func(type) {
2021-06-09 16:20:19 +00:00
if (fmgc.Input.athr.getValue() == 1) {
2020-01-02 21:13:18 +00:00
if (type == "hard") {
fadec.lockThr();
}
2021-06-09 16:20:19 +00:00
fmgc.Input.athr.setValue(0);
2020-05-16 20:04:03 +00:00
ecam.doAthrWarn(type);
2019-10-27 20:54:00 +00:00
}
}
# If the heading knob is turned while in nav mode, it will display heading for a period of time
var hdgInput = func {
2021-06-09 16:20:19 +00:00
if (fmgc.Output.lat.getValue() != 0) {
fmgc.Custom.showHdg.setBoolValue(1);
2020-09-27 18:00:46 +00:00
fmgc.Custom.hdgTime.setValue(pts.Sim.Time.elapsedSec.getValue());
2019-10-27 20:54:00 +00:00
}
2020-04-27 13:58:38 +00:00
}