You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using Entity.Constant;
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
using log4net;
|
|
|
|
using Service.Execute;
|
|
|
|
using Service.Execute.Api;
|
|
|
|
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();
|
|
|
|
Log.Info($"PlcTaskMgr.QueryPlcTask taskNo={taskNo} execute resp readPlcTaskStatus={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 || 1001== readPlcTaskStatus )
|
|
|
|
{
|
|
|
|
Log.Info($"PlcTaskMgr.QueryPlcTask taskNo={taskNo} execute success readPlcTaskStatus={readPlcTaskStatus}");
|
|
|
|
isSuccess = true;
|
|
|
|
}
|
|
|
|
}, () =>
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"PlcTaskMgr.QueryPlcTask taskNo={taskNo} execute ing");
|
|
|
|
if (taskNo == 2)
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoBatteryMove);
|
|
|
|
}else if (taskNo == 5)
|
|
|
|
{
|
|
|
|
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoFireRemove);
|
|
|
|
}
|
|
|
|
}, true, () => { }
|
|
|
|
, 5, InvokeStatus.Exception);
|
|
|
|
|
|
|
|
if (InvokeStatus.Exception == invokeStatus)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|