• R/O
  • HTTP
  • SSH
  • HTTPS

yubeshi: Commit

source codes and tests


Commit MetaInfo

Revisiond7bdae6dbdb5302593c916f5ea3d572cc74453aa (tree)
Time2011-02-24 21:20:02
Authorkimikage <kimikage_ceo@hotm...>
Commiterkimikage

Log Message

境界チェック不具合修正,UBX特化の座標コンストラクタ廃止,パケット実装の拡充と修正

Change Summary

Incremental Difference

--- a/Yubeshi/EcefCoordinate.cs
+++ b/Yubeshi/EcefCoordinate.cs
@@ -35,18 +35,6 @@ namespace Yubeshi
3535 Z = z;
3636 Accuracy = accuracy;
3737 }
38-
39- /// <summary>
40- ///
41- /// </summary>
42- /// <param name="x">ECEF X coordinate in cm</param>
43- /// <param name="y">ECEF Y coordinate in cm</param>
44- /// <param name="z">ECEF Z coordinate in cm</param>
45- /// <param name="accuracy">3D Position Accuracy Estimate in cm</param>
46- public EcefCoordinate(int x, int y, int z, uint accuracy)
47- : this(x * 0.01, y * 0.01, z * 0.01, accuracy * 0.01)
48- {
49- }
5038 #endregion
5139
5240 #region properties
--- a/Yubeshi/EcefVelocity.cs
+++ b/Yubeshi/EcefVelocity.cs
@@ -22,17 +22,6 @@ namespace Yubeshi
2222 Accuracy = accuracy;
2323 }
2424
25- /// <summary>
26- ///
27- /// </summary>
28- /// <param name="e">ENU E velocity in cm/s</param>
29- /// <param name="n">ENU N velocity in cm/s</param>
30- /// <param name="u">ENU U velocity in cm/s</param>
31- /// <param name="accuracy">Speed Accuracy Estimate in cm/s</param>
32- public EcefVelocity(int e, int n, int u, uint accuracy)
33- : this(e * 0.01, n * 0.01, u * 0.01, accuracy * 0.01)
34- {
35- }
3625 #endregion
3726
3827 #region properties
--- a/Yubeshi/EnuVelocity.cs
+++ b/Yubeshi/EnuVelocity.cs
@@ -27,11 +27,6 @@ namespace Yubeshi
2727 Origin = null;
2828 }
2929
30- public EnuVelocity(int e, int n, int u)
31- : this(e * 0.01, n * 0.01, u * 0.01)
32- {
33- }
34-
3530 #endregion
3631
3732 #region properties
--- a/Yubeshi/Ubx/AidAlm.cs
+++ b/Yubeshi/Ubx/AidAlm.cs
@@ -20,14 +20,14 @@ namespace Yubeshi.Ubx
2020 {
2121 }
2222
23- public AidAlm(uint svId)
23+ public AidAlm(uint svID)
2424 : base(
2525 new byte[]
2626 {
2727 Packet.SyncCharacter1, Packet.SyncCharacter2,
2828 0x0B, 0x30, // ID
2929 0x01, 0x00, // length
30- (byte)svId, // svid
30+ (byte)svID, // svid
3131 0x00, 0x00 // checksum
3232 })
3333 {
@@ -53,7 +53,7 @@ namespace Yubeshi.Ubx
5353
5454 #region properties
5555
56- public uint SvId
56+ public uint SvID
5757 {
5858 get
5959 {
--- a/Yubeshi/Ubx/MonHw2.cs
+++ b/Yubeshi/Ubx/MonHw2.cs
@@ -38,7 +38,7 @@ namespace Yubeshi.Ubx
3838 {
3939 get
4040 {
41- return (((int)Raw[6 + 0] << 24) >> 24) / 128.0;
41+ return (sbyte)Raw[6 + 0] / 128.0;
4242 }
4343 }
4444
@@ -54,7 +54,7 @@ namespace Yubeshi.Ubx
5454 {
5555 get
5656 {
57- return (((int)Raw[6 + 2] << 24) >> 24) / 128.0;
57+ return (sbyte)Raw[6 + 2] / 128.0;
5858 }
5959 }
6060
--- a/Yubeshi/Ubx/NavDop.cs
+++ b/Yubeshi/Ubx/NavDop.cs
@@ -36,7 +36,7 @@ namespace Yubeshi.Ubx
3636 {
3737 get
3838 {
39- return BitConverter.ToUInt16(Raw, 6 + 4) * 1e-2;
39+ return BitConverter.ToUInt16(Raw, 6 + 4) * 0.01;
4040 }
4141 }
4242
@@ -44,7 +44,7 @@ namespace Yubeshi.Ubx
4444 {
4545 get
4646 {
47- return BitConverter.ToUInt16(Raw, 6 + 6) * 1e-2;
47+ return BitConverter.ToUInt16(Raw, 6 + 6) * 0.01;
4848 }
4949 }
5050
@@ -52,7 +52,7 @@ namespace Yubeshi.Ubx
5252 {
5353 get
5454 {
55- return BitConverter.ToUInt16(Raw, 6 + 8) * 1e-2;
55+ return BitConverter.ToUInt16(Raw, 6 + 8) * 0.01;
5656 }
5757 }
5858
@@ -60,7 +60,7 @@ namespace Yubeshi.Ubx
6060 {
6161 get
6262 {
63- return BitConverter.ToUInt16(Raw, 6 + 10) * 1e-2;
63+ return BitConverter.ToUInt16(Raw, 6 + 10) * 0.01;
6464 }
6565 }
6666
@@ -68,7 +68,7 @@ namespace Yubeshi.Ubx
6868 {
6969 get
7070 {
71- return BitConverter.ToUInt16(Raw, 6 + 12) * 1e-2;
71+ return BitConverter.ToUInt16(Raw, 6 + 12) * 0.01;
7272 }
7373 }
7474
@@ -76,7 +76,7 @@ namespace Yubeshi.Ubx
7676 {
7777 get
7878 {
79- return BitConverter.ToUInt16(Raw, 6 + 14) * 1e-2;
79+ return BitConverter.ToUInt16(Raw, 6 + 14) * 0.01;
8080 }
8181 }
8282
@@ -84,7 +84,7 @@ namespace Yubeshi.Ubx
8484 {
8585 get
8686 {
87- return BitConverter.ToUInt16(Raw, 6 + 16) * 1e-2;
87+ return BitConverter.ToUInt16(Raw, 6 + 16) * 0.01;
8888 }
8989 }
9090
--- a/Yubeshi/Ubx/NavPosEcef.cs
+++ b/Yubeshi/Ubx/NavPosEcef.cs
@@ -39,8 +39,8 @@ namespace Yubeshi.Ubx
3939 int x = BitConverter.ToInt32(Raw, 6 + 4);
4040 int y = BitConverter.ToInt32(Raw, 6 + 8);
4141 int z = BitConverter.ToInt32(Raw, 6 + 12);
42- uint acc = BitConverter.ToUInt32(Raw, 6 + 16);
43- return new EcefCoordinate(x, y, z, acc);
42+ double acc = BitConverter.ToUInt32(Raw, 6 + 16) * 0.01;
43+ return new EcefCoordinate(x * 0.01, y * 0.01, z * 0.01, acc);
4444 }
4545 }
4646
--- a/Yubeshi/Ubx/NavSbas.cs
+++ b/Yubeshi/Ubx/NavSbas.cs
@@ -14,6 +14,23 @@ namespace Yubeshi.Ubx
1414 public class NavSbas : Packet
1515 {
1616 #region type definitions
17+
18+ public enum SbasMode : byte
19+ {
20+ Disabled = 0,
21+ IntegrityEnabled = 1,
22+ TestModeEnabled = 3,
23+ }
24+
25+ public enum SbasSystem : sbyte
26+ {
27+ Unknown = -1,
28+ Waas = 0,
29+ Egnos = 1,
30+ Msas = 2,
31+ Gps = 16,
32+ }
33+
1734 public struct SbasStatus
1835 {
1936 private byte[] Raw;
@@ -39,6 +56,43 @@ namespace Yubeshi.Ubx
3956 }
4057 }
4158
59+ public int SbasID
60+ {
61+ get
62+ {
63+ return Raw[6 + 4];
64+ }
65+ }
66+
67+ public SbasMode Mode
68+ {
69+ get
70+ {
71+ return (SbasMode)Raw[6 + 5];
72+ }
73+ }
74+
75+ public SbasSystem System
76+ {
77+ get
78+ {
79+ return (SbasSystem)Raw[6 + 6];
80+ }
81+ }
82+
83+ public int NumberOfSvData
84+ {
85+ get
86+ {
87+ return Raw[6 + 8];
88+ }
89+ }
90+
91+ public SbasStatus[] Status
92+ {
93+ get;
94+ private set;
95+ }
4296 #endregion
4397
4498 #region public methods
@@ -46,7 +100,7 @@ namespace Yubeshi.Ubx
46100 public static bool TryParse(byte[] sentence, out UnknownPacket packet)
47101 {
48102 packet = null;
49- if (sentence.Length < 12)
103+ if (sentence.Length < 20)
50104 {
51105 return false;
52106 }
--- a/Yubeshi/Ubx/NavSol.cs
+++ b/Yubeshi/Ubx/NavSol.cs
@@ -50,7 +50,7 @@ namespace Yubeshi.Ubx
5050 }
5151 }
5252
53- public GpsFixType PositionFixType
53+ public GpsFixType FixType
5454 {
5555 get
5656 {
@@ -73,8 +73,8 @@ namespace Yubeshi.Ubx
7373 int x = BitConverter.ToInt32(Raw, 6 + 12);
7474 int y = BitConverter.ToInt32(Raw, 6 + 16);
7575 int z = BitConverter.ToInt32(Raw, 6 + 20);
76- uint acc = BitConverter.ToUInt32(Raw, 6 + 24);
77- return new EcefCoordinate(x, y, z, acc);
76+ double acc = BitConverter.ToUInt32(Raw, 6 + 24) * 0.01;
77+ return new EcefCoordinate(x * 0.01, y * 0.01, z * 0.01, acc);
7878 }
7979 }
8080
--- a/Yubeshi/Ubx/NavStatus.cs
+++ b/Yubeshi/Ubx/NavStatus.cs
@@ -17,13 +17,22 @@ namespace Yubeshi.Ubx
1717 [Flags]
1818 public enum NavigationStatus : byte
1919 {
20-
20+ GpsFixOk = 0x01,
21+ DgpsFix = 0x02,
22+ WeekNumberValid = 0x04,
23+ TimeOfWeekValid = 0x08,
24+ }
25+
26+ public enum DifferentialStatus : byte
27+ {
28+ None = 0,
29+ PrPrr = 1,
30+ PrPrrCp = 2,
31+ HighAccuracyPrPrrCp = 3,
2132 }
2233 #endregion
2334
2435 #region fields
25-
26- private NavigationStatus flags;
2736
2837 #endregion
2938
@@ -38,10 +47,54 @@ namespace Yubeshi.Ubx
3847
3948 #region properties
4049
50+ public decimal TimeOfWeek
51+ {
52+ get
53+ {
54+ return BitConverter.ToUInt32(Raw, 6 + 0) * 1e-3m;
55+ }
56+ }
57+
4158 public GpsFixType PositionFixType
4259 {
43- get;
44- private set;
60+ get
61+ {
62+ return (GpsFixType)Raw[6 + 4];
63+ }
64+ }
65+
66+ public NavigationStatus NavigationStatusFlags
67+ {
68+ get
69+ {
70+ return (NavigationStatus)Raw[6 + 5];
71+ }
72+ }
73+
74+ public DifferentialStatus DgpsStatus
75+ {
76+ get
77+ {
78+ return (DifferentialStatus)(Raw[6 + 6] & 3);
79+ }
80+ }
81+
82+ public TimeSpan TimeToFirstFix
83+ {
84+ get
85+ {
86+ long ms = BitConverter.ToUInt32(Raw, 6 + 8);
87+ return new TimeSpan(ms * 10000); // 1e-3 / 100e-9
88+ }
89+ }
90+
91+ public TimeSpan TimeSinceStartup
92+ {
93+ get
94+ {
95+ long ms = BitConverter.ToUInt32(Raw, 6 + 12);
96+ return new TimeSpan(ms * 10000); // 1e-3 / 100e-9
97+ }
4598 }
4699
47100 #endregion
@@ -50,7 +103,8 @@ namespace Yubeshi.Ubx
50103
51104 public static bool TryParse(byte[] sentence, out UnknownPacket packet)
52105 {
53- return TryParse(sentence, out packet, MessageID.NavSol, 52, Build);
106+ return TryParse(sentence, out packet,
107+ MessageID.NavStatus, 16, Build);
54108 }
55109
56110 #endregion
@@ -59,7 +113,7 @@ namespace Yubeshi.Ubx
59113
60114 private static Packet Build(byte[] sentence, int length)
61115 {
62- return new NavSol(sentence, length);
116+ return new NavStatus(sentence, length);
63117 }
64118
65119 #endregion
--- a/Yubeshi/Ubx/NavSvInfo.cs
+++ b/Yubeshi/Ubx/NavSvInfo.cs
@@ -47,7 +47,7 @@ namespace Yubeshi.Ubx
4747 }
4848 }
4949
50- public int SatelliteId
50+ public int SatelliteID
5151 {
5252 get
5353 {
@@ -83,7 +83,7 @@ namespace Yubeshi.Ubx
8383 {
8484 get
8585 {
86- return ((int)(Raw[4] << 24)) >> 24;
86+ return (sbyte)(Raw[5]);
8787 }
8888 }
8989
@@ -164,7 +164,7 @@ namespace Yubeshi.Ubx
164164 public static bool TryParse(byte[] sentence, out UnknownPacket packet)
165165 {
166166 packet = null;
167- if (sentence.Length < 8)
167+ if (sentence.Length < 16)
168168 {
169169 return false;
170170 }
--- a/Yubeshi/Ubx/NavTimeUtc.cs
+++ b/Yubeshi/Ubx/NavTimeUtc.cs
@@ -13,6 +13,18 @@ namespace Yubeshi.Ubx
1313 {
1414 public class NavTimeUtc : Packet
1515 {
16+ #region type definitions
17+
18+ [Flags]
19+ public enum Validity : byte
20+ {
21+ TimeOfWeek = 0x01,
22+ WeekNumber = 0x02,
23+ Utc = 0x04,
24+ }
25+
26+ #endregion
27+
1628 #region constructors
1729
1830 public NavTimeUtc(byte[] sentence, int length)
@@ -48,16 +60,24 @@ namespace Yubeshi.Ubx
4860 {
4961 int y = BitConverter.ToUInt16(Raw, 6 + 12);
5062 int m = Raw[6 + 14];
51- int d = Raw[6 + 14];
52- int h = Raw[6 + 14];
53- int min = Raw[6 + 14];
54- int s = Raw[6 + 14];
63+ int d = Raw[6 + 15];
64+ int h = Raw[6 + 16];
65+ int min = Raw[6 + 17];
66+ int s = Raw[6 + 18];
5567 int ftow = BitConverter.ToInt32(Raw, 6 + 8);
5668 DateTime utc = new DateTime(y, m, d, h, min, s,
5769 DateTimeKind.Utc);
5870 return utc.AddTicks(ftow / 100);
5971 }
6072 }
73+
74+ public Validity ValidityFlag
75+ {
76+ get
77+ {
78+ return (Validity)Raw[19];
79+ }
80+ }
6181 #endregion
6282
6383 #region public methods
--- a/Yubeshi/Ubx/NavVelEcef.cs
+++ b/Yubeshi/Ubx/NavVelEcef.cs
@@ -39,8 +39,8 @@ namespace Yubeshi.Ubx
3939 int x = BitConverter.ToInt32(Raw, 6 + 4);
4040 int y = BitConverter.ToInt32(Raw, 6 + 8);
4141 int z = BitConverter.ToInt32(Raw, 6 + 12);
42- uint acc = BitConverter.ToUInt32(Raw, 6 + 16);
43- return new EcefVelocity(x, y, z, acc);
42+ double acc = BitConverter.ToUInt32(Raw, 6 + 16) * 0.01;
43+ return new EcefVelocity(x * 0.01, y * 0.01, z * 0.01, acc);
4444 }
4545 }
4646
--- a/Yubeshi/Ubx/NavVelNed.cs
+++ b/Yubeshi/Ubx/NavVelNed.cs
@@ -39,7 +39,7 @@ namespace Yubeshi.Ubx
3939 int n = BitConverter.ToInt32(Raw, 6 + 4);
4040 int e = BitConverter.ToInt32(Raw, 6 + 8);
4141 int d = -BitConverter.ToInt32(Raw, 6 + 12);
42- return new EnuVelocity(e, n, -d);
42+ return new EnuVelocity(e * 0.01, n * 0.01, -d * 0.01);
4343 }
4444 }
4545
@@ -47,20 +47,40 @@ namespace Yubeshi.Ubx
4747 {
4848 get
4949 {
50- return BitConverter.ToUInt32(Raw, 6 + 16);
50+ return BitConverter.ToUInt32(Raw, 6 + 16) * 0.01;
5151 }
5252 }
5353
5454 public double GroundSpeed
5555 {
56- get;
57- private set;
56+ get
57+ {
58+ return BitConverter.ToUInt32(Raw, 6 + 20) * 0.01;
59+ }
5860 }
5961
6062 public Degree Heading
6163 {
62- get;
63- private set;
64+ get
65+ {
66+ return BitConverter.ToInt32(Raw, 6 + 24) * 1e-5;
67+ }
68+ }
69+
70+ public double SpeedAccuracy
71+ {
72+ get
73+ {
74+ return BitConverter.ToUInt32(Raw, 6 + 28) * 0.01;
75+ }
76+ }
77+
78+ public Degree HeadingAccuracy
79+ {
80+ get
81+ {
82+ return BitConverter.ToUInt32(Raw, 6 + 32) * 1e-5;
83+ }
6484 }
6585
6686 #endregion
--- a/Yubeshi/Ubx/Parser.cs
+++ b/Yubeshi/Ubx/Parser.cs
@@ -90,11 +90,11 @@ namespace Yubeshi.Ubx
9090 {
9191 return false;
9292 }
93- Packet.MessageID messageId =
93+ Packet.MessageID messageID =
9494 (Packet.MessageID)(sentence[2] << 8 | sentence[3]);
95- if (parsers.ContainsKey(messageId))
95+ if (parsers.ContainsKey(messageID))
9696 {
97- return parsers[messageId](sentence, out packet);
97+ return parsers[messageID](sentence, out packet);
9898 }
9999 return Unknown.TryParse(sentence, out packet);
100100 }
--- a/Yubeshi/Ubx/RxmAlm.cs
+++ b/Yubeshi/Ubx/RxmAlm.cs
@@ -20,14 +20,14 @@ namespace Yubeshi.Ubx
2020 {
2121 }
2222
23- public RxmAlm(uint svId)
23+ public RxmAlm(uint svID)
2424 : base(
2525 new byte[]
2626 {
2727 Packet.SyncCharacter1, Packet.SyncCharacter2,
2828 0x02, 0x30, // ID
2929 0x01, 0x00, // length
30- (byte)svId, // svid
30+ (byte)svID, // svid
3131 0x00, 0x00 // checksum
3232 })
3333 {
@@ -54,7 +54,7 @@ namespace Yubeshi.Ubx
5454
5555 #region properties
5656
57- public uint SvId
57+ public uint SvID
5858 {
5959 get
6060 {
--- a/Yubeshi/Ubx/RxmRaw.cs
+++ b/Yubeshi/Ubx/RxmRaw.cs
@@ -58,7 +58,7 @@ namespace Yubeshi.Ubx
5858 {
5959 get
6060 {
61- return ((int)(Raw[21] << 24)) >> 24; // SByte
61+ return (sbyte)Raw[21];
6262 }
6363 }
6464
@@ -66,7 +66,7 @@ namespace Yubeshi.Ubx
6666 {
6767 get
6868 {
69- return ((int)(Raw[22] << 24)) >> 24; // SByte
69+ return (sbyte)Raw[22];
7070 }
7171 }
7272
@@ -147,7 +147,7 @@ namespace Yubeshi.Ubx
147147 public static bool TryParse(byte[] sentence, out UnknownPacket packet)
148148 {
149149 packet = null;
150- if (sentence.Length < 8)
150+ if (sentence.Length < 16)
151151 {
152152 return false;
153153 }
--- a/Yubeshi/Ubx/RxmSfrB.cs
+++ b/Yubeshi/Ubx/RxmSfrB.cs
@@ -37,7 +37,7 @@ namespace Yubeshi.Ubx
3737 }
3838 }
3939
40- public int SatelliteId
40+ public int SatelliteID
4141 {
4242 get
4343 {
Show on old repository browser