Browse Source

设备显示信息变更

master
杨栋梁 10 months ago
parent
commit
37c6f32f67
  1. 6
      .vsconfig
  2. 106
      Assets/Scripts/ANet/DeviceInfo.cs
  3. 5
      Assets/Scripts/ANet/DeviceObj.cs
  4. 1
      Assets/StreamingAssets/DeviceObj.json
  5. 7
      Assets/StreamingAssets/DeviceObj.json.meta

6
.vsconfig

@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}

106
Assets/Scripts/ANet/DeviceInfo.cs

@ -34,60 +34,112 @@ public class DeviceInfo : MonoBehaviour
Destroy(item.gameObject); Destroy(item.gameObject);
} }
} }
if (info.deviceType == 256 || info.deviceType == 258) Debug.Log("数据:" + info.timelyData);
/*
code (136-, 258-,
401-, 302-, 305-,
256-, 301-, 304-,
451-, 452-, 453-)
*/
InfoBase infobase = JsonConvert.DeserializeObject<InfoBase>(info.timelyData.ToString());
{ {
GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("名称 : " + infobase.deviceName);
}
{ {
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString());
GameObject go = Instantiate(infoItem, infoParent); GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("名称:" + pinfo.deviceName); go.GetComponent<DeviceInfoItem>().Bind("类型 : " + infobase.deviceTypeName);
} }
if (info.deviceType == 256 || info.deviceType == 258)
{ {
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString()); PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString());
{
GameObject go = Instantiate(infoItem, infoParent); GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("状态:" + pinfo.startStopStatus); go.GetComponent<DeviceInfoItem>().Bind("手自动状态 : " + (pinfo.manualAutomaticState == "0" ? "自动" : "手动"));
} }
{ {
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString());
GameObject go = Instantiate(infoItem, infoParent); GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("状态:" + pinfo.faultStatus); go.GetComponent<DeviceInfoItem>().Bind("电源状态 : " + (pinfo.powerState == "0" ? "已上电" : "未上电"));
} }
{ {
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString());
GameObject go = Instantiate(infoItem, infoParent); GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("电源状态:" + pinfo.powerState); go.GetComponent<DeviceInfoItem>().Bind("故障信息 : " + (pinfo.faultStatus == "0" ? "正常" : "故障"));
} }
{ {
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString());
GameObject go = Instantiate(infoItem, infoParent); GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("描述:" + pinfo.descript); go.GetComponent<DeviceInfoItem>().Bind("启停状态 : " + (pinfo.startStopStatus == "0" ? "停止" : "启动"));
} }
}
else if (info.deviceType == 401)
{
SXInfo pinfo = JsonConvert.DeserializeObject<SXInfo>(info.timelyData.ToString());
{ {
PLInfo pinfo = JsonConvert.DeserializeObject<PLInfo>(info.timelyData.ToString());
GameObject go = Instantiate(infoItem, infoParent); GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("楼层:" + pinfo.floor); go.GetComponent<DeviceInfoItem>().Bind("水位 : " + pinfo.level);
} }
{
GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("预警状态 : " + (pinfo.alarmStatus == "0" ? "正常" : "告警"));
}
}
else if (info.deviceType == 305)
{
XHSInfo pinfo = JsonConvert.DeserializeObject<XHSInfo>(info.timelyData.ToString());
{
GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("压力 : " + pinfo.pressure);
}
{
GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("预警状态 : " + (pinfo.alarmStatus == "0" ? "正常" : "告警"));
}
}
{
GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("楼层 : " + infobase.floor);
}
{
GameObject go = Instantiate(infoItem, infoParent);
go.GetComponent<DeviceInfoItem>().Bind("描述 : " + infobase.descript);
} }
gameObject.SetActive(true); gameObject.SetActive(true);
} }
} }
public class PLInfo public class InfoBase
{
public string deviceType;//类型例如"256"
public string devInterface;//"spraypump"
public string openProjectId;//"1150"
public string deviceTypeName;//"喷淋泵"
public string ulogtime;// "1712793073050"
public int isOnline;//1 在线状态
public string deviceNo;//"2020000006461"
public string deviceName; //"水泵控制柜6461"
public string logTime;//"2024-04-11 07:51:12"
public string devSystem;// "sprinkler"
public string appKey;// "849248896159842305"
public string descript;//描述
public string floor;//楼层
}
//manualAutomaticState 手自动状态(0 自动,1 手动) TRUE string
//powerState 电源状态(0 已上电,1 未上电) TRUE string
//faultStatus 故障信息(0 正常,1 故障) TRUE string
//startStopStatus 启停状态(0 停止,1 启动) TRUE string
public class PLInfo : InfoBase
{ {
public string deviceType;
public string devInterface;
public string startStopStatus; public string startStopStatus;
public string openProjectId;
public string deviceTypeName;
public string faultStatus; public string faultStatus;
public string ulogtime;
public int isOnline;
public string deviceNo;
public string deviceName;
public string logTime;
public string powerState; public string powerState;
public string manualAutomaticState; public string manualAutomaticState;
public string devSystem; }
public string appKey; public class XHSInfo : InfoBase
public string descript; {
public string floor; public string pressure;
public string alarmStatus;
}
public class SXInfo : InfoBase
{
public string level;
public string alarmStatus;
} }

5
Assets/Scripts/ANet/DeviceObj.cs

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.EventSystems;
public class DeviceObj : MonoBehaviour public class DeviceObj : MonoBehaviour
{ {
@ -13,6 +14,10 @@ public class DeviceObj : MonoBehaviour
} }
private void OnMouseDown() private void OnMouseDown()
{ {
if (EventSystem.current.IsPointerOverGameObject())
{
return;
}
DevicePanelManager.Instance.ShowBindList(BindType, this); DevicePanelManager.Instance.ShowBindList(BindType, this);
} }
} }

1
Assets/StreamingAssets/DeviceObj.json

@ -1 +0,0 @@
[{"ObjName":"Cube (1)","DeviceId":"2020000006464"},{"ObjName":"BF_Beng0","DeviceId":"2020000006463"}]

7
Assets/StreamingAssets/DeviceObj.json.meta

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: b58d3f38dd601a94f9d59128c283d571
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Loading…
Cancel
Save