OSDN Git Service

初期コミット
authorkimikage <kimikage_ceo@hotmail.com>
Tue, 21 Dec 2010 09:01:06 +0000 (18:01 +0900)
committerkimikage <kimikage_ceo@hotmail.com>
Tue, 21 Dec 2010 09:01:06 +0000 (18:01 +0900)
26 files changed:
.gitignore [new file with mode: 0755]
Yubeshi.sln [new file with mode: 0755]
Yubeshi/Coordinate.cs [new file with mode: 0755]
Yubeshi/Nmea/GpDtm.cs [new file with mode: 0755]
Yubeshi/Nmea/GpGbs.cs [new file with mode: 0755]
Yubeshi/Nmea/GpGga.cs [new file with mode: 0755]
Yubeshi/Nmea/GpGll.cs [new file with mode: 0755]
Yubeshi/Nmea/GpGrs.cs [new file with mode: 0755]
Yubeshi/Nmea/GpGsa.cs [new file with mode: 0755]
Yubeshi/Nmea/GpGst.cs [new file with mode: 0755]
Yubeshi/Nmea/GpGsv.cs [new file with mode: 0755]
Yubeshi/Nmea/GpRmc.cs [new file with mode: 0755]
Yubeshi/Nmea/Packet.cs [new file with mode: 0755]
Yubeshi/Nmea/Parser.cs [new file with mode: 0755]
Yubeshi/Parser.cs [new file with mode: 0755]
Yubeshi/Properties/AssemblyInfo.cs [new file with mode: 0755]
Yubeshi/Ubx/Packet.cs [new file with mode: 0755]
Yubeshi/UnknownPacket.cs [new file with mode: 0755]
Yubeshi/Yubeshi.csproj [new file with mode: 0755]
Yubeshi/app.config [new file with mode: 0755]
YubeshiTest/Nmea/PacketTest.cs [new file with mode: 0755]
YubeshiTest/ParserTest.cs [new file with mode: 0755]
YubeshiTest/Properties/AssemblyInfo.cs [new file with mode: 0755]
YubeshiTest/YubeshiTest.csproj [new file with mode: 0755]
YubeshiTest/app.config [new file with mode: 0755]
license.txt [new file with mode: 0755]

