From c50255b23628cb0018f2ddfac53ecb0c29b3f9d4 Mon Sep 17 00:00:00 2001 From: glopesdev Date: Tue, 2 Jul 2024 21:52:22 +0100 Subject: [PATCH] Read device ID from type metadata --- .../OpenEphys.Onix/ConfigureAnalogIO.cs | 2 +- .../OpenEphys.Onix/ConfigureBno055.cs | 2 +- .../OpenEphys.Onix/ConfigureDS90UB9x.cs | 2 +- .../OpenEphys.Onix/ConfigureDigitalIO.cs | 2 +- .../ConfigureFmcLinkController.cs | 2 +- .../OpenEphys.Onix/ConfigureHarpSyncInput.cs | 2 +- ...onfigureHeadstage64ElectricalStimulator.cs | 2 +- .../OpenEphys.Onix/ConfigureHeartbeat.cs | 2 +- .../OpenEphys.Onix/ConfigureLoadTester.cs | 2 +- .../OpenEphys.Onix/ConfigureMemoryMonitor.cs | 2 +- .../OpenEphys.Onix/ConfigureNeuropixelsV1e.cs | 2 +- .../ConfigureNeuropixelsV1eBno055.cs | 2 +- .../OpenEphys.Onix/ConfigureNeuropixelsV2e.cs | 2 +- .../ConfigureNeuropixelsV2eBeta.cs | 2 +- .../ConfigureNeuropixelsV2eBno055.cs | 2 +- .../OpenEphys.Onix/ConfigureRhd2164.cs | 2 +- .../OpenEphys.Onix/ConfigureTS4231.cs | 2 +- .../OpenEphys.Onix/ConfigureTest0.cs | 2 +- .../OpenEphys.Onix/ContextHelper.cs | 47 ++++++++++++++----- OpenEphys.Onix/OpenEphys.Onix/DeviceInfo.cs | 2 +- .../NeuropixelsV1eBno055Data.cs | 2 +- .../OpenEphys.Onix/NeuropixelsV1eData.cs | 2 +- .../OpenEphys.Onix/NeuropixelsV2eBetaData.cs | 2 +- .../NeuropixelsV2eBno055Data.cs | 2 +- .../OpenEphys.Onix/NeuropixelsV2eData.cs | 2 +- 25 files changed, 60 insertions(+), 35 deletions(-) diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureAnalogIO.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureAnalogIO.cs index 82cc7a3d..d36805ed 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureAnalogIO.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureAnalogIO.cs @@ -119,7 +119,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, AnalogIO.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(AnalogIO.ENABLE, Enable ? 1u : 0u); device.WriteRegister(AnalogIO.CH00INRANGE, (uint)InputRange0); device.WriteRegister(AnalogIO.CH01INRANGE, (uint)InputRange1); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureBno055.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureBno055.cs index b2b297ac..8605c9d0 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureBno055.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureBno055.cs @@ -20,7 +20,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, Bno055.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(Bno055.ENABLE, Enable ? 1u : 0); return DeviceManager.RegisterDevice(deviceName, device, DeviceType); }); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureDS90UB9x.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureDS90UB9x.cs index 852fc1e7..67bcae7b 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureDS90UB9x.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureDS90UB9x.cs @@ -21,7 +21,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, DS90UB9x.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(DS90UB9x.ENABLE, enable ? 1u : 0); return DeviceManager.RegisterDevice(deviceName, device, DeviceType); }); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureDigitalIO.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureDigitalIO.cs index eedf9797..c4996c0b 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureDigitalIO.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureDigitalIO.cs @@ -21,7 +21,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, DigitalIO.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(DigitalIO.ENABLE, Enable ? 1u : 0); return DeviceManager.RegisterDevice(deviceName, device, DeviceType); }); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureFmcLinkController.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureFmcLinkController.cs index 5d3442c1..4ad8927d 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureFmcLinkController.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureFmcLinkController.cs @@ -53,7 +53,7 @@ public override IObservable Process(IObservable source }) .ConfigureLink(context => { - var device = context.GetDeviceContext(deviceAddress, FmcLinkController.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); void dispose() => device.WriteRegister(FmcLinkController.PORTVOLTAGE, 0); device.WriteRegister(FmcLinkController.ENABLE, 1); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureHarpSyncInput.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureHarpSyncInput.cs index 4f5debf9..65412776 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureHarpSyncInput.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureHarpSyncInput.cs @@ -25,7 +25,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, HarpSyncInput.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(HarpSyncInput.ENABLE, Enable ? 1u : 0); device.WriteRegister(HarpSyncInput.SOURCE, (uint)Source); return DeviceManager.RegisterDevice(deviceName, device, DeviceType); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeadstage64ElectricalStimulator.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeadstage64ElectricalStimulator.cs index fe5d8c5e..3cfef694 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeadstage64ElectricalStimulator.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeadstage64ElectricalStimulator.cs @@ -15,7 +15,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, Headstage64ElectricalStimulator.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(Headstage64ElectricalStimulator.ENABLE, 0); return DeviceManager.RegisterDevice(deviceName, device, DeviceType); }); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeartbeat.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeartbeat.cs index c0c2c9f5..972ab53f 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeartbeat.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureHeartbeat.cs @@ -35,7 +35,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, Heartbeat.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(Heartbeat.ENABLE, 1); var subscription = beatsPerSecond.Subscribe(newValue => { diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureLoadTester.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureLoadTester.cs index 4c02a155..68018b1a 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureLoadTester.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureLoadTester.cs @@ -42,7 +42,7 @@ public override IObservable Process(IObservable source var transmittedWords = TransmittedWords; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, LoadTester.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(LoadTester.ENABLE, 1); var clk_hz = device.ReadRegister(LoadTester.CLK_HZ); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureMemoryMonitor.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureMemoryMonitor.cs index 633407c2..f3dacca0 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureMemoryMonitor.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureMemoryMonitor.cs @@ -28,7 +28,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, MemoryMonitor.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(MemoryMonitor.ENABLE, 1); device.WriteRegister(MemoryMonitor.CLK_DIV, device.ReadRegister(MemoryMonitor.CLK_HZ) / SampleFrequency); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1e.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1e.cs index c799a73c..eaa4fc87 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1e.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1e.cs @@ -56,7 +56,7 @@ public override IObservable Process(IObservable source return source.ConfigureDevice(context => { // configure device via the DS90UB9x deserializer device - var device = context.GetPassthroughDeviceContext(deviceAddress, DS90UB9x.ID); + var device = context.GetPassthroughDeviceContext(deviceAddress, typeof(DS90UB9x)); device.WriteRegister(DS90UB9x.ENABLE, enable ? 1u : 0); // configure deserializer aliases and serializer power supply diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1eBno055.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1eBno055.cs index 55b6ebe3..9dc9e3ae 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1eBno055.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV1eBno055.cs @@ -22,7 +22,7 @@ public override IObservable Process(IObservable source return source.ConfigureDevice(context => { // configure device via the DS90UB9x deserializer device - var device = context.GetPassthroughDeviceContext(deviceAddress, DS90UB9x.ID); + var device = context.GetPassthroughDeviceContext(deviceAddress, typeof(DS90UB9x)); ConfigureDeserializer(device); ConfigureBno055(device); var deviceInfo = new DeviceInfo(context, DeviceType, deviceAddress); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2e.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2e.cs index e2e402a5..192adce0 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2e.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2e.cs @@ -42,7 +42,7 @@ public override IObservable Process(IObservable source return source.ConfigureDevice(context => { // configure device via the DS90UB9x deserializer device - var device = context.GetPassthroughDeviceContext(deviceAddress, DS90UB9x.ID); + var device = context.GetPassthroughDeviceContext(deviceAddress, typeof(DS90UB9x)); device.WriteRegister(DS90UB9x.ENABLE, enable ? 1u : 0); // configure deserializer aliases and serializer power supply diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBeta.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBeta.cs index 0da820fb..65926a20 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBeta.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBeta.cs @@ -46,7 +46,7 @@ public override IObservable Process(IObservable source return source.ConfigureDevice(context => { // configure device via the DS90UB9x deserializer device - var device = context.GetPassthroughDeviceContext(deviceAddress, DS90UB9x.ID); + var device = context.GetPassthroughDeviceContext(deviceAddress, typeof(DS90UB9x)); device.WriteRegister(DS90UB9x.ENABLE, enable ? 1u : 0); // configure deserializer aliases and serializer power supply diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBno055.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBno055.cs index 1a6d10b4..1019a900 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBno055.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureNeuropixelsV2eBno055.cs @@ -22,7 +22,7 @@ public override IObservable Process(IObservable source return source.ConfigureDevice(context => { // configure device via the DS90UB9x deserializer device - var device = context.GetPassthroughDeviceContext(deviceAddress, DS90UB9x.ID); + var device = context.GetPassthroughDeviceContext(deviceAddress, typeof(DS90UB9x)); ConfigureDeserializer(device); ConfigureBno055(device); var deviceInfo = new DeviceInfo(context, DeviceType, deviceAddress); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureRhd2164.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureRhd2164.cs index 76929557..40ae4d30 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureRhd2164.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureRhd2164.cs @@ -39,7 +39,7 @@ public override IObservable Process(IObservable source { // config register format following RHD2164 datasheet // https://intantech.com/files/Intan_RHD2000_series_datasheet.pdf - var device = context.GetDeviceContext(deviceAddress, Rhd2164.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); var format = device.ReadRegister(Rhd2164.FORMAT); var amplifierDataFormat = AmplifierDataFormat; diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureTS4231.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureTS4231.cs index 1c954e71..0c6577e1 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureTS4231.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureTS4231.cs @@ -20,7 +20,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, TS4231.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(TS4231.ENABLE, Enable ? 1u : 0); return DeviceManager.RegisterDevice(deviceName, device, DeviceType); }); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ConfigureTest0.cs b/OpenEphys.Onix/OpenEphys.Onix/ConfigureTest0.cs index b1138b61..9d9cfa5c 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ConfigureTest0.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ConfigureTest0.cs @@ -42,7 +42,7 @@ public override IObservable Process(IObservable source var deviceAddress = DeviceAddress; return source.ConfigureDevice(context => { - var device = context.GetDeviceContext(deviceAddress, Test0.ID); + var device = context.GetDeviceContext(deviceAddress, DeviceType); device.WriteRegister(Test0.ENABLE, Enable ? 1u : 0); FrameRateHz = device.ReadRegister(Test0.FRAMERATE); DummyCount = device.ReadRegister(Test0.NUMTESTWORDS); diff --git a/OpenEphys.Onix/OpenEphys.Onix/ContextHelper.cs b/OpenEphys.Onix/OpenEphys.Onix/ContextHelper.cs index 87a4b721..c8dff0bb 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/ContextHelper.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/ContextHelper.cs @@ -1,20 +1,21 @@ using System; +using System.Reflection; using oni; namespace OpenEphys.Onix { static class ContextHelper { - public static DeviceContext GetDeviceContext(this ContextTask context, uint address, int id) + public static DeviceContext GetDeviceContext(this ContextTask context, uint address, Type expectedType) { if (!context.DeviceTable.TryGetValue(address, out Device device)) { - throw new InvalidOperationException($"The specified device '{id}:{address}' is not present in the device table."); + ThrowDeviceNotFoundException(expectedType, address); } - if (device.ID != id) + if (device.ID != GetDeviceID(expectedType)) { - throw new InvalidOperationException($"The selected device is not a {id} device."); + ThrowInvalidDeviceException(expectedType, address); } return new DeviceContext(context, device); @@ -25,23 +26,47 @@ public static DeviceContext GetDeviceContext(this DeviceInfo deviceInfo, Type ex deviceInfo.AssertType(expectedType); if (!deviceInfo.Context.DeviceTable.TryGetValue(deviceInfo.DeviceAddress, out Device device)) { - throw new InvalidOperationException( - $"The specified device '{expectedType}:{deviceInfo.DeviceAddress}' is not present in the device table." - ); + ThrowDeviceNotFoundException(expectedType, deviceInfo.DeviceAddress); } return new DeviceContext(deviceInfo.Context, device); } - public static DeviceContext GetPassthroughDeviceContext(this ContextTask context, uint address, int id) + public static DeviceContext GetPassthroughDeviceContext(this ContextTask context, uint address, Type expectedType) { var passthroughDeviceAddress = context.GetPassthroughDeviceAddress(address); - return GetDeviceContext(context, passthroughDeviceAddress, id); + return GetDeviceContext(context, passthroughDeviceAddress, expectedType); } - public static DeviceContext GetPassthroughDeviceContext(this DeviceContext device, int id) + public static DeviceContext GetPassthroughDeviceContext(this DeviceContext device, Type expectedType) { - return GetPassthroughDeviceContext(device.Context, device.Address, id); + return GetPassthroughDeviceContext(device.Context, device.Address, expectedType); + } + + static int GetDeviceID(Type deviceType) + { + var fieldInfo = deviceType.GetField( + "ID", + BindingFlags.Static | + BindingFlags.Public | + BindingFlags.NonPublic | + BindingFlags.IgnoreCase); + if (fieldInfo == null || !fieldInfo.IsLiteral) + { + throw new ArgumentException($"The specified device type {deviceType} does not have a const ID field.", nameof(deviceType)); + } + + return (int)fieldInfo.GetRawConstantValue(); + } + + static void ThrowDeviceNotFoundException(Type expectedType, uint address) + { + throw new InvalidOperationException($"Device '{expectedType.Name}' was not found in the device table at address {address}."); + } + + static void ThrowInvalidDeviceException(Type expectedType, uint address) + { + throw new InvalidOperationException($"Invalid device ID. The device found at address {address} is not a '{expectedType.Name}' device."); } } } diff --git a/OpenEphys.Onix/OpenEphys.Onix/DeviceInfo.cs b/OpenEphys.Onix/OpenEphys.Onix/DeviceInfo.cs index 53059dcf..94fc8d74 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/DeviceInfo.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/DeviceInfo.cs @@ -27,7 +27,7 @@ public void AssertType(Type expectedType) if (DeviceType != expectedType) { throw new InvalidOperationException( - $"Expected device with register type {expectedType}. Actual type is {DeviceType}." + $"Expected device of type {expectedType.Name}. Actual type is {DeviceType.Name}." ); } } diff --git a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eBno055Data.cs b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eBno055Data.cs index fba34333..7a699148 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eBno055Data.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eBno055Data.cs @@ -27,7 +27,7 @@ public unsafe IObservable Generate(IObservable Observable.Create(observer => { var device = deviceInfo.GetDeviceContext(typeof(NeuropixelsV1eBno055)); - var passthrough = device.GetPassthroughDeviceContext(DS90UB9x.ID); + var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x)); var i2c = new I2CRegisterContext(passthrough, NeuropixelsV1eBno055.BNO055Address); var pollingObserver = Observer.Create( diff --git a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eData.cs b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eData.cs index 506ca3dd..55d70f92 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eData.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV1eData.cs @@ -33,7 +33,7 @@ public unsafe override IObservable Generate() { var info = (NeuropixelsV1eDeviceInfo)deviceInfo; var device = info.GetDeviceContext(typeof(NeuropixelsV1e)); - var passthrough = device.GetPassthroughDeviceContext(DS90UB9x.ID); + var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x)); var probeData = device.Context.FrameReceived.Where(frame => frame.DeviceAddress == passthrough.Address); return Observable.Create(observer => diff --git a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBetaData.cs b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBetaData.cs index 9be5f2e2..4de16e61 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBetaData.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBetaData.cs @@ -26,7 +26,7 @@ public unsafe override IObservable Generate() { var info = (NeuropixelsV2eDeviceInfo)deviceInfo; var device = info.GetDeviceContext(typeof(NeuropixelsV2eBeta)); - var passthrough = device.GetPassthroughDeviceContext(DS90UB9x.ID); + var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x)); var probeData = device.Context.FrameReceived.Where(frame => frame.DeviceAddress == passthrough.Address && NeuropixelsV2eBetaDataFrame.GetProbeIndex(frame) == (int)ProbeIndex); diff --git a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBno055Data.cs b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBno055Data.cs index ddf3c053..981ac1a7 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBno055Data.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eBno055Data.cs @@ -27,7 +27,7 @@ public unsafe IObservable Generate(IObservable Observable.Create(observer => { var device = deviceInfo.GetDeviceContext(typeof(NeuropixelsV2eBno055)); - var passthrough = device.GetPassthroughDeviceContext(DS90UB9x.ID); + var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x)); var i2c = new I2CRegisterContext(passthrough, NeuropixelsV2eBno055.BNO055Address); var pollingObserver = Observer.Create( diff --git a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eData.cs b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eData.cs index a86d6eb5..fcad11c2 100644 --- a/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eData.cs +++ b/OpenEphys.Onix/OpenEphys.Onix/NeuropixelsV2eData.cs @@ -26,7 +26,7 @@ public unsafe override IObservable Generate() { var info = (NeuropixelsV2eDeviceInfo)deviceInfo; var device = info.GetDeviceContext(typeof(NeuropixelsV2e)); - var passthrough = device.GetPassthroughDeviceContext(DS90UB9x.ID); + var passthrough = device.GetPassthroughDeviceContext(typeof(DS90UB9x)); var probeData = device.Context.FrameReceived.Where(frame => frame.DeviceAddress == passthrough.Address && NeuropixelsV2eDataFrame.GetProbeIndex(frame) == (int)ProbeIndex);