コード例 #1
0
        //Returns velocity in whole meters per second
        public int CalculateVelocity(TrackObject oldTO, TrackObject newTO)
        {
            TimeSpan timeDiff = newTO.Timestamp - oldTO.Timestamp;
            double   dist     = this.dist.CalculateDistance2D(oldTO.XCoord, newTO.XCoord, oldTO.YCoord, newTO.YCoord);

            return((int)(dist / (timeDiff.TotalMilliseconds / 1000)));    //This will give dist m / timeDiff s
        }
コード例 #2
0
        //Will return true if a Track is in another Track's airspace
        public bool IsInOtherAirSpace(TrackObject TO1, TrackObject TO2)
        {
            double horizontalDistance = dist.CalculateDistance2D(TO1.XCoord, TO2.XCoord, TO1.YCoord, TO2.YCoord);
            int    verticalDistance   = dist.CalculateDistance1D(TO1.Altitude, TO2.Altitude);

            return(horizontalDistance < horizontalSeparation && verticalDistance < verticalSeparation);
        }
コード例 #3
0
        public void LogSeparationEvent(TrackObject TO1, TrackObject TO2)
        {
            string output = "Timestamp: " + TO1.Timestamp + "\t" +
                            TO1.Tag + " and " + TO2.Tag + " are breaking separation rules";

            using (StreamWriter outputFile = new StreamWriter(@"SeparatationEventLog.txt", true))
            {
                outputFile.WriteLine(output);
            }
        }
コード例 #4
0
        //Returns course in whole degrees. North is 0
        public int CalculateCourse(TrackObject oldTO, TrackObject newTO)
        {
            // angle in degrees
            var angleDeg = Math.Atan2(-(newTO.YCoord - oldTO.YCoord), newTO.XCoord - oldTO.XCoord) * 180 / Math.PI;

            angleDeg += 90;

            if (angleDeg < 0)
            {
                angleDeg += 360;
            }

            return((int)angleDeg);
        }
コード例 #5
0
        public void MakeTrack(object sender, RawTransponderDataEventArgs e)
        {
            _trackObjects.Clear();
            foreach (var data in e.TransponderData)                                       //foreach string in the stringlist
            {
                var trackData = _transponderParsing.TransponderParser(data);              //Parse string (contains all track data)

                if (_trackingValidation.IsTrackInMonitoredAirspace(trackData))            //Only if plane is inside the Monitored area
                {
                    var track = new TrackObject(trackData);                               //Make new trackObject
                    track.PrettyTimeStamp = _dateFormatter.FormatTimestamp(trackData[4]); //Add formated date to the Track object

                    _trackObjects.Add(track);                                             //Add the track to the list of Tracks
                }
            }

            if (_trackObjects.Count != 0)   //If there are any trackObjects
            {
                var handler = TrackListReady;
                handler?.Invoke(this, new TrackListEventArgs(_trackObjects));   //Invoke TrackListReady event, containing all the trackObjects
            }
        }