合并obu

Signed-off-by: 董宏宇 <martindhy@gmail.com>
This commit is contained in:
lixiaopeng
2021-09-16 17:13:59 +08:00
committed by 董宏宇
parent af07586400
commit 27193fe1f2
2 changed files with 100 additions and 82 deletions

View File

@@ -167,10 +167,11 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
* 控制展示限速标志及内容
*/
override fun showLimitingVelocity(limitingSpeed: Int) {
tvLimitingVelocity.visibility = View.VISIBLE
if (limitingSpeed > 0) {
tvLimitingVelocity.visibility = View.VISIBLE
tvLimitingVelocity.text = "$limitingSpeed"
} else {
tvLimitingVelocity.visibility = View.INVISIBLE
tvLimitingVelocity.text = "0"
}
}

View File

@@ -43,7 +43,7 @@ class MogoPrivateObuManager private constructor() {
fun init(context: Context?) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "obuManager初始化--")
mMogoServiceApis = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS)
.navigation(context) as IMogoServiceApis
.navigation(context) as IMogoServiceApis
mContext = context
// 获取预警模块的接口
mIMoGoWaringProvider = mMogoServiceApis!!.waringProviderApi
@@ -165,7 +165,7 @@ class MogoPrivateObuManager private constructor() {
val status = info.status
val level = info.threat_info.threat_level
val direction =
getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1)
getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1)
when (appId) {
// 道路危险情况预警
EventTypeEnum.TYPE_USECASE_ID_HLW.poiType -> {
@@ -291,12 +291,12 @@ class MogoPrivateObuManager private constructor() {
// (4) V2I预警信息CVX_IVP_THREAT_IND
override fun onCvxIvpThreatIndInfo(info: CvxIvpThreatIndInfo?) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "CvxIvpThreatIndInfo ------> $info")
if (info != null && info.ext_info != null && info.ext_info.lights.isNotEmpty()) {
if (info != null && info.ext_info != null && info.threat_info != null && info.ext_info.lights != null && info.ext_info.lights.isNotEmpty()) {
handlerTrafficLight(
info.threat_info.app_id,
info.status,
info.ext_info.lights,
info.ext_info.indicator
info.threat_info.app_id,
info.status,
info.ext_info.lights,
info.ext_info.indicator
)
}
}
@@ -304,12 +304,12 @@ class MogoPrivateObuManager private constructor() {
// (6) 地图红绿灯信息CVX_MAP_SPAT_INFO_IND
override fun onCvxMapSpatInfoIndInfo(info: CvxMapSpatInfoIndInfo?) {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxMapSpatInfoIndInfo ------> $info")
if (info != null && info.ivp_threat_ext != null && info.ivp_threat_ext.lights.isNotEmpty()) {
if (info != null && info.ivp_threat_ext != null && info.ivp_threat_ext.lights != null && info.ivp_threat_ext.lights.isNotEmpty()) {
handlerTrafficLight(
info.ivp_threat_info.app_id,
info.status,
info.ivp_threat_ext.lights,
info.ivp_threat_ext.indicator
info.ivp_threat_info.app_id,
info.status,
info.ivp_threat_ext.lights,
info.ivp_threat_ext.indicator
)
}
}
@@ -319,8 +319,8 @@ class MogoPrivateObuManager private constructor() {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "onCvxPtcInfoIndInfo ------> $info")
if (info != null) {
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"onCvxPtcInfoIndInfo ---status---> ${info.status}"
MogoObuConst.TAG_MOGO_OBU,
"onCvxPtcInfoIndInfo ---status---> ${info.status}"
)
var v2xType = ""
if (info.ptc_type == 1) { //摩托车
@@ -331,8 +331,8 @@ class MogoPrivateObuManager private constructor() {
val ttsContent = EventTypeEnum.getWarningTts(v2xType)
val alertContent = EventTypeEnum.getWarningContent(v2xType)
val direction =
getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1)
val level = info.threat_info.threat_level
getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1)
val level = if (info.threat_info != null) info.threat_info.threat_level else -1
when (info.status) {
// 添加
@@ -387,7 +387,9 @@ class MogoPrivateObuManager private constructor() {
ObuConstants.STATUS.ADD,
ObuConstants.STATUS.UPDATE,
-> {
mIMoGoWaringProvider?.showLimitingVelocity(info.ext_info.speed_limit_max.toInt())
if (info.ext_info != null) {
mIMoGoWaringProvider?.showLimitingVelocity(info.ext_info.speed_limit_max.toInt())
}
}
// 删除
ObuConstants.STATUS.DELETE -> {
@@ -411,10 +413,10 @@ class MogoPrivateObuManager private constructor() {
val level = info.threat_info.threat_level
val status = info.status
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"onCvxV2vThreatIndInfo target_classification = ${
MogoObuConst.TAG_MOGO_OBU,
"onCvxV2vThreatIndInfo target_classification = ${
getMessageDirection(info.ext_info.target_classification)
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
} --- direction = $direction --- appId = $appId ---level = $level -- status = $status"
)
handleSdkObu(appId, direction, status, level, info)
}
@@ -478,8 +480,8 @@ class MogoPrivateObuManager private constructor() {
*/
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<Light>, indicator: Int) {
Logger.d(
MogoObuConst.TAG_MOGO_OBU,
"handlerTrafficLight appId = $appId --- status = $status ---indicator = $indicator "
MogoObuConst.TAG_MOGO_OBU,
"handlerTrafficLight appId = $appId --- status = $status ---indicator = $indicator ---lights = $lights ---lights.size = ${lights.size}"
)
when (status) {
// 添加
@@ -497,19 +499,23 @@ class MogoPrivateObuManager private constructor() {
}
}
private var isRedLight = false
private var isGreenLight = false
/**
* 修改红绿灯
*/
private fun changeTrafficLightStatus(
appId: Int,
lights: List<Light>,
indicator: Int
appId: Int,
lights: List<Light>,
indicator: Int
) {
var ttsContent: String
var alertContent: String
// TODO 这里需要根据真实数据确定 indicator 取值方式
var ttsContent = ""
var alertContent = ""
// TODO 这里需要根据真实数据确定 indicator 取值方式,暂时写 0 调试
if (lights.size >= indicator) {
val currentLight = lights[indicator]
val currentLight = lights[0]
Logger.d(MogoObuConst.TAG_MOGO_OBU, "currentLight = $currentLight ---currentLight.phase = ${currentLight.phase} --- indicator = $indicator ---appId = $appId")
when (currentLight.phase) {
// 灯光不可用
0x0 -> {
@@ -517,35 +523,42 @@ class MogoPrivateObuManager private constructor() {
}
// 红灯
0x1 -> {
//显示警告红边
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
if (!isRedLight) {
mIMoGoWaringProvider!!.disableWarningV2X(appId.toString())
isRedLight = true
}
isGreenLight = false
mIMoGoWaringProvider?.showWarningTrafficLight(1)
mIMoGoWaringProvider?.changeCountdownRed(currentLight.count_down.toInt())
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
alertContent = EventTypeEnum.getWarningContent(appId.toString())
mIMoGoWaringProvider!!.showWarningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
appId.toString(),
object : WarningStatusListener {
override fun onDismiss() {
//关闭显示警告红边
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
}
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
appId.toString(),
null
)
}
// 绿灯
0x2 -> {
if (!isGreenLight) {
mIMoGoWaringProvider!!.disableWarningV2X(appId.toString())
isGreenLight = true
}
isRedLight = false
mIMoGoWaringProvider?.showWarningTrafficLight(3)
mIMoGoWaringProvider?.changeCountdownGreen(currentLight.count_down.toInt())
mIMoGoWaringProvider?.changeCountdownGreen(currentLight.count_down.toInt() + 1)
//防止数据出现问题的容错
mIMoGoWaringProvider?.changeCountdownRed(0)
mIMoGoWaringProvider?.changeCountdownYellow(0)
// 拼接建议速度
Logger.d(MogoObuConst.TAG_MOGO_OBU, "speed_min = ${currentLight.glosa_suggested_speed_min} --speed_max = ${currentLight.glosa_suggested_speed_max.toInt()}")
val adviceSpeed =
"${currentLight.glosa_suggested_speed_min.toInt()} - ${currentLight.glosa_suggested_speed_max.toInt()}"
"${currentLight.glosa_suggested_speed_min.toInt()} - ${currentLight.glosa_suggested_speed_max.toInt()}"
val adviceSpeedTts =
"${currentLight.glosa_suggested_speed_min.toInt()}${currentLight.glosa_suggested_speed_max.toInt()}"
"${currentLight.glosa_suggested_speed_min.toInt()}${currentLight.glosa_suggested_speed_max.toInt()}"
ttsContent =
String.format(
@@ -559,6 +572,7 @@ class MogoPrivateObuManager private constructor() {
adviceSpeed
)
var maxSpeed = currentLight.glosa_suggested_speed_max.toInt()
mIMoGoWaringProvider!!.showWarningV2X(
EventTypeEnum.TYPE_USECASE_ID_IVP_GREEN.poiType.toInt(),
alertContent,
@@ -569,8 +583,11 @@ class MogoPrivateObuManager private constructor() {
}
// 黄灯
0x3 -> {
mIMoGoWaringProvider!!.disableWarningV2X(appId.toString())
mIMoGoWaringProvider?.showWarningTrafficLight(2)
mIMoGoWaringProvider?.changeCountdownYellow(currentLight.count_down.toInt())
mIMoGoWaringProvider?.changeCountdownYellow(currentLight.count_down.toInt() + 1)
mIMoGoWaringProvider?.changeCountdownGreen(0)
mIMoGoWaringProvider?.changeCountdownRed(0)
}
}
}
@@ -586,16 +603,16 @@ class MogoPrivateObuManager private constructor() {
* @see com.mogo.module.common.enums.EventTypeEnum
*/
private fun handleSdkObu(
appId: Int,
direction: WarningDirectionEnum,
status: Int,
level: Int,
info: CvxV2vThreatIndInfo
appId: Int,
direction: WarningDirectionEnum,
status: Int,
level: Int,
info: CvxV2vThreatIndInfo
) {
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnum 提供的
Log.d(
MogoObuConst.TAG_MOGO_OBU,
"handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status"
MogoObuConst.TAG_MOGO_OBU,
"handleSdkObu appId = $appId --- handleDirection = $direction ---level = $level ---status = $status"
)
var alertContent: String
var ttsContent: String
@@ -605,16 +622,16 @@ class MogoPrivateObuManager private constructor() {
alertContent = EventTypeEnum.getWarningContent(appId.toString())
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
@@ -635,15 +652,15 @@ class MogoPrivateObuManager private constructor() {
alertContent = EventTypeEnum.getWarningContent(appId.toString())
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) {
ttsContent = String.format(ttsContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) {
ttsContent = String.format(ttsContent, "")
}
@@ -662,16 +679,16 @@ class MogoPrivateObuManager private constructor() {
ttsContent = EventTypeEnum.getWarningTts(appId.toString())
alertContent = EventTypeEnum.getWarningContent(appId.toString())
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) { //左后
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) { //右后
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
@@ -690,22 +707,22 @@ class MogoPrivateObuManager private constructor() {
ObuConstants.STATUS.ADD,
ObuConstants.STATUS.UPDATE -> {
Log.d(
MogoObuConst.TAG_MOGO_OBU,
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
MogoObuConst.TAG_MOGO_OBU,
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)
if (level == 2 || level == 3) {
//显示弹框,语音提示
mIMoGoWaringProvider?.showWarningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : WarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
(appId + direction.direction).toString(),//使用当前事件类型+方向记录tag当发生变化的时候关闭当前弹出新的
object : WarningStatusListener {
override fun onDismiss() {
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
}
}
)
//显示警告红边
mIMoGoWaringProvider?.showWarning(direction)