完成了预警红边的迁移HMI

调用方式为
//显示警告红边
mIMoGoWaringProvider!!.showWarning(direction)
This commit is contained in:
董宏宇
2021-09-10 22:02:24 +08:00
parent d6c348f1c7
commit 2efc04d1d1
31 changed files with 487 additions and 122 deletions

1
.idea/gradle.xml generated
View File

@@ -35,6 +35,7 @@
<option value="$PROJECT_DIR$/modules/mogo-module-authorize" />
<option value="$PROJECT_DIR$/modules/mogo-module-back" />
<option value="$PROJECT_DIR$/modules/mogo-module-common" />
<option value="$PROJECT_DIR$/modules/mogo-module-data" />
<option value="$PROJECT_DIR$/modules/mogo-module-extensions" />
<option value="$PROJECT_DIR$/modules/mogo-module-hmi" />
<option value="$PROJECT_DIR$/modules/mogo-module-left-panel" />

2
.idea/misc.xml generated
View File

@@ -11,8 +11,10 @@
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="../../../../../../layout/custom_preview.xml" value="0.390625" />
<entry key="../../../../../layout/custom_preview.xml" value="0.19947916666666668" />
<entry key="modules/mogo-module-hmi/src/main/res/layout/fragment_warning.xml" value="0.34427083333333336" />
<entry key="modules/mogo-module-hmi/src/main/res/layout/module_hmi_warning_v2x.xml" value="0.246875" />
<entry key="modules/mogo-module-hmi/src/main/res/layout/notification_v2x_msg_vr.xml" value="0.3453125" />
<entry key="modules/mogo-module-hmi/src/main/res/layout/view_traffic_light_vr.xml" value="0.25" />
<entry key="modules/mogo-module-main/src/main/res/layout/module_main_activity_main.xml" value="0.3125" />

View File

