Esempio n. 1
0
        public void LogicalOrCommandTest()
        {
            SwitchVM      switchOne = new SwitchVM();
            SwitchVM      switchTwo = new SwitchVM();
            LogicalBaseVM or        = LogicalBaseVM.CreateLogicalOr();

            ICommand switchingSwitchOne = switchOne.SwitchingCommand;

            switchingSwitchOne.Execute(null);

            ICommand selectSignalCommand = switchOne.SelectSignalCommand;

            selectSignalCommand.Execute(null);

            selectSignalCommand = or.SelectSignalCommand;
            selectSignalCommand.Execute(or.InputSignals[0]);

            selectSignalCommand = or.SelectSignalCommand;
            selectSignalCommand.Execute(or.InputSignals[1]);

            selectSignalCommand = switchTwo.SelectSignalCommand;
            selectSignalCommand.Execute(null);

            Assert.AreEqual(true, or.OutputSignals[0].SignalValue);
        }
Esempio n. 2
0
        public void LogicalSwitchCommandTest()
        {
            SwitchVM switchOne = new SwitchVM();

            ICommand switchCommand = switchOne.SwitchingCommand;

            switchCommand.Execute(null);
            Assert.AreEqual(true, switchOne.Output.SignalValue);

            switchCommand.Execute(null);
            Assert.AreEqual(false, switchOne.Output.SignalValue);
        }
Esempio n. 3
0
        public void LogicalNotCommandTest()
        {
            SwitchVM      switchOne = new SwitchVM();
            LogicalBaseVM not       = LogicalBaseVM.CreateLogicalNot();

            ICommand selectSignalCommand = switchOne.SelectSignalCommand;

            selectSignalCommand.Execute(null);

            selectSignalCommand = not.SelectSignalCommand;
            selectSignalCommand.Execute(not.InputSignals[0]);

            Assert.AreEqual(true, not.OutputSignals[0].SignalValue);
        }
Esempio n. 4
0
        public void LogicalSpaceCommandTest()
        {
            SwitchVM      switchOne = new SwitchVM();
            LogicalBaseVM space     = LogicalBaseVM.CreateLogicalSpace();

            ICommand switchingSwitchOne = switchOne.SwitchingCommand;

            ICommand selectSignalCommand = switchOne.SelectSignalCommand;

            selectSignalCommand.Execute(null);

            selectSignalCommand = space.SelectSignalCommand;
            selectSignalCommand.Execute(space.InputSignals[0]);

            switchingSwitchOne.Execute(null);
            Assert.AreEqual(true, space.OutputSignals[0].SignalValue);
        }
Esempio n. 5
0
        public void SelectSignalValueTest()
        {
            SwitchVM      switchOne = new SwitchVM();
            SwitchVM      switchTwo = new SwitchVM();
            LogicalBaseVM and       = LogicalBaseVM.CreateLogicalAnd();

            ICommand switchingSwitchOne = switchOne.SwitchingCommand;

            switchingSwitchOne.Execute(null);

            ICommand switchingSwitchTwo = switchTwo.SwitchingCommand;

            switchingSwitchTwo.Execute(null);


            ICommand selectSignalCommand = switchOne.SelectSignalCommand;

            selectSignalCommand.Execute(null);
            Assert.AreEqual(switchOne.Output, SelectSignal.Signal);

            selectSignalCommand = switchTwo.SelectSignalCommand;
            selectSignalCommand.Execute(null);
            Assert.AreEqual(switchTwo.Output, SelectSignal.Signal);


            selectSignalCommand = and.SelectSignalCommand;
            selectSignalCommand.Execute(and.InputSignals[0]);
            Assert.AreEqual(null, SelectSignal.Signal);

            selectSignalCommand = and.SelectSignalCommand;
            selectSignalCommand.Execute(and.InputSignals[1]);
            Assert.AreEqual(and.InputSignals[1], SelectSignal.Signal);

            selectSignalCommand = switchOne.SelectSignalCommand;
            selectSignalCommand.Execute(null);
            Assert.AreEqual(null, SelectSignal.Signal);
        }
