Exemplo n.º 1
0
        /// <summary>
        /// See base docs.
        /// </summary>
        protected override void DoInitialise()
        {
            _AutoConfigDatabase = Factory.Singleton.Resolve <IAutoConfigBaseStationDatabase>().Singleton;
            _AutoConfigDatabase.Database.AircraftUpdated += BaseStationDatabase_AircraftUpdated;
            _AutoConfigDatabase.Database.FileNameChanged += BaseStationDatabase_FileNameChanged;

            _AircraftOnlineLookupManager = Factory.Singleton.Resolve <IAircraftOnlineLookupManager>().Singleton;
            _AircraftOnlineLookupManager.AircraftFetched += AircraftOnlineLookupManager_AircraftFetched;

            _PictureManager = Factory.Singleton.Resolve <IAircraftPictureManager>().Singleton;
            var autoConfigurationPictureFolderCache = Factory.Singleton.Resolve <IAutoConfigPictureFolderCache>().Singleton;

            _PictureFolderCache = autoConfigurationPictureFolderCache.DirectoryCache;
            autoConfigurationPictureFolderCache.CacheConfigurationChanged += AutoConfigPictureFolderCache_CacheConfigurationChanged;

            _StandingDataManager = Factory.Singleton.Resolve <IStandingDataManager>().Singleton;
            _StandingDataManager.LoadCompleted += StandingDataManager_LoadCompleted;

            if (_PictureLookupThread == null)
            {
                _PictureLookupThread = new BackgroundThreadQueue <LookupPictureDetail>("PictureLookup", BackgroundThreadQueueMechanism.ThreadPool);
                _PictureLookupThread.MaximumParallelThreads = 10;
                _PictureLookupThread.StartBackgroundThread(PictureLookupThread_ProcessLookup, PictureLookupThread_ProcessException);
            }

            base.DoInitialise();
        }
