private static void InitParameterDict()
 {
     mParameters = new Dictionary<string, FlyParameter>();
     mCaptionParameters = new Dictionary<string, FlyParameter>();
     
     XmlDocument doc = new XmlDocument();
     doc.Load(Application.StartupPath + "\\FlyParameter.xml");
     XmlNodeList nodes = doc.DocumentElement.SelectNodes("Parameter");
     foreach (XmlNode n in nodes)
     {
          FlyParameter fp=new FlyParameter();
          fp.Index = Convert.ToInt32(n.Attributes["Index"].Value);
          fp.SubIndex = Convert.ToInt32(n.Attributes["SubIndex"].Value);
          fp.Unit = n.Attributes["Unit"].Value;
          if (fp.Unit == "")
          {
              fp.Caption = n.Attributes["Caption"].Value;
          }
          else
              fp.Caption = n.Attributes["Caption"].Value + "(" + fp.Unit + ")";                 
          fp.Frequence = Convert.ToInt32(n.Attributes["Frequence"].Value);
          mParameters.Add(fp.ID, fp);
          mCaptionParameters.Add(fp.Caption, fp);
     }
 }
        public void AddCurve(FlyParameter parameter, List<float> data)
        {
            this.Parameter = parameter;
            this.mdata = data;

            CtrCurve curve = this.ctrCurve1;
            curve.GetParameterObject = this;
            curve.Height = 200;
            curve.Dock = DockStyle.Top;
            NPlot.LineList lineList = new NPlot.LineList(parameter, data);
            curve.SuspendLayout();
            curve.InitCurve();
            curve.DrawCurve(lineList, 0, lineList.EndNum);
            curve.Parameters.Add(parameter);
            curve.ResumeLayout();
            curve.BringToFront();
        }
        /// <summary>
        /// 动态增加图表控件
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="data"></param>
        private void AddCurve(FlyParameter parameter, List<float> data, List<int> happenTimes,int duration)
        {
            CtrCurve curve = new CtrCurve();
            curve.GetParameterObject = this;
            curve.Height = 200;
            curve.Dock = DockStyle.Top;
            NPlot.LineList lineList = new NPlot.LineList(parameter, data);
            curve.SuspendLayout();
            curve.InitCurve();
            curve.DrawCurve(lineList, 0, lineList.EndNum);
            curve.Parameters.Add(parameter);

            //添加红线(故障的发生时间)
            List<VerticalLine> vlines = GetVerticalLines(happenTimes, duration);
            if (vlines != null)
            {
                curve.AddVerticalLines(vlines);
            }

            this.pnlContainer.Controls.Add(curve);
            curve.ResumeLayout();
            curve.BringToFront();

            curve.CtrCurveClick += new CtrCurveClickEvent(curve_CtrCurveClick);
            //curve.CurveInteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(curve_CurveInteractionOccured);
            curve.RestoreStatusClick += new EventHandler(curve_RestoreStatusClick);

            this.mCtrCurves.Add(curve);
        }
        /// <summary>
        /// 读取某一秒的一个飞参数据
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="second">第几秒</param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        public static float[] ReadFlyParameter(BinaryReader reader, int second, PHYHeader header, FlyParameter parameter)
        {
            //设置要读取的飞参的起始位置
            reader.BaseStream.Position = header.PhyValueAddr + (second - 1) * PARAM_LENGTH * header.PNum + (parameter.Index - 1) * PARAM_LENGTH;

            float[] values = new float[parameter.Frequence];
            for (int i = 0; i < parameter.Frequence; i++)
            {
                if (parameter.SubIndex == -1)
                    values[i] = reader.ReadSingle();
                else
                    values[i] = Convert.ToSingle(BaseFunction.GetBit((int)reader.ReadSingle(), parameter.SubIndex)); 
            }
            return values;
        }