| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System.Threading;
- using System;
- using SHJX.Service.Model.Control;
- using SHJX.Service.Common.ReadXML;
- using SHJX.Service.ServerClient.Interface;
- using SHJX.Service.ServerClient.TempController;
- using SHJX.Service.Common.Logging;
- using Microsoft.Extensions.Logging;
- namespace SHJX.Service.ServerClient.RS485Control
- {
- public class TimerPort : SerialPortImp, PortControlImp
- {
- private static readonly ILogger logger = LogFactory.BuildLogger(typeof(TimerPort));
- /// <summary>
- /// 计时器
- /// </summary>
- /// <param name="log">日志</param>
- /// <param name="config">配置</param>
- public TimerPort( ReadConfigUtil config)
- : base( config) { }
- public object Read(PortArgs args)
- {
- object res = null;
- switch (args.ReadWay)
- {
- case "Judge":
- res = JudgeStorage(args.NodeId)?[7].Equals('0');
- break;
- }
- return res;
- }
- public bool Write(PortArgs args)
- {
-
- var way = args.WriteWay switch
- {
- WriteWay.Start => "L",
- WriteWay.Stop => "H",
- _ => throw new ArgumentNullException()
- };
- return zMotorStorage(args, way);
- }
- private bool zMotorStorage(PortArgs args, string op)
- {
- string res1 = "";
- while (res1 != "0009\r" && res1 != "0209\r")
- {
- var storageRes = JudgeXYZMove(4);
- if (storageRes.Equals("")) return false;
- res1 = storageRes;
- Thread.Sleep(300);
- }
- return MotorStorage(args.NodeId, 4, op);
- }
- }
- }
|