| | |
| | | |
| | | namespace LB_SmartVision.ProcessRun |
| | | { |
| | | public delegate void ProcessRunBllRun(); |
| | | |
| | | public class ProcessRunBll |
| | | { |
| | | |
| | |
| | | |
| | | public static string Node2ToolClassName(string NodeName) |
| | | { |
| | | |
| | | foreach (var item in IProcess.dicProcesses) |
| | | { |
| | | if (NodeName.StartsWith(item.Key)) |
| | | { |
| | | return item.Value.ToString(); |
| | | } |
| | | } |
| | | |
| | | return string.Empty; |
| | |
| | | /// <summary> |
| | | /// 运行标记 |
| | | /// </summary> |
| | | public bool bPruning |
| | | public bool bRuning |
| | | { |
| | | set |
| | | { |
| | |
| | | process.Load(ProcessPath); |
| | | process.strProcessName = ProcessName; |
| | | |
| | | //if (process is VisionProTool && Tool.ContainsChinese(ProcessName)) |
| | | // MessageBox.Show($"VisionPro工具不支持命名为中文:{ProcessName}", "异常"); |
| | | |
| | | if (process is ScriptTool script) |
| | | { |
| | | if (script.Params.Outputs.Count <= 0) |
| | |
| | | { |
| | | dicInputsMapping.TryAdd(name, new List<Tuple<string, string>>()); |
| | | dicInputsMapping[name].Add(new Tuple<string, string>(name + ".Inputs.Image", "")); |
| | | //dicInputsMapping[name].Add(new Tuple<string, string>(name + ".Inputs.Fixture", "")); |
| | | |
| | | foreach (var item in process.Params.Inputs) |
| | | dicInputsMapping[name].Add(new Tuple<string, string>(name + ".Inputs." + item.Name, "")); |
| | |
| | | dicOutputsMapping[name].Add(name + ".Outputs.Image"); |
| | | dicOutputsMapping[name].Add(name + ".Outputs.Record"); |
| | | dicOutputsMapping[name].Add(name + ".Outputs.Result"); |
| | | //dicOutputsMapping[name].Add(name + ".Outputs.Fixture"); |
| | | |
| | | foreach (var item in process.Params.Outputs) |
| | | dicOutputsMapping[name].Add(name + ".Outputs." + item.Name); |
| | |
| | | /// <returns></returns> |
| | | public bool Run() |
| | | { |
| | | bPruning = true; |
| | | bRuning = true; |
| | | bCompleted = false; |
| | | |
| | | DateTime StartTime = DateTime.Now; |
| | | try |
| | | { |
| | |
| | | Result = false; |
| | | Msg = string.Format("运行发送了意外{0}", ex.Message.Trim()); |
| | | } |
| | | |
| | | RunTime = (DateTime.Now - StartTime).TotalMilliseconds; |
| | | |
| | | bPruning = false; |
| | | bRuning = false; |
| | | bCompleted = true; |
| | | |
| | | if (Result) |
| | | { |
| | | total_OK++; |
| | | Msg = "运行成功"; |
| | | } |
| | | else |
| | | { |
| | | total_NG++; |
| | | |
| | | } |
| | | if (IProcess.dicGlobalVars.ContainsKey($"{Name}.Result")) |
| | | { |
| | | IProcess.dicGlobalVars[$"{Name}.Result"] = Result; |
| | | } |
| | | else |
| | | { |
| | | IProcess.dicGlobalVars.TryAdd($"{Name}.Result", Result); |
| | | |
| | | } |
| | | if (IProcess.dicGlobalVars.ContainsKey($"{Name}.Msg")) |
| | | { |
| | | IProcess.dicGlobalVars[$"{Name}.Msg"] = Msg; |
| | | } |
| | | else |
| | | { |
| | | IProcess.dicGlobalVars.TryAdd($"{Name}.Msg", Msg); |
| | | |
| | | } |
| | | // 手动触发垃圾回收 |
| | | GC.Collect(); |
| | | return Result; |