Skip to content

Commit

Permalink
Merge pull request #14 from glopesdev/data-ptr
Browse files Browse the repository at this point in the history
Expose unmanaged pointer to frame data payload
  • Loading branch information
jonnew authored Jul 11, 2023
2 parents 2a33ef3 + db86d44 commit 4ef9aa6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/clroni/clroni-test/Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void CaptureData()
{
if (display)
{
var dat = frame.Data<ushort>();
var dat = frame.GetData<ushort>();
var idx = frame.DeviceAddress;
Console.WriteLine("\t[{0}] Dev: {1} ({2})", frame.Clock, idx, ctx.DeviceTable[idx].Description);
Console.WriteLine("\t[{0}]", String.Join(", ", dat));
Expand Down
17 changes: 12 additions & 5 deletions api/clroni/clroni/Frame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ protected override bool ReleaseHandle()
}

/// <summary>
/// Retrieve a managed copy of the <see cref="Frame"/> data.
/// Retrieves a managed copy of the <see cref="Frame"/> data.
/// </summary>
/// <returns>Array containing the <see cref="Frame"/> data.</returns>
public T[] Data<T>() where T : unmanaged
/// <returns>
/// A managed array containing a copy of the <see cref="Frame"/> data.
/// </returns>
public T[] GetData<T>() where T : unmanaged
{
var frame = (frame_t*)handle.ToPointer();
var output = new T[frame->data_sz / sizeof(T)];
Expand All @@ -68,7 +70,7 @@ public T[] Data<T>() where T : unmanaged
}

/// <summary>
/// Retrieve the host acquisition clock counter value at frame creation.
/// The host acquisition clock counter value at frame creation.
/// See <see cref="Context.AcquisitionClockHz"/> and
/// <see cref="Context.ResetFrameClock"/>.
/// </summary>
Expand All @@ -81,8 +83,13 @@ public T[] Data<T>() where T : unmanaged
public uint DeviceAddress => ((frame_t*)handle.ToPointer())->dev_idx;

/// <summary>
/// Get the payload data size in bytes. See <see cref="Frame.Data{T}"/>.
/// The payload data size in bytes.
/// </summary>
public uint DataSize => ((frame_t*)handle.ToPointer())->data_sz;

/// <summary>
/// A pointer to the payload data.
/// </summary>
public IntPtr Data => (IntPtr)((frame_t*)handle.ToPointer())->data;
}
}
4 changes: 1 addition & 3 deletions api/clroni/clroni/clroni.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<PackageTags>ONI Open Ephys ONIX</PackageTags>
<TargetFramework>net472</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Version>5.0.1</Version>
<Version>6.0.0</Version>
<Authors>Jon Newman</Authors>
<Company>Open Ephys</Company>
<Copyright>Copyright © Jonathan Newman</Copyright>
Expand All @@ -15,8 +15,6 @@
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<Platforms>AnyCPU;x64</Platforms>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<FileVersion>5.0.0.0</FileVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RepositoryUrl>https://github.com/open-ephys/liboni</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down

0 comments on commit 4ef9aa6

Please sign in to comment.