挚感采集 main

 static void Main(string[] args)
        {
            m_total_MeasureResultV_t.Clear();//在List内移除所有元素
            strLidarIp1 = new StringBuilder("192.168.1.2");// new StringBuilder(ReadString("Basic", "IPV4_1", "192.168.1.111", strConfigIniAddr));
            myc = new OSP_Lidar.MeasureModeCallback(myMeasureModeCallback);
            Console.Write("IP1:" + strLidarIp1.ToString() + "\n");        

            //第一个正式的步骤:SDK的初始化
            int nBackId_device_init = 0;
            //SDK初始化函数,该函数必须优先调用。
            nBackId_device_init = OSP_Lidar.device_init();
            Console.Write("device_init结果:" + nBackId_device_init.ToString() + "\n");
            if (nBackId_device_init < 0)
            {
                Console.Write("device init error \n");
                return;
            }
            //第二个正式的步骤:添加硬件
            int nBackId_device_add = 0;
            //参数1:设备输出句柄
            //参数2:设备的IP地址
            //参数3:设备数据信息回调函数
            //ref:该关键字用于按引用传递参数,这意味着方法内部对参数的修改会影响到方法外部的原始变量
            nBackId_device_add = OSP_Lidar.device_add(ref dHandler1, strLidarIp1, myc);
            if ( 0== nBackId_device_add)
            {
                //uint cc = 0;
                //设备初始化
                OSP_Lidar.device_general_init(dHandler1);
                //   OSP_Lidar.device_write_fpga_reg(dHandler1, OSP_Fpga_Reg.B_transfer_down,31);
                //  uint transferdown = OSP_Lidar.device_read_fpga_reg(dHandler1, OSP_Fpga_Reg.B_transfer_down);//这些值读取了 dll会自己使用 不需要上层操作
                //cc = OSP_Lidar.device_read_fpga_reg(dHandler1, OSP_Fpga_Reg.B_dist_pow2);
                //cc = OSP_Lidar.device_read_fpga_reg(dHandler1, OSP_Fpga_Reg.B_rem_pow2);
                //cc = OSP_Lidar.device_read_fpga_reg(dHandler1, OSP_Fpga_Reg.B_out_amp_range_o);
                //cc = OSP_Lidar.device_read_fpga_reg(dHandler1, OSP_Fpga_Reg.B_output_phase_range);
                //设备信息结构体,可在设备连接之后通过device_get_info函数获取。
                OSP_Lidar.device_get_info(dHandler1, ref p_device_inf);//必须要加否则数据结构不对

                //读寄存器。
                ////判断是否收敛 1为收敛
                uint nC = OSP_Lidar.device_read_fpga_reg(dHandler1, OSP_Fpga_Reg.B_path_sel);
                int a = System.Environment.TickCount;//一个 32 位带符号整数,它包含自上次启动计算机以来所经过的时间(以毫秒为单位)
                for (int i = 0; i < 1024; i++)
                {
                    uint naddr = (uint)(0xc0000000 + 4 * i);
                    //Console.WriteLine(naddr.ToString("X") + "  " + OSP_Lidar.device_read_fpga_reg(dHandler1, naddr));
                }
                Console.WriteLine("耗时:" + (System.Environment.TickCount - a) + "ms");

                //进入测量模式,进入该模式后,数据将由用户注册的回调函数返回给用户。在测量期间,用户无法调用除停止测量之外的其他接口。
                OSP_Lidar.device_measure_mode_entry(dHandler1);
            }
            else
            {
                Console.Write("device1_add failure!\n");
            }


            int nSecWait2Stop =  ReadInt("Basic", "preserve_time", 5, strConfigIniAddr);
            while (nSecWait2Stop > 0)
            {
                Thread.Sleep(1000);
                nSecWait2Stop--;
            }
            //退出测量模式。
            OSP_Lidar.device_measure_mode_exit(dHandler1);
            //SDK逆初始化函数,该函数必须优先调用。
            if (OSP_Lidar.device_deinit() != 0)
            {
                Console.Write("device deinit error \n");
                return;
            }
            else
            {
                Console.Write("device deinit success ! \n");
            }
            WritePrivateProfileString("Basic", "IPV4", ReadString("Basic", "IPV4", strLidarIp1.ToString(), strConfigIniAddr), strConfigIniAddr);
            WritePrivateProfileString("Basic", "preserve_time", ReadString("Basic", "preserve_time", "5", strConfigIniAddr), strConfigIniAddr);
            Console.Write("Press any key to exit……\n");
            Console.Read();
        }

  

posted @ 2025-02-18 15:16  wenluderen  阅读(13)  评论(1)    收藏  举报