示例#1
0
文件: Program.cs 项目: Ykobe/metaCode
     //Console.ReadKey();
 }

        public static void getentityData(string resFilePath, string rawFile, string headerInfo, string paraIndex)
        {
            IRawDataPlus plus = RawFileReaderAdapter.FileFactory(rawFile);
            plus.SelectInstrument(Device.MS, 1);

            ArrayList indexOfpara = new ArrayList();
            string[] selectIndex = paraIndex.Split(',');

            foreach (string ele in selectIndex)
            {
                int index = Int32.Parse(ele);
                indexOfpara.Add(index);
            }

            //string fileName = DateTime.Now.ToLocalTime().ToString().Replace("/", "").Replace(":", "").Replace(" ", "_") + ".csv";
            FileStream stream = new FileStream(resFilePath, FileMode.Create, FileAccess.Write);
            StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);

            headerInfo = "RT," + headerInfo;
            headerInfo = "#," + headerInfo;
            writer.WriteLine(headerInfo);

            int offset = 0;
            int maxoffset = plus.GetStatusLogEntriesCount();
            while (offset < maxoffset)
            {
                string temp = "";
                IStatusLogEntry statusLogEntry = plus.GetStatusLogEntry(offset);
                temp += offset.ToString() + ",";
                temp += statusLogEntry.Time.ToString() + ",";

                foreach (int ele in indexOfpara)
                {
                    temp += Convert.ToString(statusLogEntry.Values[ele]) + ",";
                }

                writer.WriteLine(temp.Substring(0, temp.Length - 1));
                offset += 1;
            }

            writer.Close();
        }

        public static void showheaderInfo(string filePath)
        {
            IRawDataPlus plus = RawFileReaderAdapter.FileFactory(filePath);
            plus.SelectInstrument(Device.MS, 1);
            HeaderItem[] statuslogheaderinformation = plus.GetStatusLogHeaderInformation();
            int index = 0;

            Console.OutputEncoding = Encoding.UTF8;

            while (index < statuslogheaderinformation.Length)
            {
                Console.WriteLine(statuslogheaderinformation[index].Label);
                //headerInfo[index] = statuslogheaderinformation[index].Label;
                //writer.WriteLine(statuslogheaderinformation[index].Label);
                index += 1;
            }
            //writer.Close();

            //while (true)
            //{
            //if (index >= statuslogheaderinformation.Length)
            //{
            //    Console.WriteLine(plus.RunHeaderEx.FirstSpectrum.ToString());
            //    Console.WriteLine(plus.RunHeaderEx.LastSpectrum.ToString());
            //    Console.WriteLine(plus.RunHeaderEx.StartTime.ToString("F2"));
            //    Console.WriteLine(plus.RunHeaderEx.EndTime.ToString("F2"));
            //    Console.WriteLine(plus.RunHeaderEx.LowMass.ToString());
            //    Console.WriteLine(plus.RunHeaderEx.HighMass.ToString());
            //    break;
            //}
            //    Console.WriteLine(statuslogheaderinformation[index].Label);
            //    writer.WriteLine(statuslogheaderinformation[index].Label);
            //    index++;
            //}

            //writer.Close();

        }
        public static void getTuneInfo(string filePath)
        {
            IRawDataPlus plus = RawFileReaderAdapter.FileFactory(filePath);
            plus.SelectInstrument(Device.MS, 1);
            string fileName = DateTime.Now.ToLocalTime().ToString().Replace("/", "").Replace(":", "").Replace(" ", "_") + ".txt";
            FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write);
            StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);
            writer.WriteLine("*********************InstrumentMethod(0)***************************");
            writer.WriteLine(plus.GetInstrumentMethod(0));

            writer.WriteLine("*********************InstrumentMethod(1)****************************");
            writer.WriteLine(plus.GetInstrumentMethod(1));

            HeaderItem[] tuneDataHeaderInfo = plus.GetTuneDataHeaderInformation();

            writer.WriteLine("*********************Tune DATA ****************************");
            int tuneCnt = plus.GetTuneDataCount();

            for (int i = 0; i < tuneDataHeaderInfo.Length; ++i)
            {
                writer.WriteLine(tuneDataHeaderInfo[i].Label);
            }
            writer.Close();
        }

        public static void getMSdataFromScanNum(int startNum, int endNum, string filePath, double lowMS = 0.00, double highMS = 0.00)
        {
            IRawDataPlus plus = RawFileReaderAdapter.FileFactory(filePath);