private void simconnect_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data) { switch ((DATA_REQUESTS)data.dwRequestID) { case DATA_REQUESTS.REQUEST_SYSTEMSTATE: FLIGHTSIM_STATUS_STRUCT fsStat; fsStat.inFlight = false; if (data.dwInteger == 1) { fsStat.inFlight = true; simconnect.SetSystemEventState(EVENTS.FLIGHTPLAN_LOADED, SIMCONNECT_STATE.ON); } OnDataReceived(new DataReceivedEventArgs(FSDataType.DT_FLIGHTSIM_STATUS, fsStat)); break; case DATA_REQUESTS.REQUEST_FLIGHTPLAN: FLIGHTPLAN_LINK fpl; fpl.flightPlanFilename = data.szString; OnDataReceived(new DataReceivedEventArgs(FSDataType.DT_FLIGHTPLAN, fpl)); break; default: break; } }
private void Simconnect_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data) { switch (data.dwRequestID) { case (int)DATA_REQUESTS.FLIGHT_PLAN: if (!string.IsNullOrEmpty(data.szString)) { logger.LogInformation("Receive flight plan {flightPlan}", data.szString); } break; } }
private async void simconnect_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data) { switch (data.dwRequestID) { case (int)DATA_REQUESTS.FLIGHT_PLAN: if (!string.IsNullOrEmpty(data.szString)) { logger.LogInformation($"Receive flight plan {data.szString}"); var planName = data.szString; var parser = new FlightPlanParser(); var plan = await parser.ParseAsync(planName); var flightPlan = new FlightPlan { Title = plan.FlightPlanFlightPlan.Title, Departure = new Point { Id = plan.FlightPlanFlightPlan.DepartureID, Name = plan.FlightPlanFlightPlan.DepartureName, Position = plan.FlightPlanFlightPlan.DeparturePosition, }, Destination = new Point { Id = plan.FlightPlanFlightPlan.DestinationID, Name = plan.FlightPlanFlightPlan.DestinationName, }, CruisingAltitude = plan.FlightPlanFlightPlan.CruisingAlt }; (flightPlan.Departure.Latitude, flightPlan.Departure.Longitude) = GpsHelper.ConvertString(plan.FlightPlanFlightPlan.DepartureLLA); (flightPlan.Destination.Latitude, flightPlan.Destination.Longitude) = GpsHelper.ConvertString(plan.FlightPlanFlightPlan.DestinationLLA); if (plan.FlightPlanFlightPlan.ATCWaypoint != null) { flightPlan.Waypoints = new System.Collections.Generic.List <Waypoint>(); foreach (var waypoint in plan.FlightPlanFlightPlan.ATCWaypoint) { var w = new Waypoint { Id = waypoint.id, Type = waypoint.ATCWaypointType, Airway = waypoint.ATCAirway, }; (w.Latitude, w.Longitude) = GpsHelper.ConvertString(waypoint.WorldPosition); flightPlan.Waypoints.Add(w); } } FlightPlanUpdated?.Invoke(this, new FlightPlanUpdatedEventArgs(flightPlan)); } break; } }
private async void Simconnect_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data) { switch (data.dwRequestID) { case (int)DATA_REQUESTS.FLIGHT_PLAN: if (!string.IsNullOrEmpty(data.szString)) { logger.LogInformation($"Received flight plan {data.szString}"); var planName = data.szString; if (planName == ".PLN") { logger.LogInformation("Flight plan is not read. Wait for 5s..."); await Task.Delay(5000); simconnect.RequestSystemState(DATA_REQUESTS.FLIGHT_PLAN, "FlightPlan"); } else { if (File.Exists(planName)) { using var stream = File.OpenRead(planName); var serializer = new XmlSerializer(typeof(FlightPlanDocumentXml)); var flightPlan = serializer.Deserialize(stream) as FlightPlanDocumentXml; var flightPlanData = flightPlan.FlightPlan.ToData(); FlightPlanUpdated?.Invoke(this, new FlightPlanUpdatedEventArgs(flightPlanData)); flightPlanTcs?.TrySetResult(flightPlanData); flightPlanTcs = null; } else { logger.LogWarning($"{planName} does not exist!"); FlightPlanUpdated?.Invoke(this, new FlightPlanUpdatedEventArgs(null)); flightPlanTcs?.TrySetResult(null); flightPlanTcs = null; } } } break; } }
void sc_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data) { Console.WriteLine("sc_OnRecvSystemState"); }
private void Simconnect_OnRecvSystemState(SimConnect sender, SIMCONNECT_RECV_SYSTEM_STATE data) { logger.LogDebug("OnRecvSystemState dwRequestID {dwRequestID}", (DATA_REQUESTS)data.dwRequestID); }