You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.1 KiB
93 lines
3.1 KiB
using Newtonsoft.Json; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
using UnityEngine.UI; |
|
|
|
public class DeviceInfo : MonoBehaviour |
|
{ |
|
public static DeviceInfo Instance; |
|
public GameObject infoItem; |
|
public Transform infoParent; |
|
public Text infoName; |
|
public Button CloseBtn; |
|
|
|
public DeviceList bindInfo; |
|
private void Awake() |
|
{ |
|
Instance = this; |
|
gameObject.SetActive(false); |
|
} |
|
private void Start() |
|
{ |
|
CloseBtn.onClick.AddListener(() => { gameObject.SetActive(false); }); |
|
} |
|
public void OnShow(DeviceList info) |
|
{ |
|
infoName.text = "设备信息"; |
|
bindInfo = info; |
|
|
|
foreach (Transform item in infoParent) |
|
{ |
|
if (item.name != "None") |
|
{ |
|
Destroy(item.gameObject); |
|
} |
|
} |
|
if (info.deviceType == 256 || info.deviceType == 258) |
|
{ |
|
{ |
|
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString()); |
|
GameObject go = Instantiate(infoItem, infoParent); |
|
go.GetComponent<DeviceInfoItem>().Bind("名称:" + pinfo.deviceName); |
|
} |
|
{ |
|
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString()); |
|
GameObject go = Instantiate(infoItem, infoParent); |
|
go.GetComponent<DeviceInfoItem>().Bind("状态:" + pinfo.startStopStatus); |
|
} |
|
{ |
|
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString()); |
|
GameObject go = Instantiate(infoItem, infoParent); |
|
go.GetComponent<DeviceInfoItem>().Bind("状态:" + pinfo.faultStatus); |
|
} |
|
{ |
|
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString()); |
|
GameObject go = Instantiate(infoItem, infoParent); |
|
go.GetComponent<DeviceInfoItem>().Bind("电源状态:" + pinfo.powerState); |
|
} |
|
{ |
|
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString()); |
|
GameObject go = Instantiate(infoItem, infoParent); |
|
go.GetComponent<DeviceInfoItem>().Bind("描述:" + pinfo.descript); |
|
} |
|
{ |
|
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString()); |
|
GameObject go = Instantiate(infoItem, infoParent); |
|
go.GetComponent<DeviceInfoItem>().Bind("楼层:" + pinfo.floor); |
|
} |
|
} |
|
|
|
gameObject.SetActive(true); |
|
} |
|
} |
|
public class PLInfo |
|
{ |
|
public string deviceType; |
|
public string devInterface; |
|
public string startStopStatus; |
|
public string openProjectId; |
|
public string deviceTypeName; |
|
public string faultStatus; |
|
public string ulogtime; |
|
public int isOnline; |
|
public string deviceNo; |
|
public string deviceName; |
|
public string logTime; |
|
public string powerState; |
|
public string manualAutomaticState; |
|
public string devSystem; |
|
public string appKey; |
|
public string descript; |
|
public string floor; |
|
} |