Esempio n. 1
0
        Rect GetXZROI()
        {
            GoSetup _setup  = _sensor.Setup;
            GoRole  role    = _sensor.Role;
            string  jobName = _sensor.DefaultJob;

            _syncContext.Post(delegate { jobFile.Content = jobName; }, null);
            System.Windows.Point topLeft     = new System.Windows.Point(_setup.GetActiveAreaXLimitMin(role), _setup.GetActiveAreaZLimitMax(role));
            System.Windows.Point bottomRight = new System.Windows.Point(_setup.GetActiveAreaXLimitMax(role), _setup.GetActiveAreaZLimitMin(role));
            Rect rect = new Rect(topLeft, bottomRight);

            return(rect);
        }
Esempio n. 2
0
        public bool connect(ref string errMsg)
        {
            if (gocatorIp != null)
            {
                state = GoSdkWrapper.GoSdk_Construct(ref go_api);
                if (state != kStatus.kOK)
                {
                    errMsg = string.Format("GoSystem_Construct Error:{0}", state);
                    return(false);
                }

                state = GoSdkWrapper.GoSystem_Construct(ref go_system, IntPtr.Zero);
                if (state != kStatus.kOK)
                {
                    errMsg = string.Format("GoSystem_Construct Error:{0}", state);
                    return(false);
                }
                addrPtr = Marshal.AllocHGlobal(Marshal.SizeOf(addr));
                Marshal.StructureToPtr(addr, addrPtr, false);

                state = GoSdkWrapper.kIpAddress_Parse(addrPtr, gocatorIp);
                if (state != kStatus.kOK)
                {
                    errMsg = string.Format("kIpAddress_Parse Error:{0}", state);
                    return(false);
                }
                state = GoSdkWrapper.GoSystem_FindSensorByIpAddress(go_system, addrPtr, ref go_sensor);
                if (state != kStatus.kOK)
                {
                    errMsg = string.Format("GoSystem_FindSensorByIpAddress Error:{0}", state);
                    return(false);
                }
                state = GoSdkWrapper.GoSystem_Connect(go_system);
                if (state != kStatus.kOK)
                {
                    errMsg = string.Format("GoSystem_Connect Error:{0}", state);
                    return(false);
                }
                state = GoSdkWrapper.GoSystem_EnableData(go_system, true);
                if (state != kStatus.kOK)
                {
                    errMsg = string.Format("GoSystem_EnableData Error:{0}", state);
                    return(false);
                }


                Setup             = GoSdkWrapper.GoSensor_Setup(go_sensor);
                zRange            = GoSdkWrapper.GoSetup_ActiveAreaHeight(Setup, GoRole.GO_ROLE_MAIN);
                z_byte_resolution = 255 / zRange;
                zStart            = GoSdkWrapper.GoSetup_ActiveAreaZ(Setup, GoRole.GO_ROLE_MAIN);

                ondatatype = new onDataType(OnData);
                state      = GoSdkWrapper.GoSystem_SetDataHandler(go_system, ondatatype, context);
                GC.KeepAlive(ondatatype);
                if (state != kStatus.kOK)
                {
                    errMsg = string.Format("GoSystem_SetDataHandler Error:{0}", state);
                    return(false);
                }
                profileDataZ        = new List <Profile>();
                measurementDataList = new List <MeasurementData>();

                #region 加密模块
                SecretKey.License l = new SecretKey.License("license.dat", expirationTime, isStartCheck, tel);
                l.GocatorId = GoSdkWrapper.GoSensor_Id(go_sensor).ToString();
                l.Warn(warnStartDay, warnTime);
                #endregion
                context.serialNumber = GoSdkWrapper.GoSensor_Id(go_sensor);
                GoRole role = GoRole.GO_ROLE_MAIN;
                //context.yResolution =(double) GoSdkWrapper.GoSetup_YSpacingCount(Setup, role);
                context.yResolution = GoSdkWrapper.GoSetup_EncoderSpacing(Setup);
                context.xResolution = Math.Round(GoSdkWrapper.GoSetup_SpacingIntervalSystemValue(Setup, role), 3);
                return(true);
            }
            else
            {
                errMsg = "Gocator ip is Empty";
                return(false);
            }
        }
