Esempio n. 1
0
        protected override void OnStartup(StartupEventArgs args)
        {
            CVTester cvTester = new CVTester();

            IKeithley2400Model  kt2400 = new Keithley2400Model();
            IWayneKerr4300Model wk4300 = new WayneKerr4300Model();

            IKeithley2400ViewModel  kt2400vm = new Keithley2400ViewModel(kt2400);
            IWayneKerr4300ViewModel wk4300vm = new WayneKerr4300ViewModel(wk4300);

            CVTesterViewModel vm = new CVTesterViewModel(kt2400vm, wk4300vm, cvTester);

            cvTester.DataContext = vm;
            cvTester.Show();
        }
Esempio n. 2
0
        public CVTesterViewModel(IKeithley2400ViewModel keithley2400ViewModel,
                                 IWayneKerr4300ViewModel wayneKerr4300ViewModel,
                                 CVTester cvTester)
        {
            _cvScan            = new CVScan();
            _cvtester          = cvTester;
            _cvtester.Closing += CloseProgram;
            Keithley           = keithley2400ViewModel;
            WayneKerr          = wayneKerr4300ViewModel;
            _wayneKerr         = WayneKerr.GetModel();
            _keithley          = Keithley.GetModel();

            _serialPortManagerSelector = new SerialPortManagerSelector(new SerialPortManager(),
                                                                       new SerialPortEmulatorManager());

            _cvConfiguration      = new CVConfiguration();
            _cvScan.Monitor       = MonitorMessageDelegate;
            _monitorStringBuilder = new StringBuilder();
            FrequencyList         = new ObservableCollection <double>();
            _shortCircuitActive   = false;
            _openCircuitActive    = false;
            _devicesDiscovered    = false;
            Executing             = false;
            Emulate = false;

            SaveConfigCommand = new DelegateCommand(ExecuteSaveConfig, CanExecuteSaveConfig)
                                .ObservesProperty <string>(() => ConfigurationFile);

            AddFrequencyCommand = new DelegateCommand(ExecuteAddFrequency, CanExecuteAddFrequency).ObservesProperty(() => NewFrequency);

            DeleteSelectedFrequenciesCommand = new DelegateCommand <ICollection <object> >(ExecuteDeleteSelectedFrequencies, CanExecuteDeleteSelectedFrequencies);

            DiscoveryCommand = new DelegateCommand(ExecuteDiscovery, CanExecuteDiscovery)
                               .ObservesProperty <bool>(() => Emulate)
                               .ObservesProperty <string>(() => KeithleyEmulationFile)
                               .ObservesProperty <string>(() => WayneKerrEmulationFile);

            ShortCircuitTestCommand = new DelegateCommand(ExecuteShortCircuitTest, CanExecuteShortCircuitTest)
                                      .ObservesProperty <bool>(() => Emulate)
                                      .ObservesProperty <bool>(() => Executing)
                                      .ObservesProperty <bool>(() => ShortCircuitActive)
                                      .ObservesProperty <bool>(() => DevicesDiscovered)
                                      .ObservesProperty <string>(() => ResultsFileName);


            OpenCircuitTestCommand = new DelegateCommand(ExecuteOpenCircuitTest, CanExecuteOpenCircuitTest)
                                     .ObservesProperty <bool>(() => Emulate)
                                     .ObservesProperty <bool>(() => Executing)
                                     .ObservesProperty <bool>(() => DevicesDiscovered)
                                     .ObservesProperty <bool>(() => OpenCircuitActive)
                                     .ObservesProperty <string>(() => ResultsFileName);


            CVTestCommand = new DelegateCommand(ExecuteCVTest, CanExecuteCVTest)
                            .ObservesProperty <bool>(() => Emulate)
                            .ObservesProperty <bool>(() => Executing)
                            .ObservesProperty <bool>(() => DevicesDiscovered)
                            .ObservesProperty <string>(() => ResultsFileName);

            StopCVTestCommand = new DelegateCommand(StopCVTest, CanExecuteStopCVTest)
                                .ObservesProperty <bool>(() => Executing);
        }