From 3022b877d0cf9b7546c80953237c7bca5a4afa50 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Tue, 26 Sep 2023 19:32:13 -0600 Subject: [shared] Fix hourmeter for some devices --- .../trackermap/TrackerMap/client/models/UnitInformation.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'shared') diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt index 6afa350..33e85ee 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/UnitInformation.kt @@ -53,5 +53,15 @@ data class UnitInformation( } ?: EngineStop.UNKNOWN } else EngineStop.UNKNOWN - fun getHourmeter() = position?.attributes?.get("hours")?.longOrNull + fun getHourmeter() = position?.attributes?.let { attrs -> + if ("io16" in attrs) { + // Minutes + attrs["io16"]?.longOrNull?.let { it * 60 * 1000 } + } else if ("hours" in attrs) { + // Milliseconds + attrs["hours"]?.longOrNull + } else { + null + } + } } \ No newline at end of file -- cgit v1.2.3