2006-01-06 09:47:58 +00:00
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# Nasal script to print errors to the screen when aircraft exceed design limits:
|
2006-02-15 22:53:23 +00:00
|
|
|
# - extending flaps above maximum flap extension speed(s)
|
2006-01-06 09:47:58 +00:00
|
|
|
# - extending gear above maximum gear extension speed
|
|
|
|
# - exceeding Vna
|
|
|
|
# - exceeding structural G limits
|
|
|
|
#
|
2006-02-15 22:53:23 +00:00
|
|
|
# To use, include this .nas file and define one or more of
|
|
|
|
# limits/max-flap-extension-speed/speed
|
|
|
|
# limits/max-flap-extension-speed/flaps
|
2006-01-06 09:47:58 +00:00
|
|
|
# limits/vne
|
|
|
|
# limits/max-gear-extension-speed
|
|
|
|
# limits/max-positive-g
|
|
|
|
# limits/max-negative-g (must be defined in max-positive-g defined)
|
|
|
|
#
|
2007-02-04 12:55:28 +00:00
|
|
|
# You can define multiple max-flap-extension-speed entries for max extension
|
2006-02-15 22:53:23 +00:00
|
|
|
# speeds for different flap settings.
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var checkFlaps = func(n) {
|
|
|
|
var flapsetting = n.getValue();
|
2007-06-13 20:49:11 +00:00
|
|
|
if (flapsetting == 0)
|
|
|
|
return;
|
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var airspeed = getprop("velocities/airspeed-kt");
|
|
|
|
var ltext = "";
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var limits = props.globals.getNode("limits");
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
if ((limits != nil) and (limits.getChildren("max-flap-extension-speed") != nil))
|
|
|
|
{
|
2008-10-12 18:50:06 +00:00
|
|
|
var children = limits.getChildren("max-flap-extension-speed");
|
2012-01-17 20:00:52 +00:00
|
|
|
foreach(var c; children)
|
2006-02-15 22:53:23 +00:00
|
|
|
{
|
|
|
|
if ((c.getChild("flaps") != nil) and
|
|
|
|
(c.getChild("speed") != nil) )
|
|
|
|
{
|
2008-10-12 18:50:06 +00:00
|
|
|
var flaps = c.getChild("flaps").getValue();
|
|
|
|
var speed = c.getChild("speed").getValue();
|
2006-02-15 22:53:23 +00:00
|
|
|
|
|
|
|
if ((flaps != nil) and
|
|
|
|
(speed != nil) and
|
|
|
|
(flapsetting > flaps) and
|
|
|
|
(airspeed > speed) )
|
|
|
|
{
|
|
|
|
ltext = "Flaps extended above maximum flap extension speed!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
if (ltext != "")
|
|
|
|
{
|
|
|
|
screen.log.write(ltext);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-01-06 09:47:58 +00:00
|
|
|
|
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var checkGear = func(n) {
|
|
|
|
if (!n.getValue())
|
2007-06-13 20:49:11 +00:00
|
|
|
return;
|
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var airspeed = getprop("velocities/airspeed-kt");
|
|
|
|
var max_gear = getprop("limits/max-gear-extension-speed");
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
if ((max_gear != nil) and (airspeed > max_gear))
|
|
|
|
{
|
|
|
|
screen.log.write("Gear extended above maximum extension speed!");
|
|
|
|
}
|
|
|
|
}
|
2006-01-06 09:47:58 +00:00
|
|
|
|
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
# Set the listeners
|
|
|
|
setlistener("controls/flight/flaps", checkFlaps);
|
|
|
|
setlistener("controls/gear/gear-down", checkGear);
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
# =============================== Pilot G stuff (taken from hurricane.nas) =================================
|
2008-10-12 18:50:06 +00:00
|
|
|
var pilot_g = props.globals.getNode("fdm/jsbsim/accelerations/a-pilot-z-ft_sec2", 1);
|
2006-01-06 09:47:58 +00:00
|
|
|
pilot_g.setDoubleValue(0);
|
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
var g_damp = 0;
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var updatePilotG = func {
|
2006-02-15 22:53:23 +00:00
|
|
|
var g = pilot_g.getValue() ;
|
|
|
|
#if (g == nil) { g = 0; }
|
|
|
|
g_damp = ( g * 0.2) + (g_damp * 0.8);
|
2006-01-06 09:47:58 +00:00
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
settimer(updatePilotG, 0.2);
|
|
|
|
}
|
2006-01-06 09:47:58 +00:00
|
|
|
|
|
|
|
updatePilotG();
|
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var checkGandVNE = func {
|
2007-06-13 20:49:11 +00:00
|
|
|
if (getprop("/sim/freeze/replay-state"))
|
|
|
|
return;
|
|
|
|
|
2008-10-12 18:50:06 +00:00
|
|
|
var max_positive = getprop("limits/max-positive-g");
|
|
|
|
var max_negative = getprop("limits/max-negative-g");
|
|
|
|
var msg = "";
|
2006-02-15 22:53:23 +00:00
|
|
|
|
|
|
|
# Convert the ft/sec^2 into Gs - allowing for gravity.
|
2008-10-12 18:50:06 +00:00
|
|
|
var g = (- g_damp) / 32;
|
2006-02-15 22:53:23 +00:00
|
|
|
|
|
|
|
if ((max_positive != nil) and (g > max_positive))
|
|
|
|
{
|
|
|
|
msg = "Airframe structural positive-g load limit exceeded!";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((max_negative != nil) and (g < max_negative))
|
|
|
|
{
|
|
|
|
msg = "Airframe structural negative-g load limit exceeded!";
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now check VNE
|
2008-10-12 18:50:06 +00:00
|
|
|
var airspeed = getprop("velocities/airspeed-kt");
|
|
|
|
var vne = getprop("limits/vne");
|
2006-02-15 22:53:23 +00:00
|
|
|
|
|
|
|
if ((airspeed != nil) and (vne != nil) and (airspeed > vne))
|
|
|
|
{
|
|
|
|
msg = "Airspeed exceeds Vne!";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg != "")
|
|
|
|
{
|
|
|
|
# If we have a message, display it, but don't bother checking for
|
|
|
|
# any other errors for 10 seconds. Otherwise we're likely to get
|
|
|
|
# repeated messages.
|
|
|
|
screen.log.write(msg);
|
|
|
|
settimer(checkGandVNE, 10);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
settimer(checkGandVNE, 1);
|
|
|
|
}
|
2006-01-06 09:47:58 +00:00
|
|
|
}
|
|
|
|
|
2006-02-15 22:53:23 +00:00
|
|
|
checkGandVNE();
|