UICallManager.cs 15 KB

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