HomeAll.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections.Generic;
  2. using Aitex.Core.RT.Fsm;
  3. using Aitex.Core.RT.Routine;
  4. using Aitex.Core.RT.SCCore;
  5. using Aitex.Core.Util;
  6. namespace VirgoRT.Modules
  7. {
  8. public class HomeAll
  9. {
  10. private List<List<IModuleEntity>> _lstModules = new List<List<IModuleEntity>>();
  11. private Dictionary<IModuleEntity, int> _homeToken = new Dictionary<IModuleEntity, int>();
  12. public HomeAll()
  13. {
  14. }
  15. public Result Start(params object[] objs)
  16. {
  17. var pms = new List<IModuleEntity>();
  18. if (SC.GetValue<bool>("System.PMAIsInstalled"))
  19. pms.Add(Singleton<RouteManager>.Instance.PMA);
  20. if (SC.GetValue<bool>("System.PMBIsInstalled"))
  21. pms.Add(Singleton<RouteManager>.Instance.PMB);
  22. _lstModules.Clear();
  23. _lstModules.Add(new List<IModuleEntity>() { Singleton<RouteManager>.Instance.EFEM });
  24. _lstModules.Add(pms);
  25. return Result.RUN;
  26. }
  27. public Result Monitor(params object[] objs)
  28. {
  29. if (_homeToken.Count == 0 && _lstModules.Count == 0)
  30. return Result.DONE;
  31. if (_homeToken.Count > 0)
  32. {
  33. foreach (var moduleToken in _homeToken)
  34. {
  35. IModuleEntity module = moduleToken.Key;
  36. if (module.IsError)
  37. return Result.FAIL;
  38. if (!module.CheckAcked(moduleToken.Value) || module.IsBusy || module.IsInit)
  39. return Result.RUN;
  40. }
  41. _homeToken.Clear();
  42. if (_lstModules.Count == 0)
  43. return Result.DONE;
  44. }
  45. if (_homeToken.Count == 0)
  46. {
  47. foreach (var moduleEntity in _lstModules[0])
  48. {
  49. _homeToken[moduleEntity] = moduleEntity.Invoke("Home");
  50. }
  51. _lstModules.RemoveAt(0);
  52. }
  53. return Result.RUN;
  54. }
  55. public void Clear()
  56. {
  57. _lstModules.Clear();
  58. _homeToken.Clear();
  59. }
  60. }
  61. }