FuncDeviceCheck.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Rokid.UXR.Native;
  4. namespace Rokid.UXR.Module
  5. {
  6. /// <summary>
  7. /// 功能设备匹配工具类
  8. /// </summary>
  9. public class FuncDeviceCheck
  10. {
  11. public enum FuncEnum
  12. {
  13. HandTracking,
  14. Slam,
  15. CameraFunc
  16. }
  17. /// <summary>
  18. /// 功能检测
  19. /// </summary>
  20. /// <param name="glassDeviceModel"></param>
  21. /// <param name="funcName"></param>
  22. /// <returns></returns>
  23. public static bool Check(string glassDeviceModel, string funcName)
  24. {
  25. bool valid = false;
  26. List<DeviceFuncMatchInfo> deviceInfos = DeviceFuncMatchInfos.GetInfos();
  27. DeviceFuncMatchInfo info = deviceInfos.Where(item =>
  28. {
  29. return item.FuncName == funcName && ContainGlassDeviceModel(glassDeviceModel, item.GlassDeviceModels);
  30. }).FirstOrDefault();
  31. if (info != null)
  32. {
  33. RKLog.Info(string.Format("====FuncDeviceCheck==== {0}:功能支持,眼镜设备模型:{1}", funcName, glassDeviceModel));
  34. valid = true;
  35. }
  36. else
  37. {
  38. RKLog.Error(string.Format("====FuncDeviceCheck==== {0}:功能不支持,眼镜设备模型:{1}", funcName, glassDeviceModel));
  39. }
  40. return valid;
  41. }
  42. /// <summary>
  43. /// 是否存在模块
  44. /// </summary>
  45. /// <param name="glassDeviceModel"></param>
  46. /// <returns></returns>
  47. private static bool ContainGlassDeviceModel(string glassDeviceModel, string models)
  48. {
  49. string[] data = models.Split('|');
  50. for (int i = 0; i < data.Length; i++)
  51. {
  52. if (glassDeviceModel.Contains(data[i]))
  53. {
  54. return true;
  55. }
  56. }
  57. return false;
  58. }
  59. public static bool CheckHandTrackingFunc()
  60. {
  61. return Check(NativeInterface.NativeAPI.GetGlassName(), FuncEnum.HandTracking.ToString());
  62. }
  63. public static string GetOSVersion(string OSVersion)
  64. {
  65. int index = OSVersion.LastIndexOf('/');
  66. string osVersion = OSVersion.Substring(index + 1);
  67. osVersion = osVersion.Remove(osVersion.Length - 1);
  68. return osVersion;
  69. }
  70. public static bool CheckCameraFunc()
  71. {
  72. return Check(NativeInterface.NativeAPI.GetGlassName(), FuncEnum.CameraFunc.ToString());
  73. }
  74. public static bool CheckSlamFunc()
  75. {
  76. return Check(NativeInterface.NativeAPI.GetGlassName(), FuncEnum.Slam.ToString());
  77. }
  78. public static bool CheckFunc(FuncEnum func)
  79. {
  80. switch (func)
  81. {
  82. case FuncEnum.HandTracking:
  83. return CheckHandTrackingFunc();
  84. case FuncEnum.CameraFunc:
  85. return CheckCameraFunc();
  86. case FuncEnum.Slam:
  87. return CheckSlamFunc();
  88. default:
  89. return false;
  90. }
  91. }
  92. }
  93. }