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(); })); }); }
// Overrides the ConvertFrom method of TypeConverter. public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (value is string) { var selection = new DeviceIndexSelection(); selection.StringToSelection((string)value); return(selection); } return(base.ConvertFrom(context, culture, value)); }
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 FMCVLinkDevice() { // Reference to context this.oni_ref = ONIManager.ReserveDAQ(); // TODO: Somehow get the context index from the configuration file // Find all estim devices devices = oni_ref.DAQ.DeviceMap.Where(pair => pair.Value.id == (uint)oni.Device.DeviceID.FMCVCTRL).ToDictionary(x => x.Key, x => x.Value); // Stop here if there are no estim devices to use if (devices.Count == 0) { throw new oni.ONIException((int)oni.lib.Error.DEVIDX); } // Set device selection DeviceIndex = new DeviceIndexSelection(); DeviceIndex.Indices = devices.Keys.ToArray(); }
// Setup context etc public ElectricalStimulator() //oni.Context context, uint (uint)DeviceIndex.SelectedIndex) { // Reference to context this.oni_ref = ONIManager.ReserveDAQ(); // TODO: Somehow get the context index from the configuration file // Find all estim devices devices = oni_ref.DAQ.DeviceMap.Where(pair => pair.Value.id == (uint)oni.Device.DeviceID.ESTIM).ToDictionary(x => x.Key, x => x.Value); // Stop here if there are no estim devices to use if (devices.Count == 0) { throw new oni.ONIException((int)oni.lib.Error.DEVIDX); } // Set device selection DeviceIndex = new DeviceIndexSelection(); DeviceIndex.Indices = devices.Keys.ToArray(); // Default configuration Reset(); }