コード例 #1
0
		private void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			// Prepare data in arrays
			const int N = 100;
			double[] x = new double[N];
			double[] y = new double[N];

			for (int i = 0; i < N; i++)
			{
				x[i] = i * 0.1;
				y[i] = Math.Cos(x[i]);
			}

			// Add data sources:
			var yDataSource = new EnumerableDataSource<double>(y);
			yDataSource.SetYMapping(Y => Y);
			yDataSource.AddMapping(ShapeElementPointMarker.ToolTipTextProperty,
				Y => string.Format("Value is {0}", Y));

			var xDataSource = new EnumerableDataSource<double>(x);
			xDataSource.SetXMapping(X => X);


			CompositeDataSource compositeDataSource = new CompositeDataSource(xDataSource, yDataSource);

			Matrix m = Matrix.Identity;
			m.RotateAt(45, 10, 10);
			line = new LineGraph
			{
				Stroke = Brushes.Green,
				StrokeThickness = 2,
				DataTransform =
					//new MatrixDataTransform(m) 
				new RotateDataTransform(45.0.DegreesToRadians())
			};
			line.DataSource = compositeDataSource;
			line.AddToPlotter(plotter);

			plotter.Viewport.Constraints.Add(new PhysicalProportionsConstraint { ProportionRatio = 1 });


			// adding graph to plotter
			plotter.AddLineGraph(compositeDataSource,
				new Pen(Brushes.Goldenrod, 3),
				new SampleMarker(),
				new PenDescription("Cosine"));

			//plotter.Viewport.FitToViewRestrictions.Add(new FollowDataWidthRestriction { Width = 1 });

			plotter.PreviewKeyDown += plotter_KeyDown;
		}
