private void DataReceived(object sender, ATMSEventArgs e)
        {
            //For each track
            foreach (var track in e.Tracks)
            {
                // Compare with all other tracks
                foreach (var t in e.Tracks)
                {
                    if (track != t)
                    {
                        if (CheckIfInList(track, t) == false)
                        {
                            CheckForCondition(track, t);
                        }
                        else if (CheckIfInList(track, t))
                        {
                            RemoveIfNoLongerCondition(track, t);
                        }
                    }
                }
            }

            // Creation of args for renderer event
            if (_listOfConditionTracks.Count != 0)
            {
                var args = new RendEventArgs();
                args.ListOfCurrentConditions = _SepCondEventArgsList;
                args.TimeOfEvent             = DateTime.Now;

                RendererWarning?.Invoke(this, args);
            }
        }
Example #2
0
        //When ReceiverClient events
        private void OnReceiverClientEvent(object sender, DataEventArgs e)
        {
            foreach (var track in e.Tracks)
            {
                // Look for track in list of tracks in airspace
                var   foundTrack      = _airCraftsInAirspaceList.Find(ByTag(track.Tag));
                Track trackToValidate = null;
                // If already in list - update speed and coordinates.
                if (foundTrack != null)
                {
                    double trackSeconds      = (track.Time.Minute * 60) + track.Time.Second;
                    double foundTrackSeconds = (foundTrack.Time.Minute * 60) + foundTrack.Time.Second;

                    // Workaround
                    TimeSpan differenceTime = track.Time.Subtract(foundTrack.Time);


                    var velocity = _trackCalculator.CalculateVelocity(foundTrack.XCoordinate, track.XCoordinate,
                                                                      foundTrack.YCoordinate, track.YCoordinate,
                                                                      foundTrack.Altitude, track.Altitude,
                                                                      0, differenceTime.TotalSeconds);

                    var compassCourse = _trackCalculator.CalculateCourse(foundTrack.XCoordinate, track.XCoordinate,
                                                                         foundTrack.YCoordinate, track.YCoordinate);

                    var newTrack = new Track(foundTrack.Tag, track.XCoordinate, track.YCoordinate,
                                             track.Altitude, track.Time, velocity, compassCourse);

                    _airCraftsInAirspaceList.Remove(foundTrack);
                    _airCraftsInAirspaceList.Add(newTrack);
                    trackToValidate = newTrack;
                }

                // If not in list - add it    This should be tested - intellisense says expression is always true
                else if (foundTrack == null)
                {
                    _airCraftsInAirspaceList.Add(track);
                    trackToValidate = track;
                }

                // If outside airspace, remove it.
                bool inAirSpace = _monitoredAirspace.ValidateAirspace(trackToValidate);
                if (!inAirSpace)
                {
                    _airCraftsInAirspaceList.Remove(trackToValidate);
                }
            }

            // Pass on Tracks in monitored airspace if not empty
            if (_airCraftsInAirspaceList.Count != 0)
            {
                var args = new ATMSEventArgs();
                args.Tracks = _airCraftsInAirspaceList;

                // Raise event if somebody has "subscribed" to it
                DataReady?.Invoke(this, args);
            }
        }
 private void OnDataReadyInATMS(object sender, ATMSEventArgs e)
 {
     RenderAirCrafts(e.Tracks, true);
 }