diff --git a/.gitignore b/.gitignore
new file mode 100755 (executable)
index 0000000..3f1191e
--- /dev/null
@@ -0,0 +1,12 @@
+*.bak\r
+*.tmp\r
+\r
+#for Visual Studio\r
+*.ncb\r
+*.suo\r
+*.user\r
+*.aps\r
+Yubeshi/bin\r
+Yubeshi/obj\r
+YubeshiTest/bin\r
+YubeshiTest/obj\r
diff --git a/Yubeshi.sln b/Yubeshi.sln
new file mode 100755 (executable)
index 0000000..bf2668a
--- /dev/null
@@ -0,0 +1,39 @@
+\r
+Microsoft Visual Studio Solution File, Format Version 10.00\r
+# Visual C# Express 2008\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Yubeshi", "Yubeshi\Yubeshi.csproj", "{EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}"\r
+EndProject\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YubeshiTest", "YubeshiTest\YubeshiTest.csproj", "{1173BFCF-CA10-433B-A8FF-B9C1148A3700}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB} = {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}\r
+       EndProjectSection\r
+EndProject\r
+Global\r
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+               Debug|Any CPU = Debug|Any CPU\r
+               Debug|x64 = Debug|x64\r
+               Release|Any CPU = Release|Any CPU\r
+               Release|x64 = Release|x64\r
+       EndGlobalSection\r
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Debug|x64.ActiveCfg = Debug|Any CPU\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Debug|x64.Build.0 = Debug|Any CPU\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Release|x64.ActiveCfg = Release|x64\r
+               {EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}.Release|x64.Build.0 = Release|x64\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Debug|x64.ActiveCfg = Debug|Any CPU\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Debug|x64.Build.0 = Debug|Any CPU\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Release|Any CPU.Build.0 = Release|Any CPU\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Release|x64.ActiveCfg = Release|x64\r
+               {1173BFCF-CA10-433B-A8FF-B9C1148A3700}.Release|x64.Build.0 = Release|x64\r
+       EndGlobalSection\r
+       GlobalSection(SolutionProperties) = preSolution\r
+               HideSolutionNode = FALSE\r
+       EndGlobalSection\r
+EndGlobal\r
diff --git a/Yubeshi/Coordinate.cs b/Yubeshi/Coordinate.cs
new file mode 100755 (executable)
index 0000000..7706363
--- /dev/null
@@ -0,0 +1,40 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi\r
+{\r
+    public class Coordinate\r
+    {\r
+        public Coordinate(string latitude, string ns, \r
+                                    string longitude, string ew)\r
+        {\r
+            decimal latRaw = Decimal.Parse(latitude);\r
+            decimal lngRaw = Decimal.Parse(longitude);\r
+            decimal lat = Math.Floor(latRaw / 100m) + (latRaw % 100m) / 60m;\r
+            decimal lng = Math.Floor(lngRaw / 100m) + (lngRaw % 100m) / 60m;\r
+            Latitude  = (ns == "S") ? -lat : lat;\r
+            Longitude = (ns == "W") ? -lng : lng;\r
+        }\r
+\r
+        #region properties\r
+        public decimal Latitude\r
+        {\r
+            get;\r
+            set;\r
+        }\r
+        public decimal Longitude\r
+        {\r
+            get;\r
+            set;\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/Yubeshi/Nmea/GpDtm.cs b/Yubeshi/Nmea/GpDtm.cs
new file mode 100755 (executable)
index 0000000..95e3abf
--- /dev/null
@@ -0,0 +1,68 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    public class GpDtm : Packet\r
+    {\r
+        #region fields\r
+\r
+        private static readonly byte[] header;\r
+        private const int elementNum = 7;\r
+\r
+        #endregion\r
+\r
+        #region constructors\r
+        \r
+        static GpDtm()\r
+        {\r
+            header = Encoding.ASCII.GetBytes("$GPDTM,");\r
+        }\r
+        \r
+        public GpDtm()\r
+        {\r
+        }\r
+\r
+        public GpDtm(byte[] sentence)\r
+            : this(sentence, GetElements(sentence, elementNum))\r
+        {\r
+        }\r
+\r
+        private GpDtm(byte[] sentence, Elements elements)\r
+        { \r
+\r
+        }\r
+\r
+        #endregion\r
+\r
+        #region properties\r
+\r
+        #endregion\r
+\r
+        #region public method\r
+\r
+        public static bool TryParse(byte[] sentence, out Packet packet)\r
+        {\r
+            return TryParse(sentence, out packet, header, elementNum, Build);\r
+        }\r
+\r
+        #endregion\r
+\r
+        #region private method\r
+\r
+        private static Packet Build(byte[] sentence, Elements elements)\r
+        {\r
+            return new GpDtm(sentence, elements);\r
+        }\r
+\r
+        #endregion\r
+    }\r
+}\r
diff --git a/Yubeshi/Nmea/GpGbs.cs b/Yubeshi/Nmea/GpGbs.cs
new file mode 100755 (executable)
index 0000000..c479ec3
--- /dev/null
@@ -0,0 +1,20 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     \r
+    /// </summary>\r
+    public class GpGbs : Packet\r
+    {\r
+    }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/GpGga.cs b/Yubeshi/Nmea/GpGga.cs
new file mode 100755 (executable)
index 0000000..5c61eb0
--- /dev/null
@@ -0,0 +1,125 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     Global Positioning System Fix Data\r
+    /// </summary>\r
+       public class GpGga : Packet\r
+    {\r
+        #region type definitions\r
+        public enum FixQualityClass\r
+        {\r
+            Invalid = 0,\r
+            Gps = 1,\r
+            Dgps = 2,\r
+            Pps = 3,\r
+            Rtk = 4,\r
+            FloatRtk = 5,\r
+            Estimated = 6,\r
+        }\r
+        #endregion\r
+        #region fields\r
+\r
+        private static readonly byte[] header;\r
+        private const int elementNum = 13;\r
+\r
+        #endregion\r
+\r
+        #region constructors\r
+\r
+        static GpGga()\r
+        {\r
+            header = Encoding.ASCII.GetBytes("$GPGGA,");\r
+        }\r
+\r
+               public GpGga()\r
+               {\r
+               }\r
+\r
+               public GpGga(byte[] sentence)\r
+            : this(sentence, GetElements(sentence, elementNum))\r
+               {\r
+        }\r
+\r
+        private GpGga(byte[] sentence, Elements elements)\r
+        {\r
+            Raw = new byte[elements.PacketLength];\r
+            Array.Copy(sentence, Raw, elements.PacketLength);\r
+\r
+            TimeOfFix = ParseTime(elements.Values[0]);\r
+            Position = new Coordinate(elements.Values[1], elements.Values[2],\r
+                                    elements.Values[3], elements.Values[4]);\r
+            FixQuality = (FixQualityClass)Int32.Parse(elements.Values[5]);\r
+            TrackedSatellites = Int32.Parse(elements.Values[6]);\r
+            Dilution = Decimal.Parse(elements.Values[7]);\r
+            CheckSum = elements.CheckSum;\r
+        }\r
+\r
+        #endregion\r
+\r
+        #region properties\r
+\r
+        public TimeSpan TimeOfFix\r
+        {\r
+            get;\r
+            private set;\r
+        }\r
+        \r
+        public Coordinate Position\r
+        {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public FixQualityClass FixQuality\r
+        {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public int TrackedSatellites\r
+        {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+        public decimal Dilution\r
+        {\r
+            get;\r
+            private set;\r
+        }\r
+\r
+\r
+        #endregion\r
+\r
+\r
+        public static bool TryParse(byte[] sentence, out Packet packet)\r
+        {\r
+            return TryParse(sentence, out packet, header, elementNum, Build);\r
+        }\r
+\r
+        private static Packet Build(byte[] sentence, Elements elements)\r
+        {\r
+            return new GpGga(sentence, elements);\r
+        }\r
+\r
+        private TimeSpan ParseTime(string time)\r
+        {\r
+            string h = time.Substring(0, 2);\r
+            string m = time.Substring(2, 2);\r
+            string s = time.Substring(4, 2);\r
+            return new TimeSpan(Int32.Parse(h), Int32.Parse(m), Int32.Parse(s));\r
+        }\r
+\r
+       }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/GpGll.cs b/Yubeshi/Nmea/GpGll.cs
new file mode 100755 (executable)
index 0000000..c25672c
--- /dev/null
@@ -0,0 +1,20 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     \r
+    /// </summary>\r
+    public class GpGll : Packet\r
+    {\r
+    }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/GpGrs.cs b/Yubeshi/Nmea/GpGrs.cs
new file mode 100755 (executable)
index 0000000..cca3a2a
--- /dev/null
@@ -0,0 +1,20 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     \r
+    /// </summary>\r
+    public class GpGrs : Packet\r
+    {\r
+    }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/GpGsa.cs b/Yubeshi/Nmea/GpGsa.cs
new file mode 100755 (executable)
index 0000000..92cffcd
--- /dev/null
@@ -0,0 +1,20 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     \r
+    /// </summary>\r
+    public class GpGsa : Packet\r
+    {\r
+    }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/GpGst.cs b/Yubeshi/Nmea/GpGst.cs
new file mode 100755 (executable)
index 0000000..9d4e5f6
--- /dev/null
@@ -0,0 +1,20 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     \r
+    /// </summary>\r
+    public class GpGst : Packet\r
+    {\r
+    }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/GpGsv.cs b/Yubeshi/Nmea/GpGsv.cs
new file mode 100755 (executable)
index 0000000..4008af0
--- /dev/null
@@ -0,0 +1,20 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     \r
+    /// </summary>\r
+    public class GpGsv : Packet\r
+    {\r
+    }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/GpRmc.cs b/Yubeshi/Nmea/GpRmc.cs
new file mode 100755 (executable)
index 0000000..73193e2
--- /dev/null
@@ -0,0 +1,20 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    /// <summary>\r
+    ///     \r
+    /// </summary>\r
+    public class GpRmc : Packet\r
+    {\r
+    }\r
+}
\ No newline at end of file
diff --git a/Yubeshi/Nmea/Packet.cs b/Yubeshi/Nmea/Packet.cs
new file mode 100755 (executable)
index 0000000..4982c88
--- /dev/null
@@ -0,0 +1,155 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    public abstract class Packet : Yubeshi.UnknownPacket\r
+    {\r
+        #region type definitions\r
+        protected delegate Packet PacketBuilder(\r
+                                        byte[] sentence, Elements elements);\r
+\r
+        protected class Elements\r
+        {\r
+            public string[] Values;\r
+            public int CheckSum;\r
+            public int PacketLength;\r
+        }\r
+        #endregion\r
+\r
+        #region fields\r
+\r
+        #endregion\r
+\r
+        #region constructors\r
+\r
+        public Packet()\r
+        { \r
+        }\r
+\r
+        public Packet(byte[] sentence)\r
+        {\r
+            Raw = sentence;\r
+        }\r
+\r
+        #endregion\r
+\r
+        #region properties\r
+\r
+        public int CheckSum\r
+        {\r
+            get;\r
+            protected set;\r
+        }\r
+        #endregion\r
+\r
+        #region public method\r
+\r
+        #endregion\r
+        #region protected method\r
+\r
+        protected static bool TryParse(byte[] sentence, out Packet packet, \r
+                                        byte[] header, int elementNum, \r
+                                                        PacketBuilder builder)\r
+        { \r
+            packet = null;\r
+            if (!Match(sentence, header))\r
+            {\r
+                return false;\r
+            }\r
+            Elements elements = GetElements(sentence, elementNum);\r
+            if (elements == null)\r
+            {\r
+                return false;\r
+            }\r
+            try\r
+            {\r
+                packet = builder(sentence, elements);\r
+            }\r
+            catch\r
+            {\r
+                return false;\r
+            }\r
+            return true;\r
+        }\r
+\r
+        protected static Elements GetElements(byte[] sentence, int elementNum)\r
+        {\r
+            string[] values = new string[elementNum];\r
+            int elementIndex = 0;\r
+            int lastCommaPos = 7;\r
+            for (int i = lastCommaPos; i < sentence.Length; ++i)\r
+            {\r
+                if (sentence[i] == ',')\r
+                {\r
+                    values[elementIndex++] = Encoding.ASCII.GetString(\r
+                                    sentence, lastCommaPos, i - lastCommaPos);\r
+                    lastCommaPos = i + 1;\r
+                    if (elementIndex == elementNum)\r
+                    {\r
+                        break;\r
+                    }\r
+                }\r
+            }\r
+            if (elementIndex != elementNum)\r
+            {\r
+                return null;\r
+            }\r
+\r
+            int length = lastCommaPos + 5;\r
+\r
+            if (sentence.Length < length)\r
+            {\r
+                return null;\r
+            }\r
+\r
+            if (sentence[lastCommaPos] != (byte)'*' || \r
+                sentence[lastCommaPos+3] != (byte)'\r' ||\r
+                sentence[lastCommaPos+4] != (byte)'\n')\r
+            {\r
+                return null;\r
+            }\r
+            int checksum1 = sentence[lastCommaPos+1];\r
+            int checksum2 = sentence[lastCommaPos+2];\r
+            if (checksum1 < '0' || checksum1 > '9')\r
+            {\r
+                return null;\r
+            }\r
+            if (checksum2 < '0' || checksum1 > '9')\r
+            {\r
+                return null;\r
+            }\r
+            \r
+            Elements elements = new Elements();\r
+            elements.Values = values;\r
+            elements.CheckSum = (checksum1 - '0') << 4 | (checksum2 - '0');\r
+            elements.PacketLength = length;\r
+            return elements;\r
+        }\r
+\r
+        protected static bool Match(byte[] sentence, byte[] header)\r
+        {\r
+            if (sentence.Length < header.Length)\r
+            {\r
+                return false;\r
+            }\r
+            for (int i = 0; i < header.Length; ++i)\r
+            {\r
+                if (header[i] != sentence[i])\r
+                {\r
+                    return false;\r
+                }\r
+            }\r
+            return true;\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/Yubeshi/Nmea/Parser.cs b/Yubeshi/Nmea/Parser.cs
new file mode 100755 (executable)
index 0000000..3a864f2
--- /dev/null
@@ -0,0 +1,25 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Nmea\r
+{\r
+    public class Parser : Yubeshi.Parser\r
+    {\r
+        #region public method\r
+\r
+        public bool TryParse(byte[] sentence, out Packet packet)\r
+        {\r
+            packet = new GpGga();\r
+            return false;\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/Yubeshi/Parser.cs b/Yubeshi/Parser.cs
new file mode 100755 (executable)
index 0000000..2beb51c
--- /dev/null
@@ -0,0 +1,17 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi\r
+{\r
+    public class Parser\r
+    {\r
+    }\r
+}\r
diff --git a/Yubeshi/Properties/AssemblyInfo.cs b/Yubeshi/Properties/AssemblyInfo.cs
new file mode 100755 (executable)
index 0000000..406a273
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。\r
+// アセンブリに関連付けられている情報を変更するには、\r
+// これらの属性値を変更してください。\r
+[assembly: AssemblyTitle("Yubeshi")]\r
+[assembly: AssemblyDescription("")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("Microsoft")]\r
+[assembly: AssemblyProduct("Yubeshi")]\r
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから \r
+// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、\r
+// その型の ComVisible 属性を true に設定してください。\r
+[assembly: ComVisible(false)]\r
+\r
+// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です\r
+[assembly: Guid("e2ff32dd-ca78-4cb8-996f-d9bf0dd64f2b")]\r
+\r
+// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を \r
+// 既定値にすることができます:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
diff --git a/Yubeshi/Ubx/Packet.cs b/Yubeshi/Ubx/Packet.cs
new file mode 100755 (executable)
index 0000000..cd3ae51
--- /dev/null
@@ -0,0 +1,17 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi.Ubx\r
+{\r
+    public class Packet : UnknownPacket\r
+    {\r
+    }\r
+}\r
diff --git a/Yubeshi/UnknownPacket.cs b/Yubeshi/UnknownPacket.cs
new file mode 100755 (executable)
index 0000000..ca3516e
--- /dev/null
@@ -0,0 +1,37 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+\r
+namespace Yubeshi\r
+{\r
+    public class UnknownPacket\r
+    {\r
+        #region constructors\r
+\r
+        public UnknownPacket()\r
+        { \r
+        }\r
+\r
+        public UnknownPacket(byte[] sentence)\r
+        {\r
+            Raw = sentence;\r
+        }\r
+        #endregion\r
+\r
+        #region properties\r
+\r
+        public byte[] Raw\r
+        {\r
+            get;\r
+            protected set;\r
+        }\r
+        #endregion\r
+    }\r
+}\r
diff --git a/Yubeshi/Yubeshi.csproj b/Yubeshi/Yubeshi.csproj
new file mode 100755 (executable)
index 0000000..332fa7c
--- /dev/null
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.30729</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}</ProjectGuid>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>Yubeshi</RootNamespace>\r
+    <AssemblyName>Yubeshi</AssemblyName>\r
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+    <TargetFrameworkSubset>\r
+    </TargetFrameworkSubset>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <OutputPath>bin\x64\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <DebugType>full</DebugType>\r
+    <PlatformTarget>x64</PlatformTarget>\r
+    <ErrorReport>prompt</ErrorReport>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">\r
+    <OutputPath>bin\x64\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <Optimize>true</Optimize>\r
+    <DebugType>pdbonly</DebugType>\r
+    <PlatformTarget>x64</PlatformTarget>\r
+    <ErrorReport>prompt</ErrorReport>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Coordinate.cs" />\r
+    <Compile Include="Nmea\Parser.cs" />\r
+    <Compile Include="Parser.cs" />\r
+    <Compile Include="Nmea\GpDtm.cs" />\r
+    <Compile Include="Nmea\GpGbs.cs" />\r
+    <Compile Include="Nmea\GpGga.cs" />\r
+    <Compile Include="Nmea\GpGll.cs" />\r
+    <Compile Include="Nmea\GpGrs.cs" />\r
+    <Compile Include="Nmea\GpGsa.cs" />\r
+    <Compile Include="Nmea\GpGst.cs" />\r
+    <Compile Include="Nmea\GpGsv.cs" />\r
+    <Compile Include="Nmea\GpRmc.cs" />\r
+    <Compile Include="Nmea\Packet.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+    <Compile Include="Ubx\Packet.cs" />\r
+    <Compile Include="UnknownPacket.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="app.config" />\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file
diff --git a/Yubeshi/app.config b/Yubeshi/app.config
new file mode 100755 (executable)
index 0000000..b7db281
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>\r
+<configuration>\r
+<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>\r
diff --git a/YubeshiTest/Nmea/PacketTest.cs b/YubeshiTest/Nmea/PacketTest.cs
new file mode 100755 (executable)
index 0000000..4d52a2b
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using NUnit.Framework;\r
+using Yubeshi.Nmea;\r
+\r
+namespace YubeshiTest.Nmea\r
+{\r
+\r
+    class PacketTest\r
+    {\r
+\r
+        static readonly byte[] gpdtm;\r
+        static readonly byte[] gpgbs;\r
+        static readonly byte[] gpgga;\r
+\r
+        static PacketTest()\r
+        {\r
+            Encoding ascii = Encoding.ASCII;\r
+\r
+            gpdtm = ascii.GetBytes("$GPDTM,W84,,0.000000,N,0.000000,E,0.0,W84*6F\r\n");\r
+            gpgga = ascii.GetBytes("$GPGGA,123519,4807.038,N,01131.000,E,1,08,0.9,545.4,M,46.9,M,,*47\r\n");\r
+        }\r
+\r
+        [Test]\r
+        public void GpDtmTest()\r
+        {\r
+            Packet p;\r
+            GpDtm.TryParse(gpdtm, out p);\r
+        }\r
+\r
+        [Test]\r
+        public void GpGgaTest()\r
+        {\r
+            Packet packet;\r
+            Assert.AreEqual(true, GpGga.TryParse(gpgga, out packet));\r
+            GpGga p = packet as GpGga;\r
+            Assert.AreEqual(new TimeSpan(12,35,19), p.TimeOfFix);\r
+            Assert.AreEqual(48.1173m, p.Position.Latitude);\r
+            Assert.AreEqual(691m / 60m, p.Position.Longitude);\r
+        }\r
+    }\r
+}\r
diff --git a/YubeshiTest/ParserTest.cs b/YubeshiTest/ParserTest.cs
new file mode 100755 (executable)
index 0000000..c054d17
--- /dev/null
@@ -0,0 +1,23 @@
+/*\r
+ *     Yubeshi GPS Parser\r
+ *\r
+ *     This software is distributed under a zlib-style license.\r
+ *     See license.txt for more information.\r
+ */\r
+\r
+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using NUnit.Framework;\r
+\r
+namespace YubeshiTest\r
+{\r
+    public class ParserTest\r
+    {\r
+        [Test]\r
+        public void Parse()\r
+        {\r
+        \r
+        }\r
+    }\r
+}\r
diff --git a/YubeshiTest/Properties/AssemblyInfo.cs b/YubeshiTest/Properties/AssemblyInfo.cs
new file mode 100755 (executable)
index 0000000..a33a353
--- /dev/null
@@ -0,0 +1,36 @@
+using System.Reflection;\r
+using System.Runtime.CompilerServices;\r
+using System.Runtime.InteropServices;\r
+\r
+// アセンブリに関する一般情報は以下の属性セットをとおして制御されます。\r
+// アセンブリに関連付けられている情報を変更するには、\r
+// これらの属性値を変更してください。\r
+[assembly: AssemblyTitle("YubeshiTest")]\r
+[assembly: AssemblyDescription("")]\r
+[assembly: AssemblyConfiguration("")]\r
+[assembly: AssemblyCompany("Microsoft")]\r
+[assembly: AssemblyProduct("YubeshiTest")]\r
+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]\r
+[assembly: AssemblyTrademark("")]\r
+[assembly: AssemblyCulture("")]\r
+\r
+// ComVisible を false に設定すると、その型はこのアセンブリ内で COM コンポーネントから \r
+// 参照不可能になります。COM からこのアセンブリ内の型にアクセスする場合は、\r
+// その型の ComVisible 属性を true に設定してください。\r
+[assembly: ComVisible(false)]\r
+\r
+// 次の GUID は、このプロジェクトが COM に公開される場合の、typelib の ID です\r
+[assembly: Guid("60f8beee-e74d-4598-8c1b-2ecedf6e09af")]\r
+\r
+// アセンブリのバージョン情報は、以下の 4 つの値で構成されています:\r
+//\r
+//      Major Version\r
+//      Minor Version \r
+//      Build Number\r
+//      Revision\r
+//\r
+// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を \r
+// 既定値にすることができます:\r
+// [assembly: AssemblyVersion("1.0.*")]\r
+[assembly: AssemblyVersion("1.0.0.0")]\r
+[assembly: AssemblyFileVersion("1.0.0.0")]\r
diff --git a/YubeshiTest/YubeshiTest.csproj b/YubeshiTest/YubeshiTest.csproj
new file mode 100755 (executable)
index 0000000..58202f7
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <PropertyGroup>\r
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+    <ProductVersion>9.0.30729</ProductVersion>\r
+    <SchemaVersion>2.0</SchemaVersion>\r
+    <ProjectGuid>{1173BFCF-CA10-433B-A8FF-B9C1148A3700}</ProjectGuid>\r
+    <OutputType>Library</OutputType>\r
+    <AppDesignerFolder>Properties</AppDesignerFolder>\r
+    <RootNamespace>YubeshiTest</RootNamespace>\r
+    <AssemblyName>YubeshiTest</AssemblyName>\r
+    <TargetFrameworkVersion>v2.0</TargetFrameworkVersion>\r
+    <FileAlignment>512</FileAlignment>\r
+    <TargetFrameworkSubset>\r
+    </TargetFrameworkSubset>\r
+    <StartAction>Program</StartAction>\r
+    <StartProgram>$(ProgramFiles)\NUnit 2.5.7\bin\net-2.0\nunit.exe</StartProgram>\r
+    <StartArguments>$(TargetPath) /run</StartArguments>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <DebugType>full</DebugType>\r
+    <Optimize>false</Optimize>\r
+    <OutputPath>bin\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+    <DebugType>pdbonly</DebugType>\r
+    <Optimize>true</Optimize>\r
+    <OutputPath>bin\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <ErrorReport>prompt</ErrorReport>\r
+    <WarningLevel>4</WarningLevel>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">\r
+    <DebugSymbols>true</DebugSymbols>\r
+    <OutputPath>bin\x64\Debug\</OutputPath>\r
+    <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+    <DebugType>full</DebugType>\r
+    <PlatformTarget>x64</PlatformTarget>\r
+    <ErrorReport>prompt</ErrorReport>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">\r
+    <OutputPath>bin\x64\Release\</OutputPath>\r
+    <DefineConstants>TRACE</DefineConstants>\r
+    <Optimize>true</Optimize>\r
+    <DebugType>pdbonly</DebugType>\r
+    <PlatformTarget>x64</PlatformTarget>\r
+    <ErrorReport>prompt</ErrorReport>\r
+  </PropertyGroup>\r
+  <ItemGroup>\r
+    <Reference Include="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />\r
+    <Reference Include="System" />\r
+    <Reference Include="System.Data" />\r
+    <Reference Include="System.Xml" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <Compile Include="Nmea\PacketTest.cs" />\r
+    <Compile Include="ParserTest.cs" />\r
+    <Compile Include="Properties\AssemblyInfo.cs" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <None Include="app.config" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ProjectReference Include="..\Yubeshi\Yubeshi.csproj">\r
+      <Project>{EC4BB8E0-FD4B-4072-A17A-BA0EC0C750AB}</Project>\r
+      <Name>Yubeshi</Name>\r
+    </ProjectReference>\r
+  </ItemGroup>\r
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
+       Other similar extension points exist, see Microsoft.Common.targets.\r
+  <Target Name="BeforeBuild">\r
+  </Target>\r
+  <Target Name="AfterBuild">\r
+  </Target>\r
+  -->\r
+</Project>
\ No newline at end of file
diff --git a/YubeshiTest/app.config b/YubeshiTest/app.config
new file mode 100755 (executable)
index 0000000..b7db281
--- /dev/null
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>\r
+<configuration>\r
+<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>\r
diff --git a/license.txt b/license.txt
new file mode 100755 (executable)
index 0000000..6de753b
--- /dev/null
@@ -0,0 +1,22 @@
+\r
+Copyright (c) 2010 Yubeshi Project\r
+\r
+This software is provided 'as-is', without any express or implied\r
+warranty. In no event will the authors be held liable for any damages\r
+arising from the use of this software.\r
+\r
+Permission is granted to anyone to use this software for any purpose,\r
+including commercial applications, and to alter it and redistribute it\r
+freely, subject to the following restrictions:\r
+\r
+    1. The origin of this software must not be misrepresented; you must not\r
+    claim that you wrote the original software. If you use this software\r
+    in a product, an acknowledgment in the product documentation would be\r
+    appreciated but is not required.\r
+\r
+    2. Altered source versions must be plainly marked as such, and must not be\r
+    misrepresented as being the original software.\r
+\r
+    3. This notice may not be removed or altered from any source\r
+    distribution.\r
+\r