예제 #1
0
        public void EventDetectedUsingIGCFile(string path, string airfield, int landingAfterSeconds, AircraftTrackEventTypes evtType)
        {
            var beacons = IGCAircraftBeaconReader.ReadFromIGCFile(path, 0x0A000001); // simulate fifo collection
            var beaconsBuffer = new CircularFifoBuffer<AircraftBeaconSpeedAndTrack>(beacons.Count() - 4); // gice the circular buffer a chance to fill the internal buffer
            var events = new List<AircraftTrackEvent>();

            int i = 0;
            foreach (var beacon in beacons)
            {
                beaconsBuffer.Enqueue(new AircraftBeaconSpeedAndTrack(beacon));
                if (i++ % 5 == 0) // analyse with sliding window after some beacons - in normale use triggered by timer.
                {
                    var pseudoTimeEvalDateTime = beacon.PositionTimeUTC.AddSeconds(10);
                    beaconsBuffer.AnalyseSpeedAndTrack(pseudoTimeEvalDateTime, TimeSpan.FromSeconds(60));
                    events.AddRange(beaconsBuffer.DetectTrackEvents(pseudoTimeEvalDateTime, TimeSpan.FromSeconds(60), testAirfields[airfield]));
                }
            }

            var expectedDateTime = beacons.First().PositionTimeUTC + TimeSpan.FromSeconds(landingAfterSeconds);
            var expectedEvents = events.Distinct(new AircraftTrackEventComparer()).Where(e => e.EventType == evtType && e.EventDateTimeUTC == expectedDateTime);

            Assert.True(expectedEvents.Any());
        }