public void SetInSim(ExtendedSimConnect simConnect, string?label) { UInt32 range = UInt32.Parse(label !); var code = Math.Clamp(BitOperations.Log2(range / 10), 0, 5); sender.Execute(simConnect, $"{code} (>L:{lvarName})"); }
protected override void ProcessSpoilerDemand(ExtendedSimConnect simConnect, SpoilerData data) { int? newPosition = null; IEvent?toSend = null; if (data.armed != 0) { toSend = armOffEvent; //newPosition = 0; } else if (data.position < 100) { newPosition = Math.Min(data.position + 25, 100); } if (toSend != null) { _logger.LogDebug($"Now send {toSend}"); simConnect.SendEvent(toSend); } if (newPosition != null) { uint eventData = (uint)newPosition * 164; eventData = Math.Min(eventData, 16384u); _logger.LogDebug($"Now demand position {newPosition} or as U {eventData}"); simConnect.SendEvent(setEvent, eventData); } }
private void OnGroundHandler(ExtendedSimConnect simConnect, bool isOnGround) { SIMCONNECT_PERIOD period = isOnGround ? SIMCONNECT_PERIOD.SECOND : SIMCONNECT_PERIOD.NEVER; simConnect.RequestDataOnSimObject(this, period); wasAirspeedAlive = wasAbove80 = wasAbove100 = wasAboveV1 = wasAboveVR = null; }
public override void Process(ExtendedSimConnect simConnect, LandingLightData data) { _logging.LogDebug($"Landing light switch? L {data.landingSwitchLeft} R {data.landingSwitchRight} states L {data.landingStateLeft} R {data.landingStateRight}"); oldLeft = data.landingSwitchLeft == 1; oldRight = data.landingSwitchRight == 1; hub.Clients.All.SetFromSim(GetId(), oldLeft || oldRight); }
public override void Process(ExtendedSimConnect simConnect, RunwayCallsStateData data) { //System.Console.Error.WriteLine($"Runway calls state: {data.onGround}"); var period = data.onGround == 1 ? SIMCONNECT_PERIOD.VISUAL_FRAME : SIMCONNECT_PERIOD.NEVER; onGroundHandlers?.Invoke(simConnect, data.onGround == 1); }
public void SetInSim(ExtendedSimConnect simConnect, string?newFrequencyString) { var newFrequency = Decimal.Parse(newFrequencyString !); uint hz = Decimal.ToUInt32(Decimal.Multiply(newFrequency, new Decimal(1000000))); simConnect.SendEvent(setEvent, hz); }
public override void Process(ExtendedSimConnect simConnect, ClimbRateData data) { if (data.feetPerMinute > 500) { hubContext.Clients.All.Speak("positive climb"); SetIsLIstening(simConnect, false); } }
public void SetInSim(ExtendedSimConnect simConnect, Int16 value) { while (value != 0) { simConnect.SendEvent(value < 0 ? dec : inc); value -= (short)Math.Sign(value); } }
private void OnGroundHandler(ExtendedSimConnect simConnect, bool isOnGround) { SIMCONNECT_PERIOD period = isOnGround ? SIMCONNECT_PERIOD.SECOND : SIMCONNECT_PERIOD.NEVER; simConnect.RequestDataOnSimObject(this, period); wasDecel = wasBelow70 = null; wasSpoilers = isOnGround ? false : null; }
public void SetInSim(ExtendedSimConnect simConnect, bool value) { if (value != isOn) { sender.Execute(simConnect, "2 (>K:TOGGLE_TAXI_LIGHTS) 3 (>K:TOGGLE_TAXI_LIGHTS)"); isOn = value; } }
public void SetInSim(ExtendedSimConnect simConnect, Int16 value) { while (value != 0) { simConnect.SendEvent(value < 0 ? dec : inc); value -= (short)Math.Sign(value); } //TODO: in the real FCU, when turning quickly, it takes *two* clicks to change by 100 ft/min V/S. }
private void OnGroundHandler(ExtendedSimConnect simConnect, bool isOnGround) { Request(simConnect, isOnGround ? 1000 : 0); if (!isOnGround) { engine1N1.Request(simConnect, 0); engine2N1.Request(simConnect, 0); } }
public void SetInSim(ExtendedSimConnect simConnect, string?position) { var auto = position == "auto" ? 1 : 0; var set = position != "off" ? 1 : 0; var value = position switch { "on" => 0, "auto" => 1, "off" => 2, _ => throw new ArgumentException($"Unknown strobe position {position}") }; sender.Execute(simConnect, $"{auto} (>L:STROBE_0_Auto) {set} 0 r (>K:2:STROBES_SET) {value} (>L:LIGHTING_STROBE_0)"); } }
public void SetInSim(ExtendedSimConnect simConnect, Int16?value) { Console.Error.WriteLine("Speedbrake from Serial not currently honoured"); return; //TODO: remove when "handle" is exposed again. simConnect.SendEvent(value >= 0 ? armOff : armOn); uint eventData = (uint)Math.Max((int)value !, 0) * 164; eventData = Math.Min(eventData, 16384u); simConnect.SendEvent(set, eventData); }
public void Request(ExtendedSimConnect simConnect, string name, int milliseconds, double value) { if (milliseconds != 0 && milliseconds != 167 && milliseconds != 1000 && milliseconds != 4000) { throw new ArgumentException($"{milliseconds}ms not supported as checking interval"); } var data = new LVarDataRequest { name = name, milliseconds = milliseconds, value = value }; simConnect.SendDataOnSimObject(data); }
public void SetInSim(ExtendedSimConnect simConnect, string?label) { var code = label switch { "Off" => 0, "ADF" => 1, "VOR" => 2, _ => throw new ArgumentOutOfRangeException($"Unrecognised EFIS navaid setting '{label}'") }; sender.Execute(simConnect, $"{code} (>L:{lvarName})"); } }
public override void Process(ExtendedSimConnect simConnect, TenThousandData data) { if (previous != null) { bool isAbove = data.feetIndicated > 10000; bool wasAbove = previous > 10000; if (isAbove != wasAbove) { hubContext.Clients.All.Speak("ten thousand"); } } previous = data.feetIndicated; }
public void SetInSim(ExtendedSimConnect simConnect, bool value) { var retracted = value ? 0 : 1; var code = $"{retracted} (>L:LANDING_2_Retracted,·Bool) {retracted} (>L:LANDING_3_Retracted,·Bool)"; if (oldLeft != value) { code += " 2 (>K:LANDING_LIGHTS_TOGGLE)"; } if (oldRight != value) { code += " 3 (>K:LANDING_LIGHTS_TOGGLE)"; } sender.Execute(simConnect, code); }
public void SetInSim(ExtendedSimConnect simConnect, string?label) { var code = label switch { "Rose ILS" => 0, "Rose VOR" => 1, "Rose Nav" => 2, "Arc" => 3, "Plan" => 4, _ => throw new ArgumentOutOfRangeException($"Unrecognised EFIS mode '{label}'") }; sender.Execute(simConnect, $"{code} (>L:{lvarName})"); } }
public override void Process(ExtendedSimConnect simConnect, TakeOffData data) { if (data.kias < 39) { wasAirspeedAlive = wasAbove80 = wasAboveV1 = wasAboveVR = false; } if (SetAndCallIfRequired(40, data.kias, "airspeed alive", ref wasAirspeedAlive)) { v1Speed.Request(simConnect); vrSpeed.Request(simConnect); } _ = SetAndCallIfRequired(80, data.kias, "eighty knots", ref wasAbove80); _ = SetAndCallIfRequired(100, data.kias, "one hundred knots", ref wasAbove100); _ = SetAndCallIfRequired((Int16?)v1Speed ?? 0, data.kias, "vee one", ref wasAboveV1); _ = SetAndCallIfRequired((Int16?)vrSpeed ?? 0, data.kias, "rotate", ref wasAboveVR); }
protected override void ProcessSpoilerDemand(ExtendedSimConnect simConnect, SpoilerData data) { if (data.position > 0) { int newPosition = Math.Max(data.position - 25, 0); uint eventData = (uint)newPosition * 164u; eventData = Math.Min(eventData, 16384u); _logger.LogDebug($"Now demand position {newPosition} or as U {eventData}"); simConnect.SendEvent(setEvent, eventData); } else if (data.armed == 0) { _logger.LogDebug($"Now send {armOnEvent}"); simConnect.SendEvent(armOnEvent); } }
public override void Process(ExtendedSimConnect simConnect, LandingData data) { if (wasDecel == null && data.kias >= 80) { autobrakeSetting.Request(simConnect); wasDecel = false; } else if (wasDecel == false) { bool isDecel = (autobrakeSetting == 0 || autobrakeDecelLight != 0) && data.accelerationZ <= -1.5; if (isDecel) { hubContext.Clients.All.Speak("Decell!"); wasDecel = true; } } if (wasBelow70 == null && data.kias >= 70) { wasBelow70 = false; } else if (wasBelow70 == false && data.kias < 70) { hubContext.Clients.All.Speak("seventy knots"); wasBelow70 = true; } if (wasSpoilers == false) { bool isSpoilers = data.spoilersLeft > MIN_SPOILER_DEPLOYMENT && data.spoilersRight > MIN_SPOILER_DEPLOYMENT; if (isSpoilers) { hubContext.Clients.All.Speak("Spoilers!"); wasSpoilers = true; } } if (wasRevGreen == null && data.kias >= 50) { wasRevGreen = false; } if (wasRevGreen == false && data.rev1 > 0 && data.rev2 > 0) { hubContext.Clients.All.Speak("Rev Green"); wasRevGreen = true; } }
public override void Process(ExtendedSimConnect simConnect, SpoilerData data) { _logger.LogDebug($"Wants spoiler; raw data pos {data.position} armed {data.armed} A32NX armed {(double?)armed} active {(double?)active} handle {(double?)handle}"); if ((double?)armed == 1.0f || (double?)active == 1.0f) { data.armed = 1; } var a32nxHandle = (double?)handle; if (a32nxHandle is not null) { data.position = (int)(100f * a32nxHandle); } _logger.LogDebug($"... processed data pos {data.position} armed {data.armed}"); ProcessSpoilerDemand(simConnect, data); }
public override void Process(ExtendedSimConnect simConnect, RunwayTurnoffLightData data) { _logging.LogDebug($"Runway turnoff light state L {data.leftState} R {data.rightState}, switch L {data.leftSwitch}, switch R {data.rightSwitch}"); isOn = data.leftSwitch == 1 || data.rightSwitch == 1; hub.Clients.All.SetFromSim(GetId(), isOn); }
public void OnStarted(ExtendedSimConnect simConnect) => Request(simConnect);
public void SetInSim(ExtendedSimConnect simConnect, bool?value) { sender.Execute(simConnect, $"1 (L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON, Bool) - (>L:A32NX_OVHD_APU_MASTER_SW_PB_IS_ON)"); }
public void SetInSim(ExtendedSimConnect simConnect, bool?value) { sender.Execute(simConnect, "(L:A32NX_OVHD_APU_START_PB_IS_AVAILABLE, Bool) if { 1 (>L:A32NX_OVHD_APU_START_PB_IS_ON, Bool) }"); }
public override void Process(ExtendedSimConnect simConnect, FlightDirectorData data) => logging.LogError($"FdActive1={data.fdActive1} FdActive2={data.fdActive2}");
public void OnConnection(ExtendedSimConnect simConnect) => Request(simConnect);
public void SetInSim(ExtendedSimConnect simConnect, bool value) { simConnect.SendEvent(toggleBeaconLightsEvent); }