Пример #1
0
        public double CalculateDegree(AircraftData newPosition, AircraftData oldPosition)
        {
            double vektorX = newPosition.X_coordinate - oldPosition.X_coordinate;
            double vektorY = newPosition.Y_coordinate - oldPosition.Y_coordinate;


            double angel = (Math.Atan(vektorY / vektorX) * (180 / Math.PI));

            if (vektorX < 0)
            {
                angel += 180 - 90;
            }
            else if (vektorY < 0)
            {
                angel += 360 - 90;
            }
            else
            {
                if ((angel - 90) < 0)
                {
                    angel += 360 - 90;
                }
            }

            // this calculation works for at Compas that are Anti-Clockwise

            // We can flip this by doing : 360-angle

            return(360 - angel);
        }
Пример #2
0
        public int ConvertTimeToMilliseconds(AircraftData obj)
        {
            int hour  = obj.TimeStamp.hour * 60 * 60 * 1000;
            int minut = obj.TimeStamp.min * 60 * 1000;
            int sec   = obj.TimeStamp.sec * 1000;

            return(hour + minut + sec + obj.TimeStamp.ms);
        }
Пример #3
0
 public bool CheckIfTrackIsGoneFromAirspace(AircraftData OldTrack)
 {
     foreach (var item in _FilteredAircrafts)
     {
         if (item.Tag == OldTrack.Tag)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #4
0
 public bool CheckIfTrackIsNewInAirspace(AircraftData track)
 {
     foreach (var item in _OldFilteredAircrafts)
     {
         if (item.Tag == track.Tag)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #5
0
        public bool CheckForCollision(AircraftData obj1, AircraftData obj2)
        {
            int AltDiff = Math.Abs(obj1.Altitude - obj2.Altitude);
            int Dist    = _utility.CalcDistance(obj1, obj2);

            if (AltDiff <= 300 && Dist <= 5000)
            {
                return(true);
            }

            return(false);
        }
Пример #6
0
        public void OutputTrackLeftAirSpaceEventHandler(object o, AircraftData track)
        {
            Thread t1 = new Thread(new ThreadStart(() =>
            {
                lock (ExitLock)
                {
                    TrackLeftAirSpaceTasks.Add(track);
                }

                Thread.Sleep(5000);

                lock (ExitLock)
                {
                    TrackLeftAirSpaceTasks.Remove(track);
                }
            }));

            t1.Start();
        }
Пример #7
0
 public void LogSeperationEvent(AircraftData a1, AircraftData a2)
 {
     File.AppendAllText(@"log.txt", $"WARNING! Possible collision between flight {a1.Tag} and {a2.Tag}."
                        + Environment.NewLine + a1.ToString() + Environment.NewLine + a2.ToString() + Environment.NewLine + Environment.NewLine);
 }
Пример #8
0
        public double Speed(AircraftData newPosition, AircraftData oldPosition)
        {
            int timeDiff = Math.Abs(ConvertTimeToMilliseconds(newPosition) - ConvertTimeToMilliseconds(oldPosition));

            return(CalcDistance(newPosition, oldPosition) / ((double)timeDiff / 1000));
        }
Пример #9
0
 public int CalcDistance(AircraftData obj1, AircraftData obj2)
 {
     return((int)Math.Sqrt(Math.Pow((double)(obj2.X_coordinate - obj1.X_coordinate), 2) +
                           Math.Pow((double)(obj2.Y_coordinate - obj1.Y_coordinate), 2)));
 }