196 lines
4.7 KiB
C#
196 lines
4.7 KiB
C#
using Newtonsoft.Json;
|
||
using System.Collections.Generic;
|
||
using System.Threading.Tasks;
|
||
using UnityEngine;
|
||
using UnityEngine.EventSystems;
|
||
|
||
/// <summary>
|
||
/// 端口-查询
|
||
/// </summary>
|
||
[AddComponentMenu("端口查询")]
|
||
public class PortQuery : MonoBehaviour
|
||
{
|
||
public GameObject hight;
|
||
public PortList portList = new PortList();
|
||
|
||
private void Awake()
|
||
{
|
||
hight = Instantiate(Resources.Load<GameObject>("端口高亮"), transform);
|
||
hight.SetActive(false);
|
||
}
|
||
|
||
private void OnEnable()
|
||
{
|
||
if (!string.IsNullOrEmpty(portList.id))
|
||
{
|
||
gameObject.name = portList.id;
|
||
}
|
||
}
|
||
|
||
private void Start()
|
||
{
|
||
portList.deviceId = transform.parent.GetComponent<DeviceQuery>().deviceList.id;
|
||
//await initAsync("");
|
||
|
||
}
|
||
|
||
//public async Task initAsync()
|
||
//{
|
||
// var jsonResult = await CombineJSON.GetJson_POST(GameManager.Inst.Jk_URL.dk_cx, GameManager.Inst.token);
|
||
|
||
// Root root = JsonConvert.DeserializeObject<Root>(jsonResult);
|
||
|
||
// foreach (var item in root.data)
|
||
// {
|
||
// if (item.id == portList.id)
|
||
// {
|
||
// portList = item;
|
||
// break;
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
|
||
/// <summary>
|
||
/// 更新端口JSON
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
string refreshJson()
|
||
{
|
||
|
||
string json = JsonConvert.SerializeObject(portList);
|
||
//Debug.Log(json);
|
||
return json;
|
||
}
|
||
|
||
|
||
public void OnMouseEnter()
|
||
{
|
||
hight.SetActive(true);
|
||
}
|
||
|
||
public void OnMouseExit()
|
||
{
|
||
if (GameManager.Inst.nowDevice == gameObject)
|
||
return;
|
||
hight.SetActive(false);
|
||
}
|
||
|
||
public void OnMouseUp()
|
||
{
|
||
if (GameManager.Inst.nowDevice == gameObject)
|
||
hight.SetActive(true);
|
||
}
|
||
|
||
#region JSON
|
||
[System.Serializable]
|
||
public class PortList
|
||
{
|
||
/// <summary>
|
||
/// id
|
||
/// </summary>
|
||
[Tooltip("")] public string id;
|
||
/// <summary>
|
||
/// 端口
|
||
/// </summary>
|
||
[Tooltip("端口")] public string port;
|
||
/// <summary>
|
||
/// 编号
|
||
/// </summary>
|
||
[Tooltip("编号")] public string portCode;
|
||
/// <summary>
|
||
/// 名称
|
||
/// </summary>
|
||
[Tooltip("名称")] public string portName;
|
||
/// <summary>
|
||
/// 端口类型
|
||
/// </summary>
|
||
[Tooltip("端口类型")] public string portType;
|
||
/// <summary>
|
||
/// 端口位置
|
||
/// </summary>
|
||
[Tooltip("端口位置")] public string portPosition;
|
||
/// <summary>
|
||
/// 所属设备
|
||
/// </summary>
|
||
[Tooltip("所属设备")] public string deviceId;
|
||
/// <summary>
|
||
/// 所属设备名称
|
||
/// </summary>
|
||
[Tooltip("所属设备名称")] public string deviceName;
|
||
/// <summary>
|
||
/// 端口型号
|
||
/// </summary>
|
||
[Tooltip("端口型号")] public string portModel;
|
||
/// <summary>
|
||
/// 是否启用:1-正常;0-禁用
|
||
/// </summary>
|
||
[Tooltip("是否启用:1-正常;0-禁用")] public string status;
|
||
/// <summary>
|
||
/// 对联设备
|
||
/// </summary>
|
||
[Tooltip("对联设备")] public string conDevice;
|
||
/// <summary>
|
||
/// 对联设备名称
|
||
/// </summary>
|
||
[Tooltip("对联设备名称")] public string conDeviceName;
|
||
/// <summary>
|
||
/// 对联端口
|
||
/// </summary>
|
||
[Tooltip("对联端口")] public string conPort;
|
||
/// <summary>
|
||
/// 线缆名
|
||
/// </summary>
|
||
[Tooltip("线缆名")] public string cableName;
|
||
/// <summary>
|
||
/// 线缆组名
|
||
/// </summary>
|
||
[Tooltip("线缆组名")] public string cableGroupName;
|
||
/// <summary>
|
||
/// 备注
|
||
/// </summary>
|
||
[Tooltip("备注")] public string remark;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
[Tooltip("")] public string createTime;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
[Tooltip("")] public string createName;
|
||
}
|
||
|
||
|
||
[System.Serializable]
|
||
public class Root
|
||
{
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string code;
|
||
/// <summary>
|
||
/// 操作成功
|
||
/// </summary>
|
||
public string message;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public string totalRows;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int pageSize;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public int pageNum;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public List<PortList> data;
|
||
}
|
||
#endregion
|
||
|
||
|
||
}
|