diff --git a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt index 7bf199d550..c012b9f31e 100644 --- a/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt +++ b/core/function-impl/mogo-core-function-obu-mogo/src/main/java/com/mogo/eagle/core/function/obu/mogo/MogoPrivateObuNewManager.kt @@ -18,6 +18,7 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Defa import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager import com.mogo.eagle.core.function.call.obu.CallerObuListenerManager +import com.mogo.eagle.core.function.call.obu.CallerObuTrafficLightDisappearManager import com.mogo.eagle.core.function.call.obu.CallerObuTrafficLightListenerManager import com.mogo.eagle.core.function.call.v2x.CallObuLimitingSpeedListenerManager import com.mogo.eagle.core.function.obu.mogo.utils.TrafficDataConvertUtilsNew @@ -758,30 +759,35 @@ class MogoPrivateObuNewManager private constructor() { // 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的 var alertContent: String = "" var ttsContent: String = "" + var saveAppId: String = "" var changeVisualAngle = false when (appId) { - //交叉路口碰撞预警 + //前向碰撞预警 MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType } //交叉路口碰撞预警 MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType } //左转辅助预警 MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType } //盲区预警 MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> { ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType if ( direction == WarningDirectionEnum.ALERT_WARNING_LEFT || direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || @@ -805,6 +811,7 @@ class MogoPrivateObuNewManager private constructor() { MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType if ( direction == WarningDirectionEnum.ALERT_WARNING_LEFT || direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT || @@ -826,12 +833,14 @@ class MogoPrivateObuNewManager private constructor() { MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType } //紧急制动预警 MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType } //异常车辆提醒 @@ -840,6 +849,7 @@ class MogoPrivateObuNewManager private constructor() { ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType) alertContent = String.format(alertContent, direction.desc) ttsContent = String.format(ttsContent, direction.desc) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType } //车辆失控预警 @@ -848,11 +858,13 @@ class MogoPrivateObuNewManager private constructor() { ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType) alertContent = String.format(alertContent, direction.desc) ttsContent = String.format(ttsContent, direction.desc) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType } //车辆失控预警 MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> { alertContent = EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) ttsContent = EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType) + saveAppId = EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType } // 这里处理固定的提示信息,包括了<紧急车辆提醒> @@ -868,7 +880,7 @@ class MogoPrivateObuNewManager private constructor() { MogoObuConstants.STATUS.UPDATE -> { CallerLogger.d( "$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}", - "new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" + "new handleSdkObu appId2 = $saveAppId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction" ) if (level == 2 || level == 3) { //不显示弹框,其它保留 @@ -876,7 +888,7 @@ class MogoPrivateObuNewManager private constructor() { MsgBoxBean( MsgBoxType.V2X, V2XMsg( - appId, + saveAppId, alertContent, ttsContent ) @@ -885,10 +897,10 @@ class MogoPrivateObuNewManager private constructor() { } ) CallerHmiManager.warningV2X( - appId, + saveAppId, alertContent, ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒 - (appId + direction.direction),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 + (saveAppId + direction.direction),//使用当前事件类型+方向记录tag,当发生变化的时候关闭当前弹出新的 object : IMoGoWarningStatusListener { override fun onShow() { super.onShow() @@ -958,9 +970,7 @@ class MogoPrivateObuNewManager private constructor() { isShowGreenWave = false isShowRunRedLight = false isYellowLight = false -// lightCountDownRed = 1 -// lightCountDownGreen = 1 -// lightCountDownYellow = 1 + CallerObuTrafficLightDisappearManager.invokeObuTrafficLightDisappear() } } } @@ -971,11 +981,6 @@ class MogoPrivateObuNewManager private constructor() { private var isShowGreenWave = false private var isShowRunRedLight = false -// private var lightCountDownRed : Int = 1 -// private var lightCountDownGreen : Int = 1 -// private var lightCountDownYellow : Int = 1 - - /** * 修改红绿灯 */ @@ -1044,15 +1049,9 @@ class MogoPrivateObuNewManager private constructor() { if (minSpeedTemp == maxSpeedTemp) { minSpeedTemp -= 5 } - val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp" val adviceSpeedTts = "$minSpeedTemp 到 $maxSpeedTemp" -// val adviceSpeed = -// "${Math.round(currentLight.suggestMinSpeed*3.6)} - ${Math.round(currentLight.suggestMaxSpeed*3.6)}" -// val adviceSpeedTts = -// "${Math.round(currentLight.suggestMinSpeed*3.6)} 到 ${Math.round(currentLight.suggestMaxSpeed*3.6)}" - ttsContent = String.format( EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType), @@ -1100,87 +1099,42 @@ class MogoPrivateObuNewManager private constructor() { } // 红灯 2, 3 -> { -// if (!isGreenLight) { //只有不是是绿灯,才能展示跳转到红灯 if (!isRedLight) { CallerHmiManager.disableWarningV2X(appId.toString()) isRedLight = true } isGreenLight = false isYellowLight = false -// lightCountDownYellow = 1 -// lightCountDownGreen = 1 - CallerObuTrafficLightListenerManager.invokeObuTrafficLight(1) val red = currentLight.countDown.toInt() -// Log.e("lixp", " ----11--- red --------- = $red ----lightCountDownRed = $lightCountDownRed ----isGreenLight = $isGreenLight") -// //记录当前红灯的上一帧的值 10,9,10 -// if (lightCountDownRed == 1) { //最后一个灯态是1 -// lightCountDownRed = red -// } -// -// if (lightCountDownRed < red) { //10 9 -// return -// } -// lightCountDownRed = red -// Log.e("lixp", " ----22--- red --------- = $red ----lightCountDownRed = $lightCountDownRed ----isGreenLight = $isGreenLight") CallerHmiManager.changeCountdownRed(red) -// } } // 绿灯 4, 5, 6 -> { -// if (!isYellowLight) { //只有不是黄灯的时候,才能跳转到绿灯 if (!isGreenLight) { CallerHmiManager.disableWarningV2X(appId.toString()) isGreenLight = true } isRedLight = false isYellowLight = false -// lightCountDownRed = 1 -// lightCountDownYellow = 1 CallerObuTrafficLightListenerManager.invokeObuTrafficLight(3) val green = currentLight.countDown.toInt() -// Log.e("lixp", " ----11--- green --------- = $green ---lightCountDownGreen = $lightCountDownGreen ----isYellowLight = $isYellowLight") -// if (lightCountDownGreen == 1) { -// lightCountDownGreen = green -// } -// -// if (lightCountDownGreen < green) { -// return -// } -// lightCountDownGreen = green -// Log.d("lixp", " ----22--- green --------- = $green ---lightCountDownGreen = $lightCountDownGreen ----isYellowLight = $isYellowLight") CallerHmiManager.changeCountdownGreen(green) -// } } // 黄灯 7, 8 -> { -// if (!isRedLight) { //黄灯只能跳转绿灯 if (!isYellowLight) { isYellowLight = true } isRedLight = false isGreenLight = false -// lightCountDownRed = 1 -// lightCountDownGreen = 1 - CallerHmiManager.disableWarningV2X(appId.toString()) CallerObuTrafficLightListenerManager.invokeObuTrafficLight(2) val yellow = currentLight.countDown.toInt() -// Log.e("lixp", " -----11-- yellow --------- = $yellow ---lightCountDownYellow = $lightCountDownYellow ----isYellowLight = $isYellowLight") -// if (lightCountDownYellow == 1) { -// lightCountDownYellow = yellow -// } -// -// if (lightCountDownYellow < yellow) { -// return -// } -// lightCountDownYellow = yellow -// Log.d("lixp", " -----22-- yellow --------- = $yellow ---lightCountDownYellow = $lightCountDownYellow ----isYellowLight = $isYellowLight") CallerHmiManager.changeCountdownYellow(yellow) } } -// } } diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/trafficlight/core/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/trafficlight/core/TrafficLightDispatcher.kt index 03ca1b2c9d..3fa53c8834 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/trafficlight/core/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/trafficlight/core/TrafficLightDispatcher.kt @@ -5,10 +5,12 @@ import android.os.Handler import android.util.Log import com.mogo.eagle.core.data.trafficlight.TrafficLightResult import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener +import com.mogo.eagle.core.function.api.obu.IMoGoObuTrafficLightDisapperListener import com.mogo.eagle.core.function.api.obu.IMoGoObuTrafficLightListener import com.mogo.eagle.core.function.api.trafficlight.IMoGoTrafficLightListener import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager import com.mogo.eagle.core.function.call.hmi.CallerHmiManager +import com.mogo.eagle.core.function.call.obu.CallerObuTrafficLightDisappearManager import com.mogo.eagle.core.function.call.obu.CallerObuTrafficLightListenerManager import com.mogo.eagle.core.function.call.trafficlight.CallerTrafficLightListenerManager import com.mogo.eagle.core.function.v2x.trafficlight.TrafficLightHMIManager @@ -21,7 +23,7 @@ import perception.TrafficLightOuterClass.TrafficLight * @since: 2022/4/28 */ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLightListener, - IMoGoObuTrafficLightListener { + IMoGoObuTrafficLightListener, IMoGoObuTrafficLightDisapperListener { companion object { const val TAG = "TrafficLightDispatcher" @@ -50,6 +52,8 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerAutopilotIdentifyListenerManager.addListener(TAG, this) //obu红绿灯数据 CallerObuTrafficLightListenerManager.registerObuTrafficLightListener(TAG, this) + //obu红绿灯数据消失 + CallerObuTrafficLightDisappearManager.registerObuTrafficLightListener(TAG, this) } /** @@ -153,6 +157,10 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight CallerHmiManager.showWarningTrafficLight(light, 3) } + override fun onObuLightDisapper() { + hasObuLightStatus = false + } + fun destroy() { //取消注册监听AI云获取红绿灯状态 CallerTrafficLightListenerManager.unRegisterTrafficLightListener(TAG) diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuTrafficLightDisapperListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuTrafficLightDisapperListener.kt new file mode 100644 index 0000000000..a5297714cd --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuTrafficLightDisapperListener.kt @@ -0,0 +1,12 @@ +package com.mogo.eagle.core.function.api.obu + + +/** + * @author lixiaopeng + * @date 2022/1/30 10:28 下午 + * OBU 灯态信息 消失 + */ +interface IMoGoObuTrafficLightDisapperListener { + + fun onObuLightDisapper() +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuTrafficLightListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuTrafficLightListener.kt index 1b4be4e95c..de5b5aee6a 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuTrafficLightListener.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/obu/IMoGoObuTrafficLightListener.kt @@ -11,5 +11,4 @@ interface IMoGoObuTrafficLightListener { * @param light 灯的信息 */ fun onObuTrafficLight(light: Int){} - } \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuTrafficLightDisappearManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuTrafficLightDisappearManager.kt new file mode 100644 index 0000000000..3302fafd29 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/obu/CallerObuTrafficLightDisappearManager.kt @@ -0,0 +1,61 @@ +package com.mogo.eagle.core.function.call.obu + +import com.mogo.eagle.core.function.api.obu.IMoGoObuTrafficLightDisapperListener +import com.mogo.eagle.core.function.api.obu.IMoGoObuTrafficLightListener +import java.util.concurrent.ConcurrentHashMap + +object CallerObuTrafficLightDisappearManager { + + private val M_OBU_TRAFFIC_LIGHT_LISTENER: ConcurrentHashMap = + ConcurrentHashMap() + + /** + * 添加监听 + * @param tag 标记,用来注销监听使用 + * @param listener 监听回调 + */ + fun registerObuTrafficLightListener( + tag: String, + listener: IMoGoObuTrafficLightDisapperListener + ) { + if (M_OBU_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) { + return + } + M_OBU_TRAFFIC_LIGHT_LISTENER[tag] = listener + } + + /** + * 删除监听 + * @param tag 标记,用来注销监听使用 + */ + fun unRegisterObuTrafficLightListener(tag: String) { + if (!M_OBU_TRAFFIC_LIGHT_LISTENER.containsKey(tag)) { + return + } + M_OBU_TRAFFIC_LIGHT_LISTENER.remove(tag) + } + + /** + * 删除监听 + * @param listener 要删除的监听对象 + */ + fun unRegisterObuTrafficLightListener(listener: IMoGoObuTrafficLightListener) { + if (!M_OBU_TRAFFIC_LIGHT_LISTENER.containsValue(listener)) { + return + } + M_OBU_TRAFFIC_LIGHT_LISTENER.forEach { + if (it.value == listener) { + M_OBU_TRAFFIC_LIGHT_LISTENER.remove(it.key) + } + } + } + + fun invokeObuTrafficLightDisappear() { + M_OBU_TRAFFIC_LIGHT_LISTENER.forEach { + val tag = it.key + val listener = it.value + listener.onObuLightDisapper() + } + } + +} \ No newline at end of file