using SHJX.Service.Common.Extend;
using SHJX.Service.Common.ReadXML;
using SHJX.Service.Model.Control;
using SHJX.Service.ServerClient.Interface;
using SHJX.Service.ServerClient.TempController;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using SHJX.Service.Common.Logging;
using Microsoft.Extensions.Logging;
namespace SHJX.Service.ServerClient.PortControl
{
public class SilverSulfatePipePort : SerialPortImp, PortControlImp
{
private static readonly ILogger logger = LogFactory.BuildLogger(typeof(SilverSulfatePipePort));
///
/// 硫酸银管道
///
/// 日志
/// 配置
public SilverSulfatePipePort( ReadConfigUtil config)
: base( config) { }
public object Read(PortArgs args)
{
throw new NotImplementedException();
}
public bool Write(PortArgs args)
{
var res = args.WriteWay switch
{
WriteWay.Start => tMotorStorage(args, "L"),
WriteWay.Stop => tMotorStorage(args, "H"),
_ => throw new ArgumentNullException(args.WriteWay.GetEnumDesc())
};
Thread.Sleep(500);
return res;
}
private bool tMotorStorage(PortArgs args, string op)
{
string res1 = "";
while (res1 != "0009\r" && res1 != "0209\r")
{
var storageRes = JudgeXYZMove(4); //加液前T轴要静止
if (storageRes.Equals("")) return false;
res1 = storageRes;
Thread.Sleep(300);
}
return MotorStorage(args.NodeId, Convert.ToInt32(args.Reserve), op);
}
}
}