Beispiel #1
0
 /// <summary>
 /// 获取检测峰参数
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static DetectPeakParameter GetDetectPeakParameter(string filename)
 {
     try
     {
         DetectPeakParameter dpp = new DetectPeakParameter();
         DoOpen(filename, null, null, dpp);
         return(dpp);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex);
         return(null);
     }
 }
Beispiel #2
0
 /// <summary>
 /// 保存数据
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="dh"></param>
 /// <param name="ph"></param>
 /// <returns></returns>
 //private static bool DoSave(string filename, DataHelper dh, PeekHelper ph)
 //{
 //    return DoSave(filename, dh, ph, null);
 //}
 /// <summary>
 /// 保存数据
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="dh"></param>
 /// <param name="ph"></param>
 /// <returns></returns>
 private static bool DoSave(string filename, DataHelper dh, PeakHelper ph, DetectPeakParameter dpp)
 {
     try
     {
         if (dh == null || ph == null)
         {
             return(false);
         }
         IFileReadWrite file = ReadWriteFactory.CreateFileInstance(SerialType.Binary);
         try
         {
             file.OpenFile(filename, FileOpenFlag.Create);
             List <MemoryStream> mlst = new List <MemoryStream>();
             MemoryStream        ms   = new MemoryStream();
             //save points
             dh.Serialize(ref ms);
             mlst.Add(ms);
             file.WriteContent(mlst, 0);
             //save peaks
             mlst.Clear();
             ms = new MemoryStream();
             ph.SerializePeaks(ref ms);
             mlst.Add(ms);
             file.WriteContent(mlst, 1);
             //save operates
             //mlst.Clear();
             //ms = new MemoryStream();
             //ph.SerializeOperates(ref ms);
             //mlst.Add(ms);
             //file.WriteContent(mlst, 2);
             //save Detect Peak Parameter
             mlst.Clear();
             ms = new MemoryStream();
             dpp.Serialize(ref ms);
             mlst.Add(ms);
             file.WriteContent(mlst, 2);
         }
         finally
         {
             file.CloseFile();
         }
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex);
         return(false);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 峰表反序列化
        /// </summary>
        /// <param name="stream">从流对象反序列化</param>
        public void Deserialize(MemoryStream stream)
        {
            BinaryFormatter     format = new BinaryFormatter();
            DetectPeakParameter dpp    = (DetectPeakParameter)format.Deserialize(stream);

            this.MinArea             = dpp.MinArea;
            this.MinWidth            = dpp.MinWidth;
            this.MinHeight           = dpp.MinHeight;
            this.CheckLevel          = dpp.CheckLevel;
            this.StartSlope          = dpp.StartSlope;
            this.EndSlope            = dpp.EndSlope;
            this.TimeSpan            = dpp.TimeSpan;
            this.SG_Order            = dpp.SG_Order;
            this.SG_SideWindowLength = dpp.SG_SideWindowLength;
        }
Beispiel #4
0
 /// <summary>
 /// 打开数据
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 private static bool DoOpen(string filename, DataHelper dh, PeakHelper ph, DetectPeakParameter dpp)
 {
     try
     {
         //if (dh == null || ph == null) return false;
         if (!File.Exists(filename))
         {
             return(false);
         }
         IFileReadWrite file = ReadWriteFactory.CreateFileInstance(SerialType.Binary);
         try
         {
             file.OpenFile(filename, FileOpenFlag.Open);
             List <MemoryStream> mlst = new List <MemoryStream>();
             //open points
             if (dh != null && file.ReadContent(0, out mlst))
             {
                 dh.Deserialize(mlst[0]);
             }
             mlst = new List <MemoryStream>();
             //open peaks
             if (ph != null && file.ReadContent(1, out mlst))
             {
                 ph.DeserializePeaks(mlst[0]);
             }
             mlst = new List <MemoryStream>();
             ////open operates
             //if (ph != null && file.ReadContent(2, out mlst))
             //    ph.DeserializeOperates(mlst[0]);
             //open Detect Peak Parameter
             if (dpp != null && file.ReadContent(2, out mlst))
             {
                 dpp.Deserialize(mlst[0]);
             }
             return(true);
         }
         finally
         {
             file.CloseFile();
         }
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex);
         return(false);
     }
 }
Beispiel #5
0
        /// <summary>
        /// 根据阀值重新判峰
        /// </summary>
        /// <param name="winwidth">判峰宽度</param>
        /// <returns></returns>
        public bool ReCheckPeak(DetectPeakParameter dpp)
        {
            try
            {
                if (dpp == null)
                {
                    ReCheckPeak();
                    return(true);
                }
                if (_peakcheckor == null)
                {
                    _peakcheckor = new PeakLocationManager();
                    _peakcheckor.PeakLocationParam.LocationType        = LocationType.TraditionWithMerging;
                    _peakcheckor.PeakLocationParam.SG_Order            = dpp.SG_Order;            //3;
                    _peakcheckor.PeakLocationParam.SG_SideWindowLength = dpp.SG_SideWindowLength; //20;
                    _peakcheckor.PeakLocationParam.TimeSpan            = dpp.TimeSpan;            //1f / 20;
                    _peakcheckor.Execute();
                    _peakcheckor.OnPeakFound += new PeakFoundEvent.PeakLocationEventHandler(OnPeakFound);
                }
                _peakcheckor.PeakLocationParam.StartSLope     = dpp.StartSlope;
                _peakcheckor.PeakLocationParam.SampleInterval = dpp.CheckLevel;
                _peakcheckor.PeakLocationParam.EndSLope       = dpp.EndSlope;
                _peakhelper.Flush();

                _peakcheckor.PeakLocationParam.SDNoiseAmplitude = 1f;
                _peakcheckor.PeakLocationParam.SourceData       = _datahelper.List.ToArray();
                _peakcheckor.Execute();

                Calculated = true;
                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex);
                return(false);
            }
        }
Beispiel #6
0
 /// <summary>
 /// 保存峰数据
 /// </summary>
 /// <param name="filename"></param>
 /// <param name="lst"></param>
 /// <returns></returns>
 public static bool SetGraphData(string filename, List <Peak> lst)
 {
     try
     {
         //open points
         DataHelper dh = new DataHelper();
         //open peaks
         PeakHelper ph = new PeakHelper();
         //open detectpeakparameter
         DetectPeakParameter dpp = new DetectPeakParameter();
         if (!DoOpen(filename, dh, ph, dpp))
         {
             return(false);
         }
         ph.Peaks.Clear();
         ph.Peaks.AddRange(lst);
         return(DoSave(filename, dh, ph, dpp));
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex);
         return(false);
     }
 }