Skip to content

Commit

Permalink
AUTO-7943: Add Python API command for getting bridge type
Browse files Browse the repository at this point in the history
  • Loading branch information
hadiTab authored and lokesku committed Sep 24, 2021
1 parent 0e26f7f commit 861c55d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Assets/Scripts/Api/Commands/GetBridgeType.cs
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");
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Api/Commands/GetBridgeType.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 861c55d

Please sign in to comment.