Runway Awareness and Advisory System: Difference between revisions

Jump to navigation Jump to search
no edit summary
mNo edit summary
No edit summary
Line 112: Line 112:
=== Functions ===
=== Functions ===


First, create a number of functions to format and print messages, and to execute certain actions when some signals are emitted:
First, create a number of functions to format and print messages:


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
Line 148: Line 148:
     return sprintf("%%d %s remaining", landing_config.distances_unit);
     return sprintf("%%d %s remaining", landing_config.distances_unit);
};
};
</syntaxhighlight>


var stop_announcer = func {
{{tip|You might want to replace copilot_say().}}
    landing_announcer.stop();
    logger.warn("Stopping landing announcer");
 
    takeoff_announcer.set_mode("taxi-and-takeoff");
    logger.warn(sprintf("Takeoff mode: %s", takeoff_announcer.mode));
};
 
var switch_to_takeoff = func {
    # Switch to takeoff mode so that the "approaching-runway" signal
    # is not emitted for any runways that are crossed during takeoff
    if (takeoff_announcer.mode == "taxi-and-takeoff") {
        takeoff_announcer.set_mode("takeoff");
        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));
    }
};
</syntaxhighlight>


=== Connecting signals ===
=== Announcers ===


Second, create configuration objects, override some of their parameters, and then connect the various signals to callbacks:
Second, create configuration objects, override some of their parameters, create the announcers, and then connect the various signals to callbacks:


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
Line 188: Line 169:
# nose of the aircraft comes within 120 meters of the runway
# nose of the aircraft comes within 120 meters of the runway
takeoff_config.distance_edge_max_m = 150;
takeoff_config.distance_edge_max_m = 150;
var takeoff_announcer = runway.TakeoffRunwayAnnounceClass.new(takeoff_config);
takeoff_announcer.connect("on-runway", runway.make_betty_cb(copilot_say, "On runway %s", 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", runway.make_betty_cb(copilot_say, "Approaching runway %s"));
takeoff_announcer.connect("approaching-short-runway", runway.make_betty_cb(copilot_say, approaching_short_runway_format));


var landing_config = { parents: [runway.LandingRunwayAnnounceConfig] };
var landing_config = { parents: [runway.LandingRunwayAnnounceConfig] };
Line 201: Line 176:
landing_config.distances_unit = "meter";
landing_config.distances_unit = "meter";


# Create announcers
var takeoff_announcer = runway.TakeoffRunwayAnnounceClass.new(takeoff_config);
var landing_announcer = runway.LandingRunwayAnnounceClass.new(landing_config);
var landing_announcer = runway.LandingRunwayAnnounceClass.new(landing_config);
var stop_announcer    = runway.make_stop_announcer_func(takeoff_announcer, landing_announcer);
var switch_to_takeoff = runway.make_switch_to_takeoff_func(takeoff_announcer, landing_announcer);
takeoff_announcer.connect("on-runway", runway.make_betty_cb(copilot_say, "On runway %s", 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", runway.make_betty_cb(copilot_say, "Approaching runway %s"));
takeoff_announcer.connect("approaching-short-runway", runway.make_betty_cb(copilot_say, approaching_short_runway_format));
landing_announcer.connect("remaining-distance", runway.make_betty_cb(copilot_say, remaining_distance_format));
landing_announcer.connect("remaining-distance", runway.make_betty_cb(copilot_say, remaining_distance_format));
landing_announcer.connect("vacated-runway", runway.make_betty_cb(copilot_say, "Vacated runway %s", stop_announcer));
landing_announcer.connect("vacated-runway", runway.make_betty_cb(copilot_say, "Vacated runway %s", stop_announcer));
Line 210: Line 196:
=== Listeners ===
=== Listeners ===


Finally, set up a listener to detect when the aircraft is on the ground and when it is airborne. Depending on this conditions, you need to start, stop, or change the modes of the announcers:
Finally, set up a listener to detect when the aircraft is on the ground and when it is airborne:


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
var have_been_in_air = 0;
# Depending on whether the aircraft is on the ground or not, it will start, stop, or change the modes of the announcers
 
var set_on_ground = runway.make_set_ground_func(takeoff_announcer, landing_announcer);
var test_on_ground = func (on_ground) {
    if (on_ground) {
        takeoff_announcer.start();
        logger.warn("Starting takeoff announce");
 
        if (have_been_in_air == 1) {
            have_been_in_air = 0;
 
            takeoff_announcer.set_mode("");
 
            landing_announcer.set_mode("landing");
            landing_announcer.start();
            logger.warn(sprintf("Starting landing (%s) announcer", landing_announcer.mode));
        }
        else {
            takeoff_announcer.set_mode("taxi-and-takeoff");
            logger.warn(sprintf("Takeoff mode: %s", takeoff_announcer.mode));
        }
        takeoff_announcer.start();
        logger.warn(sprintf("Starting takeoff (%s) announcer", takeoff_announcer.mode));
    }
    else {
        takeoff_announcer.set_mode("approach");
        logger.warn(sprintf("Takeoff mode: %s", takeoff_announcer.mode));
 
        landing_announcer.stop();
        logger.warn("Stopping landing announcer");
 
        if (have_been_in_air == 0) {
            have_been_in_air = 1;
        }
    }
};


var init_announcers = func {
var init_announcers = func {
     setlistener("/gear/on-ground", func (node) {
     setlistener("/gear/on-ground", func (node) {
         test_on_ground(node.getBoolValue());
         set_on_ground(node.getBoolValue());
     }, startup=1, runtime=0);
     }, startup=1, runtime=0);
};
};
Line 265: Line 218:


{{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.}}
{{tip|You might want to replace copilot_say().}}


== Configuring the announcers ==
== Configuring the announcers ==
72

edits

Navigation menu