Beispiel #1
0
        public static int Load(
            IntPtr proc,
            int parIndex,
            HTupleType type,
            out HTupleImplementation data)
        {
            IntPtr tuple;

            HalconAPI.GetOutputTuple(proc, parIndex, out tuple);
            return(HTupleImplementation.LoadData(tuple, type, out data));
        }
Beispiel #2
0
        public static void StoreTuple(IntPtr tupleHandle, HTuple tuple)
        {
            HTupleType type = tuple.Type == HTupleType.LONG ? HTupleType.INTEGER : tuple.Type;

            HalconAPI.HCkH(HalconAPI.CreateElementsOfType(tupleHandle, tuple.Length, type));
            switch (tuple.Type)
            {
            case HTupleType.INTEGER:
                HalconAPI.HCkH(HalconAPI.SetIArr(tupleHandle, tuple.IArr));
                break;

            case HTupleType.DOUBLE:
                HalconAPI.HCkH(HalconAPI.SetDArr(tupleHandle, tuple.DArr));
                break;

            case HTupleType.STRING:
                string[] sarr = tuple.SArr;
                for (int index = 0; index < tuple.Length; ++index)
                {
                    HalconAPI.HCkH(HalconAPI.SetS(tupleHandle, index, sarr[index]));
                }
                break;

            case HTupleType.MIXED:
                object[] oarr = tuple.data.OArr;
                for (int index = 0; index < tuple.Length; ++index)
                {
                    switch (HTupleImplementation.GetObjectType(oarr[index]))
                    {
                    case 1:
                        HalconAPI.HCkH(HalconAPI.SetI(tupleHandle, index, (int)oarr[index]));
                        break;

                    case 2:
                        HalconAPI.HCkH(HalconAPI.SetD(tupleHandle, index, (double)oarr[index]));
                        break;

                    case 4:
                        HalconAPI.HCkH(HalconAPI.SetS(tupleHandle, index, (string)oarr[index]));
                        break;

                    case 129:
                        HalconAPI.HCkH(HalconAPI.SetL(tupleHandle, index, (long)oarr[index]));
                        break;
                    }
                }
                break;

            case HTupleType.LONG:
                HalconAPI.HCkH(HalconAPI.SetLArr(tupleHandle, tuple.LArr));
                break;
            }
        }
Beispiel #3
0
        internal static int LoadNew(
            IntPtr proc,
            int parIndex,
            HTupleType type,
            int err,
            out HHomMat3D obj)
        {
            HTuple tuple;

            err = HTuple.LoadNew(proc, parIndex, err, out tuple);
            obj = new HHomMat3D(new HData(tuple));
            return(err);
        }
Beispiel #4
0
        public HTupleType GetElementType(int[] indices)
        {
            if (indices == null || indices.Length == 0)
            {
                return(HTupleType.EMPTY);
            }
            HTupleType objectType = (HTupleType)HTupleImplementation.GetObjectType(this.o[indices[0]]);

            for (int index = 1; index < indices.Length; ++index)
            {
                if ((HTupleType)HTupleImplementation.GetObjectType(this.o[indices[index]]) != objectType)
                {
                    return(HTupleType.MIXED);
                }
            }
            return(objectType);
        }
Beispiel #5
0
        private static int HCkSingle(IntPtr tuple, HTupleType expectedType)
        {
            int length = 0;

            if (tuple != IntPtr.Zero)
            {
                HalconAPI.GetTupleLength(tuple, out length);
            }
            if (length <= 0)
            {
                return(7001);
            }
            HTupleType type;

            HalconAPI.GetElementType(tuple, 0, out type);
            return(type != expectedType ? 7002 : 2);
        }
Beispiel #6
0
 //[DllImport("halconxl", EntryPoint = "HLIGetElementType", CallingConvention = CallingConvention.Cdecl)]
 internal static int GetElementType(IntPtr tuple, int index, out HTupleType type)
 {
     type = (HTupleType)0;
     return(1);
 }
Beispiel #7
0
 //[DllImport("halconxl", EntryPoint = "HLICreateElementsOfType", CallingConvention = CallingConvention.Cdecl)]
 internal static int CreateElementsOfType(IntPtr tuple, int length, HTupleType type)
 {
     return(1);
 }
Beispiel #8
0
 internal int Load(IntPtr proc, int parIndex, HTupleType type, int err)
 {
     return(this.tuple.Load(proc, parIndex, type, err));
 }
Beispiel #9
0
        public static int LoadData(IntPtr tuple, HTupleType type, out HTupleImplementation data)
        {
            int num = 2;

            if (tuple == IntPtr.Zero)
            {
                data = (HTupleImplementation)HTupleVoid.EMPTY;
                return(num);
            }
            int type1;

            HalconAPI.GetTupleTypeScanElem(tuple, out type1);
            switch (type1)
            {
            case 1:
                if (HalconAPI.isPlatform64)
                {
                    HTupleInt64 data1;
                    num  = HTupleInt64.Load(tuple, out data1);
                    data = (HTupleImplementation)data1;
                }
                else
                {
                    HTupleInt32 data1;
                    num  = HTupleInt32.Load(tuple, out data1);
                    data = (HTupleImplementation)data1;
                }
                type = HTupleType.INTEGER;
                break;

            case 2:
                HTupleDouble data2;
                num  = HTupleDouble.Load(tuple, out data2);
                data = (HTupleImplementation)data2;
                type = HTupleType.DOUBLE;
                break;

            case 4:
                HTupleString data3;
                num  = HTupleString.Load(tuple, out data3);
                data = (HTupleImplementation)data3;
                type = HTupleType.STRING;
                break;

            case 7:
                HTupleMixed data4;
                num  = HTupleMixed.Load(tuple, out data4);
                data = (HTupleImplementation)data4;
                type = HTupleType.MIXED;
                break;

            case 15:
                data = (HTupleImplementation)HTupleVoid.EMPTY;
                type = HTupleType.EMPTY;
                break;

            default:
                data = (HTupleImplementation)HTupleVoid.EMPTY;
                num  = 7002;
                break;
            }
            return(num);
        }