1
0
Fork 0

FMGC: improve Nasal code quality

This commit is contained in:
legoboyvdlp R 2021-06-10 16:38:16 +01:00
parent 1827042f10
commit 6c138c4a10
3 changed files with 28 additions and 17 deletions

View file

@ -952,35 +952,35 @@ setlistener("/it-autoflight/input/ap1", func() {
if (Input.ap1Temp != Output.ap1.getBoolValue()) {
ITAF.ap1Master(Input.ap1Temp);
}
});
}, 0, 0);
setlistener("/it-autoflight/input/ap2", func() {
Input.ap2Temp = Input.ap2.getBoolValue();
if (Input.ap2Temp != Output.ap2.getBoolValue()) {
ITAF.ap2Master(Input.ap2Temp);
}
});
}, 0, 0);
setlistener("/it-autoflight/input/athr", func() {
Input.athrTemp = Input.athr.getBoolValue();
if (Input.athrTemp != Output.athr.getBoolValue()) {
ITAF.athrMaster(Input.athrTemp);
}
});
}, 0, 0);
setlistener("/it-autoflight/input/fd1", func() {
Input.fd1Temp = Input.fd1.getBoolValue();
if (Input.fd1Temp != Output.fd1.getBoolValue()) {
ITAF.fd1Master(Input.fd1Temp);
}
});
}, 0, 0);
setlistener("/it-autoflight/input/fd2", func() {
Input.fd2Temp = Input.fd2.getBoolValue();
if (Input.fd2Temp != Output.fd2.getBoolValue()) {
ITAF.fd2Master(Input.fd2Temp);
}
});
}, 0, 0);
setlistener("/it-autoflight/input/kts-mach", func() {
@ -1002,7 +1002,7 @@ setlistener("/it-autoflight/input/toga", func() {
ITAF.takeoffGoAround();
Input.toga.setBoolValue(0);
}
});
}, 0, 0);
setlistener("/it-autoflight/input/lat", func() {
Input.latTemp = Input.lat.getValue();
@ -1010,6 +1010,7 @@ setlistener("/it-autoflight/input/lat", func() {
Output.ap2Temp = Output.ap2.getBoolValue();
Output.fd1Temp = Output.fd1.getBoolValue();
Output.fd2Temp = Output.fd2.getBoolValue();
if (!Gear.wow1.getBoolValue() and !Gear.wow2.getBoolValue()) {
if (Output.ap1Temp or Output.ap2Temp or Output.fd1Temp or Output.fd2Temp) {
ITAF.setLatMode(Input.latTemp);
@ -1023,7 +1024,7 @@ setlistener("/it-autoflight/input/lat", func() {
ITAF.setLatArm(0);
}
}
});
}, 0, 0);
setlistener("/it-autoflight/input/vert", func() {
if (!Gear.wow1.getBoolValue() and !Gear.wow2.getBoolValue() and (Output.ap1.getBoolValue() or Output.ap2.getBoolValue() or Output.fd1.getBoolValue() or Output.fd2.getBoolValue())) {
@ -1031,19 +1032,19 @@ setlistener("/it-autoflight/input/vert", func() {
} else {
ITAF.setVertMode(9);
}
});
}, 0, 0);
setlistener("/sim/signals/fdm-initialized", func() {
ITAF.init();
});
}, 0, 0);
# For Canvas Nav Display.
setlistener("/it-autoflight/input/hdg", func() {
setprop("/autopilot/settings/heading-bug-deg", Input.hdg.getValue());
pts.Autopilot.Settings.headingBugDeg.setValue(Input.hdg.getValue());
}, 0, 0);
setlistener("/it-autoflight/internal/alt", func() {
setprop("/autopilot/settings/target-altitude-ft", Internal.alt.getValue());
pts.Autopilot.Settings.targetAltitudeFt.setValue(Internal.alt.getValue());
}, 0, 0);
var loopTimer = maketimer(0.1, ITAF, ITAF.loop);

View file

@ -63,6 +63,8 @@ var crzFl = 0;
var windHdg = 0;
var windSpeed = 0;
var windsDidChange = 0;
var tempOverspeed = nil;
setprop("position/gear-agl-ft", 0);
setprop("/it-autoflight/settings/accel-agl-ft", 1500); #eventually set to 1500 above runway
setprop("/it-autoflight/internal/vert-speed-fpm", 0);
@ -275,9 +277,9 @@ var trimReset = func {
###############
var updateARPT = func {
setprop("autopilot/route-manager/departure/airport", FMGCInternal.depApt);
setprop("autopilot/route-manager/destination/airport", FMGCInternal.arrApt);
setprop("autopilot/route-manager/alternate/airport", FMGCInternal.altAirport);
setprop("/autopilot/route-manager/departure/airport", FMGCInternal.depApt);
setprop("/autopilot/route-manager/destination/airport", FMGCInternal.arrApt);
setprop("/autopilot/route-manager/alternate/airport", FMGCInternal.altAirport);
if (getprop("/autopilot/route-manager/active") != 1) {
fgcommand("activate-flightplan", props.Node.new({"activate": 1}));
}
@ -306,7 +308,7 @@ var updateArptLatLon = func {
}
updateRouteManagerAlt = func() {
setprop("autopilot/route-manager/cruise/altitude-ft", FMGCInternal.crzFt);
setprop("/autopilot/route-manager/cruise/altitude-ft", FMGCInternal.crzFt);
# TODO - update FMGCInternal.phase when DES to re-enter in CLIMB/CRUIZE
};
@ -670,8 +672,9 @@ var masterFMGC = maketimer(0.2, func {
FMGCInternal.phase = 2;
}
if (getprop("/systems/navigation/adr/computation/overspeed-vfe-spd") != 1024) {
FMGCInternal.maxspeed = getprop("/systems/navigation/adr/computation/overspeed-vfe-spd") - 4;
tempOverspeed = systems.ADIRS.overspeedVFE.getValue();
if (tempOverspeed != 1024) {
FMGCInternal.maxspeed = tempOverspeed - 4;
} elsif (pts.Gear.position[0].getValue() != 0 or pts.Gear.position[1].getValue() != 0 or pts.Gear.position[2].getValue() != 0) {
FMGCInternal.maxspeed = 284;
} else {

View file

@ -4,6 +4,13 @@
# Anything that says Temp is set by another file to avoid multiple getValue calls
# Usage Example: pts.Class.SubClass.node.getValue()
var Autopilot = {
Settings: {
headingBugDeg: props.globals.getNode("/autopilot/settings/heading-bug-deg",1),
targetAltitudeFt: props.globals.getNode("/autopilot/settings/target-altitude-ft",1),
},
};
var Accelerations = {
pilotGDamped: props.globals.getNode("/accelerations/pilot-gdamped"),
};