From ee82ffda89efa0b141760ad8d04460ef408e4c14 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Tue, 16 Nov 2021 20:35:15 +0800 Subject: [PATCH] =?UTF-8?q?[Fix]=E4=BF=AE=E5=A4=8D=E9=97=AF=E7=BA=A2?= =?UTF-8?q?=E7=81=AF=E5=92=8C=E7=BB=BF=E6=B3=A2=E9=80=9A=E8=A1=8C=E9=A2=84?= =?UTF-8?q?=E8=AD=A6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../redlightwarning/RedLightWarningManager.kt | 20 ++++++++++++++----- .../data/trafficlight/TrafficLightResult.kt | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/redlightwarning/RedLightWarningManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/redlightwarning/RedLightWarningManager.kt index c523056355..18eba08b79 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/redlightwarning/RedLightWarningManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/redlightwarning/RedLightWarningManager.kt @@ -6,6 +6,7 @@ import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener import com.mogo.eagle.core.function.call.hmi.CallerHmiManager import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightListenerManager +import com.mogo.eagle.core.utilcode.util.SPUtils import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.module.common.enums.EventTypeEnum import com.mogo.utils.logger.Logger @@ -25,7 +26,7 @@ class RedLightWarningManager : IMoGoTrafficLightListener { override fun onTrafficLightStatus(trafficLightResult: TrafficLightResult) { getCurrentRoadTrafficLight(trafficLightResult)?.let { - handleRedLightWarning(it) + handleRedLightWarning(it, trafficLightResult.flashYellow) } } @@ -33,21 +34,28 @@ class RedLightWarningManager : IMoGoTrafficLightListener { CallTrafficLightListenerManager.registerTrafficLightListener(TAG, this) } - private fun handleRedLightWarning(trafficLightStatus: TrafficLightStatus) { + private fun handleRedLightWarning(trafficLightStatus: TrafficLightStatus, yellowLightTime: Int = 0) { + // 如果是Vip则不处理 + if (SPUtils.getInstance().getLong("vip") > 0) { + return + } // 路口100m闯红灯预警 CallerMapLocationListenerManager.getCurrentLocation()?.let { + // 单位m/s + val speed = it.speed + // 车停止或者速度非常慢,可能返回负数或者很小的值,需要过滤 + if (speed <= 2.5f) return// 小于等于9km/h不处理 val distance = 100 val remainTime = trafficLightStatus.remain - val speed = it.speed - if (speed == 0f) return val arriveTime = distance / speed + Logger.d(TAG, "speed is:$speed,remainTime is:$remainTime,arriveTime is:$arriveTime,yellowTime is:$yellowLightTime") when { trafficLightStatus.isRed() -> { // 到达路口时红灯还没走完 if (arriveTime <= remainTime) { redLightWarning() - } else if (arriveTime > remainTime) { + } else if (arriveTime > remainTime + yellowLightTime) {// 到达时红、黄灯都走完 greenLightWarning() } } @@ -55,6 +63,8 @@ class RedLightWarningManager : IMoGoTrafficLightListener { // 到达路口时黄灯还没走完 if (arriveTime <= remainTime) { redLightWarning() + } else { + greenLightWarning() } } trafficLightStatus.isGreen() -> { diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/trafficlight/TrafficLightResult.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/trafficlight/TrafficLightResult.kt index 1cd18f663c..66bf66feb4 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/trafficlight/TrafficLightResult.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/trafficlight/TrafficLightResult.kt @@ -16,6 +16,7 @@ data class TrafficLightResult( val lightId: Int, //红绿灯ID val laneNo: Int, //车道号 val arrowNo: Int, //当前车道对应地面要素转向 - val laneList: TrafficLightDetail //灯态具体信息 + val laneList: TrafficLightDetail, //灯态具体信息 + val flashYellow: Int// 黄灯总时间 ) { } \ No newline at end of file