public void OnFDRUpdate(FDP2.FDR updated) { if (FDP2.GetFDRIndex(updated.Callsign) == -1)//removed { updated.PropertyChanged -= FDR_PropertyChanged; vStripsConnector.RemoveFDR(updated); } else { updated.PropertyChanged -= FDR_PropertyChanged; updated.PropertyChanged += FDR_PropertyChanged; } }
/// This is called each time a flight data record is updated /// Here we are updating the eastbound callsigns dictionary with each flight data record public void OnFDRUpdate(FDP2.FDR updated) { if (FDP2.GetFDRIndex(updated.Callsign) == -1) //FDR was removed (that's what triggered the update) { eastboundCallsigns.TryRemove(updated.Callsign, out _); } else { if (updated.ParsedRoute.Count > 1) { //calculate track from first route point to last (Departure point to destination point) var rte = updated.ParsedRoute; double trk = Conversions.CalculateTrack(rte.First().Intersection.LatLong, rte.Last().Intersection.LatLong); bool east = trk >= 0 && trk < 180; eastboundCallsigns.AddOrUpdate(updated.Callsign, east, (c, e) => east); } } }
public void OnRadarTrackUpdate(RDP.RadarTrack updated) { // Prevents some errors while the coupling ocours. if (updated.CoupledFDR == null) { return; } // Validate if the callsign still exist. Otherwise remove from the Dict. if (FDP2.GetFDRIndex(updated.CoupledFDR.Callsign) == -1) { ssrCodeValues.TryRemove(updated.CoupledFDR.Callsign, out _); } else { bool codeValidity = this.isSSRCodeValid(updated.CoupledFDR, updated.ActualAircraft); ssrCodeValues.AddOrUpdate(updated.CoupledFDR.Callsign, codeValidity, (k, v) => codeValidity); } }
public void OnFDRUpdate(FDP2.FDR updated) { if (FDP2.GetFDRIndex(updated.Callsign) == -1) { pbnValues.TryRemove(updated.Callsign, out _); } else { Match pbn = Regex.Match(updated.Remarks, @"PBN\/\w+\s"); bool rnp10 = Regex.IsMatch(pbn.Value, @"A\d"); bool rnp5 = Regex.IsMatch(pbn.Value, @"B\d"); bool rnp4 = Regex.IsMatch(pbn.Value, @"L\d"); bool rnp2 = updated.Remarks.Contains("NAV/RNP2") || updated.Remarks.Contains("NAV/GLS RNP2"); // TODO: Find a better way char cap = 'P'; if (rnp2 && (rnp10 || rnp4)) { cap = '\0'; } else if (rnp2) { cap = '\0'; } else if (rnp4) { cap = '\0'; } else if (rnp5) { cap = '\0'; } else if (rnp10) { cap = '\0'; } pbnValues.AddOrUpdate(updated.Callsign, cap, (k, v) => cap); } }
private void ProcessData(string packet) { if (packet.Length == 0) { return; } string msg = packet.Substring(1); string[] msg_fields = msg.Split(':'); FDP2.FDR fdr = null; if (msg_fields.Length > 0) { fdr = FDP2.GetFDRs.FirstOrDefault(f => f.Callsign == msg_fields[0]); } switch (packet[0]) { case 'U': if (!connected) { OnConnected(); } SendControllerInfo(); break; case 'r': // Runway request if (Airport?.ICAOName != msg) // || setRunways == false) // Commented out as part of runway supression { getMetar(msg); // Call before we update 'Airport' Airport = Airspace2.GetAirport(msg); setRunways = false; //vStripsPlugin.ShowSetupWindow(); // Commented out to stop popup JMG } else { //SendRunways(); Airport = Airspace2.GetAirport(msg); } break; case 'S': // State if (msg_fields.Length > 1 && fdr != null) { switch (msg_fields[1]) { case "TAXI": MMI.EstFDR(fdr); break; } } break; /* * JMG * vStrips doesn't send Arrival Runway, so we use Dep runway in vStrips for Arrival runway allocation. * We need to keep an eye out when Route changes received that have a Dep runway and reassign to Arr runway. * */ case 'R': // Route if (msg_fields.Length > 3 && fdr != null) { if (fdr.DepAirport == msg_fields[1] && fdr.DesAirport == msg_fields[2]) { string rte = msg_fields[3]; string[] rte_fields = rte.Split(' '); // parse route on space if (rte_fields[0].Contains('/')) // If the first field has a slash, it's a Dep runway assignment. { string[] start_fields = rte_fields[0].Split('/'); String NewRwy = start_fields[1]; // get the runway if (fdr.CoupledTrack?.OnGround == false) // if we're airborne apply the runway to Arrivals { FDP2.SetArrivalRunway(fdr, Airspace2.GetRunway(fdr.DesAirport, NewRwy)); } else // Apply the Route change, or Dep runway change { string temprwy = ""; if (fdr.DepartureRunway != null) { temprwy = fdr.DepartureRunway.ToString(); } if (temprwy != NewRwy) // if the Dep runway has changed { FDP2.SetDepartureRunway(fdr, Airspace2.GetRunway(fdr.DepAirport, NewRwy)); } else // Not a runway change, so update the route { FDP2.ModifyRoute(fdr, rte); } } } } else { FDP2.ModifyFDR(fdr, fdr.Callsign, fdr.FlightRules, msg_fields[1], msg_fields[2], msg_fields[3], fdr.Remarks, fdr.AircraftCount.ToString(), fdr.AircraftType, fdr.AircraftWake, fdr.AircraftEquip, fdr.AircraftSurvEquip, fdr.TAS.ToString(), fdr.RFL.ToString(), fdr.ETD.ToString("HHmm"), fdr.EET.ToString("HHmm")); } } break; case 'H': // Heading if (msg_fields.Length > 1 && fdr != null) { vStripsAssignedHeadings.AddOrUpdate(fdr.Callsign, int.Parse(msg_fields[1]), (s, i) => int.Parse(msg_fields[1])); if (!string.IsNullOrEmpty(msg_fields[1]) && msg_fields[1] != "0") { FDP2.SetGlobalOps(fdr, $"H{msg_fields[1]}"); } if (msg_fields.Length > 2 && msg_fields[2] != "0") { FDP2.SetCFL(fdr, FDP2.FDR.LEVEL_NONE, int.Parse(msg_fields[2]), false); } } break; case '>': // Select Callsign // Edited JMG to ensure when strip is selected in vStrips, track is selected in vatSys if (fdr != null) { var currentSelection = MMI.SelectedTrack; // Deselect old if (MMI.SelectedTrack != null) { MMI.SelectOrDeselectTrack(currentSelection); } var trk = MMI.FindTrack(fdr); if (trk != null) { MMI.SelectOrDeselectTrack(trk); } } break; } PacketReceived?.Invoke(this, new PacketReceivedEventArgs(packet)); Console.WriteLine(packet); }