/// <summary> /// Opens the selected device controller and prepares for sampling /// </summary> public void Open() { Close(); switch (this.Settings.ControllerType) { case ControllerTypes.Serial: Controller = new SerialController(this.Settings.SerialPortName, this.Settings.BaudRate, System.IO.Ports.Parity.None, 8, System.IO.Ports.StopBits.One); break; case ControllerTypes.Test: Controller = new TestController("Test Controller", new Test.LaTestDevice()); break; default: throw new NotImplementedException("Unknown controller"); } grabber = new DataGrabber(Controller, this.Settings.SamplingRate, this.Settings.SamplingChannels, this.Settings.SamplingTime, this.Settings.SamplingMode, this.Settings.SamplingCompression); grabber.OnComplete += grabber_Complete; grabber.OnProgress += grabber_Progress; grabber.OnError += grabber_Error; grabber.OnConsoleMessage += grabber_ConsoleMessage; grabber.Open(); }
/// <summary> /// Closes the device controller, if it is open /// </summary> public void Close() { if (grabber != null) { grabber.Close(); grabber = null; } }