public RHDDevice() { // Reference to context this.oni_ref = ONIManager.ReserveDAQ(); // Find the hardware clock rate var sample_clock_hz = (int)50e6; // TODO: oni_ref.DAQ.AcquisitionClockHz; // Find all RHD devices devices = oni_ref.DAQ.DeviceMap.Where( pair => pair.Value.id == (uint)Device.DeviceID.RHD2132 || pair.Value.id == (uint)Device.DeviceID.RHD2164 ).ToDictionary(x => x.Key, x => x.Value); // Stop here if there are no devices to use if (devices.Count == 0) { throw new oni.ONIException((int)oni.lib.Error.DEVIDX); } DeviceIndex = new DeviceIndexSelection(); DeviceIndex.Indices = devices.Keys.ToArray(); // Set defaults here, these settings can be manipulated in the outer scope and affect the functionality of the Task, I think. SampleRate = AmplifierSampleRate.SampleRate30000Hz; LowerBandwidth = 0.1; UpperBandwidth = 7500.0; DspCutoffFrequency = 1.0; DspEnabled = true; source = Observable.Create <RHDDataFrame>(observer => { EventHandler <FrameReceivedEventArgs> inputReceived; var data_block = new RHDDataBlock(NumEphysChannels((int)devices[DeviceIndex.SelectedIndex].id), BlockSize); oni_ref.Environment.Start(); inputReceived = (sender, e) => { var frame = e.Value; //If this frame contaisn data from the selected device_index if (frame.DeviceIndices.Contains(DeviceIndex.SelectedIndex)) { // Pull the sample if (data_block.FillFromFrame(frame, DeviceIndex.SelectedIndex)) { observer.OnNext(new RHDDataFrame(data_block, sample_clock_hz)); //TODO: Does this deep copy?? data_block = new RHDDataBlock(NumEphysChannels((int)devices[DeviceIndex.SelectedIndex].id), BlockSize); } } }; oni_ref.Environment.FrameInputReceived += inputReceived; return(Disposable.Create(() => { oni_ref.Environment.FrameInputReceived -= inputReceived; oni_ref.Environment.Stop(); oni_ref.Dispose(); })); }); }
public Neuropixels1R0Device() { // Reference to context this.oni_ref = ONIManager.ReserveDAQ(); // Find the hardware clock rate var sample_clock_hz = (int)50e6; // TODO: oni_ref.DAQ.AcquisitionClockHz; // Find all RHD devices devices = oni_ref.DAQ.DeviceMap.Where( pair => pair.Value.id == (uint)oni.Device.DeviceID.NEUROPIX1R0 ).ToDictionary(x => x.Key, x => x.Value); // Stop here if there are no devices to use // TODO: this aliases into some XML error if (devices.Count == 0) { throw new oni.ONIException((int)oni.lib.Error.DEVIDX); } DeviceIndex = new DeviceIndexSelection(); DeviceIndex.Indices = devices.Keys.ToArray(); source = Observable.Create <Neuropixels1R0DataFrame>(observer => { EventHandler <FrameReceivedEventArgs> inputReceived; var data_block = new Neuropixels1R0DataBlock(BlockSize); oni_ref.Environment.Start(); inputReceived = (sender, e) => { var frame = e.Value; //If this frame contaisn data from the selected device_index if (frame.DeviceIndices.Contains(DeviceIndex.SelectedIndex)) { // Pull the sample if (data_block.FillFromFrame(frame, DeviceIndex.SelectedIndex)) { observer.OnNext(new Neuropixels1R0DataFrame(data_block, sample_clock_hz)); //TODO: Does this deep copy?? data_block = new Neuropixels1R0DataBlock(BlockSize); } } }; oni_ref.Environment.FrameInputReceived += inputReceived; return(Disposable.Create(() => { oni_ref.Environment.FrameInputReceived -= inputReceived; oni_ref.Environment.Stop(); oni_ref.Dispose(); })); }); }
public BNO055Device() { // Reference to context this.oni_ref = ONIManager.ReserveDAQ(); // Find the hardware clock rate var sys_clock_hz = oni_ref.DAQ.SystemClockHz; var sample_clock_hz = (int)50e6; // TODO: oni_ref.DAQ.AcquisitionClockHz; // Find all RHD devices devices = oni_ref.DAQ.DeviceMap.Where( pair => pair.Value.id == (uint)Device.DeviceID.BNO055 ).ToDictionary(x => x.Key, x => x.Value); // Stop here if there are no devices to use if (devices.Count == 0) { throw new ONIException((int)oni.lib.Error.DEVIDX); } DeviceIndex = new DeviceIndexSelection(); DeviceIndex.Indices = devices.Keys.ToArray(); source = Observable.Create <BNO055DataFrame>(observer => { EventHandler <FrameReceivedEventArgs> inputReceived; oni_ref.Environment.Start(); inputReceived = (sender, e) => { var frame = e.Value; // If this frame contains data from the selected device_index if (frame.DeviceIndices.Contains(DeviceIndex.SelectedIndex)) { observer.OnNext(new BNO055DataFrame(frame, DeviceIndex.SelectedIndex, sample_clock_hz, sys_clock_hz)); } }; oni_ref.Environment.FrameInputReceived += inputReceived; return(Disposable.Create(() => { oni_ref.Environment.FrameInputReceived -= inputReceived; oni_ref.Dispose(); })); }); }
public GenericDevice() { // Reference to context this.oni_ref = ONIManager.ReserveDAQ(); source = Observable.Create <Mat>(observer => { EventHandler <FrameReceivedEventArgs> inputReceived; oni_ref.Environment.Start(); inputReceived = (sender, e) => { var frame = e.Value; // If this frame contains data from the selected device_index if (frame.DeviceIndices.Contains(DeviceIndex)) { var dat = frame.Data <ushort>(DeviceIndex, ReadSize); var mat = new Mat(1, dat.Length, ElementDepth, 1); using (var header = Mat.CreateMatHeader(dat)) { CV.Convert(header, mat); } observer.OnNext(mat); } }; oni_ref.Environment.FrameInputReceived += inputReceived; return(Disposable.Create(() => { oni_ref.Environment.FrameInputReceived -= inputReceived; oni_ref.Dispose(); })); }); }