OSDN Git Service

UBXパケットの追加,ECEFからLLH座標系への変換で高さも反映するように変更
[yubeshi/yubeshi.git] / Yubeshi / Ubx / NavPosEcef.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 NavPosEccf : Packet\r
15     {\r
16         #region constructors\r
17 \r
18         public NavPosEccf(byte[] sentence, int length)\r
19             : base(sentence, length)\r
20         {\r
21             ID = MessageID.NavPosEcef;\r
22 \r
23             Raw = new byte[length + 8];\r
24             Array.Copy(sentence, Raw, Raw.Length);\r
25             \r
26             uint tow = BitConverter.ToUInt32(sentence, 6 + 0);\r
27             TimeOfWeek = tow * 1e-3m;\r
28             int x = BitConverter.ToInt32(sentence, 6 + 4);\r
29             int y = BitConverter.ToInt32(sentence, 6 + 8);\r
30             int z = BitConverter.ToInt32(sentence, 6 + 12);\r
31             uint acc = BitConverter.ToUInt32(sentence, 6 + 16);\r
32             Position = new EcefCoordinate(x, y, z, acc);\r
33             CheckSum = BitConverter.ToUInt16(sentence, sentence.Length - 2);\r
34         }\r
35 \r
36         #endregion\r
37 \r
38         #region properties\r
39 \r
40         public decimal TimeOfWeek\r
41         {\r
42             get;\r
43             private set;\r
44         }\r
45 \r
46         public EcefCoordinate Position\r
47         {\r
48             get;\r
49             private set;\r
50         }\r
51 \r
52         #endregion\r
53 \r
54         #region public methods\r
55 \r
56         public static bool TryParse(byte[] sentence, out Packet packet)\r
57         {\r
58             return TryParse(sentence, out packet, \r
59                                             MessageID.NavPosEcef, 20, Build);\r
60         }\r
61 \r
62         #endregion\r
63 \r
64         #region private methods\r
65 \r
66         private static Packet Build(byte[] sentence, int length)\r
67         {\r
68             return new NavPosEccf(sentence, length);\r
69         }\r
70 \r
71         #endregion\r
72     }\r
73 }\r