HttpHelper.cs 46 KB

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