HttpHelper.cs 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Threading.Tasks;
  6. using UnityAsync;
  7. using Best.HTTP;
  8. using Best.HTTP.JSON;
  9. using Newtonsoft.Json;
  10. using Newtonsoft.Json.Linq;
  11. using UnityEngine;
  12. using UnityEngine.Networking;
  13. using Unity.VisualScripting;
  14. using static System.Net.WebRequestMethods;
  15. public class HttpHelper : MonoBehaviour
  16. {
  17. public Action OnSWYJRefresh;
  18. public static HttpHelper _Instance;
  19. public static Dictionary<string, DevicesId_Data> _devicesIdDatas_BuYuan = new Dictionary<string, DevicesId_Data>();
  20. private async void Awake()
  21. {
  22. _Instance = this;
  23. InItBuYuanDevicesList();
  24. SendBuYuan_GetSensorData();
  25. GetBuYuanDevicesGroupInfo();
  26. if (GlobalData.pageIndex == PageIndex.Page1 || GlobalData.pageIndex == PageIndex.Page2 || GlobalData.pageIndex == PageIndex.Page3)
  27. {
  28. //可以并行,无需等待
  29. InitYZTData();
  30. }
  31. if (GlobalData.pageIndex == PageIndex.Page1)
  32. {
  33. //可以并行,无需等待
  34. InitXHGKData();//已完成迁移
  35. }
  36. if (GlobalData.pageIndex == PageIndex.Page1)
  37. {
  38. //可以并行,无需等待
  39. InitGCJKData();
  40. }
  41. if (GlobalData.pageIndex == PageIndex.Page1)
  42. {
  43. //可以并行,无需等待
  44. InitXHDDData();
  45. }
  46. if (GlobalData.pageIndex == PageIndex.Page1)
  47. {
  48. //可以并行,无需等待
  49. InitRKZYData();
  50. }
  51. if (GlobalData.pageIndex == PageIndex.Page1 || GlobalData.pageIndex == PageIndex.Page2)
  52. {
  53. //可以并行,无需等待
  54. InitSWYJData();
  55. }
  56. if (GlobalData.pageIndex == PageIndex.Page1 || GlobalData.pageIndex == PageIndex.Page2)
  57. {
  58. //可以并行,无需等待
  59. InitGCYWData(0);
  60. }
  61. }
  62. public async Task InitYZTData()
  63. {
  64. await InitYZTData1();//已完成迁移
  65. InitYZTData2();//未完成迁移
  66. InitYZTData3();//已完成迁移
  67. }
  68. public async Task InitYZTData1()
  69. {
  70. bool successInternet = true;
  71. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetWaterManagerProject);
  72. await requestData.SendWebRequest();
  73. try
  74. {
  75. if (requestData.result != UnityWebRequest.Result.Success)
  76. {
  77. Debug.LogWarning("YZTLayer联网不成功,读本地缓存数据,原因:返request不成功");
  78. successInternet = false;
  79. }
  80. else
  81. {
  82. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  83. // 提取data字段的值
  84. JToken dataToken = jsonObject["data"];
  85. JToken codeToken = jsonObject["code"];
  86. if (codeToken.ToString() == "200")
  87. {
  88. GlobalData.layerUnitDatas = JsonConvert.DeserializeObject<List<LayerUnitData>>(dataToken.ToString());
  89. }
  90. else
  91. {
  92. Debug.LogWarning("YZTLayer联网不成功,读本地缓存数据,原因:返序列化失败");
  93. successInternet = false;
  94. }
  95. }
  96. }
  97. catch (Exception e)
  98. {
  99. successInternet = false;
  100. Debug.LogWarning("YZTLayer联网不成功,读本地缓存数据,原因:" + e.ToString());
  101. }
  102. requestData.Dispose();
  103. if (!successInternet)
  104. {
  105. WWW www = new WWW(Application.streamingAssetsPath + "/layerUnitDatas.json");
  106. await new UnityAsync.WaitUntil(() =>
  107. {
  108. return www.isDone;
  109. });
  110. GlobalData.layerUnitDatas = JsonConvert.DeserializeObject<List<LayerUnitData>>(www.text);
  111. www.Dispose();
  112. }
  113. for (int i = 0; i < GlobalData.layerUnitDatas.Count; i++)
  114. {
  115. if (GlobalData.layerUnitDatas[i].type == LayerUnitType.JK)
  116. {
  117. GlobalData.obsCameraLib.Add(GlobalData.layerUnitDatas[i].name, GlobalData.layerUnitDatas[i].namePri);
  118. }
  119. }
  120. }
  121. public async Task InitYZTData2()
  122. {
  123. bool successInternet = true;
  124. string sendUrl = ServerAddress.API_GetDevicesInfo;
  125. sendUrl += "/34020000001180000001/channels?page=1&count=40";
  126. Debug.Log(sendUrl);
  127. UnityWebRequest requestData = UnityWebRequest.Get(sendUrl);
  128. await requestData.SendWebRequest();
  129. try
  130. {
  131. if (requestData.result != UnityWebRequest.Result.Success)
  132. {
  133. Debug.LogWarning("监控数据联网不成功,原因:返request不成功:" + requestData.error);
  134. successInternet = false;
  135. }
  136. else
  137. {
  138. Debug.Log(requestData.downloadHandler.text);
  139. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  140. // 提取data字段的值
  141. JToken dataToken = jsonObject["data"];
  142. JToken codeToken = jsonObject["code"];
  143. if (codeToken.ToString() == "0")
  144. {
  145. GlobalData.obsDatas = new List<ObsData>();
  146. ServerObsDatas serverObsDatas = JsonConvert.DeserializeObject<ServerObsDatas>(dataToken.ToString());
  147. for (int i = 0; i < serverObsDatas.list.Count; i++)
  148. {
  149. ObsData obsData = new ObsData();
  150. obsData.name = serverObsDatas.list[i].name;
  151. obsData.targetName = GlobalData.obsCameraLib[obsData.name];
  152. // if (i > 0)
  153. // {
  154. // obsData.url =
  155. // "http://www.chatgpt918.top:9080/rtp/34020000001180000001_34020000001310000001/hls.m3u8";
  156. // }
  157. // else
  158. // {
  159. obsData.url = ServerAddress.ObsSeverM3U8Address + string.Format("/rtp/{0}_{1}/hls.m3u8", serverObsDatas.list[i].deviceId, serverObsDatas.list[i].channelId);
  160. //}
  161. obsData.type = obsType.BuYuanObs;
  162. obsData.deviceId = serverObsDatas.list[i].deviceId;
  163. obsData.channelId = serverObsDatas.list[i].channelId;
  164. obsData.status = serverObsDatas.list[i].status;
  165. GlobalData.obsDatas.Add(obsData);
  166. }
  167. }
  168. else
  169. {
  170. Debug.LogWarning("监控数据联网不成功,原因:返序列化失败");
  171. successInternet = false;
  172. }
  173. }
  174. }
  175. catch (Exception e)
  176. {
  177. successInternet = false;
  178. Debug.LogWarning("监控数据联网不成功,原因:" + e.ToString());
  179. }
  180. requestData.Dispose();
  181. }
  182. public async Task InitYZTData3()
  183. {
  184. bool successInternet = true;
  185. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetWaterHotPoint);
  186. await requestData.SendWebRequest();
  187. try
  188. {
  189. if (requestData.result != UnityWebRequest.Result.Success)
  190. {
  191. Debug.LogWarning("YZTLayer联网不成功,读本地缓存数据,原因:返request不成功");
  192. successInternet = false;
  193. }
  194. else
  195. {
  196. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  197. // 提取data字段的值
  198. JToken dataToken = jsonObject["data"];
  199. JToken codeToken = jsonObject["code"];
  200. if (codeToken.ToString() == "200")
  201. {
  202. GlobalData.hotPointDatas = JsonConvert.DeserializeObject<List<HotPointData>>(dataToken.ToString());
  203. }
  204. else
  205. {
  206. Debug.LogWarning("YZTLayer联网不成功,读本地缓存数据,原因:返序列化失败");
  207. successInternet = false;
  208. }
  209. }
  210. }
  211. catch (Exception e)
  212. {
  213. successInternet = false;
  214. Debug.LogWarning("YZTLayer联网不成功,读本地缓存数据,原因:" + e.ToString());
  215. }
  216. requestData.Dispose();
  217. if (!successInternet)
  218. {
  219. WWW www = new WWW(Application.streamingAssetsPath + "/hotPoints.json");
  220. await new UnityAsync.WaitUntil(() =>
  221. {
  222. return www.isDone;
  223. });
  224. GlobalData.hotPointDatas = JsonConvert.DeserializeObject<List<HotPointData>>(www.text);
  225. Debug.Log(GlobalData.hotPointDatas.Count);
  226. www.Dispose();
  227. }
  228. }
  229. public async Task InitXHGKData()
  230. {
  231. bool successInternet = true;
  232. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGetProjectMilestones);
  233. await requestData.SendWebRequest();
  234. try
  235. {
  236. if (requestData.result != UnityWebRequest.Result.Success)
  237. {
  238. Debug.LogWarning("XHGKLayer联网不成功,读本地缓存数据,原因:返request不成功");
  239. successInternet = false;
  240. }
  241. else
  242. {
  243. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  244. // ȡdata ֶε ֵ
  245. JToken dataToken = jsonObject["data"];
  246. //Debug.Log(dataToken.ToString());
  247. JToken codeToken = jsonObject["code"];
  248. if (codeToken.ToString() == "200")
  249. {
  250. GlobalData.dsjContents = JsonConvert.DeserializeObject<List<DSJData>>(dataToken.ToString());
  251. }
  252. else
  253. {
  254. Debug.LogWarning("XHGKLayer联网不成功,读本地缓存数据,原因:返序列化失败");
  255. successInternet = false;
  256. }
  257. }
  258. }
  259. catch (Exception e)
  260. {
  261. successInternet = false;
  262. Debug.LogWarning("XHGKLayer联网不成功,读本地缓存数据,原因:" + e.ToString());
  263. }
  264. requestData.Dispose();
  265. if (!successInternet)
  266. {
  267. WWW www = new WWW(Application.streamingAssetsPath + "/dsj.json");
  268. await new UnityAsync.WaitUntil(() =>
  269. {
  270. return www.isDone;
  271. });
  272. GlobalData.dsjContents = JsonConvert.DeserializeObject<List<DSJData>>(www.text);
  273. www.Dispose();
  274. }
  275. }
  276. public async Task InitGCJKData()
  277. {
  278. bool successInternet = true;
  279. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGeQXZData);
  280. await requestData.SendWebRequest();
  281. try
  282. {
  283. if (requestData.result != UnityWebRequest.Result.Success)
  284. {
  285. Debug.LogWarning("水文站联网不成功,原因:返request不成功");
  286. successInternet = false;
  287. }
  288. else
  289. {
  290. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  291. // 提取data字段的值
  292. JToken dataToken = jsonObject["data"];
  293. JToken codeToken = jsonObject["code"];
  294. if (codeToken.ToString() == "200")
  295. {
  296. GlobalData.qXZDatas = JsonConvert.DeserializeObject<List<QXZData>>(dataToken.ToString());
  297. }
  298. else
  299. {
  300. Debug.LogWarning("水文站联网不成功,原因:返序列化失败");
  301. successInternet = false;
  302. }
  303. }
  304. }
  305. catch (Exception e)
  306. {
  307. successInternet = false;
  308. Debug.LogWarning("水文站联网不成功,原因:" + e.ToString());
  309. }
  310. requestData.Dispose();
  311. successInternet = true;
  312. UnityWebRequest requestData1 = UnityWebRequest.Get(ServerAddress.APIGetGeSWZData);
  313. await requestData1.SendWebRequest();
  314. try
  315. {
  316. if (requestData1.result != UnityWebRequest.Result.Success)
  317. {
  318. Debug.LogWarning("水文站联网不成功,原因:返request不成功");
  319. successInternet = false;
  320. }
  321. else
  322. {
  323. JObject jsonObject = JObject.Parse(requestData1.downloadHandler.text);
  324. // 提取data字段的值
  325. JToken dataToken = jsonObject["data"];
  326. JToken codeToken = jsonObject["code"];
  327. if (codeToken.ToString() == "200")
  328. {
  329. GlobalData.sWZDatas = JsonConvert.DeserializeObject<List<SWZData>>(dataToken.ToString());
  330. }
  331. else
  332. {
  333. Debug.LogWarning("水文站联网不成功,原因:返序列化失败");
  334. successInternet = false;
  335. }
  336. }
  337. }
  338. catch (Exception e)
  339. {
  340. successInternet = false;
  341. Debug.LogWarning("水文站联网不成功,原因:" + e.ToString());
  342. }
  343. requestData1.Dispose();
  344. }
  345. public async Task InitXHDDData()
  346. {
  347. WWW www = new WWW(Application.streamingAssetsPath + "/scheduling.json");
  348. await new UnityAsync.WaitUntil(() =>
  349. {
  350. return www.isDone;
  351. });
  352. GlobalData.schedulingData = JsonConvert.DeserializeObject<SchedulingData>(www.text);
  353. www.Dispose();
  354. }
  355. public async Task InitRKZYData()
  356. {
  357. bool successInternet = true;
  358. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGetMovePlans);
  359. await requestData.SendWebRequest();
  360. try
  361. {
  362. if (true)
  363. {
  364. Debug.LogWarning("RKZYLayer联网不成功,读本地缓存数据,原因:返request不成功");
  365. successInternet = false;
  366. }
  367. else
  368. {
  369. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  370. // 提取data字段的值
  371. JToken dataToken = jsonObject["data"];
  372. JToken codeToken = jsonObject["code"];
  373. if (codeToken.ToString() == "200")
  374. {
  375. GlobalData.allServerMovePlans = JsonConvert.DeserializeObject<List<ServerMovePlan>>(dataToken.ToString());
  376. }
  377. else
  378. {
  379. successInternet = false;
  380. Debug.LogWarning("XHGKLayer联网不成功,读本地缓存数据,原因:返序列化失败");
  381. }
  382. }
  383. }
  384. catch (Exception e)
  385. {
  386. successInternet = false;
  387. Debug.LogWarning("RKZYLayer联网不成功,读本地缓存数据,原因:" + e.ToString());
  388. }
  389. if (!successInternet)
  390. {
  391. WWW www = new WWW(Application.streamingAssetsPath + "/moveplan.json");
  392. await new UnityAsync.WaitUntil(() =>
  393. {
  394. return www.isDone;
  395. });
  396. GlobalData.allServerMovePlans = JsonConvert.DeserializeObject<List<ServerMovePlan>>(www.text);
  397. www.Dispose();
  398. }
  399. }
  400. public async Task InitSWYJData()
  401. {
  402. InitSWYJData0();
  403. await InitSWYJData1();
  404. await InitSWYJData2();
  405. OnSWYJRefresh?.Invoke();
  406. }
  407. public async Task InitSWYJData1()
  408. {
  409. GlobalData.BuYuanShuiWeiDataList = new List<ShuiWeiData>();
  410. var devicesInfo = _devicesIdDatas_BuYuan["上游水位计"];
  411. string sw1Result = await GetSingleDevicesInfo(devicesInfo.ChannelID, devicesInfo.DeviceID, 24);
  412. try
  413. {
  414. GetDevicesRequestData tempData = JsonConvert.DeserializeObject<GetDevicesRequestData>(sw1Result);
  415. if (tempData != null)
  416. {
  417. GlobalData.BuYuanShuiWeiDataList.Add(new ShuiWeiData()
  418. {
  419. name = "补元上游水位",
  420. targetName = "BY_ShuiWei_Up",
  421. value = tempData.datas[0].NodeValue / 100,
  422. type = shuiWeiType.BuYuanShuiWei,
  423. datas = tempData.datas.ToArray()
  424. });
  425. }
  426. }
  427. catch (Exception e)
  428. {
  429. Debug.LogWarning("补元上游水位不成功,原因:" + e.ToString());
  430. }
  431. var devicesInfo1 = _devicesIdDatas_BuYuan["下游水位计"];
  432. string sw2Result = await GetSingleDevicesInfo(devicesInfo1.ChannelID, devicesInfo1.DeviceID, 24);
  433. try
  434. {
  435. GetDevicesRequestData tempData = JsonConvert.DeserializeObject<GetDevicesRequestData>(sw2Result);
  436. if (tempData != null)
  437. {
  438. GlobalData.BuYuanShuiWeiDataList.Add(new ShuiWeiData()
  439. {
  440. name = "补元下游水位",
  441. targetName = "BY_ShuiWei_Down",
  442. value = tempData.datas[0].NodeValue / 100,
  443. type = shuiWeiType.BuYuanShuiWei,
  444. datas = tempData.datas.ToArray()
  445. });
  446. }
  447. }
  448. catch (Exception e)
  449. {
  450. Debug.LogWarning("补元下游水位不成功,原因:" + e.ToString());
  451. }
  452. string dayResult = await GetSingleDevicesInfo_day(devicesInfo.ChannelID, devicesInfo.DeviceID, 6);
  453. try
  454. {
  455. GetDevicesRequestData tempData = JsonConvert.DeserializeObject<GetDevicesRequestData>(dayResult);
  456. GlobalData.buYuanShuiWei_day = new ShuiWeiBianHuaData();
  457. GlobalData.buYuanShuiWei_day.name = new string[6];
  458. GlobalData.buYuanShuiWei_day.value = new double[6];
  459. for (int i = 0; i < tempData.datas.Count; i++)
  460. {
  461. GlobalData.buYuanShuiWei_day.name[i] = tempData.datas[i].RecvTime;
  462. GlobalData.buYuanShuiWei_day.value[i] = tempData.datas[i].NodeValue;
  463. }
  464. }
  465. catch (Exception e)
  466. {
  467. Debug.LogWarning("获取6天平均数据不成功,原因:" + e.ToString());
  468. }
  469. string monthResult = await GetSingleDevicesInfo_month(devicesInfo.ChannelID, devicesInfo.DeviceID, 6);
  470. try
  471. {
  472. GetDevicesRequestData tempData = JsonConvert.DeserializeObject<GetDevicesRequestData>(monthResult);
  473. GlobalData.buYuanShuiWei_month = new ShuiWeiBianHuaData();
  474. GlobalData.buYuanShuiWei_month.name = new string[6];
  475. GlobalData.buYuanShuiWei_month.value = new double[6];
  476. for (int i = 0; i < tempData.datas.Count; i++)
  477. {
  478. GlobalData.buYuanShuiWei_month.name[i] = tempData.datas[i].RecvTime;
  479. GlobalData.buYuanShuiWei_month.value[i] = tempData.datas[i].NodeValue;
  480. }
  481. }
  482. catch (Exception e)
  483. {
  484. Debug.LogWarning("获取6月平均数据不成功,原因:" + e.ToString());
  485. }
  486. string hourResult = await GetSingleDevicesInfo_hour(devicesInfo.ChannelID, devicesInfo.DeviceID, 6);
  487. try
  488. {
  489. GetDevicesRequestData tempData = JsonConvert.DeserializeObject<GetDevicesRequestData>(hourResult);
  490. GlobalData.buYuanShuiWei_hour = new ShuiWeiBianHuaData();
  491. GlobalData.buYuanShuiWei_hour.name = new string[6];
  492. GlobalData.buYuanShuiWei_hour.value = new double[6];
  493. for (int i = 0; i < tempData.datas.Count; i++)
  494. {
  495. GlobalData.buYuanShuiWei_hour.name[i] = tempData.datas[i].RecvTime;
  496. GlobalData.buYuanShuiWei_hour.value[i] = tempData.datas[i].NodeValue;
  497. }
  498. }
  499. catch (Exception e)
  500. {
  501. Debug.LogWarning("获取6小时平均数据不成功,原因:" + e.ToString());
  502. }
  503. }
  504. public async Task InitSWYJData2()
  505. {
  506. bool successInternet = true;
  507. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetGeSWData);
  508. await requestData.SendWebRequest();
  509. try
  510. {
  511. if (requestData.result != UnityWebRequest.Result.Success)
  512. {
  513. Debug.LogWarning("水位高度联网不成功,原因:返request不成功");
  514. successInternet = false;
  515. }
  516. else
  517. {
  518. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  519. // 提取data字段的值
  520. JToken dataToken = jsonObject["data"];
  521. JToken codeToken = jsonObject["code"];
  522. if (codeToken.ToString() == "200")
  523. {
  524. GlobalData.swDatas = JsonConvert.DeserializeObject<List<StationData>>(dataToken.ToString());
  525. }
  526. else
  527. {
  528. Debug.LogWarning("水位高度联网不成功,原因:返序列化失败");
  529. successInternet = false;
  530. }
  531. for (int i = 0; i < GlobalData.BuYuanShuiWeiDataList.Count; i++)
  532. {
  533. StationData stationData = new StationData();
  534. stationData.LGTD = 113.910187f;
  535. stationData.LTTD = 30.1765823f;
  536. stationData.STNM = GlobalData.BuYuanShuiWeiDataList[i].name;
  537. stationData.upz = GlobalData.BuYuanShuiWeiDataList[i].name.Contains("上") ? GlobalData.BuYuanShuiWeiDataList[i].value : -1;
  538. stationData.dwz = GlobalData.BuYuanShuiWeiDataList[i].name.Contains("下") ? GlobalData.BuYuanShuiWeiDataList[i].value : -1;
  539. GlobalData.swDatas.Add(stationData);
  540. }
  541. }
  542. }
  543. catch (Exception e)
  544. {
  545. successInternet = false;
  546. Debug.LogWarning("水位高度联网不成功,原因:" + e.ToString());
  547. }
  548. }
  549. public async Task InitSWYJData0()
  550. {
  551. bool successInternet = true;
  552. UnityWebRequest requestData = UnityWebRequest.Get(ServerAddress.APIGetThreeLevel);
  553. await requestData.SendWebRequest();
  554. try
  555. {
  556. if (requestData.result != UnityWebRequest.Result.Success)
  557. {
  558. Debug.LogWarning("三线水位联网不成功,原因:返request不成功");
  559. successInternet = false;
  560. }
  561. else
  562. {
  563. JObject jsonObject = JObject.Parse(requestData.downloadHandler.text);
  564. // 提取data字段的值
  565. JToken dataToken = jsonObject["data"];
  566. JToken codeToken = jsonObject["code"];
  567. if (codeToken.ToString() == "200")
  568. {
  569. GlobalData.threeLevelShuiWeiDatas = JsonConvert.DeserializeObject<List<ThreeLevelShuiWeiData>>(dataToken.ToString());
  570. }
  571. else
  572. {
  573. Debug.LogWarning("三线水位联网不成功,原因:返序列化失败");
  574. successInternet = false;
  575. }
  576. }
  577. }
  578. catch (Exception e)
  579. {
  580. successInternet = false;
  581. Debug.LogWarning("三线水位联网不成功,原因:" + e.ToString());
  582. }
  583. }
  584. public async Task SendBuYuan_GetSensorData()
  585. {
  586. UnityWebRequest www = UnityWebRequest.Get(ServerAddress.API_BuYuan_GetSensorData);
  587. await www.SendWebRequest();
  588. try
  589. {
  590. if (www.result != UnityWebRequest.Result.Success)
  591. {
  592. Debug.LogWarning("获取补元闸门设备数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  593. }
  594. else
  595. {
  596. GlobalData.buYuanSensorData = JsonUtility.FromJson<SensorDataResult>(www.downloadHandler.text);
  597. }
  598. }
  599. catch (Exception e)
  600. {
  601. Debug.LogWarning("获取补元闸门设备数据不成功,原因:" + e.ToString());
  602. }
  603. www.Dispose();
  604. }
  605. public async Task GetBuYuanDevicesGroupInfo()
  606. {
  607. //获取所有渗压记
  608. GetDevicesData tempData = new GetDevicesData();
  609. tempData.idsList = new List<DevicesMessage>();
  610. for (int i = 0; i < 13; i++)
  611. {
  612. var devicesInfo = _devicesIdDatas_BuYuan[$"P{i + 1}"];
  613. tempData.idsList.Add(new DevicesMessage()
  614. {
  615. DeviceID = devicesInfo.DeviceID,
  616. ChannelID = devicesInfo.ChannelID
  617. });
  618. }
  619. string jsonStr;
  620. try
  621. {
  622. jsonStr = await Devices(tempData);
  623. jsonStr = "{\"datas\":" + jsonStr + "}";
  624. GetDevicesRequestData resultData = JsonUtility.FromJson<GetDevicesRequestData>(jsonStr);
  625. GlobalData.BuYuanShuiYaDataList = new List<ShuiYaData>();
  626. for (int i = 0; i < resultData.datas.Count; i++)
  627. {
  628. GlobalData.BuYuanShuiYaDataList.Add(new ShuiYaData()
  629. {
  630. name = resultData.datas[i].NodeName,
  631. value = resultData.datas[i].NodeValue,
  632. type = shuiYaType.BuYuanShuiYa,
  633. targetName = $"BY_{resultData.datas[i].NodeName}"
  634. });
  635. }
  636. }
  637. catch (Exception e)
  638. {
  639. Debug.LogWarning("获取补元水压计设备数据不成功,原因:" + e.ToString());
  640. throw;
  641. }
  642. //获取所有位移记
  643. tempData = new GetDevicesData();
  644. tempData.idsList = new List<DevicesMessage>();
  645. for (int i = 0; i < 8; i++)
  646. {
  647. var devicesInfo = _devicesIdDatas_BuYuan[$"M{i + 1}"];
  648. tempData.idsList.Add(new DevicesMessage()
  649. {
  650. DeviceID = devicesInfo.DeviceID,
  651. ChannelID = devicesInfo.ChannelID
  652. });
  653. }
  654. try
  655. {
  656. jsonStr = await Devices(tempData);
  657. jsonStr = "{\"datas\":" + jsonStr + "}";
  658. GetDevicesRequestData resultData = JsonUtility.FromJson<GetDevicesRequestData>(jsonStr);
  659. GlobalData.BuYuanWeiYiDataList = new List<WeiYiData>();
  660. for (int i = 0; i < resultData.datas.Count; i++)
  661. {
  662. GlobalData.BuYuanWeiYiDataList.Add(new WeiYiData()
  663. {
  664. name = resultData.datas[i].NodeName,
  665. value = resultData.datas[i].NodeValue,
  666. type = weiYiType.BuYuanWeiYi,
  667. targetName = $"BY_{resultData.datas[i].NodeName}"
  668. });
  669. }
  670. }
  671. catch (Exception e)
  672. {
  673. Debug.LogWarning("获取补元位移计设备数据不成功,原因:" + e.ToString());
  674. throw;
  675. }
  676. }
  677. /// <summary>
  678. /// 获取补元硬件组数据
  679. /// </summary>
  680. /// <param name="sendData"></param>
  681. /// <returns></returns>
  682. public async Task<string> Devices(GetDevicesData sendData)
  683. {
  684. string cmdUrl = ServerAddress.API_BuYuan_GetDevicesGroupInfo;
  685. string tempStr = JsonConvert.SerializeObject(sendData);
  686. var sendByte = System.Text.Encoding.UTF8.GetBytes(tempStr);
  687. UnityWebRequest www = new UnityWebRequest(cmdUrl, "POST");
  688. www.uploadHandler = new UploadHandlerRaw(sendByte);
  689. www.downloadHandler = new DownloadHandlerBuffer();
  690. www.SetRequestHeader("Content-Type", "application/json");
  691. await www.SendWebRequest();
  692. if (www.result != UnityWebRequest.Result.Success)
  693. {
  694. Debug.LogWarning($"获取设备数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  695. }
  696. string result = www.downloadHandler.text;
  697. www.Dispose();
  698. return result;
  699. }
  700. /// <summary>
  701. /// 获取设备的最近N条记录
  702. /// </summary>
  703. /// <param name="channelId"></param>
  704. /// <param name="deviceId"></param>
  705. /// <param name="count"></param>
  706. /// <returns></returns>
  707. public async Task<string> GetSingleDevicesInfo(int channelId, int deviceId, int count)
  708. {
  709. string cmdUrl = ServerAddress.API_BuYuan_GetSingleDevicesInfo;
  710. GetSingleDeviceData sendData = new GetSingleDeviceData();
  711. sendData.ChannelID = channelId;
  712. sendData.DeviceID = deviceId;
  713. sendData.N = count;
  714. string tempStr = JsonConvert.SerializeObject(sendData);
  715. var sendByte = System.Text.Encoding.UTF8.GetBytes(tempStr);
  716. UnityWebRequest www = new UnityWebRequest(cmdUrl, "POST");
  717. www.uploadHandler = new UploadHandlerRaw(sendByte);
  718. www.downloadHandler = new DownloadHandlerBuffer();
  719. www.SetRequestHeader("Content-Type", "application/json");
  720. await www.SendWebRequest();
  721. if (www.result != UnityWebRequest.Result.Success)
  722. {
  723. Debug.LogWarning("获取设备数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  724. }
  725. string result = www.downloadHandler.text;
  726. www.Dispose();
  727. return result;
  728. }
  729. /// <summary>
  730. /// 获取设备最近几天的平均数据
  731. /// </summary>
  732. /// <param name="channelId"></param>
  733. /// <param name="deviceId"></param>
  734. /// <param name="count"></param>
  735. /// <returns></returns>
  736. public async Task<string> GetSingleDevicesInfo_day(int channelId, int deviceId, int count)
  737. {
  738. string cmdUrl = ServerAddress.API_BuYuan_GetSingleDevicesInfo_avg;
  739. GetSingleDeviceData_AvgType sendData = new GetSingleDeviceData_AvgType();
  740. sendData.ChannelID = channelId;
  741. sendData.DeviceID = deviceId;
  742. sendData.AvgType = "day";
  743. sendData.N = count;
  744. string tempStr = JsonConvert.SerializeObject(sendData);
  745. var sendByte = System.Text.Encoding.UTF8.GetBytes(tempStr);
  746. UnityWebRequest www = new UnityWebRequest(cmdUrl, "POST");
  747. www.uploadHandler = new UploadHandlerRaw(sendByte);
  748. www.downloadHandler = new DownloadHandlerBuffer();
  749. www.SetRequestHeader("Content-Type", "application/json");
  750. await www.SendWebRequest();
  751. if (www.result != UnityWebRequest.Result.Success)
  752. {
  753. Debug.LogWarning("获取设备天平均数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  754. }
  755. string result = www.downloadHandler.text;
  756. www.Dispose();
  757. return result;
  758. }
  759. /// <summary>
  760. /// 获取设备最近几小时的平均数据
  761. /// </summary>
  762. /// <param name="channelId"></param>
  763. /// <param name="deviceId"></param>
  764. /// <param name="count"></param>
  765. /// <returns></returns>
  766. public async Task<string> GetSingleDevicesInfo_hour(int channelId, int deviceId, int count)
  767. {
  768. string cmdUrl = ServerAddress.API_BuYuan_GetSingleDevicesInfo_avg;
  769. GetSingleDeviceData_AvgType sendData = new GetSingleDeviceData_AvgType();
  770. sendData.ChannelID = channelId;
  771. sendData.DeviceID = deviceId;
  772. sendData.AvgType = "hour";
  773. sendData.N = count;
  774. string tempStr = JsonConvert.SerializeObject(sendData);
  775. var sendByte = System.Text.Encoding.UTF8.GetBytes(tempStr);
  776. UnityWebRequest www = new UnityWebRequest(cmdUrl, "POST");
  777. www.uploadHandler = new UploadHandlerRaw(sendByte);
  778. www.downloadHandler = new DownloadHandlerBuffer();
  779. www.SetRequestHeader("Content-Type", "application/json");
  780. await www.SendWebRequest();
  781. if (www.result != UnityWebRequest.Result.Success)
  782. {
  783. Debug.LogWarning("获取设备小时平均数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  784. }
  785. string result = www.downloadHandler.text;
  786. www.Dispose();
  787. return result;
  788. }
  789. /// <summary>
  790. /// 获取设备最近几个月的平均数据
  791. /// </summary>
  792. /// <param name="channelId"></param>
  793. /// <param name="deviceId"></param>
  794. /// <param name="count"></param>
  795. /// <returns></returns>
  796. public async Task<string> GetSingleDevicesInfo_month(int channelId, int deviceId, int count)
  797. {
  798. string cmdUrl = ServerAddress.API_BuYuan_GetSingleDevicesInfo_avg;
  799. GetSingleDeviceData_AvgType sendData = new GetSingleDeviceData_AvgType();
  800. sendData.ChannelID = channelId;
  801. sendData.DeviceID = deviceId;
  802. sendData.AvgType = "month";
  803. sendData.N = count;
  804. string tempStr = JsonConvert.SerializeObject(sendData);
  805. var sendByte = System.Text.Encoding.UTF8.GetBytes(tempStr);
  806. UnityWebRequest www = new UnityWebRequest(cmdUrl, "POST");
  807. www.uploadHandler = new UploadHandlerRaw(sendByte);
  808. www.downloadHandler = new DownloadHandlerBuffer();
  809. www.SetRequestHeader("Content-Type", "application/json");
  810. await www.SendWebRequest();
  811. if (www.result != UnityWebRequest.Result.Success)
  812. {
  813. Debug.LogWarning("获取设备月平均数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  814. }
  815. string result = www.downloadHandler.text;
  816. www.Dispose();
  817. return result;
  818. }
  819. /// <summary>
  820. /// 0 补元 1套口
  821. /// </summary>
  822. /// <param name="type"></param>
  823. public async Task InitGCYWData(int type)
  824. {
  825. GlobalData.B08_Type = type;
  826. string jsonStr;
  827. try
  828. {
  829. jsonStr = await B08_API_data(ServerAddress.API_B08_dataStatis,type);
  830. Debug.Log("API_B08_dataStatis" + jsonStr);
  831. GlobalData.B08DataStatis = JsonConvert.DeserializeObject<B08_dataStatis>(jsonStr);
  832. }
  833. catch (Exception e)
  834. {
  835. Debug.LogWarning("获取API_B08_dataStatis数据不成功,原因:" + e.ToString());
  836. }
  837. try
  838. {
  839. jsonStr = await B08_API_data(ServerAddress.API_B08_inspectResult,type);
  840. Debug.Log("API_B08_inspectResult" + jsonStr);
  841. GlobalData.B08InspectResult = JsonConvert.DeserializeObject<B08_inspectResult>(jsonStr);
  842. }
  843. catch (Exception e)
  844. {
  845. Debug.LogWarning("获取API_B08_inspectResult数据不成功,原因:" + e.ToString());
  846. }
  847. try
  848. {
  849. jsonStr = await B08_API_data(ServerAddress.API_B08_projectExamine,type);
  850. Debug.Log("API_B08_projectExamine" + jsonStr);
  851. GlobalData.B08ProjectExamine = JsonConvert.DeserializeObject<B08_projectExamine>(jsonStr);
  852. }
  853. catch (Exception e)
  854. {
  855. Debug.LogWarning("获取API_B08_projectExamine数据不成功,原因:" + e.ToString());
  856. }
  857. try
  858. {
  859. jsonStr = await B08_API_data(ServerAddress.API_B08_event,type);
  860. Debug.Log("API_B08_event" + jsonStr);
  861. GlobalData.B08Event = JsonConvert.DeserializeObject<B08_event>(jsonStr);
  862. }
  863. catch (Exception e)
  864. {
  865. Debug.LogWarning("获取API_B08_event数据不成功,原因:" + e.ToString());
  866. }
  867. try
  868. {
  869. jsonStr = await B08_API_data(ServerAddress.API_B08_questionStatis,type);
  870. Debug.Log("API_B08_questionStatis" + jsonStr);
  871. GlobalData.B08QuestionStatis = JsonConvert.DeserializeObject<B08_questionStatis>(jsonStr);
  872. }
  873. catch (Exception e)
  874. {
  875. Debug.LogWarning("获取API_B08_questionStatis数据不成功,原因:" + e.ToString());
  876. }
  877. try
  878. {
  879. jsonStr = await B08_API_data(ServerAddress.API_B08_inspectType,type);
  880. Debug.Log("API_B08_inspectType" + jsonStr);
  881. GlobalData.B08InspectType = JsonConvert.DeserializeObject<B08_inspectType>(jsonStr);
  882. }
  883. catch (Exception e)
  884. {
  885. Debug.LogWarning("获取API_B08_inspectType数据不成功,原因:" + e.ToString());
  886. }
  887. }
  888. public async Task<string> B08_API_data(string cmdUrl,int type)
  889. {
  890. if (type == 0)
  891. {
  892. cmdUrl += "1794245918999351298";
  893. }
  894. else
  895. {
  896. cmdUrl += "1798366756789653505";
  897. }
  898. UnityWebRequest www = new UnityWebRequest(cmdUrl, "Get");
  899. www.downloadHandler = new DownloadHandlerBuffer();
  900. www.SetRequestHeader("Content-Type", "application/json");
  901. await www.SendWebRequest();
  902. if (www.result != UnityWebRequest.Result.Success)
  903. {
  904. Debug.LogWarning($"获取{cmdUrl}数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  905. }
  906. string result = www.downloadHandler.text;
  907. www.Dispose();
  908. return result;
  909. }
  910. /// <summary>
  911. /// 获取站点水位信息
  912. /// </summary>
  913. /// <param name="stcd"></param>
  914. /// <returns></returns>
  915. public async Task<string> GetWaterTrend_Chart(string stcd)
  916. {
  917. UnityWebRequest www = new UnityWebRequest(ServerAddress.API_GetWaterTrend_chart+stcd, "Get");
  918. www.downloadHandler = new DownloadHandlerBuffer();
  919. www.SetRequestHeader("Content-Type", "application/json");
  920. await www.SendWebRequest();
  921. if (www.result != UnityWebRequest.Result.Success)
  922. {
  923. Debug.LogWarning($"获取stcd:{stcd},水位统计信息数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  924. }
  925. string result = www.downloadHandler.text;
  926. www.Dispose();
  927. return result;
  928. }
  929. public async Task<string> GetWaterTrend_List(string stcd)
  930. {
  931. UnityWebRequest www = new UnityWebRequest(ServerAddress.API_GetWaterTrend_list+stcd, "Get");
  932. www.downloadHandler = new DownloadHandlerBuffer();
  933. www.SetRequestHeader("Content-Type", "application/json");
  934. await www.SendWebRequest();
  935. if (www.result != UnityWebRequest.Result.Success)
  936. {
  937. Debug.LogWarning($"获取stcd:{stcd},水位统计信息数据不成功,原因:返request不成功:" + www.downloadHandler.text);
  938. }
  939. string result = www.downloadHandler.text;
  940. www.Dispose();
  941. return result;
  942. }
  943. public void SaveFirstFrame(byte[] uploadData, string fileName, string _targetName)
  944. {
  945. StartCoroutine(SendSaveFirstFrame(uploadData, fileName, _targetName));
  946. }
  947. IEnumerator SendSaveFirstFrame(byte[] uploadData, string fileName, string _targetName)
  948. {
  949. Debug.Log(fileName);
  950. WWWForm form = new WWWForm();
  951. form.AddBinaryData("file", uploadData, fileName);
  952. UnityWebRequest www = UnityWebRequest.Post(ServerAddress.API_TextureUploadPath, form);
  953. yield return www.SendWebRequest();
  954. if (www.result == UnityWebRequest.Result.Success)
  955. {
  956. ActionInstance._Instance.obsFmUpdata?.Invoke(_targetName);
  957. }
  958. Debug.Log(www.downloadHandler.text);
  959. www.Dispose();
  960. }
  961. #region 摄像头远程控制
  962. public void GetDeviceChannelId(string deviceId, Action<string> callBack)
  963. {
  964. StartCoroutine(SendGetDevicesChannel(deviceId, 1, 1, callBack));
  965. }
  966. IEnumerator SendGetDevicesChannel(string deviceId, int page, int count, Action<string> call)
  967. {
  968. string sendUrl = ServerAddress.API_GetDevicesInfo;
  969. sendUrl += $"/{deviceId}/channels?page={page}&count={count}&query&online&channelType&catalogUnderDevice";
  970. UnityWebRequest www = UnityWebRequest.Get(sendUrl);
  971. yield return www.SendWebRequest();
  972. ObsHttpRequestData tempData = JsonConvert.DeserializeObject<ObsHttpRequestData>(www.downloadHandler.text);
  973. GetObsChannelRequestData channelData = tempData.data.ToObject<GetObsChannelRequestData>();
  974. call?.Invoke(channelData.list[0].channelId);
  975. www.Dispose();
  976. }
  977. IEnumerator SendStartRTSP(string deviceId, string channelId)
  978. {
  979. string sendUrl = ServerAddress.API_PlayStart;
  980. sendUrl += $"/{deviceId}/{channelId}";
  981. UnityWebRequest www = UnityWebRequest.Get(sendUrl);
  982. yield return www.SendWebRequest();
  983. Debug.Log(www.downloadHandler.text);
  984. www.Dispose();
  985. }
  986. public void SendObsCameraCtrlCmd(string deviceId, string channelId, ObsCtrlType type)
  987. {
  988. StartCoroutine(SendCameraCtrl(deviceId, channelId, type.ToString()));
  989. }
  990. IEnumerator SendCameraCtrl(string deviceId, string channelId, string command)
  991. {
  992. string sendUrl = ServerAddress.API_CameraCtrl;
  993. sendUrl += $"/{deviceId}/{channelId}?command={command}&horizonSpeed=10&verticalSpeed=10&zoomSpeed=10";
  994. UnityWebRequest www = UnityWebRequest.Post(sendUrl, "");
  995. Debug.Log("send:" + sendUrl);
  996. yield return www.SendWebRequest();
  997. Debug.Log(www.downloadHandler.text);
  998. www.Dispose();
  999. }
  1000. #endregion
  1001. /// <summary>
  1002. /// 初始化所有补元硬件设备的获取信息
  1003. /// </summary>
  1004. public void InItBuYuanDevicesList()
  1005. {
  1006. _devicesIdDatas_BuYuan = new Dictionary<string, DevicesId_Data>();
  1007. _devicesIdDatas_BuYuan.Add("上游水位计", new DevicesId_Data()
  1008. {
  1009. ChannelID = 7,
  1010. DeviceID = 4,
  1011. name = "上游水位计",
  1012. showName = "",
  1013. value = -1
  1014. });
  1015. _devicesIdDatas_BuYuan.Add("下游水位计", new DevicesId_Data()
  1016. {
  1017. ChannelID = 8,
  1018. DeviceID = 4,
  1019. name = "上游水位计",
  1020. showName = "",
  1021. value = -1
  1022. });
  1023. #region P
  1024. _devicesIdDatas_BuYuan.Add("P1", new DevicesId_Data()
  1025. {
  1026. ChannelID = 1,
  1027. DeviceID = 2,
  1028. name = "P1/UP1",
  1029. showName = "",
  1030. value = -1
  1031. });
  1032. _devicesIdDatas_BuYuan.Add("P2", new DevicesId_Data()
  1033. {
  1034. ChannelID = 2,
  1035. DeviceID = 2,
  1036. name = "P2/UP2",
  1037. showName = "",
  1038. value = -1
  1039. });
  1040. _devicesIdDatas_BuYuan.Add("P3", new DevicesId_Data()
  1041. {
  1042. ChannelID = 3,
  1043. DeviceID = 2,
  1044. name = "P3",
  1045. showName = "",
  1046. value = -1
  1047. });
  1048. _devicesIdDatas_BuYuan.Add("P4", new DevicesId_Data()
  1049. {
  1050. ChannelID = 4,
  1051. DeviceID = 2,
  1052. name = "P4/UP3",
  1053. showName = "",
  1054. value = -1
  1055. });
  1056. _devicesIdDatas_BuYuan.Add("P5", new DevicesId_Data()
  1057. {
  1058. ChannelID = 1,
  1059. DeviceID = 3,
  1060. name = "P5/UP5",
  1061. showName = "",
  1062. value = -1
  1063. });
  1064. _devicesIdDatas_BuYuan.Add("P6", new DevicesId_Data()
  1065. {
  1066. ChannelID = 2,
  1067. DeviceID = 3,
  1068. name = "P6/",
  1069. showName = "",
  1070. value = -1
  1071. });
  1072. _devicesIdDatas_BuYuan.Add("P7", new DevicesId_Data()
  1073. {
  1074. ChannelID = 3,
  1075. DeviceID = 3,
  1076. name = "P7/UP5",
  1077. showName = "",
  1078. value = -1
  1079. });
  1080. _devicesIdDatas_BuYuan.Add("P8", new DevicesId_Data()
  1081. {
  1082. ChannelID = 4,
  1083. DeviceID = 3,
  1084. name = "P8/UP6",
  1085. showName = "",
  1086. value = -1
  1087. });
  1088. _devicesIdDatas_BuYuan.Add("P5温度", new DevicesId_Data()
  1089. {
  1090. ChannelID = 9,
  1091. DeviceID = 3,
  1092. name = "P5温度",
  1093. showName = "",
  1094. value = -1
  1095. });
  1096. _devicesIdDatas_BuYuan.Add("P6温度", new DevicesId_Data()
  1097. {
  1098. ChannelID = 10,
  1099. DeviceID = 3,
  1100. name = "P6温度",
  1101. showName = "",
  1102. value = -1
  1103. });
  1104. _devicesIdDatas_BuYuan.Add("P7温度", new DevicesId_Data()
  1105. {
  1106. ChannelID = 11,
  1107. DeviceID = 3,
  1108. name = "P7温度",
  1109. showName = "",
  1110. value = -1
  1111. });
  1112. _devicesIdDatas_BuYuan.Add("P8温度", new DevicesId_Data()
  1113. {
  1114. ChannelID = 12,
  1115. DeviceID = 3,
  1116. name = "P8温度",
  1117. showName = "",
  1118. value = -1
  1119. });
  1120. _devicesIdDatas_BuYuan.Add("P9温度", new DevicesId_Data()
  1121. {
  1122. ChannelID = 9,
  1123. DeviceID = 4,
  1124. name = "P9温度",
  1125. showName = "",
  1126. value = -1
  1127. });
  1128. _devicesIdDatas_BuYuan.Add("P10温度", new DevicesId_Data()
  1129. {
  1130. ChannelID = 10,
  1131. DeviceID = 4,
  1132. name = "P10温度",
  1133. showName = "",
  1134. value = -1
  1135. });
  1136. _devicesIdDatas_BuYuan.Add("P12温度", new DevicesId_Data()
  1137. {
  1138. ChannelID = 11,
  1139. DeviceID = 4,
  1140. name = "P12温度",
  1141. showName = "",
  1142. value = -1
  1143. });
  1144. _devicesIdDatas_BuYuan.Add("P9", new DevicesId_Data()
  1145. {
  1146. ChannelID = 3,
  1147. DeviceID = 4,
  1148. name = "P9",
  1149. showName = "",
  1150. value = -1
  1151. });
  1152. _devicesIdDatas_BuYuan.Add("P10", new DevicesId_Data()
  1153. {
  1154. ChannelID = 4,
  1155. DeviceID = 4,
  1156. name = "P10/UP7",
  1157. showName = "",
  1158. value = -1
  1159. });
  1160. _devicesIdDatas_BuYuan.Add("P11", new DevicesId_Data()
  1161. {
  1162. ChannelID = 5,
  1163. DeviceID = 4,
  1164. name = "P11/UP8",
  1165. showName = "",
  1166. value = -1
  1167. });
  1168. _devicesIdDatas_BuYuan.Add("P12", new DevicesId_Data()
  1169. {
  1170. ChannelID = 1,
  1171. DeviceID = 4,
  1172. name = "P12/UP9",
  1173. showName = "",
  1174. value = -1
  1175. });
  1176. _devicesIdDatas_BuYuan.Add("P13", new DevicesId_Data()
  1177. {
  1178. ChannelID = 2,
  1179. DeviceID = 4,
  1180. name = "P13/UP10",
  1181. showName = "",
  1182. value = -1
  1183. });
  1184. #endregion
  1185. #region M
  1186. //M1-8
  1187. int m_cid = 1;
  1188. int m_did = 5;
  1189. for (int i = 0; i < 8; i++)
  1190. {
  1191. _devicesIdDatas_BuYuan.Add($"M{i + 1}", new DevicesId_Data()
  1192. {
  1193. ChannelID = m_cid + i,
  1194. DeviceID = m_did,
  1195. name = $"M{i + 1}",
  1196. showName = "",
  1197. value = -1
  1198. });
  1199. }
  1200. //M温度
  1201. _devicesIdDatas_BuYuan.Add($"M2温度", new DevicesId_Data()
  1202. {
  1203. ChannelID = 10,
  1204. DeviceID = 5,
  1205. name = $"M2温度",
  1206. showName = "",
  1207. value = -1
  1208. });
  1209. _devicesIdDatas_BuYuan.Add($"M5温度", new DevicesId_Data()
  1210. {
  1211. ChannelID = 13,
  1212. DeviceID = 5,
  1213. name = $"M5温度",
  1214. showName = "",
  1215. value = -1
  1216. });
  1217. _devicesIdDatas_BuYuan.Add($"M6温度", new DevicesId_Data()
  1218. {
  1219. ChannelID = 14,
  1220. DeviceID = 5,
  1221. name = $"M6温度",
  1222. showName = "",
  1223. value = -1
  1224. });
  1225. _devicesIdDatas_BuYuan.Add($"M7温度", new DevicesId_Data()
  1226. {
  1227. ChannelID = 15,
  1228. DeviceID = 5,
  1229. name = $"M7温度",
  1230. showName = "",
  1231. value = -1
  1232. });
  1233. _devicesIdDatas_BuYuan.Add($"M8温度", new DevicesId_Data()
  1234. {
  1235. ChannelID = 16,
  1236. DeviceID = 5,
  1237. name = $"M8温度",
  1238. showName = "",
  1239. value = -1
  1240. });
  1241. #endregion
  1242. }
  1243. }