Esempio n. 1
0
		private bool getStability() {

			if (_continuousSamplingCount == 0) {
				InitializeSamplingDatas();
			} 
            
            //オートゲインを取得
            SetLaserAutoOffsetGain(false);

			//タイムアウト用タイマースタート
			System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
			sw.Start();
					   
            List<int> SampParam =  new List<int>{1000,int.Parse(_settings._data._waitTime)};
			//サンプリング開始
			if (_machine.StartSampling(SampParam)) {
			} else {
				return false;
			}

			 //装置の応答待ち
			if (_machine.GetStatus() != true) {
				while (_machine._sampStatus != Machine.SamplingStatus.FINISH) {
					_machine.GetStatus();
					if (sw.ElapsedMilliseconds > 10000) {
						return false;
					}
				}
			}

			//データの取得
			if (_machine.GetSamplingData(0, 999)) {
				
				//sigref計算
				_dp = new DataProcessor(_machine, _settings);
				_dp.Main();

				//データ用変数確保
				//_sampDataStorageForRaw = new List<List<SamplingResult>>();

				//生データを入れる
				//_sampDataStorageBeforeAvg = _dp._allSamplingResult;
                List<List<SamplingResult>> allSamplingResult = _dp._allSamplingResult;
                List<List<double>> allGammaList = _dp._allGammaList;
                List<double> allBslList = _dp._allBslList;

                //それぞれを移動平均にかける
                MovingAverage mvAvg = new MovingAverage();
                List<List<SamplingResult>> mvAvg_samplingResult =  mvAvg.GetSamplingResult(allSamplingResult, int.Parse(_settings._data._movingAverageCount));
                List<List<double>> mvAvg_gamma = mvAvg.GetGammaResult(allGammaList,int.Parse(_settings._data._movingAverageCount));
                List<double>mvAvg_bsl = mvAvg.GetBslResult(allBslList, int.Parse(_settings._data._movingAverageCount));

                //それぞれの安定性を採る
                _stb = new Stability(_settings);
                _stb.GetSamplingResult(mvAvg_samplingResult);
                _stb.GetGammaResult(mvAvg_gamma);
                _stb.GetBslResult(mvAvg_bsl);

                //校正係数の取得
                _calib = new Calibrate(allSamplingResult, _settings);
                _stb._calib = _calib._result;

                //出力用生データのセット
                _stb.SetRawData(allSamplingResult, allGammaList, allBslList);

			} else {
				return false;
			}

			return true;
		}
