b49b68059eefc5ea650c586eb0d0afb3abad104a55769e1940e10f42fb7e4c9a.source 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using TeamAAS.Robot;
  2. using TeamAAS.FlowEditor.Models;
  3. using TeamAAS.FlowEditor.Execution;
  4. using TeamAAS.Communication;
  5. using TeamAAS.Camera;
  6. using TeamAAS.Feeder;
  7. namespace TeamAAS.Core
  8. {
  9. /// <summary>
  10. /// 统一管理各子项目核心服务实例(现为 SDK ServiceRegistry 的门面:get/set 委托到注册表,单一真相源)。
  11. /// 静态工具类直接调用:DialogHelper、PluginLoader、CameraFactory、RobotFactory、ResultRegistry
  12. /// </summary>
  13. public static class CoreManager
  14. {
  15. /// <summary>
  16. /// 获取所有设备的连接状态(名称, 类别, 是否连接)
  17. /// </summary>
  18. public static System.Collections.Generic.List<(string Name, string Category, bool IsConnected)> GetAllDeviceStatuses()
  19. {
  20. var list = new System.Collections.Generic.List<(string, string, bool)>();
  21. foreach (var cam in Camera.Devices)
  22. list.Add((cam.Name ?? "相机", "相机", cam.IsConnected));
  23. foreach (var robot in Robot.Devices)
  24. list.Add((robot.Name ?? $"机器人{robot.RobotNo}", "机器人", robot.IsConnected));
  25. foreach (var comm in Communication.Devices)
  26. list.Add((comm.Name, "通讯", comm.IsConnected));
  27. return list;
  28. }
  29. /// <summary>
  30. /// 相机服务(单例)
  31. /// </summary>
  32. public static CameraManager Camera
  33. {
  34. get => TeamAAS.Global.ServiceRegistry.Default.GetService<CameraManager>();
  35. set => TeamAAS.Global.ServiceRegistry.Default.Register(value);
  36. }
  37. /// <summary>
  38. /// 机器人服务(单例)
  39. /// </summary>
  40. public static RobotManager Robot
  41. {
  42. get => TeamAAS.Global.ServiceRegistry.Default.GetService<RobotManager>();
  43. set => TeamAAS.Global.ServiceRegistry.Default.Register(value);
  44. }
  45. public static CommunicationManager Communication
  46. {
  47. get => TeamAAS.Global.ServiceRegistry.Default.GetService<CommunicationManager>();
  48. set => TeamAAS.Global.ServiceRegistry.Default.Register(value);
  49. }
  50. /// <summary>
  51. /// 供料器服务(单例)
  52. /// </summary>
  53. public static FeederManager Feeder
  54. {
  55. get => TeamAAS.Global.ServiceRegistry.Default.GetService<FeederManager>();
  56. set => TeamAAS.Global.ServiceRegistry.Default.Register(value);
  57. }
  58. /// <summary>
  59. /// 运动控制服务(设备内核·新增;仿真/雷赛/固高/IMC60G/GR20T 统一入口)
  60. /// </summary>
  61. public static TeamAAS.Motion.MotionManager Motion
  62. {
  63. get => TeamAAS.Global.ServiceRegistry.Default.GetService<TeamAAS.Motion.MotionManager>();
  64. set => TeamAAS.Global.ServiceRegistry.Default.Register(value);
  65. }
  66. /// <summary>
  67. /// 创建流程执行器
  68. /// </summary>
  69. //public static FlowExecutor CreateFlowExecutor(FlowGraph graph) => new FlowExecutor(graph);
  70. }
  71. }