Ejemplo n.º 1
0
        //double[] data = new double[5000];
        //double[] newdata = new double[5000];
        /// <summary>
        /// 获取光谱仪原始数据
        /// </summary>
        /// <returns></returns>
        public double[] GetSpectralData(bool non_linear = true)
        {
            int data_len = 0;

            double[] data = new double[pix_num];
            int      ret  = Nahon_DLL.SA_GetSpectum(this.devindex, data, ref data_len);

            if (ret < 0)
            {
                throw new Exception("采集光谱失败");
            }

            if (data.Length == dk_data.Length)
            {
                for (int i = 0; i < data.Length; i++)
                {
                    data[i] -= dk_data[i];
                }
            }

            if (non_linear)
            {
                double[] newdata = new double[data.Length];
                Nahon_DLL.SA_NonlinearCalibration(this.devindex, data, newdata, data.Length);
                return(newdata);
            }
            else
            {
                return(data);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置积分时间
        /// </summary>
        public void SetIntegerTime(int ms)
        {
            int ret = Nahon_DLL.SA_SetIntegrationTime(this.devindex, ms * 1000);

            if (ret < 0)
            {
                throw new Exception("积分时间设置失败");
            }
        }
Ejemplo n.º 3
0
        public static ISpDevice[] SearchNqDevices()
        {
            Nahon_DLL.SA_CloseSpectrometers();

            int devnum = Nahon_DLL.SA_OpenSpectrometers();

            if (devnum < 0)
            {
                throw new Exception("没有找到光谱仪");
            }

            ISpDevice[] devices = new ISpDevice[devnum + 1];
            for (int i = 0; i < devices.Length; i++)
            {
                devices[i] = new NqSpDevice(i);
                devices[i].UpdateDevice();
            }
            return(devices);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 刷新设备数据
        /// </summary>
        public void UpdateDevice()
        {
            //读取序列号
            IntPtr ptr = Nahon_DLL.SA_GetSerialNumber(this.devindex);

            sp_serialNum = Marshal.PtrToStringAnsi(ptr);

            //读取设备名称
            ptr     = Nahon_DLL.SA_GetSpectrometersName(this.devindex);
            sp_name = Marshal.PtrToStringAnsi(ptr);

            pix_num = Nahon_DLL.SA_GetSpectrometerPixelsNumber(this.devindex);
            if (pix_num < 0)
            {
                throw new Exception("获取像素个数失败");
            }

            //获取波长系数
            sp_wave = new double[pix_num];
            int num = 0;

            Nahon_DLL.SA_GetWavelength(this.devindex, sp_wave, ref num);
        }