Пример #1
0
 private static void InitParameterDict()
 {
     mParameters = new Dictionary<string, FlyParameter>();
     mCaptionParameters = new Dictionary<string, FlyParameter>();
     
     XmlDocument doc = new XmlDocument();
     doc.Load("FlyParameter.xml");
         //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);
     }
 }
Пример #2
0
        /// <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;
        }