mirror of
https://github.com/KeymonSoft/Profina-Reparto_V2.git
synced 2026-04-17 21:06:10 +00:00
6.03.26
This commit is contained in:
@@ -84,16 +84,16 @@ Sub Service_Create
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuccess
|
||||
' If B4XPages.MainPage.logger Then Log("Connected to location provider")
|
||||
' If Starter.logger Then Log("Connected to location provider")
|
||||
'FLP.GetLastKnownLocation
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionFailed(ConnectionResult1 As Int)
|
||||
If B4XPages.MainPage.logger Then Log("Failed to connect to location provider")
|
||||
If Starter.logger Then Log("Failed to connect to location provider")
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuspended(ConnectionResult1 As Int)
|
||||
If B4XPages.MainPage.logger Then Log("FLP conection suspended")
|
||||
If Starter.logger Then Log("FLP conection suspended")
|
||||
StartFLP
|
||||
End Sub
|
||||
|
||||
@@ -108,13 +108,13 @@ Sub Service_Start (StartingIntent As Intent)
|
||||
End Sub
|
||||
|
||||
Public Sub Track
|
||||
If B4XPages.MainPage.logger Then Log("Inicia Track - Tracking : "&Tracking)
|
||||
If Starter.logger Then Log("Inicia Track - Tracking : "&Tracking)
|
||||
If Tracking Then
|
||||
' Log(actualLR.GetSmallestDisplacement)
|
||||
Return 'Si ya estamos "rastreando" no hacemos nada (return)
|
||||
End If
|
||||
If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
|
||||
If B4XPages.MainPage.logger Then Log("No permission")
|
||||
If Starter.logger Then Log("No permission")
|
||||
Return
|
||||
End If
|
||||
StartFLP 'Iniciamos FusedLocationProvider
|
||||
@@ -122,7 +122,7 @@ Public Sub Track
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP
|
||||
' If B4XPages.MainPage.logger Then Log("StartFLP - flpStarted="&flpStarted)
|
||||
' If Starter.logger Then Log("StartFLP - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
' If Main.logger Then Log("sleeping")
|
||||
@@ -137,19 +137,19 @@ Public Sub StartFLP
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP2Reqs
|
||||
If B4XPages.MainPage.logger Then Log("StartFLP - flpStarted="&flpStarted)
|
||||
If Starter.logger Then Log("StartFLP - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
If B4XPages.MainPage.logger Then Log("sleeping GR")
|
||||
If Starter.logger Then Log("sleeping GR")
|
||||
Loop
|
||||
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
|
||||
FLP.RequestLocationUpdates(CreateLocationRequest2times) 'Buscamos ubicacion 2 peticiones
|
||||
If B4XPages.MainPage.logger Then Log("Buscamos ubicacion 2 peticiones")
|
||||
If B4XPages.MainPage.logger Then Log(actualLR.GetSmallestDisplacement)
|
||||
If Starter.logger Then Log("Buscamos ubicacion 2 peticiones")
|
||||
If Starter.logger Then Log(actualLR.GetSmallestDisplacement)
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest As LocationRequest
|
||||
If B4XPages.MainPage.logger Then Log("CreateLocationRequest")
|
||||
If Starter.logger Then Log("CreateLocationRequest")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(10000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
@@ -161,7 +161,7 @@ Private Sub CreateLocationRequest As LocationRequest
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest2times As LocationRequest
|
||||
If B4XPages.MainPage.logger Then Log("Iniciamos CreateLocationRequest2times")
|
||||
If Starter.logger Then Log("Iniciamos CreateLocationRequest2times")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(2000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
@@ -176,7 +176,7 @@ End Sub
|
||||
Sub dameUltimaUbicacionConocida
|
||||
If FLP.GetLastKnownLocation.IsInitialized Then 'Mandamos ultima ubicacion guardada
|
||||
' If Main.logger Then Log("Mandamos UUC : "&formatoFecha(FLP.GetLastKnownLocation.Time))
|
||||
If B4XPages.MainPage.Logger Then LogColor($"Mandamos UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|Acc:$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|Spd:$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
|
||||
If Starter.logger Then LogColor($"Mandamos UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|Acc:$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|Spd:$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
|
||||
Dim coords As String = FLP.GetLastKnownLocation.Latitude&","&FLP.GetLastKnownLocation.Longitude&","&formatoFecha(FLP.GetLastKnownLocation.Time)
|
||||
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||
Subs.mandamosLoc(coords)
|
||||
@@ -198,8 +198,8 @@ Sub flp_LocationChanged (Location1 As Location)
|
||||
CallSub2(Starter, "GPS_LocationChanged", Location1)
|
||||
' CallSub2(gestion, "GPS_LocationChanged", Location1)
|
||||
' CallSubDelayed2(gestion, "GPS_LocationChanged", Location1)
|
||||
B4XPages.MainPage.lat_gps = Location1.Latitude
|
||||
B4XPages.MainPage.lon_gps = Location1.Longitude
|
||||
Starter.lat_gps = Location1.Latitude
|
||||
Starter.lon_gps = Location1.Longitude
|
||||
'/////// para la ultima ubicacion FL
|
||||
Dim sDate,sTime As String
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
@@ -207,15 +207,15 @@ Sub flp_LocationChanged (Location1 As Location)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
Try
|
||||
Starter.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
|
||||
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, Starter.lat_gps, Starter.lon_gps))
|
||||
Catch
|
||||
If B4XPages.MainPage.logger Then Log("Error al borrar o insertar nuevas coordendas en HIST_GPS")
|
||||
If Starter.logger Then Log("Error al borrar o insertar nuevas coordendas en HIST_GPS")
|
||||
End Try
|
||||
'///////
|
||||
Dim coords As String = Location1.Latitude&","&Location1.Longitude&","&formatoFecha(Location1.Time)
|
||||
Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude)
|
||||
If B4XPages.MainPage.logger Then Log("Mandamos Ubicacion")
|
||||
If B4XPages.MainPage.logger Then Log(locRequest)
|
||||
If Starter.logger Then Log("Mandamos Ubicacion")
|
||||
If Starter.logger Then Log(locRequest)
|
||||
' Solo mandamos la ubicacion si la precision es menor a XX mts
|
||||
If Location1.Accuracy < 100 Then
|
||||
Subs.guardaInfoEnBD(coords)'Escribimos coordenadas y fecha en BD
|
||||
@@ -227,7 +227,7 @@ Sub flp_LocationChanged (Location1 As Location)
|
||||
Dim minsDif As Int = DateTime.Time(DateTime.Now) - B4XPages.MainPage.ultimaActualizacionGPS
|
||||
' If Main.logger Then Log("UltimaAct="&Main.ultimaActualizacionGPS&" MinsDif="&minsDif)
|
||||
If Location1.Accuracy < 100 And minsDif > 240 Then 'Si precision de 100 y 4 min transcurridos manda a web
|
||||
If B4XPages.MainPage.logger Then Log("actualizamos Ubicacion Web")
|
||||
If Starter.logger Then Log("actualizamos Ubicacion Web")
|
||||
CallSubDelayed(Starter, "ENVIA_ULTIMA_GPS")
|
||||
End If
|
||||
DateTime.TimeFormat = origFormat 'Regresamos formato de fecha original
|
||||
|
||||
Reference in New Issue
Block a user