Skip to content
Merged
Changes from all 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
41 changes: 23 additions & 18 deletions Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ void ConnectToServer()
{
_connectionErrorText.text = err;
_connectButtonText.text = "Connect";

_manipulatorTypeDropdown.interactable = !CommunicationManager.Instance.IsConnected;
_launchEphysLinkButton.interactable = !CommunicationManager.Instance.IsConnected;
}
else
{
Expand Down Expand Up @@ -260,24 +263,7 @@ public void OnConnectDisconnectPressed()
else
{
// Disconnect from server
QuestionDialogue.Instance.YesCallback = () =>
{
foreach (var probeManager in ProbeManager.Instances
.Where(probeManager => probeManager.IsEphysLinkControlled))
{
probeManager.SetIsEphysLinkControlled(false,
probeManager.ManipulatorBehaviorController.ManipulatorID);

// FIXME: This is done because of race condition with closing out server. Should be fixed with non-registration setup.
probeManager.ManipulatorBehaviorController.Deinitialize();
}

CommunicationManager.Instance.DisconnectFromServer(() =>
{
KillEphysLinkProcess();
UpdateConnectionPanel();
});
};
QuestionDialogue.Instance.YesCallback = HandleDisconnectingFromServer;

QuestionDialogue.Instance.NewQuestion(
"Are you sure you want to disconnect?\nAll incomplete movements will be canceled.");
Expand Down Expand Up @@ -325,6 +311,25 @@ private void HandleSuccessfulConnection()
});
}

private void HandleDisconnectingFromServer()
{
foreach (var probeManager in ProbeManager.Instances
.Where(probeManager => probeManager.IsEphysLinkControlled))
{
probeManager.SetIsEphysLinkControlled(false,
probeManager.ManipulatorBehaviorController.ManipulatorID);

// FIXME: This is done because of race condition with closing out server. Should be fixed with non-registration setup.
probeManager.ManipulatorBehaviorController.Deinitialize();
}

CommunicationManager.Instance.DisconnectFromServer(() =>
{
KillEphysLinkProcess();
UpdateConnectionPanel();
});
}

/// <summary>
/// Populate UI elements with current connection settings.
/// </summary>
Expand Down