public override void OnTrigger(RecognitionResult rResult, string phrase) { var groundPowerAvailAble = XPlaneInterface.GetDataRef <double>("laminar/B738/annunciator/ground_power_avail"); if (phrase.Contains(_groundPowerStatesStrings[0]) && groundPowerAvailAble.Value == 1) { Task.Run(() => { XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/gpu_dn", Command.CommandType.Begin); Thread.Sleep(Constants.ButtonReleaseDelay); XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/gpu_dn", Command.CommandType.End); }); SpeechSynthesizer.SpeakAsync("Ground power connected"); } else if (phrase.Contains(_groundPowerStatesStrings[1])) { Task.Run(() => { XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/gpu_up", Command.CommandType.Begin); Thread.Sleep(Constants.ButtonReleaseDelay); XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/gpu_up", Command.CommandType.End); }); SpeechSynthesizer.SpeakAsync("Ground power disconnected"); } }
private void PressButton() { Task.Run(() => { XPlaneInterface.SetExecutingCommand("laminar/B738/autopilot/change_over_press"); }); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var lightToSwitch = _lightTypeStrings.First(phrase.Contains); var valueToSet = _lightStatusesStrings.First(phrase.Contains); if (lightToSwitch == _lightTypeStrings[1]) { if (valueToSet.Equals("off", StringComparison.CurrentCultureIgnoreCase)) { XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/position_light_up"); XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/position_light_up"); XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/position_light_down"); } else { XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/position_light_up"); XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/position_light_up"); } } else if (lightToSwitch == _lightTypeStrings[2]) { XPlaneInterface.SetExecutingCommand($"sim/lights/beacon_lights_{valueToSet}"); } else { XPlaneInterface.SetExecutingCommand($"laminar/B738/switch/{lightToSwitch}_light_{valueToSet}"); } SpeechSynthesizer.SpeakAsync($"{lightToSwitch} lights turned {valueToSet}"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { if (_apuOnStrings.Any(phrase.Contains) || phrase.Contains(_apuStatus[0])) { Task.Run(() => { XPlaneInterface.SetExecutingCommand("laminar/B738/spring_toggle_switch/APU_start_pos_dn"); Thread.Sleep(Constants.ButtonReleaseDelay - 200); XPlaneInterface.SetExecutingCommand("laminar/B738/spring_toggle_switch/APU_start_pos_dn", Command.CommandType.Begin); Thread.Sleep(Constants.ButtonReleaseDelay); XPlaneInterface.SetExecutingCommand("laminar/B738/spring_toggle_switch/APU_start_pos_dn", Command.CommandType.End); }); SpeechSynthesizer.SpeakAsync("APU is starting up"); } else if (_apuOffString.Any(phrase.Contains) || phrase.Contains(_apuStatus[1])) { Task.Run(() => { XPlaneInterface.SetExecutingCommand("laminar/B738/spring_toggle_switch/APU_start_pos_up"); Thread.Sleep(Constants.ButtonReleaseDelay); XPlaneInterface.SetExecutingCommand("laminar/B738/spring_toggle_switch/APU_start_pos_up"); }); SpeechSynthesizer.SpeakAsync("APU is shutting down"); } }
private void PressButton() { Task.Run(() => { XPlaneInterface.SetExecutingCommand("laminar/B738/autopilot/alt_interv", Command.CommandType.Begin); }); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var radioToSwap = _comRadios.First(phrase.Contains); var stringFreq = Constants.StringNumbersToDigits(phrase).Split(new[] { $"{radioToSwap} to " }, StringSplitOptions.None)[1] .Replace(" ", ""); var trailing = false; if (stringFreq.Length == 6) { if (stringFreq[5] == '5') { trailing = true; } stringFreq = stringFreq.Remove(5, 1); } stringFreq += new string('0', 5 - stringFreq.Length); var freq = int.Parse(stringFreq); if (!Constants.IsValidComFreq(freq)) { return; } var dataRef = $"sim/cockpit2/radios/actuators/{radioToSwap}_standby_frequency_hz"; XPlaneInterface.SetDataRef(dataRef, freq); if (trailing) { XPlaneInterface.SetExecutingCommand("laminar/B738/rtp_L/freq_khz/sel_dial_up"); } }
public override void OnTrigger(RecognitionResult result, string phrase) { var toFlip = _radios.First(phrase.Contains); XPlaneInterface.SetExecutingCommand($"sim/radios/{toFlip}_standy_flip"); SpeechSynthesizer.SpeakAsync($"{toFlip} swapped"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var transponderPos = (int)XPlaneInterface.GetDataRef <double>("laminar/B738/knob/transponder_pos").Value; var requestedPosition = _transponderModes.First(phrase.Contains) == "on" ? 5 : 1; int numberToAdd = 0; if (requestedPosition > transponderPos) { numberToAdd = 1; } else if (requestedPosition < transponderPos) { numberToAdd = -1; } else { numberToAdd = transponderPos; } while (transponderPos != requestedPosition) { XPlaneInterface.SetExecutingCommand(numberToAdd == 1 ? "laminar/B738/knob/transponder_mode_up" : "laminar/B738/knob/transponder_mode_dn"); transponderPos += numberToAdd; } SpeechSynthesizer.SpeakAsync($"transponder set to {(requestedPosition == 1 ? "off" : "on")}"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var currentAltitude = (int)XPlaneInterface.GetDataRef <float>("sim/cockpit/autopilot/altitude").Value; var altitudeToSet = 0; if (phrase.Contains("flight level")) { var flString = phrase.Split(new[] { "flight level " }, StringSplitOptions.RemoveEmptyEntries)[1]; altitudeToSet = int.Parse(Constants.StringNumbersToDigits(flString).Replace(" ", "")) * 100; } var strinAltitude = Constants.StringNumbersToDigits(phrase); try { var startingIndexNumber = Constants.NumbersInDigits40.First(strinAltitude.Contains); var startingIndex = strinAltitude.IndexOf(startingIndexNumber, StringComparison.Ordinal); strinAltitude = strinAltitude.Substring(startingIndex, strinAltitude.Length - startingIndex); } catch { // ignored } var splittedString = strinAltitude.Split(' '); for (var i = 0; i < splittedString.Length; i += 2) { var nextIndex = i + 1; if (nextIndex > splittedString.Length - 1) { break; } if (splittedString[i + 1] == "thousand") { altitudeToSet += int.Parse(splittedString[i]) * 1000; } if (splittedString[i + 1] == "hundred") { altitudeToSet += int.Parse(splittedString[i]) * 100; } } var buttonCommand = currentAltitude > altitudeToSet ? "laminar/B738/autopilot/altitude_dn" : "laminar/B738/autopilot/altitude_up"; var rotation = currentAltitude > altitudeToSet ? -100 : 100; Task.Run(() => { while (currentAltitude != altitudeToSet) { currentAltitude += rotation; XPlaneInterface.SetExecutingCommand(buttonCommand); Thread.Sleep(20); } }); SpeechSynthesizer.SpeakAsync($"Setting altitude to {altitudeToSet} feet"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var valueToSet = _statutes.First(phrase.Contains) == "on" ? 1 : 0; XPlaneInterface.SetDataRef("laminar/B738/knobs/cross_feed_pos", valueToSet); SpeechSynthesizer.SpeakAsync($"crossfeed set to {(valueToSet == 1 ? "on" : "off")}"); }
public override void DataRefSubscribe() { XPlaneInterface.Subscribe <double>("laminar/B738/ice/window_heat_l_fwd_pos"); XPlaneInterface.Subscribe <double>("laminar/B738/ice/window_heat_l_side_pos"); XPlaneInterface.Subscribe <double>("laminar/B738/ice/window_heat_r_fwd_pos"); XPlaneInterface.Subscribe <double>("laminar/B738/ice/window_heat_r_side_pos"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var valueOne = XPlaneInterface.GetDataRef <double>("laminar/B738/engine/starter1_pos"); var valueTwo = XPlaneInterface.GetDataRef <double>("laminar/B738/engine/starter2_pos"); if (phrase.Contains(_engineNumbersStrings[0])) { if (_engineStartStrings.Any(phrase.Contains)) { XPlaneInterface.SetDataRef(valueOne.Name, 0); SpeechSynthesizer.SpeakAsync("Starting engine number one"); } else if (_engineShutdownStrings.Any(phrase.Contains)) { XPlaneInterface.SetDataRef("laminar/B738/engine/mixture_ratio1", 0); SpeechSynthesizer.SpeakAsync("Shutting down engine number one"); } } else if (phrase.Contains(_engineNumbersStrings[1])) { if (_engineStartStrings.Any(phrase.Contains)) { XPlaneInterface.SetDataRef(valueTwo.Name, 0); SpeechSynthesizer.SpeakAsync("Starting engine number two"); } else if (_engineShutdownStrings.Any(phrase.Contains)) { XPlaneInterface.SetDataRef("laminar/B738/engine/mixture_ratio2", 0); SpeechSynthesizer.SpeakAsync("Shutting down engine number two"); } } }
public override void DataRefSubscribe() { XPlaneInterface.Subscribe <double>("laminar/B738/engine/starter1_pos"); XPlaneInterface.Subscribe <double>("laminar/B738/engine/starter2_pos"); XPlaneInterface.Subscribe <double>("laminar/B738/engine/mixture_ratio2"); XPlaneInterface.Subscribe <double>("laminar/B738/engine/mixture_ratio1"); }
public override void OnTrigger(RecognitionResult result, string phrase) { var index = phrase.IndexOf("com", StringComparison.InvariantCulture); var id = phrase[index + 3].ToString(); XPlaneInterface.SetExecutingCommand($"sim/radios/com{id}_standy_flip"); SpeechSynthesizer.SpeakAsync($"com {id} swapped"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var stringPackSide = _packUnitsStrings.First(phrase.Contains); var stringValueToSet = _packStatutesStrings.First(phrase.Contains); var index = Array.IndexOf(_packStatutesStrings, stringValueToSet); XPlaneInterface.SetDataRef($"laminar/B738/air/{stringPackSide[0]}_pack_pos", index); SpeechSynthesizer.SpeakAsync($"{stringPackSide} pack set to {stringValueToSet}"); }
private void PressButton() { Task.Run(() => { XPlaneInterface.SetExecutingCommand("laminar/B738/autopilot/alt_hld_press", Command.CommandType.Begin); Thread.Sleep(Constants.PushButtonReleaseDelay); XPlaneInterface.SetExecutingCommand("laminar/B738/autopilot/alt_hld_press", Command.CommandType.End); }); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var stringFreq = Constants.StringNumbersToDigits(phrase); stringFreq = stringFreq.Substring(stringFreq.Length - 7, 7); var squawk = int.Parse(stringFreq.Replace(" ", "")); XPlaneInterface.SetDataRef("sim/cockpit2/radios/actuators/transponder_code", squawk); SpeechSynthesizer.SpeakAsync($"squawk code set to {stringFreq}"); }
public override void DataRefSubscribe() { XPlaneInterface.Subscribe <double>("laminar/B738/switches/landing_gear"); XPlaneInterface.Subscribe <double>("laminar/B738/annunciator/nose_gear_transit"); XPlaneInterface.Subscribe <double>("laminar/B738/annunciator/nose_gear_safe"); XPlaneInterface.Subscribe <double>("laminar/B738/annunciator/left_gear_transit"); XPlaneInterface.Subscribe <double>("laminar/B738/annunciator/left_gear_safe"); XPlaneInterface.Subscribe <double>("laminar/B738/annunciator/right_gear_transit"); XPlaneInterface.Subscribe <double>("laminar/B738/annunciator/right_gear_safe"); }
public override void DataRefSubscribe() { XPlaneInterface.Subscribe <double>("laminar/B738/fuel/fuel_tank_pos_lft1"); XPlaneInterface.Subscribe <double>("laminar/B738/fuel/fuel_tank_pos_lft2"); XPlaneInterface.Subscribe <double>("laminar/B738/fuel/fuel_tank_pos_rgt1"); XPlaneInterface.Subscribe <double>("laminar/B738/fuel/fuel_tank_pos_rgt2"); XPlaneInterface.Subscribe <double>("laminar/B738/fuel/fuel_tank_pos_ctr1"); XPlaneInterface.Subscribe <double>("laminar/B738/fuel/fuel_tank_pos_ctr2"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var actionString = _controlStateStrings.First(phrase.Contains); var actionNumber = -1; switch (actionString) { case "off": actionNumber = 0; break; case "auto": actionNumber = 1; break; case "on": actionNumber = 2; break; } if (phrase.Contains(_controlNamesStrings[0])) { XPlaneInterface.SetDataRef("laminar/B738/toggle_switch/no_smoking_pos", actionNumber); SpeechSynthesizer.SpeakAsync($"No smoking set to {actionString}"); } else if (phrase.Contains(_controlNamesStrings[1])) { var seatBeltValue = XPlaneInterface.GetDataRef <double>("laminar/B738/toggle_switch/seatbelt_sign_pos"); int valueToAdd; var actualValue = Convert.ToInt32(seatBeltValue.Value); if (seatBeltValue.Value == actionNumber) { return; } else if (seatBeltValue.Value > actionNumber) { valueToAdd = -1; } else { valueToAdd = 1; } while (actionNumber != actualValue) { actualValue += valueToAdd; XPlaneInterface.SetExecutingCommand(valueToAdd > 0 ? "laminar/B738/toggle_switch/seatbelt_sign_dn" : "laminar/B738/toggle_switch/seatbelt_sign_up"); } SpeechSynthesizer.SpeakAsync($"Seatbelts set to {actionString}"); } }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var presentHeading = (int)XPlaneInterface.GetDataRef <double>("laminar/B738/autopilot/mcp_hdg_dial").Value; var stringHeading = Constants.StringNumbersToDigits(phrase); stringHeading = stringHeading.Substring(stringHeading.Length - 5, 5); var requestedHeading = int.Parse(stringHeading.Replace(" ", "")); if (requestedHeading > 360) { SpeechSynthesizer.SpeakAsync("Cannot set heading bigger than 360"); return; } if (requestedHeading == 360) { requestedHeading = 0; } int wayToRotate; if (presentHeading < requestedHeading) { var x = requestedHeading - presentHeading; var y = presentHeading + (360 - requestedHeading); wayToRotate = x <= y ? 1 : -1; } else { var x = (360 - presentHeading) + requestedHeading; var y = presentHeading - requestedHeading; wayToRotate = x <= y ? 1 : -1; } Task.Run(() => { while (presentHeading != requestedHeading) { presentHeading += wayToRotate; if (presentHeading == 360) { presentHeading = 0; } if (presentHeading == -1) { presentHeading = 359; } XPlaneInterface.SetDataRef("laminar/B738/autopilot/mcp_hdg_dial", presentHeading); Thread.Sleep(2); } }); SpeechSynthesizer.SpeakAsync($"Setting heading to {stringHeading}"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var value = XPlaneInterface.GetDataRef <double>("laminar/B738/annunciator/parking_brake").Value; if (_brakeOnStrings.Contains(phrase) && value.Equals(0)) { XPlaneInterface.SetExecutingCommand("sim/flight_controls/brakes_toggle_max"); SpeechSynthesizer.SpeakAsync("Parking brake set."); } else if (_brakeOffStrings.Contains(phrase) && value.Equals(1)) { XPlaneInterface.SetExecutingCommand("sim/flight_controls/brakes_toggle_max"); SpeechSynthesizer.SpeakAsync("Parking brake released."); } }
public override void OnTrigger(RecognitionResult rResult, string phrase) { if (phrase.Contains("on")) { XPlaneInterface.SetDataRef("laminar/B738/toggle_switch/capt_probes_pos", 1); XPlaneInterface.SetDataRef("laminar/B738/toggle_switch/fo_probes_pos", 1); SpeechSynthesizer.SpeakAsync("Probe heat on"); } else if (phrase.Contains("off")) { XPlaneInterface.SetDataRef("laminar/B738/toggle_switch/capt_probes_pos", 0); XPlaneInterface.SetDataRef("laminar/B738/toggle_switch/fo_probes_pos", 0); SpeechSynthesizer.SpeakAsync("Probe heat off"); } }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var stringUnit = _bleedUnitsStrings.First(phrase.Contains); var stringValueToSet = _bleedStatusStrings.First(phrase.Contains); var index = Array.IndexOf(_bleedStatusStrings, stringValueToSet); var indexUnit = Array.IndexOf(_bleedUnitsStrings, stringUnit); var unitToSet = "apu"; if (indexUnit == 1 || indexUnit == 2) { unitToSet = indexUnit.ToString(); } XPlaneInterface.SetDataRef($"laminar/B738/toggle_switch/bleed_air_{unitToSet}_pos", index); SpeechSynthesizer.SpeakAsync($"{stringUnit} bleed air set to {stringValueToSet}"); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var value = XPlaneInterface.GetDataRef <double>("laminar/B738/toggle_switch/taxi_light_brightness_pos").Value; if (phrase.Contains("on") && value != 2) { XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/taxi_light_brigh_toggle"); SpeechSynthesizer.SpeakAsync("Taxi lights on"); } else if (phrase.Contains("off") && value != 0) { XPlaneInterface.SetExecutingCommand("laminar/B738/toggle_switch/taxi_light_brigh_toggle"); SpeechSynthesizer.SpeakAsync("Taxi lights off"); } }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var valueOne = XPlaneInterface.GetDataRef <double>("laminar/B738/engine/mixture_ratio1"); var valueTwo = XPlaneInterface.GetDataRef <double>("laminar/B738/engine/mixture_ratio2"); if (phrase.Contains(_engineNumbersStrings[0])) { XPlaneInterface.SetDataRef(valueOne.Name, 1); SpeechSynthesizer.SpeakAsync("Introducing fuel into engine number one"); } else if (phrase.Contains(_engineNumbersStrings[1])) { XPlaneInterface.SetDataRef(valueTwo.Name, 1); SpeechSynthesizer.SpeakAsync("Introducing fuel into engine number two"); } }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var value = XPlaneInterface.GetDataRef <float>("sim/flightmodel/controls/flaprqst").Value; var command = _flapsPositionStrings.First(phrase.Contains); if (command == "up") { if (phrase.Contains(ANotch)) { var valueToSet = value - 0.125f; if (valueToSet < 0) { valueToSet = 0; } XPlaneInterface.SetDataRef("sim/flightmodel/controls/flaprqst", valueToSet); SpeechSynthesizer.SpeakAsync("Flaps are going up a notch."); } else { XPlaneInterface.SetExecutingCommand("laminar/B738/push_button/flaps_0"); SpeechSynthesizer.SpeakAsync("Flaps are going up."); } } else if (command == "down") { if (phrase.Contains(ANotch)) { var valueToSet = value + 0.125f; if (valueToSet > 1) { valueToSet = 1; } XPlaneInterface.SetDataRef("sim/flightmodel/controls/flaprqst", valueToSet); SpeechSynthesizer.SpeakAsync("Flaps are going down a notch."); } else { XPlaneInterface.SetExecutingCommand("laminar/B738/push_button/flaps_40"); SpeechSynthesizer.SpeakAsync("Flaps are going down."); } } else if (command != string.Empty) { XPlaneInterface.SetExecutingCommand($"laminar/B738/push_button/flaps_{FlapPositions.StringtoInt(command)}"); SpeechSynthesizer.SpeakAsync($"Flaps {command}."); } }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var dataref = XPlaneInterface.GetDataRef <float[]>("sim/cockpit2/switches/landing_lights_switch"); var landingLights = new float[4]; Array.Copy(dataref.Value, 0, landingLights, 0, 4); if (phrase.Contains("on") && !landingLights.SequenceEqual(_landingLightsAllOn)) { XPlaneInterface.SetExecutingCommand("sim/lights/landing_lights_on"); SpeechSynthesizer.SpeakAsync("Landing lights on"); } else if (phrase.Contains("off") && !landingLights.SequenceEqual(_landingLightsAllOff)) { XPlaneInterface.SetExecutingCommand("sim/lights/landing_lights_off"); SpeechSynthesizer.SpeakAsync("Landing lights off"); } }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var stringHeading = Constants.StringNumbersToDigits(phrase); try { var startingIndexNumber = Constants.NumbersInDigits.First(stringHeading.Contains); var startingIndex = stringHeading.IndexOf(startingIndexNumber, StringComparison.Ordinal); stringHeading = stringHeading.Substring(startingIndex, stringHeading.Length - startingIndex); } catch { // ignored } var splittedString = stringHeading.Split(' '); float verticalSpeedToSet = 0; for (var i = 0; i < splittedString.Length; i += 2) { var nextIndex = i + 1; if (nextIndex > splittedString.Length - 1) { break; } if (splittedString[i + 1] == "thousand") { verticalSpeedToSet += int.Parse(splittedString[i]) * 1000; } if (splittedString[i + 1] == "hundred") { verticalSpeedToSet += int.Parse(splittedString[i]) * 100; } } if (phrase.Contains("fifty") && verticalSpeedToSet < 1000 && verticalSpeedToSet > -1000) { verticalSpeedToSet += 50; } if (phrase.Contains("negative")) { verticalSpeedToSet *= -1; } XPlaneInterface.SetDataRef("sim/cockpit/autopilot/vertical_velocity", verticalSpeedToSet); }
public override void OnTrigger(RecognitionResult rResult, string phrase) { var turnOn = !_apOffStrings.Any(phrase.Contains); var apChar = phrase.Contains("auto pilot b") ? "b" : "a"; var apStatus = (int)XPlaneInterface.GetDataRef <double>($"laminar/B738/autopilot/cmd_{apChar}_pos").Value; if (turnOn && apStatus == 0) { PressButton(apChar); SpeechSynthesizer.SpeakAsync($"auto pilot {apChar} engaged"); } else if (!turnOn && apStatus == 1) { PressButton(apChar); SpeechSynthesizer.SpeakAsync($"autopilot {apChar} disengaged"); } }