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

Modularize API and code review #9

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion OpenEphys.ProbeInterface.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34511.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenEphys.ProbeInterface.NET", "OpenEphys.ProbeInterface.NET\OpenEphys.ProbeInterface.NET.csproj", "{822F3536-A4B7-4FE4-8332-A75A8458EE56}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenEphys.ProbeInterface.NET", "OpenEphys.ProbeInterface.NET\OpenEphys.ProbeInterface.NET.csproj", "{822F3536-A4B7-4FE4-8332-A75A8458EE56}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8644FAC-94E5-4E73-B809-925ABABE35B1}"
ProjectSection(SolutionItems) = preProject
Expand Down
72 changes: 72 additions & 0 deletions OpenEphys.ProbeInterface.NET/Contact.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
namespace OpenEphys.ProbeInterface.NET
{
/// <summary>
/// Struct that extends the Probeinterface specification by encapsulating all values for a single contact.
/// </summary>
public readonly struct Contact
{
/// <summary>
/// Gets the x-position of the contact.
/// </summary>
public float PosX { get; }

/// <summary>
/// Gets the y-position of the contact.
/// </summary>
public float PosY { get; }

/// <summary>
/// Gets the <see cref="ContactShape"/> of the contact.
/// </summary>
public ContactShape Shape { get; }

/// <summary>
/// Gets the <see cref="ContactShapeParam"/>'s of the contact.
/// </summary>
public ContactShapeParam ShapeParams { get; }

/// <summary>
/// Gets the device ID of the contact.
/// </summary>
public int DeviceId { get; }

/// <summary>
/// Gets the contact ID of the contact.
/// </summary>
public string ContactId { get; }

/// <summary>
/// Gets the shank ID of the contact.
/// </summary>
public string ShankId { get; }

/// <summary>
/// Gets the index of the contact within the <see cref="Probe"/> object.
/// </summary>
public int Index { get; }

/// <summary>
/// Initializes a new instance of the <see cref="Contact"/> struct.
/// </summary>
/// <param name="posX"></param>
/// <param name="posY"></param>
/// <param name="shape"></param>
/// <param name="shapeParam"></param>
/// <param name="device_id"></param>
/// <param name="contact_id"></param>
/// <param name="shank_id"></param>
/// <param name="index"></param>
public Contact(float posX, float posY, ContactShape shape, ContactShapeParam shapeParam,
int device_id, string contact_id, string shank_id, int index)
{
PosX = posX;
PosY = posY;
Shape = shape;
ShapeParams = shapeParam;
DeviceId = device_id;
ContactId = contact_id;
ShankId = shank_id;
Index = index;
}
}
}
25 changes: 25 additions & 0 deletions OpenEphys.ProbeInterface.NET/ContactAnnotations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using Newtonsoft.Json;

namespace OpenEphys.ProbeInterface.NET
{
/// <summary>
/// Class holding all of the annotations for each contact.
/// </summary>
public class ContactAnnotations
{
/// <summary>
/// Gets the array of strings holding annotations for each contact. Not all indices must have annotations.
/// </summary>
public string[] Annotations { get; protected set; }

/// <summary>
/// Initializes a new instance of the <see cref="ContactAnnotations"/> class.
/// </summary>
/// <param name="contactAnnotations"></param>
[JsonConstructor]
public ContactAnnotations(string[] contactAnnotations)
{
Annotations = contactAnnotations;
}
}
}
31 changes: 31 additions & 0 deletions OpenEphys.ProbeInterface.NET/ContactShape.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace OpenEphys.ProbeInterface.NET
{
/// <summary>
/// Shape of the contact.
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public enum ContactShape
{
/// <summary>
/// Circle.
/// </summary>
[EnumMember(Value = "circle")]
Circle = 0,

/// <summary>
/// Rectangle.
/// </summary>
[EnumMember(Value = "rect")]
Rect = 1,

/// <summary>
/// Square.
/// </summary>
[EnumMember(Value = "square")]
Square = 2,
}
}
63 changes: 63 additions & 0 deletions OpenEphys.ProbeInterface.NET/ContactShapeParam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Newtonsoft.Json;

namespace OpenEphys.ProbeInterface.NET
{
/// <summary>
/// Class holding parameters used to draw the contact.
/// </summary>
/// <remarks>
/// Fields are nullable, since not all fields are required depending on the shape selected.
/// </remarks>
public class ContactShapeParam
{
/// <summary>
/// Gets the radius of the contact.
/// </summary>
/// <remarks>
/// This is only used to draw <see cref="ContactShape.Circle"/> contacts. Field can be null.
/// </remarks>
public float? Radius { get; protected set; }

/// <summary>
/// Gets the width of the contact.
/// </summary>
/// <remarks>
/// This is used to draw <see cref="ContactShape.Square"/> or <see cref="ContactShape.Rect"/> contacts.
/// Field can be null.
/// </remarks>
public float? Width { get; protected set; }

/// <summary>
/// Gets the height of the contact.
/// </summary>
/// <remarks>
/// This is only used to draw <see cref="ContactShape.Rect"/> contacts. Field can be null.
/// </remarks>
public float? Height { get; protected set; }

/// <summary>
/// Initializes a new instance of the <see cref="ContactShapeParam"/> class.
/// </summary>
/// <param name="radius">Radius. Can be null.</param>
/// <param name="width">Width. Can be null.</param>
/// <param name="height">Height. Can be null.</param>
[JsonConstructor]
public ContactShapeParam(float? radius = null, float? width = null, float? height = null)
{
Radius = radius;
Width = width;
Height = height;
}

/// <summary>
/// Copy constructor given an existing <see cref="ContactShapeParam"/> object.
/// </summary>
/// <param name="shape"></param>
protected ContactShapeParam(ContactShapeParam shape)
{
Radius = shape.Radius;
Width = shape.Width;
Height = shape.Height;
}
}
}
Loading