private void btnStop_Click(object sender, RoutedEventArgs e) { timer.IsEnabled = false; myTask.Stop(); myTask.Dispose(); btnStart.IsEnabled = true; btnStop.IsEnabled = false; }
/// <summary> /// 停止任务,回到idle状态 /// </summary> /// <returns></returns> public bool TryStopTask() { if (aiTask != null) { try { aiTask.Stop(); //之前没有,发布停事件 //OnAITaskStopped(); } catch (Exception ex) { //目前啥也不用做 } Thread.Sleep(1000); if (aiTask != null) { aiTask.Dispose(); } aiTask = null; AIState = Status.Idle; return(true); } else { return(false); } }
public void Stop() { this.IsInitialized = false; if (_daqTask != null) { _daqTask.Stop(); _daqTask.Dispose(); } }
private void stopButton_Click(object sender, System.EventArgs e) { timer.IsEnabled = false; if (myTask != null) { try { myTask.Stop(); } catch (Exception x) { MessageBox.Show(x.Message); } myTask.Dispose(); myTask = null; btnStart.IsEnabled = true; btnStop.IsEnabled = false; } }
private void btnStop_Click(object sender, RoutedEventArgs e) { if (runningTask != null) { runningTask.Stop(); // Dispose of the task runningTask = null; btnStop.IsEnabled = false; btnStart.IsEnabled = true; } }
public static string GenerateWave(string sourceDevice = "Dev1", double freq = 100, double amp = 2, string waveType = "sine") { waveType = waveType.ToLower(); AOFunctionGenerationType type = AOFunctionGenerationType.Sine; //default value if (waveType.Equals("square")) { type = AOFunctionGenerationType.Square; } else if (waveType.Equals("triangle")) { type = AOFunctionGenerationType.Triangle; } NationalInstruments.DAQmx.Task myTask = new NationalInstruments.DAQmx.Task(); try { if (amp < 0) { amp *= -1; } if (amp > 5) { amp = 5; } myTask.AOChannels.CreateFunctionGenerationChannel(sourceDevice + "/fgen", "fgen", type, freq, //freq amp); //amplitude // verify the task before doing the waveform calculations myTask.Control(TaskAction.Verify); myTask.Stop(); myTask.AOChannels[0].FunctionGenerationType = type; myTask.AOChannels[0].FunctionGenerationFrequency = freq; myTask.AOChannels[0].FunctionGenerationAmplitude = amp; myTask.Start(); } catch (DaqException err) { myTask.Dispose(); return("Fail" + err.Message); } myTask.Dispose(); return("OK"); }
/// <summary> /// 停止任务,回到idle状态 /// </summary> /// <returns></returns> public bool StopTask() { if (aiTask != null) { aiTask.Stop(); aiTask.Dispose(); aiTask = null; AIState = Status.Idle; OnStatusChanged(); return(true); } else { return(false); } }
void StopTask() { try { runningTask = null; inputTask.Stop(); outputTask.Stop(); inputTask.Dispose(); outputTask.Dispose(); } catch (Exception ex) { WarningDAQUpdate?.Invoke(ex.Message); } //Dispose(); }
public void GenerateWave(string device = "Dev1", double freq = 100, double amp = 2, AOFunctionGenerationType type = AOFunctionGenerationType.Sine) { try { if (myTask == null) { myTask = new NationalInstruments.DAQmx.Task(); if (amp < 0) { amp *= -1; } if (amp > 5) { amp = 5; } myTask.AOChannels.CreateFunctionGenerationChannel(device + "/fgen", "fgen", type, freq, //freq amp); //amplitude // verify the task before doing the waveform calculations myTask.Control(TaskAction.Verify); } else { myTask.Stop(); myTask.AOChannels[0].FunctionGenerationType = type; myTask.AOChannels[0].FunctionGenerationFrequency = freq; myTask.AOChannels[0].FunctionGenerationAmplitude = amp; } myTask.Start(); } catch (DaqException err) { MessageBox.Show(err.Message); myTask.Dispose(); myTask = null; } }
/// <summary> /// 停止任务,回到idle状态 /// </summary> /// <returns></returns> public bool TryStopTask() { if (aiTask != null) { try { aiTask.Stop(); } catch (Exception ex) { //目前啥也不用做 } aiTask.Dispose(); aiTask = null; AIState = Status.Idle; return(true); } else { return(false); } }
/// <summary> /// Stopper den asynkrone indlæsning af data fra DAQ'en /// </summary> public void stoptInputAsync() { runningTask = null; analogInTask.Stop(); analogInTask.Dispose(); }