Esempio n. 1
0
 public bool SetExposureTime(int exposureTime)
 {
     if (_isSpectrometerReady)
     {
         lock (_syncObj)
         {
             var result = OrminsCcdDriverWrapper.SetExposition(exposureTime, Id);
             if (result)
             {
                 _exposTime = exposureTime;
             }
             return(result);
         }
     }
     return(false);
 }
Esempio n. 2
0
        private void DataLoop()
        {
            var  errcount = 0;
            bool isNotify;

            while (true)
            {
                if (_isSpectrometerReady)
                {
                    try
                    {
                        lock (_syncObj)
                        {
                            if (OrminsCcdDriverWrapper.InitMeasuring(Id))
                            {
                                if (!OrminsCcdDriverWrapper.StartWaitMeasuring(Id))
                                {
                                    continue;
                                }
                                if (!OrminsCcdDriverWrapper.GetData(_intencityArray, Id))
                                {
                                    continue;
                                }
                                isNotify = true;
                                //Thread.Sleep(10);
                            }
                            //if (OrminsCcdDriverWrapper.InitMeasuringData(_intencityArray))
                            //{
                            //    //OrminsCcdDriverWrapper.InitMeasuring();
                            //    //OrminsCcdDriverWrapper.StartMeasuring();
                            //    OrminsCcdDriverWrapper.StartWaitMeasuring();
                            //    //OrminsCcdDriverWrapper.GetData(_intencityArray);
                            //    NotifyDataChanged(GetData());
                            //    Thread.Sleep(10);
                            //}
                            else
                            {
                                OrminsCcdDriverWrapper.CameraReset(Id);
                                OrminsCcdDriverWrapper.SetExposition(_exposTime, Id);
                                Thread.Sleep(100);
                                isNotify = false;
                            }
                        }
                        if (isNotify)
                        {
                            NotifyDataChanged(GetData());
                        }
                        //Thread.Sleep(10);
                    }
                    catch (Exception)
                    {
                        OrminsCcdDriverWrapper.CameraReset(Id);
                        OrminsCcdDriverWrapper.SetExposition(_exposTime, Id);
                        errcount++;
                        if (errcount > 5)
                        {
                            throw;
                        }
                        Thread.Sleep(100);
                    }
                }
                else
                {
                    return;
                }
            }
        }