[8.1.0]统一红绿灯
This commit is contained in:
@@ -24,8 +24,10 @@ import com.mogo.eagle.core.data.multidisplay.TelematicConstant
|
||||
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.datacenter.union.IMoGoTrafficLightListener
|
||||
import com.mogo.eagle.core.function.api.devatools.INDECloudListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerNDECloudManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
@@ -36,6 +38,9 @@ import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.skin.utils.SkinResources
|
||||
import com.zhjt.mogo.adas.common.cloud.AstFuncTlmPhaseStateLightState
|
||||
import com.zhjt.mogo.adas.data.bean.cloud.info.AstFuncTlmInfo
|
||||
import com.zhjt.mogo.adas.data.bean.cloud.pojo.AstFuncPojo
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import perception.FusionTrafficLightOuterClass
|
||||
import kotlin.math.abs
|
||||
@@ -66,7 +71,7 @@ fun convert(state: FusionTrafficLightOuterClass.FusionLightState): TrafficLightE
|
||||
* @since: 2022/4/28
|
||||
*/
|
||||
class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLightListener,
|
||||
IMoGoChassisLocationGCJ02Listener {
|
||||
IMoGoChassisLocationGCJ02Listener, INDECloudListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "TrafficLightDispatcher"
|
||||
@@ -93,6 +98,11 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
@Volatile
|
||||
private var hasFusionLightStatus: Boolean = false
|
||||
|
||||
//是否有云控基础平台红绿灯数据
|
||||
@Volatile
|
||||
private var hasCloudControlLight: Boolean = false
|
||||
|
||||
|
||||
//红绿灯定时器,超时未更新隐藏红绿灯
|
||||
@Volatile
|
||||
private var lightCountDownTimer: CountDownTimer? = null
|
||||
@@ -110,6 +120,8 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
CallerAutopilotIdentifyListenerManager.addListener(TAG, this)
|
||||
//注册获取当前车速
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 1, this)
|
||||
//注册监听云控基础平台数据
|
||||
CallerNDECloudManager.addListener(TAG,this)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -362,7 +374,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
"${SceneConstant.M_D_C}${TAG}",
|
||||
"resetTrafficLight ------> isReset = $isReset ---hasObuLightStatus = $hasObuLightStatus"
|
||||
)
|
||||
if (!hasObuLightStatus && !hasAutopilotPerception && !hasFusionLightStatus) {
|
||||
if (!hasObuLightStatus && !hasAutopilotPerception && !hasFusionLightStatus && !hasCloudControlLight) {
|
||||
if (isReset) {
|
||||
hide("云端重置红绿灯数据", DataSourceType.AICLOUD)
|
||||
}
|
||||
@@ -425,6 +437,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
hasObuLightStatus = false
|
||||
hasAutopilotPerception = false
|
||||
hasAiLightStatus = false
|
||||
hasCloudControlLight = false
|
||||
hasFusionLightStatus = true
|
||||
CallerTrafficLightListenerManager.showFusionTrafficLight(currentState, currentDuration, nextState, nextDuration,
|
||||
nextTwoState, nextTwoDuration, lightSource)
|
||||
@@ -542,6 +555,8 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
CallerAutopilotIdentifyListenerManager.removeListener(TAG)
|
||||
//取消注册获取当前车速
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
//取消注册云控基础平台数据
|
||||
CallerNDECloudManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -551,4 +566,64 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight
|
||||
currentSpeed = abs(mogoLocation?.gnssSpeed ?: 0f)
|
||||
}
|
||||
|
||||
/**
|
||||
* NDE下发 信号灯信息
|
||||
* @param astFuncPojo 云端辅助功能信息
|
||||
* @param astFuncTlmInfo 云端下发信号灯信息
|
||||
*/
|
||||
override fun onNdeCloudAstFuncTlm(astFuncPojo: AstFuncPojo, astFuncTlmInfo: AstFuncTlmInfo) {
|
||||
super.onNdeCloudAstFuncTlm(astFuncPojo, astFuncTlmInfo)
|
||||
if(astFuncTlmInfo.phaseState.isNotEmpty()){
|
||||
if(hasFusionLightStatus){
|
||||
return
|
||||
}else{
|
||||
val currentState = getLightStatus(astFuncTlmInfo.phaseState[0].lightState)
|
||||
val nextState = getLightStatus(astFuncTlmInfo.phaseState[0].nextLightState)
|
||||
val currentDuration = astFuncTlmInfo.phaseState[0].timeLeft
|
||||
val nextDuration = astFuncTlmInfo.phaseState[0].nextLightTime
|
||||
if(currentState!=TrafficLightEnum.BLACK && nextState != TrafficLightEnum.BLACK
|
||||
&& currentDuration != 0 && nextDuration != 0){
|
||||
hasCloudControlLight = true
|
||||
//展示云控基础平台信号灯信息
|
||||
CallerTrafficLightListenerManager.showCloudTrafficLight(currentState, currentDuration, nextState, nextDuration)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
hasCloudControlLight = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取云控基础平台灯态
|
||||
* @param lightState 当前灯态
|
||||
*/
|
||||
private fun getLightStatus(lightState: AstFuncTlmPhaseStateLightState): TrafficLightEnum {
|
||||
return when (lightState) {
|
||||
//红闪、红灯
|
||||
AstFuncTlmPhaseStateLightState.RED_FLASH,
|
||||
AstFuncTlmPhaseStateLightState.RED -> {
|
||||
TrafficLightEnum.RED
|
||||
}
|
||||
//绿灯待行状态、绿灯状态、受保护相位绿灯(箭头灯)
|
||||
AstFuncTlmPhaseStateLightState.GREEN_WAIT,
|
||||
AstFuncTlmPhaseStateLightState.GREEN,
|
||||
AstFuncTlmPhaseStateLightState.GREEN_PROTECTED -> {
|
||||
TrafficLightEnum.GREEN
|
||||
}
|
||||
//黄灯状态、黄闪
|
||||
AstFuncTlmPhaseStateLightState.YELLOW,
|
||||
AstFuncTlmPhaseStateLightState.YELLOW_FLASH -> {
|
||||
TrafficLightEnum.YELLOW
|
||||
}
|
||||
//异常、预留、未知状态、信号灯未工作、故障
|
||||
AstFuncTlmPhaseStateLightState.ERROR,
|
||||
AstFuncTlmPhaseStateLightState.RESERVED,
|
||||
AstFuncTlmPhaseStateLightState.UNKNOWN,
|
||||
AstFuncTlmPhaseStateLightState.OFF,
|
||||
AstFuncTlmPhaseStateLightState.FAULT -> {
|
||||
TrafficLightEnum.BLACK
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user