Fix 动态编译
This commit is contained in:
parent
cd13657b36
commit
5011aa5ede
@ -156,7 +156,7 @@ namespace PLCSharp.VVMs.Connects
|
||||
set { SetProperty(ref _Online, value); }
|
||||
}
|
||||
|
||||
private string _ReceiveInfo;
|
||||
private string _ReceiveInfo = "";
|
||||
|
||||
[NotMapped]
|
||||
/// <summary>
|
||||
|
||||
@ -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<Action<GlobalModel, FlowModel>>("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<Action<GlobalModel, FlowModel>>(typeName, "Run", target: instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog += "编译错误:无法找到 Extension 类型。\n";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user