Example #1
0
        public static int LoadL(IntPtr proc, int parIndex, int err, out long longValue)
        {
            if (HalconAPI.IsFailure(err))
            {
                longValue = -1L;
                return(err);
            }
            IntPtr tuple = IntPtr.Zero;

            HalconAPI.GetOutputTuple(proc, parIndex, out tuple);
            err = HalconAPI.HCkSingle(tuple, HTupleType.INTEGER);
            if (err == 2)
            {
                return(HalconAPI.GetL(tuple, 0, out longValue));
            }
            err = HalconAPI.HCkSingle(tuple, HTupleType.DOUBLE);
            if (err != 2)
            {
                longValue = -1L;
                return(err);
            }
            double doubleValue = -1.0;

            err       = HalconAPI.GetD(tuple, 0, out doubleValue);
            longValue = (long)doubleValue;
            return(err);
        }
Example #2
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);
        }
Example #3
0
        internal static int GetIP(IntPtr tuple, int index, out IntPtr intPtrValue)
        {
            int num;

            if (HalconAPI.isPlatform64)
            {
                long longValue;
                num         = HalconAPI.GetL(tuple, index, out longValue);
                intPtrValue = new IntPtr(longValue);
            }
            else
            {
                int intValue;
                num         = HalconAPI.GetI(tuple, index, out intValue);
                intPtrValue = new IntPtr(intValue);
            }
            return(num);
        }