Exemple #1
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));
        }
Exemple #2
0
 private void OnAirspaceContentUpdated(object o, AirspaceContentEventArgs args)
 {
     Debug.Log("Monitor: Handling TransponderDataReady Event");
     foreach (var f in args.UpdatedFlights)
     {
         FTDataPoint dp = f.GetNewestDataPoint();
         Console.WriteLine("Tag: " + dp.Tag + " Pos: " + dp.X + "," + dp.Y + " Altitude: " + dp.Altitude + " Time: " + dp.TimeStamp + " Velocity: " + f.GetCurrentVelocity());
     }
 }
Exemple #3
0
        //public event EventHandler<FlightTrackUpdatedEventArgs> FlightTrackUpdated;

        public Flight(FTDataPoint first)
        {
            _tag             = first.Tag;
            _currentPosition = new Vector2(first.X, first.Y);
            _currentAltitude = first.Altitude;
            _lastUpdated     = first.TimeStamp;

            _trackDataLog       = new LinkedList <FTDataPoint>();
            _velocityCalculator = new FlightVelocityCalculator();
            _courseCalculator   = new FlightCourseCalculator();
        }
Exemple #4
0
 public Flight(FTDataPoint first)
 {
     Tag             = first.Tag;
     CurrentPosition = new Vector2(first.X, first.Y);
     CurrentAltitude = first.Altitude;
     LastUpdated     = first.TimeStamp;
     //TrackDataLog = new SortedList<DateTime, FTDataPoint>();
     TrackDataLog       = new LinkedList <FTDataPoint>();
     VelocityCalculator = new FlightVelocityCalculator(this);
     CourseCalculator   = new FlightCourseCalculator(this);
 }
Exemple #5
0
        public List <FTDataPoint> ConvertTransponderData(RawTransponderDataEventArgs args)
        {
            var DpList = new List <FTDataPoint>();

            foreach (var rawdatastring in args.TransponderData)
            {
                FTDataPoint dp = ConvertTransponderString(rawdatastring);
                DpList.Add(dp);
            }
            Debug.Log("DataReader: Converted " + DpList.Count + " strings");
            return(DpList);
        }
Exemple #6
0
        public void AddDataPoint(FTDataPoint dp)
        {
            Tag = dp.Tag;
            CurrentPosition.X = dp.X;
            CurrentPosition.Y = dp.Y;
            CurrentAltitude   = dp.Altitude;
            LastUpdated       = dp.TimeStamp;

            //TrackDataLog.Add(dp.TimeStamp, dp);
            TrackDataLog.AddFirst(dp);
            CurrentVelocity = VelocityCalculator.GetCurrentVelocity(TrackDataLog);
            CurrentCourse   = CourseCalculator.GetCurrentCourse(TrackDataLog);
        }
Exemple #7
0
 public bool IsInsideAirspace(FTDataPoint dp, AirspaceArea area)
 {
     if (dp.Altitude > area.AltitudeBoundaryLower && dp.Altitude < area.AltitudeBoundaryUpper &&
         dp.X > area.SouthWestCornerX && dp.X < area.NorthEastCornerX &&
         dp.Y > area.SouthWestCornerY && dp.Y < area.NorthEastCornerY)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #8
0
        public FTDataPoint ConvertTransponderString(string rawdata)
        {
            var dp = new FTDataPoint();

            string[] splitdata = rawdata.Split(';');

            dp.Tag       = splitdata[0];
            dp.X         = Int32.Parse(splitdata[1]);
            dp.Y         = Int32.Parse(splitdata[2]);
            dp.Altitude  = Int32.Parse(splitdata[3]);
            dp.TimeStamp = DateTime.ParseExact(splitdata[4], "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture);

            return(dp);
        }
Exemple #9
0
 public int CompareTo(FTDataPoint other)
 {
     if (this.TimeStamp > other.TimeStamp)
     {
         return(1);
     }
     else if (this.TimeStamp < other.TimeStamp)
     {
         return(-1);
     }
     else
     {
         return(0);
     }
 }
Exemple #10
0
        public FTDataPoint ConvertTransponderString(string rawdata)
        {
            //Todo: tilføj data validation (antal semikoloner, længde på elementer, allowed characters etc)
            var dp = new FTDataPoint();

            string[] splitdata = rawdata.Split(';');

            dp.Tag       = splitdata[0];
            dp.X         = Int32.Parse(splitdata[1]);
            dp.Y         = Int32.Parse(splitdata[2]);
            dp.Altitude  = Int32.Parse(splitdata[3]);
            dp.TimeStamp = DateTime.ParseExact(splitdata[4], "yyyyMMddHHmmssfff", CultureInfo.InvariantCulture);

            return(dp);
        }
Exemple #11
0
        public string GenerateAirspaceFlightList(List <IFlightTrack> flights)
        {
            string airspaceflightlist = "TAG\tPOSX\tPOSY\tALT\tTIME\tVEL\tCOURSE\n";

            foreach (var flight in flights)
            {
                FTDataPoint dp = flight.GetNewestDataPoint();
                airspaceflightlist += dp.Tag + "\t"
                                      + dp.X + "\t"
                                      + dp.Y + "\t"
                                      + dp.Altitude + "\t"
                                      + dp.TimeStamp.ToShortTimeString() + "\t"
                                      + flight.GetCurrentVelocity().ToString("0.00") + "\t"
                                      + flight.GetCurrentCourse().ToString("0.00") + "\n";
            }

            return(airspaceflightlist);
        }
Exemple #12
0
        public void AddDataPoint(FTDataPoint new_dp)
        {
            _tag = new_dp.Tag;
            _currentPosition.X = new_dp.X;
            _currentPosition.Y = new_dp.Y;
            _currentAltitude   = new_dp.Altitude;
            _lastUpdated       = new_dp.TimeStamp;

            FTDataPoint previous_dp = _trackDataLog.Count != 0 ? _trackDataLog.First() : null;

            _trackDataLog.AddFirst(new_dp);

            Vector2 previous_position = (previous_dp != null) ? new Vector2(previous_dp.X, previous_dp.Y) : Vector2.Zero;
            Vector2 current_position  = new Vector2(new_dp.X, new_dp.Y);

            _currentVelocity = _velocityCalculator.CalculateCurrentVelocity(
                previous_position,
                previous_dp?.TimeStamp,
                current_position,
                new_dp.TimeStamp
                );
            _currentCourse = _courseCalculator.CalculateCurrentCourse(previous_position, current_position);
        }
Exemple #13
0
        public FTDataPoint GetNewestDataPoint()
        {
            FTDataPoint newest = TrackDataLog.First();//.Value;

            return(newest);
        }