72
edits
mNo edit summary |
No edit summary |
||
| Line 112: | Line 112: | ||
=== Functions === | === Functions === | ||
First, create a number of functions to format and print messages | 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> | |||
{{tip|You might want to replace copilot_say().}} | |||
} | |||
=== | === 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 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 | 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"> | ||
# 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 init_announcers = func { | var init_announcers = func { | ||
setlistener("/gear/on-ground", func (node) { | setlistener("/gear/on-ground", func (node) { | ||
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.}} | ||
== Configuring the announcers == | == Configuring the announcers == | ||
edits