コード例 #1
0
ファイル: HalconAPI.cs プロジェクト: zshankang/OpenHalcon
        public static int LoadD(IntPtr proc, int parIndex, int err, out double doubleValue)
        {
            if (HalconAPI.IsFailure(err))
            {
                doubleValue = -1.0;
                return(err);
            }
            IntPtr tuple = IntPtr.Zero;

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

            err         = HalconAPI.GetI(tuple, 0, out intValue);
            doubleValue = (double)intValue;
            return(err);
        }
コード例 #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);
        }