Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support RHS2116 streaming and stimulation #67

Closed
wants to merge 123 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
b19f6a0
Add partial headstage RHS2116 support
jonnew Feb 23, 2024
5a136d6
Finish headstage RHS2116 support
jonnew Mar 31, 2024
fcf921a
Move register class to top-level for consistency
glopesdev Apr 3, 2024
50e29db
Fix indentation for consistency
glopesdev Apr 3, 2024
33d933d
Bring rhs2116 up to date with main and gateware 0.3
jonnew Jun 28, 2024
ea49ff5
Remove un-resolvable TODO comment
jonnew Jun 28, 2024
cbb9f70
Ensure any BNO polling exceptions are routed
glopesdev Jul 4, 2024
39ee5bc
Ensure exception is thrown on configuration error
glopesdev Jul 9, 2024
5818b57
Ensure dynamic configuration exceptions are routed
glopesdev Jul 9, 2024
e60f898
Remove unused fields and properties
glopesdev Jul 11, 2024
35d1862
Refactor context task to allow async dispose
glopesdev Jul 12, 2024
191bedb
Avoid rethrowing exception if routed to observer
glopesdev Jul 16, 2024
6eb907a
Terminate frame distribution if read frame throws
glopesdev Jul 22, 2024
75c12ef
Document analog IO
jonnew Jul 22, 2024
7a7bd95
NeuropixelsV1e documentation
bparks13 Jul 23, 2024
4eb85eb
Address comments in #142
jonnew Jul 23, 2024
4ac8aa4
Ensure device is removed even on shutdown errors
glopesdev Jul 24, 2024
9769985
Rename standard data frame properties
glopesdev Jul 24, 2024
a266c31
Add data frame abstract base classes
glopesdev Jul 24, 2024
879c318
Align heartbeat data node with data frame pattern
glopesdev Jul 24, 2024
1138ee2
Derive data types from common data frame classes
glopesdev Jul 24, 2024
517e7dd
Align memory monitor node with data frame pattern
glopesdev Jul 24, 2024
4dd39bb
NeuropixelsV2e documentation
bparks13 Jul 24, 2024
a07d1bb
Address comments
bparks13 Jul 24, 2024
58c41a7
Merge pull request #132 from neurogears/issue-131
glopesdev Jul 24, 2024
f42fb50
Merge pull request #126 from neurogears/issue-121
glopesdev Jul 24, 2024
bd54594
Remove ConfigureRhd2164.Rhd2164AmplifierDataFormat
jonnew Jul 24, 2024
20f779e
NeuropixelsV2eBeta documentation
bparks13 Jul 24, 2024
8b7852d
Document headstage-64 and related classes
jonnew Jul 24, 2024
74585bc
Remove unused enum
glopesdev Jul 24, 2024
da99155
Merge pull request #151 from neurogears/issue-149
glopesdev Jul 24, 2024
a30d975
Merge pull request #147 from neurogears/issue-140
glopesdev Jul 25, 2024
7ddea06
Refactor device manager to avoid ref count dispose
glopesdev Jul 24, 2024
3d6fb57
Rename manager getter function for clarity
glopesdev Jul 24, 2024
68552df
Merge pull request #155 from neurogears/devicemanager-refactor
glopesdev Jul 25, 2024
c946cb1
Update ConfigureRhd2164.cs
jonnew Jul 25, 2024
4bfe9c0
Update Rhd2164Data.cs
jonnew Jul 25, 2024
181bf0f
Address review comments
bparks13 Jul 25, 2024
9fb74da
Merge branch 'issue-144' into issue-158
bparks13 Jul 25, 2024
56396ac
Merge branch 'issue-141' into issue-158
bparks13 Jul 25, 2024
a1be2ef
Merge branch 'issue-148' into documentation
bparks13 Jul 25, 2024
8b2b93a
Add breakout board documentation
jonnew Jul 25, 2024
65546e3
Fixing modified variables after merges
bparks13 Jul 25, 2024
bf5ebe9
Merge branch 'issue-157' into documentation
bparks13 Jul 25, 2024
01c4e38
Minor fixes
bparks13 Jul 25, 2024
c100fe6
Remove reference to method call
bparks13 Jul 25, 2024
2df0ff0
Add V1 to TS4231 class names
jonnew Jul 25, 2024
f2db16f
Fix properties in several basic device types
jonnew Jul 25, 2024
de1d561
Validate device name argument against null
glopesdev Jul 25, 2024
b5d8720
Ensure dynamic property subscription error routing
glopesdev Jul 25, 2024
d9066e0
Remove Test0 device from FMC package
glopesdev Jul 25, 2024
8aa7eed
Rename AnalogIO and DigitalIO to refer to breakout
glopesdev Jul 25, 2024
63bbc4f
Remove unused enum type
glopesdev Jul 25, 2024
2b70a4c
Address review comments from #153
bparks13 Jul 26, 2024
649ac2d
Merge pull request #163 from neurogears/api-cleanup
glopesdev Jul 26, 2024
9ca6531
Merge pull request #164 from neurogears/issue-160
glopesdev Jul 26, 2024
96c64b7
Add TS4231 data source that automatically calculates 3D positions
jonnew Jul 26, 2024
d628246
Update ConfigureHeadstage64.cs
jonnew Jul 26, 2024
9b78802
Improve existing TS4231 documentation
jonnew Jul 26, 2024
571b8b2
Address code review
jonnew Jul 26, 2024
ac28b93
Merge pull request #166 from neurogears/issue-152-attempt2
jonnew Jul 26, 2024
4097251
TS4231 code cleanup
jonnew Jul 26, 2024
7b4c7de
Document TS4231V1GeometricPositionData/Frame
jonnew Jul 26, 2024
7574e63
Group frame distribution by device address
glopesdev Jul 25, 2024
c809023
Merge pull request #110 from neurogears/issue-62
glopesdev Jul 26, 2024
ad55181
Merge branch 'issue-167' into documentation
bparks13 Jul 26, 2024
6216f5e
Add docs for TS4231V1DataFrame
jonnew Jul 26, 2024
80dcdb9
Merge branch 'documentation'
jonnew Jul 26, 2024
a5e0505
Remove geometric prefix
glopesdev Jul 27, 2024
6dc9e26
Merge pull request #171 from neurogears/naming-refactor
glopesdev Jul 27, 2024
c123dd5
Update package dependencies
glopesdev Jul 27, 2024
391ad2b
Unify processor architecture
glopesdev Jul 27, 2024
56e026c
Remove unused configuration operator for DS90UB9x
glopesdev Jul 27, 2024
7bdb036
Avoid exposing internal implementation classes
glopesdev Jul 27, 2024
fb191f0
Merge pull request #172 from neurogears/api-cleanup
glopesdev Jul 28, 2024
ff250e9
Internalize implementation specific members
glopesdev Jul 29, 2024
4088fd6
Merge pull request #175 from neurogears/issue-174
glopesdev Jul 29, 2024
7ef2536
Document ContextTask public API
jonnew Jul 29, 2024
01e3661
Document StartAcquisition and CreateContext
jonnew Jul 29, 2024
589370e
Add missing descriptions and improve wording
glopesdev Jul 29, 2024
cf1557f
Address review comments
glopesdev Jul 30, 2024
e8add7f
Merge pull request #177 from neurogears/issue-173-internalized
glopesdev Jul 30, 2024
2b1039b
Refactor project folder structure
glopesdev Jul 30, 2024
dcbc0c5
Use artifacts output layout
glopesdev Jul 30, 2024
25010e4
Avoid packing empty project
glopesdev Jul 30, 2024
a38c23f
Add package README file
glopesdev Jul 30, 2024
259cd20
Add build CI workflow with package artifacts
glopesdev Jul 30, 2024
9347ce3
Merge pull request #179 from neurogears/release-automation
glopesdev Jul 31, 2024
744d587
Minor documentation edits
jonnew Jul 31, 2024
fcca30a
Add functional README file
jonnew Aug 1, 2024
be731ce
Merge pull request #183 from open-ephys/add-readme
glopesdev Aug 1, 2024
bd979f5
Merge pull request #181 from open-ephys/20240731-docs-edits
glopesdev Aug 1, 2024
ba63945
Rename hub to multi-device factory for clarity
glopesdev Aug 1, 2024
66f858b
Merge pull request #184 from open-ephys/naming-refactor
glopesdev Aug 1, 2024
2bb4474
Rename project to OpenEphys.Onix1
glopesdev Aug 1, 2024
e44531d
Add package project and repository URLs
glopesdev Aug 1, 2024
e7a63cb
Merge pull request #185 from open-ephys/naming-refactor
glopesdev Aug 1, 2024
cf4ce2f
Publish packages to github on push to main
glopesdev Aug 2, 2024
5dc8fb8
Merge pull request #187 from open-ephys/release-automation
glopesdev Aug 2, 2024
9215835
Minor updates to documentation
jonnew Aug 2, 2024
7e2c852
Publish packages to github on release
glopesdev Aug 2, 2024
0b071bf
Ensure build suffix is declared at job level
glopesdev Aug 2, 2024
7a3a6c2
Change spelling
bparks13 Aug 2, 2024
7cb45a2
Merge pull request #189 from open-ephys/20240802-docs-update
bparks13 Aug 2, 2024
18b50bf
Fix register mapping for Neuropixels 2.0 public probes
jonnew Aug 3, 2024
de8af86
Resolve issues in discussion of #189
jonnew Aug 4, 2024
beb4610
Disconnect i2c bus from probes before streaming
jonnew Aug 4, 2024
b86733c
Fix neuropixels gain corrections
jonnew Aug 5, 2024
62aa90b
Merge pull request #190 from open-ephys/issue-186
jonnew Aug 6, 2024
e2b7f72
Address review in #194
jonnew Aug 6, 2024
ee8a775
Minor wording review
glopesdev Aug 6, 2024
cf48a92
Merge pull request #194 from open-ephys/20240804-docs-update
glopesdev Aug 6, 2024
3cbf6ca
Merge pull request #196 from open-ephys/release-automation
glopesdev Aug 6, 2024
13fb905
Update bootstrapper version
glopesdev Aug 6, 2024
7ac700f
Merge pull request #197 from open-ephys/bootstrapper-update
glopesdev Aug 7, 2024
01b36a2
Add partial headstage RHS2116 support
jonnew Feb 23, 2024
4209da7
Finish headstage RHS2116 support
jonnew Mar 31, 2024
84ec7ed
Fix indentation for consistency
glopesdev Apr 3, 2024
51fb1fb
Bring rhs2116 up to date with main and gateware 0.3
jonnew Jun 28, 2024
6e8133e
Remove un-resolvable TODO comment
jonnew Jun 28, 2024
208d631
Bring rhs2116 classes up to date with latest API
jonnew Aug 8, 2024
068c681
Merge branch 'issue-26' of github.com:open-ephys/onix-bonsai-onix1 in…
jonnew Aug 8, 2024
07871b4
Fix sytax errors introduced during conflict resolution
jonnew Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Bonsai/Bonsai.config
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Packages>
<Package id="Bonsai" version="2.8.1" />
<Package id="Bonsai.Core" version="2.8.1" />
<Package id="Bonsai.Design" version="2.8.0" />
<Package id="Bonsai" version="2.8.3" />
<Package id="Bonsai.Core" version="2.8.2" />
<Package id="Bonsai.Design" version="2.8.1" />
<Package id="Bonsai.Design.Visualizers" version="2.8.0" />
<Package id="Bonsai.Dsp" version="2.8.0" />
<Package id="Bonsai.Dsp.Design" version="2.8.0" />
<Package id="Bonsai.Editor" version="2.8.0" />
<Package id="Bonsai.Editor" version="2.8.2" />
<Package id="Bonsai.Scripting.Expressions" version="2.8.0" />
<Package id="Bonsai.Scripting.Expressions.Design" version="2.8.0" />
<Package id="Bonsai.System" version="2.8.0" />
<Package id="Bonsai.System.Design" version="2.8.0" />
<Package id="Bonsai.Vision" version="2.8.0" />
<Package id="Bonsai.Vision.Design" version="2.8.0" />
<Package id="Bonsai.Windows.Input" version="2.7.0" />
<Package id="jacobslusser.ScintillaNET" version="3.6.3" />
<Package id="Markdig" version="0.18.1" />
<Package id="MathNet.Numerics" version="5.0.0" />
<Package id="Microsoft.Web.WebView2" version="1.0.1823.32" />
<Package id="OpenCV.Net" version="3.4.2" />
<Package id="OpenEphys.PhaseDetector" version="0.6.0" />
<Package id="OpenTK" version="3.1.0" />
<Package id="OpenTK.GLControl" version="3.1.0" />
<Package id="Rx-Core" version="2.2.5" />
Expand All @@ -43,26 +46,31 @@
<AssemblyReference assemblyName="Bonsai.System.Design" />
<AssemblyReference assemblyName="Bonsai.Vision" />
<AssemblyReference assemblyName="Bonsai.Vision.Design" />
<AssemblyReference assemblyName="Bonsai.Windows.Input" />
<AssemblyReference assemblyName="OpenEphys.PhaseDetector" />
</AssemblyReferences>
<AssemblyLocations>
<AssemblyLocation assemblyName="Bonsai" processorArchitecture="MSIL" location="Packages\Bonsai.2.8.1\lib\net48\Bonsai.exe" />
<AssemblyLocation assemblyName="Bonsai.Core" processorArchitecture="MSIL" location="Packages\Bonsai.Core.2.8.1\lib\net462\Bonsai.Core.dll" />
<AssemblyLocation assemblyName="Bonsai.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Design.2.8.0\lib\net462\Bonsai.Design.dll" />
<AssemblyLocation assemblyName="Bonsai" processorArchitecture="MSIL" location="Packages\Bonsai.2.8.3\lib\net48\Bonsai.exe" />
<AssemblyLocation assemblyName="Bonsai.Core" processorArchitecture="MSIL" location="Packages\Bonsai.Core.2.8.2\lib\net462\Bonsai.Core.dll" />
<AssemblyLocation assemblyName="Bonsai.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Design.2.8.1\lib\net462\Bonsai.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Design.Visualizers" processorArchitecture="MSIL" location="Packages\Bonsai.Design.Visualizers.2.8.0\lib\net462\Bonsai.Design.Visualizers.dll" />
<AssemblyLocation assemblyName="Bonsai.Dsp" processorArchitecture="MSIL" location="Packages\Bonsai.Dsp.2.8.0\lib\net462\Bonsai.Dsp.dll" />
<AssemblyLocation assemblyName="Bonsai.Dsp.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Dsp.Design.2.8.0\lib\net462\Bonsai.Dsp.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Editor" processorArchitecture="MSIL" location="Packages\Bonsai.Editor.2.8.0\lib\net472\Bonsai.Editor.dll" />
<AssemblyLocation assemblyName="Bonsai.Editor" processorArchitecture="MSIL" location="Packages\Bonsai.Editor.2.8.2\lib\net472\Bonsai.Editor.dll" />
<AssemblyLocation assemblyName="Bonsai.Scripting.Expressions" processorArchitecture="MSIL" location="Packages\Bonsai.Scripting.Expressions.2.8.0\lib\net462\Bonsai.Scripting.Expressions.dll" />
<AssemblyLocation assemblyName="Bonsai.Scripting.Expressions.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Scripting.Expressions.Design.2.8.0\lib\net462\Bonsai.Scripting.Expressions.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.System" processorArchitecture="MSIL" location="Packages\Bonsai.System.2.8.0\lib\net462\Bonsai.System.dll" />
<AssemblyLocation assemblyName="Bonsai.System.Design" processorArchitecture="MSIL" location="Packages\Bonsai.System.Design.2.8.0\lib\net462\Bonsai.System.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Vision" processorArchitecture="MSIL" location="Packages\Bonsai.Vision.2.8.0\lib\net462\Bonsai.Vision.dll" />
<AssemblyLocation assemblyName="Bonsai.Vision.Design" processorArchitecture="MSIL" location="Packages\Bonsai.Vision.Design.2.8.0\lib\net462\Bonsai.Vision.Design.dll" />
<AssemblyLocation assemblyName="Bonsai.Windows.Input" processorArchitecture="MSIL" location="Packages\Bonsai.Windows.Input.2.7.0\lib\net462\Bonsai.Windows.Input.dll" />
<AssemblyLocation assemblyName="Markdig" processorArchitecture="MSIL" location="Packages\Markdig.0.18.1\lib\net40\Markdig.dll" />
<AssemblyLocation assemblyName="MathNet.Numerics" processorArchitecture="MSIL" location="Packages\MathNet.Numerics.5.0.0\lib\net48\MathNet.Numerics.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Core" processorArchitecture="MSIL" location="Packages\Microsoft.Web.WebView2.1.0.1823.32\lib\net45\Microsoft.Web.WebView2.Core.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.WinForms" processorArchitecture="MSIL" location="Packages\Microsoft.Web.WebView2.1.0.1823.32\lib\net45\Microsoft.Web.WebView2.WinForms.dll" />
<AssemblyLocation assemblyName="Microsoft.Web.WebView2.Wpf" processorArchitecture="MSIL" location="Packages\Microsoft.Web.WebView2.1.0.1823.32\lib\net45\Microsoft.Web.WebView2.Wpf.dll" />
<AssemblyLocation assemblyName="OpenCV.Net" processorArchitecture="MSIL" location="Packages\OpenCV.Net.3.4.2\lib\net462\OpenCV.Net.dll" />
<AssemblyLocation assemblyName="OpenEphys.PhaseDetector" processorArchitecture="MSIL" location="Packages\OpenEphys.PhaseDetector.0.6.0\lib\net472\OpenEphys.PhaseDetector.dll" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the phase detector package used in the implementation, or just for examples?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Should not be there. Also don't know why I committed this file.

