123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Text;
- using LitJson;
- using UnityEngine;
- using UnityEngine.Networking;
- using static Manager;
- public class DataManager : MonoBehaviour
- {
- public static DataManager Instance;
- private void Awake()
- {
- Instance = this;
- }
- public void GetJiFang(Action<ServerData> callback)
- {
- ServerData sd = new ServerData();
- sd.serverList = new List<ServerRoomData>();
- for (int i = 0; i < 8; i++)
- {
- ServerRoomData srd = new ServerRoomData();
- srd.id = i;
- srd.name = i + "_机房";
- sd.serverList.Add(srd);
- }
- callback.Invoke(sd);
- }
- IEnumerator getUsageInfo(ServerData data, Action<LineChartData> callback, int type)
- {
- string typestr = "last_month_usage";
- if (type == 0)
- {
- typestr = "last_week_usage";
- }
- LineChartData data2 = new LineChartData();
- data2.xdata = new List<string>();
- data2.sdata = new List<LineChartSeriesData>();
-
- yield return StartCoroutine(Post_Demo("/detail/electricUsageInfo", "", (string msg) =>
- {
- JsonData datamsg = JsonMapper.ToObject(msg);
- for (int j = 0; j < datamsg["data"][typestr].Count; j++)
- {
- if(!data2.xdata.Contains(datamsg["data"][typestr][j]["date"].ToString()))
- data2.xdata.Add(datamsg["data"][typestr][j]["date"].ToString());
- }
- for (int i = 0; i < data.serverList.Count; i++)
- {
- LineChartSeriesData lc = new LineChartSeriesData();
- lc.name = data.serverList[i].name;
- lc.values = new List<float>();
- for (int z = 0; z < datamsg["data"][typestr].Count; z++)
- {
- if(data.serverList[i].name == datamsg["data"][typestr][z]["server_room_name"].ToString())
- {
- lc.values.Add(float.Parse(datamsg["data"][typestr][z]["usage"].ToString()));
- }
- }
- data2.sdata.Add(lc);
- }
- }));
- callback.Invoke(data2);
- }
- public void GetDLBiao(Action<LineChartData> callback,int type)
- {
- GetWSD((data) =>
- {
- StartCoroutine(getUsageInfo(data, callback, type));
- });
- return;
- LineChartData data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- for (int i = 0; i < 20; i++)
- {
- data.xdata.Add("xdata_" + i);
- }
-
- for (int i = 0; i < 8; i++)
- {
- LineChartSeriesData lc = new LineChartSeriesData();
- lc.name = "数据_"+ i;
- lc.values = new List<float>();
- for (int j = 0; j < 20; j++)
- {
- lc.values.Add(UnityEngine.Random.Range(1, 1000));
- }
- data.sdata.Add(lc);
- }
- callback.Invoke(data);
- }
- public void GetJL(int id,Action<List<ServerJiLongData>> callback)
- {
- List<ServerJiLongData> list = new List<ServerJiLongData>();
- JsonData data = new JsonData();
- data["server_room_id"] = id;
- StartCoroutine(Post_Demo("/detail/rackElectricInfo", data.ToJson(), (string msg) => {
- JsonData data = JsonMapper.ToObject(msg);
- for (int i = 0; i < data["data"]["groups"].Count; i++)
- {
- ServerJiLongData jilong = new ServerJiLongData();
- jilong.id = i;
- jilong.name = data["data"]["groups"][i]["name"].ToString();
- jilong.jiguilist = new List<ServerjiguiData>();
- for (int z = 0; z < data["data"]["groups"][i]["racks"].Count; z++)
- {
- ServerjiguiData jg = new ServerjiguiData();
- jg.name = data["data"]["groups"][i]["racks"][z]["name"].ToString();
- jg.srz = float.Parse(data["data"]["groups"][i]["racks"][z]["last_day_usage"].ToString());
- jg.syz = float.Parse(data["data"]["groups"][i]["racks"][z]["last_month_usage"].ToString());
- jg.szz = float.Parse(data["data"]["groups"][i]["racks"][z]["last_week_usage"].ToString());
- jg.zgl = float.Parse(data["data"]["groups"][i]["racks"][z]["power"].ToString());
- jilong.jiguilist.Add(jg);
- }
- list.Add(jilong);
- }
- callback.Invoke(list);
- }));
- }
- public void GetDL(Action<ServerData> callback)
- {
- GetWSD((data) =>
- {
-
- for (int j = 0; j < data.serverList.Count; j++)
- {
- if(data.serverList[j].jilonglist==null)
- {
- data.serverList[j].jilonglist = new List<ServerJiLongData>();
- }
-
- }
- callback.Invoke(data);
- });
- return;
- ServerData sd = new ServerData();
- sd.serverList = new List<ServerRoomData>();
- for (int i = 0; i < 8; i++)
- {
- ServerRoomData srd = new ServerRoomData();
- srd.id = i;
- srd.name = i + "_机房";
- srd.zonggonglv = UnityEngine.Random.Range(30.0f, 40.0f);
- srd.shangridl = UnityEngine.Random.Range(30.0f, 40.0f);
- srd.jilonglist = new List<ServerJiLongData>();
- for (int j = 0; j < i; j++)
- {
- ServerJiLongData jilong = new ServerJiLongData();
- jilong.id = j;
- jilong.name = i + "_" + j;
- jilong.jiguilist = new List<ServerjiguiData>();
- int rand = UnityEngine.Random.Range(2,4)>2?4:2;
- for (int z = 0; z < rand; z++)
- {
- ServerjiguiData jg = new ServerjiguiData();
- jg.name = i + "_" + j + "_" + z;
- jg.srz = 123;
- jg.syz = 123;
- jg.szz = 123;
- jg.zgl = 123;
- jilong.jiguilist.Add(jg);
- }
- srd.jilonglist.Add(jilong);
- }
- sd.serverList.Add(srd);
- }
- callback.Invoke(sd);
- }
- public static string ip = "";
- public IEnumerator Post_Demo(string url,string lstformData,Action<string> callback)
- {
- while(ip=="")
- {
- yield return null;
- }
- string m_url = ip + url;
- var request = new UnityWebRequest(m_url, "POST");
- byte[] bodyRaw = Encoding.UTF8.GetBytes(lstformData);
- request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
- request.SetRequestHeader("Content-Type", "application/json");
- DownloadHandler downloadHandler = new DownloadHandlerBuffer();
- request.downloadHandler = downloadHandler;
- yield return request.SendWebRequest();
- if (string.IsNullOrEmpty(request.error))
- {//Post的请求成功 //Post请求的返回参数
- var data = request.downloadHandler.text;
- Debug.Log(m_url+"_"+ lstformData + "——成功:" + data);
- callback.Invoke(data);
- }
- else
- {//Post的请求失败
- Debug.Log(m_url + "失败"+ lstformData+"_"+ request.error);
- }
- }
- public void GetTwoWsdTb(int id,int rid, Action<List<LineChartData>> callback)
- {
- JsonData data = new JsonData();
- data["server_room_id"] = id;
- data["rack_id"] = rid;
- StartCoroutine(Post_Demo("/detail/tempHumiInfo", data.ToJson(), (string msg) =>
- {
- List<LineChartData> sjds = new List<LineChartData>();
- JsonData datamsg = JsonMapper.ToObject(msg);
- LineChartData data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- //24小时last_24h_temp 温度
- LineChartSeriesData lc = new LineChartSeriesData();
- lc.name = "温度";
- lc.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_24h_temp"].Count; i++)
- {
- data.xdata.Add(datamsg["data"]["last_24h_temp"][i]["date"].ToString().Split(' ')[1]);
- lc.values.Add(float.Parse(datamsg["data"]["last_24h_temp"][i]["value"].ToString()));
- }
- data.sdata.Add(lc);
- //24小时last_24h_humi 温度
- LineChartSeriesData lc2 = new LineChartSeriesData();
- lc2.name = "湿度";
- lc2.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_24h_humi"].Count; i++)
- {
- lc2.values.Add(float.Parse(datamsg["data"]["last_24h_humi"][i]["value"].ToString()));
- }
- data.sdata.Add(lc2);
- sjds.Add(data);
- data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- //24小时last_day_temp 温度
- lc = new LineChartSeriesData();
- lc.name = "温度";
- lc.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_day_temp"].Count; i++)
- {
- data.xdata.Add(datamsg["data"]["last_day_temp"][i]["date"].ToString().Split(' ')[1]);
- lc.values.Add(float.Parse(datamsg["data"]["last_day_temp"][i]["value"].ToString()));
- }
- data.sdata.Add(lc);
- //24小时last_day_humi 温度
- lc2 = new LineChartSeriesData();
- lc2.name = "湿度";
- lc2.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_day_humi"].Count; i++)
- {
- lc2.values.Add(float.Parse(datamsg["data"]["last_day_humi"][i]["value"].ToString()));
- }
- data.sdata.Add(lc2);
- sjds.Add(data);
- data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- //24小时last_weed_temp 温度
- lc = new LineChartSeriesData();
- lc.name = "温度";
- lc.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_week_temp"].Count; i++)
- {
- data.xdata.Add(datamsg["data"]["last_week_temp"][i]["date"].ToString().Split(' ')[0]);
- lc.values.Add(float.Parse(datamsg["data"]["last_week_temp"][i]["value"].ToString()));
- }
- data.sdata.Add(lc);
- //24小时last_week_humi 温度
- lc2 = new LineChartSeriesData();
- lc2.name = "湿度";
- lc2.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_week_humi"].Count; i++)
- {
- lc2.values.Add(float.Parse(datamsg["data"]["last_week_humi"][i]["value"].ToString()));
- }
- data.sdata.Add(lc2);
- sjds.Add(data); data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- //24小时last_weed_temp 温度
- lc = new LineChartSeriesData();
- lc.name = "温度";
- lc.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_month_temp"].Count; i++)
- {
- data.xdata.Add(datamsg["data"]["last_month_temp"][i]["date"].ToString().Split(' ')[0]);
- lc.values.Add(float.Parse(datamsg["data"]["last_month_temp"][i]["value"].ToString()));
- }
- data.sdata.Add(lc);
- //24小时last_week_humi 温度
- lc2 = new LineChartSeriesData();
- lc2.name = "湿度";
- lc2.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["last_month_humi"].Count; i++)
- {
- lc2.values.Add(float.Parse(datamsg["data"]["last_month_humi"][i]["value"].ToString()));
- }
- data.sdata.Add(lc2);
- sjds.Add(data);
- callback.Invoke(sjds);
- }));
- }
- public void GetTwoWsd(int id, Action<List<ServerjiguiData>> callback)
- {
- JsonData data = new JsonData();
- data["server_room_id"] = id;
-
- StartCoroutine(Post_Demo("/detail/rackTempHumi", data.ToJson(), (string msg) =>
- {
- List<ServerjiguiData> sjds = new List<ServerjiguiData>();
- JsonData data = JsonMapper.ToObject(msg);
- for (int i = 0; i < data["data"]["racks"].Count; i++)
- {
- ServerjiguiData sjd = new ServerjiguiData();
- sjd.id =int.Parse( data["data"]["racks"][i]["id"].ToString());
- sjd.name = data["data"]["racks"][i]["name"].ToString();
- sjd.shidu = float.Parse(data["data"]["racks"][i]["temp"].ToString());
- sjd.wendu = float.Parse(data["data"]["racks"][i]["humi"].ToString());
- sjds.Add(sjd);
- }
- callback.Invoke(sjds);
- }));
- }
- public void GetWSD(Action<ServerData> callback)
- {
- Debug.Log("获取温湿度===》");
- StartCoroutine(Post_Demo("/overview/serverroom","",(string msg)=> {
- JsonData data = JsonMapper.ToObject(msg);
- ServerData sd = new ServerData();
- sd.serverList = new List<ServerRoomData>();
- for (int i = 0; i < data["data"]["item_info"].Count; i++)
- {
- ServerRoomData srd = new ServerRoomData();
- srd.id = int.Parse(data["data"]["item_info"][i]["server_room_id"].ToString());
- srd.name = data["data"]["item_info"][i]["item_name"].ToString();
- srd.wendu = float.Parse(data["data"]["item_info"][i]["item_temp"].ToString());
- srd.shidu = float.Parse(data["data"]["item_info"][i]["item_humi"].ToString());
- try
- {
- srd.shangridl = float.Parse(data["data"]["item_info"][i]["item_lastday_usage"].ToString());
- srd.zonggonglv = float.Parse(data["data"]["item_info"][i]["item_total_power"].ToString());
- }
- catch
- {
- }
- sd.serverList.Add(srd);
- }
- callback.Invoke(sd);
- }));
- return;
- ServerData sd = new ServerData();
- sd.serverList = new List<ServerRoomData>();
- for (int i = 0; i < 8; i++)
- {
- ServerRoomData srd = new ServerRoomData();
- srd.id = i;
- srd.name = i + "_机房";
- srd.wendu = UnityEngine.Random.Range(30.0f, 40.0f);
- srd.shidu = UnityEngine.Random.Range(30.0f, 40.0f);
- srd.jilonglist = new List<ServerJiLongData>();
- for (int j = 0; j < i; j++)
- {
- ServerJiLongData jilong = new ServerJiLongData();
- jilong.id = j;
- jilong.name = i + "_" + j;
- jilong.jiguilist = new List<ServerjiguiData>();
- int rand = UnityEngine.Random.Range(2, 4) > 2 ? 4 : 2;
- for (int z = 0; z < rand; z++)
- {
- ServerjiguiData jg = new ServerjiguiData();
- jg.name = i + "_" + j + "_" + z;
- jg.wendu = 123;
- jg.shidu = 123;
- jilong.jiguilist.Add(jg);
- }
- srd.jilonglist.Add(jilong);
- }
- sd.serverList.Add(srd);
- }
- callback.Invoke(sd);
- }
- ServerRoomData checkroom(int id , List<ServerRoomData> roomdata )
- {
- for (int i = 0; i < roomdata.Count; i++)
- {
- if(roomdata[i].id == id)
- {
- return roomdata[i];
- }
- }
- return null;
- }
- public void GetVideo(Action<ServerData> callback)
- {
- Debug.Log("获取video===》");
- StartCoroutine(Post_Demo("/overview/serverLiveOverview", "", (string msg) => {
- JsonData data = JsonMapper.ToObject(msg);
- ServerData sd = new ServerData();
- sd.serverList = new List<ServerRoomData>();
- for (int i = 0; i < data["data"]["items"].Count; i++)
- {
- ServerRoomData srd = new ServerRoomData();
- srd.id = int.Parse(data["data"]["items"][i]["server_room_id"].ToString());
- srd.name = data["data"]["items"][i]["server_name"].ToString();
- srd.videolist = new List<ServerVideoData>();
- ServerVideoData svd = new ServerVideoData();
- svd.id = 1;
- svd.type = 0;
- svd.name = "机房摄像头";
- svd.url = new List<string>();
- srd.videolist.Add(svd);
- for (int j = 0; j < data["data"]["items"][i]["video_list"]["room"].Count; j++)
- {
- svd.url.Add(data["data"]["items"][i]["video_list"]["room"][j].ToString());
- }
- ServerVideoData svd2 = new ServerVideoData();
- svd2.id = 1;
- svd.type = 1;
- svd2.name = "机笼摄像头";
- svd2.url = new List<string>();
- srd.videolist.Add(svd2);
- for (int j = 0; j < data["data"]["items"][i]["video_list"]["rack"].Count; j++)
- {
- svd2.url.Add(data["data"]["items"][i]["video_list"]["rack"][j].ToString());
- }
- sd.serverList.Add(srd);
- }
- callback.Invoke(sd);
- }));
- return;
- ServerData sd = new ServerData();
- sd.serverList = new List<ServerRoomData>();
- for (int i = 0; i < 8; i++)
- {
- ServerRoomData srd = new ServerRoomData();
- srd.id = i;
- srd.videolist = new List<ServerVideoData>();
- ServerVideoData svd = new ServerVideoData();
- svd.id = 1;
- svd.name = "机房摄像头";
- svd.url = new List<string>();
- for (int j = 0; j < 8; j++)
- {
- svd.url.Add("https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/hls/xgplayer-demo.m3u8");
- }
- srd.videolist.Add(svd);
- ServerVideoData svd2 = new ServerVideoData();
- svd2.id = 1;
- svd2.name = "机笼摄像头";
- svd2.url = new List<string>();
- for (int j = 0; j < 8; j++)
- {
- svd2.url.Add("https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/hls/xgplayer-demo.m3u8");
- }
- srd.videolist.Add(svd2);
- sd.serverList.Add(srd);
- }
- callback.Invoke(sd);
- }
- public void GetTongSuan(Action<TongSuanData> callback)
- {
- StartCoroutine(Post_Demo("/overview/generalResourceOverview", "", (string msg) =>
- {
- JsonData data = JsonMapper.ToObject(msg)["data"];
- TongSuanData jdata = new TongSuanData();
- jdata.devct = float.Parse(data["host_number"].ToString());
- jdata.serverct = float.Parse(data["server_number"].ToString());
- jdata.zhiji = float.Parse(data["network_device_number"].ToString());
- callback.Invoke(jdata);
- }));
- return;
- TongSuanData jdata = new TongSuanData();
- jdata.devct = 123;
- jdata.serverct = 123;
- jdata.zhiji = 123;
- callback.Invoke(jdata);
- }
- public void GetJianKongPt(Action<JianKongPtData> callback)
- {
- StartCoroutine(Post_Demo("/overview/monitor", "", (string msg) =>
- {
- JsonData data = JsonMapper.ToObject(msg)["data"];
- JianKongPtData jdata = new JianKongPtData();
- jdata.shijianct =float.Parse( data["strategy_number"].ToString()) ;
- jdata.zhixingct = float.Parse(data["plugin_number"].ToString());
- jdata.gaojingct = float.Parse(data["warn_number"].ToString());
- callback.Invoke(jdata);
- }));
- return;
- JianKongPtData jdata = new JianKongPtData();
- jdata.shijianct = 123;
- jdata.zhixingct = 123;
- jdata.gaojingct = 123;
- callback.Invoke(jdata);
- }
- public void GetSixServer(Action<List<PieChartData>> callback)
- {
- Debug.Log("6个服务器===》");
- StartCoroutine(Post_Demo("/overview/intelligentResourceOverview", "", (string msg) =>
- {
- JsonData data = JsonMapper.ToObject(msg);
- List<PieChartData> lp = new List<PieChartData>();
- for (int i = 0; i < data["data"]["items"].Count; i++)
- {
- PieChartData p = new PieChartData();
- p.title = data["data"]["items"][i]["name"].ToString();
- p.value =float.Parse( data["data"]["items"][i]["count"].ToString());
- p.items = new List<PieChartItemData>();
- foreach(var k in data["data"]["items"][i].Keys)
- {
- if(k!="name"&&k!="count")
- {
- PieChartItemData idata1 = new PieChartItemData();
- idata1.name = k;
- idata1.value = float.Parse(data["data"]["items"][i][k].ToString().Split('%')[0]);
- p.items.Add(idata1);
- }
- }
- lp.Add(p);
- }
- PieChartData p2 = new PieChartData();
- p2.title = data["data"]["flops"]["name"].ToString();
- p2.value = float.Parse(data["data"]["flops"]["value"].ToString().Split(' ')[0]);
- lp.Add(p2);
- callback.Invoke(lp);
- }));
-
- return;
- List<PieChartData> lp = new List<PieChartData>();
- for (int i = 0; i < 6; i++)
- {
- PieChartData p = new PieChartData();
- p.title = i.ToString();
- p.value = 1000000;
- p.items = new List<PieChartItemData>();
- PieChartItemData idata1 = new PieChartItemData();
- idata1.name = "RUN";
- idata1.value = 27;
- p.items.Add(idata1);
- PieChartItemData idata2 = new PieChartItemData();
- idata2.name = "IDLE";
- idata2.value = 27;
- p.items.Add(idata2);
- lp.Add(p);
- }
- callback.Invoke(lp);
- }
- public void GetK8s(Action<List<RingValueData>> callback)
- {
- Debug.Log("获取k8s===》");
- List<RingValueData> rvs = new List<RingValueData>();
- StartCoroutine(Post_Demo("/overview/kubernetsCluster", "", (string msg) =>
- {
- JsonData datamsg = JsonMapper.ToObject(msg);
- RingValueData d1 = new RingValueData();
- d1.value = datamsg["data"]["cluster_name"].ToString();
- RingValueData d2 = new RingValueData();
- d2.value = datamsg["data"]["cluster_status"].ToString();
- datamsg["data"]["cluster_status"].ToString();
- RingValueData d3 = new RingValueData();
- d3.value = datamsg["data"]["cluster_node_count"][0].ToString();
- d3.max = datamsg["data"]["cluster_node_count"][1].ToString();
- rvs.Add(d1);
- rvs.Add(d2);
- rvs.Add(d3);
- callback.Invoke(rvs);
- }));
- return;
-
- }
- public void GetGPUData(Action<LineChartData> callback)
- {
- Debug.Log("获取gpu===》");
- StartCoroutine(Post_Demo("/overview/gpupower", "", (string msg) => {
- JsonData datamsg = JsonMapper.ToObject(msg);
- LineChartData data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- LineChartSeriesData lc = new LineChartSeriesData();
- lc.name = "今日";
- lc.values = new List<float>();
- for (int i = 0; i < datamsg["data"][ "today_info"].Count; i++)
- {
- data.xdata.Add(datamsg["data"]["today_info"][i]["time"].ToString().Split(' ')[1]);
- lc.values.Add(float.Parse(datamsg["data"]["today_info"][i]["value"].ToString()));
- }
- data.sdata.Add(lc);
- LineChartSeriesData lc2 = new LineChartSeriesData();
- lc2.name = "昨日";
- lc2.values = new List<float>();
- for (int i = 0; i < datamsg["data"]["yesterday_info"].Count; i++)
- {
- lc2.values.Add(float.Parse( datamsg["data"]["yesterday_info"][i]["value"].ToString()));
- }
- data.sdata.Add(lc2);
- callback.Invoke(data);
- }));
- return;
- LineChartData data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- for (int i = 0; i < 10; i++)
- {
- data.xdata.Add("xdata_" + i);
- }
- LineChartSeriesData lc = new LineChartSeriesData();
- lc.name = "数据1";
- lc.values = new List<float>();
- for (int i = 0; i < 10; i++)
- {
- lc.values.Add(UnityEngine.Random.Range(1, 800));
- }
- data.sdata.Add(lc);
- LineChartSeriesData lc2 = new LineChartSeriesData();
- lc2.name = "数据2";
- lc2.values = new List<float>();
- for (int i = 0; i < 10; i++)
- {
- lc2.values.Add(UnityEngine.Random.Range(1, 800));
- }
- data.sdata.Add(lc2);
- callback.Invoke(data);
- }
- public void GetGaoJingData(Action<LineChartData> callback)
- {
- StartCoroutine(Post_Demo("/overview/warnData", "", (string msg) =>
- {
- JsonData datamsg = JsonMapper.ToObject(msg);
- LineChartData data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- for (int i = 0; i < datamsg["data"]["prop_ame"].Count; i++)
- {
- LineChartSeriesData lc = new LineChartSeriesData();
- lc.name = datamsg["data"]["prop_ame"][i].ToString();
- lc.values = new List<float>();
- data.sdata.Add(lc);
- }
- for (int i = 0; i < datamsg["data"]["items"].Count; i++)
- {
- data.xdata.Add(datamsg["data"]["items"][i]["date"].ToString());
- for (int j = 0; j < data.sdata.Count; j++)
- {
- data.sdata[j].values.Add(float.Parse(datamsg["data"]["items"][i]["prop_value"][j].ToString()));
- }
- }
- callback.Invoke(data);
- }));
- return;
- LineChartData data = new LineChartData();
- data.xdata = new List<string>();
- data.sdata = new List<LineChartSeriesData>();
- for (int i = 0; i < 20; i++)
- {
- data.xdata.Add("xdata_" + i);
- }
- LineChartSeriesData lc = new LineChartSeriesData();
- lc.name = "数据1";
- lc.values = new List<float>();
- for (int i = 0; i < 20; i++)
- {
- lc.values.Add(UnityEngine.Random.Range(1, 1000));
- }
- data.sdata.Add(lc);
- LineChartSeriesData lc2 = new LineChartSeriesData();
- lc2.name = "数据2";
- lc2.values = new List<float>();
- for (int i = 0; i < 20; i++)
- {
- lc2.values.Add(UnityEngine.Random.Range(1, 1000));
- }
- data.sdata.Add(lc2);
- LineChartSeriesData lc3 = new LineChartSeriesData();
- lc3.name = "数据3";
- lc3.values = new List<float>();
- for (int i = 0; i < 20; i++)
- {
- lc3.values.Add(UnityEngine.Random.Range(1, 1000));
- }
- data.sdata.Add(lc2);
- callback.Invoke(data);
- }
- public void GetGaoJingJiLuData(Action<GaoJingListData> callback)
- {
- StartCoroutine(Post_Demo("/overview/warnRecord", "", (string msg) =>
- {
- JsonData datamsg = JsonMapper.ToObject(msg);
- GaoJingListData gjl = new GaoJingListData();
- gjl.list = new List<GaoJingItemData>();
- for (int i = 0; i < datamsg["data"]["items"].Count; i++)
- {
- GaoJingItemData gjid = new GaoJingItemData();
- gjid.lv = datamsg["data"]["items"][i]["level"].ToString();
- gjid.time = datamsg["data"]["items"][i]["time"].ToString();
- gjid.dev = datamsg["data"]["items"][i]["device"].ToString();
- gjid.type = datamsg["data"]["items"][i]["status"].ToString();
- gjl.list.Add(gjid);
- }
- callback.Invoke(gjl);
- }));
- return;
- GaoJingListData gjl = new GaoJingListData();
- gjl.list = new List<GaoJingItemData>();
- for (int i = 0; i < 2; i++)
- {
- GaoJingItemData gjid = new GaoJingItemData();
- gjid.lv = "一般";
- gjid.time = "2024-1-1 00:11";
- gjid.dev = "111机房";
- gjid.type = "已解决";
- gjl.list.Add(gjid);
- }
- for (int i = 0; i < 2; i++)
- {
- GaoJingItemData gjid = new GaoJingItemData();
- gjid.lv = "紧急";
- gjid.time = "2024-1-1 00:11";
- gjid.dev = "111机房";
- gjid.type = "待解决";
- gjl.list.Add(gjid);
- }
- for (int i = 0; i < 2; i++)
- {
- GaoJingItemData gjid = new GaoJingItemData();
- gjid.lv = "严重";
- gjid.time = "2024-1-1 00:11";
- gjid.dev = "111机房";
- gjid.type = "已解决";
- gjl.list.Add(gjid);
- }
- callback.Invoke(gjl);
- }
- }
|