internal static int LoadTupleVector(HTupleVector outVector, IntPtr vectorHandle) { int dimension; EngineAPI.HCkE(EngineAPI.GetTupleVectorDimension(vectorHandle, out dimension)); int length; EngineAPI.HCkE(EngineAPI.GetTupleVectorLength(vectorHandle, out length)); if (dimension == 1) { for (int index = length - 1; index >= 0; --index) { IntPtr element_handle; EngineAPI.HCkE(EngineAPI.GetTupleVectorTuple(vectorHandle, index, out element_handle)); outVector[index].T = HalconAPI.LoadTuple(element_handle); } } else { for (int index = length - 1; index >= 0; --index) { IntPtr element_handle; EngineAPI.HCkE(EngineAPI.GetTupleVectorVector(vectorHandle, index, out element_handle)); EngineAPI.HCkE(EngineAPI.LoadTupleVector(outVector[index], element_handle)); EngineAPI.HCkE(EngineAPI.DestroyTupleVector(element_handle)); } } return(2); }
internal static int StoreTupleVector(HTupleVector inVector, IntPtr vectorHandle) { int dimension = inVector.Dimension; int length = inVector.Length; if (dimension == 1) { for (int index = length - 1; index >= 0; --index) { IntPtr tuple; EngineAPI.HCkE(HalconAPI.CreateTuple(out tuple)); HalconAPI.StoreTuple(tuple, inVector[index].T); EngineAPI.HCkE(EngineAPI.SetTupleVectorTuple(vectorHandle, index, tuple)); EngineAPI.HCkE(HalconAPI.DestroyTuple(tuple)); } } else { for (int index = length - 1; index >= 0; --index) { IntPtr vectorHandle1; EngineAPI.HCkE(EngineAPI.CreateTupleVector(inVector[index], out vectorHandle1)); EngineAPI.HCkE(EngineAPI.SetTupleVectorVector(vectorHandle, index, vectorHandle1)); EngineAPI.HCkE(EngineAPI.DestroyTupleVector(vectorHandle1)); } } GC.KeepAlive((object)inVector); return(2); }
/// <summary>Sets input control parameter for procedure call</summary> public void SetInputCtrlParamVector(string name, HTupleVector vector) { IntPtr vectorHandle; HDevProcedureCall.HCkE(EngineAPI.CreateTupleVector(vector, out vectorHandle)); HDevProcedureCall.HCkE(EngineAPI.SetInputCtrlParamVector(this.call, name, vectorHandle)); GC.KeepAlive((object)this); HDevProcedureCall.HCkE(EngineAPI.DestroyTupleVector(vectorHandle)); }
/// <summary>Sets the value of a global control variable</summary> public void SetGlobalCtrlVarVector(string name, HTupleVector vector) { IntPtr vectorHandle; HDevEngine.HCkE(EngineAPI.CreateTupleVector(vector, out vectorHandle)); HDevEngine.HCkE(EngineAPI.SetGlobalCtrlVarVector(this.engine, name, vectorHandle)); GC.KeepAlive((object)this); HDevEngine.HCkE(EngineAPI.DestroyTupleVector(vectorHandle)); }
internal static HTupleVector GetAndDestroyTupleVector(IntPtr vectorHandle) { int dimension; EngineAPI.HCkE(EngineAPI.GetTupleVectorDimension(vectorHandle, out dimension)); HTupleVector outVector = new HTupleVector(dimension); EngineAPI.HCkE(EngineAPI.LoadTupleVector(outVector, vectorHandle)); EngineAPI.HCkE(EngineAPI.DestroyTupleVector(vectorHandle)); return(outVector); }