PLC 交互

This commit is contained in:
qianhao.xu
2024-11-08 08:42:33 +08:00
parent 74c849149e
commit 47855d3f54
7 changed files with 104 additions and 48 deletions

View 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);
}
}
}