@@ -99,6 +99,7 @@ ext {
modulemainindependent : "com.mogo.module:module-main-independent:${MOGO_MODULE_MAIN_INDEPENDENT_VERSION}",
modulemap : "com.mogo.module:module-map:${MOGO_MODULE_MAP_VERSION}",
moduleservice : "com.mogo.module:module-service:${MOGO_MODULE_SERVICE_VERSION}",
moduledata : "com.mogo.module:module-data:${MOGO_MODULE_DATA_VERSION}",
mogoservice : "com.mogo.service:mogo-service:${MOGO_SERVICE_VERSION}",
mogoserviceapi : "com.mogo.service:mogo-service-api:${MOGO_SERVICE_API_VERSION}",
moduleapps : "com.mogo.module:module-apps:${MOGO_MODULE_APPS_VERSION}",

View File

@@ -68,6 +68,7 @@ MOGO_MODULE_COMMON_VERSION=2.0.58
MOGO_MODULE_MAIN_VERSION=2.0.58
MOGO_MODULE_MAP_VERSION=2.0.58
MOGO_MODULE_SERVICE_VERSION=2.0.58
MOGO_MODULE_DATA_VERSION=2.0.58
MOGO_MODULE_EXTENSIONS_VERSION=2.0.58
MOGO_MODULE_SEARCH_VERSION=2.0.58
MOGO_MODULE_BACK_VERSION=2.0.58

View File

@@ -190,44 +190,44 @@ public class MainLauncherActivity extends MainActivity implements IMogoIntentLis
mWarningLeft.setVisibility(View.GONE);
mWarningRight.setVisibility(View.GONE);
mWarningBottom.setVisibility(View.GONE);
// startCountDownWithView(mWarningTop);
startCountDownWithView(mWarningTop);
break;
case ALERT_THE_FRONT_CRASH_WARNING_LEFT:
mWarningLeft.setVisibility(View.VISIBLE);
mWarningTop.setVisibility(View.GONE);
mWarningRight.setVisibility(View.GONE);
mWarningBottom.setVisibility(View.GONE);
// startCountDownWithView(mWarningLeft);
startCountDownWithView(mWarningLeft);
break;
case ALERT_THE_FRONT_CRASH_WARNING_RIGHT:
mWarningRight.setVisibility(View.VISIBLE);
mWarningTop.setVisibility(View.GONE);
mWarningLeft.setVisibility(View.GONE);
mWarningBottom.setVisibility(View.GONE);
// startCountDownWithView(mWarningRight);
startCountDownWithView(mWarningRight);
break;
case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM:
mWarningBottom.setVisibility(View.VISIBLE);
mWarningRight.setVisibility(View.GONE);
mWarningTop.setVisibility(View.GONE);
mWarningLeft.setVisibility(View.GONE);
// startCountDownWithView(mWarningBottom);
startCountDownWithView(mWarningBottom);
break;
case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_LEFT:
mWarningBottom.setVisibility(View.VISIBLE);
mWarningRight.setVisibility(View.GONE);
mWarningTop.setVisibility(View.GONE);
mWarningLeft.setVisibility(View.VISIBLE);
// startCountDownWithView(mWarningBottom);
// startCountDownWithView(mWarningLeft);
startCountDownWithView(mWarningBottom);
startCountDownWithView(mWarningLeft);
break;
case ALERT_THE_FRONT_CRASH_WARNING_BOTTOM_RIGHT:
mWarningBottom.setVisibility(View.VISIBLE);
mWarningRight.setVisibility(View.VISIBLE);
mWarningTop.setVisibility(View.GONE);
mWarningLeft.setVisibility(View.GONE);
// startCountDownWithView(mWarningBottom);
// startCountDownWithView(mWarningRight);
startCountDownWithView(mWarningBottom);
startCountDownWithView(mWarningRight);
break;
default:
break;

View File

@@ -1,3 +1,4 @@
:modules:mogo-module-data
:foudations:mogo-utils
:skin:mogo-skin-support
:tts:tts-base

1
modules/mogo-module-data/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1 @@
### 这里存放数据相关的class

View File

@@ -0,0 +1,36 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion rootProject.ext.android.compileSdkVersion
// buildToolsVersion rootProject.ext.android.buildToolsVersion
defaultConfig {
minSdkVersion rootProject.ext.android.minSdkVersion
targetSdkVersion rootProject.ext.android.targetSdkVersion
versionCode Integer.valueOf(VERSION_CODE)
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -0,0 +1,3 @@
GROUP=com.mogo.module
POM_ARTIFACT_ID=module-data
VERSION_CODE=1

View File

@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.mogo.module.data">
</manifest>

View File

@@ -0,0 +1,51 @@
package com.mogo.module.data.enums
/**
*@author xiaoyuzhou
*@date 2021/9/10 8:48 下午
*/
enum class WarningDirectionEnum(
var direction: Int,
var desc: String,
) {
ALERT_WARNING_NON(
0,
"关闭红色边框预警"
),
ALERT_WARNING_TOP(
1,
"正前方"
),
ALERT_WARNING_RIGHT(
2,
"正右边"
),
ALERT_WARNING_BOTTOM(
3,
"正后方"
),
ALERT_WARNING_LEFT(
4,
"正左方"
),
ALERT_WARNING_TOP_RIGHT(
5,
"正前方"
),
ALERT_WARNING_BOTTOM_RIGHT(
6,
"正前方"
),
ALERT_WARNING_BOTTOM_LEFT(
7,
"正前方"
),
ALERT_WARNING_TOP_LEFT(
8,
"正前方"
),
ALERT_WARNING_ALL(
9,
"全方位"
)
}

View File

@@ -59,6 +59,7 @@ dependencies {
api rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.moduleservice
implementation rootProject.ext.dependencies.moduledata
} else {
api project(":libraries:mogo-map")
api project(":libraries:mogo-map-api")
@@ -67,6 +68,7 @@ dependencies {
api project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-service')
implementation project(':modules:mogo-module-data')
}
}

View File

@@ -1,6 +1,7 @@
package com.mogo.module.hmi.ui
import com.mogo.commons.mvp.IView
import com.mogo.module.data.enums.WarningDirectionEnum
/**
@@ -9,10 +10,6 @@ import com.mogo.commons.mvp.IView
*/
interface MoGoWarningContract {
/**
*
*/
interface View : IView {
/**
@@ -81,5 +78,20 @@ interface MoGoWarningContract {
* 关闭限速预警
*/
fun disableLimitingVelocity()
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum)
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long)
}
}

View File