Esempio n. 6
0
        public void LogicalXorShemaCommandTest()
        {
            ObservableCollection <LogicalBase> xorInternalCollectionFrame =
                CreateCollectionFrame.CreateXorShemaFrame();

            LogicalBaseVM xor = LogicalBaseVM.CreateLogicalShema(xorInternalCollectionFrame);

            SwitchVM switchOne = new SwitchVM();
            SwitchVM switchTwo = new SwitchVM();

            ICommand switchingSwitchOne = switchOne.SwitchingCommand;

            switchingSwitchOne.Execute(null);

            ICommand switchingSwitchTwo = switchOne.SwitchingCommand;

            switchingSwitchOne.Execute(null);

            ICommand selectSignalCommand = switchOne.SelectSignalCommand;

            selectSignalCommand.Execute(null);

            selectSignalCommand = xor.SelectSignalCommand;
            selectSignalCommand.Execute(xor.InputSignals[0]);

            selectSignalCommand = xor.SelectSignalCommand;
            selectSignalCommand.Execute(xor.InputSignals[1]);

            selectSignalCommand = switchTwo.SelectSignalCommand;
            selectSignalCommand.Execute(null);

            Assert.AreEqual(false, xor.OutputSignals[0].SignalValue);

            switchingSwitchOne.Execute(null);
            Assert.AreEqual(true, xor.OutputSignals[0].SignalValue);
        }
Esempio n. 7
0
        public ApplicationVM(IProfileService profileService) : base(profileService)
        {
            try {
                if (NINA.Properties.Settings.Default.UpdateSettings)
                {
                    NINA.Properties.Settings.Default.Upgrade();
                    NINA.Properties.Settings.Default.UpdateSettings = false;
                    NINA.Properties.Settings.Default.Save();
                }

                Logger.SetLogLevel(profileService.ActiveProfile.ApplicationSettings.LogLevel);
                cameraMediator            = new CameraMediator();
                telescopeMediator         = new TelescopeMediator();
                focuserMediator           = new FocuserMediator();
                filterWheelMediator       = new FilterWheelMediator();
                rotatorMediator           = new RotatorMediator();
                flatDeviceMediator        = new FlatDeviceMediator();
                guiderMediator            = new GuiderMediator();
                imagingMediator           = new ImagingMediator();
                applicationStatusMediator = new ApplicationStatusMediator();

                switchMediator      = new SwitchMediator();
                weatherDataMediator = new WeatherDataMediator();

                SwitchVM = new SwitchVM(profileService, applicationStatusMediator, switchMediator);

                ExitCommand                      = new RelayCommand(ExitApplication);
                ClosingCommand                   = new RelayCommand(ClosingApplication);
                MinimizeWindowCommand            = new RelayCommand(MinimizeWindow);
                MaximizeWindowCommand            = new RelayCommand(MaximizeWindow);
                CheckProfileCommand              = new RelayCommand(LoadProfile);
                CheckUpdateCommand               = new AsyncCommand <bool>(() => CheckUpdate());
                OpenManualCommand                = new RelayCommand(OpenManual);
                CheckASCOMPlatformVersionCommand = new RelayCommand(CheckASCOMPlatformVersion);
                ConnectAllDevicesCommand         = new AsyncCommand <bool>(async() => {
                    var diag = MyMessageBox.MyMessageBox.Show(Locale.Loc.Instance["LblReconnectAll"], "", MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
                    if (diag == MessageBoxResult.OK)
                    {
                        return(await Task <bool> .Run(async() => {
                            var cam = cameraMediator.Connect();
                            var fw = filterWheelMediator.Connect();
                            var telescope = telescopeMediator.Connect();
                            var focuser = focuserMediator.Connect();
                            var rotator = rotatorMediator.Connect();
                            var flatdevice = flatDeviceMediator.Connect();
                            var guider = guiderMediator.Connect();
                            var weather = weatherDataMediator.Connect();
                            var swtch = switchMediator.Connect();
                            await Task.WhenAll(cam, fw, telescope, focuser, rotator, flatdevice, guider, weather, swtch);
                            return true;
                        }));
                    }
                    else
                    {
                        return(false);
                    }
                });
                DisconnectAllDevicesCommand = new RelayCommand((object o) => {
                    var diag = MyMessageBox.MyMessageBox.Show(Locale.Loc.Instance["LblDisconnectAll"], "", MessageBoxButton.OKCancel, MessageBoxResult.Cancel);
                    if (diag == MessageBoxResult.OK)
                    {
                        DisconnectEquipment();
                    }
                });

                InitAvalonDockLayout();

                OptionsVM.PropertyChanged += OptionsVM_PropertyChanged;

                profileService.ProfileChanged += ProfileService_ProfileChanged;
            } catch (Exception e) {
                Logger.Error(e);
                throw e;
            }
        }
Esempio n. 8
0
 public SwitchControl()
 {
     InitializeComponent();
     DataContext = new SwitchVM();
 }