Skip to content

Commit

Permalink
Merge pull request #6 from GhostwareDev/development
Browse files Browse the repository at this point in the history
Bugfixes
  • Loading branch information
kevingoos authored Feb 14, 2017
2 parents e932991 + 1839feb commit bb49f0a
Show file tree
Hide file tree
Showing 25 changed files with 400 additions and 29 deletions.
8 changes: 8 additions & 0 deletions GPS.NET/GPS.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghostware.GPS.NET.WindowsAP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghostware.GPS.NET.UnitTests", "Ghostware.GPS.NET.UnitTests\Ghostware.GPS.NET.UnitTests.csproj", "{53670C74-EF59-43EC-8521-219EF5A95D1D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ghostware.GPS.NET.FileConsole", "Ghostware.GPS.NET.FileConsole\Ghostware.GPS.NET.FileConsole.csproj", "{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -50,6 +52,12 @@ Global
{53670C74-EF59-43EC-8521-219EF5A95D1D}.Release|Any CPU.Build.0 = Release|Any CPU
{53670C74-EF59-43EC-8521-219EF5A95D1D}.RemoteDebug|Any CPU.ActiveCfg = Debug|Any CPU
{53670C74-EF59-43EC-8521-219EF5A95D1D}.RemoteDebug|Any CPU.Build.0 = Debug|Any CPU
{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}.Release|Any CPU.Build.0 = Release|Any CPU
{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}.RemoteDebug|Any CPU.ActiveCfg = Debug|Any CPU
{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}.RemoteDebug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions GPS.NET/Ghostware.GPS.NET.FileConsole/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>
<ProjectGuid>{BCE5E0DE-603C-4818-8AEF-90C20D4DBC12}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Ghostware.GPS.NET.FileConsole</RootNamespace>
<AssemblyName>Ghostware.GPS.NET.FileConsole</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ghostware.GPS.NET\Ghostware.GPS.NET.csproj">
<Project>{CFBDB710-C75D-4DDF-94D2-8855FA6F9F07}</Project>
<Name>Ghostware.GPS.NET</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.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>
48 changes: 48 additions & 0 deletions GPS.NET/Ghostware.GPS.NET.FileConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Runtime.InteropServices;
using Ghostware.GPS.NET.Enums;
using Ghostware.GPS.NET.Models.ConnectionInfo;
using Ghostware.GPS.NET.Models.Events;

namespace Ghostware.GPS.NET.FileConsole
{
public class Program
{
[DllImport("Kernel32")]
private static extern bool SetConsoleCtrlHandler(EventHandler handler, bool add);

private delegate bool EventHandler();
private static EventHandler _eventHandler;

private static GpsService _gpsService;

static void Main(string[] args)
{
_eventHandler += ExitHandler;
SetConsoleCtrlHandler(_eventHandler, true);

var info = new FileGpsInfo
{
FilePath = "GPS.TXT",
FileType = FileType.LatitudeLongitude
};
_gpsService = new GpsService(info);

_gpsService.RegisterDataEvent(GpsdServiceOnLocationChanged);
_gpsService.Connect();

Console.WriteLine("Press enter to continue...");
Console.ReadKey();
}

private static void GpsdServiceOnLocationChanged(object sender, GpsDataEventArgs e)
{
System.Console.WriteLine(e.ToString());
}

private static bool ExitHandler()
{
return _gpsService == null || _gpsService.Disconnect();
}
}
}
36 changes: 36 additions & 0 deletions GPS.NET/Ghostware.GPS.NET.FileConsole/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("Ghostware.GPS.NET.FileConsole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Infrabel")]
[assembly: AssemblyProduct("Ghostware.GPS.NET.FileConsole")]
[assembly: AssemblyCopyright("Copyright © Infrabel 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bce5e0de-603c-4818-8aef-90c20d4dbc12")]

// 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")]
9 changes: 5 additions & 4 deletions GPS.NET/Ghostware.GPS.NET.GPSDConsole/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Runtime.InteropServices;
using System;
using System.Runtime.InteropServices;
using Ghostware.GPS.NET.Models.ConnectionInfo;
using Ghostware.GPS.NET.Models.Events;

Expand Down Expand Up @@ -35,13 +36,13 @@ static void Main(string[] args)
_gpsService.RegisterDataEvent(GpsdServiceOnLocationChanged);
_gpsService.Connect();

System.Console.WriteLine("Press enter to continue...");
System.Console.ReadKey();
Console.WriteLine("Press enter to continue...");
Console.ReadKey();
}

private static void GpsdServiceOnLocationChanged(object sender, GpsDataEventArgs e)
{
System.Console.WriteLine(e.ToString());
Console.WriteLine(e.ToString());
}

