Exemple #1
0
        public void ReloadOptions()
        {
            var optionsStorage = new OptionsStorage();

            _Options = optionsStorage.Load();

            var configurationStorage = Factory.Singleton.ResolveSingleton <IConfigurationStorage>();

            _Configuration = configurationStorage.Load();

            _View.CombinedFeeds.Clear();
            _View.CombinedFeeds.AddRange(
                _Configuration.Receivers.Select(r => new CombinedFeed()
            {
                UniqueId = r.UniqueId, Name = r.Name
            })
                .Concat(_Configuration.MergedFeeds.Select(r => new CombinedFeed()
            {
                UniqueId = r.UniqueId, Name = r.Name
            }))
                );

            _View.PluginEnabled = _Options.Enabled;
            _View.AllowUpdateOfOtherDatabases = _Options.AllowUpdateOfOtherDatabases;
            _View.DatabaseFileName            = _Configuration.BaseStationSettings.DatabaseFileName;
            _View.ReceiverId = _Options.ReceiverId;
            _View.SaveDownloadedAircraftDetails = _Options.SaveDownloadedAircraftDetails;
            _View.RefreshOutOfDateAircraft      = _Options.RefreshOutOfDateAircraft;

            RefreshWriteNotice();
        }
Exemple #2
0
        /// <summary>
        /// Called when the user indicates that they want to save their changes.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void View_SaveClicked(object sender, EventArgs args)
        {
            _Options.Enabled = _View.PluginEnabled;
            _Options.AllowUpdateOfOtherDatabases = _View.AllowUpdateOfOtherDatabases;
            _Options.ReceiverId = _View.ReceiverId;
            _Options.SaveDownloadedAircraftDetails = _View.SaveDownloadedAircraftDetails;
            _Options.RefreshOutOfDateAircraft      = _View.RefreshOutOfDateAircraft;

            var configurationStorage = Factory.Singleton.Resolve <IConfigurationStorage>().Singleton;

            _Configuration.BaseStationSettings.DatabaseFileName = _View.DatabaseFileName;
            configurationStorage.Save(_Configuration);

            var optionsStorage = new OptionsStorage();

            optionsStorage.Save(_Options);
        }
Exemple #3
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();
            }
        }
        /// <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>
        /// See interface docs.
        /// </summary>
        public void ShowWinFormsOptionsUI()
        {
            using(var view = Provider.CreateOptionsView()) {
                var configurationStorage = Factory.Singleton.Resolve<IConfigurationStorage>().Singleton;
                var configuration = configurationStorage.Load();

                view.PluginEnabled = _Options.Enabled;
                view.AllowUpdateOfOtherDatabases = _Options.AllowUpdateOfOtherDatabases;
                view.DatabaseFileName = configuration.BaseStationSettings.DatabaseFileName;

                if(view.DisplayView()) {
                    lock(_SyncLock) {
                        _Options.Enabled = view.PluginEnabled;
                        _Options.AllowUpdateOfOtherDatabases = view.AllowUpdateOfOtherDatabases;
                        var optionsStorage = new OptionsStorage();
                        optionsStorage.Save(this, _Options);

                        configuration.BaseStationSettings.DatabaseFileName = view.DatabaseFileName;
                        configurationStorage.Save(configuration);

                        bool optionsPermit = _Options.Enabled && (_Options.AllowUpdateOfOtherDatabases || DatabaseCreatedByPlugin());
                        if(_Session != null && !optionsPermit) EndSession();
                        StartSession();
                    }
                }
            }
        }