Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
Updated project
Browse files Browse the repository at this point in the history
  • Loading branch information
David committed Jun 20, 2018
1 parent fb5d7ea commit 328f7bb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
23 changes: 11 additions & 12 deletions X-Plane Voice Control/Commands/TaxiLights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,35 @@ namespace X_Plane_Voice_Control.Commands
{
class TaxiLights : ControlTemplate
{
private readonly string[] _brakeOnStrings = { "taxi lights on", "taxi lights down a notch" };
private readonly string[] _brakeOffStrings = { "taxi lights off", "taxi lighs up a notch" };
private readonly string[] _taxiLightsOnStrings = { "taxi lights on" };
private readonly string[] _taxiLightsOffStrings = { "taxi lights off" };

public TaxiLights(ExtPlaneInterface interface_, SpeechSynthesizer synthesizer) : base(interface_, synthesizer)
{
var brakeGrammar = new GrammarBuilder();
brakeGrammar.Append("please", 0, 1);
brakeGrammar.Append("set", 0, 1);
brakeGrammar.Append(new Choices(_brakeOnStrings.Concat(_brakeOffStrings).ToArray()));
brakeGrammar.Append(new Choices(_taxiLightsOnStrings.Concat(_taxiLightsOffStrings).ToArray()));
brakeGrammar.Append("please", 0, 1);
Grammar = new Grammar(brakeGrammar);
XPlaneInterface.Subscribe<double>("laminar/B738/annunciator/parking_brake");
XPlaneInterface.Subscribe<double>("laminar/B738/toggle_switch/taxi_light_brightness_pos");
}

public sealed override Grammar Grammar { get; }

public override void OnTrigger(RecognitionResult rResult, string phrase)
{
var value = XPlaneInterface.GetDataRef<double>("laminar/B738/annunciator/parking_brake").Value;
if (_brakeOnStrings.Contains(phrase) && value == 0d)
var value = XPlaneInterface.GetDataRef<double>("laminar/B738/toggle_switch/taxi_light_brightness_pos").Value;
if (phrase.Contains("on") && value != 2)
{
XPlaneInterface.SetExecutingCommand("sim/flight_controls/brakes_toggle_max");
SpeechSynthesizer.SpeakAsync("Parking brake set.");
XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/taxi_light_brigh_toggle");
SpeechSynthesizer.SpeakAsync("Taxi lights on");
}
else if (_brakeOffStrings.Contains(phrase) && value == 1d)
else if (phrase.Contains("off") && value != 0)
{
XPlaneInterface.SetExecutingCommand("sim/flight_controls/brakes_toggle_max");
SpeechSynthesizer.SpeakAsync("Parking brake released.");
XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/taxi_light_brigh_toggle");
SpeechSynthesizer.SpeakAsync("Taxi lights off");
}

}
}
}
13 changes: 7 additions & 6 deletions X-Plane Voice Control/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions X-Plane Voice Control/X-Plane Voice Control.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<ItemGroup>
<Compile Include="Commands\ComSwapControl.cs" />
<Compile Include="Commands\FlapControl.cs" />
<Compile Include="Commands\LandingLights.cs" />
<Compile Include="Commands\TaxiLights.cs" />
<Compile Include="Commands\GearControl.cs" />
<Compile Include="Commands\ControlTemplate.cs" />
Expand Down

0 comments on commit 328f7bb

Please sign in to comment.