SilverSulfatePipePort.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. 
  2. using SHJX.Service.Common.Extend;
  3. using SHJX.Service.Common.ReadXML;
  4. using SHJX.Service.Model.Control;
  5. using SHJX.Service.ServerClient.Interface;
  6. using SHJX.Service.ServerClient.TempController;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Threading.Tasks;
  13. using SHJX.Service.Common.Logging;
  14. using Microsoft.Extensions.Logging;
  15. namespace SHJX.Service.ServerClient.PortControl
  16. {
  17. public class SilverSulfatePipePort : SerialPortImp, PortControlImp
  18. {
  19. private static readonly ILogger logger = LogFactory.BuildLogger(typeof(SilverSulfatePipePort));
  20. /// <summary>
  21. /// 硫酸银管道
  22. /// </summary>
  23. /// <param name="log">日志</param>
  24. /// <param name="config">配置</param>
  25. public SilverSulfatePipePort( ReadConfigUtil config)
  26. : base( config) { }
  27. public object Read(PortArgs args)
  28. {
  29. throw new NotImplementedException();
  30. }
  31. public bool Write(PortArgs args)
  32. {
  33. var res = args.WriteWay switch
  34. {
  35. WriteWay.Start => tMotorStorage(args, "L"),
  36. WriteWay.Stop => tMotorStorage(args, "H"),
  37. _ => throw new ArgumentNullException(args.WriteWay.GetEnumDesc<WriteWay>())
  38. };
  39. Thread.Sleep(500);
  40. return res;
  41. }
  42. private bool tMotorStorage(PortArgs args, string op)
  43. {
  44. string res1 = "";
  45. while (res1 != "0009\r" && res1 != "0209\r")
  46. {
  47. var storageRes = JudgeXYZMove(4); //加液前T轴要静止
  48. if (storageRes.Equals("")) return false;
  49. res1 = storageRes;
  50. Thread.Sleep(300);
  51. }
  52. return MotorStorage(args.NodeId, Convert.ToInt32(args.Reserve), op);
  53. }
  54. }
  55. }