Skip to content

Commit 460e57d

Browse files
authored
fix: 639 ephys link should default to localhost if no ip provided (#642)
* Provide default ephys link connection settings * Properly unregister pathfinder probe, is not destroying * Destroy pathfinder probes
1 parent 84c318e commit 460e57d

File tree

6 files changed

+46
-17
lines changed

6 files changed

+46
-17
lines changed

Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ MonoBehaviour:
164164
m_CaretColor: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
165165
m_CustomCaretColor: 0
166166
m_SelectionColor: {r: 0.65882355, g: 0.80784315, b: 1, a: 0.7529412}
167-
m_Text:
167+
m_Text: localhost
168168
m_CaretBlinkRate: 0.85
169169
m_CaretWidth: 1
170170
m_ReadOnly: 0
@@ -261,7 +261,7 @@ MonoBehaviour:
261261
m_OnCullStateChanged:
262262
m_PersistentCalls:
263263
m_Calls: []
264-
m_text: "\u200B"
264+
m_text: "localhost\u200B"
265265
m_isRightToLeft: 0
266266
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
267267
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
@@ -906,7 +906,7 @@ MonoBehaviour:
906906
m_PrefabInstance: {fileID: 0}
907907
m_PrefabAsset: {fileID: 0}
908908
m_GameObject: {fileID: 2820967185475947156}
909-
m_Enabled: 1
909+
m_Enabled: 0
910910
m_EditorHideFlags: 0
911911
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
912912
m_Name:
@@ -3227,7 +3227,7 @@ PrefabInstance:
32273227
objectReference: {fileID: 0}
32283228
- target: {fileID: 887568134984656929, guid: b5c9c741a0d4edd4c9948dba78e58d2b, type: 3}
32293229
propertyPath: m_Enabled
3230-
value: 1
3230+
value: 0
32313231
objectReference: {fileID: 0}
32323232
- target: {fileID: 887568134984656929, guid: b5c9c741a0d4edd4c9948dba78e58d2b, type: 3}
32333233
propertyPath: m_FontData.m_FontStyle
@@ -3241,6 +3241,10 @@ PrefabInstance:
32413241
propertyPath: m_RootOrder
32423242
value: 1
32433243
objectReference: {fileID: 0}
3244+
- target: {fileID: 5109513604156068580, guid: b5c9c741a0d4edd4c9948dba78e58d2b, type: 3}
3245+
propertyPath: m_Text
3246+
value: 8081
3247+
objectReference: {fileID: 0}
32443248
- target: {fileID: 5109513604156068580, guid: b5c9c741a0d4edd4c9948dba78e58d2b, type: 3}
32453249
propertyPath: m_ContentType
32463250
value: 3
@@ -3253,6 +3257,10 @@ PrefabInstance:
32533257
propertyPath: m_CharacterValidation
32543258
value: 2
32553259
objectReference: {fileID: 0}
3260+
- target: {fileID: 6430610103568116672, guid: b5c9c741a0d4edd4c9948dba78e58d2b, type: 3}
3261+
propertyPath: m_Text
3262+
value: 8081
3263+
objectReference: {fileID: 0}
32563264
- target: {fileID: 7233051494870565536, guid: b5c9c741a0d4edd4c9948dba78e58d2b, type: 3}
32573265
propertyPath: m_Pivot.x
32583266
value: 0.5

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,15 +3154,15 @@ PrefabInstance:
31543154
objectReference: {fileID: 1703646459}
31553155
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31563156
propertyPath: m_AnchorMax.y
3157-
value: 0
3157+
value: 1
31583158
objectReference: {fileID: 0}
31593159
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31603160
propertyPath: m_AnchorMin.y
3161-
value: 0
3161+
value: 1
31623162
objectReference: {fileID: 0}
31633163
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31643164
propertyPath: m_AnchoredPosition.x
3165-
value: 0
3165+
value: 169.88
31663166
objectReference: {fileID: 0}
31673167
- target: {fileID: 341190943836276264, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31683168
propertyPath: m_IsOn
@@ -3298,19 +3298,19 @@ PrefabInstance:
32983298
objectReference: {fileID: 0}
32993299
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
33003300
propertyPath: m_AnchorMax.y
3301-
value: 0
3301+
value: 1
33023302
objectReference: {fileID: 0}
33033303
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
33043304
propertyPath: m_AnchorMin.y
3305-
value: 0
3305+
value: 1
33063306
objectReference: {fileID: 0}
33073307
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
33083308
propertyPath: m_AnchoredPosition.x
3309-
value: 0
3309+
value: 354.84
33103310
objectReference: {fileID: 0}
33113311
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
33123312
propertyPath: m_AnchoredPosition.y
3313-
value: 0
3313+
value: -15
33143314
objectReference: {fileID: 0}
33153315
- target: {fileID: 341190944071593138, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
33163316
propertyPath: m_AnchorMax.x
@@ -3590,19 +3590,19 @@ PrefabInstance:
35903590
objectReference: {fileID: 0}
35913591
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35923592
propertyPath: m_AnchorMax.y
3593-
value: 0
3593+
value: 1
35943594
objectReference: {fileID: 0}
35953595
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35963596
propertyPath: m_AnchorMin.y
3597-
value: 0
3597+
value: 1
35983598
objectReference: {fileID: 0}
35993599
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
36003600
propertyPath: m_AnchoredPosition.x
3601-
value: 0
3601+
value: 384.91998
36023602
objectReference: {fileID: 0}
36033603
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
36043604
propertyPath: m_AnchoredPosition.y
3605-
value: 0
3605+
value: -15
36063606
objectReference: {fileID: 0}
36073607
- target: {fileID: 341190944411999430, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
36083608
propertyPath: m_AnchorMax.y

Assets/Scripts/Pinpoint/Probes/ManipulatorBehaviorController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ void StartEchoing()
192192
});
193193
}
194194

195+
public void Deinitialize()
196+
{
197+
// Destroy Pathfinder probe.
198+
if (NumAxes == -1) DestroyThisProbe.Invoke();
199+
}
200+
195201
private void UpdateSpaceAndTransform()
196202
{
197203
CoordinateSpace = NumAxes switch

Assets/Scripts/Pinpoint/Probes/ProbeManager.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,11 +953,14 @@ public void SetIsEphysLinkControlled(bool register, string manipulatorId = null,
953953
onSuccess?.Invoke();
954954
}, err => onError?.Invoke(err));
955955
else
956+
{
956957
CommunicationManager.Instance.UnregisterManipulator(manipulatorId, () =>
957958
{
959+
ManipulatorBehaviorController.Deinitialize();
958960
IsEphysLinkControlled = false;
959961
onSuccess?.Invoke();
960962
}, err => onError?.Invoke(err));
963+
}
961964
}
962965

