脚本异常关联到状态机
This commit is contained in:
parent
ece2e7afd5
commit
fbd1b0216a
@ -6,7 +6,6 @@ using System.ComponentModel;
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
@ -246,14 +245,18 @@ namespace PLCSharp.VVMs.Workflows
|
|||||||
{
|
{
|
||||||
if (Assembly == null || !IsCompiled || Exception)
|
if (Assembly == null || !IsCompiled || Exception)
|
||||||
{
|
{
|
||||||
|
IsRuning = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
IsRuning = true;
|
||||||
action?.Invoke(globalModel, Flow);
|
action?.Invoke(globalModel, Flow);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
IsRuning = false;
|
||||||
DebugLog += $"运行时异常: {ex}\n";
|
DebugLog += $"运行时异常: {ex}\n";
|
||||||
globalModel.SendErr($"运行时异常: {ex}\n");
|
globalModel.SendErr($"运行时异常: {ex}\n");
|
||||||
Exception = true;
|
Exception = true;
|
||||||
@ -302,7 +305,7 @@ namespace PLCSharp.VVMs.Workflows
|
|||||||
Thread.Sleep((int)(CycleDelayTime * 1000));
|
Thread.Sleep((int)(CycleDelayTime * 1000));
|
||||||
if (AutomaticExecution)
|
if (AutomaticExecution)
|
||||||
{
|
{
|
||||||
IsRuning = true;
|
|
||||||
Run(GlobalModel);
|
Run(GlobalModel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -311,6 +314,16 @@ namespace PLCSharp.VVMs.Workflows
|
|||||||
}
|
}
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
CycleTime = sw.Elapsed.TotalSeconds;
|
CycleTime = sw.Elapsed.TotalSeconds;
|
||||||
|
if (Exception)
|
||||||
|
{
|
||||||
|
GlobalModel.ModeState.Sc.Stop = true;
|
||||||
|
if (GlobalModel.ModeState.State.Stopped)
|
||||||
|
{
|
||||||
|
Exception = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,6 +80,15 @@
|
|||||||
</DataGridTemplateColumn.CellTemplate>
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
</DataGridTemplateColumn>
|
</DataGridTemplateColumn>
|
||||||
|
|
||||||
|
<DataGridTemplateColumn Header="运行中">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Viewbox>
|
||||||
|
<Ellipse Width="10" Height="10" Fill="{Binding IsRuning, Converter={StaticResource BoolToValueConverter}, Mode=TwoWay, ConverterParameter=Lime, FallbackValue=Gray}" />
|
||||||
|
</Viewbox>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
<DataGridTextColumn MinWidth="100" Binding="{Binding Prompt}" Header="提示" IsReadOnly="True" />
|
<DataGridTextColumn MinWidth="100" Binding="{Binding Prompt}" Header="提示" IsReadOnly="True" />
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user