mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-22 17:16:34 +08:00
IOC容器添加构造函数注入(DLL类中使用AutoRegisterAttribute特性标注的类,会在流程启动时自动注册),提高可读性。
This commit is contained in:
@@ -21,23 +21,18 @@ namespace Net461DllTest.LogicControl
|
||||
GetPparkingSpace,
|
||||
}
|
||||
|
||||
|
||||
[AutoRegister]
|
||||
[DynamicFlow]
|
||||
public class ParkingLogicControl
|
||||
{
|
||||
[AutoInjection]
|
||||
public PrakingDevice PrakingDevice { get; set; }
|
||||
private readonly PrakingDevice PrakingDevice;
|
||||
|
||||
|
||||
[NodeAction(NodeType.Init)]
|
||||
public void Init(IDynamicContext context)
|
||||
public ParkingLogicControl(PrakingDevice PrakingDevice)
|
||||
{
|
||||
|
||||
context.Env.IOC.Register<PrakingDevice>();
|
||||
this.PrakingDevice = PrakingDevice;
|
||||
}
|
||||
|
||||
|
||||
|
||||
[NodeAction(NodeType.Flipflop, "等待车位调取命令",ReturnType=typeof(string))]
|
||||
public async Task<IFlipflopContext> GetPparkingSpace(ParkingCommand parkingCommand = ParkingCommand.GetPparkingSpace)
|
||||
{
|
||||
|
||||
@@ -19,21 +19,21 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Net461DllTest.LogicControl
|
||||
{
|
||||
[AutoRegister]
|
||||
[DynamicFlow]
|
||||
public class PlcLogicControl
|
||||
{
|
||||
[AutoInjection]
|
||||
public SiemensPlcDevice MyPlc { get; set; }
|
||||
|
||||
|
||||
private readonly SiemensPlcDevice MyPlc;
|
||||
|
||||
public PlcLogicControl(SiemensPlcDevice MyPlc)
|
||||
{
|
||||
this.MyPlc = MyPlc;
|
||||
}
|
||||
|
||||
#region 初始化、初始化完成以及退出的事件
|
||||
[NodeAction(NodeType.Init)] // Init : 初始化事件,流程启动时执行
|
||||
public void Init(IDynamicContext context)
|
||||
{
|
||||
context.Env.IOC.Register<SiemensPlcDevice>(); // 注册Plc设备
|
||||
context.Env.IOC.Register<WebServer>(); // 注册Web服务
|
||||
// // 注册控制器
|
||||
context.Env.IOC.Run<IRouter>(router => {
|
||||
router.RegisterController(typeof(ApiController));
|
||||
@@ -146,14 +146,14 @@ namespace Net461DllTest.LogicControl
|
||||
|
||||
if (MyPlc.State == PlcState.Runing)
|
||||
{
|
||||
if (!varInfo.IsProtected)
|
||||
if (varInfo.IsProtected)
|
||||
{
|
||||
MyPlc.Write(varInfo, value);
|
||||
Console.WriteLine($"PLC变量{varInfo}写入数据:{value}");
|
||||
Console.WriteLine($"PLC变量{varInfo}当前禁止写入");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"PLC变量{varInfo}当前禁止写入");
|
||||
MyPlc.Write(varInfo, value);
|
||||
Console.WriteLine($"PLC变量{varInfo}写入数据:{value}");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Net461DllTest.Signal;
|
||||
using Net461DllTest.Device;
|
||||
using Net461DllTest.Signal;
|
||||
using Net461DllTest.ViewModel;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.Attributes;
|
||||
@@ -11,7 +12,7 @@ using System.Windows.Forms;
|
||||
|
||||
namespace Net461DllTest.LogicControl
|
||||
{
|
||||
|
||||
[AutoRegister]
|
||||
public class ViewManagement
|
||||
{
|
||||
|
||||
@@ -46,8 +47,11 @@ namespace Net461DllTest.LogicControl
|
||||
[DynamicFlow]
|
||||
public class ViewLogicControl
|
||||
{
|
||||
[AutoInjection]
|
||||
public ViewManagement ViewManagement { get; set; }
|
||||
private readonly ViewManagement ViewManagement;
|
||||
public ViewLogicControl(ViewManagement ViewManagement)
|
||||
{
|
||||
this.ViewManagement = ViewManagement;
|
||||
}
|
||||
|
||||
[NodeAction(NodeType.Init)]
|
||||
public void Init(IDynamicContext context)
|
||||
|
||||
Reference in New Issue
Block a user