Tektronix Technical Forums are maintained by community involvement. Feel free to post questions or respond to questions by other members. Should you require a time-sensitive answer, please contact your local Tektronix support center here.

C# Program crashes with accessing IKe37XX.Scan.State Property

Post Reply
takamasa
Posts: 2
Joined: April 6th, 2021, 10:10 pm
Country: Japan

C# Program crashes with accessing IKe37XX.Scan.State Property

Post by takamasa » April 6th, 2021, 10:38 pm

I'm programming using C# with Keithley 3706A & 3721 card.
Modifed Keithley's sample code "Simple Measurement", I could run scan on instrument, and get measurement result values.

But, for watching scan status, when I accessed "IKe37XX.Scan.State" program crashed with no exception.

My program based on sample code "Simple Measurement" is below.

Code: Select all

		private IKe37XX _driver;
		...
		private void measureButton_Click(object sender, System.EventArgs e)
		{
			if (!_driver.Initialized)
			{
				MessageBox.Show("Instrument not initialized.");
				return;
			}

			try	
			{
				resultsListBox.Items.Clear();

				_driver.Utility.Reset();

				_driver.Measurement.AutoRange = true;
			
				switch (functionComboBox.SelectedItem.ToString())
				{
					case "4 wire Resistance":
					default:
						_driver.Measurement.Function = Ke37XXMeasurementFunctionEnum.Ke37XXMeasurementFunctionFourWireOhms;
						break;
				}

				int measureCount = (int)measureCountControl.Value;

				_driver.Measurement.MeasurementCount = measureCount;

				statusBar.Text = "Measuring...";

				if (measureCount == 1)
				{
				...
				}
				else
				{
					// Perform a multi-point measurement

					_driver.Channel.OpenAll();
					_driver.Status.Clear();

					_driver.Scan.CreateScanList("1001:1003", "fourwireohms");
					_driver.Scan.ScanCount = measureCount;

					// First create a measurement buffer to store the readings
					string bufferName = "MyBuf";
					_driver.Measurement.Buffer.Create(bufferName, (measureCount * 3));

					// Perform the measurement and store the readings in the buffer
					_driver.Scan.ExecuteBackground(bufferName);

					bool isMeasuring = true;
					Ke37XXScanStateEnum state;
					do
					{
						state = _driver.Scan.State;    // Program Crashes HERE!
						statusBar.Text = string.Format("Status of scan is {0}.", state.ToString());

						if (state.CompareTo(Ke37XXScanStateEnum.Ke37XXScanStateSuccess) == 0)
						{
							isMeasuring = false;
						}
						//slow down polling
						Thread.Sleep(100);
						//need to yield so totalizer increment button can work
						Application.DoEvents();
					} while (isMeasuring);

					// Retrieve all of the readings from the buffer
					double[] readings = _driver.Measurement.Buffer.ReadingData.GetAllReadings(bufferName);

					foreach (double reading in readings)
					{
						resultsListBox.Items.Add(reading.ToString("E"));
					}
				}
			}
			catch (COMException ex)
			{
				HandleInstrumentError(ex);
			}
			catch (Exception excep)
			{
				MessageBox.Show(excep.ToString());
			}

        		statusBar.Text = "Ready.";
		}
Could anyone tell me how can I access IKe37XX.Scan.State or watch Scan status?
Thanks!

takamasa
Posts: 2
Joined: April 6th, 2021, 10:10 pm
Country: Japan

Re: C# Program crashes with accessing IKe37XX.Scan.State Property

Post by takamasa » April 7th, 2021, 6:09 pm

Additional information :

Run the driver in simulation mode(Simulate=True), program was NOT crashed. But in actual mode (Simulation = False), still crashes...
I'm connecting PC to 3706A with USB.

Post Reply

Return to “IVI Drivers”

Who is online

Users browsing this forum: No registered users and 2 guests