From 5011aa5edea5d6c6e28121d92b78ab5733049975 Mon Sep 17 00:00:00 2001 From: tfarcraw <123211521@163.com> Date: Sun, 5 Jul 2026 23:53:04 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20=E5=8A=A8=E6=80=81=E7=BC=96=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PLCSharpWpf/VVMs/Connects/Connect.cs | 2 +- PLCSharpWpf/VVMs/Workflows/Workflow.cs | 13 +++++++- PLCSharpWpf/VVMs/Workflows/WorkflowsModel.cs | 32 +++++++++++--------- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/PLCSharpWpf/VVMs/Connects/Connect.cs b/PLCSharpWpf/VVMs/Connects/Connect.cs index 08254d5..bc42be2 100644 --- a/PLCSharpWpf/VVMs/Connects/Connect.cs +++ b/PLCSharpWpf/VVMs/Connects/Connect.cs @@ -156,7 +156,7 @@ namespace PLCSharp.VVMs.Connects set { SetProperty(ref _Online, value); } } - private string _ReceiveInfo; + private string _ReceiveInfo = ""; [NotMapped] /// diff --git a/PLCSharpWpf/VVMs/Workflows/Workflow.cs b/PLCSharpWpf/VVMs/Workflows/Workflow.cs index f33774d..9284e76 100644 --- a/PLCSharpWpf/VVMs/Workflows/Workflow.cs +++ b/PLCSharpWpf/VVMs/Workflows/Workflow.cs @@ -6,6 +6,7 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics; +using System.Linq; using System.Reflection; using System.Threading; @@ -214,7 +215,17 @@ namespace PLCSharp.VVMs.Workflows Prompt = ""; IsCompiled = true; Exception = false; - action = Assembly.GetDelegateFromShortName>("Extension_" + ID.ToString().Replace("-", ""), "Run"); + var typeName = "Extension_" + ID.ToString().Replace("-", ""); + var extType = Assembly.GetTypes().FirstOrDefault(t => t.Name == typeName || t.FullName == typeName); + if (extType != null) + { + var instance = Activator.CreateInstance(extType)!; + action = Assembly.GetDelegateFromShortName>(typeName, "Run", target: instance); + } + else + { + DebugLog += "编译错误:无法找到 Extension 类型。\n"; + } } catch (Exception e) { diff --git a/PLCSharpWpf/VVMs/Workflows/WorkflowsModel.cs b/PLCSharpWpf/VVMs/Workflows/WorkflowsModel.cs index 403dd8d..5a504ec 100644 --- a/PLCSharpWpf/VVMs/Workflows/WorkflowsModel.cs +++ b/PLCSharpWpf/VVMs/Workflows/WorkflowsModel.cs @@ -77,32 +77,34 @@ namespace PLCSharp.VVMs.Workflows @" using System; using System.Linq; -using System.Collections.ObjectModel; using PLCSharp.Models; -using PLCSharp.VVMs.Homepage; using PLCSharp.Core.Common; -using System.Windows.Shapes; -using System.Windows.Media; -using System.Windows; -using PLCSharp.Core.UserControls; +using PLCSharp.VVMs.Connects; +using PLCSharp.VVMs.GlobalVariables; +using PLCSharp.VVMs.Homepage; +using PLCSharp.VVMs.MotionController; using PLCSharp.VVMs.Robots; using PLCSharp.VVMs.Vision; public class Extension_" + newTask.ID.ToString().Replace("-", "") + @" { - Robot CurrRobot; //机器人 - CustomControl CurrtateControl; //显示控件 - VisionFunction CurrVF; //视觉功能 + private Robot CurrRobot; + private CustomControl CurrtateControl; + private VisionFunction CurrVF; + private Connect CurrConnect; + private AxisPoint CurrAxisPoint; + private Variable CurrVariable; + private CustomControl CurrControl; public void Run(GlobalModel globalModel,FlowModel flow) { - switch (flow.Step) - { - //插入代码 - case 0: - break; + switch (flow.Step) + { + //插入代码 + case 0: + break; - } + } } } ";