/// <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);
        }
예제 #2
0
파일: Listener.cs 프로젝트: ts295983632/vrs
        /// <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();
                }
            }
        }
예제 #3
0
파일: Feed.cs 프로젝트: J0hnLiu/vrs
        /// <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);
        }
예제 #4
0
        /// <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);
                    }
                }
            }
        }
예제 #5
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="extractor"></param>
 /// <returns></returns>
 public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor)
 {
     return(extractor != null && extractor is ICompressedMessageBytesExtractor);
 }
예제 #6
0
 /// <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);
 }
예제 #8
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="extractor"></param>
 /// <returns></returns>
 public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor)
 {
     return(extractor != null && extractor is IBeastMessageBytesExtractor);
 }
예제 #9
0
 /// <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");
 }
예제 #10
0
 /// <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;
 }
예제 #12
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="extractor"></param>
 /// <returns></returns>
 public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor)
 {
     return(extractor != null && extractor is IPort30003MessageBytesExtractor);
 }
 public CommonMessageBytesExtractorTests(TestContext testContext, IMessageBytesExtractor extractor, ExtractedBytesFormat format)
 {
     TestContext = testContext;
     Extractor = extractor;
     Format = format;
 }
예제 #14
0
 /// <summary>
 /// See interface docs.
 /// </summary>
 /// <param name="extractor"></param>
 /// <returns></returns>
 public bool IsUsableBytesExtractor(IMessageBytesExtractor extractor)
 {
     return(extractor != null && extractor is IAircraftListJsonMessageBytesExtractor);
 }
예제 #15
0
        /// <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);
                }
            }
        }