@@ -14,6 +14,7 @@ import com.mogo.module.hmi.notification.WarningFloat
import com.mogo.module.hmi.notification.anim.DefaultAnimator
import com.mogo.module.hmi.notification.enums.SidePattern
import com.mogo.module.hmi.ui.widget.V2XNotificationView
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.fragment_warning.*
@@ -95,7 +96,10 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
.show()
// 创建弹窗成功才进行TTS播报
Logger.d("MoGoWarningFragment", " mWarningFloat = " + mWarningFloat + "---ttsContent = " + ttsContent)
Logger.d(
"MoGoWarningFragment",
"mWarningFloat = $mWarningFloat---ttsContent = $ttsContent"
)
if (mWarningFloat != null && !TextUtils.isEmpty(ttsContent)) {
Logger.d("MoGoWarningFragment", "---> ttsContent = $ttsContent")
AIAssist.getInstance(activity)
@@ -171,4 +175,23 @@ class MoGoWarningFragment : MvpFragment<MoGoWarningContract.View?, WaringPresent
tvLimitingVelocity.visibility = View.GONE
tvLimitingVelocity.text = "0"
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
override fun showWarning(direction: WarningDirectionEnum) {
flV2XWarningView.showWarning(direction)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
override fun showWarning(direction: WarningDirectionEnum, closeTime: Long) {
flV2XWarningView.showWarning(direction, closeTime)
}
}

View File

@@ -10,27 +10,4 @@ class WaringPresenter(view: MoGoWarningContract.View?) :
Presenter<MoGoWarningContract.View?>(view) {
fun showWarningV2X(v2xType: Int, alertMessage: String, tag: String) {
}
fun disableWarningV2X(tag: String) {
mView?.disableWarningV2X(tag)
}
fun showWarningTrafficLight(checkLightId: Int) {
mView?.showWarningTrafficLight(checkLightId)
}
fun disableWarningTrafficLight() {
mView?.disableWarningTrafficLight()
}
fun showLimitingVelocity(limitingSpeed: Int) {
mView?.showLimitingVelocity(limitingSpeed)
}
fun disableLimitingVelocity() {
mView?.disableLimitingVelocity()
}
}

View File

@@ -0,0 +1,118 @@
package com.mogo.module.hmi.ui.widget
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.RelativeLayout
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.module.hmi.R
import com.mogo.utils.logger.Logger
import kotlinx.android.synthetic.main.module_hmi_warning_v2x.view.*
/**
*@author xiaoyuzhou
*@date 2021/9/10 7:44 下午
*/
class V2XWarningView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr) {
private val ALL_CLOSE_TIMER = 10000L
private val closeWarningTask: Runnable = Runnable {
showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
}
init {
LayoutInflater.from(context).inflate(R.layout.module_hmi_warning_v2x, this, true)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum) {
showWarning(direction, ALL_CLOSE_TIMER)
}
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long) {
Logger.d("V2XWarningView", "预警红边:预警方向->$direction 预警倒计时->$closeTime")
// 如果传入的不是关闭显示,则设置倒计时,定时关闭红框警示
if (direction != WarningDirectionEnum.ALERT_WARNING_NON) {
removeCallbacks(closeWarningTask)
postDelayed(closeWarningTask, closeTime)
}
when (direction) {
WarningDirectionEnum.ALERT_WARNING_NON -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_TOP -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.VISIBLE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.GONE
}
WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> {
hmiWarningTopImg.visibility = View.GONE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.VISIBLE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_TOP_LEFT -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
WarningDirectionEnum.ALERT_WARNING_ALL -> {
hmiWarningTopImg.visibility = View.VISIBLE
hmiWarningRightImg.visibility = View.GONE
hmiWarningBottomImg.visibility = View.GONE
hmiWarningLeftImg.visibility = View.VISIBLE
}
}
}
}

View File

@@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.module.data.enums.WarningDirectionEnum;
import com.mogo.module.hmi.WaringConst;
import com.mogo.module.hmi.ui.MoGoWarningFragment;
import com.mogo.service.MogoServicePaths;
@@ -101,4 +102,13 @@ public class MoGoWarningProvider implements IMoGoWaringProvider {
mMoGoWarningFragment.disableWarningV2X(tag);
}
@Override
public void showWarning(@NonNull WarningDirectionEnum direction) {
mMoGoWarningFragment.showWarning(direction);
}
@Override
public void showWarning(@NonNull WarningDirectionEnum direction, long closeTime) {
mMoGoWarningFragment.showWarning(direction, closeTime);
}
}

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="0"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="180"
android:endColor="#00F03232"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="270"
android:endColor="#00FF0606"
android:startColor="#66FF0808"
android:type="linear"/>
</shape>

