From 1d883c20d5242757f809a5e6e235265c15f721d2 Mon Sep 17 00:00:00 2001 From: xuxinchao Date: Fri, 15 Sep 2023 11:41:56 +0800 Subject: [PATCH] =?UTF-8?q?[6.1.0]=E8=BF=90=E8=90=A5=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/hmi/ui/setting/SOPSettingView.kt | 127 +++++++++++++++--- .../src/main/res/layout/view_sop_setting.xml | 117 +++++++++++++++- 2 files changed, 222 insertions(+), 22 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt index e065153e6e..9f9700b99f 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt @@ -4,6 +4,7 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.view.View +import android.widget.Toast import androidx.constraintlayout.widget.ConstraintLayout import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.config.HmiBuildConfig @@ -28,6 +29,7 @@ import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager import com.mogo.eagle.core.function.hmi.ui.utils.HmiActionLog.Companion.hmiAction import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.util.ThreadUtils +import com.mogo.eagle.core.utilcode.util.ToastUtils import com.zhjt.mogo.adas.data.AdasConstants import com.zhjt.mogo.adas.data.bean.AdasParam import kotlinx.android.synthetic.main.view_sop_setting.view.* @@ -338,6 +340,91 @@ internal class SOPSettingView @JvmOverloads constructor( hmiAction("SOP 是否展示被动触发的录包弹窗, ",isChecked) } + //变道绕障的目标障碍物速度阈值 + tvSpeed.text = "${FunctionBuildConfig.detouringSpeed} m/s" + ivSpeedReduce.setOnClickListener { + if (FunctionBuildConfig.detouringSpeed <= 3) { + ToastUtils.showShort("阈值最小可为3 m/s") + } else { + FunctionBuildConfig.detouringSpeed-- + tvSpeed.text = "${FunctionBuildConfig.detouringSpeed} m/s" + } + hmiAction("SOP 变道绕障的目标障碍物速度阈值",FunctionBuildConfig.detouringSpeed) + } + ivSpeedAdd.setOnClickListener { + if (FunctionBuildConfig.detouringSpeed >= 7) { + ToastUtils.showShort("阈值最大可为7 m/s") + } else { + FunctionBuildConfig.detouringSpeed++ + tvSpeed.text = "${FunctionBuildConfig.detouringSpeed} m/s" + } + hmiAction("SOP 变道绕障的目标障碍物速度阈值",FunctionBuildConfig.detouringSpeed) + } + btnSpeedSet.setOnClickListener { + val isSuccess = + CallerAutoPilotControlManager.sendDetouringSpeed(FunctionBuildConfig.detouringSpeed.toDouble()) + if (isSuccess == true) { + ToastUtils.showShort("变道绕障的目标障碍物速度阈值设置成功") + hmiAction("SOP 变道绕障的目标障碍物速度阈值设置","成功") + } else { + ToastUtils.showShort("变道绕障的目标障碍物速度阈值设置失败") + hmiAction("SOP 变道绕障的目标障碍物速度阈值设置","失败") + } + } + + if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { + tvSpeedThresholdTitle.visibility = View.GONE + ivSpeedReduce.visibility = View.GONE + tvSpeed.visibility = View.GONE + ivSpeedAdd.visibility = View.GONE + btnSpeedSet.visibility = View.GONE + } + + /** + * 魔方sop运营相关配置 + */ + if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) { + val mf = CallerDevaToolsManager.mofang() + if (mf != null) { + mfStatusLayout.setClickEnabled(true) + mfStatusLayout.setClickedTextAndTag(if (mf.isConnected()) "断开魔方连接" else "开始连接魔方", if (mf.isConnected()) 0 else 1) + mf.registerMoFangStatusListener(TAG, this) + mfStatusLayout.setOnClickCallback { + val tag = it.tag as? Int + if (tag == 0) { + //断开魔方连接 + if (!mf.isConnected()) { + Toast.makeText(context, "尚未建立连接", Toast.LENGTH_SHORT).show() + return@setOnClickCallback + } + mfStatusLayout.showLoadingView() + mfStatusLayout.setLoadingViewText("正在断开魔方连接, 请稍候...") + mf.disconnect() + } + if (tag == 1) { + //建立魔方连接 + if (mf.isConnected()) { + Toast.makeText(context, "已连接,不要重复连接", Toast.LENGTH_SHORT).show() + return@setOnClickCallback + } + mf.connect() + mfStatusLayout.showLoadingView() + mfStatusLayout.setLoadingViewText("正在连接魔方, 请稍候") + } + } + } + + mfTest.isEnabled = mf?.isConnected() ?: false + mfTest.isChecked = mf?.isEnableTest() ?: false + mfTest.setOnCheckedChangeListener { _, isChecked -> + mf?.enableTest(isChecked) + } + } else { + mfStatusLayout.setClickEnabled(false) + mfTest.isEnabled = false + } + + } @@ -393,34 +480,34 @@ internal class SOPSettingView @JvmOverloads constructor( scRainMode.visibility = View.VISIBLE } } - -// FuncBizConfig.BIZ_PNC_WARNING -> { -// tbMarkingObstacles.isClickable = !lock -// if (lock) { -// tbMarkingObstacles.visibility = View.INVISIBLE -// } else { -// tbMarkingObstacles.visibility = View.VISIBLE -// } -// } + //危险障碍物颜色标记 + FuncBizConfig.BIZ_PNC_WARNING -> { + scMarkingObstacles.isClickable = !lock + if (lock) { + scMarkingObstacles.visibility = View.INVISIBLE + } else { + scMarkingObstacles.visibility = View.VISIBLE + } + } } } override fun onMoFangConnected() { -// mfStatusLayout?.also { -// it.hideLoadingView() -// it.setClickedTextAndTag("断开魔方连接", 0) -// mfTest?.isEnabled = true -// mfTest?.isChecked = CallerDevaToolsManager.mofang()?.isEnableTest() ?: false -// } + mfStatusLayout?.also { + it.hideLoadingView() + it.setClickedTextAndTag("断开魔方连接", 0) + mfTest?.isEnabled = true + mfTest?.isChecked = CallerDevaToolsManager.mofang()?.isEnableTest() ?: false + } } override fun onMoFangDisconnected() { -// mfStatusLayout?.also { -// it.hideLoadingView() -// it.setClickedTextAndTag("开始连接魔方", 1) -// mfTest?.isEnabled = false -// } + mfStatusLayout?.also { + it.hideLoadingView() + it.setClickedTextAndTag("开始连接魔方", 1) + mfTest?.isEnabled = false + } } override fun onMoFangBatteryChanged(battery: Int) { diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml index c1d928aff4..eb00657456 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_sop_setting.xml @@ -1,5 +1,5 @@ - + + + + + + + + + + + + +