Esempio n. 1
0
        /// <summary>
        /// 扫描样品
        /// </summary>
        /// <param name="scanMethodFile">扫描配置文件</param>
        /// <param name="scanCount">扫描次数</param>
        /// <param name="backgroundFile">样品保存文件</param>
        public static string ScanSample(string scanMethodFile, int scanCount, string sampleFile, bool?IsOVP)
        {
            lock (thisLock)
            {
                //移动积分球
                if (IsOVP.HasValue)
                {
                    if ((bool)IsOVP)
                    {
                        MoveFlag(1);
                    }
                    else
                    {
                        MoveFlag(0);
                    }
                    if (IsIntegratingSphere.HasValue)
                    {
                        if ((bool)IsIntegratingSphere)
                        {
                            instrumentObject.SampleSpinner(1);
                        }
                    }
                }
                //加载扫描配置
                ErrorCode = instrumentObject.LoadSettings(scanMethodFile);
                if (ErrorCode != 0)
                {
                    return(null);
                }

                ErrorCode = instrumentObject.CollectSpectrum(scanCount, sampleFile);
                if (ErrorCode != 0)
                {
                    return(null);
                }

                //扫描后的文件中有_abs,需要去掉_abs
                string scanedfile = sampleFile.Insert(sampleFile.Length - ".spc".Length, "_sbm");
                //Common.CommonMethod.ErrorMsgBox(scanedfile);
                if (!File.Exists(scanedfile))
                {
                    ErrorCode = -12;
                    return(null);
                }

                //try
                //{
                //    File.Move(scanedfile, sampleFile);
                //}
                //catch (Exception)
                //{
                //    ErrorCode = -13;
                //}

                return(scanedfile);// ErrorCode == 0;
            }
        }
        /// <summary>
        /// 移动转轮位置 0 for off.1 for on
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        public bool?SampleSpinner(int position)
        {
            if (!isConnected)
            {
                errorCode = -11;
                return(false);
            }

            errorCode = instrumentObject.SampleSpinner(position);
            return(errorCode == 0);
        }