Example #1
0
        public void StartMeasurement(object sender, DoWorkEventArgs e, MotionKind motionKind, int numberRepetities = 1)
        {
            var worker = sender as BackgroundWorker;

            switch (_SourceMode)
            {
            case KEITHLEY_2601A_SourceMode.Voltage:
            {
                _MeasureDevice.SetSourceVoltage(_ValueThroughTheStructure);
            } break;

            case KEITHLEY_2601A_SourceMode.Current:
            {
                _MeasureDevice.SetSourceCurrent(_ValueThroughTheStructure);
            } break;

            default:
                break;
            }

            AllEventsHandler.Instance.OnTimeTraceMeasurementsStateChanged(this, new TimeTraceMeasurementStateChanged_EventArgs(true));

            _MeasureDevice.SwitchON();

            switch (motionKind)
            {
            case MotionKind.Single:
            {
                _Motor.StartMotion(_StartPosition, _Destination, MotionKind.Single);
            } break;

            case MotionKind.Repetitive:
            {
                _Motor.StartMotion(_StartPosition, _Destination, MotionKind.Repetitive, numberRepetities);
            } break;

            default:
                break;
            }

            while (true)
            {
                if (worker.CancellationPending == true)
                {
                    _Motor.StopMotion();
                    e.Cancel = true;
                    break;
                }
                if (_CancelMeasures == true)
                {
                    _Motor.StopMotion();
                    break;
                }
            }

            _MeasureDevice.SwitchOFF();
        }