static void Main(string[] args) { _eventHandler += ExitHandler; SetConsoleCtrlHandler(_eventHandler, true); var info = new ComPortInfo() { ComPort = "COM9\0\0\0\0", }; _gpsService = new GpsService(info); _gpsService.RegisterStatusEvent(Action); _gpsService.RegisterDataEvent(GpsdServiceOnLocationChanged); try { _gpsService.Connect(); } catch (UnauthorizedAccessException) { Console.WriteLine("The selected com port is already in use!"); } Console.WriteLine("Press enter to continue..."); Console.ReadKey(); }
private void button1_Click(object sender, EventArgs e) { try { GpsData gpsData = null; GpsService gpsService = new GpsService(); gpsService.Initialize("COM3"); while (gpsData == null) { if (gpsService.ReadData() != null) { gpsData = new GpsData(); gpsData = gpsService.ReadData(); if (gpsData != null) { richTextBox1.Text = "lat:\t" + gpsData.Latitude + "\n" + "lon:\t" + gpsData.Longitude + "\n"; } } } } catch (Exception ex) { richTextBox1.Text = ex.Message; } }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { if (_gpsdService != null && _gpsdService.IsRunning) { return; } var info = new GpsdInfo() { Address = "***.* **.* **.***", //Default //Port = 2947, //IsProxyEnabled = true, //ProxyAddress = "proxy", //ProxyPort = 80, //ProxyCredentials = new ProxyCredentials("*****", "*****") }; _gpsdService = new GpsService(info); _writer = new StreamWriter("testFile1.nmea"); _gpsdService.RegisterRawDataEvent(GpsdServiceOnRawLocationChanged); _gpsdService.RegisterDataEvent(GpsdServiceOnLocationChanged); var task = Task.Run(() => { Retry.Do(_gpsdService.Connect, TimeSpan.FromSeconds(1)); }); task.ContinueWith(t => { MessageBox.Show(t.Exception?.ToString(), "Exception", MessageBoxButton.OK); }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext()); }
public IoTWindow() { _gpsService = new GpsService(); _weatherService = new WeatherService(); _moodService = new MoodService(); InitializeComponent(); }
/** * Localizes the user with his GPS * return a MyPosition class wrapping the longitude and latitude of the user current position */ public async Task <MyPosition> localize() { backToRadar.IsVisible = false; showLoad(); MyPosition position = await GpsService.getCurrentPosition(); showBall(); backToRadar.IsVisible = true; return(position); }
/// <summary> /// 위치 정보 수집 시작 /// </summary> private void CallGpsService() { if (GpsService.IsAgree() && !GpsService.run) { GpsService.Init(); Device.StartTimer(TimeSpan.FromSeconds(10), () => { GpsService.SendCurrentLocation(); return(GpsService.run); }); } }
static void Main(string[] args) { _eventHandler += ExitHandler; SetConsoleCtrlHandler(_eventHandler, true); _gpsService = new GpsService(GpsType.WindowsLocationApi); _gpsService.RegisterDataEvent(GpsdServiceOnLocationChanged); _gpsService.Connect(); System.Console.WriteLine("Press enter to continue..."); System.Console.ReadKey(); }
public async Task GetRouteInfo_PassGpsLocations_GetCorrectRouteInfoObject() { //Arrange Trackers tracker = TrackersListStub.GetTracker(); List <Locations> locations = LocationsListStub.GetLocationsList().Where(x => x.Imei == tracker.Imei).ToList(); GpsService gpsService = GetGpsService(); RouteInfo expectedRouteInfo = GetExpectedRouteInfo(); //Act RouteInfo routeInfo = await gpsService.GetRouteInfo(locations, tracker); //Assert Assert.AreEqual(expectedRouteInfo, routeInfo); }
//public InputField titulo; void OnApplicationPause(bool focusing) { focusTime++; _logText.text = $"Pause {focusing} {focusTime}"; if (focusing == true) { return; } if (_firstTime == true) { if (_alreadyVisited == true) { return; } _logText.text = $"Gps loading..."; var gpsService = new GpsService((data) => { Lat = "-11.8820457"; Long = "-75.2584401"; var distance = GpsService.Distance( (double)data.latitude, (double)data.longitude, double.Parse(Lat), double.Parse(Long)); if (distance <= minimumDistance) { //sendAddVista(); _logText.text = $"Distance: {distance} (Llegó!)"; _alreadyVisited = true; } else { _logText.text = $"Distance: {distance} (No llegó)"; } }, null); StartCoroutine(gpsService.StartServiceRoutine()); } else { _firstTime = true; _logText.text = $"First time {_firstTime}"; } }
public async Task GetRouteInfo_PassDateRangeAndImeiParams_GetCorrectRouteInfoObject() { //Arrange GpsService gpsService = GetGpsService(); DateTime dateFrom = new DateTime(2018, 10, 11, 17, 9, 32); DateTime dateTo = new DateTime(2018, 10, 11, 17, 23, 11); string imei = "1"; RouteInfo expectedRouteInfo = GetExpectedRouteInfo(); //Act RouteInfo routeInfo = await gpsService.GetRouteInfo(dateFrom, dateTo, imei); //Assert Assert.AreEqual(expectedRouteInfo, routeInfo); }
public async Task GetRouteInfoList_PassDateRange_GetCorrectRouteInfoList() { //Arrange GpsService gpsService = GetGpsService(); DateTime dateFrom = new DateTime(2018, 10, 11, 17, 9, 32); DateTime dateTo = new DateTime(2018, 10, 11, 17, 23, 11); List <RouteInfo> expectedRouteInfoList = GetExpectedRouteInfoList(); //Act List <RouteInfo> routeInfoList = await gpsService.GetRouteInfoList(dateFrom, dateTo); //Assert for (int i = 0; i < expectedRouteInfoList.Count; i++) { Assert.AreEqual(expectedRouteInfoList[i], routeInfoList[i]); } }
public void AbrirMapa() { sendAddVista(); // Destino estatico, mas adelante, cambiar por un valor obtenido de la Base de datos Lat = "-11.8820457"; Long = "-75.2584401"; var gpsService = new GpsService((data) => { //Application.OpenURL("https://www.google.com/maps/search/?api=1&query=" + Lat + "," + Long); var url = $"https://www.google.com/maps/dir/?api=1&origin={data.latitude},{data.longitude}&destination=" + Lat + "," + Long + "&travelmode=driving"; Debug.Log(url); Application.OpenURL(url); }, _logText); StartCoroutine(gpsService.StartServiceRoutine()); }
private GpsService GetGpsService() { Mock <IGpsDistanceHelper> gpsDistanceMock = new Mock <IGpsDistanceHelper>(); gpsDistanceMock.Setup(x => x.CalculateDistance(It.IsAny <List <Locations> >())).Returns(200); Mock <IGpsTimeHelper> gpsTimeMock = new Mock <IGpsTimeHelper>(); gpsTimeMock.Setup(x => x.GetElapsedTime(It.IsAny <List <Locations> >())).Returns(new TimeSpan(1, 10, 20)); Mock <IDistanceMatrix> distanceMatrixMock = new Mock <IDistanceMatrix>(); distanceMatrixMock.Setup(x => x.CalculateDistanceAsync(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult("210")); IGpsContext gpsContext = new GpsContextStub().GetContext(); GpsService gpsService = new GpsService(gpsDistanceMock.Object, gpsTimeMock.Object, distanceMatrixMock.Object, gpsContext); return(gpsService); }
static void Main(string[] args) { _eventHandler += ExitHandler; SetConsoleCtrlHandler(_eventHandler, true); var info = new FileGpsInfo { FilePath = "GPS.TXT", FileType = FileType.Nmea }; _gpsService = new GpsService(info); _gpsService.RegisterDataEvent(GpsdServiceOnLocationChanged); _gpsService.Connect(); Console.WriteLine("Press enter to continue..."); Console.ReadKey(); }
public NmeaViewModel(GpsService gpsService) { GpsService = gpsService; GpsService.GlonassSVsChanged += (_, _) => Application.Current.Dispatcher.InvokeAsync(() => SVs = GpsService.GpsSVs.Concat(GpsService.GlonassSVs).ToList()); gpsService.GpsSVsChanged += (_, _) => Application.Current.Dispatcher.InvokeAsync(() => SVs = GpsService.GpsSVs.Concat(GpsService.GlonassSVs).ToList()); var timer = new DispatcherTimer(DispatcherPriority.Background, Application.Current.Dispatcher) { Interval = TimeSpan.FromSeconds(1) }; timer.Tick += (_, _) => { RaisePropertyChanged(nameof(SVs)); RaisePropertyChanged(nameof(FixDateTime)); RaisePropertyChanged(nameof(Position)); RaisePropertyChanged(nameof(Dop)); }; gpsService.IsOpenChanged += (_, _) => timer.IsEnabled = gpsService.IsOpen; }
static void Main(string[] args) { _eventHandler += ExitHandler; SetConsoleCtrlHandler(_eventHandler, true); var info = new GpsdInfo() { Address = "***.* **.* **.***", //Default //Port = 2947, //IsProxyEnabled = true, //ProxyAddress = "proxy", //ProxyPort = 80, //ProxyCredentials = new ProxyCredentials("*****", "*****") }; _gpsService = new GpsService(info); _gpsService.RegisterDataEvent(GpsdServiceOnLocationChanged); _gpsService.Connect(); Console.WriteLine("Press enter to continue..."); Console.ReadKey(); }
public MapViewModel(GpsService gpsService) { gpsService.PositionChanged += (_, _) => Application.Current.Dispatcher.InvokeAsync(() => CurrentLocation = new Location(gpsService.Position.Latitude, gpsService.Position.Longitude)); }