123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- using LitJson;
- using Newtonsoft.Json;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class ModelDataManager : MonoSingleton<ModelDataManager>
- {
- public HumitdlyPanel humityObj;
- public NoisePanel NoiseObj;
- public OccPanel OccObj;
- public bool isLoadModel = false;
- private void Start()
- {
- GetPanelState();
- }
- // 获取三个设备的基础状态
- public void GetPanelState()
- {
- JsonData data = new JsonData();
- data["deviceClassification"] = "TEMPERATURE_HUMIDITY";
- PanelController.Instance.Post("https://api-fat1.ghz-tech.com" + "/feature-tester/v1/AIot/device/statisticsEquipmentStatus", data.ToJson(), (msg) =>
- {
- Debug.Log("DGJ ===> TEMPERATURE_HUMIDITY " + msg);
- if (msg == "Request Timeout")
- return;
- JsonData data = JsonMapper.ToObject(msg);
- if (data["code"].ToString() == "200")
- {
- string state = data["data"]["alarm"].ToString();
- humityObj.state = state;
- }
- });
- data["deviceClassification"] = "VIBRATE";
- PanelController.Instance.Post("https://api-fat1.ghz-tech.com" + "/feature-tester/v1/AIot/device/statisticsEquipmentStatus", data.ToJson(), (msg) =>
- {
- Debug.Log("DGJ ===> TEMPERATURE_HUMIDITY " + msg);
- if (msg == "Request Timeout")
- return;
- JsonData data = JsonMapper.ToObject(msg);
- if (data["code"].ToString() == "200")
- {
- string state = data["data"]["alarm"].ToString();
- OccObj.state = state;
- }
- });
- data["deviceClassification"] = "VOICE";
- PanelController.Instance.Post("https://api-fat1.ghz-tech.com" + "/feature-tester/v1/AIot/device/statisticsEquipmentStatus", data.ToJson(), (msg) =>
- {
- Debug.Log("DGJ ===> TEMPERATURE_HUMIDITY " + msg);
- if (msg == "Request Timeout")
- return;
- JsonData data = JsonMapper.ToObject(msg);
- if (data["code"].ToString() == "200")
- {
- string state = data["data"]["alarm"].ToString();
- NoiseObj.state = state;
- }
- });
- }
- /// <summary>
- /// 1. 温湿度 2. 噪声 3. 振动
- /// </summary>
- /// <param name="i"></param>
- ///
- public void ShowDataObj(int num)
- {
- if (isLoadModel == false)
- return;
- switch (num)
- {
- case 1:
- humityObj.gameObject.SetActive(true);
- NoiseObj.gameObject.SetActive(false);
- OccObj.gameObject.SetActive(false);
- break;
- case 2:
- humityObj.gameObject.SetActive(false);
- NoiseObj.gameObject.SetActive(true);
- OccObj.gameObject.SetActive(false);
- break;
- case 3:
- humityObj.gameObject.SetActive(false);
- NoiseObj.gameObject.SetActive(false);
- OccObj.gameObject.SetActive(true);
- break;
- case -1:
- humityObj.gameObject.SetActive(false);
- NoiseObj.gameObject.SetActive(false);
- OccObj.gameObject.SetActive(false);
- break;
- default:
- break;
- }
- }
- public void SetHumitdlyData(string Msg)
- {
- HumitureMqttData humitureData = JsonConvert.DeserializeObject<HumitureMqttData>(Msg);
- humityObj.SetData(humitureData);
- }
- public void SetOscData(string Msg)
- {
- OscillateMqttData oscillateData = JsonConvert.DeserializeObject<OscillateMqttData>(Msg);
- OccObj.SetData(oscillateData);
- }
- public void SetNoiseData(string Msg)
- {
- NoiseMqttData Noise = JsonConvert.DeserializeObject<NoiseMqttData>(Msg);
- NoiseObj.SetData(Noise);
- }
- }
- public class HumitureMqttData
- {
- public AIDeviceData device { get; set; }
- public DeviceValueData temperature { get; set; }
- public DeviceValueData humidity { get; set; }
- }
- public class OscillateMqttData
- {
- public AIDeviceData device { get; set; }
- public DeviceValueData disp { get; set; }
- public DeviceValueData speed { get; set; }
- public DeviceValueData temp { get; set; }
- }
- public class NoiseMqttData
- {
- public AIDeviceData device { get; set; }
- public float value { get; set; }
- public string unit { get; set; }
- }
- public class AIDeviceData
- {
- public string deviceCode { get; set; }
- public string deviceName { get; set; }
- public string deviceClassification { get; set; }
- public long unixTimestamp { get; set; }
- }
- public class DeviceValueData
- {
- public float value { get; set; }
- public string unit { get; set; }
- }
|