void on_cmd_startNoiseDefR(object sender, RoutedEventArgs e)
        {
            if (experiment != null)
            {
                experiment.Dispose();
            }

            var calPath = string.Format("{0}\\{1}", AppDomain.CurrentDomain.BaseDirectory, "NoiseCalibration");
            var amplifierNoiseFilePath    = string.Format("{0}\\{1}", calPath, "AmplifierNoise.dat");
            var frequencyResponseFilePath = string.Format("{0}\\{1}", calPath, "FrequencyResponse.dat");

            var amplifierNoise    = ReadCalibrationFile(amplifierNoiseFilePath);
            var frequencyResponse = ReadCalibrationFile(frequencyResponseFilePath);


            var motorDriver           = new SerialDevice("COM5", 115200, Parity.None, 8, StopBits.One);
            IMotionController1D motor = new SA_2036U012V(motorDriver) as IMotionController1D;

            experiment = new Noise_DefinedResistance(((measurementInterface as Noise_at_DefinedResistance).DataContext as Noise_DefinedResistanceModel).ExperimentSettings.AgilentU2542AResName, motor, amplifierNoise, frequencyResponse);

            experiment.DataArrived += Noise_at_der_R_DataArrived;

            experiment.Status   += experimentStatus;
            experiment.Progress += experimentProgress;

            if (measurementInterface != null)
            {
                if (measurementInterface is Noise_at_DefinedResistance)
                {
                    experiment.Start(((measurementInterface as Noise_at_DefinedResistance).DataContext as Noise_DefinedResistanceModel).ExperimentSettings);
                }
            }
        }
        void cmdStartIV_at_defR_Click(object sender, RoutedEventArgs e)
        {
            // Has to be implemented in another section of code

            var smuDriver = new VisaDevice("GPIB0::26::INSTR") as IDeviceIO;
            var keithley  = new Keithley26xxB <Keithley2602B>(smuDriver);
            var smu       = keithley[Keithley26xxB_Channels.Channel_A];

            var motorDriver = new SerialDevice("COM1", 115200, Parity.None, 8, StopBits.One);
            var motor       = new SA_2036U012V(motorDriver) as IMotionController1D;

            experiment              = new IV_DefinedResistance(smu, motor) as IExperiment;
            experiment.DataArrived += experimentIV_at_def_R_DataArrived;

            experiment.Status   += experimentStatus;
            experiment.Progress += experimentProgress;

            if (measurementInterface != null)
            {
                if (measurementInterface is IV_at_DefinedResistance)
                {
                    experiment.Start(((measurementInterface as IV_at_DefinedResistance).DataContext as IV_DefinedResistanceModel).ExperimentSettigns);
                }
            }
        }
        static void Main(string[] args)
        {
            #region Testing of SerialDevice & Faulhaber SA2036U012V

            var driver = new SerialDevice("COM1", 115200, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One);
            var motor  = new SA_2036U012V(driver);

            Console.WriteLine(string.Format("Motor Position is {0}", motor.Position));
            Console.WriteLine("Going to -0.2mm...");

            motor.Position = -0.2;

            Console.WriteLine(string.Format("Motor Position is {0}", motor.Position));
            Console.WriteLine("Going to 0mm...");

            motor.Position = 0.0;

            Console.WriteLine(string.Format("Motor Position is {0}", motor.Position));
            Console.WriteLine("Going to 0.2mm...");

            motor.Position = 0.2;

            Console.WriteLine(string.Format("Motor Position is {0}", motor.Position));
            Console.WriteLine("Going to 0mm...");

            motor.Position = 0.0;

            Console.WriteLine(string.Format("Motor Position is {0}", motor.Position));
            Console.WriteLine("Going to 0mm...");

            motor.Position = 0.0;
            Console.WriteLine(string.Format("Motor Position is {0}", motor.Position));

            Console.WriteLine();

            #endregion
        }
Пример #4
0
        private void on_cmdStartClick(object sender, RoutedEventArgs e)
        {
            IsInProgress = true;
            var filePath = GetSerializationFilePath();

            SerializeDataContext(filePath);

            Task.Factory.StartNew(new Action(() =>
            {
                var Settings = DeserializeDataContext(filePath);

                var innerLoopCollection = Settings.ExperimentSettings.ScanningVoltageCollection;
                var outerLoopCollection = Settings.ExperimentSettings.SetConductanceCollection;

                var innerLoopSelectionList = new List <double[]>();

                var nCompleteSelections = innerLoopCollection.Length / Settings.NMaxSpectra;
                var nResidualSpectra    = innerLoopCollection.Length % Settings.NMaxSpectra;

                for (int i = 0; i < nCompleteSelections; i++)
                {
                    innerLoopSelectionList.Add(innerLoopCollection.Where((value, index) => index >= i * Settings.NMaxSpectra && index < (i + 1) * Settings.NMaxSpectra).ToArray());
                }

                if (nResidualSpectra > 0)
                {
                    innerLoopSelectionList.Add(innerLoopCollection.Where((value, index) => index >= nCompleteSelections * Settings.NMaxSpectra && index < nCompleteSelections * Settings.NMaxSpectra + nResidualSpectra).ToArray());
                }

                for (int i = 0; i < outerLoopCollection.Length; i++)
                {
                    if (!IsInProgress)
                    {
                        break;
                    }
                    for (int j = 0; j < innerLoopSelectionList.Count;)
                    {
                        if (!IsInProgress)
                        {
                            break;
                        }

                        var innerLoopSelection = innerLoopSelectionList[j];

                        Settings.ExperimentSettings.SetConductanceCollection  = new double[] { outerLoopCollection[i] };
                        Settings.ExperimentSettings.ScanningVoltageCollection = innerLoopSelection;

                        var noiseFilePath = GetNoiseSerializationFilePath();
                        var noiseFileDir  = System.IO.Path.GetDirectoryName(noiseFilePath);

                        if (!Directory.Exists(noiseFileDir))
                        {
                            Directory.CreateDirectory(noiseFileDir);
                        }

                        SerializeDataContext(noiseFilePath, Settings.ExperimentSettings);

                        ++j;

                        using (var process = Process.Start("MCBJ.exe", "MCBJNoise"))
                        {
                            process.WaitForExit();
                            if (process.ExitCode != 0)
                            {
                                --j;
                            }
                        }
                    }
                }

                using (var driver = new SerialDevice("COM5", 115200, Parity.None, 8, StopBits.One) as IDeviceIO)
                {
                    var motionController = new SA_2036U012V(driver) as IMotionController1D;

                    motionController.Enabled = true;
                    motionController.SetVelosity(4.8);
                    motionController.SetPosition(0.0);
                    motionController.Enabled = false;
                }

                MessageBox.Show("The measurement is done!", "Measurement Info", MessageBoxButton.OK, MessageBoxImage.Information);
            }));
        }