DataManager.cs 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using static Manager;
  6. public class DataManager : MonoBehaviour
  7. {
  8. public static DataManager Instance;
  9. private void Awake()
  10. {
  11. Instance = this;
  12. }
  13. public void GetJiFang(Action<ServerData> callback)
  14. {
  15. ServerData sd = new ServerData();
  16. sd.serverList = new List<ServerRoomData>();
  17. for (int i = 0; i < 8; i++)
  18. {
  19. ServerRoomData srd = new ServerRoomData();
  20. srd.id = i;
  21. srd.name = i + "_机房";
  22. sd.serverList.Add(srd);
  23. }
  24. callback.Invoke(sd);
  25. }
  26. public void GetDLBiao(Action<LineChartData> callback,int type)
  27. {
  28. LineChartData data = new LineChartData();
  29. data.xdata = new List<string>();
  30. data.sdata = new List<LineChartSeriesData>();
  31. for (int i = 0; i < 20; i++)
  32. {
  33. data.xdata.Add("xdata_" + i);
  34. }
  35. for (int i = 0; i < 8; i++)
  36. {
  37. LineChartSeriesData lc = new LineChartSeriesData();
  38. lc.name = "数据_"+ i;
  39. lc.values = new List<float>();
  40. for (int j = 0; j < 20; j++)
  41. {
  42. lc.values.Add(UnityEngine.Random.Range(1, 1000));
  43. }
  44. data.sdata.Add(lc);
  45. }
  46. callback.Invoke(data);
  47. }
  48. public void GetDL(Action<ServerData> callback)
  49. {
  50. ServerData sd = new ServerData();
  51. sd.serverList = new List<ServerRoomData>();
  52. for (int i = 0; i < 8; i++)
  53. {
  54. ServerRoomData srd = new ServerRoomData();
  55. srd.id = i;
  56. srd.name = i + "_机房";
  57. srd.zonggonglv = UnityEngine.Random.Range(30.0f, 40.0f);
  58. srd.shangridl = UnityEngine.Random.Range(30.0f, 40.0f);
  59. srd.jilonglist = new List<ServerJiLongData>();
  60. for (int j = 0; j < i; j++)
  61. {
  62. ServerJiLongData jilong = new ServerJiLongData();
  63. jilong.id = j;
  64. jilong.name = i + "_" + j;
  65. jilong.jiguilist = new List<ServerjiguiData>();
  66. int rand = UnityEngine.Random.Range(2,4)>2?4:2;
  67. for (int z = 0; z < rand; z++)
  68. {
  69. ServerjiguiData jg = new ServerjiguiData();
  70. jg.name = i + "_" + j + "_" + z;
  71. jg.srz = 123;
  72. jg.syz = 123;
  73. jg.szz = 123;
  74. jg.zgl = 123;
  75. jilong.jiguilist.Add(jg);
  76. }
  77. srd.jilonglist.Add(jilong);
  78. }
  79. sd.serverList.Add(srd);
  80. }
  81. callback.Invoke(sd);
  82. }
  83. public void GetWSD(Action<ServerData> callback)
  84. {
  85. ServerData sd = new ServerData();
  86. sd.serverList = new List<ServerRoomData>();
  87. for (int i = 0; i < 8; i++)
  88. {
  89. ServerRoomData srd = new ServerRoomData();
  90. srd.id = i;
  91. srd.name = i + "_机房";
  92. srd.wendu = UnityEngine.Random.Range(30.0f, 40.0f);
  93. srd.shidu = UnityEngine.Random.Range(30.0f, 40.0f);
  94. srd.jilonglist = new List<ServerJiLongData>();
  95. for (int j = 0; j < i; j++)
  96. {
  97. ServerJiLongData jilong = new ServerJiLongData();
  98. jilong.id = j;
  99. jilong.name = i + "_" + j;
  100. jilong.jiguilist = new List<ServerjiguiData>();
  101. int rand = UnityEngine.Random.Range(2, 4) > 2 ? 4 : 2;
  102. for (int z = 0; z < rand; z++)
  103. {
  104. ServerjiguiData jg = new ServerjiguiData();
  105. jg.name = i + "_" + j + "_" + z;
  106. jg.wendu = 123;
  107. jg.shidu = 123;
  108. jilong.jiguilist.Add(jg);
  109. }
  110. srd.jilonglist.Add(jilong);
  111. }
  112. sd.serverList.Add(srd);
  113. }
  114. callback.Invoke(sd);
  115. }
  116. public void GetVideo(Action<ServerData> callback)
  117. {
  118. ServerData sd = new ServerData();
  119. sd.serverList = new List<ServerRoomData>();
  120. for (int i = 0; i < 8; i++)
  121. {
  122. ServerRoomData srd = new ServerRoomData();
  123. srd.id = i;
  124. srd.videolist = new List<ServerVideoData>();
  125. ServerVideoData svd = new ServerVideoData();
  126. svd.id = 1;
  127. svd.name = "机房摄像头";
  128. svd.url = new List<string>();
  129. for (int j = 0; j < 8; j++)
  130. {
  131. svd.url.Add("https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/hls/xgplayer-demo.m3u8");
  132. }
  133. srd.videolist.Add(svd);
  134. ServerVideoData svd2 = new ServerVideoData();
  135. svd2.id = 1;
  136. svd2.name = "机笼摄像头";
  137. svd2.url = new List<string>();
  138. for (int j = 0; j < 8; j++)
  139. {
  140. svd2.url.Add("https://sf1-cdn-tos.huoshanstatic.com/obj/media-fe/xgplayer_doc_video/hls/xgplayer-demo.m3u8");
  141. }
  142. srd.videolist.Add(svd2);
  143. sd.serverList.Add(srd);
  144. }
  145. callback.Invoke(sd);
  146. }
  147. public void GetTongSuan(Action<TongSuanData> callback)
  148. {
  149. TongSuanData jdata = new TongSuanData();
  150. jdata.devct = 123;
  151. jdata.serverct = 123;
  152. jdata.zhiji = 123;
  153. callback.Invoke(jdata);
  154. }
  155. public void GetJianKongPt(Action<JianKongPtData> callback)
  156. {
  157. JianKongPtData jdata = new JianKongPtData();
  158. jdata.shijianct = 123;
  159. jdata.zhixingct = 123;
  160. jdata.gaojingct = 123;
  161. callback.Invoke(jdata);
  162. }
  163. public void GetSixServer(Action<List<PieChartData>> callback)
  164. {
  165. List<PieChartData> lp = new List<PieChartData>();
  166. for (int i = 0; i < 6; i++)
  167. {
  168. PieChartData p = new PieChartData();
  169. p.title = i.ToString();
  170. p.value = 1000000;
  171. p.items = new List<PieChartItemData>();
  172. PieChartItemData idata1 = new PieChartItemData();
  173. idata1.name = "RUN";
  174. idata1.value = 27;
  175. p.items.Add(idata1);
  176. PieChartItemData idata2 = new PieChartItemData();
  177. idata2.name = "IDLE";
  178. idata2.value = 27;
  179. p.items.Add(idata2);
  180. lp.Add(p);
  181. }
  182. callback.Invoke(lp);
  183. }
  184. public void GetK8s(Action<List<RingValueData>> callback)
  185. {
  186. List<RingValueData> rvs = new List<RingValueData>();
  187. for (int i = 0; i < 3; i++)
  188. {
  189. RingValueData d = new RingValueData();
  190. d.value = "4";
  191. d.max = "4";
  192. rvs.Add(d);
  193. }
  194. callback.Invoke(rvs);
  195. }
  196. public void GetGPUData(Action<LineChartData> callback)
  197. {
  198. LineChartData data = new LineChartData();
  199. data.xdata = new List<string>();
  200. data.sdata = new List<LineChartSeriesData>();
  201. for (int i = 0; i < 10; i++)
  202. {
  203. data.xdata.Add("xdata_" + i);
  204. }
  205. LineChartSeriesData lc = new LineChartSeriesData();
  206. lc.name = "数据1";
  207. lc.values = new List<float>();
  208. for (int i = 0; i < 10; i++)
  209. {
  210. lc.values.Add(UnityEngine.Random.Range(1, 800));
  211. }
  212. data.sdata.Add(lc);
  213. LineChartSeriesData lc2 = new LineChartSeriesData();
  214. lc2.name = "数据2";
  215. lc2.values = new List<float>();
  216. for (int i = 0; i < 10; i++)
  217. {
  218. lc2.values.Add(UnityEngine.Random.Range(1, 800));
  219. }
  220. data.sdata.Add(lc2);
  221. callback.Invoke(data);
  222. }
  223. public void GetGaoJingData(Action<LineChartData> callback)
  224. {
  225. LineChartData data = new LineChartData();
  226. data.xdata = new List<string>();
  227. data.sdata = new List<LineChartSeriesData>();
  228. for (int i = 0; i < 20; i++)
  229. {
  230. data.xdata.Add("xdata_" + i);
  231. }
  232. LineChartSeriesData lc = new LineChartSeriesData();
  233. lc.name = "数据1";
  234. lc.values = new List<float>();
  235. for (int i = 0; i < 20; i++)
  236. {
  237. lc.values.Add(UnityEngine.Random.Range(1, 1000));
  238. }
  239. data.sdata.Add(lc);
  240. LineChartSeriesData lc2 = new LineChartSeriesData();
  241. lc2.name = "数据2";
  242. lc2.values = new List<float>();
  243. for (int i = 0; i < 20; i++)
  244. {
  245. lc2.values.Add(UnityEngine.Random.Range(1, 1000));
  246. }
  247. data.sdata.Add(lc2);
  248. LineChartSeriesData lc3 = new LineChartSeriesData();
  249. lc3.name = "数据3";
  250. lc3.values = new List<float>();
  251. for (int i = 0; i < 20; i++)
  252. {
  253. lc3.values.Add(UnityEngine.Random.Range(1, 1000));
  254. }
  255. data.sdata.Add(lc2);
  256. callback.Invoke(data);
  257. }
  258. public void GetGaoJingJiLuData(Action<GaoJingListData> callback)
  259. {
  260. GaoJingListData gjl = new GaoJingListData();
  261. gjl.list = new List<GaoJingItemData>();
  262. for (int i = 0; i < 2; i++)
  263. {
  264. GaoJingItemData gjid = new GaoJingItemData();
  265. gjid.lv = "一般";
  266. gjid.time = "2024-1-1 00:11";
  267. gjid.dev = "111机房";
  268. gjid.type = "已解决";
  269. gjl.list.Add(gjid);
  270. }
  271. for (int i = 0; i < 2; i++)
  272. {
  273. GaoJingItemData gjid = new GaoJingItemData();
  274. gjid.lv = "紧急";
  275. gjid.time = "2024-1-1 00:11";
  276. gjid.dev = "111机房";
  277. gjid.type = "待解决";
  278. gjl.list.Add(gjid);
  279. }
  280. for (int i = 0; i < 2; i++)
  281. {
  282. GaoJingItemData gjid = new GaoJingItemData();
  283. gjid.lv = "严重";
  284. gjid.time = "2024-1-1 00:11";
  285. gjid.dev = "111机房";
  286. gjid.type = "已解决";
  287. gjl.list.Add(gjid);
  288. }
  289. callback.Invoke(gjl);
  290. }
  291. }