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 35ddbf0426
commit f025bb82f9
3 changed files with 32 additions and 21 deletions

View file

@ -947,35 +947,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 {
if (Input.ktsMach.getBoolValue()) {
@ -990,7 +990,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();
@ -998,6 +998,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);
@ -1011,7 +1012,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())) {
@ -1019,19 +1020,19 @@ setlistener("/it-autoflight/input/vert", func {
} else {
ITAF.setVertMode(9);
}
});
}, 0, 0);
setlistener("/sim/signals/fdm-initialized", func {
ITAF.init();
});
# For Canvas Nav Display.
setlistener("/it-autoflight/input/hdg", func {
setprop("/autopilot/settings/heading-bug-deg", Input.hdg.getValue());
}, 0, 0);
setlistener("/it-autoflight/internal/alt", func {
setprop("/autopilot/settings/target-altitude-ft", Internal.alt.getValue());
# For Canvas Nav Display.
setlistener("/it-autoflight/input/hdg", func() {
pts.Autopilot.Settings.headingBugDeg.setValue(Input.hdg.getValue());
}, 0, 0);
setlistener("/it-autoflight/internal/alt", func() {
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);
@ -279,9 +281,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}));
}
@ -310,7 +312,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
};
@ -674,8 +676,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"),
};