963966
#endregion

Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ public void OnConnectDisconnectPressed()
158158
try
159159
{
160160
_connectButtonText.text = "Connecting...";
161+
162+
// Provide default values for IP and port if empty.
163+
if (string.IsNullOrEmpty(_ipAddressInputField.text))
164+
_ipAddressInputField.text = "localhost";
165+
if (string.IsNullOrEmpty(_portInputField.text))
166+
_portInputField.text = "8081";
167+
161168
CommunicationManager.Instance.ConnectToServer(_ipAddressInputField.text,
162169
int.Parse(_portInputField.text),
163170
() =>
@@ -197,7 +204,13 @@ public void OnConnectDisconnectPressed()
197204
{
198205
foreach (var probeManager in ProbeManager.Instances
199206
.Where(probeManager => probeManager.IsEphysLinkControlled))
200-
probeManager.SetIsEphysLinkControlled(false);
207+
{
208+
probeManager.SetIsEphysLinkControlled(false,
209+
probeManager.ManipulatorBehaviorController.ManipulatorID);
210+
211+
// FIXME: This is done because of race condition with closing out server. Should be fixed with non-registration setup.
212+
probeManager.ManipulatorBehaviorController.Deinitialize();
213+
}
201214

202215
CommunicationManager.Instance.DisconnectFromServer(UpdateConnectionPanel);
203216
};

Assets/Scripts/Pinpoint/UI/EphysLinkSettings/ManipulatorConnectionPanel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ void CreatePathfinderProbe(ProbeProperties.ProbeType newProbeType)
8989
var newProbe = trajectoryPlannerManager.AddNewProbe(newProbeType);
9090

9191
// Configure probe and link to Ephys Link
92-
newProbe.ManipulatorBehaviorController.NumAxes = numAxes;
9392
newProbe.ManipulatorBehaviorController.CreatePathfinderProbe = CreatePathfinderProbe;
9493
newProbe.ManipulatorBehaviorController.DestroyThisProbe = () =>
9594
trajectoryPlannerManager.DestroyProbe(newProbe);

0 commit comments

Comments
 (0)