private void button_impedanceTest_Click(object sender, EventArgs e) { if (stimDigitalTask != null) { stimDigitalTask.Dispose(); stimDigitalTask = null; } if (stimPulseTask != null) { stimPulseTask.Dispose(); stimPulseTask = null; } double startFreq = Convert.ToDouble(numericUpDown_impStartFreq.Value); double stopFreq = Convert.ToDouble(numericUpDown_impStopFreq.Value); double numPeriods = Convert.ToDouble(numericUpDown_impNumPeriods.Value); double commandVoltage = Convert.ToDouble(numericUpDown_impCommandVoltage.Value); double RCurr = Convert.ToDouble(numericUpDown_RCurr.Value); double RMeas = Convert.ToDouble(numericUpDown_RMeas.Value); double RGain = Convert.ToDouble(numericUpDown_RGain.Value); buttonStart.Enabled = false; //So users can't try to get data from the same card button_impedanceTest.Enabled = false; button_computeGain.Enabled = false; button_impedanceCancel.Enabled = true; //Toggle between voltage/current to discharge any weird build-ups if (radioButton_impCurrent.Checked) { radioButton_impVoltage_Click(this, null); System.Threading.Thread.Sleep(500); radioButton_impCurrent_Click(this, null); } else { radioButton_impCurrent_Click(this, null); System.Threading.Thread.Sleep(500); radioButton_impVoltage_Click(this, null); } //Clear plots scatterGraph_impedance.Plots.Clear(); impMeasurer = new Impedance.ImpedanceMeasurer(); impMeasurer.alertChannelFinished += new Impedance.ImpedanceMeasurer.ChannelFinishedHandler(impedanceChannelFinishedHandler); impMeasurer.alertAllFinished += new Impedance.ImpedanceMeasurer.AllFinishedHandler(impedanceFinished); impMeasurer.alertProgressChanged += new Impedance.ImpedanceMeasurer.ProgressChangedHandler(impedanceProgressChangedHandler); if (checkBox_impedanceAllChannels.Checked) { impMeasurer.getImpedance(startFreq, stopFreq, numPeriods, radioButton_impCurrent.Checked, 1, numChannels, RCurr, RMeas, RGain, commandVoltage, checkBox_impBandpassFilter.Checked, checkBox_impUseMatchedFilter.Checked); } else { impMeasurer.getImpedance(startFreq, stopFreq, numPeriods, radioButton_impCurrent.Checked, Convert.ToInt32(numericUpDown_impChannel.Value), 1, RCurr, RMeas, RGain, commandVoltage, checkBox_impBandpassFilter.Checked, checkBox_impUseMatchedFilter.Checked); } }
private void button_impedanceTest_Click(object sender, EventArgs e) { if (stimDigitalTask != null) { stimDigitalTask.Dispose(); stimDigitalTask = null; } if (stimPulseTask != null) { stimPulseTask.Dispose(); stimPulseTask = null; } double startFreq = Convert.ToDouble(numericUpDown_impStartFreq.Value); double stopFreq = Convert.ToDouble(numericUpDown_impStopFreq.Value); double numPeriods = Convert.ToDouble(numericUpDown_impNumPeriods.Value); double commandVoltage = Convert.ToDouble(numericUpDown_impCommandVoltage.Value); double RCurr = Convert.ToDouble(numericUpDown_RCurr.Value); double RMeas = Convert.ToDouble(numericUpDown_RMeas.Value); double RGain = Convert.ToDouble(numericUpDown_RGain.Value); buttonStart.Enabled = false; //So users can't try to get data from the same card button_impedanceTest.Enabled = false; button_computeGain.Enabled = false; button_impedanceCancel.Enabled = true; //Toggle between voltage/current to discharge any weird build-ups if (radioButton_impCurrent.Checked) { radioButton_impVoltage_Click(this, null); System.Threading.Thread.Sleep(500); radioButton_impCurrent_Click(this, null); } else { radioButton_impCurrent_Click(this, null); System.Threading.Thread.Sleep(500); radioButton_impVoltage_Click(this, null); } //Clear plots scatterGraph_impedance.Plots.Clear(); impMeasurer = new Impedance.ImpedanceMeasurer(); impMeasurer.alertChannelFinished += new Impedance.ImpedanceMeasurer.ChannelFinishedHandler(impedanceChannelFinishedHandler); impMeasurer.alertAllFinished += new Impedance.ImpedanceMeasurer.AllFinishedHandler(impedanceFinished); impMeasurer.alertProgressChanged += new Impedance.ImpedanceMeasurer.ProgressChangedHandler(impedanceProgressChangedHandler); if (checkBox_impedanceAllChannels.Checked) impMeasurer.getImpedance(startFreq, stopFreq, numPeriods, radioButton_impCurrent.Checked, 1, numChannels, RCurr, RMeas, RGain, commandVoltage, checkBox_impBandpassFilter.Checked, checkBox_impUseMatchedFilter.Checked); else impMeasurer.getImpedance(startFreq, stopFreq, numPeriods, radioButton_impCurrent.Checked, Convert.ToInt32(numericUpDown_impChannel.Value), 1, RCurr, RMeas, RGain, commandVoltage, checkBox_impBandpassFilter.Checked, checkBox_impUseMatchedFilter.Checked); }