/// <summary> /// Creates an initializes a DataGrabber object. /// </summary> /// <param name="Controller">A controller for the device being sampled</param> /// <param name="SamplingRate">The rate at which to sample (in samples/second)</param> /// <param name="SamplingChannels">The number of channels to sample</param> /// <param name="SamplingTime">The total time to sample (in milliseconds)</param> /// <param name="SamplingMode">The sampling mode</param> /// <param name="SamplingCompression">'true' if compression is to be used</param> public DataGrabber(AbstractController Controller, int SamplingRate, int SamplingChannels, int SamplingTime, SamplingModes SamplingMode, bool SamplingCompression) { if (Controller == null) throw new Exception("DataGrabber: Invalid controller"); this.Controller = Controller; this.SamplingRate = SamplingRate; this.SamplingChannels = SamplingChannels; this.SamplingMode = SamplingMode; this.SamplingTime = SamplingTime; this.SamplingCompression = SamplingCompression; this.Data = new List<byte>(); Controller.OnDataReceived += new EventHandler<ControllerEventArgs>(Controller_OnDataReceived); Controller.OnError += new EventHandler<ControllerEventArgs>(Controller_OnError); }
/// <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> /// Creates an initializes a DataGrabber object. /// </summary> /// <param name="Controller">A controller for the device being sampled</param> public DataGrabber(AbstractController Controller) : this(Controller, 1000, 4, 1000, SamplingModes.Continuous, true) { }