/// <summary> /// Creates and configures the message bytes extractor to use to get the message bytes out of the feed. /// </summary> /// <param name="config"></param> /// <returns></returns> private IMessageBytesExtractor DetermineBytesExtractor(Configuration config) { IMessageBytesExtractor result = Listener.BytesExtractor; switch (config.BaseStationSettings.DataSource) { case DataSource.Beast: if (result == null || !(result is IBeastMessageBytesExtractor)) { result = Factory.Singleton.Resolve <IBeastMessageBytesExtractor>(); } break; case DataSource.Port30003: if (result == null || !(result is IPort30003MessageBytesExtractor)) { result = Factory.Singleton.Resolve <IPort30003MessageBytesExtractor>(); } break; case DataSource.Sbs3: if (result == null || !(result is ISbs3MessageBytesExtractor)) { result = Factory.Singleton.Resolve <ISbs3MessageBytesExtractor>(); } break; default: throw new NotImplementedException(); } return(result); }
/// <summary> /// See interface docs. /// </summary> /// <param name="connector"></param> /// <param name="bytesExtractor"></param> /// <param name="rawMessageTranslator"></param> public void ChangeSource(IConnector connector, IMessageBytesExtractor bytesExtractor, IRawMessageTranslator rawMessageTranslator) { var changed = false; var reconnect = false; lock (_SyncLock) { reconnect = Connector != null && Connector.EstablishingConnections; if (connector != Connector || bytesExtractor != BytesExtractor || rawMessageTranslator != RawMessageTranslator) { if (RawMessageTranslator != null && RawMessageTranslator != rawMessageTranslator) { RawMessageTranslator.Dispose(); } if (Connector != connector) { if (Connector != null) { UnhookConnector(); Connector.Dispose(); } Connector = connector; Connector.IsSingleConnection = true; HookConnector(); } BytesExtractor = bytesExtractor; RawMessageTranslator = rawMessageTranslator; if (RawMessageTranslator != null) { RawMessageTranslator.Statistics = Statistics; } TotalMessages = 0; TotalBadMessages = 0; changed = true; } } if (changed) { OnSourceChanged(EventArgs.Empty); if (reconnect) { Connect(); } } }
/// <summary> /// Creates and configures the message bytes extractor to use to get the message bytes out of the feed. /// </summary> /// <param name="receiver"></param> /// <returns></returns> private IMessageBytesExtractor DetermineBytesExtractor(Receiver receiver) { IMessageBytesExtractor result = Listener.BytesExtractor; var provider = _ReceiverFormatManager.GetProvider(receiver.DataSource); if (provider == null) { throw new InvalidOperationException($"There is no receiver format provider registered with a unique ID of {receiver.DataSource}"); } if (result == null || !provider.IsUsableBytesExtractor(result)) { result = provider.CreateMessageBytesExtractor(); } return(result); }
/// <summary> /// See interface docs. /// </summary> /// <param name="provider"></param> /// <param name="bytesExtractor"></param> /// <param name="rawMessageTranslator"></param> /// <param name="autoReconnect"></param> public void ChangeSource(IListenerProvider provider, IMessageBytesExtractor bytesExtractor, IRawMessageTranslator rawMessageTranslator, bool autoReconnect) { lock (_SyncLock) { bool changed = false; if (provider != Provider || bytesExtractor != BytesExtractor || rawMessageTranslator != RawMessageTranslator) { if (Provider != null) { Disconnect(); } if (RawMessageTranslator != null && RawMessageTranslator != rawMessageTranslator) { RawMessageTranslator.Dispose(); } Provider = provider; BytesExtractor = bytesExtractor; RawMessageTranslator = rawMessageTranslator; TotalMessages = 0; TotalBadMessages = 0; changed = true; } if (changed) { OnSourceChanged(EventArgs.Empty); if (autoReconnect) { Connect(false); } } } }
/// <summary> /// See interface docs. /// </summary> /// <param name="extractor"></param> /// <returns></returns> public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor) { return(extractor != null && extractor is ICompressedMessageBytesExtractor); }
/// <summary> /// See interface docs. /// </summary> /// <param name="extractor"></param> /// <returns></returns> public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor) { return(extractor != null && extractor is IAirnavXRangeMessageBytesExtractor); }
/// <summary> /// See interface docs. /// </summary> /// <param name="extractor"></param> /// <returns></returns> public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor) { return(extractor != null && extractor is IPlaneFinderMessageBytesExtractor); }
/// <summary> /// See interface docs. /// </summary> /// <param name="extractor"></param> /// <returns></returns> public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor) { return(extractor != null && extractor is IBeastMessageBytesExtractor); }
/// <summary> /// See interface docs. /// </summary> /// <param name="connector"></param> /// <param name="bytesExtractor"></param> /// <param name="rawMessageTranslator"></param> public void ChangeSource(IConnector connector, IMessageBytesExtractor bytesExtractor, IRawMessageTranslator rawMessageTranslator) { throw new InvalidOperationException("You cannot call ChangeSource on a merged feed listener"); }
/// <summary> /// See interface docs. /// </summary> /// <param name="connector"></param> /// <param name="bytesExtractor"></param> /// <param name="rawMessageTranslator"></param> public void ChangeSource(IConnector connector, IMessageBytesExtractor bytesExtractor, IRawMessageTranslator rawMessageTranslator) { _Original.ChangeSource(connector, bytesExtractor, rawMessageTranslator); }
public CommonMessageBytesExtractorTests(TestContext testContext, IMessageBytesExtractor extractor, ExtractedBytesFormat format) { TestContext = testContext; Extractor = extractor; Format = format; }
/// <summary> /// See interface docs. /// </summary> /// <param name="extractor"></param> /// <returns></returns> public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor) { return(extractor != null && extractor is IPort30003MessageBytesExtractor); }
/// <summary> /// See interface docs. /// </summary> /// <param name="extractor"></param> /// <returns></returns> public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor) { return(extractor != null && extractor is IAircraftListJsonMessageBytesExtractor); }
/// <summary> /// See interface docs. /// </summary> /// <param name="provider"></param> /// <param name="bytesExtractor"></param> /// <param name="rawMessageTranslator"></param> /// <param name="autoReconnect"></param> public void ChangeSource(IListenerProvider provider, IMessageBytesExtractor bytesExtractor, IRawMessageTranslator rawMessageTranslator, bool autoReconnect) { lock(_SyncLock) { bool changed = false; if(provider != Provider || bytesExtractor != BytesExtractor || rawMessageTranslator != RawMessageTranslator) { if(Provider != null) Disconnect(); if(RawMessageTranslator != null && RawMessageTranslator != rawMessageTranslator) RawMessageTranslator.Dispose(); Provider = provider; BytesExtractor = bytesExtractor; RawMessageTranslator = rawMessageTranslator; TotalMessages = 0; TotalBadMessages = 0; changed = true; } if(changed) { OnSourceChanged(EventArgs.Empty); if(autoReconnect) Connect(false); } } }