コード例 #2
0
        private bool InitTimeTraceMeasurements()
        {
            #region SMU, rendering and save data configurations

            if (sourceDeviceConfiguration != null)
            {
                #region Chart rendering settings

                if (_TimeTraceLineGraph != null)
                {
                    _experimentalTimeTraceDataSource.DetachPointReceiveEvent();
                    _TimeTraceLineGraph.Remove();
                    _CurrentTimeTrace.Clear();
                }

                _CurrentTimeTrace = new List<PointD>();
                _experimentalTimeTraceDataSource = new ExperimentalTimetraceDataSource(_CurrentTimeTrace);
                _experimentalTimeTraceDataSource.AttachPointReceiveEvent();
                _TimeTraceLineGraph = new LineGraph(_experimentalTimeTraceDataSource);
                _TimeTraceLineGraph.AddToPlotter(chartTimeTrace);

                #endregion

                //Getting SMU device
                Device = sourceDeviceConfiguration.Keithley2602A_DeviceSettings.Device;

                #region Time trace measurement configuration

                var pAddress = sourceDeviceConfiguration.Keithley2602A_DeviceSettings.DeviceSettings.PrimaryAddress;
                var sAddress = sourceDeviceConfiguration.Keithley2602A_DeviceSettings.DeviceSettings.SecondaryAddress;
                var bNumber = sourceDeviceConfiguration.Keithley2602A_DeviceSettings.DeviceSettings.BoardNumber;

                var motor = new ORDINARY_MOTOR(pAddress, sAddress, bNumber);
                motor.FinalDestination = 0.0;

                Motor = motor;

                if (TimeTraceCurve != null)
                {
                    TimeTraceCurve.Dispose();
                }

                var ExperimentSettings = IV_And_TimeTraceViewModel.Instance;

                var valueThroughTheStructure = ExperimentSettings.TimeTraceMeasurementValueThrougtTheStructure;
                var isTimeTraceVoltageModeChecked = ExperimentSettings.IsTimeTraceMeasurementVoltageModeChecked;
                var isTimeTraceCurrentModeChecked = ExperimentSettings.IsTimeTraceMeasurementCurrentModeChecked;

                var selectedTimeTraceModeItem = (tabControlTimeTraceMeasurementParameters.SelectedItem as TabItem).Header.ToString();

                switch (selectedTimeTraceModeItem)
                {
                    case "Distance":
                        {
                            var motionStartPosition = ExperimentSettings.TimeTraceMeasurementMotionCurrentDestination;
                            var motionFinalDestination = ExperimentSettings.TimeTraceMeasurementMotionFinalDestination;

                            if (isTimeTraceVoltageModeChecked == true)
                                TimeTraceCurve = new MeasureTimeTrace(Motor, motionStartPosition, motionFinalDestination, Device, KEITHLEY_2601A_SourceMode.Voltage, KEITHLEY_2601A_MeasureMode.Resistance, valueThroughTheStructure);
                            else if (isTimeTraceCurrentModeChecked == true)
                                TimeTraceCurve = new MeasureTimeTrace(Motor, motionStartPosition, motionFinalDestination, Device, KEITHLEY_2601A_SourceMode.Current, KEITHLEY_2601A_MeasureMode.Resistance, valueThroughTheStructure);
                        } break;
                    case "Distance (Repetitive)":
                        {
                            var motionRepetitiveStartPosition = ExperimentSettings.TimeTraceMeasurementDistanceRepetitiveStartPosition;
                            var motionRepetitiveEndPosition = ExperimentSettings.TimeTraceMeasurementDistanceRepetitiveEndPosition;
                            var numerCycles = ExperimentSettings.TimeTraceMeasurementDistanceRepetitiveNumberCycles;

                            if (isTimeTraceVoltageModeChecked == true)
                                TimeTraceCurve = new MeasureTimeTrace(Motor, motionRepetitiveStartPosition, motionRepetitiveEndPosition, Device, KEITHLEY_2601A_SourceMode.Voltage, KEITHLEY_2601A_MeasureMode.Resistance, valueThroughTheStructure);
                            else if (isTimeTraceCurrentModeChecked == true)
                                TimeTraceCurve = new MeasureTimeTrace(Motor, motionRepetitiveStartPosition, motionRepetitiveEndPosition, Device, KEITHLEY_2601A_SourceMode.Current, KEITHLEY_2601A_MeasureMode.Resistance, valueThroughTheStructure);
                        } break;
                    case "Time":
                        {
                        } break;
                    case "Fixed R":
                        {
                        } break;
                    default:
                        break;
                }

                #endregion

                #region Saving Time Trace data into files

                var _TimeTraceFileNumber = String.Format("_{0}{1}{2}", (_TimeTraceFilesCounter / 100) % 10, (_TimeTraceFilesCounter / 10) % 10, _TimeTraceFilesCounter % 10);
                string newFileName = string.Empty;

                if (!string.IsNullOrEmpty(_SaveTimeTraceMeasuremrentFileName))
                {
                    _TimeTraceMeasurementLog = new TimeTraceMeasurementLog((new FileInfo(_SaveTimeTraceMeasuremrentFileName)).DirectoryName + "\\TimeTraceMeasurementLog.dat");

                    newFileName = _SaveTimeTraceMeasuremrentFileName.Insert(_SaveTimeTraceMeasuremrentFileName.LastIndexOf('.'), _TimeTraceFileNumber);
                    ++_TimeTraceFilesCounter;
                }

                string sourceMode = string.Empty;

                if (!string.IsNullOrEmpty(_SaveTimeTraceMeasuremrentFileName))
                {
                    string fileName = (new FileInfo(newFileName)).Name;

                    if (this.radioTimeTraceSourceVoltage.IsChecked == true)
                    {
                        sourceMode = "Source mode: Voltage";
                    }
                    else if (this.radioTimeTraceSourceCurrent.IsChecked == true)
                    {
                        sourceMode = "SourceMode: Current";
                    }

                    double micrometricBoltPosition = double.NaN;
                    double.TryParse(this.textBoxTimeTraceMicrometricBoltPosition.Text, numberStyle, culture, out micrometricBoltPosition);

                    string comment = this.textBoxTimeTraceComment.Text;

                    _TimeTraceMeasurementLog.AddNewTimeTraceMeasurementLog(fileName, sourceMode, valueThroughTheStructure, comment);
                }

                SourceMode _sourceMode = SourceMode.Voltage; //Source mode is voltage by default

                if (sourceMode == "Source mode: Voltage")
                    _sourceMode = SourceMode.Voltage;
                else if (sourceMode == "SourceMode: Current")
                    _sourceMode = SourceMode.Current;

                if (_TimeTraceSingleMeasurement != null)
                    _TimeTraceSingleMeasurement.Dispose();

                _TimeTraceSingleMeasurement = new TimeTraceSingleMeasurement(newFileName, _sourceMode);

                #endregion

                return true;
            }
            else
            {
                return false;
            }

            #endregion
        }
