UICallManager.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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. this.GetService<IRTCService>().CreatRoom();
  71. }
  72. public void OntimeOut()
  73. {
  74. // 退出房间
  75. RTCRoomManager.Instance.LeaveChannel();
  76. // 改文字UI
  77. // AllotPanel.Instance.SetAllotText("");
  78. }
  79. public void OnnoExpert()
  80. {
  81. // 退出房间
  82. switch (RTCRoomManager.Instance.rtcState)
  83. {
  84. case RTCEnum.OFF:
  85. case RTCEnum.Online:
  86. RTCRoomManager.Instance.LeaveChannel();
  87. break;
  88. case RTCEnum.ExpertOnline:
  89. break;
  90. case RTCEnum.ConterlOnline:
  91. break;
  92. case RTCEnum.ALLOnline:
  93. break;
  94. default:
  95. break;
  96. }
  97. // RTCRoomManager.Instance.LeaveChannel();
  98. // 改文字UI
  99. // AllotPanel.Instance.SetAllotText("");
  100. }
  101. /// <summary>
  102. /// 设置MQTT房间ID
  103. /// </summary>
  104. public void SetMQTTRoomId(string roomId)
  105. {
  106. MQTTManager.Instance.SetRoomId(roomId);
  107. }
  108. private void AnyUp(InputKeyCode keyCode, InputDevicePartBase part)
  109. {
  110. // Debug.Log("DGJ ====> AnyUp " + keyCode.ToString());
  111. // UILogManager.Instance.SendLogText(3, part.PartType.ToString());
  112. if (part.PartType == InputDevicePartType.KSRight )
  113. {
  114. switch (keyCode)
  115. {
  116. case InputKeyCode.Enter:
  117. break;
  118. case InputKeyCode.Cancel:
  119. break;
  120. case InputKeyCode.Trigger:
  121. break;
  122. case InputKeyCode.Function:
  123. break;
  124. case InputKeyCode.Back:
  125. break;
  126. case InputKeyCode.Tp:
  127. break;
  128. case InputKeyCode.VolumeDown:
  129. break;
  130. case InputKeyCode.VolumeUp:
  131. break;
  132. case InputKeyCode.A:
  133. break;
  134. case InputKeyCode.B:
  135. break;
  136. case InputKeyCode.LjoystickKey:
  137. break;
  138. case InputKeyCode.LFunction:
  139. break;
  140. case InputKeyCode.LHallInside:
  141. break;
  142. case InputKeyCode.LHallForward:
  143. break;
  144. case InputKeyCode.LTrigger:
  145. break;
  146. case InputKeyCode.X:
  147. break;
  148. case InputKeyCode.Y:
  149. break;
  150. case InputKeyCode.RjoystickKey:
  151. break;
  152. case InputKeyCode.RFunction: // 返回主界面
  153. Debug.Log("DGJ ====> RFunction 按了 ");
  154. // ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  155. break;
  156. case InputKeyCode.RHallInside:
  157. break;
  158. case InputKeyCode.RHallForward:
  159. break;
  160. case InputKeyCode.RTrigger:
  161. break;
  162. case InputKeyCode.UP:
  163. break;
  164. case InputKeyCode.DOWN:
  165. break;
  166. case InputKeyCode.RIGHT:
  167. break;
  168. case InputKeyCode.LEFT:
  169. break;
  170. case InputKeyCode.OTHER:
  171. break;
  172. case InputKeyCode.NULL:
  173. break;
  174. default:
  175. break;
  176. }
  177. }
  178. if (part.PartType == InputDevicePartType.KSLeft)
  179. {
  180. switch (keyCode)
  181. {
  182. case InputKeyCode.Enter:
  183. break;
  184. case InputKeyCode.Cancel:
  185. break;
  186. case InputKeyCode.Trigger:
  187. break;
  188. case InputKeyCode.Function:
  189. break;
  190. case InputKeyCode.Back:
  191. break;
  192. case InputKeyCode.Tp:
  193. break;
  194. case InputKeyCode.VolumeDown:
  195. break;
  196. case InputKeyCode.VolumeUp:
  197. break;
  198. case InputKeyCode.A:
  199. break;
  200. case InputKeyCode.B:
  201. break;
  202. case InputKeyCode.LjoystickKey:
  203. break;
  204. case InputKeyCode.LFunction:
  205. break;
  206. case InputKeyCode.LHallInside:
  207. break;
  208. case InputKeyCode.LHallForward:
  209. break;
  210. case InputKeyCode.LTrigger:
  211. break;
  212. case InputKeyCode.X:
  213. break;
  214. case InputKeyCode.Y:
  215. break;
  216. case InputKeyCode.RjoystickKey:
  217. break;
  218. case InputKeyCode.RFunction:
  219. break;
  220. case InputKeyCode.RHallInside:
  221. break;
  222. case InputKeyCode.RHallForward:
  223. break;
  224. case InputKeyCode.RTrigger:
  225. break;
  226. case InputKeyCode.UP:
  227. break;
  228. case InputKeyCode.DOWN:
  229. break;
  230. case InputKeyCode.RIGHT:
  231. break;
  232. case InputKeyCode.LEFT:
  233. break;
  234. case InputKeyCode.OTHER:
  235. break;
  236. case InputKeyCode.NULL:
  237. break;
  238. default:
  239. break;
  240. }
  241. }
  242. }
  243. private void AnyDown(InputKeyCode keyCode, InputDevicePartBase part)
  244. {
  245. // Debug.Log("DGJ ====> AnyDown " + keyCode.ToString());
  246. // UILogManager.Instance.SendLogText(3, part.PartType.ToString());
  247. if (part.PartType == InputDevicePartType.KSRight)
  248. {
  249. switch (keyCode)
  250. {
  251. case InputKeyCode.Enter:
  252. break;
  253. case InputKeyCode.Cancel:
  254. break;
  255. case InputKeyCode.Trigger:
  256. break;
  257. case InputKeyCode.Function:
  258. break;
  259. case InputKeyCode.Back:
  260. break;
  261. case InputKeyCode.Tp:
  262. break;
  263. case InputKeyCode.VolumeDown:
  264. break;
  265. case InputKeyCode.VolumeUp:
  266. break;
  267. case InputKeyCode.A:
  268. break;
  269. case InputKeyCode.B:
  270. break;
  271. case InputKeyCode.LjoystickKey:
  272. break;
  273. case InputKeyCode.LFunction:
  274. break;
  275. case InputKeyCode.LHallInside:
  276. break;
  277. case InputKeyCode.LHallForward:
  278. break;
  279. case InputKeyCode.LTrigger:
  280. break;
  281. case InputKeyCode.X:
  282. break;
  283. case InputKeyCode.Y:
  284. break;
  285. case InputKeyCode.RjoystickKey:
  286. break;
  287. case InputKeyCode.RFunction:
  288. Debug.Log("DGJ ====> RFunction 按了 ");
  289. break;
  290. case InputKeyCode.RHallInside:
  291. break;
  292. case InputKeyCode.RHallForward:
  293. break;
  294. case InputKeyCode.RTrigger:
  295. break;
  296. case InputKeyCode.UP:
  297. break;
  298. case InputKeyCode.DOWN:
  299. break;
  300. case InputKeyCode.RIGHT:
  301. break;
  302. case InputKeyCode.LEFT:
  303. break;
  304. case InputKeyCode.OTHER:
  305. break;
  306. case InputKeyCode.NULL:
  307. break;
  308. default:
  309. break;
  310. }
  311. }
  312. if (part.PartType == InputDevicePartType.KSLeft)
  313. {
  314. switch (keyCode)
  315. {
  316. case InputKeyCode.Enter:
  317. break;
  318. case InputKeyCode.Cancel:
  319. break;
  320. case InputKeyCode.Trigger:
  321. break;
  322. case InputKeyCode.Function:
  323. break;
  324. case InputKeyCode.Back:
  325. break;
  326. case InputKeyCode.Tp:
  327. break;
  328. case InputKeyCode.VolumeDown:
  329. break;
  330. case InputKeyCode.VolumeUp:
  331. break;
  332. case InputKeyCode.A:
  333. break;
  334. case InputKeyCode.B:
  335. break;
  336. case InputKeyCode.LjoystickKey:
  337. break;
  338. case InputKeyCode.LFunction:
  339. break;
  340. case InputKeyCode.LHallInside:
  341. break;
  342. case InputKeyCode.LHallForward:
  343. break;
  344. case InputKeyCode.LTrigger:
  345. break;
  346. case InputKeyCode.X:
  347. break;
  348. case InputKeyCode.Y:
  349. break;
  350. case InputKeyCode.RjoystickKey:
  351. break;
  352. case InputKeyCode.RFunction:
  353. break;
  354. case InputKeyCode.RHallInside:
  355. break;
  356. case InputKeyCode.RHallForward:
  357. break;
  358. case InputKeyCode.RTrigger:
  359. break;
  360. case InputKeyCode.UP:
  361. break;
  362. case InputKeyCode.DOWN:
  363. break;
  364. case InputKeyCode.RIGHT:
  365. break;
  366. case InputKeyCode.LEFT:
  367. break;
  368. case InputKeyCode.OTHER:
  369. break;
  370. case InputKeyCode.NULL:
  371. break;
  372. default:
  373. break;
  374. }
  375. }
  376. }
  377. /// <summary>
  378. /// 机房场景的初始化
  379. /// </summary>
  380. /// <param name="msg"> 机房信息 </param>
  381. public void MachineRoomInit( string msg)
  382. {
  383. Debug.Log("DGJ ===> MachineRoomInit ");
  384. MachineRoomManager.Instance.Init();
  385. }
  386. /// <summary>
  387. /// 获取机房列表
  388. /// </summary>
  389. public List<string> GetMachineRoomList()
  390. {
  391. return MachineRoomManager.Instance.listRoomName;
  392. }
  393. /// <summary>
  394. /// 获取机房数据
  395. /// </summary>
  396. /// <returns></returns>
  397. public MachineRoomData GetMachineRoomData( string machineRoomName)
  398. {
  399. // 根据机房名称从后台获取机房信息
  400. return MachineRoomManager.Instance.data;
  401. }
  402. /// <summary>
  403. /// 场景物体初始化
  404. /// </summary>
  405. public void MachineRoomInit()
  406. {
  407. MachineRoomManager.Instance.SceneInit();
  408. }
  409. public MachineObj QueryMachineObj(string id)
  410. {
  411. for (int i = 0; i < MachineRoomManager.Instance.listObjes.Count; i++)
  412. {
  413. if(id == MachineRoomManager.Instance.listObjes[i].deviceParameters.deviceId)
  414. {
  415. return MachineRoomManager.Instance.listObjes[i];
  416. }
  417. }
  418. return null;
  419. }
  420. /// <summary>
  421. /// 获取ShowDevice位置
  422. /// </summary>
  423. /// <param name="showDeviceTransform"></param>
  424. public void ShowDeviceTransform(Transform showDeviceTransform)
  425. {
  426. this.SendCommand(new ShowDeviceCommand(showDeviceTransform));
  427. }
  428. /// <summary>
  429. /// 获取ShowDevice位置
  430. /// </summary>
  431. public void GetDeviceTransform()
  432. {
  433. this.SendCommand(new ShowDeviceCommand(MachineRoomManager.Instance.startShowDevice));
  434. }
  435. /// <summary>
  436. /// 导航
  437. /// </summary>
  438. /// <param name="item"></param>
  439. public void NavigatorServer(MachineObj item)
  440. {
  441. WayFindingManager.Instance.NavigatorServer(item);
  442. }
  443. /// <summary>
  444. /// 导航
  445. /// </summary>
  446. /// <param name="listItem"></param>
  447. public void NavigatorServer(List<MachineObj> listItem)
  448. {
  449. WayFindingManager.Instance.NavigatorServer(listItem);
  450. }
  451. /// <summary>
  452. /// 获取告警列表
  453. /// </summary>
  454. /// <returns></returns>
  455. public List<AlarmData> GetAlarmData()
  456. {
  457. // 缺少获取设备名称---备注
  458. if(MachineRoomManager.Instance.data.listAlarmData==null)
  459. SetData();
  460. return MachineRoomManager.Instance.data.listAlarmData;
  461. }
  462. private void SetData()
  463. {
  464. MachineRoomManager.Instance.data.listAlarmData = new List<AlarmData>();
  465. for (int i = 0; i < 5;i++)
  466. {
  467. AlarmData AlarmData = new AlarmData();
  468. AlarmData.deviceId = i.ToString();
  469. AlarmData.deviceName = "设备" + i;
  470. AlarmData.title = "问题" + i;
  471. AlarmData.carryingSystem = "承载系统" + i;
  472. AlarmData.level = "重大告警";
  473. AlarmData.equipmentAlarmTime = System.DateTime.Now.ToString();
  474. MachineRoomManager.Instance.data.listAlarmData.Add(AlarmData);
  475. }
  476. }
  477. }