Modules | |
Exceptions thrown by GNSS | |
Enumerations | |
Events related with Gnss | |
Classes | |
class | GnssDeepsyService |
Manager for connecting to GNSS Service More... | |
class | GnssService |
Service for getting GNSS data and configuring GNSS service More... | |
Detailed Description
To work with Deepsy Power service it is necessary to use GnssDeepsyService located in GMV.ITS.HAL.DEEPSY.Gnss.Facade
GnssDeepsyService has an optional parameter indicating the IP address of remote service. For instance:
To obtain a GNSS object:
GnssDeepsyService is an IDisposable Interface. An object that may hold resources (such as file or socket handles) until it is closed. The Dispose() method of an IDisposable object is called automatically when exiting a try-with-resources block, or using block, for which the object has been declared in the resource specification header. This construction ensures prompt release, avoiding resource exhaustion exceptions and errors that may otherwise occur.
Examples
-
Get Gnss Position and Dates
using System;{class GnssPositionDateApp{static void Main(string[] args){GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("172.22.198.103");IGnssManager gnss = gnssDeepsyService.GetGnss();DateTime instant = gnss.GetInstant();Console.WriteLine($"Instant: {instant}");IGnssPosition position = gnss.GetLastPosition();Console.WriteLine($"Position Lat: [{position.Latitude}] Lon: [{position.Longitude}]");}}}
-
Get Gnss Status
using System;{class GnssStatusApp{static void Main(string[] args){GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("192.168.0.144");IGnssManager gnss = gnssDeepsyService.GetGnss();IGnssStatus status = gnss.GetStatus();Console.WriteLine($"Quality: {status.Quality}");Console.WriteLine($"Antenna Status: {status.AntennaStatus}");Console.WriteLine($"Power Status: {status.PowerStatus}");Console.WriteLine($"Simulation Mode Active: {status.SimulationModeActive}");}}}
-
Get Gnss Information using System;{class GnssInformationApp{static void Main(string[] args){GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("172.22.198.103");IGnssManager gnss = gnssDeepsyService.GetGnss();string manufacturer = gnss.GetModuleInfo(GnssInfo.Info.Manufacturer);Console.WriteLine($"Manufacturer: {manufacturer}");string model = gnss.GetModuleInfo(GnssInfo.Info.Model);Console.WriteLine($"Model: {model}");string fwVer = gnss.GetModuleInfo(GnssInfo.Info.FwVer);Console.WriteLine($"FW VERSION: {fwVer}");string protocolVersion = gnss.GetModuleInfo(GnssInfo.Info.ProtocolVer);Console.WriteLine($"Protocol Version: {protocolVersion }");}}}
-
Subscribe to Gnss positions and status using System;{class GnssSubscribeApp{static void Main(string[] args){//GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("172.22.198.103");//GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("95.124.251.132");GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("212.169.147.170");IGnssManager gnss = gnssDeepsyService.GetGnss();gnss.GnssPosition += Gnss_GnssPosition;Console.WriteLine("Press ESC for exit. Any other for requesting a new position");while (Console.ReadKey().Key != ConsoleKey.Escape){IGnssPosition position = gnss.GetLastPosition();Console.WriteLine("New position requested");printPosition("request",position);}}private static void Gnss_GnssPosition(object sender, IGnssPosition e){Console.WriteLine(" *** New event position received *** ");printPosition("event", e);}private static void printPosition(string prefix, IGnssPosition e){Console.WriteLine($"{prefix} Lat: {e.Latitude}");Console.WriteLine($"{prefix} Lon: {e.Longitude}");Console.WriteLine($"{prefix} Heading: {e.DirectionDegrees}");Console.WriteLine($"{prefix} Speed: {e.SpeedKph}");Console.WriteLine($"{prefix} Date: {e.Date}");Console.WriteLine($"{prefix} Satellites Visible: {e.SatellitesVisible}");Console.WriteLine($"{prefix} Satellites used: {e.SatellitesUsed}");}}}
-
Perform a cold start using System;{class GnssColdStartApp{static void Main(string[] args){GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("192.168.0.144");IGnssManager gnss = gnssDeepsyService.GetGnss();gnss.PerformSoftwareReset(DEEPSY.Gnss.Interface.Enum.SwResetType.Type.Coldstart);Console.WriteLine("SoftwareReset operation successfully finished");}}}
-
Create a virual odometer using System;{class GnssVirtualOdometerApp{static void Main(string[] args){GnssDeepsyService gnssDeepsyService = new GnssDeepsyService("192.168.0.144");IGnssManager gnss = gnssDeepsyService.GetGnss();VirtualOdometer virtualOdometer = new VirtualOdometer();gnss.GnssPosition += virtualOdometer.Gnss_PositionEvent;Console.WriteLine("Press ESC for exit. Any other for showind the current odometer");while (Console.ReadKey().Key != ConsoleKey.Escape){Console.WriteLine($"Current odometer: {virtualOdometer.GetOdometer()}");}}}class VirtualOdometer{private double odometer = 0;private readonly double _initialOdometer = 0;private readonly double EARTH_RADIUS_KM = 6371.0;private readonly double M_PI = 3.141592;private double lastLon = 0, lastLat = 0;public VirtualOdometer(double initialOdometer = 0){_initialOdometer = initialOdometer;odometer = initialOdometer;}public void ResetOdometer(){odometer = _initialOdometer;lastLon = 0;lastLat = 0;}public void Gnss_PositionEvent(object sender, IGnssPosition e){if(e.Quality != DEEPSY.Gnss.Interface.Enum.QualityIndicator.Quality.NoFix){if (lastLat != 0 && lastLon != 0){double d = distanceEarth(lastLat, lastLon, e.Latitude, e.Longitude);if (d > 20){ //20 meters for avoiding GPS bouncingodometer += d;}}lastLat = e.Latitude;lastLon = e.Longitude;}}public double GetOdometer() => odometer;private double distanceEarth(double lat1, double lon1, double lat2, double lon2){double lat1r, lon1r, lat2r, lon2r, u, v;lat1r = lat1 * M_PI / 180;lon1r = lon1 * M_PI / 180;lat2r = lat2 * M_PI / 180;lon2r = lon2 * M_PI / 180;u = Math.Sin((lat2r - lat1r) / 2);v = Math.Sin((lon2r - lon1r) / 2);return 2.0 * EARTH_RADIUS_KM * Math.Asin(Math.Sqrt(u * u + Math.Cos(lat1r) * Math.Cos(lat2r) * v * v)) * 1000;}}}