Runway Awareness and Advisory System: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 15: Line 15:
The Runway Advisory and Awareness System can give a number of advisories:
The Runway Advisory and Awareness System can give a number of advisories:


* Advisory when approaching a runway while taxiing
* Advisory when approaching a runway while taxiing if groundspeed is less than 40 knots


* Advisory when the aircraft is on the runway and aligned within 20 degrees with runway
* Advisory when the aircraft is on the runway and aligned within 20 degrees with runway
Line 121: Line 121:
var copilot_say = func (message) {
var copilot_say = func (message) {
     setprop("/sim/messages/copilot", message);
     setprop("/sim/messages/copilot", message);
};
     logger.info(sprintf("Announcing '%s'", message));
 
var make_notification_cb = func (format, action=nil) {
     return func (data=nil) {
        if (format != nil) {
            if (typeof(format) == "func") {
                var message_format = format();
            }
            else {
                var message_format = format;
            }
 
            if (data != nil) {
                var message = sprintf(message_format, data.getValue());
            }
            else {
                var message = message_format;
            }
 
            copilot_say(message);
            logger.info(sprintf("Announcing '%s'", message));
        }
 
        if (typeof(action) == "func") {
            action();
        }
    };
};
};


Line 161: Line 135:
var stop_announcer = func {
var stop_announcer = func {
     landing_announcer.stop();
     landing_announcer.stop();
     logger.warn("Stopping landing announce");
     logger.warn("Stopping landing announcer");


     takeoff_announcer.set_mode("taxi-and-takeoff");
     takeoff_announcer.set_mode("taxi-and-takeoff");
Line 173: Line 147:
         takeoff_announcer.set_mode("takeoff");
         takeoff_announcer.set_mode("takeoff");
         logger.warn(sprintf("Takeoff mode: %s", takeoff_announcer.mode));
         logger.warn(sprintf("Takeoff mode: %s", takeoff_announcer.mode));
        landing_announcer.set_mode("takeoff");
        landing_announcer.start();
        logger.warn(sprintf("Starting landing (%s) announcer", landing_announcer.mode));
     }
     }
};
};
Line 186: Line 164:


# Let the announcer emit the "approaching-runway" signal if the
# Let the announcer emit the "approaching-runway" signal if the
# aircraft comes within 200 meters of the runway
# nose of the aircraft comes within 120 meters of the runway
takeoff_config.distance_edge_max_m = 200;
takeoff_config.distance_edge_max_m = 150;


var takeoff_announcer = runway.TakeoffRunwayAnnounceClass.new(takeoff_config);
var takeoff_announcer = runway.TakeoffRunwayAnnounceClass.new(takeoff_config);
takeoff_announcer.connect("on-runway", make_notification_cb("On runway %s", switch_to_takeoff));
takeoff_announcer.connect("on-runway", runway.make_betty_cb(copilot_say, "On runway %s", switch_to_takeoff));
takeoff_announcer.connect("on-short-runway", make_notification_cb(on_short_runway_format, switch_to_takeoff));
takeoff_announcer.connect("on-short-runway", runway.make_betty_cb(copilot_say, on_short_runway_format, switch_to_takeoff));
takeoff_announcer.connect("approaching-runway", make_notification_cb("Approaching runway %s"));
takeoff_announcer.connect("approaching-runway", runway.make_betty_cb(copilot_say, "Approaching runway %s"));


var landing_config = { parents: [runway.LandingRunwayAnnounceConfig] };
var landing_config = { parents: [runway.LandingRunwayAnnounceConfig] };
Line 201: Line 179:


var landing_announcer = runway.LandingRunwayAnnounceClass.new(landing_config);
var landing_announcer = runway.LandingRunwayAnnounceClass.new(landing_config);
landing_announcer.connect("remaining-distance", make_notification_cb(remaining_distance_format));
landing_announcer.connect("remaining-distance", runway.make_betty_cb(copilot_say, remaining_distance_format));
landing_announcer.connect("vacated-runway", make_notification_cb("Vacated runway %s", stop_announcer));
landing_announcer.connect("vacated-runway", runway.make_betty_cb(copilot_say, "Vacated runway %s", stop_announcer));
landing_announcer.connect("landed-runway", make_notification_cb("Touchdown on runway %s"));
landing_announcer.connect("landed-runway", runway.make_betty_cb(copilot_say, "Touchdown on runway %s"));
landing_announcer.connect("landed-outside-runway", make_notification_cb(nil, stop_announcer));
landing_announcer.connect("landed-outside-runway", runway.make_betty_cb(nil, nil, stop_announcer));
 
