-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AUTO-7943: Add Python API command for getting bridge type
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) 2021 LG Electronics, Inc. | ||
* | ||
* This software contains code licensed as described in LICENSE. | ||
* | ||
*/ | ||
|
||
using SimpleJSON; | ||
using UnityEngine; | ||
using Simulator.Bridge; | ||
using Simulator.Components; | ||
|
||
namespace Simulator.Api.Commands | ||
{ | ||
class GetBridgeType : ICommand | ||
{ | ||
public string Name => "vehicle/bridge/type"; | ||
|
||
public void Execute(JSONNode args) | ||
{ | ||
var uid = args["uid"].Value; | ||
var api = ApiManager.Instance; | ||
|
||
if (api.Agents.TryGetValue(uid, out GameObject obj)) | ||
{ | ||
var bridge = obj.GetComponentInChildren<BridgeClient>(); | ||
if (bridge == null) | ||
{ | ||
api.SendError(this, $"Agent '{uid}' is missing bridge client"); | ||
} | ||
else | ||
{ | ||
var result = bridge.Bridge.Plugin.GetBridgeNameAttribute().Type; | ||
api.SendResult(this, result); | ||
} | ||
} | ||
else | ||
{ | ||
api.SendError(this, $"Agent '{uid}' not found"); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.