Navigációs térkép és útvoanlrögzítés hibáinak javítása
This commit is contained in:
@@ -51,26 +51,48 @@ class VibroNavController extends GetxController {
|
||||
|
||||
// ── Periodikus napló ───────────────────────────────────────────────
|
||||
final isLogging = false.obs;
|
||||
final logIntervalSec = 60.obs; // felhasználó által állítható
|
||||
final logIntervalSec = 5.obs; // felhasználó által állítható
|
||||
final logs = <VehiclePositionLog>[].obs;
|
||||
Timer? _logTimer;
|
||||
|
||||
// ── Térkép — a MapController itt él, nem a View State-jében ────────
|
||||
final mapController = MapController();
|
||||
|
||||
StreamSubscription? _gnssUpdateSub;
|
||||
|
||||
/// A kezdő térképközéppont lekérdezése (gyors, telefon-GPS-alapú)
|
||||
/// befejeződött-e — a View ez alapján dönti el, mikor építse fel a
|
||||
/// térképet, hogy ne induljon rossz (pl. budapesti) középponttal.
|
||||
final mapReady = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
load();
|
||||
refreshLogs();
|
||||
if (Get.isRegistered<GnssService>()) {
|
||||
ever(GnssService.to.lastGgaLine, (_) => _onPosition());
|
||||
// FONTOS: a lastGgaLine csak NMEA (külső BT/BLE vevő) esetén
|
||||
// frissül — telefon GPS-nél sosem. Az onDataUpdated viszont
|
||||
// MINDKÉT forrásnál lefut, ez a helyes, egységes jelzés.
|
||||
_gnssUpdateSub =
|
||||
GnssService.to.onDataUpdated.listen((_) => _onPosition());
|
||||
GnssService.to.determineInitialPosition().whenComplete(() {
|
||||
mapReady.value = true;
|
||||
});
|
||||
} else {
|
||||
mapReady.value = true;
|
||||
}
|
||||
// Automatikus indítás: amint van pozíció ÉS ki van választva jármű,
|
||||
// induljon a rögzítés — korábban ez a bekötés hiányzott, a
|
||||
// _tryAutoStart() metódust semmi nem hívta meg.
|
||||
ever(hasPosition, (_) => _tryAutoStart());
|
||||
ever(VehicleIdentityService.to.selectedVehicle, (_) => _tryAutoStart());
|
||||
}
|
||||
|
||||
@override
|
||||
void onClose() {
|
||||
_logTimer?.cancel();
|
||||
_gnssUpdateSub?.cancel();
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@@ -194,6 +216,13 @@ class VibroNavController extends GetxController {
|
||||
_logTimer = null;
|
||||
}
|
||||
|
||||
void _tryAutoStart() {
|
||||
if (isLogging.value) return;
|
||||
if (!hasPosition.value) return;
|
||||
if (VehicleIdentityService.to.selectedVehicle.value == null) return;
|
||||
startLogging();
|
||||
}
|
||||
|
||||
Future<void> _logTick() async {
|
||||
if (!hasPosition.value) return;
|
||||
final projectId = ProjectService.to.activeProjectId;
|
||||
|
||||
Reference in New Issue
Block a user