当前位置: 首页>>代码示例>>C#>>正文


C# LogEntry.GetField方法代码示例

本文整理汇总了C#中LogEntry.GetField方法的典型用法代码示例。如果您正苦于以下问题:C# LogEntry.GetField方法的具体用法?C# LogEntry.GetField怎么用?C# LogEntry.GetField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogEntry的用法示例。


在下文中一共展示了LogEntry.GetField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LogEntryGPS

 public LogEntryGPS(LogEntry entry)
 {
     if (entry.HasField("TimeUS"))
     {
         // perhaps it is the old format with GWk and TimeUS
         // "QBIHBcLLeeEefB"
         GPSTime = entry.GetField<UInt64>("TimeUS"); // Q
         //byte Status = entry.GetField<byte>("Status"); // B
         //uint GMS = entry.GetField<UInt32>("GMS"); // I
         ushort GWk = entry.GetField<UInt16>("GWk"); // H
         nSat = entry.GetField<byte>("NSats"); // B
         EPH = (float)entry.GetField<double>("HDop"); // c
         Lat = entry.GetField<double>("Lat"); // L
         Lon = entry.GetField<double>("Lng"); // L
         //double RAlt = entry.GetField<double>("RAlt"); // e
         Alt = (float)entry.GetField<double>("Alt"); // e
         //double spd = entry.GetField<double>("Spd"); // E
         //double gcrs = entry.GetField<float>("GCrs"); // e
         //double vz = entry.GetField<float>("VZ"); // f
         //byte u = entry.GetField<byte>("U"); // B
     }
     else if (entry.HasField("GPSTime"))
     {
         GPSTime = entry.GetField<UInt64>("GPSTime");
         Fix = entry.GetField<byte>("Fix");
         EPH = entry.GetField<float>("EPH");
         EPV = entry.GetField<float>("EPV");
         Lat = (double)entry.GetField<Int32>("Lat") / 1E7;
         Lon = (double)entry.GetField<UInt64>("Lon") / 1E7;
         Alt = entry.GetField<float>("Alt");
         VelN = entry.GetField<float>("VelN");
         VelE = entry.GetField<float>("VelE");
         VelD = entry.GetField<float>("VelD");
         Cog = entry.GetField<float>("Cog");
         nSat = entry.GetField<byte>("nSat");
         SNR = entry.GetField<UInt16>("SNR");
         N = entry.GetField<UInt16>("N");
         J = entry.GetField<UInt16>("J");
     }
     else if (entry.HasField("time_usec"))
     {
         GPSTime = entry.GetField<UInt64>("time_usec") / 1000;
         Fix = entry.GetField<byte>("fix_type");
         EPH = entry.GetField<float>("eph");
         EPV = entry.GetField<float>("epv");
         Lat = (double)entry.GetField<Int32>("lat") / 1E7;
         Lon = (double)entry.GetField<UInt64>("lon") / 1E7;
         Alt = entry.GetField<float>("alt");
         VelN = entry.GetField<float>("Vel");
         Cog = entry.GetField<float>("cog");
         nSat = entry.GetField<byte>("satellites_visible");
     }
 }
开发者ID:Dronacharya-Org,项目名称:Dronacharya,代码行数:53,代码来源:Generated.cs

示例2: ReadRow

        object ReadRow(byte packettype, Stream br)
        {
            switch (packettype)
            {
                case 0x80: // FMT
                    ReadLogFormat(br);
                    return null;

                default:
                    string format = "";
                    string name = "";
                    int size = 0;

                    if (!generatedParser && GenerateParser)
                    {
                        StringWriter writer = new StringWriter();
                        GenerateLogEntryParser(writer);
                        Debug.WriteLine(writer.ToString());
                        generatedParser = true;
                    }

                    LogEntryFMT fmt = null;
                    if (packettypecache.ContainsKey(packettype))
                    {
                        fmt = packettypecache[packettype];
                        name = fmt.Name;
                        format = fmt.FormatString;
                        size = fmt.Length;
                    }

                    // didnt find a match, return unknown packet type
                    if (fmt == null)
                        return null;

                    int len = size - 3; // size - 3 = message - messagetype - (header *2)

                    if (buffer == null || buffer.Length < len)
                    {
                        buffer = new byte[len];
                    }
                    br.Read(buffer, 0, len);

                    MemoryStream ms = new MemoryStream(buffer, 0, len);
                    BinaryReader reader = new BinaryReader(ms);

                    LogEntry entry = new LogEntry()
                    {
                        Format = fmt,
                        Blob = ms.ToArray(),
                        Name = fmt.Name
                    };
                    if (name == "GPS")
                    {
                        ulong time = entry.GetField<ulong>("GPSTime");
                        if (time > 0)
                        {
                            this.currentTime = time;
                        }
                    }
                    entry.Timestamp = currentTime;

                    return entry;
            }
        }
开发者ID:Dronacharya-Org,项目名称:Dronacharya,代码行数:64,代码来源:PX4BinaryLog.cs


注:本文中的LogEntry.GetField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。