/// <summary> /// 根据参数名称获取对应数值。 /// </summary> /// <param name="name"></param> /// <returns></returns> public HTuple getmeasurements(string name) { try { return(programCall.GetCtrlVarTuple(name)); } catch { return(""); } }
/// <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; } }