/// <summary> /// Service Start /// </summary> protected override void Start() { if (_state == null) { _state = new GpsState(); _state.MicrosoftGpsConfig = new MicrosoftGpsConfig(); _state.MicrosoftGpsConfig.CommPort = 0; _state.MicrosoftGpsConfig.CaptureHistory = true; _state.MicrosoftGpsConfig.CaptureNmea = true; _state.MicrosoftGpsConfig.RetrackNmea = false; SaveState(_state); } else { // Clear old Gps readings _state.GpGga = null; _state.GpGll = null; _state.GpGsa = null; _state.GpGsv = null; _state.GpRmc = null; _state.GpVtg = null; } _httpUtilities = DsspHttpUtilitiesService.Create(Environment); if (_state.MicrosoftGpsConfig == null) _state.MicrosoftGpsConfig = new MicrosoftGpsConfig(); // Publish the service to the local Node Directory DirectoryInsert(); if (simulateFromLogNmea) { SpawnIterator(SimulateMicrosoftGps); } else { _gpsConnection = new GpsConnection(_state.MicrosoftGpsConfig, _gpsDataPort); setCaptureNmea(); SpawnIterator(ConnectToMicrosoftGps); } // Listen on the main port for requests and call the appropriate handler. Interleave mainInterleave = ActivateDsspOperationHandlers(); mainInterleave.CombineWith(new Interleave(new ExclusiveReceiverGroup( Arbiter.Receive<string[]>(true, _gpsDataPort, DataReceivedHandler) ,Arbiter.Receive<Exception>(true, _gpsDataPort, ExceptionHandler) #if TRACEDATA // see Info messages with data strings coming from GPS at http://localhost:50000/console/output ,Arbiter.Receive<string>(true, _gpsDataPort, MessageHandler) #endif ), new ConcurrentReceiverGroup())); // display HTTP service Uri LogInfo(LogGroups.Console, "Overhead view [" + FindServiceAliasFromScheme(Uri.UriSchemeHttp) + "/top]\r\n* Service uri: "); LogInfo(LogGroups.Console, "Map view [" + FindServiceAliasFromScheme(Uri.UriSchemeHttp) + "/map]\r\n* Service uri: "); LogInfo(LogGroups.Console, string.Format("Switches: CaptureHistory={0} CaptureNmea={1} RetrackNmea={2}", _state.MicrosoftGpsConfig.CaptureHistory, _state.MicrosoftGpsConfig.CaptureNmea, _state.MicrosoftGpsConfig.RetrackNmea)); Console.WriteLine(string.Format("Switches: CaptureHistory={0} CaptureNmea={1} RetrackNmea={2}", _state.MicrosoftGpsConfig.CaptureHistory, _state.MicrosoftGpsConfig.CaptureNmea, _state.MicrosoftGpsConfig.RetrackNmea)); }
private void LoadAttributes(GpsConnection gpsConnection) { Latitude = gpsConnection.Latitude; Longitude = gpsConnection.Longitude; GpsTime = gpsConnection.DateTime; LocalTime = GpsTime.ToLocalTime(); Hdop = gpsConnection.HorizontalDilutionOfPrecision; SatelliteFixCount = gpsConnection.FixSatelliteCount; SatelliteFixStatus = gpsConnection.FixStatus; Speed = gpsConnection.Speed; Bearing = gpsConnection.Course; #if TESTINGWITHOUTGPS Location = new Coordinate(443759, 6484291); //East end of MainBay19 Bearing = 0; #elif GPSINANCHORAGE //Offset Regan's office to end of Transect 001 Latitude -= (61.2174 - 58.5260); Longitude += (149.88493 - 135.9615); Location = MobileApplication.Current.Project.SpatialReference.FromGps(Longitude, Latitude); #elif GPSINJUNEAU //Offset SEAN Juneau office to end of Transect 001 Latitude -= (58.377663888 - 58.5260); Longitude += (134.69872777 - 135.9615); Location = MobileApplication.Current.Project.SpatialReference.FromGps(Longitude, Latitude); #else Location = MobileApplication.Current.Project.SpatialReference.FromGps(Longitude, Latitude); #endif }
internal static GpsPoint FromGpsConnection(TrackLog trackLog, GpsConnection gpsConnection) { if (trackLog == null) throw new ArgumentNullException("trackLog"); if (gpsConnection == null) throw new ArgumentNullException("gpsConnection"); #if !TESTINGWITHOUTGPS if (!gpsConnection.IsOpen) throw new InvalidOperationException("GPS connection is closed"); #endif //May throw an exception, but should never return null var gpsPoint = FromFeature(MobileUtilities.CreateNewFeature(FeatureSource)); gpsPoint.TrackLog = trackLog; gpsPoint.LoadAttributes(gpsConnection); return gpsPoint; }
private void HookupGpsEvents() { if (_gpsConnection == null) _gpsConnection = MobileApplication.Current.GpsConnectionManager.Connection; if (_gpsConnection.IsOpen) { _gpsConnection.GpsClosed += ProcessGpsClosedEventFromConnection; _gpsConnection.GpsError += ProcessGpsErrorEventFromConnection; _gpsConnection.GpsChanged += ProcessGpsChangedEventFromConnection; _gpsConnection.GpsOpened -= ProcessGpsOpenedEventFromConnection; ShowBoat(); } else { _gpsConnection.GpsOpened += ProcessGpsOpenedEventFromConnection; } }
private void CloseGpsConnection() { UnhookGpsEvents(); _gpsConnection = null; }
private static bool LocationChanged(GpsConnection gpsConnection) { return (gpsConnection.GpsChangeType & GpsChangeType.Position) != 0; }