Example #1
0
        public static HTuple LoadTuple(IntPtr tupleHandle)
        {
            HTupleImplementation data;

            HTupleImplementation.LoadData(tupleHandle, HTupleType.MIXED, out data);
            return(new HTuple(data));
        }
Example #2
0
        private static string BuildMessage(HTupleImplementation sender, string sInfo)
        {
            string str = sInfo;

            if (sender != null)
            {
                str = "'" + str + "' when accessing '" + sender.ToString() + "'";
            }
            return(str);
        }
Example #3
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));
        }
Example #4
0
 public HTupleMixed(object[] o, bool copy)
 {
     for (int index = 0; index < o.Length; ++index)
     {
         int objectType = HTupleImplementation.GetObjectType(o[index]);
         if (objectType == 15 || (objectType & 32768) > 0)
         {
             throw new HTupleAccessException("Encountered invalid data types when creating HTuple");
         }
     }
     this.SetArray((Array)o, copy);
 }
Example #5
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;
            }
        }
Example #6
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);
        }
Example #7
0
        protected override void StoreData(IntPtr proc, IntPtr tuple)
        {
            for (int index = 0; index < this.iLength; ++index)
            {
                switch (HTupleImplementation.GetObjectType(this.o[index]))
                {
                case 1:
                    HalconAPI.HCkP(proc, HalconAPI.SetI(tuple, index, (int)this.o[index]));
                    break;

                case 2:
                    HalconAPI.HCkP(proc, HalconAPI.SetD(tuple, index, (double)this.o[index]));
                    break;

                case 4:
                    HalconAPI.HCkP(proc, HalconAPI.SetS(tuple, index, (string)this.o[index]));
                    break;

                case 129:
                    HalconAPI.HCkP(proc, HalconAPI.SetL(tuple, index, (long)this.o[index]));
                    break;
                }
            }
        }
Example #8
0
 public HTupleMixed(HTupleImplementation data)
     : this(data.ToOArr(), false)
 {
 }
Example #9
0
 public HTupleType GetElementType(int index)
 {
     return((HTupleType)HTupleImplementation.GetObjectType(this.o[index]));
 }
Example #10
0
 internal HTupleAccessException(HTupleImplementation sender)
     : this(sender, "Illegal operation on Tuple")
 {
 }
Example #11
0
 internal HTupleAccessException(HTupleImplementation sender, string sInfo)
     : this(sender, sInfo, (Exception)null)
 {
 }
Example #12
0
 internal HTupleAccessException(HTupleImplementation sender, string sInfo, Exception inner)
     : base(HTupleAccessException.BuildMessage(sender, sInfo), (Exception)null)
 {
 }
Example #13
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);
        }