UICallManager.cs 14 KB

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