PLC 交互
This commit is contained in:
39
DOAN.ServiceCore/Filters/DoanPlcActionFilter.cs
Normal file
39
DOAN.ServiceCore/Filters/DoanPlcActionFilter.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using DOAN.Infrastructure.PLC;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using System;
|
||||
|
||||
namespace DOAN.ServiceCore.Middleware
|
||||
{
|
||||
public class DoanPlcActionFilter : ActionFilterAttribute
|
||||
{
|
||||
///// <summary>
|
||||
///// PLC地址
|
||||
///// </summary>
|
||||
//private readonly string addr;
|
||||
|
||||
//private readonly bool value;
|
||||
|
||||
//public DoanPlcActionFilter(string addr,string value)
|
||||
//{
|
||||
// addr = addr;
|
||||
// value = value;
|
||||
//}
|
||||
public override void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
//建立plC 连接
|
||||
PLCTool.ConnectPLC();
|
||||
|
||||
|
||||
base.OnActionExecuting(context);
|
||||
}
|
||||
|
||||
public override void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
// 关闭pLc连接
|
||||
PLCTool.ConnectClose();
|
||||
|
||||
base.OnActionExecuted(context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user