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