Beispiel #1
0
        private void OnStoppedControl([NotNull] object sender, [NotNull] StoppedControlEventArgs e)
        {
            if (isDisposing) return;
            if (!Equals(CurrentController, sender)) return;

            var oldController = CurrentController;
            var newController = requestingController ?? defaultController;
            requestingController = null;
            CurrentController = null;
            Log.Information("Stopped control.");

            if (newController != null && newController != oldController)
                StartControl(newController, e.PortName);

            RaisePropertyChanged(() => IsConnected);
        }
Beispiel #2
0
        public void AddController(
            [CanBeNull] string name,
            [CanBeNull] IDppController controller,
            bool asDefault = false)
        {
            if (String.IsNullOrWhiteSpace(name))
                throw new ArgumentException("name is null or empty or white space.");
            if (controller == null)
                throw new ArgumentNullException("controller");

            controller.StartedControl += OnStartedControl;
            controller.StoppedControl += OnStoppedControl;
            controller.RequestControl += OnControlRequested;
            controllers.Add(name, controller);

            if (asDefault) defaultController = controller;
            RaisePropertyChanged(() => IsConnected);
        }
Beispiel #3
0
 private void OnControlRequested([NotNull] object sender, [NotNull] EventArgs e)
 {
     requestingController = (IDppController) sender;
     Log.Information("Requested control by " + requestingController);
     StopControl();
 }