Exemplo n.º 2
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="parameters"></param>
        public void Startup(PluginStartupParameters parameters)
        {
            lock (_SyncLock) {
                var optionsStorage = new OptionsStorage();
                _Options = optionsStorage.Load(this);

                _Database = Factory.Singleton.Resolve <IAutoConfigBaseStationDatabase>().Singleton.Database;
                _Database.FileNameChanging += BaseStationDatabase_FileNameChanging;
                _Database.FileNameChanged  += BaseStationDatabase_FileNameChanged;

                _StandingDataManager = Factory.Singleton.Resolve <IStandingDataManager>().Singleton;
                _StandingDataManager.LoadCompleted += StandingDataManager_LoadCompleted;

                StartSession();

                // If we process messages on the same thread as IAutoConfigListener raises the message received event on then we
                // will be running on the same thread as the aircraft list. Our processing can take some time, particularly if many
                // database writes have to happen simultaneously on startup, so to avoid blocking the update of the aircraft list
                // we create a background thread and process the messages on that.
                _BackgroundThreadMessageQueue = new BackgroundThreadQueue <BaseStationMessageEventArgs>("BaseStationDatabaseWriterMessageQueue");
                _BackgroundThreadMessageQueue.StartBackgroundThread(MessageQueue_MessageReceived, MessageQueue_ExceptionCaught);
                var listener = Factory.Singleton.Resolve <IAutoConfigListener>().Singleton.Listener;
                listener.Port30003MessageReceived += MessageListener_MessageReceived;
                listener.SourceChanged            += MessageListener_SourceChanged;

                Factory.Singleton.Resolve <IHeartbeatService>().Singleton.SlowTick += Heartbeat_SlowTick;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public Listener()
        {
            _Statistics = Factory.Singleton.Resolve <IStatistics>().Singleton;

            _Port30003MessageTranslator = Factory.Singleton.Resolve <IBaseStationMessageTranslator>();
            _ModeSMessageTranslator     = Factory.Singleton.Resolve <IModeSTranslator>();
            _AdsbMessageTranslator      = Factory.Singleton.Resolve <IAdsbTranslator>();
            _ModeSParity = Factory.Singleton.Resolve <IModeSParity>();

            var messageQueueName = String.Format("MessageProcessingAndDispatchQueue_{0}", ++_ListenerCounter);

            _MessageProcessingAndDispatchQueue = new BackgroundThreadQueue <MessageDispatch>(messageQueueName);
            _MessageProcessingAndDispatchQueue.StartBackgroundThread(ProcessAndDispatchMessageQueueItem, HandleMessageDispatchException);
        }
Exemplo n.º 4
0
        #pragma warning restore 0067
        #endregion
        #endregion

        #region Constructor, finaliser
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public MergedFeedListener()
        {
            _Clock           = Factory.Resolve <IClock>();
            Listeners        = new ReadOnlyCollection <IMergedFeedComponentListener>(_Listeners);
            IcaoTimeout      = 5000;
            ConnectionStatus = ConnectionStatus.Connected;

            var messageQueueName = String.Format("MergedFeedListenerMessages_{0}", ++_ListenerCounter);

            _MessageProcessingQueue = new BackgroundThreadQueue <MessageReceived>(messageQueueName, 200000);
            _MessageProcessingQueue.StartBackgroundThread(ProcessReceivedMessage, HandleMessageProcessingException);

            var heartbeatService = Factory.ResolveSingleton <IHeartbeatService>();

            heartbeatService.SlowTick += HeartbeatService_SlowTick;
            _HookedSlowTick            = true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        /// <param name="connector"></param>
        /// <param name="initialStatus"></param>
        public Connection(Connector connector, ConnectionStatus initialStatus)
        {
            if (connector == null)
            {
                throw new ArgumentNullException("connector");
            }
            _Connector = connector;

            Created = DateTime.UtcNow;

            string operationQueueName;

            lock (_SyncLock) {
                operationQueueName = String.Format("ConnectionOpQueue-{0}-{1}", _Connector.Name ?? "unnamed", ++_ConnectionCount);
            }
            _OperationQueue = new BackgroundThreadQueue <ReadWriteOperation>(operationQueueName, BackgroundThreadQueueMechanism.QueueWithNoBlock, 200000);
            _OperationQueue.StartBackgroundThread(OperationQueue_ProcessOperation, OperationQueue_ProcessException);

            ConnectionStatus = initialStatus;
        }
Exemplo n.º 6
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="parameters"></param>
        public void Startup(PluginStartupParameters parameters)
        {
            Singleton = this;

            lock (_SyncLock) {
                var optionsStorage = new OptionsStorage();
                _Options = optionsStorage.Load();

                _Database = Factory.Singleton.Resolve <IAutoConfigBaseStationDatabase>().Singleton.Database;
                _Database.FileNameChanging += BaseStationDatabase_FileNameChanging;
                _Database.FileNameChanged  += BaseStationDatabase_FileNameChanged;

                _StandingDataManager = Factory.Singleton.Resolve <IStandingDataManager>().Singleton;
                _StandingDataManager.LoadCompleted += StandingDataManager_LoadCompleted;

                var feedManager = Factory.Singleton.Resolve <IFeedManager>().Singleton;
                feedManager.FeedsChanged += FeedManager_FeedsChanged;

                _OnlineLookupCache          = Provider.CreateOnlineLookupCache();
                _OnlineLookupCache.Database = _Database;
                _OnlineLookupCache.RefreshOutOfDateAircraft = _Options.RefreshOutOfDateAircraft;
                _OnlineLookupCache.EnabledChanged          += OnlineLookupCache_EnabledChanged;
                StartSession();

                var onlineLookupManager = Factory.Singleton.Resolve <IAircraftOnlineLookupManager>().Singleton;
                onlineLookupManager.RegisterCache(_OnlineLookupCache, 100, letManagerControlLifetime: false);

                // If we process messages on the same thread as the listener raises the message received event on then we
                // will be running on the same thread as the aircraft list. Our processing can take some time, particularly if many
                // database writes have to happen simultaneously on startup, so to avoid blocking the update of the aircraft list
                // we create a background thread and process the messages on that.
                _BackgroundThreadMessageQueue = new BackgroundThreadQueue <BaseStationMessageEventArgs>("BaseStationDatabaseWriterMessageQueue", 200000);
                _BackgroundThreadMessageQueue.StartBackgroundThread(MessageQueue_MessageReceived, MessageQueue_ExceptionCaught);

                HookFeed();

                _HeartbeatService           = Factory.Singleton.Resolve <IHeartbeatService>();
                _HeartbeatService.SlowTick += Heartbeat_SlowTick;
                _HeartbeatService.Start();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public Listener()
        {
            _Clock     = Factory.Singleton.Resolve <IClock>();
            Statistics = Factory.Singleton.Resolve <IStatistics>();
            Statistics.Initialise();

            _Port30003MessageTranslator = Factory.Singleton.Resolve <IBaseStationMessageTranslator>();
            _ModeSMessageTranslator     = Factory.Singleton.Resolve <IModeSTranslator>();
            _AdsbMessageTranslator      = Factory.Singleton.Resolve <IAdsbTranslator>();
            _ModeSParity = Factory.Singleton.Resolve <IModeSParity>();
            _Compressor  = Factory.Singleton.Resolve <IBaseStationMessageCompressor>();
            _AircraftListJsonMessageConverter = Factory.Singleton.Resolve <IAircraftListJsonMessageConverter>();

            _ModeSMessageTranslator.Statistics = Statistics;
            _AdsbMessageTranslator.Statistics  = Statistics;

            var messageQueueName = String.Format("MessageProcessingAndDispatchQueue_{0}", ++_ListenerCounter);

            _MessageProcessingAndDispatchQueue = new BackgroundThreadQueue <MessageDispatch>(messageQueueName, 200000);
            _MessageProcessingAndDispatchQueue.StartBackgroundThread(ProcessAndDispatchMessageQueueItem, HandleMessageDispatchException);
        }
Exemplo n.º 8
0
        /// <summary>
        /// See interface docs.
        /// </summary>
        /// <param name="parameters"></param>
        public void Startup(PluginStartupParameters parameters)
        {
            lock(_SyncLock) {
                var optionsStorage = new OptionsStorage();
                _Options = optionsStorage.Load(this);

                _Database = Factory.Singleton.Resolve<IAutoConfigBaseStationDatabase>().Singleton.Database;
                _Database.FileNameChanging += BaseStationDatabase_FileNameChanging;
                _Database.FileNameChanged += BaseStationDatabase_FileNameChanged;

                _StandingDataManager = Factory.Singleton.Resolve<IStandingDataManager>().Singleton;
                _StandingDataManager.LoadCompleted += StandingDataManager_LoadCompleted;

                StartSession();

                // If we process messages on the same thread as IAutoConfigListener raises the message received event on then we
                // will be running on the same thread as the aircraft list. Our processing can take some time, particularly if many
                // database writes have to happen simultaneously on startup, so to avoid blocking the update of the aircraft list
                // we create a background thread and process the messages on that.
                _BackgroundThreadMessageQueue = new BackgroundThreadQueue<BaseStationMessageEventArgs>("BaseStationDatabaseWriterMessageQueue");
                _BackgroundThreadMessageQueue.StartBackgroundThread(MessageQueue_MessageReceived, MessageQueue_ExceptionCaught);
                var listener = Factory.Singleton.Resolve<IAutoConfigListener>().Singleton.Listener;
                listener.Port30003MessageReceived += MessageListener_MessageReceived;
                listener.SourceChanged += MessageListener_SourceChanged;

                Factory.Singleton.Resolve<IHeartbeatService>().Singleton.SlowTick += Heartbeat_SlowTick;
            }
        }
 /// <summary>
 /// Creates a new object.
 /// </summary>
 public BroadcastProvider()
 {
     _SendQueue = new BackgroundThreadQueue<byte[]>(String.Format("BroadcastProvider{0}", ++_InstanceCounter));
     _SendQueue.StartBackgroundThread(SendQueueHandler, SendQueueExceptionHandler);
 }
 /// <summary>
 /// Creates a new object.
 /// </summary>
 public BroadcastProvider()
 {
     _SendQueue = new BackgroundThreadQueue <byte[]>(String.Format("BroadcastProvider{0}", ++_InstanceCounter));
     _SendQueue.StartBackgroundThread(SendQueueHandler, SendQueueExceptionHandler);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Creates a new object.
        /// </summary>
        public Listener()
        {
            _Statistics = Factory.Singleton.Resolve<IStatistics>().Singleton;

            _Port30003MessageTranslator = Factory.Singleton.Resolve<IBaseStationMessageTranslator>();
            _ModeSMessageTranslator = Factory.Singleton.Resolve<IModeSTranslator>();
            _AdsbMessageTranslator = Factory.Singleton.Resolve<IAdsbTranslator>();
            _ModeSParity = Factory.Singleton.Resolve<IModeSParity>();

            var messageQueueName = String.Format("MessageProcessingAndDispatchQueue_{0}", ++_ListenerCounter);
            _MessageProcessingAndDispatchQueue = new BackgroundThreadQueue<MessageDispatch>(messageQueueName);
            _MessageProcessingAndDispatchQueue.StartBackgroundThread(ProcessAndDispatchMessageQueueItem, HandleMessageDispatchException);
        }