Skip to content

Commit eb79f0c

Browse files
authored
Merge pull request #9 from open-ephys/jon-review
Modularize API and code review
2 parents f3892db + a83c770 commit eb79f0c

11 files changed

+939
-1057
lines changed

OpenEphys.ProbeInterface.NET.sln

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.8.34511.84
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenEphys.ProbeInterface.NET", "OpenEphys.ProbeInterface.NET\OpenEphys.ProbeInterface.NET.csproj", "{822F3536-A4B7-4FE4-8332-A75A8458EE56}"
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenEphys.ProbeInterface.NET", "OpenEphys.ProbeInterface.NET\OpenEphys.ProbeInterface.NET.csproj", "{822F3536-A4B7-4FE4-8332-A75A8458EE56}"
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F8644FAC-94E5-4E73-B809-925ABABE35B1}"
99
ProjectSection(SolutionItems) = preProject
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
namespace OpenEphys.ProbeInterface.NET
2+
{
3+
/// <summary>
4+
/// Struct that extends the Probeinterface specification by encapsulating all values for a single contact.
5+
/// </summary>
6+
public readonly struct Contact
7+
{
8+
/// <summary>
9+
/// Gets the x-position of the contact.
10+
/// </summary>
11+
public float PosX { get; }
12+
13+
/// <summary>
14+
/// Gets the y-position of the contact.
15+
/// </summary>
16+
public float PosY { get; }
17+
18+
/// <summary>
19+
/// Gets the <see cref="ContactShape"/> of the contact.
20+
/// </summary>
21+
public ContactShape Shape { get; }
22+
23+
/// <summary>
24+
/// Gets the <see cref="ContactShapeParam"/>'s of the contact.
25+
/// </summary>
26+
public ContactShapeParam ShapeParams { get; }
27+
28+
/// <summary>
29+
/// Gets the device ID of the contact.
30+
/// </summary>
31+
public int DeviceId { get; }
32+
33+
/// <summary>
34+
/// Gets the contact ID of the contact.
35+
/// </summary>
36+
public string ContactId { get; }
37+
38+
/// <summary>
39+
/// Gets the shank ID of the contact.
40+
/// </summary>
41+
public string ShankId { get; }
42+
43+
/// <summary>
44+
/// Gets the index of the contact within the <see cref="Probe"/> object.
45+
/// </summary>
46+
public int Index { get; }
47+
48+
/// <summary>
49+
/// Initializes a new instance of the <see cref="Contact"/> struct.
50+
/// </summary>
51+
/// <param name="posX">Center value of the contact on the X-axis.</param>
52+
/// <param name="posY">Center value of the contact on the Y-axis.</param>
53+
/// <param name="shape">The <see cref="ContactShape"/> of the contact.</param>
54+
/// <param name="shapeParam"><see cref="ContactShapeParam"/>'s relevant to the <see cref="ContactShape"/> of the contact.</param>
55+
/// <param name="deviceId">The device channel index (<see cref="Probe.DeviceChannelIndices"/>) of this contact.</param>
56+
/// <param name="contactId">The contact ID (<see cref="Probe.ContactIds"/>) of this contact.</param>
57+
/// <param name="shankId">The shank ID (<see cref="Probe.ShankIds"/>) of this contact.</param>
58+
/// <param name="index">The index of the contact within the context of the <see cref="Probe"/>.</param>
59+
public Contact(float posX, float posY, ContactShape shape, ContactShapeParam shapeParam,
60+
int deviceId, string contactId, string shankId, int index)
61+
{
62+
PosX = posX;
63+
PosY = posY;
64+
Shape = shape;
65+
ShapeParams = shapeParam;
66+
DeviceId = deviceId;
67+
ContactId = contactId;
68+
ShankId = shankId;
69+
Index = index;
70+
}
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using Newtonsoft.Json;
2+
3+
namespace OpenEphys.ProbeInterface.NET
4+
{
5+
/// <summary>
6+
/// Class holding all of the annotations for each contact.
7+
/// </summary>
8+
public class ContactAnnotations
9+
{
10+
/// <summary>
11+
/// Gets the array of strings holding annotations for each contact. Not all indices must have annotations.
12+
/// </summary>
13+
public string[] Annotations { get; protected set; }
14+
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="ContactAnnotations"/> class.
17+
/// </summary>
18+
/// <param name="contactAnnotations">Array of strings containing annotations for each contact. Size of the array should match the number of contacts, but they can be empty strings.</param>
19+
[JsonConstructor]
20+
public ContactAnnotations(string[] contactAnnotations)
21+
{
22+
Annotations = contactAnnotations;
23+
}
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Runtime.Serialization;
2+
using Newtonsoft.Json;
3+
using Newtonsoft.Json.Converters;
4+
5+
namespace OpenEphys.ProbeInterface.NET
6+
{
7+
/// <summary>
8+
/// Shape of the contact.
9+
/// </summary>
10+
[JsonConverter(typeof(StringEnumConverter))]
11+
public enum ContactShape
12+
{
13+
/// <summary>
14+
/// Circle.
15+
/// </summary>
16+
[EnumMember(Value = "circle")]
17+
Circle = 0,
18+
19+
/// <summary>
20+
/// Rectangle.
21+
/// </summary>
22+
[EnumMember(Value = "rect")]
23+
Rect = 1,
24+
25+
/// <summary>
26+
/// Square.
27+
/// </summary>
28+
[EnumMember(Value = "square")]
29+
Square = 2,
30+
}
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using Newtonsoft.Json;
2+
3+
namespace OpenEphys.ProbeInterface.NET
4+
{
5+
/// <summary>
6+
/// Class holding parameters used to draw the contact.
7+
/// </summary>
8+
/// <remarks>
9+
/// Fields are nullable, since not all fields are required depending on the shape selected.
10+
/// </remarks>
11+
public class ContactShapeParam
12+
{
13+
/// <summary>
14+
/// Gets the radius of the contact.
15+
/// </summary>
16+
/// <remarks>
17+
/// This is only used to draw <see cref="ContactShape.Circle"/> contacts. Field can be null.
18+
/// </remarks>
19+
public float? Radius { get; protected set; }
20+
21+
/// <summary>
22+
/// Gets the width of the contact.
23+
/// </summary>
24+
/// <remarks>
25+
/// This is used to draw <see cref="ContactShape.Square"/> or <see cref="ContactShape.Rect"/> contacts.
26+
/// Field can be null.
27+
/// </remarks>
28+
public float? Width { get; protected set; }
29+
30+
/// <summary>
31+
/// Gets the height of the contact.
32+
/// </summary>
33+
/// <remarks>
34+
/// This is only used to draw <see cref="ContactShape.Rect"/> contacts. Field can be null.
35+
/// </remarks>
36+
public float? Height { get; protected set; }
37+
38+
/// <summary>
39+
/// Initializes a new instance of the <see cref="ContactShapeParam"/> class.
40+
/// </summary>
41+
/// <param name="radius">Radius. Can be null.</param>
42+
/// <param name="width">Width. Can be null.</param>
43+
/// <param name="height">Height. Can be null.</param>
44+
[JsonConstructor]
45+
public ContactShapeParam(float? radius = null, float? width = null, float? height = null)
46+
{
47+
Radius = radius;
48+
Width = width;
49+
Height = height;
50+
}
51+
52+
/// <summary>
53+
/// Copy constructor given an existing <see cref="ContactShapeParam"/> object.
54+
/// </summary>
55+
/// <param name="shape">Existing <see cref="ContactShapeParam"/> object to be copied.</param>
56+
protected ContactShapeParam(ContactShapeParam shape)
57+
{
58+
Radius = shape.Radius;
59+
Width = shape.Width;
60+
Height = shape.Height;
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)