using Entity.Constant; using HybirdFrameworkCore.Autofac.Attribute; using log4net; using Service.Execute; using Service.Execute.StaticTools; using Service.Plc.Client; namespace Service.Mgr; [Scope("SingleInstance")] public class PlcTaskMgr { private static readonly ILog Log = LogManager.GetLogger(typeof(PlcTaskMgr)); public bool QueryPlcTask(int taskNo, int ingStatus, int exceptionStatus) { Log.Info($"PlcTaskMgr.QueryPlcTask taskNo={taskNo}"); bool isSuccess = false; InvokeStatus invokeStatus = Invoker.Invoke("QueryPlcTask", 1000, 5, () => isSuccess, () => { var readPlcTaskStatus = PlcMgr.ReadPlcTaskStatus(); if (ingStatus == readPlcTaskStatus) { } else if (exceptionStatus == readPlcTaskStatus) { Log.Info( $"PlcTaskMgr.QueryPlcTask taskNo={taskNo} execute fail readPlcTaskStatus={readPlcTaskStatus}"); throw new Exception("PlcTaskMgr.QueryPlcTask readPlcTaskStatus=" + readPlcTaskStatus); } else if (9000 == readPlcTaskStatus) { isSuccess = true; } }, () => { Log.Info($"PlcTaskMgr.QueryPlcTask taskNo={taskNo} execute ing"); if (taskNo == 2) { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoBatteryMove); }else if (taskNo == 5) { SoundTool.PlayOneSound((int)InfoEnum.SwapInfo.InfoFireRemove); } }, true, () => { } , 5, InvokeStatus.Exception); if (InvokeStatus.Exception == invokeStatus) { return false; } return true; } }