var make_switch_mode_cb = func (wow_mode, no_wow_mode) {
    return func (node) {
        if (node.getBoolValue()) {
            if (getprop("/gear/gear[1]/wow") and getprop("/gear/gear[2]/wow")) {
                takeoff_announcer.set_mode(wow_mode);
            }
            else {
                takeoff_announcer.set_mode(no_wow_mode);
            }
        }
        else {
            takeoff_announcer.set_mode("");
        }
        logger.warn(sprintf("Takeoff mode: %s", takeoff_announcer.mode));
    };
};
 
setlistener("/controls/lighting/nav-lights",
  make_switch_mode_cb("taxi-and-takeoff", "taxi"),
  startup=1, runtime=0);


var have_been_in_air = 0;
var have_been_in_air = 0;
Line 239: Line 196:
             takeoff_announcer.set_mode("");
             takeoff_announcer.set_mode("");


            landing_announcer.set_mode("landing");
             landing_announcer.start();
             landing_announcer.start();
             landing_announcer.set_mode("landing");
             logger.warn(sprintf("Starting landing (%s) announcer", landing_announcer.mode));
             logger.warn("Starting landing announce");
        }
        else {
             takeoff_announcer.set_mode("taxi-and-takeoff");
         }
         }
        takeoff_announcer.start();
        logger.warn(sprintf("Starting takeoff (%s) announcer", takeoff_announcer.mode));
     }
     }
     else {
     else {
         takeoff_announcer.stop();
         takeoff_announcer.stop();
         logger.warn("Stopping takeoff announce");
         logger.warn("Stopping takeoff announcer");


         landing_announcer.stop();
         landing_announcer.stop();
         logger.warn("Stopping landing announce");
         logger.warn("Stopping landing announcer");


         if (have_been_in_air == 0) {
         if (have_been_in_air == 0) {
Line 258: Line 220:


var init_announcers = func {
var init_announcers = func {
     setlistener("/gear/gear[1]/wow", func (n) {
     setlistener("/gear/on-ground", func (node) {
         test_on_ground(getprop("/gear/gear[1]/wow") and getprop("/gear/gear[2]/wow"));
         test_on_ground(node.getBoolValue());
    }, startup=1, runtime=0);
 
    setlistener("/gear/gear[2]/wow", func (n) {
        test_on_ground(getprop("/gear/gear[1]/wow") and getprop("/gear/gear[2]/wow"));
     }, startup=1, runtime=0);
     }, startup=1, runtime=0);
};
};


setlistener("/sim/signals/fdm-initialized", func {
setlistener("/sim/signals/fdm-initialized", func {
    logger.warn("FDM initialized");
     var timer = maketimer(5.0, func init_announcers());
     var timer = maketimer(5.0, func init_announcers());
     timer.singleShot = 1;
     timer.singleShot = 1;
Line 276: Line 232:
</syntaxhighlight>
</syntaxhighlight>


{{Note|In this case gear[1] and gear[2] are used to detect whether the aircraft is on the ground or in the air. You may want to modify this for your aircraft.}}
{{Note|In this example the /gear/on-ground property is used to detect whether the aircraft is on the ground or in the air. Make sure to use a <logic> element in a <autopilot> XML file to set this to true or false depending on your gears' wow values.}}


{{Note|It is your responsibility to start and stop the announcers and to set the correct modes. Therefore it is necessary to connect to signals like landed-outside-runway and vacated-runway, even if they appear to be useless for your specific aircraft. The example of runway.nas above already does this for you.}}
{{Note|It is your responsibility to start and stop the announcers and to set the correct modes. Therefore it is necessary to connect to signals like landed-outside-runway and vacated-runway, even if they appear to be useless for your specific aircraft. The example of runway.nas above already does this for you.}}
Line 317: Line 273:
# The unit to use for the remaining distance of short runways. Can
# The unit to use for the remaining distance of short runways. Can
# be "meter" or "feet".
# be "meter" or "feet".
groundspeed_max_kt: 40,
# Maximum groundspeed in knots for approaching runway callouts
</syntaxhighlight>
</syntaxhighlight>


72

edits

Navigation menu