调试窗修改

添加鹰眼参数配置—设置刹车加速度阈值
This commit is contained in:
xuxinchao
2022-03-29 19:43:48 +08:00
parent f7c48a6880
commit a2ce9b0b3c
5 changed files with 129 additions and 5 deletions

View File

@@ -57,7 +57,7 @@ class MoGoAutopilotProvider :
get() = TAG
override fun init(context: Context) {
MoGoHandAdasMsgManager.getInstance()
MoGoHandAdasMsgManager.getInstance(context)
CallerLogger.i("$M_ADAS_IMPL$TAG", "初始化工控机连接……")
mContext = context
// 初始化ADAS 域控制器

View File

@@ -1,9 +1,11 @@
package com.mogo.eagle.core.function.autopilot.adapter;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.constants.MoGoConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
@@ -13,6 +15,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateLi
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.module.common.drawer.IdentifyDataDrawer;
@@ -34,18 +37,20 @@ public class MoGoHandAdasMsgManager implements
private final String TAG = "AdasEventManager";
private static volatile MoGoHandAdasMsgManager moGoHandAdasMsgManager;
private Context mContext;
private MoGoHandAdasMsgManager() {
private MoGoHandAdasMsgManager(Context context) {
CallerAutopilotIdentifyListenerManager.INSTANCE.addListener(TAG, this);
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, this);
CallerAutopilotCarConfigListenerManager.INSTANCE.addListener(TAG, this);
mContext = context;
}
public static MoGoHandAdasMsgManager getInstance() {
public static MoGoHandAdasMsgManager getInstance(Context context) {
if (moGoHandAdasMsgManager == null) {
synchronized (MoGoHandAdasMsgManager.class) {
if (moGoHandAdasMsgManager == null) {
moGoHandAdasMsgManager = new MoGoHandAdasMsgManager();
moGoHandAdasMsgManager = new MoGoHandAdasMsgManager(context);
}
}
}
@@ -144,7 +149,7 @@ public class MoGoHandAdasMsgManager implements
@Override
public void onAutopilotBrakeLightByAcceleration(double acceleration) {
//设置刹车信息
if (acceleration < -2.5) {
if (acceleration < SharedPrefsMgr.getInstance(mContext).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD,-2.5F)) {
brakeLight = 1;
} else {
brakeLight = 0;

View File

@@ -257,6 +257,18 @@ class DebugSettingView @JvmOverloads constructor(
}
}
tbEagleEyeController.setOnCheckedChangeListener { buttonView, isChecked ->
if(isChecked){
buttonView.setCompoundDrawables(null, null, iconDown, null)
//展示参数配置
eagleEyeControllerLayout.visibility = View.VISIBLE
}else{
buttonView.setCompoundDrawables(null, null, iconRight, null)
//隐藏参数配置
eagleEyeControllerLayout.visibility = View.GONE
}
}
/**
* 域控制器
*/
@@ -388,6 +400,8 @@ class DebugSettingView @JvmOverloads constructor(
}
}
//设置鹰眼本地参数配置监听
setEagleEyeConfigListener()
//域控制器中心事件点击监听
setDomainControllerCheckedChangeListener()
//Hmi控制中心事件点击监听
@@ -500,6 +514,39 @@ class DebugSettingView @JvmOverloads constructor(
}
/**
* 设置鹰眼本地参数配置监听
*/
private fun setEagleEyeConfigListener(){
//初始化刹车加速度阈值信息
val brakeThreshold = SharedPrefsMgr.getInstance(context)
.getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD,-2.5F)
etInputBrakeThreshold.setText(brakeThreshold.toString())
etInputBrakeThreshold.text?.let { etInputBrakeThreshold.setSelection(brakeThreshold.toString().length) }
//设置刹车加速度阈值信息
btnBrakeThreshold.setOnClickListener {
val thresholdStr = etInputBrakeThreshold.text.toString()
if(thresholdStr.isNullOrEmpty()){
ToastUtils.showShort("请输入正确的判定刹车加速度阈值")
}else{
try{
val thresholdStrFloat = thresholdStr.toFloat()
if(thresholdStrFloat<0){
SharedPrefsMgr.getInstance(context).putFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD,thresholdStrFloat)
ToastUtils.showShort("刹车阈值设置成功")
}else{
ToastUtils.showShort("刹车阈值加速度值应小于0")
}
}catch (e: Exception){
ToastUtils.showShort("判定刹车加速度阈值格式设置不正确")
}
}
}
}
/**
* 设置域控制器点击监听
*/

View File

@@ -472,6 +472,75 @@
android:orientation="vertical"
android:visibility="gone">
<ToggleButton
android:id="@+id/tbEagleEyeController"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/dp_10"
android:background="@drawable/setting_toggle_button_background"
android:drawableEnd="@drawable/icon_right"
android:padding="@dimen/dp_20"
android:textOff="鹰眼参数配置"
android:textOn="鹰眼参数配置" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/eagleEyeControllerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<Button
android:id="@+id/btnBrakeThreshold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="@dimen/dp_5"
android:text="设置刹车加速度阈值"
android:textSize="@dimen/dp_24"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:paddingStart="@dimen/dp_20"
android:paddingEnd="@dimen/dp_20"
/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_10"
android:layout_marginEnd="@dimen/dp_30"
android:layout_marginBottom="@dimen/dp_10"
android:background="@drawable/debug_setting_edit_bg"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="@id/btnBrakeThreshold"
app:layout_constraintLeft_toRightOf="@id/btnBrakeThreshold"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/btnBrakeThreshold">
<androidx.appcompat.widget.AppCompatEditText
android:id="@+id/etInputBrakeThreshold"
style="@style/DebugSettingText"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="90px"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
tools:ignore="SpeakableTextPresentCheck" />
<TextView
style="@style/DebugSettingText"
android:layout_width="93px"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:text="m/s²" />
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.constraintlayout.widget.ConstraintLayout>
<ToggleButton
android:id="@+id/tbDomainController"
android:layout_width="match_parent"