Skip to content

Commit 55df2aa

Browse files
authored
Merge pull request #241 from Kapim/devel
Changed:
2 parents 274d8b0 + f87c9f4 commit 55df2aa

File tree

7 files changed

+1393
-290
lines changed

7 files changed

+1393
-290
lines changed

arcor2_AREditor/Assets/BASE/Scripts/GameManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public class GameManager : Singleton<GameManager> {
201201
/// <summary>
202202
/// Api version
203203
/// </summary>
204-
public const string ApiVersion = "0.19.0";
204+
public const string ApiVersion = "0.20.0";
205205
/// <summary>
206206
/// List of projects metadata
207207
/// </summary>
10.5 KB
Binary file not shown.

arcor2_AREditor/Assets/BASE/Scripts/Swagger/IO.Swagger.xml

Lines changed: 1356 additions & 263 deletions
Large diffs are not rendered by default.

arcor2_AREditor/Assets/BASE/Scripts/WebsocketManager.cs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class WebsocketManager : Singleton<WebsocketManager> {
2222
/// Websocket context
2323
/// </summary>
2424
private WebSocket websocket;
25+
26+
int counter = 0;
2527
/// <summary>
2628
/// Dictionary of unprocessed responses
2729
/// </summary>
@@ -579,30 +581,37 @@ private void HandleStateBefore(string obj) {
579581
try {
580582

581583
IO.Swagger.Model.ActionStateBefore actionStateBefore = JsonConvert.DeserializeObject<IO.Swagger.Model.ActionStateBefore>(obj);
584+
if (!string.IsNullOrEmpty(actionStateBefore.Data.ActionId)) {
585+
puck_id = actionStateBefore.Data.ActionId;
582586

583-
puck_id = actionStateBefore.Data.ActionId;
584-
585-
if (!ProjectManager.Instance.Valid) {
586-
Debug.LogWarning("Project not yet loaded, ignoring current action");
587-
GameManager.Instance.ActionRunningOnStartupId = puck_id;
588-
return;
587+
if (!ProjectManager.Instance.Valid) {
588+
Debug.LogWarning("Project not yet loaded, ignoring current action");
589+
GameManager.Instance.ActionRunningOnStartupId = puck_id;
590+
return;
591+
}
592+
// Stop previously running action (change its color to default)
593+
if (ActionsManager.Instance.CurrentlyRunningAction != null)
594+
ActionsManager.Instance.CurrentlyRunningAction.StopAction();
595+
596+
Action puck = ProjectManager.Instance.GetAction(puck_id);
597+
ActionsManager.Instance.CurrentlyRunningAction = puck;
598+
// Run current action (set its color to running)
599+
puck.RunAction();
600+
} else {
601+
if (ActionsManager.Instance.CurrentlyRunningAction != null)
602+
ActionsManager.Instance.CurrentlyRunningAction.StopAction();
603+
ActionsManager.Instance.CurrentlyRunningAction = null;
589604
}
605+
606+
590607

591608
} catch (NullReferenceException e) {
592609
Debug.Log("Parse error in HandleCurrentAction()");
593610
return;
611+
} catch (ItemNotFoundException e) {
612+
Debug.LogError(e);
594613
}
595-
// Stop previously running action (change its color to default)
596-
if (ActionsManager.Instance.CurrentlyRunningAction != null)
597-
ActionsManager.Instance.CurrentlyRunningAction.StopAction();
598-
try {
599-
Action puck = ProjectManager.Instance.GetAction(puck_id);
600-
ActionsManager.Instance.CurrentlyRunningAction = puck;
601-
// Run current action (set its color to running)
602-
puck.RunAction();
603-
} catch (ItemNotFoundException ex) {
604-
Debug.LogError(ex);
605-
}
614+
606615
}
607616

608617
private void HandleActionStateAfter(string obj) {
@@ -613,11 +622,10 @@ private void HandleActionStateAfter(string obj) {
613622
try {
614623

615624
IO.Swagger.Model.ActionStateAfter actionStateBefore = JsonConvert.DeserializeObject<IO.Swagger.Model.ActionStateAfter>(obj);
616-
617-
puck_id = actionStateBefore.Data.ActionId;
618-
619-
620-
625+
if (ActionsManager.Instance.CurrentlyRunningAction != null)
626+
ActionsManager.Instance.CurrentlyRunningAction.StopAction();
627+
ActionsManager.Instance.CurrentlyRunningAction = null;
628+
621629
} catch (NullReferenceException e) {
622630
Debug.Log("Parse error in HandleCurrentAction()");
623631
return;

0 commit comments

Comments
 (0)