<AssemblyLocation assemblyName="OpenTK" processorArchitecture="MSIL" location="Packages\OpenTK.3.1.0\lib\net20\OpenTK.dll" />
<AssemblyLocation assemblyName="OpenTK.GLControl" processorArchitecture="MSIL" location="Packages\OpenTK.GLControl.3.1.0\lib\net20\OpenTK.GLControl.dll" />
<AssemblyLocation assemblyName="ScintillaNET" processorArchitecture="MSIL" location="Packages\jacobslusser.ScintillaNET.3.6.3\lib\net40\ScintillaNET.dll" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bonsai.Core" Version="2.8.0" />
<PackageReference Include="Bonsai.Core" Version="2.8.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ConfigureFmcLinkController()
"Consult the device datasheet and documentation for allowable voltage ranges.")]
public double? PortVoltage { get; set; } = null;

protected bool CheckLinkState(DeviceContext device)
protected virtual bool CheckLinkState(DeviceContext device)
{
var linkState = device.ReadRegister(FmcLinkController.LINKSTATE);
return (linkState & FmcLinkController.LINKSTATE_SL) != 0;
Expand Down
60 changes: 34 additions & 26 deletions OpenEphys.Onix/OpenEphys.Onix/ConfigureHeadstageRhs2116.cs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file (along with a few others in the same OpenEphys.Onix/OpenEphys.Onix folder path) are leftovers from the old folder pattern. These should be removed.

Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public ConfigureHeadstageRhs2116()
[TypeConverter(typeof(HubDeviceConverter))]
public ConfigureRhs2116Trigger StimulusTrigger { get; set; } = new();

internal override void UpdateDeviceNames(string hubName)
internal override void UpdateDeviceNames()
{
LinkController.DeviceName = $"{hubName}/{nameof(LinkController)}";
Rhs2116A.DeviceName = $"{hubName}/{nameof(Rhs2116A)}";
Rhs2116B.DeviceName = $"{hubName}/{nameof(Rhs2116B)}";
StimulusTrigger.DeviceName = $"{hubName}/{nameof(StimulusTrigger)}";
LinkController.DeviceName = GetFullDeviceName(nameof(LinkController));
Rhs2116A.DeviceName = GetFullDeviceName(nameof(Rhs2116A));
Rhs2116B.DeviceName = GetFullDeviceName(nameof(Rhs2116B));
StimulusTrigger.DeviceName = GetFullDeviceName(nameof(StimulusTrigger));
}

public PortName Port
Expand All @@ -53,6 +53,16 @@ public PortName Port
}
}


