Example #1
0
        private void bt_dk_Click(object sender, EventArgs e)
        {
            updatestate();
            int int_time = int.Parse(this.tb_intertime.Text);

            for (int i = 0; i < SPDevManager.Instance.DevList.Length; i++)
            {
                ISpDevice dev = SPDevManager.Instance.DevList[i];
                if (!dev.Enable)
                {
                    continue;
                }

                try
                {
                    double[] data = dev.DKModify(int_time);
                    sp.WaitOne();
                    ShowSPData(dev.SpSerialNum, dev.DevIndex + "", dev.SpWaveArray, data);
                }
                catch (Exception ex)
                {
                    FaultCenter.Instance.SendFault(FaultLevel.ERROR, ex.Message);
                }
            }
        }
Example #2
0
        /// <summary>
        /// 开始测试
        /// </summary>
        private void RunDevice(ISpDevice dev)
        {
            int int_time = int.Parse(this.tb_intertime.Text);

            int ivl_time = int.Parse(this.tb_intervaltime.Text);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    sema.WaitOne();
                    //设置积分时间
                    dev.SetIntegerTime(int_time);
                    sema.Release();
                }
                catch (Exception ex)
                {
                    FaultCenter.Instance.SendFault(FaultLevel.ERROR, ex.Message);
                    //FaultCenter("异常!!" + ex);
                }

                try
                {
                    Thread.Sleep(ivl_time);
                    while (collect_start)
                    {
                        double[] data = dev.GetSpectralData();
                        //Console.WriteLine(dev.DevIndex);
                        sp.WaitOne();
                        ShowSPData(dev.SpSerialNum, dev.DevIndex + "", dev.SpWaveArray, data);
                        ColorData color = SPDevManager.Instance.CalInstance.GetColor(dev.SpWaveArray, data);
                        cie.WaitOne();
                        ShowCIE(dev.SpSerialNum, color.fx, color.fy);
                        Thread.Sleep(ivl_time);
                    }
                }
                catch (Exception ex)
                {
                    FaultCenter.Instance.SendFault(FaultLevel.ERROR, ex.Message);
                    //sema.Release();
                    //FaultCenter("异常!!" + ex);
                }
            });
        }
Example #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);
        }