/// <summary> /// Stops all acquisition and generation /// </summary> public void Stop() { if (!IsRunning) { return; } _writeThreadReady.Reset(); if (_writeThread != null) { _writeThread.Stop(); _writeThread.Dispose(); _writeThread = null; } if (_readThread != null) { _readThread.Stop(); _readThread.Dispose(); _readThread = null; } //Reset all writes to 0 Task resetTask = new Task("ChReset"); for (int i = 0; i < 3; i++) { resetTask.AOChannels.CreateVoltageChannel(HardwareSettings.DAQ.DeviceName + "/" + string.Format("AO{0}", i), "", -10, 10, AOVoltageUnits.Volts); } AnalogMultiChannelWriter resetWriter = new AnalogMultiChannelWriter(resetTask.Stream); resetWriter.WriteSingleSample(true, new double[3]); resetTask.Dispose(); pipeCanceller.Cancel(); IsRunning = false; }
/// <summary> /// Stop running experiment and switch back to preview /// </summary> void Stop() { if (!IsRunning) { return; } IsRunning = false; //shut down experimental threads if (_acquisitionThread != null) { _acquisitionThread.Dispose(); } //experiment stopped, restart preview FrameIndex = 0; var preview = new PreviewTrack(Properties.Settings.Default.FrameRate, Properties.Settings.Default.PixelsPermm); _acquisitionThread = new WorkerT <IExperiment>(TrackThreadRun, preview, true, 3000); }