Skip to content

Commit 3848518

Browse files
kjy5dbirman
andauthored
233 support string manipulator ids (#236)
* Update README.md * Update README.md * Update README.md * Changed all ints to strings * Convert 0 id to null * Echo with New Scale Co-authored-by: Dan Birman <danbirman@gmail.com>
1 parent bb04b1b commit 3848518

16 files changed

Lines changed: 204 additions & 70 deletions
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{
2+
"TestSuite": "",
3+
"Date": 1667951870819,
4+
"Player": {
5+
"Development": false,
6+
"ScreenWidth": 0,
7+
"ScreenHeight": 0,
8+
"ScreenRefreshRate": 0,
9+
"Fullscreen": false,
10+
"Vsync": 0,
11+
"AntiAliasing": 0,
12+
"Batchmode": false,
13+
"RenderThreadingMode": "GraphicsJobs",
14+
"GpuSkinning": true,
15+
"Platform": "",
16+
"ColorSpace": "",
17+
"AnisotropicFiltering": "",
18+
"BlendWeights": "",
19+
"GraphicsApi": "",
20+
"ScriptingBackend": "IL2CPP",
21+
"AndroidTargetSdkVersion": "AndroidApiLevelAuto",
22+
"AndroidBuildSystem": "Gradle",
23+
"BuildTarget": "StandaloneWindows64",
24+
"StereoRenderingPath": "MultiPass"
25+
},
26+
"Hardware": {
27+
"OperatingSystem": "",
28+
"DeviceModel": "",
29+
"DeviceName": "",
30+
"ProcessorType": "",
31+
"ProcessorCount": 0,
32+
"GraphicsDeviceName": "",
33+
"SystemMemorySizeMB": 0
34+
},
35+
"Editor": {
36+
"Version": "2021.3.10f1",
37+
"Branch": "2021.3/staging",
38+
"Changeset": "1c7d0df0160b",
39+
"Date": 1662046794
40+
},
41+
"Dependencies": [
42+
"com.unity.addressables@1.19.19",
43+
"com.unity.animation.rigging@1.1.1",
44+
"com.unity.ide.rider@3.0.16",
45+
"com.unity.ide.visualstudio@2.0.16",
46+
"com.unity.ide.vscode@1.2.5",
47+
"com.unity.render-pipelines.universal@12.1.7",
48+
"com.unity.rendering.hybrid@0.51.1-preview.21",
49+
"com.unity.test-framework@1.1.33",
50+
"com.unity.textmeshpro@3.0.6",
51+
"com.unity.timeline@1.6.4",
52+
"com.unity.toolchain.win-x86_64-linux-x86_64@1.0.0",
53+
"com.unity.ugui@1.0.0",
54+
"com.unity.modules.ai@1.0.0",
55+
"com.unity.modules.androidjni@1.0.0",
56+
"com.unity.modules.animation@1.0.0",
57+
"com.unity.modules.assetbundle@1.0.0",
58+
"com.unity.modules.audio@1.0.0",
59+
"com.unity.modules.cloth@1.0.0",
60+
"com.unity.modules.director@1.0.0",
61+
"com.unity.modules.imageconversion@1.0.0",
62+
"com.unity.modules.imgui@1.0.0",
63+
"com.unity.modules.jsonserialize@1.0.0",
64+
"com.unity.modules.particlesystem@1.0.0",
65+
"com.unity.modules.physics@1.0.0",
66+
"com.unity.modules.physics2d@1.0.0",
67+
"com.unity.modules.screencapture@1.0.0",
68+
"com.unity.modules.terrain@1.0.0",
69+
"com.unity.modules.terrainphysics@1.0.0",
70+
"com.unity.modules.tilemap@1.0.0",
71+
"com.unity.modules.ui@1.0.0",
72+
"com.unity.modules.uielements@1.0.0",
73+
"com.unity.modules.umbra@1.0.0",
74+
"com.unity.modules.unityanalytics@1.0.0",
75+
"com.unity.modules.unitywebrequest@1.0.0",
76+
"com.unity.modules.unitywebrequestassetbundle@1.0.0",
77+
"com.unity.modules.unitywebrequestaudio@1.0.0",
78+
"com.unity.modules.unitywebrequesttexture@1.0.0",
79+
"com.unity.modules.unitywebrequestwww@1.0.0",
80+
"com.unity.modules.vehicles@1.0.0",
81+
"com.unity.modules.video@1.0.0",
82+
"com.unity.modules.vr@1.0.0",
83+
"com.unity.modules.wind@1.0.0",
84+
"com.unity.modules.xr@1.0.0",
85+
"com.unity.modules.subsystems@1.0.0",
86+
"com.unity.modules.uielementsnative@1.0.0",
87+
"com.unity.sysroot@1.0.0",
88+
"com.unity.sysroot.linux-x86_64@1.0.0",
89+
"com.unity.ext.nunit@1.0.6",
90+
"com.unity.entities@0.51.1-preview.21",
91+
"com.unity.mathematics@1.2.6",
92+
"com.unity.burst@1.7.3",
93+
"com.unity.render-pipelines.core@12.1.7",
94+
"com.unity.shadergraph@12.1.7",
95+
"com.unity.scriptablebuildpipeline@1.20.1",
96+
"com.unity.properties@1.7.0-preview",
97+
"com.unity.properties.ui@1.7.0-preview",
98+
"com.unity.serialization@1.7.0-preview.1",
99+
"com.unity.collections@1.4.0",
100+
"com.unity.jobs@0.70.0-preview.7",
101+
"com.unity.test-framework.performance@2.8.0-preview",
102+
"com.unity.platforms@0.51.1-preview.21",
103+
"com.unity.roslyn@0.2.2-preview",
104+
"com.unity.profiling.core@1.0.2",
105+
"com.unity.searcher@4.9.1",
106+
"com.unity.nuget.mono-cecil@1.11.4"
107+
],
108+
"Results": []
109+
}

Assets/Resources/PerformanceTestRunInfo.json.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/EphysLink/CommunicationManager.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public bool IsConnected()
155155
/// </summary>
156156
/// <param name="onSuccessCallback">Callback function to handle incoming manipulator ID's</param>
157157
/// <param name="onErrorCallback">Callback function to handle errors</param>
158-
public void GetManipulators(Action<int[]> onSuccessCallback, Action<string> onErrorCallback = null)
158+
public void GetManipulators(Action<string[]> onSuccessCallback, Action<string> onErrorCallback = null)
159159
{
160160
_connectionManager.Socket.ExpectAcknowledgement<GetManipulatorsCallbackParameters>(data =>
161161
{
@@ -177,7 +177,7 @@ public void GetManipulators(Action<int[]> onSuccessCallback, Action<string> onEr
177177
/// <param name="manipulatorId">The ID of the manipulator to register</param>
178178
/// <param name="onSuccessCallback">Callback function to handle a successful registration</param>
179179
/// <param name="onErrorCallback">Callback function to handle errors</param>
180-
public void RegisterManipulator(int manipulatorId, Action onSuccessCallback = null,
180+
public void RegisterManipulator(string manipulatorId, Action onSuccessCallback = null,
181181
Action<string> onErrorCallback = null)
182182
{
183183
_connectionManager.Socket.ExpectAcknowledgement<string>(error =>
@@ -200,7 +200,7 @@ public void RegisterManipulator(int manipulatorId, Action onSuccessCallback = nu
200200
/// <param name="manipulatorId">The ID of the manipulator to unregister</param>
201201
/// <param name="onSuccessCallback">Callback function to handle a successful un-registration</param>
202202
/// <param name="onErrorCallback">Callback function to handle errors</param>
203-
public void UnregisterManipulator(int manipulatorId, Action onSuccessCallback = null,
203+
public void UnregisterManipulator(string manipulatorId, Action onSuccessCallback = null,
204204
Action<string> onErrorCallback = null)
205205
{
206206
_connectionManager.Socket.ExpectAcknowledgement<string>(error =>
@@ -223,7 +223,8 @@ public void UnregisterManipulator(int manipulatorId, Action onSuccessCallback =
223223
/// <param name="manipulatorId">ID of the manipulator to get the position of</param>
224224
/// <param name="onSuccessCallback">Callback function to pass manipulator position to</param>
225225
/// <param name="onErrorCallback">Callback function to handle errors</param>
226-
public void GetPos(int manipulatorId, Action<Vector4> onSuccessCallback, Action<string> onErrorCallback = null)
226+
public void GetPos(string manipulatorId, Action<Vector4> onSuccessCallback,
227+
Action<string> onErrorCallback = null)
227228
{
228229
_connectionManager.Socket.ExpectAcknowledgement<PositionalCallbackParameters>(data =>
229230
{
@@ -249,7 +250,7 @@ public void GetPos(int manipulatorId, Action<Vector4> onSuccessCallback, Action<
249250
/// <param name="speed">How fast to move the manipulator (in μm/s)</param>
250251
/// <param name="onSuccessCallback">Callback function to handle successful manipulator movement</param>
251252
/// <param name="onErrorCallback">Callback function to handle errors</param>
252-
public void GotoPos(int manipulatorId, Vector4 pos, int speed, Action<Vector4> onSuccessCallback,
253+
public void GotoPos(string manipulatorId, Vector4 pos, int speed, Action<Vector4> onSuccessCallback,
253254
Action<string> onErrorCallback = null)
254255
{
255256
_connectionManager.Socket.ExpectAcknowledgement<PositionalCallbackParameters>(data =>
@@ -277,7 +278,7 @@ public void GotoPos(int manipulatorId, Vector4 pos, int speed, Action<Vector4> o
277278
/// <param name="onSuccessCallback">Callback function to handle successful manipulator movement</param>
278279
/// <param name="onErrorCallback">Callback function to handle errors</param>
279280
/// <exception cref="ArgumentException">If the given position is not in an array of 4 floats</exception>
280-
public void GotoPos(int manipulatorId, float[] pos, int speed, Action<Vector4> onSuccessCallback,
281+
public void GotoPos(string manipulatorId, float[] pos, int speed, Action<Vector4> onSuccessCallback,
281282
Action<string> onErrorCallback = null)
282283
{
283284
if (pos.Length != 4) throw new ArgumentException("Position array must be of length 4");
@@ -294,7 +295,7 @@ public void GotoPos(int manipulatorId, float[] pos, int speed, Action<Vector4> o
294295
/// <param name="speed">How fast to drive the manipulator (in μm/s)</param>
295296
/// <param name="onSuccessCallback">Callback function to handle successful manipulator movement</param>
296297
/// <param name="onErrorCallback">Callback function to handle errors</param>
297-
public void DriveToDepth(int manipulatorId, float depth, int speed, Action<float> onSuccessCallback,
298+
public void DriveToDepth(string manipulatorId, float depth, int speed, Action<float> onSuccessCallback,
298299
Action<string> onErrorCallback)
299300
{
300301
_connectionManager.Socket.ExpectAcknowledgement<DriveToDepthCallbackParameters>(data =>
@@ -318,7 +319,7 @@ public void DriveToDepth(int manipulatorId, float depth, int speed, Action<float
318319
/// <param name="inside">State to set to</param>
319320
/// <param name="onSuccessCallback">Callback function to handle setting inside_brain state successfully</param>
320321
/// <param name="onErrorCallback">Callback function to handle errors</param>
321-
public void SetInsideBrain(int manipulatorId, bool inside, Action<bool> onSuccessCallback,
322+
public void SetInsideBrain(string manipulatorId, bool inside, Action<bool> onSuccessCallback,
322323
Action<string> onErrorCallback = null)
323324
{
324325
_connectionManager.Socket.ExpectAcknowledgement<StateCallbackParameters>(data =>
@@ -341,7 +342,7 @@ public void SetInsideBrain(int manipulatorId, bool inside, Action<bool> onSucces
341342
/// <param name="manipulatorId">ID of the manipulator to be calibrated</param>
342343
/// <param name="onSuccessCallback">Callback function to handle a successful calibration</param>
343344
/// <param name="onErrorCallback">Callback function to handle an unsuccessful calibration</param>
344-
public void Calibrate(int manipulatorId, Action onSuccessCallback, Action<string> onErrorCallback = null)
345+
public void Calibrate(string manipulatorId, Action onSuccessCallback, Action<string> onErrorCallback = null)
345346
{
346347
_connectionManager.Socket.ExpectAcknowledgement<string>(errorMessage =>
347348
{
@@ -364,7 +365,7 @@ public void Calibrate(int manipulatorId, Action onSuccessCallback, Action<string
364365
/// <param name="manipulatorId">ID of the manipulator to bypass calibration</param>
365366
/// <param name="onSuccessCallback">Callback function to handle a successful calibration bypass</param>
366367
/// <param name="onErrorCallback">Callback function to handle errors</param>
367-
public void BypassCalibration(int manipulatorId, Action onSuccessCallback,
368+
public void BypassCalibration(string manipulatorId, Action onSuccessCallback,
368369
Action<string> onErrorCallback = null)
369370
{
370371
_connectionManager.Socket.ExpectAcknowledgement<string>(error =>
@@ -389,7 +390,7 @@ public void BypassCalibration(int manipulatorId, Action onSuccessCallback,
389390
/// <param name="hours">How many hours a manipulator may have a write lease</param>
390391
/// <param name="onSuccessCallback">Callback function to handle successfully setting can_write state</param>
391392
/// <param name="onErrorCallback">Callback function to handle errors</param>
392-
public void SetCanWrite(int manipulatorId, bool canWrite, float hours, Action<bool> onSuccessCallback,
393+
public void SetCanWrite(string manipulatorId, bool canWrite, float hours, Action<bool> onSuccessCallback,
393394
Action<string> onErrorCallback = null)
394395
{
395396
_connectionManager.Socket.ExpectAcknowledgement<StateCallbackParameters>(data =>

Assets/Scripts/EphysLink/DataFormats.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace EphysLink
1515
/// </summary>
1616
public struct CanWriteInputDataFormat
1717
{
18-
public int manipulator_id;
18+
public string manipulator_id;
1919
public bool can_write;
2020
public float hours;
2121

@@ -25,7 +25,7 @@ public struct CanWriteInputDataFormat
2525
/// <param name="manipulatorID">ID of the manipulator to set the state on</param>
2626
/// <param name="canWrite">Write state to set</param>
2727
/// <param name="hours">Write lease duration</param>
28-
public CanWriteInputDataFormat(int manipulatorID, bool canWrite, float hours)
28+
public CanWriteInputDataFormat(string manipulatorID, bool canWrite, float hours)
2929
{
3030
manipulator_id = manipulatorID;
3131
can_write = canWrite;
@@ -38,7 +38,7 @@ public CanWriteInputDataFormat(int manipulatorID, bool canWrite, float hours)
3838
/// </summary>
3939
public struct GotoPositionInputDataFormat
4040
{
41-
public int manipulator_id;
41+
public string manipulator_id;
4242
public float[] pos;
4343
public int speed;
4444

@@ -48,7 +48,7 @@ public struct GotoPositionInputDataFormat
4848
/// <param name="manipulatorID">ID of the manipulator to move</param>
4949
/// <param name="pos">Position in μm of the manipulator (in needle coordinates)</param>
5050
/// <param name="speed">How fast to move the manipulator (in μm/s)</param>
51-
public GotoPositionInputDataFormat(int manipulatorID, Vector4 pos, int speed)
51+
public GotoPositionInputDataFormat(string manipulatorID, Vector4 pos, int speed)
5252
{
5353
manipulator_id = manipulatorID;
5454
this.pos = new[] { pos.x, pos.y, pos.z, pos.w };
@@ -61,7 +61,7 @@ public GotoPositionInputDataFormat(int manipulatorID, Vector4 pos, int speed)
6161
/// </summary>
6262
public struct DriveToDepthInputDataFormat
6363
{
64-
public int manipulator_id;
64+
public string manipulator_id;
6565
public float depth;
6666
public int speed;
6767

@@ -71,7 +71,7 @@ public struct DriveToDepthInputDataFormat
7171
/// <param name="manipulatorId">ID of the manipulator to move</param>
7272
/// <param name="depth">Depth in μm of the manipulator (in needle coordinates)</param>
7373
/// <param name="speed">How fast to drive the manipulator (in μm/s)</param>
74-
public DriveToDepthInputDataFormat(int manipulatorId, float depth, int speed)
74+
public DriveToDepthInputDataFormat(string manipulatorId, float depth, int speed)
7575
{
7676
manipulator_id = manipulatorId;
7777
this.depth = depth;
@@ -84,15 +84,15 @@ public DriveToDepthInputDataFormat(int manipulatorId, float depth, int speed)
8484
/// </summary>
8585
public struct InsideBrainInputDataFormat
8686
{
87-
public int manipulator_id;
87+
public string manipulator_id;
8888
public bool inside;
8989

9090
/// <summary>
9191
/// Construct a new inside_brain event argument.
9292
/// </summary>
9393
/// <param name="manipulatorId">ID of the manipulator to set the state of</param>
9494
/// <param name="inside">State to set to</param>
95-
public InsideBrainInputDataFormat(int manipulatorId, bool inside)
95+
public InsideBrainInputDataFormat(string manipulatorId, bool inside)
9696
{
9797
manipulator_id = manipulatorId;
9898
this.inside = inside;
@@ -108,7 +108,7 @@ public InsideBrainInputDataFormat(int manipulatorId, bool inside)
108108
/// </summary>
109109
public struct GetManipulatorsCallbackParameters
110110
{
111-
public int[] manipulators;
111+
public string[] manipulators;
112112
public string error;
113113
}
114114

Assets/Scripts/Settings/EphysLinkSettings.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class EphysLinkSettings : MonoBehaviour
4646

4747
// private readonly Dictionary<int, Tuple<ManipulatorConnectionSettingsPanel, GameObject>>
4848
// _manipulatorIdToManipulatorConnectionSettingsPanel = new();
49-
private readonly Dictionary<int, (ManipulatorConnectionSettingsPanel manipulatorConnectionSettingsPanel,
49+
private readonly Dictionary<string, (ManipulatorConnectionSettingsPanel manipulatorConnectionSettingsPanel,
5050
GameObject gameObject)>
5151
_manipulatorIdToManipulatorConnectionSettingsPanel = new();
5252

@@ -175,14 +175,14 @@ public void UpdateManipulatorPanelAndSelection()
175175
{
176176
var manipulatorDropdownOptions = new List<string> { "-" };
177177
manipulatorDropdownOptions.AddRange(availableIds.Where(id =>
178-
id == probeConnectionSettingsPanel.GetProbeManager().GetManipulatorId() ||
179-
!usedManipulatorIds.Contains(id)).Select(id => id.ToString()));
178+
id.Equals(probeConnectionSettingsPanel.GetProbeManager().GetManipulatorId()) ||
179+
!usedManipulatorIds.Contains(id)));
180180

181181
probeConnectionSettingsPanel.SetManipulatorIdDropdownOptions(manipulatorDropdownOptions);
182182
}
183183

184184
// Handle manipulator panels
185-
var handledManipulatorIds = new HashSet<int>();
185+
var handledManipulatorIds = new HashSet<string>();
186186

187187
// Add any new manipulators in scene to list
188188
foreach (var manipulatorId in availableIds)

Assets/Scripts/Settings/ManipulatorConnectionSettingsPanel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ private void Awake()
2424
/// Set the manipulator ID this panel is representing.
2525
/// </summary>
2626
/// <param name="manipulatorId">ID of the manipulator this panel is representing</param>
27-
public void SetManipulatorId(int manipulatorId)
27+
public void SetManipulatorId(string manipulatorId)
2828
{
2929
_manipulatorId = manipulatorId;
30-
manipulatorIdText.text = manipulatorId.ToString();
30+
manipulatorIdText.text = manipulatorId;
3131
handednessDropdown.value = _trajectoryPlannerManager.IsManipulatorRightHanded(manipulatorId) ? 1 : 0;
3232
}
3333

@@ -62,7 +62,7 @@ public void OnManipulatorHandednessValueChanged(int value)
6262

6363
#region Properties
6464

65-
private int _manipulatorId;
65+
private string _manipulatorId;
6666

6767
#endregion
6868

Assets/Scripts/Settings/ProbeConnectionSettingsPanel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void SetManipulatorIdDropdownOptions(List<string> idOptions)
132132

133133
// Select the option corresponding to the current manipulator id
134134
var indexOfId = _probeManager.IsConnectedToManipulator()
135-
? Math.Max(0, idOptions.IndexOf(_probeManager.GetManipulatorId().ToString()))
135+
? Math.Max(0, idOptions.IndexOf(_probeManager.GetManipulatorId()))
136136
: 0;
137137
manipulatorIdDropdown.SetValueWithoutNotify(indexOfId);
138138
}
@@ -144,7 +144,7 @@ public void SetManipulatorIdDropdownOptions(List<string> idOptions)
144144
public void OnManipulatorDropdownValueChanged(int index)
145145
{
146146
if (_probeManager.IsConnectedToManipulator())
147-
_probeManager.SetEphysLinkMovement(false, 0, false, () =>
147+
_probeManager.SetEphysLinkMovement(false, "", false, () =>
148148
{
149149
if (index != 0)
150150
AttachToManipulatorAndUpdateUI();
@@ -164,7 +164,7 @@ public void OnManipulatorDropdownValueChanged(int index)
164164
void AttachToManipulatorAndUpdateUI()
165165
{
166166
_probeManager.SetEphysLinkMovement(true,
167-
int.Parse(manipulatorIdDropdown.options[index].text),
167+
manipulatorIdDropdown.options[index].text,
168168
onSuccess: () => { _ephysLinkSettings.UpdateManipulatorPanelAndSelection(); });
169169
}
170170
}

0 commit comments

Comments
 (0)