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 1d7e68fde1..d0f35bbe73 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 @@ -3,7 +3,14 @@ package com.mogo.eagle.core.function.datacenter.v2x import android.content.Context import android.os.CountDownTimer import android.os.Handler -import com.mogo.eagle.core.data.biz.trafficlight.* +import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult +import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightStatus +import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight +import com.mogo.eagle.core.data.biz.trafficlight.isFlashGreen +import com.mogo.eagle.core.data.biz.trafficlight.isGreen +import com.mogo.eagle.core.data.biz.trafficlight.isRed +import com.mogo.eagle.core.data.biz.trafficlight.isYellow +import com.mogo.eagle.core.data.biz.trafficlight.time import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.config.HmiBuildConfig import com.mogo.eagle.core.data.deva.chain.ChainConstant @@ -116,17 +123,21 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight //隐藏红绿灯显示 hide("感知light为null隐藏", DataSourceType.TELEMATIC) } else { - if(!hasAutopilotPerception){ + if (!hasAutopilotPerception) { hasAutopilotPerception = true } - if(HmiBuildConfig.isShowCarSourceTrafficLightView){ - val source = when(trafficLights.source){ + if (HmiBuildConfig.isShowCarSourceTrafficLightView) { + var lightRemain = light.duration.toInt() + val source = when (trafficLights.source) { 1 -> DataSourceType.TELEMATIC_UNION_V2I 2 -> DataSourceType.TELEMATIC_UNION_V2N - else -> DataSourceType.TELEMATIC + else -> { + lightRemain = 0 + DataSourceType.TELEMATIC + } } - onTrafficLightPlusSource(light.convert(), light.duration.toInt(), source) - }else{ + onTrafficLightPlusSource(light.convert(), lightRemain, source) + } else { onTrafficLightPlusSource(light.convert(), 0, DataSourceType.TELEMATIC) } } @@ -160,7 +171,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight */ override fun onEnterCrossRoad(enter: Boolean) { CallerLogger.d("${SceneConstant.M_D_C}${TAG}", "onEnterCrossRoad enter = $enter ") - if(HmiBuildConfig.isShowCarSourceTrafficLightView){ + if (HmiBuildConfig.isShowCarSourceTrafficLightView) { return } if (!enter) { @@ -190,7 +201,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight "${SceneConstant.M_D_C}${TAG}", "onTrafficRequestError hasObuLightStatus = $hasObuLightStatus ------> " ) - if(HmiBuildConfig.isShowCarSourceTrafficLightView){ + if (HmiBuildConfig.isShowCarSourceTrafficLightView) { return } CallerTrafficLightListenerManager.resetTrafficLightStatus(hasAiLightStatus) @@ -232,7 +243,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight ) private fun hide(msg: String, sourceType: DataSourceType) { CallerLogger.d("${SceneConstant.M_D_C}${TAG}", "hide() :$msg type :$sourceType") - if(filterTelematicUnion(sourceType)){ + if (filterTelematicUnion(sourceType)) { return } CallerTrafficLightListenerManager.disableTrafficLight() @@ -253,7 +264,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight lightSource: DataSourceType ) { super.onTrafficLightPlusSource(light, remain, lightSource) - if(filterTelematicUnion(lightSource)){ + if (filterTelematicUnion(lightSource)) { return } if (lightSource == DataSourceType.OBU) { @@ -268,7 +279,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight //倒计时,超时还未更新数据则隐藏红绿灯 lastLightTime = System.currentTimeMillis() if (lightCountDownTimer == null) { - UiThreadHandler.post{ + UiThreadHandler.post { lightCountDownTimer = object : CountDownTimer(300000, 1000) { override fun onTick(millisUntilFinished: Long) { if ((System.currentTimeMillis() - lastLightTime) > 1500) { @@ -301,15 +312,19 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight TrafficLightEnum.GREEN -> { CallerTrafficLightListenerManager.changeCountdownGreen(remain) } + TrafficLightEnum.RED -> { CallerTrafficLightListenerManager.changeCountdownRed(remain) } + TrafficLightEnum.YELLOW -> { CallerTrafficLightListenerManager.changeCountdownYellow(remain) } + TrafficLightEnum.BLACK -> { hide("感知数据BLACK隐藏", lightSource) } + else -> { hide("未知红绿灯类型隐藏", lightSource) } @@ -335,8 +350,8 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight } } - private fun filterTelematicUnion(source:DataSourceType):Boolean{ - return HmiBuildConfig.isShowCarSourceTrafficLightView && source != DataSourceType.TELEMATIC_UNION_V2N && source != DataSourceType.TELEMATIC_UNION_V2I + private fun filterTelematicUnion(source: DataSourceType): Boolean { + return HmiBuildConfig.isShowCarSourceTrafficLightView && source != DataSourceType.TELEMATIC_UNION_V2N && source != DataSourceType.TELEMATIC_UNION_V2I && source != DataSourceType.TELEMATIC } fun destroy() {