WorkFlowService.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using SHJX.Service.Control.Repository;
  2. namespace SHJX.Service.Control.Service
  3. {
  4. public class WorkFlowService : IWorkFlowService
  5. {
  6. private readonly Repositorys _repositorys;
  7. public WorkFlowService(Repositorys repositorys) : base()
  8. {
  9. _repositorys = repositorys;
  10. Messager<WorkFlowEventArgs>.Register("CustomMove", ExecuteCustomMove);
  11. }
  12. #region MessageMethod
  13. private void ExecuteCustomMove(WorkFlowEventArgs arg)
  14. {
  15. List<string> steps = new();
  16. foreach (CustomMoveStep item in arg.MoveSteps)
  17. {
  18. if (item.CurrentStep.BeIn("开始", "结束"))
  19. {
  20. continue;
  21. }
  22. string step = Convert(item.CurrentStep);
  23. steps.Add(step);
  24. }
  25. EquipmentTask task = new()
  26. {
  27. From = arg.Position,
  28. To = arg.Position,
  29. Target = "From"
  30. };
  31. _repositorys.ExecuteTaskByVirtualPipe(task, steps);
  32. }
  33. #endregion
  34. private string Convert(string name)
  35. {
  36. string convertStr = name switch
  37. {
  38. "X轴" => NodeName.AXIS_MOVEMENT_BY_X,
  39. "Y轴" => NodeName.AXIS_MOVEMENT_BY_Y,
  40. "Z轴" => NodeName.AXIS_MOVEMENT_BY_Z,
  41. "Z轴原点" => NodeName.AXIS_GOBACK_BY_Z,
  42. "杯抓" => NodeName.TONGS_GRAB,
  43. "杯松" => NodeName.TONGS_LOOSEN,
  44. _ => throw new ArgumentNullException(name),
  45. };
  46. return convertStr;
  47. }
  48. }
  49. }