View File

@@ -5,6 +5,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mogo.module.hmi.ui.widget.V2XWarningView
android:id="@+id/flV2XWarningView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.mogo.module.hmi.ui.widget.SpeedPanelView
android:id="@+id/flSpeedChartView"
android:layout_width="@dimen/module_ext_speed_width"

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--四个方向,碰撞预警-->
<ImageView
android:id="@+id/hmiWarningTopImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_290"
android:background="@drawable/module_hmi_warning_bkg_top"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningLeftImg"
android:layout_width="@dimen/dp_290"
android:layout_height="match_parent"
android:background="@drawable/module_hmi_warning_bkg_left"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningRightImg"
android:layout_width="@dimen/dp_290"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@drawable/module_hmi_warning_bkg_right"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/hmiWarningBottomImg"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_290"
android:layout_gravity="bottom"
android:background="@drawable/module_hmi_warning_bkg_bottom"
android:visibility="gone"
tools:visibility="visible" />
</FrameLayout>

View File

@@ -54,10 +54,12 @@ dependencies {
api rootProject.ext.dependencies.mogoutils
api rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon
implementation rootProject.ext.dependencies.moduledata
} else {
api project(":foudations:mogo-utils")
api project(':services:mogo-service-api')
implementation project(':modules:mogo-module-common')
implementation project(':modules:mogo-module-data')
}
implementation rootProject.ext.dependencies.mogoobu

View File

