WaterPort.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  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 SHJX.Service.Common.Logging;
  8. using Microsoft.Extensions.Logging;
  9. namespace SHJX.Service.ServerClient.LiquidPump
  10. {
  11. /// <summary>
  12. /// 水
  13. /// </summary>
  14. public class WaterPort : SerialPortImp, PortControlImp
  15. {
  16. private static readonly ILogger logger = LogFactory.BuildLogger(typeof(WaterPort));
  17. /// <summary>
  18. /// 水
  19. /// </summary>
  20. /// <param name="log">日志</param>
  21. /// <param name="config">配置</param>
  22. public WaterPort( ReadConfigUtil config) : base( config) { }
  23. public object Read(PortArgs args)
  24. {
  25. throw new NotImplementedException();
  26. }
  27. public bool Write(PortArgs args)
  28. {
  29. int local = args.Reserve.ToString() switch
  30. {
  31. "R1" or "R2" or "R3" or "R4" or "R5" or "R6" or "R7" or "R8" or "R9" or "R10" or "R11" or "R12" => 1,
  32. "R13" or "R14" or "R15" or "R16" or "R17" or "R18" or "R19" or "R20" or "R21" or "R22" or "R23" or "R24" => 2,
  33. _ => throw new ArgumentNullException(args.Reserve.ToString())
  34. };
  35. var way = args.WriteWay switch
  36. {
  37. WriteWay.Start => "L",
  38. WriteWay.Stop => "H",
  39. _ => throw new ArgumentNullException(args.WriteWay.GetEnumDesc<WriteWay>())
  40. };
  41. return MotorStorage(args.NodeId, local, way);
  42. }
  43. }
  44. }