From ab1078209e92411d1ee493ceb45641ffe3e5bfcf Mon Sep 17 00:00:00 2001 From: renwj Date: Mon, 13 Feb 2023 17:06:36 +0800 Subject: [PATCH 1/5] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=E5=90=88=E5=B9=B6V?= =?UTF-8?q?2X=E6=A8=A1=E5=9D=97=E6=97=A0=E7=94=A8=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AE=9E=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- config.gradle | 2 +- .../function/v2x/events/V2XEventManager.kt | 12 +- .../manager/impl/MoGoV2XMarkerManager.java | 10 +- .../scenario/scene/airoad/AiRoadMarker.kt | 1 - .../scene/road/V2XAiRoadEventMarker.kt | 76 ++++-------- .../scene/road/V2XRoadEventMarker.java | 71 ++++------- .../function/v2x/events/utils/EntityUtils.kt | 117 ++++-------------- .../v2x/internal/data/V2XMarkerCardResult.kt | 13 +- .../data/map/entity/MarkerExploreWay.java | 23 +++- 10 files changed, 113 insertions(+), 214 deletions(-) diff --git a/build.gradle b/build.gradle index cbd64fba4f..afc1ee4733 100644 --- a/build.gradle +++ b/build.gradle @@ -35,7 +35,7 @@ buildscript { classpath 'com.mogo.cloud:systrace:1.0.1' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18' classpath 'com.mogo.sticky:service:1.0.8' - classpath 'io.github.knight-zxw:lancet-plugin:0.0.4' + classpath 'io.github.knight-zxw:lancet-plugin:0.0.4_mogo' // classpath ("com.tencent.matrix:matrix-gradle-plugin:0.6.6") { changing = true } } diff --git a/config.gradle b/config.gradle index 5365d0898b..c95cde91f4 100644 --- a/config.gradle +++ b/config.gradle @@ -220,7 +220,7 @@ ext { //========================= LancetX =================== - lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.4", + lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.4_mogo", //========================= autosize ====================== androidautoSize : 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1', diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt index 7f0be345a3..1c40d47f56 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt @@ -52,13 +52,12 @@ import com.mogo.eagle.core.function.v2x.events.utils.toV2XRoadEventEntity import com.mogo.eagle.core.function.v2x.internal.V2XManager import com.mogo.eagle.core.function.v2x.internal.callback.IV2XCallback import com.mogo.eagle.core.function.v2x.internal.config.V2XConfig -import com.mogo.eagle.core.function.v2x.internal.data.V2XAdvanceWarning -import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerCardResult -import com.mogo.eagle.core.function.v2x.internal.data.V2XWarningTarget +import com.mogo.eagle.core.function.v2x.internal.data.* import com.mogo.eagle.core.function.v2x.internal.event.V2XEvent import com.mogo.eagle.core.function.v2x.road.V2XEventServiceApi import com.mogo.eagle.core.network.MoGoRetrofitFactory import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.Logger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler @@ -209,6 +208,13 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback, } handleRoadMarkerEvent(event.data.toRoadMarker()) } + + is V2XEvent.RoadEventX -> { + handleRoadMarkerEvent(event.data.toRoadMarker()) + } + else -> { + Logger.e(TAG, "onAck other event: $event") + } } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java index 7b0d9d278e..327a28d209 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/manager/impl/MoGoV2XMarkerManager.java @@ -90,18 +90,18 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager { // 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常 mV2XRoadEventEntityArrayList.clear(); // 获取探路以及新鲜事儿 - List exploreWayList = markerCardResult.getExploreWay(); + List exploreWayList = markerCardResult.getExploreWay(); if (exploreWayList != null) { - for (V2XMarkerExploreWay markerExploreWay : exploreWayList) { + for (MarkerExploreWay markerExploreWay : exploreWayList) { if (EventTypeEnumNew.isRoadEvent(markerExploreWay.getPoiType())) { - V2XMarkerLocation markerLocation = markerExploreWay.getLocation(); + MarkerLocation markerLocation = markerExploreWay.getLocation(); // 记录道路事件 V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity(); - v2XRoadEventEntity.setLocation(EntityUtilsKt.toMarkerLocation(markerLocation)); + v2XRoadEventEntity.setLocation(markerLocation); // 探路目前只有上报拥堵 String poi = markerExploreWay.getPoiType(); v2XRoadEventEntity.setPoiType(poi); - v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay, markerCardResult.getExtras())); + v2XRoadEventEntity.setNoveltyInfo(markerExploreWay); v2XRoadEventEntity.setExpireTime(20000); mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity); } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt index 1a1bc8ce6c..c088868c50 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt @@ -7,7 +7,6 @@ import android.os.Looper import android.view.animation.DecelerateInterpolator import androidx.core.util.Pair import com.mogo.cloud.commons.utils.* -import com.mogo.commons.AbsMogoApplication import com.mogo.eagle.core.data.map.MogoLatLng import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity import com.mogo.eagle.core.function.call.autopilot.* diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt index 26dacad912..2a1ee214bd 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt @@ -18,63 +18,39 @@ class V2XAiRoadEventMarker { private val current = AtomicReference?>>() - private val v2xLocation = AtomicReference() - private val overlayManager by lazy { CallerMapUIServiceManager.getOverlayManager() } fun drawMarkers(entity: V2XRoadEventEntity, wrapper: MarkerWrapper) { - val extra = entity.noveltyInfo.extras["polygon"] + val polygon = entity.noveltyInfo.polygon v2xMarker()?.drawableAlarmPOI(context(), entity, null)?.also { wrapper.addMarker(it) } - if (extra is List<*> && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) { - if (extra.size > 0) { - val polygons: MutableList> = ArrayList() - for (i in extra.indices) { - val o = extra[i]!! as? androidx.core.util.Pair<*, *> ?: continue - val first = o.first - val second = o.second - if (first == null || second == null) { - continue - } - if (first !is Double || second !is Double) { - continue - } - polygons.add(androidx.core.util.Pair.create(second, first)) - } - if (polygons.size > 0) { - val l2 = entity.noveltyInfo?.location ?: return - v2xLocation.set(MogoLocation().also { - it.longitude = l2.lon; it.latitude = l2.lat; it.heading = l2.angle - }) + if (polygon != null && polygon.isNotEmpty() && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) { + val options = MogoPolylineOptions() + val colors = ArrayList() + colors.add(Color.argb(204, 237, 172, 21)) + colors.add(Color.argb(0, 255, 255, 255)) + options.colorValues(colors) + val points = ArrayList() - val options = MogoPolylineOptions() - val colors = ArrayList() - colors.add(Color.argb(204, 237, 172, 21)) - colors.add(Color.argb(0, 255, 255, 255)) - options.colorValues(colors) - val points = ArrayList() - - for (p in polygons) { - points.add(MogoLatLng(p.first, p.second)) - } - if (points.size > 2) { - points.add(points[0]) - } - options.points(points) - options.useGradient(true) - options.useFacade(true) - options.setGps(true) - options.width(5f) - options.zIndex(75000f) - options.maxIndex(800000f) - val line = overlayManager?.addPolyline(options) - line?.let { - current.set(Pair(line, wrapper.markers)) - line.isVisible = true - wrapper.addLine(line) - } - } + for (p in polygon) { + points.add(MogoLatLng(p.first, p.second)) + } + if (points.size > 2) { + points.add(points[0]) + } + options.points(points) + options.useGradient(true) + options.useFacade(true) + options.setGps(true) + options.width(5f) + options.zIndex(75000f) + options.maxIndex(800000f) + val line = overlayManager?.addPolyline(options) + line?.let { + current.set(Pair(line, wrapper.markers)) + line.isVisible = true + wrapper.addLine(line) } } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java index a743246918..b97689f35b 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java @@ -1,9 +1,7 @@ package com.mogo.eagle.core.function.v2x.events.scenario.scene.road; import android.util.Log; - import androidx.core.util.Pair; - import com.mogo.eagle.core.data.enums.EventTypeEnumNew; import com.mogo.eagle.core.data.map.entity.MarkerExploreWay; import com.mogo.eagle.core.data.map.entity.MarkerLocation; @@ -15,7 +13,6 @@ import com.mogo.eagle.core.function.v2x.events.remove.MarkerRemoveManager; import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker; import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker; import com.mogo.map.marker.IMogoMarker; - import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -34,10 +31,21 @@ public class V2XRoadEventMarker implements IV2XMarker { if (marker != null) { if (entity != null) { Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType()); - if (!Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType()) - && !Objects.equals(entity.getPoiType(), EventTypeEnumNew.FOURS_ACCIDENT_04.getPoiType()) - && !Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType()) - && !Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType())) { + if (isAiRoadEvent(entity.getPoiType())) { + MarkerExploreWay noveltyInfo = entity.getNoveltyInfo(); + Log.d("RWJ", "V2XRoadEventMarker -> noveltyInfo:" + noveltyInfo); + if (noveltyInfo != null) { + Pair gpsLocation = noveltyInfo.getGpsLocation(); + List> polygons = noveltyInfo.getPolygon(); + if (gpsLocation != null && polygons != null) { + MarkerLocation location = noveltyInfo.getLocation(); + AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity); + AiRoadMarker aiMarker = new AiRoadMarker(); + aiMarker.marker(m, true, isDrawRoadLine(m.getPoiType())); + AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker); + } + } + } else { IMogoMarker iMarker = marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null); if (iMarker != null) { Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- add Marker"); @@ -48,48 +56,6 @@ public class V2XRoadEventMarker implements IV2XMarker { } else { Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- return empty marker"); } - } else { - MarkerExploreWay noveltyInfo = entity.getNoveltyInfo(); - Log.d("RWJ", "V2XRoadEventMarker -> noveltyInfo:" + noveltyInfo); - if (noveltyInfo != null && noveltyInfo.extras != null) { - List> polygons = new ArrayList<>(); - Pair gpsLocation = null; - if (noveltyInfo.extras.containsKey("polygon")) { - Object extra = noveltyInfo.extras.get("polygon"); - if (extra instanceof List) { - List l = (List) extra; - if (l.size() > 0) { - for (int i = 0; i < l.size(); i++) { - Object o = l.get(i); - if (!(o instanceof Pair)) { - continue; - } - Pair p = (Pair) o; - Object first = p.first; - Object second = p.second; - if (first == null || second == null) { - continue; - } - if (!(first instanceof Double) || !(second instanceof Double)) { - continue; - } - polygons.add(Pair.create((Double) first, (Double) second)); - } - } - } - } - - if (noveltyInfo.extras.containsKey("gps_location")) { - gpsLocation = (Pair) ((List)(noveltyInfo.extras.get("gps_location"))).get(0); - } - if (!polygons.isEmpty() && gpsLocation != null) { - MarkerLocation location = noveltyInfo.getLocation(); - AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity); - AiRoadMarker aiMarker = new AiRoadMarker(); - aiMarker.marker(m, true, isDrawRoadLine(m.getPoiType())); - AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker); - } - } } } } @@ -98,6 +64,13 @@ public class V2XRoadEventMarker implements IV2XMarker { } } + private boolean isAiRoadEvent(String poiType) { + return Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType()) + && Objects.equals(poiType, EventTypeEnumNew.FOURS_ACCIDENT_04.getPoiType()) + && Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType()) + && Objects.equals(poiType, EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType()); + } + private boolean isDrawRoadLine(String poiType) { return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType); } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt index 65ebd78c9d..0b8602e86e 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/utils/EntityUtils.kt @@ -4,7 +4,6 @@ import androidx.core.util.Pair import com.mogo.eagle.core.data.enums.EventTypeEnumNew.Companion.isRoadEvent import com.mogo.eagle.core.data.map.entity.MarkerExploreWay import com.mogo.eagle.core.data.map.entity.MarkerLocation -import com.mogo.eagle.core.data.map.entity.MarkerUserInfo import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker import com.mogo.eagle.core.function.v2x.internal.data.* @@ -13,85 +12,24 @@ import mogo.telematics.pad.MessagePad import roadwork.Road -fun V2XMarkerLocation?.toMarkerLocation(): MarkerLocation? = - if (this == null) null else MarkerLocation().also { - it.lon = this.lon - it.lat = this.lat - it.address = this.address - it.angle = this.angle - } - -fun MarkerExploreWayItem?.toMarkerExploreWayItem(): com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem? = - if (this == null) null else com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem().also { - it.illegalCount = this.illegalCount - it.content = this.content - it.url = this.url - it.thumbnail = this.thumbnail - } - -fun V2XMarkerUserInfo?.toMarkerUserInfo(): MarkerUserInfo? = - if (this == null) null else MarkerUserInfo().also { - it.safeLabelType = this.safeLabelType - it.safeLabel = this.safeLabel - it.lastActiveweekAvgscore = this.lastActiveweekAvgscore - it.gender = this.gender - it.userHead = this.userHead - it.userName = this.userName - it.setAge(this.age) - } - -fun V2XMarkerExploreWay.toMarkExploreWay(extras: Map? = null): MarkerExploreWay = - MarkerExploreWay().also { - it.items = this.items?.map { itx -> itx.toMarkerExploreWayItem() } - it.userInfo = this.userInfo?.toMarkerUserInfo() - it.distance = this.distance - it.cityName = this.cityName - it.setGenerateTime(this.generateTime) - it.infoId = this.infoId - it.setFileType(this.fileType) - it.setDirection(this.direction) - it.location = this.location?.toMarkerLocation() - it.sn = this.sn - it.canLive = this.canLive != "0" - it.poiType = this.poiType - it.type = this.type - it.infoCheckNode = this.infoCheckNode - it.isFabulous = this.isFabulous - it.uploadType = this.uploadType - it.isCanLive = this.canLive != "0" - it.extras = extras - } - fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult = V2XMarkerCardResult().also { l1 -> - this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old -> - l1.extras = HashMap>>().also { extra -> - extra["polygon"] = old.map { d -> - Pair(d.lon, d.lat) - } - - extra["gps_location"] = listOf( - Pair( - this.roadwork?.center?.point?.lon ?: 0.0, - this.roadwork?.center?.point?.lat ?: 0.0 - ) - ) - } - } val centerX = this.roadwork?.center?.point?.lon ?: 0.0 val centerY = this.roadwork?.center?.point?.lat ?: 0.0 val id = "${centerX}_${centerY}" - l1.exploreWay = ArrayList().also { l2 -> - l2.add(V2XMarkerExploreWay().also { l3 -> + l1.exploreWay = ArrayList().also { l2 -> + l2.add(MarkerExploreWay().also { l3 -> l3.poiType = this.roadwork?.poiType?.toString() - l3.generateTime = this.roadwork?.detectTime ?: 0L - l3.location = V2XMarkerLocation().also { l4 -> + l3.setGenerateTime(this.roadwork?.detectTime ?: 0L) + l3.location = MarkerLocation().also { l4 -> val p = CoordinateTransform.WGS84ToGCJ02(this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.point?.lat ?: 0.0) l4.lon = p[0] l4.lat = p[1] l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0 } l3.infoId = id + l3.gpsLocation = Pair(this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.point?.lat ?: 0.0) + l3.polygon = this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { Pair(it.lon, it.lat) } }) } AiRoadMarker.aiMakers[id]?.receive() @@ -99,52 +37,41 @@ fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult = fun V2XRoadXData.toRoadMarker(): V2XMarkerCardResult = V2XMarkerCardResult().also { l1 -> - this.polygon?.takeIf { it.isNotEmpty() }?.also { old -> - l1.extras = HashMap>>().also { extra -> - extra["polygon"] = old.map { d -> - Pair(d.lon, d.lat) - } - extra["gps_location"] = listOf(Pair(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0)) - } - } - - l1.exploreWay = ArrayList().also { l2 -> - l2.add(V2XMarkerExploreWay().also { l3 -> + l1.exploreWay = ArrayList().also { l2 -> + l2.add(MarkerExploreWay().also { l3 -> l3.poiType = this.poiType - l3.generateTime = this.detectTime ?: 0L - l3.location = V2XMarkerLocation().also { l4 -> + l3.setGenerateTime(this.detectTime ?: 0L) + l3.location = MarkerLocation().also { l4 -> val p = CoordinateTransform.WGS84ToGCJ02(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0) l4.lon = p[0] l4.lat = p[1] l4.angle = this.centerRoad?.bearing ?: 0.0 } l3.infoId = this.index + l3.gpsLocation = Pair(this.center?.lon ?: 0.0, this.center?.lat ?: 0.0) + l3.polygon = this.polygon?.takeIf { it.isNotEmpty() }?.map { Pair(it.lon, it.lat) } }) } - AiRoadMarker.aiMakers[this.index]?.receive() } fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult = V2XMarkerCardResult().also { l1 -> - this.polygonList?.takeIf { it.isNotEmpty() }?.also { old -> - l1.extras = HashMap>>().also { extra -> - extra["polygon"] = old.map { d -> Pair(d.longitude, d.latitude) } - extra["gps_location"] = listOf(Pair(this.longitude, this.latitude)) - } - } val id = "${this.longitude}_${this.latitude}" - l1.exploreWay = ArrayList().also { l2 -> - l2.add(V2XMarkerExploreWay().also { l3 -> + l1.exploreWay = ArrayList().also { l2 -> + l2.add(MarkerExploreWay().also { l3 -> l3.poiType = poiType - l3.generateTime = 0L - l3.location = V2XMarkerLocation().also { l4 -> + l3.setGenerateTime(0L) + l3.location = MarkerLocation().also { l4 -> val p = CoordinateTransform.WGS84ToGCJ02(this.longitude, this.latitude) l4.lon = p[0] l4.lat = p[1] l4.angle = this.heading } l3.infoId = id + + l3.gpsLocation = Pair(this.longitude, this.latitude) + l3.polygon = this.polygonList?.takeIf { it.isNotEmpty() }?.map { Pair(it.longitude, it.latitude) } }) } AiRoadMarker.aiMakers[id]?.receive() @@ -152,14 +79,14 @@ fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult fun V2XMarkerCardResult.toV2XRoadEventEntity(): V2XRoadEventEntity = V2XRoadEventEntity().also { l1 -> - val exploreWayList: List? = this.exploreWay + val exploreWayList: List? = this.exploreWay if (!exploreWayList.isNullOrEmpty() && exploreWayList.isNotEmpty()) { for (markerExploreWay in exploreWayList) { if (isRoadEvent(markerExploreWay.poiType)) { val markerLocation = markerExploreWay.location - l1.location = markerLocation.toMarkerLocation() + l1.location = markerLocation l1.poiType = markerExploreWay.poiType - l1.noveltyInfo = markerExploreWay.toMarkExploreWay(this.extras) + l1.noveltyInfo = markerExploreWay l1.expireTime = 20000 } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt index db6a6b5754..a486687d10 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/internal/data/V2XMarkerCardResult.kt @@ -1,6 +1,8 @@ package com.mogo.eagle.core.function.v2x.internal.data import androidx.annotation.Keep +import com.mogo.eagle.core.data.map.entity.MarkerExploreWay +import com.mogo.eagle.core.data.map.entity.MarkerLocation import java.io.Serializable @Keep @@ -41,20 +43,15 @@ class V2XMarkerCardResult: V2XBaseData(), Serializable { /** * 探路数据集合 */ - var exploreWay: List? = null + var exploreWay: List? = null /** * 服务端下发消息时间 */ var messageTime: Long = 0 - /** - * 额外信息 - */ - var extras: Map? = null - override fun toString(): String { - return "MarkerCardResult(dataType=$dataType, carChat=$carChat, shareMusic=$shareMusic, noveltyInfo=$noveltyInfo, onlineCar=$onlineCar, exploreWay=$exploreWay, messageTime=$messageTime, extras=$extras)" + return "MarkerCardResult(dataType=$dataType, carChat=$carChat, shareMusic=$shareMusic, noveltyInfo=$noveltyInfo, onlineCar=$onlineCar, exploreWay=$exploreWay, messageTime=$messageTime)" } } @@ -369,7 +366,7 @@ class V2XMarkerExploreWay: Serializable { /** * 位置信息 */ - var location: V2XMarkerLocation? = null + var location: MarkerLocation? = null /** * 车辆方位 diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java index 8516d97fcf..12287a8b76 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/map/entity/MarkerExploreWay.java @@ -4,6 +4,8 @@ package com.mogo.eagle.core.data.map.entity; import android.text.TextUtils; +import androidx.core.util.Pair; + import java.io.Serializable; import java.util.List; import java.util.Map; @@ -35,7 +37,10 @@ public class MarkerExploreWay implements Serializable { // 1 需要用户判断是否拥堵 进行UGC问答 private int infoCheckNode; - public Map extras = null; + + private Pair gpsLocation; + + private List> polygon; public String getAddr() { if (TextUtils.isEmpty(addr)) { @@ -170,6 +175,22 @@ public class MarkerExploreWay implements Serializable { this.uploadType = uploadType; } + public Pair getGpsLocation() { + return gpsLocation; + } + + public void setGpsLocation(Pair gpsLocation) { + this.gpsLocation = gpsLocation; + } + + public List> getPolygon() { + return polygon; + } + + public void setPolygon(List> polygon) { + this.polygon = polygon; + } + @Override public boolean equals(Object o) { if (this == o) return true; From 4bd358d830ee04171e707002fbcd6a3747e39187 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 13 Feb 2023 17:22:01 +0800 Subject: [PATCH 2/5] [2.13.0-arch-opt] update ai cloud version to fit url --- config.gradle | 3 --- .../datacenter/v2x/TrafficLightDispatcher.kt | 2 +- .../startup/stageone/HttpDnsStartUp.kt | 2 +- gradle.properties | 24 +++++++------------ 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/config.gradle b/config.gradle index c95cde91f4..fab8cfd576 100644 --- a/config.gradle +++ b/config.gradle @@ -126,9 +126,6 @@ ext { mogocustommapoperational : "com.zhidaoauto.map:operational:${MAP_SDK_OPERATION_VERSION}", modulemap : "com.mogo.module:module-map:${MOGO_MODULE_MAP_VERSION}", - chat : "com.mogo.module.carchatim:module-chat:${MOGO_MODULE_CHAT_VERSION}", - callchat : "com.mogo.module.carchatim:module-carchatting:${MOGO_MODULE_CARCHATTING_VERSION}", - callchatprovider : "com.mogo.module.carchatim:module-carchatting-provider:${MOGO_MODULE_CARCHATTINGPROVIDER_VERSION}", // V2X moduleV2x : "com.mogo.module:module-v2x:${MOGO_MODULE_V2X_VERSION}", diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt index 8ae5886370..06eb44312b 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt @@ -136,7 +136,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight super.onTrafficLightPlusSource(light, remain, lightSource) if (lightSource == DataSourceType.OBU) { - hasObuLightStatus = true //todo 会存在优先级高的数据没有回调,导致没有数据出现 + hasObuLightStatus = true } CallerTrafficLightListenerManager.showTrafficLight(light, lightSource) diff --git a/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt b/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt index 6c7cc96d89..6e5e4f6cb9 100644 --- a/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt +++ b/core/function-impl/mogo-core-function-startup/src/main/java/com/mogo/eagle/core/function/startup/stageone/HttpDnsStartUp.kt @@ -132,7 +132,7 @@ class HttpDnsStartUp : AndroidStartup() { } else { clientConfig.thirdPartyDeviceId = Utils.getDevicesId() } - //设置长链接的secretKey //todo 通过SHA1和包名找中台服务生成,后续包名分渠道,需要做对应操作 + //设置长链接的secretKey 通过SHA1和包名找中台服务生成,后续包名分渠道,需要做对应操作 clientConfig.secretKey = "YMj2VFDFxJ3Q4gNoZceJ" clientConfig.iHttpDnsCurrentLocation = object : IHttpDnsCurrentLocation { diff --git a/gradle.properties b/gradle.properties index 8764d7688e..9c88990a89 100644 --- a/gradle.properties +++ b/gradle.properties @@ -66,23 +66,23 @@ SERVICE_BIZ_VERSION=1.2.4 LOGLIB_VERSION=1.5.10 ######## MogoAiCloudSDK Version ######## # 网络请求LOGLIB_VERSION -MOGO_NETWORK_VERSION=1.4.3.32-beta3 +MOGO_NETWORK_VERSION=1.4.4.1 # 鉴权 -MOGO_PASSPORT_VERSION=1.4.3.32-beta3 +MOGO_PASSPORT_VERSION=1.4.4.1 # 常链接 -MOGO_SOCKET_VERSION=1.4.3.32-beta3 +MOGO_SOCKET_VERSION=1.4.4.1 # 数据采集 -MOGO_REALTIME_VERSION=1.4.3.32-beta3 +MOGO_REALTIME_VERSION=1.4.4.1 # 探路,道路事件发布,获取 -MOGO_TANLU_VERSION=1.4.3.32-beta3 +MOGO_TANLU_VERSION=1.4.4.1 # 直播推流 -MOGO_LIVE_VERSION=1.4.3.32-beta3 +MOGO_LIVE_VERSION=1.4.4.1 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.4.3.32-beta3 +MOGO_TRAFFICLIVE_VERSION=1.4.4.1 # 定位服务 -MOGO_LOCATION_VERSION=1.4.3.32-beta3 +MOGO_LOCATION_VERSION=1.4.4.1 # 远程通讯模块 -MOGO_TELEMATIC_VERSION=1.4.3.32-beta2 +MOGO_TELEMATIC_VERSION=1.4.4.1 ######## MogoAiCloudSDK Version ######## # 自研地图 MAP_SDK_VERSION=2.10.0.2_test_01 @@ -130,12 +130,6 @@ TTS_NOOP_VERSION=2.1.16.10 # 自研地图 MAP_CUSTOM_VERSION=2.1.16.10 -# 车聊聊 -MOGO_MODULE_CHAT_VERSION=2.1.16.10 -MOGO_MODULE_CARCHATTING_VERSION=2.1.16.10 -# 车聊聊接口 -MOGO_MODULE_CARCHATTINGPROVIDER_VERSION=2.1.16.10 - # OCH MOGO_OCH_VERSION=2.1.16.10-test MOGO_OCH_BUS_VERSION=2.0.66 From c0b85f8d2c440e576fea41603e4e2e0461f888eb Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Mon, 13 Feb 2023 17:37:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?[Opt]=E5=85=A8=E8=A7=88=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E3=80=81Koom=E5=88=9D=E5=A7=8B=E5=8C=96=E5=86=85=E8=81=9A?= =?UTF-8?q?=E5=88=B0=E5=90=84=E8=87=AA=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eagle/function/biz/FuncBizProvider.kt | 6 +---- .../mogo-core-function-devatools/build.gradle | 2 ++ .../DevaToolsProvider.kt | 8 +++++- .../koom}/KoomInitTask.kt | 2 +- .../function/main/MainMoGoApplication.java | 26 +------------------ .../function/api/biz/IMoGoFuncBizProvider.kt | 2 -- 6 files changed, 12 insertions(+), 34 deletions(-) rename core/function-impl/{mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main => mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/koom}/KoomInitTask.kt (94%) diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt index 6f37a8d741..86a2933f6e 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/FuncBizProvider.kt @@ -26,7 +26,7 @@ class FuncBizProvider : IMoGoFuncBizProvider { noticeSocketManager.init(context) dispatchAutoPilotManager.init(context) cronTaskManager.startCronTask() - + OverviewDb.getDb(context) MogoTrafficLightManager.INSTANCE.initServer(context) VipCarManager.INSTANCE.initServer(context) // RedLightWarningManager.INSTANCE.listenTrafficLight() @@ -75,10 +75,6 @@ class FuncBizProvider : IMoGoFuncBizProvider { OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn) } - override fun initOverViewDb(context: Context) { - OverviewDb.getDb(context) - } - override fun onDestroy() { noticeSocketManager.release() dispatchAutoPilotManager.release() diff --git a/core/function-impl/mogo-core-function-devatools/build.gradle b/core/function-impl/mogo-core-function-devatools/build.gradle index 1467c96245..61321d4b6b 100644 --- a/core/function-impl/mogo-core-function-devatools/build.gradle +++ b/core/function-impl/mogo-core-function-devatools/build.gradle @@ -84,6 +84,8 @@ dependencies { implementation rootProject.ext.dependencies.androidxrecyclerview implementation rootProject.ext.dependencies.flexbox implementation rootProject.ext.dependencies.androidautoSize + implementation rootProject.ext.dependencies.koomnative + implementation rootProject.ext.dependencies.koomxhook if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogo_core_utils diff --git a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt index 7177fa3033..f27e3087b9 100644 --- a/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/DevaToolsProvider.kt @@ -5,6 +5,8 @@ import android.content.Context import android.view.View import android.view.ViewGroup import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.debug.DebugConfig import com.mogo.eagle.core.data.EnvConfig import com.mogo.eagle.core.data.bindingcar.ModifyBindingcarInfo import com.mogo.eagle.core.data.constants.MogoServicePaths @@ -16,10 +18,11 @@ import com.mogo.eagle.core.function.api.devatools.IDevaToolsProvider import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig -import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager import com.zhjt.mogo_core_function_devatools.binding.BindingCarManager.Companion.bindingCarManager +import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigCenter.Companion.bizConfigCenter import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigImpl +import com.zhjt.mogo_core_function_devatools.koom.KoomInitTask import com.zhjt.mogo_core_function_devatools.logcatch.MogoLogCatchManager import com.zhjt.mogo_core_function_devatools.mofang.MoFangManager.Companion.moFangManager import com.zhjt.mogo_core_function_devatools.monitor.MonitorManager @@ -46,6 +49,9 @@ class DevaToolsProvider : IDevaToolsProvider { } override fun initBiz() { + if (DebugConfig.isDebug()) { + KoomInitTask.init(AbsMogoApplication.getApp()) + } ttsManager.initTts(mContext!!) //todo //链路相关 traceManager.init(mContext!!) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/KoomInitTask.kt b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/koom/KoomInitTask.kt similarity index 94% rename from core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/KoomInitTask.kt rename to core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/koom/KoomInitTask.kt index 4fb06a0f67..6fca530bea 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/KoomInitTask.kt +++ b/core/function-impl/mogo-core-function-devatools/src/main/java/com/zhjt/mogo_core_function_devatools/koom/KoomInitTask.kt @@ -1,4 +1,4 @@ -package com.mogo.eagle.core.function.main +package com.zhjt.mogo_core_function_devatools.koom import android.app.Application import android.os.Build diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java index bcdd678bd5..4ef06c5609 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/main/MainMoGoApplication.java @@ -3,35 +3,23 @@ package com.mogo.eagle.core.function.main; import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_HMI; import android.annotation.SuppressLint; -import android.app.NotificationManager; import android.content.Context; import android.os.Process; -import androidx.annotation.Nullable; -import androidx.core.app.NotificationCompat; - import com.bytedance.boost_multidex.BoostMultiDex; -import com.elegant.utils.UiThreadHandler; import com.mogo.cloud.socket.SocketBuildConfig; import com.mogo.commons.AbsMogoApplication; -import com.mogo.commons.debug.DebugConfig; import com.mogo.commons.module.MogoModule; import com.mogo.commons.module.MogoModulePaths; import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.constants.MoGoConfig; import com.mogo.eagle.core.data.constants.MogoServicePaths; import com.mogo.eagle.core.function.api.chat.biz.ChatConsts; -import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener; -import com.mogo.eagle.core.function.call.biz.CallerFuncBizManager; import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager; -import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsUpgradeListenerManager; -import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager; import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; -import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; import com.mogo.eagle.core.utilcode.util.ProcessUtils; import com.mogo.eagle.core.utilcode.util.SPUtils; @@ -41,7 +29,7 @@ import java.text.SimpleDateFormat; import java.util.Date; /** - * 默认初始化一些基础服务配置 todo 分离 overView业务 和 msgBox去各自模块中 --- 扶风 + * 默认初始化一些基础服务配置 todo 分离 msgBox去自己的模块中 --- 扶风 */ public abstract class MainMoGoApplication extends AbsMogoApplication { @@ -61,10 +49,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { initTipToast(); initModules(); if (ProcessUtils.isMainProcess(this)) { - initOverviewDb(); - if (DebugConfig.isDebug()) { - initKoom(); - } clearMessageBoxTable(); CallerMsgBoxManager.INSTANCE.queryAllMessages(this); } @@ -109,10 +93,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { }).start(); } - private void initKoom() { - KoomInitTask.INSTANCE.init(this); - } - /** * 初始化异常采集配置 */ @@ -135,10 +115,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication { CallerDevaToolsManager.INSTANCE.init(); } - private void initOverviewDb() { - CallerFuncBizManager.getBizProvider().initOverViewDb(this); - } - private void initModules() { CallerLogger.INSTANCE.d(M_HMI + TAG, "initModules"); // OBU 模块 diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt index 774812ef84..360416ca62 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/biz/IMoGoFuncBizProvider.kt @@ -56,6 +56,4 @@ interface IMoGoFuncBizProvider : IMoGoFunctionServerProvider { fun fetchInfStructures() fun getAllV2XEvents() - - fun initOverViewDb(context: Context) } \ No newline at end of file From b09750fd2a9669d8a8e936790b1129b6fba6d69d Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Mon, 13 Feb 2023 17:37:50 +0800 Subject: [PATCH 4/5] =?UTF-8?q?[Fix]=E6=88=90=E5=91=98=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=9C=A8init=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E4=B9=8B=E5=90=8E=E5=AF=BC=E8=87=B4=E7=A9=BA=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eagle/core/function/view/OverMapView.kt | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt index 6182939d78..b32b7b3793 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/OverMapView.kt @@ -52,7 +52,8 @@ class OverMapView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 -) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener { +) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener, + IMoGoPlanningRottingListener { // =============自定义属性相关============= private var mapStylePath: String? = null @@ -166,7 +167,7 @@ class OverMapView @JvmOverloads constructor( overLayerView?.background = resources.getDrawable(if (resetDrawable != -1) resetDrawable else R.drawable.amap_reset) arrivedBitmap = BitmapDescriptorFactory.fromResource(if (arrivedDrawable != -1) arrivedDrawable else R.drawable.taxi_map_arrow_arrived) unArrivedBitmap = BitmapDescriptorFactory.fromResource(if (unArrivedDrawable != -1) unArrivedDrawable else R.drawable.taxi_map_arrow_un_arrive) - CallerPlanningRottingListenerManager.addListener(TAG, moGoAutopilotPlanningListener) + CallerPlanningRottingListenerManager.addListener(TAG, this) initAMapView(context) // 注册定位监听 CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this) @@ -262,20 +263,6 @@ class OverMapView @JvmOverloads constructor( ) } - private val moGoAutopilotPlanningListener: IMoGoPlanningRottingListener = - object : IMoGoPlanningRottingListener { - /** - * 根据全路径获取起始点和经停点进行导航路线绘制 - * 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测 - * 室内某个bag包自动驾驶启动8s后返回 - */ - override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { - globalPathResp?.let { - handlePlanningData(it.wayPointsList) - } - } - } - fun handlePlanningData(locationList: List?) { if (locationList.isNullOrEmpty()) return val list: List = locationList @@ -600,4 +587,15 @@ class OverMapView @JvmOverloads constructor( } } + + /** + * 根据全路径获取起始点和经停点进行导航路线绘制 + * 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测 + * 室内某个bag包自动驾驶启动8s后返回 + */ + override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) { + globalPathResp?.let { + handlePlanningData(it.wayPointsList) + } + } } \ No newline at end of file From 8d397709ca3d36fedf7750c47c7239d247919867 Mon Sep 17 00:00:00 2001 From: renwj Date: Mon, 13 Feb 2023 17:43:22 +0800 Subject: [PATCH 5/5] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=A7=86=E8=A7=92=E5=8F=98=E6=8D=A2=E7=9B=B8=E5=85=B3=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../obu/MogoPrivateObuNewManager.kt | 7 +- .../hmi/ui/vehicle/TurnLightViewStatus.kt | 8 +- .../angle/MoGoVisualAngleChangeProvider.kt | 306 ++++++++++++++ .../core/function/impl/MogoMapService.java | 1 - .../function/v2x/events/V2XEventManager.kt | 7 +- .../scene/road/V2XRoadEventScenario.java | 6 +- .../core/data/constants/MogoServicePaths.java | 3 + .../angle/IMoGoVisualAngleChangeProvider.kt | 10 + .../core/function/api/map/angle/Scenes.kt | 104 +++++ .../call/map/CallerVisualAngleManager.kt | 394 +----------------- 10 files changed, 447 insertions(+), 399 deletions(-) create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/MoGoVisualAngleChangeProvider.kt create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/IMoGoVisualAngleChangeProvider.kt create mode 100644 core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/Scenes.kt diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt index 501cb50af4..abb73a1638 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/obu/MogoPrivateObuNewManager.kt @@ -8,12 +8,11 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxBean import com.mogo.eagle.core.data.msgbox.MsgBoxType import com.mogo.eagle.core.data.msgbox.V2XMsg import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener +import com.mogo.eagle.core.function.api.map.angle.* import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.call.obu.CallerObuConnectListenerManager import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager @@ -805,13 +804,13 @@ private fun handleSdkObu( override fun onShow() { super.onShow() if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(TooClose) + CallerVisualAngleManager.changeAngle(TooClose) } } override fun onDismiss() { if (changeVisualAngle) { - CallerVisualAngleManager.changeVisualAngle(Default()) + CallerVisualAngleManager.changeAngle(Default()) } } }, direction diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt index e21e0514a6..e38d41ccbd 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/vehicle/TurnLightViewStatus.kt @@ -11,8 +11,8 @@ import android.view.animation.Animation import android.widget.ImageView import androidx.constraintlayout.widget.ConstraintLayout import chassis.Chassis +import com.mogo.eagle.core.function.api.map.angle.* import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Turning import com.mogo.eagle.core.function.hmi.R import kotlinx.android.synthetic.main.view_turn_light_status.view.* import kotlinx.coroutines.Dispatchers @@ -55,7 +55,7 @@ class TurnLightViewStatus @JvmOverloads constructor( //根据左右进行显示和隐藏,实际要判断每个来的时间和频度 when (directionLight) { Chassis.LightSwitch.LIGHT_LEFT -> { //左转向 - CallerVisualAngleManager.changeVisualAngle(Turning(true)) + CallerVisualAngleManager.changeAngle(Turning(true)) showNormalAnimation() left_select_image.visibility = View.VISIBLE right_select_image.visibility = View.GONE @@ -63,7 +63,7 @@ class TurnLightViewStatus @JvmOverloads constructor( setAnimation(left_select_image) } Chassis.LightSwitch.LIGHT_RIGHT -> { //右转向 - CallerVisualAngleManager.changeVisualAngle(Turning(true)) + CallerVisualAngleManager.changeAngle(Turning(true)) showNormalAnimation() left_select_image.visibility = View.GONE right_select_image.visibility = View.VISIBLE @@ -71,7 +71,7 @@ class TurnLightViewStatus @JvmOverloads constructor( setAnimation(right_select_image) } else -> { //消失 - CallerVisualAngleManager.changeVisualAngle(Turning(false)) + CallerVisualAngleManager.changeAngle(Turning(false)) animationDisappear() } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/MoGoVisualAngleChangeProvider.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/MoGoVisualAngleChangeProvider.kt new file mode 100644 index 0000000000..52216f9c14 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/angle/MoGoVisualAngleChangeProvider.kt @@ -0,0 +1,306 @@ +package com.mogo.eagle.core.function.angle + +import android.content.* +import android.os.* +import android.util.* +import androidx.lifecycle.* +import androidx.lifecycle.Lifecycle.Event +import androidx.lifecycle.Lifecycle.Event.ON_DESTROY +import com.alibaba.android.arouter.facade.annotation.Route +import com.mogo.eagle.core.data.config.* +import com.mogo.eagle.core.data.constants.MogoServicePaths +import com.mogo.eagle.core.data.map.* +import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine +import com.mogo.eagle.core.function.api.map.angle.* +import com.mogo.eagle.core.function.api.map.angle.Scene +import com.mogo.eagle.core.function.call.autopilot.* +import com.mogo.eagle.core.function.call.map.* +import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener +import com.mogo.eagle.core.utilcode.kotlin.* +import com.mogo.eagle.core.utilcode.mogo.* +import com.mogo.eagle.core.utilcode.mogo.logger.* +import com.zhidaoauto.map.sdk.open.tools.* +import kotlinx.coroutines.* +import kotlinx.coroutines.android.* +import java.util.* +import java.util.concurrent.atomic.* + +@Route(path = MogoServicePaths.PATH_VISUAL_ANGLE) +class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider { + + override val functionName: String + get() = "VisualAngleChange" + + companion object { + const val TAG = "VisualAngleChange" + } + + private val triggerLocation = AtomicReference() + + private val distanceOfCarToStopLine = AtomicReference(0.0) + + private val travelled by lazy { AtomicReference(0.0) } + + /** + * 业务实体,不对外暴露 + * @param target: 目标场景 + * @param isDisplay: 是否正在展示 + * @param triggerTime: 触发时间 + */ + private data class Record(val target: Scene, var isDisplay: Boolean = false, var triggerTime: Long): Comparable { + override fun compareTo(other: Record): Int { + //如果时间一样,优先级越高,越靠近堆顶 + return other.target.priority - target.priority + } + } + + private val queue by lazy { + PriorityQueue() + } + + private val listener = object : OnRoadListener { + private val roadId = AtomicReference() + private val triggerRoadId = AtomicReference() + + override fun onRoadIdInfo(roadId: String) { + this.roadId.set(roadId) + Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId") + val loc = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02() + var triggerClose = false + val distance = distanceOfCarToStopLine.get() + 5 + if (hasCrossRoad && distance > 0) { + val prev = triggerLocation.get() + if (prev != null && loc != null) { + travelled.set(MapTools.distance(loc.longitude, loc.latitude, prev.longitude, prev.latitude) + travelled.get()) + triggerLocation.set(loc) + } + val oldRoadId = triggerRoadId.get() + Log.d(TAG, "-- onRoadIdInfo --: travelled --: ${travelled.get()}") + if ((travelled.get() > distance) && oldRoadId != null && oldRoadId != roadId) { + distanceOfCarToStopLine.set(0.0) + hasCrossRoad = false + triggerRoadId.set(null) + travelled.set(0.0) + triggerLocation.set(null) + Log.d(TAG, "-- onRoadIdInfo --: trigger close --") + triggerClose = true + } + } + if (triggerClose) { + changeAngle(CrossRoad(false)) + } + } + + + override fun onStopLineInfo(info: StopLine) { + Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}") + if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) { + hasCrossRoad = true + triggerRoadId.set(this.roadId.get()) + distanceOfCarToStopLine.set(info.distanceOfCarToStopLine) + triggerLocation.set(CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()) + changeAngle(CrossRoad(true)) + } + } + } + + override fun init(context: Context?) { + if (Thread.currentThread() != Looper.getMainLooper().thread) { + scope.launch { + initListen(context) + } + } else { + initListen(context) + } + } + + private fun initListen(ctx: Context?) { + ctx ?: return + ctx.lifeCycleOwner.lifecycle.addObserver(object : LifecycleEventObserver { + override fun onStateChanged(source: LifecycleOwner, event: Event) { + if (event == ON_DESTROY) { + CallerMapRoadListenerManager.unRegisterRoadListener("VisualAngleChange") + } + } + }) + CallerMapRoadListenerManager.registerRoadListener("VisualAngleChange", listener) + } + + @Volatile + private var hasCrossRoad = false + + + private var scope: CoroutineScope = acquireScope() + @Synchronized + get() { + if (field.isActive) { + return field + } + val scope = acquireScope() + field = scope + return field + } + + private var defaultDelayJob: Job? = null + + private fun acquireScope(): CoroutineScope { + return CoroutineScope(Handler(Looper.getMainLooper()).asCoroutineDispatcher("change-visual-angle") + SupervisorJob()) + } + + + override fun onDestroy() { + CallerMapRoadListenerManager.unRegisterRoadListener("VisualAngleChange") + } + + @Volatile + private var mLevel:Boolean = false + + override fun updateLongSightLevel(level:Boolean){ + mLevel = level + } + + override fun changeAngle(scene: Scene) { + val appIdentityMode = FunctionBuildConfig.appIdentityMode + if (AppIdentityModeUtils.isBus(appIdentityMode) && AppIdentityModeUtils.isPassenger(appIdentityMode)) { + return + } + if(mLevel){ + return + } + val triggerTime = SystemClock.elapsedRealtime() + scope.launch { + Log.d(TAG, "--- 1 ---") + val displayed = getDisplayed() + if (displayed == null) { + Log.d(TAG, "--- 2 ---") + if (scene is Turning) { + if (!scene.open) { + changeAngle(Default()) + return@launch + } + } + if (scene is CrossRoad) { + if (!scene.open) { + changeAngle(Default()) + return@launch + } + } + doRealVisualAngleChange(triggerTime, scene, null) + } else { + val prev = displayed.target + Log.d(TAG, "--- 3 --- old: $prev -> cur: $scene") + val prevTriggerTime = displayed.triggerTime + if (scene !is Default && prev.priority > scene.priority && (prev is RoadEvent || prev is TooClose)) { + val displayDuration = triggerTime - prevTriggerTime + Log.d(TAG, "--- 4 ---:场景[$prev], 已展示时长: duration: $displayDuration") + if (displayDuration < prev.displayThreshold) { + Log.d(TAG, "--- 5 --- 场景[$prev]:仍在保护展示时长内,直接return") + return@launch + } else { + Log.d(TAG, "--- 6 --- 场景[$prev]:已过保护展示时长,从展示的队列中移除,显示默认视角") + queue -= displayed + changeAngle(Default()) + return@launch + } + } + if (prev is Turning && scene is Turning) { + val isOpen = scene.open + if (!isOpen) { + Log.d(TAG, "--- 7 --- 场景[$scene], 收到关闭通知") + queue -= displayed + changeAngle(Default()) + return@launch + } + } + if (prev is CrossRoad && scene is CrossRoad) { + val isOpen = scene.open + if (!isOpen) { + Log.d(TAG, "--- 8 --- old: $prev -> cur: $scene") + queue -= displayed + changeAngle(Default()) + return@launch + } + } + if (prev.priority == scene.priority) { + Log.d(TAG, "--- 9 --- 场景[$prev]正在展示,尚未收到关闭,优先级一致,直接return") + return@launch + } + if (prev.priority > scene.priority && prev.displayThreshold < 0) { + Log.d(TAG, "--- 10 --- 场景[$prev]正在展示,尚未收到关闭,场景,依然展示当前场景,直接return") + return@launch + } + doRealVisualAngleChange(triggerTime, scene, displayed) + } + } + } + + private fun CoroutineScope.doRealVisualAngleChange(triggerTime: Long, target: Scene, displayed: Record? = null) { + if (target is Default) { + Log.d(TAG, "--- doRealVisualAngleChange --- 1 ---") + displayed?.also { + queue -= it + } + defaultDelayJob?.safeCancel() + launch { + val delay = target.unit.toMillis(target.delay) + Log.d(TAG, "--- doRealVisualAngleChange --- 2 ---") + delay(delay) + Log.d(TAG, "--- doRealVisualAngleChange --- 3 ---") + doChangeAngle(Record(target, triggerTime = triggerTime)) + }.also { itx -> + itx.invokeOnCompletion { + if (it is CancellationException) { + Log.d(TAG, "--- doRealVisualAngleChange --- 4 ---") + } + } + defaultDelayJob = itx + } + } else { + Log.d(TAG, "--- doRealVisualAngleChange --- 5 ---") + defaultDelayJob?.safeCancel() + if (displayed == null || displayed.target.priority <= target.priority) { + Log.d(TAG, "--- doRealVisualAngleChange --- 6 ---") + displayed?.also { + queue -= it + } + if (target is Turning) { + if (!target.open) { + Log.d(TAG, "--- doRealVisualAngleChange --- 7 ---") + changeAngle(Default()) + return + } + } + if (target is CrossRoad) { + if (!target.open) { + Log.d(TAG, "--- doRealVisualAngleChange --- 8 ---") + changeAngle(Default()) + return + } + } + Log.d(TAG, "--- doRealVisualAngleChange --- 10 ---") + doChangeAngle(Record(target, triggerTime = triggerTime)) + } + } + } + + @OptIn(InternalCoroutinesApi::class) + private fun doChangeAngle(record: Record) { + val angle = record.target.angle + CallerMapUIServiceManager.getMapUIController()?.also { + Log.d(TAG, "--- doChangeAngle ---: ${record.target}") + if (record.target !is Default) { + record.isDisplay = true + kotlinx.coroutines.internal.synchronized(queue) { + queue += record + } + } + it.changeMapVisualAngle(angle, null) + } + } + + /** + * 是否有正在展示的 + */ + @Synchronized + private fun getDisplayed() = queue.firstOrNull() +} \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java index 1516eeddbc..651b2a8a74 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/impl/MogoMapService.java @@ -52,6 +52,5 @@ public class MogoMapService implements IMogoMapService { @Override public void init(Context context) { - CallerVisualAngleManager.INSTANCE.init(context); } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt index 1c40d47f56..920a297268 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt @@ -31,6 +31,7 @@ import com.mogo.eagle.core.data.traffic.TrafficData import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener +import com.mogo.eagle.core.function.api.map.angle.* import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager @@ -38,8 +39,6 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.v2x.events.alarm.V2XAlarmServer import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi @@ -373,13 +372,13 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback, val change = changeVisualAngle override fun onShow() { if (change) { - CallerVisualAngleManager.changeVisualAngle(TooClose) + CallerVisualAngleManager.changeAngle(TooClose) } } override fun onDismiss() { if (change) { - CallerVisualAngleManager.changeVisualAngle(Default()) + CallerVisualAngleManager.changeAngle(Default()) } } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java index 1c4d34d86a..c604e02cc3 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventScenario.java @@ -11,6 +11,8 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxBean; import com.mogo.eagle.core.data.msgbox.MsgBoxType; import com.mogo.eagle.core.data.msgbox.V2XMsg; import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener; +import com.mogo.eagle.core.function.api.map.angle.Default; +import com.mogo.eagle.core.function.api.map.angle.RoadEvent; import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager; import com.mogo.eagle.core.function.call.hmi.CallerHmiManager; import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager; @@ -151,7 +153,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario imp @Override public void onShow() { if (isNeedChangeAngle()) { - CallerVisualAngleManager.INSTANCE.changeVisualAngle(CallerVisualAngleManager.Scene.RoadEvent.INSTANCE); + CallerVisualAngleManager.INSTANCE.changeAngle(RoadEvent.INSTANCE); } V2XMessageEntity entity = getV2XMessageEntity(); if (entity != null) { @@ -177,7 +179,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario imp public void onDismiss() { CallerHmiManager.INSTANCE.dismissWarning(WarningDirectionEnum.ALERT_WARNING_TOP); if (isNeedChangeAngle()) { - CallerVisualAngleManager.INSTANCE.changeVisualAngle(new CallerVisualAngleManager.Scene.Default(3, TimeUnit.SECONDS)); + CallerVisualAngleManager.INSTANCE.changeAngle(new Default(3, TimeUnit.SECONDS)); } release(); } diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java index b67cf92f55..f319c9556a 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/constants/MogoServicePaths.java @@ -96,4 +96,7 @@ public class MogoServicePaths { @Keep public static final String PATH_IDENTIFY = "/map/identify"; + + @Keep + public static final String PATH_VISUAL_ANGLE = "/map/angle_change"; } diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/IMoGoVisualAngleChangeProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/IMoGoVisualAngleChangeProvider.kt new file mode 100644 index 0000000000..a4c1ec1712 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/IMoGoVisualAngleChangeProvider.kt @@ -0,0 +1,10 @@ +package com.mogo.eagle.core.function.api.map.angle + +import com.mogo.eagle.core.function.api.base.* + +interface IMoGoVisualAngleChangeProvider: IMoGoFunctionServerProvider { + + fun updateLongSightLevel(level: Boolean) + + fun changeAngle(scene: Scene) +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/Scenes.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/Scenes.kt new file mode 100644 index 0000000000..296f992b05 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/map/angle/Scenes.kt @@ -0,0 +1,104 @@ +package com.mogo.eagle.core.function.api.map.angle + +import com.mogo.map.uicontroller.* +import java.util.concurrent.* +import java.util.concurrent.TimeUnit.SECONDS + +private interface IAttach { + val angle: VisualAngleMode + val priority: Int + val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值, + } + + +sealed class Scene: IAttach + + +/** + * 默认视图 + * @param delay: 表示多少稍后,默认值为2 + * @param unit: 时间单位,默认为秒 + */ +class Default(val delay: Long = 2, val unit: TimeUnit = SECONDS): Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MODE_MEDIUM_SIGHT + + override val priority: Int = 1 + + override val displayThreshold: Long + get() = 0 + + override fun toString(): String { + return "Default(delay=$delay, unit=$unit, angle=$angle, priority=$priority)" + } +} + + +/** + * 变道-接收到转向灯信息号 + */ +class Turning(var open: Boolean = false): Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP + + override val priority: Int = 3 + + override val displayThreshold: Long + get() = -1 + + override fun toString(): String { + return "Turning(open: ${open}, priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" + } +} + + +/** + * 后方车辆离自车过近 + */ +object TooClose: Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_300 + + override val priority: Int = 2 + + override val displayThreshold: Long + get() = SECONDS.toMillis(8) + + override fun toString(): String { + return "TooClose(priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" + } +} + + +/** + * 道路事件 + */ +object RoadEvent: Scene() { + + override val angle: VisualAngleMode = VisualAngleMode.MODE_LONG_SIGHT + + override val priority: Int = 5 + + override val displayThreshold: Long + get() = SECONDS.toMillis(8) + + override fun toString(): String { + return "RoadEvent(priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" + } +} + + +/** + * 十字路口 + */ +class CrossRoad(var open: Boolean = false): Scene() { + override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS + override val priority: Int = 4 + override val displayThreshold: Long + get() = -1 + + override fun toString(): String { + return "CrossRoad(open: ${open}, priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" + } +} + diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt index 5970ebf407..4387d4a198 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt @@ -1,398 +1,24 @@ package com.mogo.eagle.core.function.call.map -import android.content.Context -import android.os.Handler -import android.os.Looper -import android.os.SystemClock -import android.util.* -import androidx.lifecycle.Lifecycle.Event -import androidx.lifecycle.Lifecycle.Event.ON_DESTROY -import androidx.lifecycle.LifecycleEventObserver -import androidx.lifecycle.LifecycleOwner -import com.mogo.eagle.core.data.config.FunctionBuildConfig -import com.mogo.eagle.core.data.map.* -import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine -import com.mogo.eagle.core.function.call.autopilot.* -import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener -import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.* -import com.mogo.eagle.core.utilcode.kotlin.lifeCycleOwner -import com.mogo.eagle.core.utilcode.kotlin.safeCancel -import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils -import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_DEVA -import com.mogo.map.uicontroller.VisualAngleMode -import com.zhidaoauto.map.sdk.open.tools.MapTools -import kotlinx.coroutines.* -import kotlinx.coroutines.android.asCoroutineDispatcher -import kotlinx.coroutines.internal.synchronized -import java.util.* -import java.util.concurrent.TimeUnit -import java.util.concurrent.TimeUnit.SECONDS -import java.util.concurrent.atomic.* -import kotlin.math.* +import com.alibaba.android.arouter.launcher.* +import com.mogo.eagle.core.data.constants.* +import com.mogo.eagle.core.function.api.map.angle.* + /** * 高精地图视角管理类 */ object CallerVisualAngleManager { - private const val TAG = "VisualAngle" - - @Volatile - private var hasCrossRoad = false - - - private var scope: CoroutineScope = acquireScope() - @Synchronized - get() { - if (field.isActive) { - return field - } - val scope = acquireScope() - field = scope - return field - } - - private var defaultDelayJob: Job? = null - - private fun acquireScope(): CoroutineScope { - return CoroutineScope(Handler(Looper.getMainLooper()).asCoroutineDispatcher("change-visual-angle") + SupervisorJob()) + private val provider by lazy { ARouter.getInstance().build(MogoServicePaths.PATH_VISUAL_ANGLE) + .navigation() as? IMoGoVisualAngleChangeProvider } - private interface IAttach { - val angle: VisualAngleMode - val priority: Int - val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值, + fun changeAngle(scene: Scene) { + provider?.changeAngle(scene) } - private val triggerLocation = AtomicReference() - - private val distanceOfCarToStopLine = AtomicReference(0.0) - - private val travelled by lazy { AtomicReference(0.0) } - - private val listener = object : OnRoadListener { - private val roadId = AtomicReference() - private val triggerRoadId = AtomicReference() - - override fun onRoadIdInfo(roadId: String) { - this.roadId.set(roadId) - Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId") - val loc = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02() - var triggerClose = false - val distance = distanceOfCarToStopLine.get() + 5 - if (hasCrossRoad && distance > 0) { - val prev = triggerLocation.get() - if (prev != null && loc != null) { - travelled.set(MapTools.distance(loc.longitude, loc.latitude, prev.longitude, prev.latitude) + travelled.get()) - triggerLocation.set(loc) - } - val oldRoadId = triggerRoadId.get() - Log.d(TAG, "-- onRoadIdInfo --: travelled --: ${travelled.get()}") - if ((travelled.get() > distance) && oldRoadId != null && oldRoadId != roadId) { - distanceOfCarToStopLine.set(0.0) - hasCrossRoad = false - triggerRoadId.set(null) - travelled.set(0.0) - triggerLocation.set(null) - Log.d(TAG, "-- onRoadIdInfo --: trigger close --") - triggerClose = true - } - } - if (triggerClose) { - changeVisualAngle(CrossRoad(false)) - } - } - - - override fun onStopLineInfo(info: StopLine) { - Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}") - if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) { - hasCrossRoad = true - triggerRoadId.set(this.roadId.get()) - distanceOfCarToStopLine.set(info.distanceOfCarToStopLine) - triggerLocation.set(CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()) - changeVisualAngle(CrossRoad(true)) - } - } + fun updateLongSightLevel(level: Boolean) { + provider?.updateLongSightLevel(level) } - - fun init(ctx: Context) { - if (Thread.currentThread() != Looper.getMainLooper().thread) { - scope.launch { - initListen(ctx) - } - } else { - initListen(ctx) - } - } - - private fun initListen(ctx: Context) { - ctx.lifeCycleOwner.lifecycle.addObserver(object : LifecycleEventObserver { - override fun onStateChanged(source: LifecycleOwner, event: Event) { - if (event == ON_DESTROY) { - CallerMapRoadListenerManager.unRegisterRoadListener("VisualAngleChange") - } - } - }) - CallerMapRoadListenerManager.registerRoadListener("VisualAngleChange", listener) - } - - sealed class Scene private constructor(): IAttach { - - /** - * 默认视图 - * @param delay: 表示多少稍后,默认值为2 - * @param unit: 时间单位,默认为秒 - */ - class Default(val delay: Long = 2, val unit: TimeUnit = SECONDS): Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MODE_MEDIUM_SIGHT - - override val priority: Int = 1 - - override val displayThreshold: Long - get() = 0 - - override fun toString(): String { - return "Default(delay=$delay, unit=$unit, angle=$angle, priority=$priority)" - } - } - - /** - * 变道-接收到转向灯信息号 - */ - class Turning(var open: Boolean = false): Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP - - override val priority: Int = 3 - - override val displayThreshold: Long - get() = -1 - - override fun toString(): String { - return "Turning(open: ${open}, priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" - } - } - - /** - * 后方车辆离自车过近 - */ - object TooClose: Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_300 - - override val priority: Int = 2 - - override val displayThreshold: Long - get() = SECONDS.toMillis(8) - - override fun toString(): String { - return "TooClose(priority=$priority, displayThreshold: $displayThreshold, priority=$priority)" - } - } - - /** - * 道路事件 - */ - object RoadEvent: Scene() { - - override val angle: VisualAngleMode = VisualAngleMode.MODE_LONG_SIGHT - - override val priority: Int = 5 - - override val displayThreshold: Long - get() = SECONDS.toMillis(8) - - override fun toString(): String { - return "RoadEvent(priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" - } - } - - - /** - * 十字路口 - */ - class CrossRoad(var open: Boolean = false): Scene() { - override val angle: VisualAngleMode = VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS - override val priority: Int = 4 - override val displayThreshold: Long - get() = -1 - - override fun toString(): String { - return "CrossRoad(open: ${open}, priority=${priority}, displayThreshold: ${displayThreshold}, priority=${priority})" - } - } - } - - - /** - * 业务实体,不对外暴露 - * @param target: 目标场景 - * @param isDisplay: 是否正在展示 - * @param triggerTime: 触发时间 - */ - private data class Record(val target: Scene, var isDisplay: Boolean = false, var triggerTime: Long): Comparable { - override fun compareTo(other: Record): Int { - //如果时间一样,优先级越高,越靠近堆顶 - return other.target.priority - target.priority - } - } - - private val queue by lazy { - PriorityQueue() - } - - @Volatile - private var mLevel:Boolean = false - - fun updateLongSightLevel(level:Boolean){ - mLevel = level - } - - fun changeVisualAngle(current: Scene) { - val appIdentityMode = FunctionBuildConfig.appIdentityMode - if (AppIdentityModeUtils.isBus(appIdentityMode) && AppIdentityModeUtils.isPassenger(appIdentityMode)) { - return - } - if(mLevel){ - return - } - val triggerTime = SystemClock.elapsedRealtime() - scope.launch { - Log.d("${M_DEVA}${TAG}", "--- 1 ---") - val displayed = getDisplayed() - if (displayed == null) { - Log.d("${M_DEVA}${TAG}", "--- 2 ---") - if (current is Turning) { - if (!current.open) { - changeVisualAngle(Default()) - return@launch - } - } - if (current is CrossRoad) { - if (!current.open) { - changeVisualAngle(Default()) - return@launch - } - } - doRealVisualAngleChange(triggerTime, current, null) - } else { - val prev = displayed.target - Log.d("${M_DEVA}${TAG}", "--- 3 --- old: $prev -> cur: $current") - val prevTriggerTime = displayed.triggerTime - if (current !is Default && prev.priority > current.priority && (prev is RoadEvent || prev is TooClose)) { - val displayDuration = triggerTime - prevTriggerTime - Log.d("${M_DEVA}${TAG}", "--- 4 ---:场景[$prev], 已展示时长: duration: $displayDuration") - if (displayDuration < prev.displayThreshold) { - Log.d("${M_DEVA}${TAG}", "--- 5 --- 场景[$prev]:仍在保护展示时长内,直接return") - return@launch - } else { - Log.d("${M_DEVA}${TAG}", "--- 6 --- 场景[$prev]:已过保护展示时长,从展示的队列中移除,显示默认视角") - queue -= displayed - changeVisualAngle(Default()) - return@launch - } - } - if (prev is Turning && current is Turning) { - val isOpen = current.open - if (!isOpen) { - Log.d("${M_DEVA}${TAG}", "--- 7 --- 场景[$current], 收到关闭通知") - queue -= displayed - changeVisualAngle(Default()) - return@launch - } - } - if (prev is CrossRoad && current is CrossRoad) { - val isOpen = current.open - if (!isOpen) { - Log.d("${M_DEVA}${TAG}", "--- 8 --- old: $prev -> cur: $current") - queue -= displayed - changeVisualAngle(Default()) - return@launch - } - } - if (prev.priority == current.priority) { - Log.d("${M_DEVA}${TAG}", "--- 9 --- 场景[$prev]正在展示,尚未收到关闭,优先级一致,直接return") - return@launch - } - if (prev.priority > current.priority && prev.displayThreshold < 0) { - Log.d("${M_DEVA}${TAG}", "--- 10 --- 场景[$prev]正在展示,尚未收到关闭,场景,依然展示当前场景,直接return") - return@launch - } - doRealVisualAngleChange(triggerTime, current, displayed) - } - } - } - - private fun CoroutineScope.doRealVisualAngleChange(triggerTime: Long, target: Scene, displayed: Record? = null) { - if (target is Default) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 1 ---") - displayed?.also { - queue -= it - } - defaultDelayJob?.safeCancel() - launch { - val delay = target.unit.toMillis(target.delay) - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 2 ---") - delay(delay) - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 3 ---") - doChangeAngle(Record(target, triggerTime = triggerTime)) - }.also { itx -> - itx.invokeOnCompletion { - if (it is CancellationException) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 4 ---") - } - } - defaultDelayJob = itx - } - } else { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 5 ---") - defaultDelayJob?.safeCancel() - if (displayed == null || displayed.target.priority <= target.priority) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 6 ---") - displayed?.also { - queue -= it - } - if (target is Turning) { - if (!target.open) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 7 ---") - changeVisualAngle(Default()) - return - } - } - if (target is CrossRoad) { - if (!target.open) { - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 8 ---") - changeVisualAngle(Default()) - return - } - } - Log.d("${M_DEVA}${TAG}", "--- doRealVisualAngleChange --- 10 ---") - doChangeAngle(Record(target, triggerTime = triggerTime)) - } - } - } - - @OptIn(InternalCoroutinesApi::class) - private fun doChangeAngle(record: Record) { - val angle = record.target.angle - CallerMapUIServiceManager.getMapUIController()?.also { - Log.d("${M_DEVA}${TAG}", "--- doChangeAngle ---: ${record.target}") - if (record.target !is Default) { - record.isDisplay = true - synchronized(queue) { - queue += record - } - } - it.changeMapVisualAngle(angle, null) - } - } - - /** - * 是否有正在展示的 - */ - @Synchronized - private fun getDisplayed() = queue.firstOrNull() - } \ No newline at end of file