From 328f7bb4fc6b7da839cb35b32f70cbb373b6a88c Mon Sep 17 00:00:00 2001 From: David Date: Wed, 20 Jun 2018 17:11:10 +0200 Subject: [PATCH] Updated project --- X-Plane Voice Control/Commands/TaxiLights.cs | 23 +++++++++---------- X-Plane Voice Control/MainForm.Designer.cs | 13 ++++++----- .../X-Plane Voice Control.csproj | 1 + 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/X-Plane Voice Control/Commands/TaxiLights.cs b/X-Plane Voice Control/Commands/TaxiLights.cs index 46e2da2..2fcd616 100644 --- a/X-Plane Voice Control/Commands/TaxiLights.cs +++ b/X-Plane Voice Control/Commands/TaxiLights.cs @@ -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("laminar/B738/annunciator/parking_brake"); + XPlaneInterface.Subscribe("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("laminar/B738/annunciator/parking_brake").Value; - if (_brakeOnStrings.Contains(phrase) && value == 0d) + var value = XPlaneInterface.GetDataRef("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"); } - } } } diff --git a/X-Plane Voice Control/MainForm.Designer.cs b/X-Plane Voice Control/MainForm.Designer.cs index c697f8a..4cc40b4 100644 --- a/X-Plane Voice Control/MainForm.Designer.cs +++ b/X-Plane Voice Control/MainForm.Designer.cs @@ -34,10 +34,12 @@ private void InitializeComponent() // // buttonListen // - this.buttonListen.Location = new System.Drawing.Point(16, 15); + this.buttonListen.AutoSize = true; + this.buttonListen.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.buttonListen.Location = new System.Drawing.Point(14, 14); this.buttonListen.Margin = new System.Windows.Forms.Padding(4); this.buttonListen.Name = "buttonListen"; - this.buttonListen.Size = new System.Drawing.Size(147, 28); + this.buttonListen.Size = new System.Drawing.Size(97, 26); this.buttonListen.TabIndex = 0; this.buttonListen.Text = "Start listening"; this.buttonListen.UseVisualStyleBackColor = true; @@ -52,18 +54,17 @@ private void InitializeComponent() this.label1.Size = new System.Drawing.Size(0, 16); this.label1.TabIndex = 1; // - // Form1 + // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; - this.ClientSize = new System.Drawing.Size(1067, 554); + this.ClientSize = new System.Drawing.Size(252, 54); this.Controls.Add(this.label1); this.Controls.Add(this.buttonListen); this.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Margin = new System.Windows.Forms.Padding(4); this.MaximizeBox = false; - this.Name = "Form1"; + this.Name = "MainForm"; this.Padding = new System.Windows.Forms.Padding(10); this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "C# Voice control"; diff --git a/X-Plane Voice Control/X-Plane Voice Control.csproj b/X-Plane Voice Control/X-Plane Voice Control.csproj index 9905b2e..6117097 100644 --- a/X-Plane Voice Control/X-Plane Voice Control.csproj +++ b/X-Plane Voice Control/X-Plane Voice Control.csproj @@ -54,6 +54,7 @@ +