UICallManager.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. using SC.XR.Unity.Module_InputSystem;
  2. using Blue;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class UICallManager : MonoSingleton<UICallManager>,IController
  6. {
  7. private delegate void TrackingFound(DataItem tagobj);
  8. private delegate void TrackingLast(DataItem tagobj);
  9. private delegate void Invite(string control, string roomid);
  10. private delegate void TimeOut();
  11. private delegate void NoExpert();
  12. /// <summary>
  13. /// 物体识别到显示
  14. /// </summary>
  15. private event TrackingFound OnTrackFound;
  16. /// <summary>
  17. /// 物体超出显示范围 隐藏
  18. /// </summary>
  19. private event TrackingLast OnTrackLast;
  20. /// <summary>
  21. /// 收到邀请
  22. /// </summary>
  23. private event Invite OnInvite;
  24. /// <summary>
  25. /// 超时
  26. /// </summary>
  27. private event TimeOut OnTimeOut;
  28. /// <summary>
  29. /// 无专家
  30. /// </summary>
  31. private event NoExpert OnNoExpert;
  32. private void Start()
  33. {
  34. DispatcherBase.KeyDownDelegateRegister(AnyDown);
  35. DispatcherBase.KeyUpDelegateRegister(AnyUp);
  36. OnTrackFound += OnTrackfound;
  37. OnTrackLast += OnTracklast;
  38. OnInvite += Oninvite;
  39. OnTimeOut += OntimeOut;
  40. OnNoExpert += OnnoExpert;
  41. // MachineRoomInit("");
  42. // MachineRoomInit();
  43. }
  44. public void OnTrackfound(DataItem item)
  45. {
  46. // ScenesManager.Instance.showWindow(ScenesManager.SceneType.Navigationing);
  47. if(HeadBtnManager.Instance.type == ScenesManager.SceneType.ShowDH)
  48. HeadBtnManager.Instance.uiFollow.Hide();
  49. }
  50. public void OnTracklast(DataItem item)
  51. {
  52. //ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowXunJian);
  53. //ShowXunJian.Instance.gotoWindow(ScenesManager.SceneType.ShowDH);
  54. }
  55. public void EventInvite(string control, string roomId)
  56. {
  57. OnInvite?.Invoke(control, roomId);
  58. }
  59. public void EventTimeOut()
  60. {
  61. OnTimeOut?.Invoke();
  62. }
  63. public void EventNoExpert()
  64. {
  65. OnNoExpert?.Invoke();
  66. }
  67. public void Oninvite(string control ,string roomId)
  68. {
  69. this.GetService<IRTCService>().JoinRoom(roomId);
  70. }
  71. public void OntimeOut()
  72. {
  73. // 退出房间
  74. this.GetService<IRTCService>().LeaveRoom();
  75. // 改文字UI
  76. // AllotPanel.Instance.SetAllotText("");
  77. }
  78. public void OnnoExpert()
  79. {
  80. // 退出房间
  81. this.GetService<IRTCService>().LeaveRoom();
  82. // 改文字UI
  83. // AllotPanel.Instance.SetAllotText("");
  84. }
  85. /// <summary>
  86. /// 设置MQTT房间ID
  87. /// </summary>
  88. public void SetMQTTRoomId(string roomId)
  89. {
  90. MQTTManager.Instance.SetRoomId(roomId);
  91. }
  92. private void AnyUp(InputKeyCode keyCode, InputDevicePartBase part)
  93. {
  94. // Debug.Log("DGJ ====> AnyUp " + keyCode.ToString());
  95. // UILogManager.Instance.SendLogText(3, part.PartType.ToString());
  96. if (part.PartType == InputDevicePartType.KSRight )
  97. {
  98. switch (keyCode)
  99. {
  100. case InputKeyCode.Enter:
  101. break;
  102. case InputKeyCode.Cancel:
  103. break;
  104. case InputKeyCode.Trigger:
  105. break;
  106. case InputKeyCode.Function:
  107. break;
  108. case InputKeyCode.Back:
  109. break;
  110. case InputKeyCode.Tp:
  111. break;
  112. case InputKeyCode.VolumeDown:
  113. break;
  114. case InputKeyCode.VolumeUp:
  115. break;
  116. case InputKeyCode.A:
  117. break;
  118. case InputKeyCode.B:
  119. break;
  120. case InputKeyCode.LjoystickKey:
  121. break;
  122. case InputKeyCode.LFunction:
  123. break;
  124. case InputKeyCode.LHallInside:
  125. break;
  126. case InputKeyCode.LHallForward:
  127. break;
  128. case InputKeyCode.LTrigger:
  129. break;
  130. case InputKeyCode.X:
  131. break;
  132. case InputKeyCode.Y:
  133. break;
  134. case InputKeyCode.RjoystickKey:
  135. break;
  136. case InputKeyCode.RFunction: // 返回主界面
  137. Debug.Log("DGJ ====> RFunction 按了 ");
  138. // ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  139. break;
  140. case InputKeyCode.RHallInside:
  141. break;
  142. case InputKeyCode.RHallForward:
  143. break;
  144. case InputKeyCode.RTrigger:
  145. break;
  146. case InputKeyCode.UP:
  147. break;
  148. case InputKeyCode.DOWN:
  149. break;
  150. case InputKeyCode.RIGHT:
  151. break;
  152. case InputKeyCode.LEFT:
  153. break;
  154. case InputKeyCode.OTHER:
  155. break;
  156. case InputKeyCode.NULL:
  157. break;
  158. default:
  159. break;
  160. }
  161. }
  162. if (part.PartType == InputDevicePartType.KSLeft)
  163. {
  164. switch (keyCode)
  165. {
  166. case InputKeyCode.Enter:
  167. break;
  168. case InputKeyCode.Cancel:
  169. break;
  170. case InputKeyCode.Trigger:
  171. break;
  172. case InputKeyCode.Function:
  173. break;
  174. case InputKeyCode.Back:
  175. break;
  176. case InputKeyCode.Tp:
  177. break;
  178. case InputKeyCode.VolumeDown:
  179. break;
  180. case InputKeyCode.VolumeUp:
  181. break;
  182. case InputKeyCode.A:
  183. break;
  184. case InputKeyCode.B:
  185. break;
  186. case InputKeyCode.LjoystickKey:
  187. break;
  188. case InputKeyCode.LFunction:
  189. break;
  190. case InputKeyCode.LHallInside:
  191. break;
  192. case InputKeyCode.LHallForward:
  193. break;
  194. case InputKeyCode.LTrigger:
  195. break;
  196. case InputKeyCode.X:
  197. break;
  198. case InputKeyCode.Y:
  199. break;
  200. case InputKeyCode.RjoystickKey:
  201. break;
  202. case InputKeyCode.RFunction:
  203. break;
  204. case InputKeyCode.RHallInside:
  205. break;
  206. case InputKeyCode.RHallForward:
  207. break;
  208. case InputKeyCode.RTrigger:
  209. break;
  210. case InputKeyCode.UP:
  211. break;
  212. case InputKeyCode.DOWN:
  213. break;
  214. case InputKeyCode.RIGHT:
  215. break;
  216. case InputKeyCode.LEFT:
  217. break;
  218. case InputKeyCode.OTHER:
  219. break;
  220. case InputKeyCode.NULL:
  221. break;
  222. default:
  223. break;
  224. }
  225. }
  226. }
  227. private void AnyDown(InputKeyCode keyCode, InputDevicePartBase part)
  228. {
  229. // Debug.Log("DGJ ====> AnyDown " + keyCode.ToString());
  230. // UILogManager.Instance.SendLogText(3, part.PartType.ToString());
  231. if (part.PartType == InputDevicePartType.KSRight)
  232. {
  233. switch (keyCode)
  234. {
  235. case InputKeyCode.Enter:
  236. break;
  237. case InputKeyCode.Cancel:
  238. break;
  239. case InputKeyCode.Trigger:
  240. break;
  241. case InputKeyCode.Function:
  242. break;
  243. case InputKeyCode.Back:
  244. break;
  245. case InputKeyCode.Tp:
  246. break;
  247. case InputKeyCode.VolumeDown:
  248. break;
  249. case InputKeyCode.VolumeUp:
  250. break;
  251. case InputKeyCode.A:
  252. break;
  253. case InputKeyCode.B:
  254. break;
  255. case InputKeyCode.LjoystickKey:
  256. break;
  257. case InputKeyCode.LFunction:
  258. break;
  259. case InputKeyCode.LHallInside:
  260. break;
  261. case InputKeyCode.LHallForward:
  262. break;
  263. case InputKeyCode.LTrigger:
  264. break;
  265. case InputKeyCode.X:
  266. break;
  267. case InputKeyCode.Y:
  268. break;
  269. case InputKeyCode.RjoystickKey:
  270. break;
  271. case InputKeyCode.RFunction:
  272. Debug.Log("DGJ ====> RFunction 按了 ");
  273. break;
  274. case InputKeyCode.RHallInside:
  275. break;
  276. case InputKeyCode.RHallForward:
  277. break;
  278. case InputKeyCode.RTrigger:
  279. break;
  280. case InputKeyCode.UP:
  281. break;
  282. case InputKeyCode.DOWN:
  283. break;
  284. case InputKeyCode.RIGHT:
  285. break;
  286. case InputKeyCode.LEFT:
  287. break;
  288. case InputKeyCode.OTHER:
  289. break;
  290. case InputKeyCode.NULL:
  291. break;
  292. default:
  293. break;
  294. }
  295. }
  296. if (part.PartType == InputDevicePartType.KSLeft)
  297. {
  298. switch (keyCode)
  299. {
  300. case InputKeyCode.Enter:
  301. break;
  302. case InputKeyCode.Cancel:
  303. break;
  304. case InputKeyCode.Trigger:
  305. break;
  306. case InputKeyCode.Function:
  307. break;
  308. case InputKeyCode.Back:
  309. break;
  310. case InputKeyCode.Tp:
  311. break;
  312. case InputKeyCode.VolumeDown:
  313. break;
  314. case InputKeyCode.VolumeUp:
  315. break;
  316. case InputKeyCode.A:
  317. break;
  318. case InputKeyCode.B:
  319. break;
  320. case InputKeyCode.LjoystickKey:
  321. break;
  322. case InputKeyCode.LFunction:
  323. break;
  324. case InputKeyCode.LHallInside:
  325. break;
  326. case InputKeyCode.LHallForward:
  327. break;
  328. case InputKeyCode.LTrigger:
  329. break;
  330. case InputKeyCode.X:
  331. break;
  332. case InputKeyCode.Y:
  333. break;
  334. case InputKeyCode.RjoystickKey:
  335. break;
  336. case InputKeyCode.RFunction:
  337. break;
  338. case InputKeyCode.RHallInside:
  339. break;
  340. case InputKeyCode.RHallForward:
  341. break;
  342. case InputKeyCode.RTrigger:
  343. break;
  344. case InputKeyCode.UP:
  345. break;
  346. case InputKeyCode.DOWN:
  347. break;
  348. case InputKeyCode.RIGHT:
  349. break;
  350. case InputKeyCode.LEFT:
  351. break;
  352. case InputKeyCode.OTHER:
  353. break;
  354. case InputKeyCode.NULL:
  355. break;
  356. default:
  357. break;
  358. }
  359. }
  360. }
  361. /// <summary>
  362. /// 机房场景的初始化
  363. /// </summary>
  364. /// <param name="msg"> 机房信息 </param>
  365. public void MachineRoomInit( string msg)
  366. {
  367. Debug.Log("DGJ ===> MachineRoomInit ");
  368. MachineRoomManager.Instance.Init();
  369. }
  370. /// <summary>
  371. /// 获取机房列表
  372. /// </summary>
  373. public List<string> GetMachineRoomList()
  374. {
  375. return MachineRoomManager.Instance.listRoomName;
  376. }
  377. /// <summary>
  378. /// 获取机房数据
  379. /// </summary>
  380. /// <returns></returns>
  381. public MachineRoomData GetMachineRoomData( string machineRoomName)
  382. {
  383. // 根据机房名称从后台获取机房信息
  384. return MachineRoomManager.Instance.data;
  385. }
  386. /// <summary>
  387. /// 场景物体初始化
  388. /// </summary>
  389. public void MachineRoomInit()
  390. {
  391. MachineRoomManager.Instance.SceneInit();
  392. }
  393. public MachineObj QueryMachineObj(string id)
  394. {
  395. for (int i = 0; i < MachineRoomManager.Instance.listObjes.Count; i++)
  396. {
  397. if(id == MachineRoomManager.Instance.listObjes[i].deviceParameters.deviceId)
  398. {
  399. return MachineRoomManager.Instance.listObjes[i];
  400. }
  401. }
  402. return null;
  403. }
  404. /// <summary>
  405. /// 获取ShowDevice位置
  406. /// </summary>
  407. /// <param name="showDeviceTransform"></param>
  408. public void ShowDeviceTransform(Transform showDeviceTransform)
  409. {
  410. this.SendCommand(new ShowDeviceCommand(showDeviceTransform));
  411. }
  412. /// <summary>
  413. /// 获取ShowDevice位置
  414. /// </summary>
  415. public void GetDeviceTransform()
  416. {
  417. this.SendCommand(new ShowDeviceCommand(MachineRoomManager.Instance.startShowDevice));
  418. }
  419. /// <summary>
  420. /// 导航
  421. /// </summary>
  422. /// <param name="item"></param>
  423. public void NavigatorServer(MachineObj item)
  424. {
  425. WayFindingManager.Instance.NavigatorServer(item);
  426. }
  427. /// <summary>
  428. /// 导航
  429. /// </summary>
  430. /// <param name="listItem"></param>
  431. public void NavigatorServer(List<MachineObj> listItem)
  432. {
  433. WayFindingManager.Instance.NavigatorServer(listItem);
  434. }
  435. /// <summary>
  436. /// 获取告警列表
  437. /// </summary>
  438. /// <returns></returns>
  439. public List<AlarmData> GetAlarmData()
  440. {
  441. // 缺少获取设备名称---备注
  442. if(MachineRoomManager.Instance.data.listAlarmData==null)
  443. SetData();
  444. return MachineRoomManager.Instance.data.listAlarmData;
  445. }
  446. private void SetData()
  447. {
  448. MachineRoomManager.Instance.data.listAlarmData = new List<AlarmData>();
  449. for (int i = 0; i < 5;i++)
  450. {
  451. AlarmData AlarmData = new AlarmData();
  452. AlarmData.deviceId = i.ToString();
  453. AlarmData.deviceName = "设备" + i;
  454. AlarmData.title = "问题" + i;
  455. AlarmData.carryingSystem = "承载系统" + i;
  456. AlarmData.level = "重大告警";
  457. AlarmData.equipmentAlarmTime = System.DateTime.Now.ToString();
  458. MachineRoomManager.Instance.data.listAlarmData.Add(AlarmData);
  459. }
  460. }
  461. }