Esempio n. 3
0
 private static extern UInt32 GoSetup_XSpacingCount(IntPtr setup, GoRole role);
Esempio n. 4
0
 public static extern double GoSetup_SpacingIntervalSystemValue(IntPtr setup, GoRole role);
Esempio n. 5
0
 public static extern double GoSetup_ActiveAreaZ(IntPtr setup, GoRole role);
Esempio n. 6
0
        /// <summary>
        /// Get Point Cloud from Gocator
        /// </summary>
        /// <returns></returns>
        private void Point3DGenerator(KObject data)
        {
            GoDataSet  goDataSource = (GoDataSet)data;
            PointCloud pc           = new PointCloud();
            long       count        = goDataSource.Count;


            for (int i = 0; i < count; i++)
            {
                GoDataMsg dataMsg = (GoDataMsg)goDataSource.Get(i);
                switch (dataMsg.MessageType)
                {
                case GoDataMessageType.Surface:

                    GoSurfaceMsg goSurfaceMsg = (GoSurfaceMsg)(dataMsg);
                    pc.Width       = (int)goSurfaceMsg.Width;
                    pc.Height      = (int)goSurfaceMsg.Length;
                    pc.XResolution = (float)goSurfaceMsg.XResolution / 1000000;
                    pc.YResolution = (float)goSurfaceMsg.YResolution / 1000000;
                    pc.ZResolution = (float)goSurfaceMsg.ZResolution / 1000000;
                    pc.XOffset     = (float)goSurfaceMsg.XOffset / 1000;
                    pc.ZOffset     = (float)goSurfaceMsg.ZOffset / 1000;
                    pc.YOffset     = (float)goSurfaceMsg.YOffset / 1000;

                    GoSetup goSetup = _sensor.Setup;
                    GoRole  goRole  = new GoRole();
                    pc.ZStart = (float)goSetup.GetActiveAreaZ(goRole);
                    pc.XStart = (float)goSetup.GetActiveAreaX(goRole);
                    pc.ZRange = (float)goSetup.GetActiveAreaHeight(goRole);
                    ///
                    //generate csv file for point data save
                    ///
                    pc.ProfileList = new List <List <Point3D> >();
                    //int pointsCount = 0;
                    pc.Point3DArray = new Point3D[pc.Width * pc.Height];
                    int pointsCount = 0;
                    for (int j = 0; j < pc.Height; j++)
                    {
                        List <Point3D> profileList = new List <Point3D>();
                        for (int k = 0; k < pc.Width; k++)
                        {
                            Point3D tempPoint = new Point3D();

                            tempPoint.X = pc.XOffset + k * pc.XResolution;
                            tempPoint.Y = pc.YOffset + j * pc.YResolution;
                            //tempPoint.Z = (goSurfaceMsg.Get(j, k) == -32768) ? 0 : (pc.ZOffset + goSurfaceMsg.Get(j, k) * pc.ZResolution);
                            //No Z  Start
                            //tempPoint.X = k * pc.XResolution;
                            //tempPoint.Y = j * pc.YResolution;
                            tempPoint.Z = (goSurfaceMsg.Get(j, k) == -32768) ? 0 : (pc.ZOffset + goSurfaceMsg.Get(j, k) * pc.ZResolution - pc.ZStart);
                            profileList.Add(tempPoint);
                            pc.Point3DArray[pointsCount] = tempPoint;
                            pointsCount++;
                        }


                        pc.ProfileList.Add(profileList);
                    }


                    //data.Destroy();
                    dataMsg.Destroy();
                    goSurfaceMsg.Destroy();
                    SerializePointCloud(pc);
                    break;

                default:
                    break;
                }
            }
        }