[Description("If defined, it will override automated voltage discovery and apply the specified voltage" +
"to the headstage. Warning: this device requires 3.4V to 4.4V for proper operation." +
"Supplying higher voltages may result in damage to the headstage.")]
public double? PortVoltage
{
get => LinkController.PortVoltage;
set => LinkController.PortVoltage = value;
}

internal override IEnumerable<IDeviceConfiguration> GetDevices()
{
yield return LinkController;
Expand All @@ -65,40 +75,38 @@ class ConfigureHeadstageRhs2116LinkController : ConfigureFmcLinkController
{
protected override bool ConfigurePortVoltage(DeviceContext device)
{
const uint MinVoltage = 33;
const uint MaxVoltage = 50;
const uint VoltageOffset = 25;
const uint VoltageIncrement = 02;
const double MinVoltage = 3.3;
const double MaxVoltage = 4.4;
const double VoltageOffset = 2.0;
const double VoltageIncrement = 0.2;

for (uint voltage = MinVoltage; voltage <= MaxVoltage; voltage += VoltageIncrement)
for (var voltage = MinVoltage; voltage <= MaxVoltage; voltage += VoltageIncrement)
{
SetPortVoltage(device, voltage);
if (CheckLinkState(device))
if (base.CheckLinkState(device))
{
SetPortVoltage(device, voltage + VoltageOffset);
if (CheckLinkState(device))
{
// TODO: The RHS2116 headstage needs an additional reset after power on
// to provide its device table.
Thread.Sleep(500);
device.Context.Reset();
return true;
}
else break;
return CheckLinkState(device);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed this now, and was really confused. If we just need to reset before the last check, why not simply add device.Context.Reset() before the return call?

My suspicion is that perhaps this is related to the case where we want to just set a port voltage override and therefore the code does not go through this path?

In that case, maybe the best would be to mark ConfigurePortVoltageOverride itself as virtual and override that?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was addressed in #124 which does what you suggest.

}
}

return false;
}

private void SetPortVoltage(DeviceContext device, uint voltage)
private void SetPortVoltage(DeviceContext device, double voltage)
{
const int WaitUntilVoltageOffSettles = 500;
const int WaitUntilVoltageOnSettles = 500;
device.WriteRegister(FmcLinkController.PORTVOLTAGE, 0);
Thread.Sleep(WaitUntilVoltageOffSettles);
device.WriteRegister(FmcLinkController.PORTVOLTAGE, voltage);
Thread.Sleep(WaitUntilVoltageOnSettles);
Thread.Sleep(500);
device.WriteRegister(FmcLinkController.PORTVOLTAGE, (uint)(10 * voltage));
Thread.Sleep(500);
}

protected override bool CheckLinkState(DeviceContext device)
{
// NB: The RHS2116 headstage needs an additional reset after power on to provide its device table.
device.Context.Reset();
var linkState = device.ReadRegister(FmcLinkController.LINKSTATE);
return (linkState & FmcLinkController.LINKSTATE_SL) != 0;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions OpenEphys.Onix/OpenEphys.Onix/ConfigureRhs2116.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static class Rhs2116
// constants
public const int AmplifierChannelCount = 16;
public const int StimMemorySlotsAvailable = 1024;
public const double SampleFrequencyHz = 30.1932367151e3;

// managed registers
public const uint ENABLE = 0x8000; // Enable or disable the data output stream (32767)
Expand Down
2 changes: 1 addition & 1 deletion OpenEphys.Onix/OpenEphys.Onix/OpenEphys.Onix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bonsai.Core" Version="2.8.0" />
<PackageReference Include="Bonsai.Core" Version="2.8.2" />
<PackageReference Include="clroni" Version="6.1.0" />
<PackageReference Include="OpenCV.Net" Version="3.4.2" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions OpenEphys.Onix/OpenEphys.Onix/Rhs2116Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public unsafe override IObservable<Rhs2116DataFrame> Generate()
clockBuffer[sampleIndex] = frame.Clock;
if (++sampleIndex >= bufferSize)
{
var amplifierData = BufferHelper.CopyBuffer(amplifierBuffer, bufferSize, Rhs2116.AmplifierChannelCount, Depth.U16);
var dcData = BufferHelper.CopyBuffer(dcBuffer, bufferSize, Rhs2116.AmplifierChannelCount, Depth.U16);
var amplifierData = BufferHelper.CopyTranspose(amplifierBuffer, bufferSize, Rhs2116.AmplifierChannelCount, Depth.U16);
var dcData = BufferHelper.CopyTranspose(dcBuffer, bufferSize, Rhs2116.AmplifierChannelCount, Depth.U16);
observer.OnNext(new Rhs2116DataFrame(clockBuffer, hubClockBuffer, amplifierData, dcData));
hubClockBuffer = new ulong[bufferSize];
clockBuffer = new ulong[bufferSize];
Expand Down
14 changes: 10 additions & 4 deletions OpenEphys.Onix/OpenEphys.Onix/Rhs2116StimulusTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@

namespace OpenEphys.Onix
{
public class Rhs2116StimulusTrigger : Sink<bool>
public class Rhs2116StimulusTrigger : Sink<double>
{
[TypeConverter(typeof(Rhs2116Trigger.NameConverter))]
public string DeviceName { get; set; }

public override IObservable<bool> Process(IObservable<bool> source)
public override IObservable<double> Process(IObservable<double> source)
{
return Observable.Using(
() => DeviceManager.ReserveDevice(DeviceName),
disposable => disposable.Subject.SelectMany(deviceInfo =>
{
var device = deviceInfo.GetDeviceContext(typeof(Rhs2116Trigger));
return source.Do(t => device.WriteRegister(Rhs2116Trigger.TRIGGER, t ? 1u : 0u));
var device = deviceInfo.GetDeviceContext(typeof(Rhs2116Trigger));
return source.Do(t =>
{
const double SampleFrequencyMegaHz = Rhs2116.SampleFrequencyHz / 1e6;
var delaySamples = (int)(t * SampleFrequencyMegaHz);
device.WriteRegister(Rhs2116Trigger.TRIGGER, (uint)(delaySamples << 12 | 0x1));
});

}));
}
}
Expand Down