From d4410a92c60b6497e8caa5ff596aa38c0b885f9c Mon Sep 17 00:00:00 2001 From: aibingbing Date: Mon, 8 Jul 2024 14:42:01 +0800 Subject: [PATCH] =?UTF-8?q?[6.5.0]=20refactor:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=85=AC=E4=BA=A4=E7=AB=99=20=E9=80=BB?= =?UTF-8?q?=E8=BE=91=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busstation/PassBusStationEventManager.kt | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt index 1085da5f79..1b033096b0 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt @@ -21,6 +21,7 @@ import com.mogo.map.entities.BusStation import com.mogo.map.overlay.core.Level import com.mogo.map.overlay.point.Point import com.zhidaoauto.map.data.point.LonLatPoint +import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.SupervisorJob @@ -30,6 +31,7 @@ import mogo.telematics.pad.MessagePad import java.util.LinkedList import java.util.UUID import java.util.concurrent.atomic.AtomicBoolean +import kotlin.random.Random /** * 计算通过公交站点 管理类 @@ -38,8 +40,14 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener { const val TAG = "PassBusStationEventManager" + private val coroutineExceptionHandler = + CoroutineExceptionHandler { coroutineContext, exception -> + Logger.e(TAG, "coroutineExceptionHandler --> Handle $exception in $coroutineContext") + isCalculateNearByStation.set(false) + } + private val mCoroutineScope: CoroutineScope = - CoroutineScope(SupervisorJob() + Dispatchers.IO) + CoroutineScope(SupervisorJob() + Dispatchers.IO + coroutineExceptionHandler) // 距离当前车位置 X 米远的点集合(用来查询根据点查询roadId, 然后用roadId查询路上的公交站点) private val farthestLocationList = ArrayList() @@ -120,9 +128,11 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener { "removeNeedNotifiedBusStation --> ${it.toString()}" ) if (HmiBuildConfig.isShowBusStationStrategyBorderPoint) { - mockOtherRetroGradeVehicleData(it.getBusStationPoint().longitude, + mockOtherRetroGradeVehicleData( + it.getBusStationPoint().longitude, it.getBusStationPoint().latitude, - currentLocation.heading) + currentLocation.heading + ) } } } @@ -237,7 +247,7 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener { busStationHDMarkerStrategy() } MogoData.mogoMapData.get()?.also { iMogoData -> - val busStationList = iMogoData.getBusStation(farthestLocationList) + val busStationList = iMogoData.getBusStation(java.util.ArrayList(farthestLocationList.toMutableList())) val filteredBusStationList = busStationList.filter { it.busStationPoints.isNotEmpty() && DrivingDirectionUtils.getDegreeOfCar2Poi( @@ -259,10 +269,12 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener { ) synchronized(busStationNearByQueue) { busStationNearByQueue.clear() - busStationNearByQueue.add(busStationList) + busStationNearByQueue.add(filteredBusStationList) } + isCalculateNearByStation.set(false) + } ?: run { + isCalculateNearByStation.set(false) } - isCalculateNearByStation.set(false) } } @@ -308,7 +320,7 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener { heading, 120.0 ) - val event = MessagePad.Event.newBuilder().setEventId("123456") + val event = MessagePad.Event.newBuilder().setEventId(Random.nextLong().toString()) .setEventType(MessagePad.EventType.CONVERSE_RUNNING) .setExts("{\"cameraIp\":\"172.18.7.40\"}") .setGnssType(2)