private static bool ExitHandler()
Expand Down
3 changes: 2 additions & 1 deletion GPS.NET/Ghostware.GPS.NET/Enums/FileType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public enum FileType
{
Nmea,
Gpsd
Gpsd,
LatitudeLongitude,
}
}
16 changes: 16 additions & 0 deletions GPS.NET/Ghostware.GPS.NET/Exceptions/InvalidFileFormatException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ghostware.GPS.NET.Exceptions
{
public class InvalidFileFormatException : Exception
{
public InvalidFileFormatException(string fileFormat) : base($"The file located at: {fileFormat} has an invalid file format! Please include a column named {Properties.Settings.Default.File_Latitude_Header} and {Properties.Settings.Default.File_Longitude_Header}.")
{

}
}
}
24 changes: 24 additions & 0 deletions GPS.NET/Ghostware.GPS.NET/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Globalization;

namespace Ghostware.GPS.NET.Extensions
{
public static class StringExtensions
{
public static double? GetDouble(this string value)
{
double result;

//Try parsing in the current culture
if (!double.TryParse(value, NumberStyles.Any, CultureInfo.CurrentCulture, out result) &&
//Then try in US english
!double.TryParse(value, NumberStyles.Any, CultureInfo.GetCultureInfo("en-US"), out result) &&
//Then in neutral language
!double.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out result))
{
return null;
}

return result;
}
}
}
10 changes: 9 additions & 1 deletion GPS.NET/Ghostware.GPS.NET/GPS.NET.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package >
<metadata>
<id>Ghostware.GPS.NET</id>
<version>1.0.2</version>
<version>1.0.3</version>
<title>Ghostware.GPS.NET</title>
<authors>Kevin Goos</authors>
<owners>Ghostware</owners>
Expand All @@ -18,6 +18,14 @@
- Using the Windows location API. (Starting from windows 7)
</description>
<releaseNotes>
v1.0.3:
--------
- Added support for files using the following format ([Latitude;Longitude], header needs to be included on the first line. (Header names are in the settings))
- Added ComPort Readfrequenty, and added 0 as unlimited
- Changed GPSD Readfrequenty, and added 0 as unlimited
- Added Readfrequenty to the Windows Location API, and added 0 as unlimited
- Added GPSType property

v1.0.2:
--------
- Bugfix: fixed the GpsClientFactory returning wrong type for GPSD
Expand Down
12 changes: 12 additions & 0 deletions GPS.NET/Ghostware.GPS.NET/Ghostware.GPS.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@
<Compile Include="Enums\GpsStatus.cs" />
<Compile Include="Exceptions\ConnectionLostException.cs" />
<Compile Include="Exceptions\InvalidDataTypeException.cs" />
<Compile Include="Exceptions\InvalidFileFormatException.cs" />
<Compile Include="Exceptions\NoGpsFoundException.cs" />
<Compile Include="Exceptions\NotConnectedException.cs" />
<Compile Include="Exceptions\UnknownTypeException.cs" />
<Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Factories\GpsClientFactory.cs" />
<Compile Include="Factories\GpsDataFactory.cs" />
<Compile Include="GpsClients\ComPortGpsClient.cs" />
Expand All @@ -88,10 +90,20 @@
<Compile Include="Models\Events\GpsDataEventArgs.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Handlers\ProxyClientHandler.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="GPS.NET.nuspec" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Plugins\ETRS89_LAMBERT_UTM_32bits.dll">
Expand Down
11 changes: 6 additions & 5 deletions GPS.NET/Ghostware.GPS.NET/GpsClients/ComPortGpsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class ComPortGpsClient : BaseGpsClient
private readonly NmeaParser _parser = new NmeaParser();
private SerialPort _serialPort;

private DateTime? _previousReadTime;

#endregion

#region Constructors
Expand All @@ -36,7 +38,7 @@ public ComPortGpsClient(BaseGpsInfo connectionData) : base(GpsType.ComPort, conn
public override bool Connect()
{
var data = (ComPortInfo)GpsInfo;

OnGpsStatusChanged(GpsStatus.Connecting);
_serialPort = new SerialPort(data.ComPort, 9600, Parity.None, 8, StopBits.One);

Expand Down Expand Up @@ -75,10 +77,9 @@ private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
var readString = _serialPort.ReadExisting();
OnRawGpsDataReceived(readString);
var result = _parser.Parse(readString);
if (typeof(GprmcMessage) == result.GetType())
{
OnGpsDataReceived(new GpsDataEventArgs((GprmcMessage)result));
}
if (typeof(GprmcMessage) != result.GetType()) return;
if (_previousReadTime != null && GpsInfo.ReadFrequenty != 0 && ((GprmcMessage)result).UpdateDate.Subtract(new TimeSpan(0, 0, 0, 0, GpsInfo.ReadFrequenty)) <= _previousReadTime) return;
OnGpsDataReceived(new GpsDataEventArgs((GprmcMessage)result));
}
catch (UnknownTypeException ex)
{
Expand Down
Loading

0 comments on commit bb49f0a

Please sign in to comment.