コード例 #3
0
        /// <summary>
        /// Initializes the new I-V curve measurements
        /// </summary>
        /// <returns>true, if initialization succeed and false otherwise</returns>
        private bool InitIV_Measurements()
        {
            #region SMU, rendering and save data configurations

            //Checking the SMU settings
            if (sourceDeviceConfiguration != null)
            {
                #region Chart rendering settings

                //Initializing a new plot on I-V chart
                if (_IV_LineGraph != null)
                {
                    //Detaching receive event from "old" data source
                    _experimentalIV_DataSource.DetachPointReceiveEvent();
                    _IV_LineGraph.Remove();
                }
                //Creating new plot and attaching it to the chart
                _CurrentIV_Curve = new List<PointD>();
                _experimentalIV_DataSource = new ExperimentalIV_DataSource(_CurrentIV_Curve);
                _experimentalIV_DataSource.AttachPointReceiveEvent();
                _IV_LineGraph = new LineGraph(_experimentalIV_DataSource);
                _IV_LineGraph.AddToPlotter(chartIV_Curves);

                #endregion

                //Getting SMU device
                Device = sourceDeviceConfiguration.Keithley2602A_DeviceSettings.Device;

                #region I-V measurement configuration

                var ExperimentSettings = IV_And_TimeTraceViewModel.Instance;

                var StartValue = ExperimentSettings.IV_MeasurementStartValue;
                var EndValue = ExperimentSettings.IV_MeasurementEndValue;
                var Step = ExperimentSettings.IV_MeasurementStep;
                var NumberOfAverages = ExperimentSettings.IV_MeasurementNumberOfAverages;
                var TimeDelay = ExperimentSettings.IV_MeasurementTimeDelay;

                SourceMode DeviceSourceMode = SourceMode.Voltage;

                if (this.radioIVSourceVoltage.IsChecked == true)
                {
                    DeviceSourceMode = SourceMode.Voltage;
                }
                else if (this.radioIVSourceCurrent.IsChecked == true)
                {
                    DeviceSourceMode = SourceMode.Current;
                }

                IV_Curve = new MeasureIV(StartValue, EndValue, Step, NumberOfAverages, TimeDelay, DeviceSourceMode, Device);

                #endregion

                #region Saving I-V data into files

                var _IV_FileNumber = String.Format("_{0}{1}{2}", (_IV_FilesCounter / 100) % 10, (_IV_FilesCounter / 10) % 10, _IV_FilesCounter % 10);
                string newFileName = string.Empty;

                if (!string.IsNullOrEmpty(_SaveIV_MeasuremrentFileName))
                {
                    _IV_MeasurementLog = new IV_MeasurementLog((new FileInfo(_SaveIV_MeasuremrentFileName)).DirectoryName + "\\IV_MeasurementLog.dat");

                    newFileName = _SaveIV_MeasuremrentFileName.Insert(_SaveIV_MeasuremrentFileName.LastIndexOf('.'), _IV_FileNumber);
                    ++_IV_FilesCounter;
                }

                if (!string.IsNullOrEmpty(_SaveIV_MeasuremrentFileName))
                {

                    string fileName = (new FileInfo(newFileName)).Name;

                    string sourceMode = string.Empty;

                    if (this.radioIVSourceVoltage.IsChecked == true)
                    {
                        sourceMode = "Source mode: Voltage";
                    }
                    else if (this.radioIVSourceCurrent.IsChecked == true)
                    {
                        sourceMode = "SourceMode: Current";
                    }

                    double micrometricBoltPosition = double.NaN;
                    double.TryParse(this.textBoxIV_MicrometricBoltPosition.Text, numberStyle, culture, out micrometricBoltPosition);

                    string comment = this.textBoxIV_Comment.Text;

                    _IV_MeasurementLog.AddNewIV_MeasurementLog(fileName, sourceMode, micrometricBoltPosition, comment);
                }

                if (_IV_SingleMeasurement != null)
                    _IV_SingleMeasurement.Dispose();

                _IV_SingleMeasurement = new IV_SingleMeasurement(newFileName);

                #endregion

                return true;
            }
            else
            {
                MessageBox.Show("The device is not initialized.", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                return false;
            }

            #endregion
        }