@@ -7,6 +7,7 @@ import com.mogo.commons.voice.AIAssist
import com.mogo.module.common.datacenter.SnapshotLocationDataCenter
import com.mogo.module.common.drawer.TrafficMarkerDrawer
import com.mogo.module.common.enums.WarningTypeEnum
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.module.obu.mogo.utils.TrafficDataConvertUtils
import com.mogo.service.IMogoServiceApis
import com.mogo.service.MogoServicePaths
@@ -165,7 +166,7 @@ class MogoPrivateObuManager private constructor() {
val status = info.status
val level = info.threat_info.threat_level
val direction =
getOtherObjDirection(if (info.ext_info != null) info.ext_info.pos_classification else 7)
getMessageDirection(if (info.ext_info != null) info.ext_info.pos_classification else -1)
when (appId) {
// 道路危险情况预警
WarningTypeEnum.TYPE_USECASE_ID_HLW.useCaseId -> {
@@ -178,11 +179,15 @@ class MogoPrivateObuManager private constructor() {
0x2 -> {
// 特殊处理左、右方向的
when (direction) {
3 -> {
WarningDirectionEnum.ALERT_WARNING_LEFT,
WarningDirectionEnum.ALERT_WARNING_TOP_LEFT,
WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT -> {
appId =
WarningTypeEnum.TYPE_USECASE_ID_ROAD_TURN_LEFT_SHARP.useCaseId
}
4 -> {
WarningDirectionEnum.ALERT_WARNING_RIGHT,
WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT,
WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT -> {
appId =
WarningTypeEnum.TYPE_USECASE_ID_ROAD_TURN_RIGHT_SHARP.useCaseId
}
@@ -246,9 +251,7 @@ class MogoPrivateObuManager private constructor() {
// 添加
ObuConstants.STATUS.ADD -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider!!.showWarning(direction)
//显示弹框,语音提示
mIMoGoWaringProvider!!.showWarningV2X(
appId,
@@ -263,10 +266,8 @@ class MogoPrivateObuManager private constructor() {
}
// 删除
ObuConstants.STATUS.DELETE -> {
//关闭警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
0, "ACTION_V2X_FRONT_WARNING"
)
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
// 更新数据
@@ -279,9 +280,7 @@ class MogoPrivateObuManager private constructor() {
// 更新
else -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider!!.showWarning(direction)
// 更新数据
TrafficDataConvertUtils.cvxRtiThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficInfo(it)
@@ -326,6 +325,17 @@ class MogoPrivateObuManager private constructor() {
MogoObuConst.TAG_MOGO_OBU,
"onCvxPtcInfoIndInfo ---status---> ${info.status}"
)
var v2xType = 0
if (info.ptc_type == 1) { //摩托车
v2xType = WarningTypeEnum.TYPE_USECASE_ID_VRUCW_MOTORBIKE.useCaseId
} else if (info.ptc_type == 2) { //行人
v2xType = WarningTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.useCaseId
}
val ttsContent = WarningTypeEnum.getWarningTts(v2xType)
val alertContent = WarningTypeEnum.getWarningContent(v2xType)
val direction =
getMessageDirection(if (info.ext_info != null) info.ext_info.target_classification else -1)
when (info.status) {
// 添加
ObuConstants.STATUS.ADD -> {
@@ -333,21 +343,8 @@ class MogoPrivateObuManager private constructor() {
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficInfo(it)
}
var v2xType = 0
if (info.ptc_type == 1) { //摩托车
v2xType = WarningTypeEnum.TYPE_USECASE_ID_VRUCW_MOTORBIKE.useCaseId
} else if (info.ptc_type == 2) { //行人
v2xType = WarningTypeEnum.TYPE_USECASE_ID_VRUCW_PERSON.useCaseId
}
val ttsContent = WarningTypeEnum.getWarningTts(v2xType)
val alertContent = WarningTypeEnum.getWarningContent(v2xType)
val direction = 1
//getOtherObjDirection(if (info.ext_info != null) info.ext_info.target_classification else 7)
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider!!.showWarning(direction)
mIMoGoWaringProvider!!.showWarningV2X(
v2xType,
alertContent,
@@ -357,10 +354,8 @@ class MogoPrivateObuManager private constructor() {
}
// 删除
ObuConstants.STATUS.DELETE -> {
//关闭警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
0, "ACTION_V2X_FRONT_WARNING"
)
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 更新数据
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
// 事件结束,还原交通参与者颜色
@@ -371,12 +366,8 @@ class MogoPrivateObuManager private constructor() {
}
// 更新
else -> {
val direction = 1
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction,
"ACTION_V2X_FRONT_WARNING"
)
// 显示警告红边
mIMoGoWaringProvider!!.showWarning(direction)
// 更新数据
TrafficDataConvertUtils.cvxPtcThreatIndInfo2TrafficData(info)?.let {
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
@@ -441,51 +432,43 @@ class MogoPrivateObuManager private constructor() {
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): Int {
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
Logger.d(MogoObuConst.TAG_MOGO_OBU, "预警红边:预警方向->$targetClassification")
return when (targetClassification) {
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_IN_LANE,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE -> 1 //正前方
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_IN_LANE,
0x04 -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE -> 2 //正
0x03 -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_IN_LANE,
0x05 -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
0x02 -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正左方
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> 3 //左前方
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_FAR_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_FAR_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_AHEAD_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_INTERSECTION_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> 4 //右前方
ObuConstants.TARGET_CLASSIFICATION.TC_ONCOMING_RIGHT -> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_LEFT,
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> 5 //左后方 弹框目前后方分为左后,右后,正后方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_LEFT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_RIGHT,
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> 6 //右后方
ObuConstants.TARGET_CLASSIFICATION.TC_BEHIND_FAR_RIGHT -> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> -1 //未知
else -> 0
ObuConstants.TARGET_CLASSIFICATION.TC_UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
else -> WarningDirectionEnum.ALERT_WARNING_ALL
}
}
/**
* 获取道路其他 的方位
*/
private fun getOtherObjDirection(posClassification: Int): Int {
return when (posClassification) {
0x01 -> 0 //事件中
0x02 -> 3 //左侧
0x03 -> 4 //右侧
0x04 -> 1 //前方
0x05 -> 2 //后方
else -> 7
}
}
fun release() {
MogoObuManager.getInstance().unregisterListener()
}
@@ -536,10 +519,7 @@ class MogoPrivateObuManager private constructor() {
// 红灯
0x1 -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
1,
"ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider?.showWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
mIMoGoWaringProvider?.showWarningTrafficLight(1)
mIMoGoWaringProvider?.changeCountdownRed(currentLight.count_down.toInt())
ttsContent = WarningTypeEnum.getWarningTts(appId)
@@ -603,7 +583,7 @@ class MogoPrivateObuManager private constructor() {
*/
private fun handleSdkObu(
appId: Int,
direction: Int,
direction: WarningDirectionEnum,
status: Int,
level: Int,
info: CvxV2vThreatIndInfo
@@ -620,10 +600,18 @@ class MogoPrivateObuManager private constructor() {
WarningTypeEnum.TYPE_USECASE_ID_LCW.useCaseId -> {
alertContent = WarningTypeEnum.getWarningContent(appId)
ttsContent = WarningTypeEnum.getWarningTts(appId)
if (direction == 5) {
if (
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 == 6) {
} else if (
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, "")
}
@@ -650,9 +638,17 @@ class MogoPrivateObuManager private constructor() {
WarningTypeEnum.TYPE_USECASE_ID_LTA.useCaseId -> {
alertContent = WarningTypeEnum.getWarningContent(appId)
ttsContent = WarningTypeEnum.getWarningTts(appId)
if (direction == 5) {
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) {
ttsContent = String.format(ttsContent, "")
} else if (direction == 6) {
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) {
ttsContent = String.format(ttsContent, "")
}
}
@@ -678,10 +674,18 @@ class MogoPrivateObuManager private constructor() {
WarningTypeEnum.TYPE_USECASE_ID_BSW.useCaseId -> {
ttsContent = WarningTypeEnum.getWarningTts(appId)
alertContent = WarningTypeEnum.getWarningContent(appId)
if (direction == 5) { //左后
if (
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 == 6) { //右后
} else if (
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, "")
}
@@ -697,17 +701,14 @@ class MogoPrivateObuManager private constructor() {
when (status) {
// 添加, add的时候可能级别是2
ObuConstants.STATUS.ADD -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction,
"ACTION_V2X_FRONT_WARNING"
)
//显示弹框,语音提示
Log.d(
MogoObuConst.TAG_MOGO_OBU,
"appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)
mIMoGoWaringProvider!!.showWarningV2X(
//显示警告红边
mIMoGoWaringProvider?.showWarning(direction)
//显示弹框,语音提示
mIMoGoWaringProvider?.showWarningV2X(
appId,
alertContent,
if (level == 3) ttsContent else "",
@@ -724,10 +725,8 @@ class MogoPrivateObuManager private constructor() {
// 删除
ObuConstants.STATUS.DELETE -> {
isStrikeTts = false
//关闭警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
0, "ACTION_V2X_FRONT_WARNING"
)
// 关闭警告红边
mIMoGoWaringProvider!!.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
mIMoGoWaringProvider?.disableWarningV2X(appId.toString())
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
@@ -739,9 +738,7 @@ class MogoPrivateObuManager private constructor() {
// 更新
else -> {
//显示警告红边
mMogoServiceApis!!.v2XListenerManager.warningChangedForListenerWithDirection(
direction, "ACTION_V2X_FRONT_WARNING"
)
mIMoGoWaringProvider?.showWarning(direction)
if (!isStrikeTts) {
AIAssist.getInstance(mContext).speakTTSVoice(ttsContent)
isStrikeTts = true

View File

@@ -56,9 +56,11 @@ dependencies {
if (Boolean.valueOf(RELEASE)) {
api rootProject.ext.dependencies.mogomapapi
api rootProject.ext.dependencies.skinsupport
implementation rootProject.ext.dependencies.moduledata
} else {
api project(":libraries:mogo-map-api")
api project(":skin:mogo-skin-support")
implementation project(':modules:mogo-module-data')
}
}

View File

@@ -1,5 +1,6 @@
package com.mogo.service.warning
import com.mogo.module.data.enums.WarningDirectionEnum
import com.mogo.service.module.IMogoModuleProvider
/**
@@ -73,4 +74,19 @@ interface IMoGoWaringProvider : IMogoModuleProvider {
* 关闭限速预警
*/
fun disableLimitingVelocity()
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
*/
fun showWarning(direction: WarningDirectionEnum)
/**
* 展示指定方位上的红框预警
* @param direction
* @see WarningDirectionEnum
* @param closeTime 倒计时
*/
fun showWarning(direction: WarningDirectionEnum, closeTime: Long)
}

View File

@@ -64,3 +64,4 @@ include ':OCH:mogo-och-noop'
include ':OCH:mogo-och'
include ':modules:mogo-module-obu-mogo'
include ':modules:mogo-module-hmi'
include ':modules:mogo-module-data'