Exemple #1
0
        public static int Load(IntPtr tuple, out HTupleMixed data)
        {
            int err = 2;
            int length;

            HalconAPI.GetTupleLength(tuple, out length);
            object[] o = new object[length];
            for (int index = 0; index < length; ++index)
            {
                if (!HalconAPI.IsFailure(err))
                {
                    HTupleType type;
                    HalconAPI.GetElementType(tuple, index, out type);
                    switch (type)
                    {
                    case HTupleType.INTEGER:
                        if (HalconAPI.isPlatform64)
                        {
                            long longValue;
                            err      = HalconAPI.GetL(tuple, index, out longValue);
                            o[index] = (object)longValue;
                            continue;
                        }
                        int intValue;
                        err      = HalconAPI.GetI(tuple, index, out intValue);
                        o[index] = (object)intValue;
                        continue;

                    case HTupleType.DOUBLE:
                        double doubleValue;
                        err      = HalconAPI.GetD(tuple, index, out doubleValue);
                        o[index] = (object)doubleValue;
                        continue;

                    case HTupleType.STRING:
                        string stringValue;
                        err      = HalconAPI.GetS(tuple, index, out stringValue);
                        o[index] = (object)stringValue;
                        continue;

                    default:
                        continue;
                    }
                }
            }
            data = new HTupleMixed(o, false);
            return(err);
        }
Exemple #2
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);
        }