From fbd1b0216a1eccaff3f330c98f1afd65a87dfd61 Mon Sep 17 00:00:00 2001 From: tfarcraw <123211521@163.com> Date: Wed, 15 Jul 2026 04:34:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=9A=E6=9C=AC=E5=BC=82=E5=B8=B8=E5=85=B3?= =?UTF-8?q?=E8=81=94=E5=88=B0=E7=8A=B6=E6=80=81=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PLCSharpWpf/VVMs/Workflows/Workflow.cs | 19 ++++++++++++++++--- PLCSharpWpf/VVMs/Workflows/Workflows.xaml | 9 +++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/PLCSharpWpf/VVMs/Workflows/Workflow.cs b/PLCSharpWpf/VVMs/Workflows/Workflow.cs index 03d438f..aa435b8 100644 --- a/PLCSharpWpf/VVMs/Workflows/Workflow.cs +++ b/PLCSharpWpf/VVMs/Workflows/Workflow.cs @@ -6,7 +6,6 @@ using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Diagnostics; -using System.Linq; using System.Reflection; using System.Threading; @@ -246,14 +245,18 @@ namespace PLCSharp.VVMs.Workflows { if (Assembly == null || !IsCompiled || Exception) { + IsRuning = false; return; } + try { + IsRuning = true; action?.Invoke(globalModel, Flow); } catch (Exception ex) { + IsRuning = false; DebugLog += $"运行时异常: {ex}\n"; globalModel.SendErr($"运行时异常: {ex}\n"); Exception = true; @@ -302,7 +305,7 @@ namespace PLCSharp.VVMs.Workflows Thread.Sleep((int)(CycleDelayTime * 1000)); if (AutomaticExecution) { - IsRuning = true; + Run(GlobalModel); } else @@ -311,8 +314,18 @@ namespace PLCSharp.VVMs.Workflows } sw.Stop(); CycleTime = sw.Elapsed.TotalSeconds; + if (Exception) + { + GlobalModel.ModeState.Sc.Stop = true; + if (GlobalModel.ModeState.State.Stopped) + { + Exception = false; + + } + + } } - + } GlobalModel GlobalModel; private FlowModel _Flow = new(); diff --git a/PLCSharpWpf/VVMs/Workflows/Workflows.xaml b/PLCSharpWpf/VVMs/Workflows/Workflows.xaml index 881c69d..b010a4b 100644 --- a/PLCSharpWpf/VVMs/Workflows/Workflows.xaml +++ b/PLCSharpWpf/VVMs/Workflows/Workflows.xaml @@ -80,6 +80,15 @@ + + + + + + + + +