public void Excute() { if (programCall.IsInitialized()) { programCall.Execute(); } }
public void inspectengine() { try { programCall.Execute(); } catch { } }
public void Excute() { if (programCall.IsInitialized()) { Task task = new Task(() => { programCall.Execute(); }); task.Start(); } }
public void Excute() { if (task.Status == TaskStatus.Created || task.IsCompleted || task.IsFaulted || task.IsCanceled) { task = new Task(() => { engine = new HDevEngine(); program = new HDevProgram(Path); programCall = new HDevProgramCall(program); if (impl == null) { impl = new HDevOpMultiWindowImpl(hSmartWindowControlcamera.HalconWindow); } engine.SetHDevOperators(impl); programCall.Execute(); }, TaskCreationOptions.LongRunning); task.Start(); } }
/// <summary> /// 执行 /// </summary> /// <param name="timeout">处理超时时间,若小于等于0,则无限等待.单位:毫秒</param> /// <param name="outputs">输出结果</param> public void Execute(int timeout, out ItemCollection outputs) { try { stopwatch.Restart(); if (runningWindow == null) { try { runningWindow = (RunningWindow as HSmartWindowControlWPF).HalconWindow; hDevEngine.SetHDevOperators(new HDevOpMultiWindowImpl(runningWindow)); } catch (Exception) { } } //执行程序 hDevProgramCall.Execute(); //拼接输出结果 Outputs.Clear(); foreach (var item in valueName) { HTuple valueTuple = hDevProgramCall.GetCtrlVarTuple(item); switch (valueTuple.Type) { case HTupleType.EMPTY: break; case HTupleType.INTEGER: Outputs.Add(new ItemBase(item, valueTuple.IArr, item)); break; case HTupleType.LONG: Outputs.Add(new ItemBase(item, valueTuple.LArr, item)); break; case HTupleType.DOUBLE: Outputs.Add(new ItemBase(item, valueTuple.DArr, item)); break; case HTupleType.STRING: Outputs.Add(new ItemBase(item, valueTuple.SArr, item)); break; case HTupleType.MIXED: break; default: break; } } stopwatch.Stop(); RunStatus = new RunStatus(stopwatch.Elapsed.TotalMilliseconds); outputs = new ItemCollection(Outputs); UpdatePart(runningWindow); } catch (Exception ex) { RunStatus = new RunStatus(0, EResult.Error, ex.Message, ex); throw; } }