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 4112baf491..74cde6b1cd 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 @@ -1,6 +1,7 @@ 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.enums.DataSourceType @@ -57,6 +58,9 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight @Volatile private var hasObuLightStatus: Boolean = false + private var lightCountDownTimer: CountDownTimer ?= null + private var lastLightTime: Long = System.currentTimeMillis() + fun initServer(context: Context) { mContext = context //注册监听AI云.OBU,路侧获取红绿灯状态 @@ -72,6 +76,28 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight override fun onAutopilotPerceptionTrafficLight(trafficLights: TrafficLightOuterClass.TrafficLights?) { if (!hasObuLightStatus) { if (!hasAiLightStatus) { + + lastLightTime = System.currentTimeMillis() + if(lightCountDownTimer==null){ + lightCountDownTimer = object: CountDownTimer(300000,1000){ + override fun onTick(millisUntilFinished: Long) { + if((System.currentTimeMillis() - lastLightTime)>1000){ + //隐藏红绿灯显示 + CallerTrafficLightListenerManager.disableTrafficLight() + lightCountDownTimer?.cancel() + lightCountDownTimer = null + } + } + + override fun onFinish() { + lightCountDownTimer?.cancel() + lightCountDownTimer = null + } + + } + lightCountDownTimer?.start() + } + trafficLights?.let { it -> var light: TrafficLight? = null if (it.hasStraight()) { @@ -165,7 +191,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerTrafficLightListenerManager.changeCountdownYellow(remain) } TrafficLightEnum.BLACK -> { - CallerTrafficLightListenerManager.disableTrafficLightCountDown() + CallerTrafficLightListenerManager.disableTrafficLight() } }