Esempio n. 2
0
        public bool MakeStabilityDataFile(Stability src, string fileName) {
            string mvAvgPoint = "200";
            string waitTime = "30";
            string file = "";

            DateTime date = DateTime.Now;
            //file += "測定サンプル:ファントム(4%セルロース)\r\n\r\n";

            file += "ファイル作成日時,";
            file += date.ToString() + "\r\n";

            file += "余熱時間(秒),";
            file += waitTime + "\r\n";



            file += "装置温度(℃),";
            file += src._tempData[0] + "\r\n";

            file += "移動平均値,";
            file += mvAvgPoint + "\r\n\r\n";

            file += "アッテネーター,ゲイン,オフセット,\r\n";
            file += "Sig,";
            file += src._settings._data._gain._sig + " / 255," + src._settings._data._offset._sig + "\r\n";
            file += "Ref,";
            file += src._settings._data._gain._ref + " / 255," + src._settings._data._offset._ref + "\r\n";
            file += "\r\n";

            //列定義LD
            file += cs(1) + fillLd(true) + "\r\n";


            file += "LD温度(℃),";
            for (int i = 1; i < src._tempData.Count; i++) {
                file += src._tempData[i] + ",";
            }
            file += "\r\n";

            file += "校正係数,";
            for (int i = 0; i < src._settings._data._ldCalib.Count; i++) {
                file += src._settings._data._ldCalib[i] + ",";
            }
            file += "\r\n";

            file += "駆動電流値(mA),";
            for (int i = 0; i < src._settings._data._ldDrive.Count; i++) {
                file += src._settings._data._ldDrive[i] + ",";
            }
            file += "\r\n";

            file += "バイアス電流値(mA),";
            for (int i = 0; i < src._settings._data._ldBias.Count; i++) {
                file += src._settings._data._ldBias[i] + ",";
            }
            file += "\r\n";

            file += "Rの平均値,";
            for (int i = 1; i < src._mvAvg_R_avg.Count; i++) {
                file += src._mvAvg_R_avg[i] + ",";
            }
            file += "\r\n";

            file += "R変動の標準偏差,";
            for (int i = 1; i < src._mvAvg_R_stdDev.Count; i++) {
                file += src._mvAvg_R_stdDev[i] + ",";
            }
            file += "\r\n";

            file += "Rの安定性,";
            for (int i = 1; i < src._mvAvg_R_stability.Count; i++) {
                file += src._mvAvg_R_stability[i] + ",";
            }
            file += "\r\n\r\n";

            //列定義ガンマ
            file += cs(1) + fillGamma(6) + "\r\n";

            file += "ガンマの平均値,";
            for (int i = 0; i < src._mvAvg_gamma_avg.Count; i++) {
                file += src._mvAvg_gamma_avg[i] + ",";
            }
            file += "\r\n";

            file += "ガンマ変動の標準偏差,";
            for (int i = 0; i < src._mvAvg_gamma_stdDev.Count; i++) {
                file += src._mvAvg_gamma_stdDev[i] + ",";
            }
            file += "\r\n";

            file += "ガンマの安定性,";
            for (int i = 0; i < src._mvAvg_gamma_stability.Count; i++) {
                file += src._mvAvg_gamma_stability[i] + ",";
            }
            file += "\r\n\r\n";

            ////推定値列定義
            file += cs(1) + fillEst(7) + "\r\n";

            file += "推定値,";
            for (int i = 0; i < src._settings._data._estimate.Count; i++) {
                file += src._settings._data._estimate[i] + ",";
            }
            file += "\r\n\r\n";

            file += "BSLの平均値," + src._mvAvg_bsl_avg + "\r\n";
            file += "BSL変動の標準偏差," + src._mvAvg_bsl_stdDev + "\r\n";
            file += "BSLの安定性," + src._mvAvg_bsl_stability + "\r\n\r\n";


            file += "測定によって得られた校正係数,";
            for (int i = 0; i < src._calib.Count; i++) {
                file += src._calib[i] + ",";
            }

            //string rawDat = MakeRawDataStringFormat(MakeRawDataList(src._raw_R));

            List<string> rawData = new List<string>();
            rawData.Add("\r\n\r\n***以下生データ***\r\n\r\n");
            rawData.Add(MakeRawDataColumnFormat());
            rawData.AddRange(MakeRawDataList(src._raw_samplingResult, src._raw_gamma, src._raw_bsl));


            List<string> mvAvg_rawData = new List<string>();
            mvAvg_rawData.Add("\r\n\r\n***以下移動平均後の生データ***\r\n\r\n");
            mvAvg_rawData.Add(MakeRawDataColumnFormat());
            mvAvg_rawData.AddRange(MakeRawDataList(src._mvAvg_samplingResult, src._mvAvg_gamma, src._mvAvg_bsl));


            try {
                string strDateForFileName = date.ToString("yyyy-MM-dd-HH-mm-ss_");
                string addTimeFileName = AddTimeToPath(fileName, strDateForFileName);
                System.IO.StreamWriter sw = new System.IO.StreamWriter(addTimeFileName, false, System.Text.Encoding.GetEncoding("shift_jis"));

                sw.Write(file);

                for (int i = 0; i < rawData.Count; i++) {
                    sw.WriteLine(rawData[i]);
                }

                for (int i = 0; i < mvAvg_rawData.Count; i++) {
                    sw.WriteLine(mvAvg_rawData[i]);
                }

                sw.Close();

                ////タイムスタンプの同じrawデータファイルを出力
                //if (!MakeOneshotRaw(src._src, AddTimeToRawDatPath(fileName, strDateForFileName))) {
                //    return false;
                //}

            } catch (Exception) {
                return false;
            }
            return true;
        }