Exemple #1
0
        private void OnFlightTracksUpdated(object o, MultipleFlightTracksUpdatedEventArgs args)
        {
            //List<IFlightTrackerSingle> allUpdatedFlights = args.UpdatedFlights;
            //List<SeperationEventArgs> activeSeps = Detector.GetActiveSeperations();

            //if (activeSeps.Count == 0){ return; }

            //bool seperationResolved = false;
            //int resolvedSeperationIndex = -1;
            //foreach (var sepEvent in activeSeps)
            //{
            //    for (int i = 0; i < allUpdatedFlights.Count; i++)
            //    {
            //        for (int j = i + 1; j < allUpdatedFlights.Count; j++)
            //        {
            //            IFlightTrackerSingle f1 = allUpdatedFlights[i];
            //            IFlightTrackerSingle f2 = allUpdatedFlights[j];
            //            if (sepEvent.HasSameTagsAs(f1, f2))
            //            {
            //                if (Detector.CheckForSeperationEvent(f1, f2) == null)
            //                {
            //                    seperationResolved = true;
            //                    resolvedSeperationIndex = activeSeps.FindIndex(x => x.HasSameTagsAs(f1, f2));
            //                    Debug.Log("SeperationHandler: Seperation Resolved");
            //                }
            //            }
            //        }
            //    }
            //}
            //if (seperationResolved)
            //{
            //    activeSeps.RemoveAt(resolvedSeperationIndex);
            //    Tracker.FlightTracksUpdated -= OnFlightTracksUpdated;
            //}
        }
Exemple #2
0
        private void OnFlightTracksUpdated(object o, MultipleFlightTracksUpdatedEventArgs args)
        {
            List <IFlightTrackerSingle> allUpdatedFlights = args.UpdatedFlights;

            Content.Clear();

            foreach (var f in allUpdatedFlights)
            {
                if (IsInsideAirspace(f.GetNewestDataPoint(), AirspaceArea))
                {
                    Content.Add(f);
                }
            }

            if (Content.Count == 0)//Should be in monitor
            {
            }
            else
            {
                Console.WriteLine("-------------------Airspace Currently Contains:------------------ ");
                foreach (var f in Content)
                {
                    FTDataPoint dp = f.GetNewestDataPoint();
                    Console.WriteLine("Flight - Tag: " + dp.Tag + " Pos: " + dp.X + "," + dp.Y + Environment.NewLine + "         Altitude: " + dp.Altitude + " Velocity: " + f.GetCurrentVelocity() + " Course: " + f.GetCurrentCourse());
                }
            }


            AirspaceContentUpdated?.Invoke(this, new AirspaceContentEventArgs(Content));
        }
        private void OnFlightTracksUpdated(object o, MultipleFlightTracksUpdatedEventArgs args)
        {
            List <IFlightTrackerSingle> allUpdatedFlights = args.UpdatedFlights;

            for (int i = 0; i < allUpdatedFlights.Count; i++)
            {
                for (int j = i + 1; j < allUpdatedFlights.Count; j++)
                {
                    IFlightTrackerSingle f1 = allUpdatedFlights[i];
                    IFlightTrackerSingle f2 = allUpdatedFlights[j];
                    SeperationEventArgs  detectedSeperation = CheckForSeperationEvent(f1, f2);
                    if (detectedSeperation != null)
                    {
                        Debug.Log("Current SeperationEvent between " + detectedSeperation.FlightA.GetTag() + " and " + detectedSeperation.FlightB.GetTag() + "started at time: " + detectedSeperation.TimeOfOccurance);
                        if (!ActiveSeperations.Exists(x => x.HasSameTagsAs(detectedSeperation)))
                        {
                            Console.WriteLine("A SeperationEvent has just been identified" + detectedSeperation.FlightA.GetTag() + " and " + detectedSeperation.FlightB.GetTag() + "started at time: " + detectedSeperation.TimeOfOccurance);
                            ActiveSeperations.Add(detectedSeperation);
                            //SeperationIdentified?.Invoke(this, detectedSeperation);
                            SeperationsUpdatedEventArgs a = new SeperationsUpdatedEventArgs(ActiveSeperations);
                            SeperationEventsUpdated?.Invoke(this, a);
                        }
                        else
                        {
                            //Debug.Log("SeperationController: SeperationEvent still going on, somebody do something!");
                        }
                    }
                }
            }

            if (ActiveSeperations.Count > 0)
            {
                bool seperationResolved      = false;
                int  resolvedSeperationIndex = -1;
                foreach (var sepEvent in ActiveSeperations)
                {
                    for (int i = 0; i < allUpdatedFlights.Count; i++)
                    {
                        for (int j = i + 1; j < allUpdatedFlights.Count; j++)
                        {
                            IFlightTrackerSingle f1 = allUpdatedFlights[i];
                            IFlightTrackerSingle f2 = allUpdatedFlights[j];
                            if (sepEvent.HasSameTagsAs(f1, f2))
                            {
                                if (CheckForSeperationEvent(f1, f2) == null)
                                {
                                    resolvedSeperationIndex = ActiveSeperations.FindIndex(x => x.HasSameTagsAs(f1, f2));
                                    Debug.Log("SeperationHandler: Seperation between" + sepEvent.FlightA.GetTag() + " and " + sepEvent.FlightB.GetTag() + " resolved!");
                                }
                            }
                        }
                    }
                }
                if (seperationResolved)
                {
                    ActiveSeperations.RemoveAt(resolvedSeperationIndex);
                }
            }
            if (ActiveSeperations.Count == 0)
            {
            }
            else
            {
                Console.WriteLine("---------------------Current Seperation Events:------------------- ");
                foreach (var f in ActiveSeperations) //Should be in monitor
                {
                    Console.WriteLine("SeperationEvent involving " + f.FlightA.GetTag() + " and " + f.FlightB.GetTag() + ", started at time: " + f.TimeOfOccurance);
                }
            }
        }