public void CheckDistance(object sender, SeperationEventArgs e) { _planelist = e.CalcedInfo; PrintToConsole(_planelist); DistanceChecker(_planelist); }
public void OnSeperation(object sender, SeperationEventArgs e) { if (!ConsoleOut) return; var seperationAlert = new SeperationAlert(e.Tag1, e.Tag2, e.Time); SeperationAlertRepository.Add(seperationAlert); }
private void Log(object sender, SeperationEventArgs args) { string fullDirectory = @"...\...\...\"; using (FileStream output = new FileStream(fullDirectory + "/SeperationLogFile.txt", FileMode.Append, FileAccess.Write)) using (StreamWriter fileWriter = new StreamWriter(output)) { fileWriter.WriteLine("Flights in Conflict: " + args.Tracks[0].Tag + ", " + args.Tracks[1].Tag + " \nTime stamp of conflict: " + args.Tracks[0].Timestamp.Year + "/" + args.Tracks[0].Timestamp.Month + "/" + args.Tracks[0].Timestamp.Day + ", at " + args.Tracks[0].Timestamp.Hour + ":" + args.Tracks[0].Timestamp.Minute + ":" + args.Tracks[0].Timestamp.Second + " and " + args.Tracks[0].Timestamp.Millisecond + " milliseconds"); fileWriter.Close(); } _output.Write(args.Tracks, true); }
public void OnSeperation_FireEvent_AddSeperationEvent() { _uut.Seperation = Substitute.For <ISeperation>(); _uut.SeperationAlertRepository = Substitute.For <ISeperationAlertRepository>(); var seperationEvent = new SeperationEventArgs("Plane1", DateTime.Now, "Plane2"); _uut.Seperation.SeperationEvent += Raise.EventWith(new object(), seperationEvent); var seperationAlert = new SeperationAlert(seperationEvent.Tag1, seperationEvent.Tag2, seperationEvent.Time); // Something is wrong // TODO: _uut.SeperationAlertRepository.Received(0).Add(seperationAlert); }
private void OnSeperationIdentified(object o, SeperationEventArgs args) { Debug.Log("SeperationHandler: Handling SeperationIdentified Event"); //if (Detector.GetActiveSeperations().Count > 0) //{ // Tracker.FlightTracksUpdated += OnFlightTracksUpdated; //} //while (args.HasSameTagsAs()) //{ //} //SeperationResolvedSignal.WaitOne(); //This thread will block here until the reset event is sent. //SeperationResolvedSignal.Reset(); // }
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); } } }
public void SetUp() { _fakeTrackInfo = Substitute.For <ITrackInfo>(); _uut = new DataCalculator(_fakeTrackInfo); _uut.CalcedDataReady += (o, a) => { output = a; }; }