OSDN Git Service

NAVパケットの整理・スタブ作成
[yubeshi/yubeshi.git] / Yubeshi / Ubx / NavPosLlh.cs
1 /*\r
2  *      Yubeshi GPS Parser\r
3  *\r
4  *      This software is distributed under a zlib-style license.\r
5  *      See license.txt for more information.\r
6  */\r
7 \r
8 using System;\r
9 using System.Collections.Generic;\r
10 using System.Text;\r
11 \r
12 namespace Yubeshi.Ubx\r
13 {\r
14     public class NavPosLlh : Packet\r
15     {\r
16         #region constructors\r
17 \r
18         public NavPosLlh(byte[] sentence, int length)\r
19             : base(sentence, length)\r
20         {\r
21             ID = MessageID.NavPosLlh;\r
22         }\r
23 \r
24         #endregion\r
25 \r
26         #region properties\r
27 \r
28         public decimal TimeOfWeek\r
29         {\r
30             get\r
31             {\r
32                 return BitConverter.ToUInt32(Raw, 6 + 0) * 1e-3m;\r
33             }\r
34         }\r
35 \r
36         public GeodeticCoordinate Position\r
37         {\r
38             get\r
39             {\r
40                 Degree lon = BitConverter.ToInt32(Raw, 6 + 4) * 1e-7;\r
41                 Degree lat = BitConverter.ToInt32(Raw, 6 + 8) * 1e-7;\r
42                 double h = BitConverter.ToUInt32(Raw, 6 + 12);\r
43                 return new GeodeticCoordinate(lon, lat, h);\r
44             }\r
45         }\r
46 \r
47         public double MslHeight\r
48         {\r
49             get\r
50             {\r
51                 return BitConverter.ToUInt32(Raw, 6 + 16);\r
52             }\r
53         }\r
54 \r
55         public double HorizonalAccuracy\r
56         {\r
57             get\r
58             {\r
59                 return BitConverter.ToUInt32(Raw, 6 + 20) * 1e-3;\r
60             }\r
61         }\r
62 \r
63         public double VerticalAccuracy\r
64         {\r
65             get\r
66             {\r
67                 return BitConverter.ToUInt32(Raw, 6 + 24) * 1e-3;\r
68             }\r
69         }\r
70         #endregion\r
71 \r
72         #region public methods\r
73 \r
74         public static bool TryParse(byte[] sentence, out UnknownPacket packet)\r
75         {\r
76             return TryParse(sentence, out packet, \r
77                                             MessageID.NavPosLlh, 28, Build);\r
78         }\r
79 \r
80         #endregion\r
81 \r
82         #region private methods\r
83 \r
84         private static Packet Build(byte[] sentence, int length)\r
85         {\r
86             return new NavPosLlh(sentence, length);\r
87         }\r
88 \r
89         #endregion\r
90     }\r
91 }\r