/// <summary> /// Returns the component listener for the listener passed across. /// </summary> /// <param name="listener"></param> /// <returns></returns> private IMergedFeedComponentListener GetComponentListener(IListener listener) { IMergedFeedComponentListener result = null; if (listener != null) { lock (_SyncLock) { if (_Listeners.Count >= 12) { _ComponentListenersMap.TryGetValue(listener.ReceiverId, out result); } else { for (var i = 0; i < _Listeners.Count; ++i) { var component = _Listeners[i]; if (component.Listener.ReceiverId == listener.ReceiverId) { result = component; break; } } } } } return(result); }
public void TestInitialise() { _Component = Factory.Singleton.Resolve <IMergedFeedComponentListener>(); _Listener = TestUtilities.CreateMockInstance <IListener>(); }
/// <summary> /// Determines whether the message from a receiver can be used. /// </summary> /// <param name="receivedUtc"></param> /// <param name="listener"></param> /// <param name="icao"></param> /// <param name="hasPosition"></param> /// <param name="hasTrack"></param> /// <param name="hasGroundSpeed"></param> /// <param name="positionIsMlat"></param> /// <returns></returns> private FilterMessageOutcome FilterMessageFromListener(DateTime receivedUtc, IListener listener, string icao, bool hasPosition, bool hasTrack, bool hasGroundSpeed, bool positionIsMlat) { var result = FilterMessageOutcome.Failed; icao = icao ?? ""; Source source = null; IMergedFeedComponentListener component = null; lock (_SyncLock) { component = GetComponentListener(listener); if (component != null) { if (!_IcaoSourceMap.TryGetValue(icao, out source)) { source = new Source() { LastMessageUtc = receivedUtc, Component = component, SeenPositionMessage = hasPosition, }; _IcaoSourceMap.Add(icao, source); result = FilterMessageOutcome.Passed; } else { if (source.Component == component) { result = FilterMessageOutcome.Passed; } else { var threshold = receivedUtc.AddMilliseconds(-IcaoTimeout); if (source.LastMessageUtc < threshold) { source.Component = component; result = FilterMessageOutcome.Passed; } } if (result == FilterMessageOutcome.Failed && (hasPosition || hasTrack || hasGroundSpeed) && (positionIsMlat || component.IsMlatFeed)) { result = FilterMessageOutcome.OutOfBand; } switch (result) { case FilterMessageOutcome.OutOfBand: if (hasPosition) { source.SeenPositionMessage = true; } break; case FilterMessageOutcome.Passed: source.LastMessageUtc = receivedUtc; goto case FilterMessageOutcome.OutOfBand; } } } } if (result == FilterMessageOutcome.Passed && IgnoreAircraftWithNoPosition && source != null && !source.SeenPositionMessage) { result = FilterMessageOutcome.Failed; } return(result); }