HomeAll.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 Virgo_DRT.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.Add(pms);
  23. _lstModules.Add(new List<IModuleEntity>() { Singleton<RouteManager>.Instance.EFEM });
  24. return Result.RUN;
  25. }
  26. public Result Monitor(params object[] objs)
  27. {
  28. if (_homeToken.Count == 0 && _lstModules.Count == 0)
  29. return Result.DONE;
  30. if (_homeToken.Count > 0)
  31. {
  32. foreach (var moduleToken in _homeToken)
  33. {
  34. IModuleEntity module = moduleToken.Key;
  35. if (module.IsError)
  36. return Result.FAIL;
  37. if (!module.CheckAcked(moduleToken.Value) || module.IsBusy || module.IsInit)
  38. return Result.RUN;
  39. }
  40. _homeToken.Clear();
  41. if (_lstModules.Count == 0)
  42. return Result.DONE;
  43. }
  44. if (_homeToken.Count == 0)
  45. {
  46. foreach (var moduleEntity in _lstModules[0])
  47. {
  48. _homeToken[moduleEntity] = moduleEntity.Invoke("Home");
  49. }
  50. _lstModules.RemoveAt(0);
  51. }
  52. return Result.RUN;
  53. }
  54. public void Clear()
  55. {
  56. _lstModules.Clear();
  57. _homeToken.Clear();
  58. }
  59. }
  60. }