public void OnAircraftConfigurationInfoReceived(object sender, NetworkDataReceivedEventArgs e) { AircraftConfigurationInfo info; try { info = AircraftConfigurationInfo.FromJson(e.Data); } catch { return; } if (info.Request.HasValue) { switch (info.Request.Value) { case AircraftConfigurationInfo.RequestType.Full: { AircraftConfiguration cfg = AircraftConfiguration.FromUserAircraftData(UserAircraftData); cfg.IsFullData = true; mFsdManager.SendAircraftConfiguration(e.From, cfg); break; } } } }
public void OnUserAircraftDataUpdated(object sender, UserAircraftDataUpdatedEventArgs e) { if (UserAircraftData == null || !UserAircraftData.Equals(e.UserAircraftData)) { UserAircraftData = e.UserAircraftData; } if ((mLastBroadcastConfig == null) || !mFsdManager.IsConnected) { mLastBroadcastConfig = AircraftConfiguration.FromUserAircraftData(UserAircraftData); } else if (mAcconfigAvailableTokens > 0) { AircraftConfiguration newCfg = AircraftConfiguration.FromUserAircraftData(UserAircraftData); if (!newCfg.Equals(mLastBroadcastConfig)) { AircraftConfiguration incremental = mLastBroadcastConfig.CreateIncremental(newCfg); mFsdManager.SendIncrementalAircraftConfigurationUpdate(incremental); mLastBroadcastConfig = newCfg; mAcconfigAvailableTokens--; } } bool wasAirborne = mAirborne; mAirborne = !UserAircraftData.OnGround; if (mInitialAircraftDataReceived && !wasAirborne && mAirborne && !mConfig.SquawkingModeC && mConfig.AutoSquawkModeC) { var laminarB738 = new XPlaneConnector.DataRefElement { DataRef = "laminar/B738/knob/transpoder_pos" }; var laminarB738_Dn_Cmd = new XPlaneConnector.XPlaneCommand("laminar/B738/knob/transponder_mode_up", ""); var laminarB738_Up_Cmd = new XPlaneConnector.XPlaneCommand("laminar/B738/knob/transponder_mode_up", ""); SendXplaneCommand?.Invoke(this, new ClientEventArgs <XPlaneConnector.XPlaneCommand>(laminarB738_Up_Cmd)); SetXplaneDataRefValue?.Invoke(this, new DataRefEventArgs(laminarB738, 3)); SendXplaneCommand?.Invoke(this, new ClientEventArgs <XPlaneConnector.XPlaneCommand>(XPlaneConnector.Commands.TransponderTransponderAlt)); } mInitialAircraftDataReceived = true; }