mirror of
https://github.com/dotMorten/NmeaParser.git
synced 2026-01-30 20:34:13 +01:00
Initial check in
This commit is contained in:
parent
e9cc342bb4
commit
01a5b20475
155
src/BTDevices.Tests/BTDevices.Tests.csproj
Normal file
155
src/BTDevices.Tests/BTDevices.Tests.csproj
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BTDevices.Tests</RootNamespace>
|
||||
<AssemblyName>BTDevices.Tests</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformVersion>8.1</TargetPlatformVersion>
|
||||
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<PackageCertificateKeyFile>BTDevices.Tests_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
<AppxBundle>Never</AppxBundle>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AppXPackage>True</AppXPackage>
|
||||
<AppxPackageIncludePrivateSymbols>true</AppxPackageIncludePrivateSymbols>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!--A reference to the entire .Net Framework and Windows SDK are automatically included-->
|
||||
<SDKReference Include="MSTestFramework, Version=11.0" />
|
||||
<SDKReference Include="TestPlatform, Version=11.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NmeaMessages.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
<None Include="BTDevices.Tests_TemporaryKey.pfx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Images\UnitTestLogo.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\UnitTestSmallLogo.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\UnitTestSplashScreen.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Images\UnitTestStoreLogo.scale-100.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BTDevices\BTDevices.WinStore.csproj">
|
||||
<Project>{62a55887-10f5-40d2-9352-96246d1b11d3}</Project>
|
||||
<Name>BTDevices.WinStore</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ">
|
||||
<VisualStudioVersion>12.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
BIN
src/BTDevices.Tests/BTDevices.Tests_TemporaryKey.pfx
Normal file
BIN
src/BTDevices.Tests/BTDevices.Tests_TemporaryKey.pfx
Normal file
Binary file not shown.
BIN
src/BTDevices.Tests/Images/UnitTestLogo.scale-100.png
Normal file
BIN
src/BTDevices.Tests/Images/UnitTestLogo.scale-100.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
BIN
src/BTDevices.Tests/Images/UnitTestSmallLogo.scale-100.png
Normal file
BIN
src/BTDevices.Tests/Images/UnitTestSmallLogo.scale-100.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 745 B |
BIN
src/BTDevices.Tests/Images/UnitTestSplashScreen.scale-100.png
Normal file
BIN
src/BTDevices.Tests/Images/UnitTestSplashScreen.scale-100.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
BIN
src/BTDevices.Tests/Images/UnitTestStoreLogo.scale-100.png
Normal file
BIN
src/BTDevices.Tests/Images/UnitTestStoreLogo.scale-100.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2 KiB |
41
src/BTDevices.Tests/NmeaMessages.cs
Normal file
41
src/BTDevices.Tests/NmeaMessages.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
|
||||
using BTDevices.Nmea;
|
||||
using BTDevices.Nmea.Gps;
|
||||
|
||||
namespace BTDevices.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class NmeaMessages
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestGprmc()
|
||||
{
|
||||
string input = "$GPRMC,123519,A,4807.038,S,01131.000,W,022.4,084.4,230313,003.1,W*6E";
|
||||
var msg = NmeaMessage.Parse(input);
|
||||
Assert.IsInstanceOfType(msg, typeof(Gprmc));
|
||||
Gprmc rmc = (Gprmc)msg;
|
||||
Assert.AreEqual(new DateTime(23, 03, 2013, 12, 35, 19, DateTimeKind.Utc), rmc.FixTime);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestPtlna()
|
||||
{
|
||||
string input = "$PTNLA,HV,002.94,M,288.1,D,008.6,D,002.98,M*74";
|
||||
var msg = NmeaMessage.Parse(input);
|
||||
Assert.IsInstanceOfType(msg, typeof(Nmea.Trimble.LaserRange.Ptnla));
|
||||
Nmea.Trimble.LaserRange.Ptnla ptlna = (Nmea.Trimble.LaserRange.Ptnla)msg;
|
||||
Assert.AreEqual(2.94, ptlna.HorizontalDistance);
|
||||
Assert.AreEqual('M', ptlna.HorizontalDistanceUnits);
|
||||
Assert.AreEqual(288.1, ptlna.HorizontalAngle);
|
||||
Assert.AreEqual('D', ptlna.HorizontalAngleUnits);
|
||||
Assert.AreEqual(8.6, ptlna.VerticalAngle);
|
||||
Assert.AreEqual('D', ptlna.VerticalAngleUnits);
|
||||
Assert.AreEqual(2.98, ptlna.SlopeDistance);
|
||||
Assert.AreEqual('M', ptlna.SlopeDistanceUnits);
|
||||
}
|
||||
}
|
||||
}
|
||||
56
src/BTDevices.Tests/Package.appxmanifest
Normal file
56
src/BTDevices.Tests/Package.appxmanifest
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest">
|
||||
|
||||
<Identity Name="1e6281d4-7d43-4dd8-b493-15c290a30455"
|
||||
Publisher="CN=mort5161"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<Properties>
|
||||
<DisplayName>BTDevices.Tests</DisplayName>
|
||||
<PublisherDisplayName>mort5161</PublisherDisplayName>
|
||||
<Logo>Images\UnitTestStoreLogo.png</Logo>
|
||||
<Description>BTDevices.Tests</Description>
|
||||
</Properties>
|
||||
|
||||
<Prerequisites>
|
||||
<OSMinVersion>6.3.0</OSMinVersion>
|
||||
<OSMaxVersionTested>6.3.0</OSMaxVersionTested>
|
||||
</Prerequisites>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="vstest.executionengine.App"
|
||||
Executable="vstest.executionengine.appcontainer.exe"
|
||||
EntryPoint="vstest.executionengine.App">
|
||||
<VisualElements
|
||||
DisplayName="NoUIEntryPoints"
|
||||
Logo="Images\UnitTestLogo.png"
|
||||
SmallLogo="Images\UnitTestSmallLogo.png"
|
||||
Description="vstest.executionengine.App"
|
||||
ForegroundText="light"
|
||||
BackgroundColor="#0084FF">
|
||||
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
|
||||
</VisualElements>
|
||||
</Application>
|
||||
|
||||
<Application Id="vstest.executionengine.x86.App"
|
||||
Executable="vstest.executionengine.appcontainer.x86.exe"
|
||||
EntryPoint="vstest.executionengine.x86.App">
|
||||
<VisualElements
|
||||
DisplayName="NoUIEntryPoints"
|
||||
Logo="Images\UnitTestLogo.png"
|
||||
SmallLogo="Images\UnitTestSmallLogo.png"
|
||||
Description="vstest.executionengine.x86.App"
|
||||
ForegroundText="light"
|
||||
BackgroundColor="#0084FF">
|
||||
<SplashScreen Image="Images\UnitTestSplashScreen.png" />
|
||||
</VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
28
src/BTDevices.Tests/Properties/AssemblyInfo.cs
Normal file
28
src/BTDevices.Tests/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("BTDevices.Tests")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BTDevices.Tests")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
91
src/BTDevices.sln
Normal file
91
src/BTDevices.sln
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2013
|
||||
VisualStudioVersion = 12.0.30110.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WinPhone", "WinPhone", "{26A0F6A9-4B11-46F4-BB01-50D37D1C3CB4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WinStore", "WinStore", "{07131E3E-1C4E-41CB-BD14-7950AA858A23}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTDevices.WinStore", "BTDevices\BTDevices.WinStore.csproj", "{62A55887-10F5-40D2-9352-96246D1B11D3}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTDevices.Tests", "BTDevices.Tests\BTDevices.Tests.csproj", "{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BTDevices.WinPhone", "BTDevices\BTDevices.WinPhone.csproj", "{EA42A713-BC6E-4914-B54B-47C0891B7421}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|x64.Build.0 = Release|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3}.Release|x86.Build.0 = Release|Any CPU
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|x64.Build.0 = Debug|x64
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|x86.Build.0 = Debug|x86
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|ARM.Build.0 = Release|ARM
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|x64.ActiveCfg = Release|x64
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|x64.Build.0 = Release|x64
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|x64.Deploy.0 = Release|x64
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|x86.ActiveCfg = Release|x86
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|x86.Build.0 = Release|x86
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C}.Release|x86.Deploy.0 = Release|x86
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{EA42A713-BC6E-4914-B54B-47C0891B7421} = {26A0F6A9-4B11-46F4-BB01-50D37D1C3CB4}
|
||||
{62A55887-10F5-40D2-9352-96246D1B11D3} = {07131E3E-1C4E-41CB-BD14-7950AA858A23}
|
||||
{5B5BAF9D-3FB9-47F9-AE07-B8CC43EC887C} = {07131E3E-1C4E-41CB-BD14-7950AA858A23}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
73
src/BTDevices/BTDevices.WinPhone.csproj
Normal file
73
src/BTDevices/BTDevices.WinPhone.csproj
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.20506</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EA42A713-BC6E-4914-B54B-47C0891B7421}</ProjectGuid>
|
||||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BTDevices</RootNamespace>
|
||||
<AssemblyName>BTDevices.WinPhone</AssemblyName>
|
||||
<TargetFrameworkIdentifier>WindowsPhone</TargetFrameworkIdentifier>
|
||||
<TargetFrameworkVersion>v8.0</TargetFrameworkVersion>
|
||||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
|
||||
<SilverlightApplication>false</SilverlightApplication>
|
||||
<ValidateXaml>true</ValidateXaml>
|
||||
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
|
||||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>BinWP\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>BinWP\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
|
||||
<NoStdLib>true</NoStdLib>
|
||||
<NoConfig>true</NoConfig>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Device.cs" />
|
||||
<Compile Include="NmeaDevice.cs" />
|
||||
<Compile Include="Nmea\Gps\Garmin\PGRME.cs" />
|
||||
<Compile Include="Nmea\Gps\GPGGA.cs" />
|
||||
<Compile Include="Nmea\Gps\GPRMC.cs" />
|
||||
<Compile Include="Nmea\LaserRangeMessage.cs" />
|
||||
<Compile Include="Nmea\LaserTech\LaserRange\PLTIT.cs" />
|
||||
<Compile Include="Nmea\NmeaMessage.cs" />
|
||||
<Compile Include="Nmea\Trimble\LaserRange\PTNLA.cs" />
|
||||
<Compile Include="Nmea\Trimble\LaserRange\PTNLB.cs" />
|
||||
<Compile Include="Nmea\UnknownMessage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="BTDevices.WinStore.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Nmea\Navigation\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).$(TargetFrameworkVersion).Overrides.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
|
||||
<ProjectExtensions />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
66
src/BTDevices/BTDevices.WinStore.csproj
Normal file
66
src/BTDevices/BTDevices.WinStore.csproj
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{62A55887-10F5-40D2-9352-96246D1B11D3}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>BTDevices</RootNamespace>
|
||||
<AssemblyName>BTDevices.WinStore</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformVersion>8.1</TargetPlatformVersion>
|
||||
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>binWS\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>binWS\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- A reference to the entire .Net Framework and Windows SDK are automatically included -->
|
||||
<Folder Include="Nmea\Gps\Garmin\" />
|
||||
<Folder Include="Nmea\Navigation\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Device.cs" />
|
||||
<Compile Include="NmeaDevice.cs" />
|
||||
<Compile Include="Nmea\Gps\GPGGA.cs" />
|
||||
<Compile Include="Nmea\Gps\GPRMC.cs" />
|
||||
<Compile Include="Nmea\LaserTech\LaserRange\PLTIT.cs" />
|
||||
<Compile Include="Nmea\LaserRangeMessage.cs" />
|
||||
<Compile Include="Nmea\NmeaMessage.cs" />
|
||||
<Compile Include="Nmea\Trimble\LaserRange\PTNLA.cs" />
|
||||
<Compile Include="Nmea\Trimble\LaserRange\PTNLB.cs" />
|
||||
<Compile Include="Nmea\UnknownMessage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '12.0' ">
|
||||
<VisualStudioVersion>12.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
116
src/BTDevices/Device.cs
Normal file
116
src/BTDevices/Device.cs
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Networking.Sockets;
|
||||
#if NETFX_CORE
|
||||
using BTDevice = Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService;
|
||||
using Windows.Devices.Bluetooth.Rfcomm;
|
||||
using Windows.Networking.Sockets;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
#else
|
||||
using BTDevice = Windows.Networking.Proximity.PeerInformation;
|
||||
#endif
|
||||
|
||||
namespace BTDevices
|
||||
{
|
||||
public abstract class Device : IDisposable
|
||||
{
|
||||
private BTDevice m_device;
|
||||
private StreamSocket socket;
|
||||
System.Threading.CancellationTokenSource tcs;
|
||||
public Device(BTDevice device)
|
||||
{
|
||||
if (device == null)
|
||||
throw new ArgumentNullException("device");
|
||||
#if NETFX_CORE
|
||||
if (device.ServiceId.Uuid != RfcommServiceId.SerialPort.Uuid)
|
||||
throw new NotSupportedException("Only SerialPort devices supported");
|
||||
#endif
|
||||
m_device = device;
|
||||
}
|
||||
TaskCompletionSource<bool> closeTask;
|
||||
|
||||
public async Task StartAsync()
|
||||
{
|
||||
if (tcs != null)
|
||||
return;
|
||||
if (m_device == null)
|
||||
throw new ObjectDisposedException("Device");
|
||||
tcs = new System.Threading.CancellationTokenSource();
|
||||
socket = new StreamSocket();
|
||||
await socket.ConnectAsync(
|
||||
#if NETFX_CORE
|
||||
m_device.ConnectionHostName,
|
||||
m_device.ConnectionServiceName);
|
||||
#else
|
||||
m_device.HostName, "1");
|
||||
//socket = await Windows.Networking.Proximity.PeerFinder.ConnectAsync(m_device.HostName;
|
||||
#endif
|
||||
if (tcs.IsCancellationRequested) //Stop was called while opening device
|
||||
{
|
||||
socket.Dispose();
|
||||
socket = null;
|
||||
throw new TaskCanceledException();
|
||||
} var token = tcs.Token;
|
||||
var _ = Task.Run(async () =>
|
||||
{
|
||||
var stream = socket.InputStream.AsStreamForRead();
|
||||
byte[] buffer = new byte[1024];
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
int readCount = 0;
|
||||
try
|
||||
{
|
||||
readCount = await stream.ReadAsync(buffer, 0, 1024, token).ConfigureAwait(false);
|
||||
}
|
||||
catch { }
|
||||
if (token.IsCancellationRequested)
|
||||
break;
|
||||
if (readCount > 0)
|
||||
{
|
||||
OnData(buffer.Take(readCount).ToArray());
|
||||
}
|
||||
await Task.Delay(10, token);
|
||||
}
|
||||
if(socket != null)
|
||||
socket.Dispose();
|
||||
if (closeTask != null)
|
||||
closeTask.SetResult(true);
|
||||
});
|
||||
}
|
||||
|
||||
public Task StopAsync()
|
||||
{
|
||||
if (tcs != null)
|
||||
{
|
||||
socket.Dispose();
|
||||
socket = null;
|
||||
closeTask = new TaskCompletionSource<bool>();
|
||||
if(tcs != null)
|
||||
tcs.Cancel();
|
||||
tcs = null;
|
||||
return closeTask.Task;
|
||||
}
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
|
||||
protected abstract void OnData(byte[] data);
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (tcs != null)
|
||||
{
|
||||
tcs.Cancel();
|
||||
tcs = null;
|
||||
}
|
||||
m_device = null;
|
||||
if(socket != null)
|
||||
socket.Dispose();
|
||||
socket = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
106
src/BTDevices/Nmea/Gps/GPGGA.cs
Normal file
106
src/BTDevices/Nmea/Gps/GPGGA.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea.Gps
|
||||
{
|
||||
/// <summary>
|
||||
/// Recommended Minimum
|
||||
/// </summary>
|
||||
[NmeaMessageType(Type = "GPGGA")]
|
||||
public class Gpgga : NmeaMessage
|
||||
{
|
||||
public enum FixQuality : int
|
||||
{
|
||||
Invalid = 0,
|
||||
GpsFix = 1,
|
||||
DgpsFix = 2,
|
||||
PpsFix = 3,
|
||||
Rtk = 4,
|
||||
FloatRtk = 5,
|
||||
Estimated = 6,
|
||||
ManualInput = 7,
|
||||
Simulation = 8
|
||||
}
|
||||
|
||||
protected override void LoadMessage(string[] message)
|
||||
{
|
||||
var time = message[0];
|
||||
Latitude = int.Parse(message[1].Substring(0, 2), CultureInfo.InvariantCulture) + double.Parse(message[1].Substring(2), CultureInfo.InvariantCulture) / 60;
|
||||
if (message[2] == "S")
|
||||
Latitude *= -1;
|
||||
Longitude = int.Parse(message[3].Substring(0, 3), CultureInfo.InvariantCulture) + double.Parse(message[3].Substring(3), CultureInfo.InvariantCulture) / 60;
|
||||
if (message[4] == "W")
|
||||
Latitude *= -1;
|
||||
Quality = (FixQuality)int.Parse(message[5], CultureInfo.InvariantCulture);
|
||||
NumberOfSatellites = int.Parse(message[6], CultureInfo.InvariantCulture);
|
||||
Hdop = double.Parse(message[7], CultureInfo.InvariantCulture);
|
||||
Altitude = double.Parse(message[8], CultureInfo.InvariantCulture);
|
||||
AltitudeUnits = message[9];
|
||||
HeightOfGeoid = double.Parse(message[10], CultureInfo.InvariantCulture);
|
||||
HeightOfGeoidUnits = message[11];
|
||||
if (message[12].Length > 0)
|
||||
TimeSinceLastDgpsUpdate = TimeSpan.FromSeconds(int.Parse(message[12], CultureInfo.InvariantCulture));
|
||||
if (message[13].Length > 0)
|
||||
DgpsStationID = int.Parse(message[13], CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Latitude
|
||||
/// </summary>
|
||||
public double Latitude { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Longitude
|
||||
/// </summary>
|
||||
public double Longitude { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fix Quality
|
||||
/// </summary>
|
||||
public FixQuality Quality { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Number of satellites being tracked
|
||||
/// </summary>
|
||||
public int NumberOfSatellites { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal Dilution of Precision
|
||||
/// </summary>
|
||||
public double Hdop { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Altitude
|
||||
/// </summary>
|
||||
public double Altitude { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Altitude units ('M' for Meters)
|
||||
/// </summary>
|
||||
public string AltitudeUnits { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Height of geoid (mean sea level) above WGS84
|
||||
/// </summary>
|
||||
public double HeightOfGeoid { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Altitude units ('M' for Meters)
|
||||
/// </summary>
|
||||
public string HeightOfGeoidUnits { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Time since last DGPS update
|
||||
/// </summary>
|
||||
public TimeSpan TimeSinceLastDgpsUpdate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// DGPS Station ID Number
|
||||
/// </summary>
|
||||
public int DgpsStationID { get; set; }
|
||||
}
|
||||
}
|
||||
73
src/BTDevices/Nmea/Gps/GPRMC.cs
Normal file
73
src/BTDevices/Nmea/Gps/GPRMC.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea.Gps
|
||||
{
|
||||
/// <summary>
|
||||
/// Recommended Minimum
|
||||
/// </summary>
|
||||
[NmeaMessageType(Type = "GPRMC")]
|
||||
public class Gprmc : NmeaMessage
|
||||
{
|
||||
protected override void LoadMessage(string[] message)
|
||||
{
|
||||
FixTime = new DateTime(int.Parse(message[8].Substring(4, 2)) + 2000,
|
||||
int.Parse(message[8].Substring(2, 2)),
|
||||
int.Parse(message[8].Substring(0, 2)),
|
||||
int.Parse(message[0].Substring(0, 2)),
|
||||
int.Parse(message[0].Substring(2, 2)),
|
||||
int.Parse(message[0].Substring(4, 2)), DateTimeKind.Utc);
|
||||
Active = (message[1] == "A");
|
||||
Latitude = int.Parse(message[2].Substring(0, 2), CultureInfo.InvariantCulture) + double.Parse(message[2].Substring(2), CultureInfo.InvariantCulture) / 60;
|
||||
if (message[3] == "S")
|
||||
Latitude *= -1;
|
||||
Longitude = int.Parse(message[4].Substring(0, 3), CultureInfo.InvariantCulture) + double.Parse(message[4].Substring(3), CultureInfo.InvariantCulture) / 60;
|
||||
if (message[5] == "W")
|
||||
Latitude *= -1;
|
||||
Speed = double.Parse(message[6], CultureInfo.InvariantCulture);
|
||||
Course = double.Parse(message[7], CultureInfo.InvariantCulture);
|
||||
MagneticVariation = double.Parse(message[9], CultureInfo.InvariantCulture);
|
||||
if (message[10] == "W")
|
||||
MagneticVariation *= -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fix Time
|
||||
/// </summary>
|
||||
public DateTime FixTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value whether the device is active
|
||||
/// </summary>
|
||||
public bool Active { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Latitude
|
||||
/// </summary>
|
||||
public double Latitude { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Longitude
|
||||
/// </summary>
|
||||
public double Longitude { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Speed over the ground in knots
|
||||
/// </summary>
|
||||
public double Speed { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Track angle in degrees True
|
||||
/// </summary>
|
||||
public double Course { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Magnetic Variation
|
||||
/// </summary>
|
||||
public double MagneticVariation { get; private set; }
|
||||
}
|
||||
}
|
||||
56
src/BTDevices/Nmea/Gps/Garmin/PGRME.cs
Normal file
56
src/BTDevices/Nmea/Gps/Garmin/PGRME.cs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea.Gps
|
||||
{
|
||||
/// <summary>
|
||||
/// Recommended Minimum
|
||||
/// </summary>
|
||||
[NmeaMessageType(Type = "PGRME")]
|
||||
public class Pgrme : NmeaMessage
|
||||
{
|
||||
protected override void LoadMessage(string[] message)
|
||||
{
|
||||
HorizontalError = double.Parse(message[0], CultureInfo.InvariantCulture);
|
||||
HorizontalErrorUnits = message[1];
|
||||
VerticalError = double.Parse(message[2], CultureInfo.InvariantCulture);
|
||||
VerticalErrorUnits = message[3];
|
||||
SphericalError = double.Parse(message[4], CultureInfo.InvariantCulture);
|
||||
SphericalErrorUnits = message[5];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Estimated horizontal position error in meters (HPE)
|
||||
/// </summary>
|
||||
public double HorizontalError { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Horizontal Error unit ('M' for Meters)
|
||||
/// </summary>
|
||||
public string HorizontalErrorUnits { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Estimated vertical position error in meters (VPE)
|
||||
/// </summary>
|
||||
public double VerticalError { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Vertical Error unit ('M' for Meters)
|
||||
/// </summary>
|
||||
public string VerticalErrorUnits { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Overall spherical equivalent position error
|
||||
/// </summary>
|
||||
public double SphericalError { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Spherical Error unit ('M' for Meters)
|
||||
/// </summary>
|
||||
public string SphericalErrorUnits { get; private set; }
|
||||
}
|
||||
}
|
||||
46
src/BTDevices/Nmea/LaserRangeMessage.cs
Normal file
46
src/BTDevices/Nmea/LaserRangeMessage.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea
|
||||
{
|
||||
/// <summary>
|
||||
/// Laser Range Measurement
|
||||
/// </summary>
|
||||
public abstract class LaserRangeMessage : NmeaMessage
|
||||
{
|
||||
protected override void LoadMessage(string[] message)
|
||||
{
|
||||
HorizontalVector = message[0];
|
||||
HorizontalDistance = double.Parse(message[1], CultureInfo.InvariantCulture);
|
||||
HorizontalDistanceUnits = message[2][0];
|
||||
HorizontalAngle = double.Parse(message[3], CultureInfo.InvariantCulture);
|
||||
HorizontalAngleUnits = message[4][0];
|
||||
VerticalAngle = double.Parse(message[5], CultureInfo.InvariantCulture);
|
||||
VerticalAngleUnits = message[6][0];
|
||||
SlopeDistance = double.Parse(message[7], CultureInfo.InvariantCulture);
|
||||
SlopeDistanceUnits = message[8][0];
|
||||
}
|
||||
|
||||
public string HorizontalVector { get; private set; }
|
||||
|
||||
public double HorizontalDistance { get; private set; }
|
||||
|
||||
public char HorizontalDistanceUnits { get; private set; }
|
||||
|
||||
public double HorizontalAngle { get; private set; }
|
||||
|
||||
public char HorizontalAngleUnits { get; private set; }
|
||||
|
||||
public double VerticalAngle { get; private set; }
|
||||
|
||||
public char VerticalAngleUnits { get; private set; }
|
||||
|
||||
public double SlopeDistance { get; private set; }
|
||||
|
||||
public char SlopeDistanceUnits { get; private set; }
|
||||
}
|
||||
}
|
||||
17
src/BTDevices/Nmea/LaserTech/LaserRange/PLTIT.cs
Normal file
17
src/BTDevices/Nmea/LaserTech/LaserRange/PLTIT.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea.LaserTech.LaserRange
|
||||
{
|
||||
/// <summary>
|
||||
/// Laser Range
|
||||
/// </summary>
|
||||
[NmeaMessageType(Type = "PLTIT")]
|
||||
public class Pltit : LaserRangeMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
97
src/BTDevices/Nmea/NmeaMessage.cs
Normal file
97
src/BTDevices/Nmea/NmeaMessage.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea
|
||||
{
|
||||
public class NmeaMessageType : Attribute { public string Type { get; set; } }
|
||||
|
||||
public abstract class NmeaMessage
|
||||
{
|
||||
public static NmeaMessage Parse(string message)
|
||||
{
|
||||
int checksum = -1;
|
||||
if (message[0] != '$')
|
||||
throw new ArgumentException("Invalid nmea message: Missing starting character '$'");
|
||||
var idx = message.IndexOf('*');
|
||||
if (idx >= 0)
|
||||
{
|
||||
checksum = Convert.ToInt32(message.Substring(idx + 1), 16);
|
||||
message = message.Substring(0, message.IndexOf('*'));
|
||||
}
|
||||
if (checksum > -1)
|
||||
{
|
||||
int checksumTest = 0;
|
||||
for (int i = 1; i < message.Length; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
checksumTest ^= Convert.ToByte(message[i]);
|
||||
}
|
||||
if (checksum != checksumTest)
|
||||
throw new ArgumentException("Invalid nmea message: Checksum failure");
|
||||
}
|
||||
|
||||
string[] parts = message.Split(new char[] { ',' });
|
||||
string MessageType = parts[0].Substring(1);
|
||||
string[] MessageParts = parts.Skip(1).ToArray();
|
||||
if(messageTypes == null)
|
||||
{
|
||||
LoadResponseTypes();
|
||||
}
|
||||
NmeaMessage msg = null;
|
||||
if (messageTypes.ContainsKey(MessageType))
|
||||
{
|
||||
msg = (NmeaMessage)messageTypes[MessageType].Invoke(new object[] { });
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = new UnknownMessage();
|
||||
}
|
||||
msg.MessageType = MessageType;
|
||||
msg.MessageParts = MessageParts;
|
||||
msg.LoadMessage(MessageParts);
|
||||
return msg;
|
||||
}
|
||||
|
||||
private static void LoadResponseTypes()
|
||||
{
|
||||
messageTypes = new Dictionary<string, ConstructorInfo>();
|
||||
var typeinfo = typeof(NmeaMessage).GetTypeInfo();
|
||||
foreach (var subclass in typeinfo.Assembly.DefinedTypes.Where(t => t.IsSubclassOf(typeof(NmeaMessage))))
|
||||
{
|
||||
var attr = subclass.GetCustomAttribute<NmeaMessageType>(false);
|
||||
if (attr != null)
|
||||
{
|
||||
if (!subclass.IsAbstract)
|
||||
{
|
||||
foreach (var c in subclass.DeclaredConstructors)
|
||||
{
|
||||
var pinfo = c.GetParameters();
|
||||
if (pinfo.Length == 0)
|
||||
{
|
||||
messageTypes.Add(attr.Type, c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, ConstructorInfo> messageTypes;
|
||||
|
||||
protected string[] MessageParts { get; private set; }
|
||||
|
||||
public string MessageType { get; private set; }
|
||||
|
||||
protected virtual void LoadMessage(string[] message) { MessageParts = message; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("${0},{1}", MessageType, string.Join(",", MessageParts));
|
||||
}
|
||||
}
|
||||
}
|
||||
17
src/BTDevices/Nmea/Trimble/LaserRange/PTNLA.cs
Normal file
17
src/BTDevices/Nmea/Trimble/LaserRange/PTNLA.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea.Trimble.LaserRange
|
||||
{
|
||||
/// <summary>
|
||||
/// Burden finder
|
||||
/// </summary>
|
||||
[NmeaMessageType(Type = "PTNLA")]
|
||||
public class Ptnla : LaserRangeMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
41
src/BTDevices/Nmea/Trimble/LaserRange/PTNLB.cs
Normal file
41
src/BTDevices/Nmea/Trimble/LaserRange/PTNLB.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea.Trimble.LaserRange
|
||||
{
|
||||
/// <summary>
|
||||
/// Tree Measurement
|
||||
/// </summary>
|
||||
[NmeaMessageType(Type = "PTNLB")]
|
||||
public class Ptnlb : NmeaMessage
|
||||
{
|
||||
protected override void LoadMessage(string[] message)
|
||||
{
|
||||
TreeHeight = message[0];
|
||||
MeasuredTreeHeight = double.Parse(message[1], CultureInfo.InvariantCulture);
|
||||
MeasuredTreeHeightUnits = message[2][0];
|
||||
TreeDiameter = message[3];
|
||||
MeasuredTreeDiameter = double.Parse(message[4], CultureInfo.InvariantCulture);
|
||||
MeasuredTreeDiameterUnits = message[5][0];
|
||||
}
|
||||
|
||||
public string TreeHeight { get; private set; }
|
||||
|
||||
public double MeasuredTreeHeight { get; private set; }
|
||||
|
||||
public char MeasuredTreeHeightUnits { get; private set; }
|
||||
|
||||
public string TreeDiameter { get; private set; }
|
||||
|
||||
public double MeasuredTreeDiameter { get; private set; }
|
||||
|
||||
public char MeasuredTreeDiameterUnits { get; private set; }
|
||||
|
||||
//more to do...
|
||||
|
||||
}
|
||||
}
|
||||
16
src/BTDevices/Nmea/UnknownMessage.cs
Normal file
16
src/BTDevices/Nmea/UnknownMessage.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BTDevices.Nmea
|
||||
{
|
||||
public class UnknownMessage : NmeaMessage
|
||||
{
|
||||
public string[] Values { get { return base.MessageParts; } }
|
||||
protected override void LoadMessage(string[] message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
55
src/BTDevices/NmeaDevice.cs
Normal file
55
src/BTDevices/NmeaDevice.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
#if NETFX_CORE
|
||||
using BTDevice = Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService;
|
||||
using Windows.Devices.Bluetooth.Rfcomm;
|
||||
#else
|
||||
using BTDevice = Windows.Networking.Proximity.PeerInformation;
|
||||
#endif
|
||||
using Windows.Foundation;
|
||||
|
||||
namespace BTDevices
|
||||
{
|
||||
public class NmeaDevice : Device
|
||||
{
|
||||
private string message = "";
|
||||
public NmeaDevice(BTDevice device)
|
||||
: base(device)
|
||||
{
|
||||
}
|
||||
protected override void OnData(byte[] data)
|
||||
{
|
||||
var nmea = System.Text.Encoding.UTF8.GetString(data, 0, data.Length);
|
||||
message += nmea;
|
||||
var lineEnd = message.IndexOf("\n");
|
||||
if (lineEnd > -1)
|
||||
{
|
||||
string line = message.Substring(0, lineEnd);
|
||||
message = message.Substring(lineEnd).Trim();
|
||||
ProcessMessage(line.Trim());
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessMessage(string p)
|
||||
{
|
||||
try
|
||||
{
|
||||
var msg = BTDevices.Nmea.NmeaMessage.Parse(p);
|
||||
if (msg != null)
|
||||
OnMessageReceived(msg);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void OnMessageReceived(Nmea.NmeaMessage msg)
|
||||
{
|
||||
if (MessageReceived != null)
|
||||
MessageReceived(this, msg);
|
||||
}
|
||||
|
||||
public event TypedEventHandler<NmeaDevice, Nmea.NmeaMessage> MessageReceived;
|
||||
}
|
||||
}
|
||||
29
src/BTDevices/Properties/AssemblyInfo.cs
Normal file
29
src/BTDevices/Properties/AssemblyInfo.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("BTDevices")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("BTDevices")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
Loading…
Reference in a new issue