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.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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}, true, () => { }
|
|
|
|
, 5, InvokeStatus.Exception);
|
|
|
|
|
|
|
|
if (InvokeStatus.Exception == invokeStatus)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|