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 ad5e57f222..dbb469898b 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.config.FunctionBuildConfig @@ -63,6 +64,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,路侧获取红绿灯状态 @@ -79,6 +83,28 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerLogger.d("${SceneConstant.M_OBU}${TAG}", "onAutopilotPerceptionTrafficLight ---- hasObuLightStatus = $hasObuLightStatus ----hasAiLightStatus = $hasAiLightStatus ") 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()) { @@ -205,7 +231,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerTrafficLightListenerManager.changeCountdownYellow(remain) } TrafficLightEnum.BLACK -> { - CallerTrafficLightListenerManager.disableTrafficLightCountDown() + CallerTrafficLightListenerManager.disableTrafficLight() } else -> { hide()