HttpHelper.cs 47 KB

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