Exemplo n.º 1
0
        internal static int StoreObjectVector(HObjectVector inVector, IntPtr vectorHandle)
        {
            int dimension = inVector.Dimension;
            int length    = inVector.Length;

            if (dimension == 1)
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    EngineAPI.HCkE(EngineAPI.SetObjectVectorObject(vectorHandle, index, inVector[index].O.Key));
                }
            }
            else
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    IntPtr vectorHandle1;
                    EngineAPI.HCkE(EngineAPI.CreateObjectVector(inVector[index], out vectorHandle1));
                    EngineAPI.HCkE(EngineAPI.SetObjectVectorVector(vectorHandle, index, vectorHandle1));
                    EngineAPI.HCkE(EngineAPI.DestroyObjectVector(vectorHandle1));
                }
            }
            GC.KeepAlive((object)inVector);
            return(2);
        }
Exemplo n.º 2
0
        internal static int LoadObjectVector(HObjectVector outVector, IntPtr vectorHandle)
        {
            int dimension;

            EngineAPI.HCkE(EngineAPI.GetObjectVectorDimension(vectorHandle, out dimension));
            int length;

            EngineAPI.HCkE(EngineAPI.GetObjectVectorLength(vectorHandle, out length));
            if (dimension == 1)
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    IntPtr key;
                    EngineAPI.HCkE(EngineAPI.GetObjectVectorObject(vectorHandle, index, out key));
                    outVector[index].O = new HObject(key, false);
                }
            }
            else
            {
                for (int index = length - 1; index >= 0; --index)
                {
                    IntPtr sub_vector_handle;
                    EngineAPI.HCkE(EngineAPI.GetObjectVectorVector(vectorHandle, index, out sub_vector_handle));
                    EngineAPI.HCkE(EngineAPI.LoadObjectVector(outVector[index], sub_vector_handle));
                    EngineAPI.HCkE(EngineAPI.DestroyObjectVector(sub_vector_handle));
                }
            }
            return(2);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        internal static int GetLastException(
            out int category,
            out string message,
            out string procedureName,
            out string lineText,
            out int lineNumber,
            out HTuple userData)
        {
            IntPtr message1;
            IntPtr procedureName1;
            IntPtr lineText1;
            IntPtr userData1;
            int    lastException = EngineAPI.HCenGetLastException(out category, out message1, out procedureName1, out lineText1, out lineNumber, out userData1);

            try
            {
                message       = Marshal.PtrToStringAnsi(message1);
                procedureName = Marshal.PtrToStringAnsi(procedureName1);
                lineText      = Marshal.PtrToStringAnsi(lineText1);
                userData      = HalconAPI.LoadTuple(userData1);
            }
            catch
            {
                message       = "Error handling exception";
                procedureName = "";
                lineText      = "";
                userData      = new HTuple();
            }
            EngineAPI.HCenReleaseLastException();
            return(lastException);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        internal static void GetProgramInfo(
            IntPtr program,
            out string name,
            out bool loaded,
            out HTuple varNamesIconic,
            out HTuple varNamesCtrl,
            out HTuple varDimsIconic,
            out HTuple varDimsCtrl)
        {
            IntPtr tuple1;

            EngineAPI.HCkE(HalconAPI.CreateTuple(out tuple1));
            IntPtr tuple2;

            EngineAPI.HCkE(HalconAPI.CreateTuple(out tuple2));
            IntPtr tuple3;

            EngineAPI.HCkE(HalconAPI.CreateTuple(out tuple3));
            IntPtr tuple4;

            EngineAPI.HCkE(HalconAPI.CreateTuple(out tuple4));
            IntPtr name1;

            EngineAPI.HCkE(EngineAPI.HCenGetProgramInfo(program, out name1, out loaded, tuple1, tuple2, tuple3, tuple4));
            name           = Marshal.PtrToStringAnsi(name1);
            varNamesIconic = HalconAPI.LoadTuple(tuple1);
            varNamesCtrl   = HalconAPI.LoadTuple(tuple2);
            varDimsIconic  = HalconAPI.LoadTuple(tuple3);
            varDimsCtrl    = HalconAPI.LoadTuple(tuple4);
            EngineAPI.HCkE(HalconAPI.DestroyTuple(tuple1));
            EngineAPI.HCkE(HalconAPI.DestroyTuple(tuple2));
            EngineAPI.HCkE(HalconAPI.DestroyTuple(tuple3));
            EngineAPI.HCkE(HalconAPI.DestroyTuple(tuple4));
        }
Exemplo n.º 7
0
        /// <summary>Gets the object of an iconic output parameter</summary>
        public HObject GetOutputIconicParamObject(string name)
        {
            IntPtr key;

            HDevProcedureCall.HCkE(EngineAPI.GetOutputIconicParamObject(this.call, name, out key));
            GC.KeepAlive((object)this);
            return(new HObject(key));
        }
Exemplo n.º 8
0
        /// <summary>Gets the value of an output control parameter</summary>
        public HTupleVector GetOutputCtrlParamVector(int index)
        {
            IntPtr vector;

            HDevProcedureCall.HCkE(EngineAPI.GetOutputCtrlParamVector(this.call, index, out vector));
            GC.KeepAlive((object)this);
            return(EngineAPI.GetAndDestroyTupleVector(vector));
        }
Exemplo n.º 9
0
        /// <summary>Gets the value of an output control parameter</summary>
        public HTuple GetOutputCtrlParamTuple(string name)
        {
            IntPtr tuple;

            HDevProcedureCall.HCkE(EngineAPI.GetOutputCtrlParamTuple(this.call, name, out tuple));
            GC.KeepAlive((object)this);
            return(HalconAPI.LoadTuple(tuple));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Gets the value of a control variable (in main)
        /// </summary>
        public HTuple GetCtrlVarTuple(int index)
        {
            IntPtr tuple;

            HDevProgramCall.HCkE(EngineAPI.GetCtrlVarTuple(this.call, index, out tuple));
            GC.KeepAlive((object)this);
            return(HalconAPI.LoadTuple(tuple));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Gets the object of an iconic variable (in main)
        /// </summary>
        public HObject GetIconicVarObject(string name)
        {
            IntPtr key;

            HDevProgramCall.HCkE(EngineAPI.GetIconicVarObject(this.call, name, out key));
            GC.KeepAlive((object)this);
            return(new HObject(key));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the values of an iconic vector variable
        ///             (in main)
        /// </summary>
        public HObjectVector GetIconicVarVector(int index)
        {
            IntPtr vector;

            HDevProgramCall.HCkE(EngineAPI.GetIconicVarVector(this.call, index, out vector));
            GC.KeepAlive((object)this);
            return(EngineAPI.GetAndDestroyObjectVector(vector));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the values of a control vector variable
        ///             (in main)
        /// </summary>
        public HTupleVector GetCtrlVarVector(string name)
        {
            IntPtr vector;

            HDevProgramCall.HCkE(EngineAPI.GetCtrlVarVector(this.call, name, out vector));
            GC.KeepAlive((object)this);
            return(EngineAPI.GetAndDestroyTupleVector(vector));
        }
Exemplo n.º 14
0
        /// <summary>Gets the value of a global iconic variable</summary>
        public HObjectVector GetGlobalIconicVarVector(string name)
        {
            IntPtr vector;

            HDevEngine.HCkE(EngineAPI.GetGlobalIconicVarVector(this.engine, name, out vector));
            GC.KeepAlive((object)this);
            return(EngineAPI.GetAndDestroyObjectVector(vector));
        }
Exemplo n.º 15
0
        /// <summary>Gets the value of a global iconic variable</summary>
        public HObject GetGlobalIconicVarObject(string name)
        {
            IntPtr key;

            HDevEngine.HCkE(EngineAPI.GetGlobalIconicVarObject(this.engine, name, out key));
            GC.KeepAlive((object)this);
            return(new HObject(key, false));
        }
Exemplo n.º 16
0
        /// <summary>Gets the value of an output control parameter</summary>
        public HObjectVector GetOutputIconicParamVector(string name)
        {
            IntPtr vector;

            HDevProcedureCall.HCkE(EngineAPI.GetOutputIconicParamVector(this.call, name, out vector));
            GC.KeepAlive((object)this);
            return(EngineAPI.GetAndDestroyObjectVector(vector));
        }
Exemplo n.º 17
0
        /// <summary>Gets the dimension of a global control variable</summary>
        public int GetGlobalCtrlVarDimension(string name)
        {
            int dimension;

            HDevEngine.HCkE(EngineAPI.GetGlobalCtrlVarDimension(this.engine, name, out dimension));
            GC.KeepAlive((object)this);
            return(dimension);
        }
Exemplo n.º 18
0
        /// <summary>Compile all procedures that are used by the program and that
        /// can be compiled with a just-in-time compiler.
        /// The method returns true when all used procedures could be compiled by
        /// the just-in-time compiler.
        /// Procedures that could not be compiled are called normally by the
        /// HDevEngine interpreter.
        /// To check which procedure could not be compiled and what the reason is
        /// for that start HDevelop and check there the compilation states.
        /// </summary>
        public bool CompileUsedProcedures()
        {
            bool ret;

            HDevProcedure.HCkE(EngineAPI.CompileUsedProceduresForProcedure(this.procedure, out ret));
            GC.KeepAlive((object)this);
            return(ret);
        }
Exemplo n.º 19
0
        internal static int LoadProcedure(IntPtr procedure, string programName, string procedureName)
        {
            IntPtr hglobalUtf8Encoding = HalconAPI.ToHGlobalUtf8Encoding(programName);
            int    num = EngineAPI.HCenLoadProcedureProgramName(procedure, hglobalUtf8Encoding, procedureName);

            Marshal.FreeHGlobal(hglobalUtf8Encoding);
            return(num);
        }
Exemplo n.º 20
0
        internal static int AddProcedurePath(IntPtr engine, string path)
        {
            IntPtr hglobalUtf8Encoding = HalconAPI.ToHGlobalUtf8Encoding(path);
            int    num = EngineAPI.HCenAddProcedurePath(engine, hglobalUtf8Encoding);

            Marshal.FreeHGlobal(hglobalUtf8Encoding);
            return(num);
        }
Exemplo n.º 21
0
        internal static int LoadProgram(IntPtr program, string fileName)
        {
            IntPtr hglobalUtf8Encoding = HalconAPI.ToHGlobalUtf8Encoding(fileName);
            int    num = EngineAPI.HCenLoadProgram(program, hglobalUtf8Encoding);

            Marshal.FreeHGlobal(hglobalUtf8Encoding);
            return(num);
        }
Exemplo n.º 22
0
        /// <summary>Gets the value of a global iconic XLD variable</summary>
        public HXLD GetGlobalIconicVarXld(string name)
        {
            IntPtr key;

            HDevEngine.HCkE(EngineAPI.GetGlobalIconicVarObject(this.engine, name, out key));
            GC.KeepAlive((object)this);
            EngineAPI.AssertObjectClass(key, "xld", "main");
            return(new HXLD(key, false));
        }
Exemplo n.º 23
0
        /// <summary>
        /// Gets the region of an iconic variable (in main)
        /// </summary>
        public HRegion GetIconicVarRegion(string name)
        {
            IntPtr key;

            HDevProgramCall.HCkE(EngineAPI.GetIconicVarObject(this.call, name, out key));
            GC.KeepAlive((object)this);
            EngineAPI.AssertObjectClass(key, "region", "main");
            return(new HRegion(key));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Gets the xld contour of an iconic variable (in main)
        /// </summary>
        public HXLD GetIconicVarXld(int index)
        {
            IntPtr key;

            HDevProgramCall.HCkE(EngineAPI.GetIconicVarObject(this.call, index, out key));
            GC.KeepAlive((object)this);
            EngineAPI.AssertObjectClass(key, "xld", "main");
            return(new HXLD(key));
        }
Exemplo n.º 25
0
        /// <summary>Sets input control parameter for procedure call</summary>
        public void SetInputIconicParamVector(int index, HObjectVector vector)
        {
            IntPtr vectorHandle;

            HDevProcedureCall.HCkE(EngineAPI.CreateObjectVector(vector, out vectorHandle));
            HDevProcedureCall.HCkE(EngineAPI.SetInputIconicParamVector(this.call, index, vectorHandle));
            GC.KeepAlive((object)this);
            HDevProcedureCall.HCkE(EngineAPI.DestroyObjectVector(vectorHandle));
        }
Exemplo n.º 26
0
        /// <summary>Sets the value of a global iconic variable</summary>
        public void SetGlobalIconicVarVector(string name, HObjectVector vector)
        {
            IntPtr vectorHandle;

            HDevEngine.HCkE(EngineAPI.CreateObjectVector(vector, out vectorHandle));
            HDevEngine.HCkE(EngineAPI.SetGlobalIconicVarVector(this.engine, name, vectorHandle));
            GC.KeepAlive((object)this);
            HDevEngine.HCkE(EngineAPI.DestroyObjectVector(vectorHandle));
        }
Exemplo n.º 27
0
        /// <summary>Gets the region of an iconic output parameter</summary>
        public HRegion GetOutputIconicParamRegion(int index)
        {
            IntPtr key;

            HDevProcedureCall.HCkE(EngineAPI.GetOutputIconicParamObject(this.call, index, out key));
            GC.KeepAlive((object)this);
            EngineAPI.AssertObjectClass(key, "region", "main");
            return(new HRegion(key));
        }
Exemplo n.º 28
0
        /// <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));
        }
Exemplo n.º 29
0
        /// <summary>Gets the xld contour of an iconic output parameter</summary>
        public HXLD GetOutputIconicParamXld(string name)
        {
            IntPtr key;

            HDevProcedureCall.HCkE(EngineAPI.GetOutputIconicParamObject(this.call, name, out key));
            GC.KeepAlive((object)this);
            EngineAPI.AssertObjectClass(key, "xld", "main");
            return(new HXLD(key));
        }
Exemplo n.º 30
0
 /// <summary>Loads a local procedure</summary>
 public void LoadProcedure(HDevProgram program, string procedureName)
 {
     if (program.Handle == IntPtr.Zero)
     {
         HDevEngineException.ThrowGeneric("Uninitialized program while creating a local procedure call");
     }
     HDevProcedure.HCkE(EngineAPI.LoadProcedure(this.procedure, program.Handle, procedureName));
     GC.KeepAlive((object)this);
     this.UpdateProcedureInfo();
 }