[code_opt_3.3.0] split autopilot status and param

This commit is contained in:
zhongchao
2023-06-12 14:08:23 +08:00
parent df55cd543b
commit ef689a9685
36 changed files with 742 additions and 783 deletions

View File

@@ -19,14 +19,12 @@ import androidx.core.content.ContextCompat
import androidx.core.view.*
import androidx.lifecycle.lifecycleScope
import chassis.Chassis
import chassis.ChassisStatesOuterClass
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.constants.SharedPrefsConstants
import com.mogo.commons.debug.DebugConfig
import com.mogo.commons.module.status.MogoStatusManager
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.config.HmiBuildConfig
import com.mogo.eagle.core.data.constants.MoGoConfig
@@ -82,7 +80,6 @@ import kotlinx.android.synthetic.main.view_debug_setting.view.tbRouteDynamicEffe
import kotlinx.coroutines.*
import mogo.telematics.pad.MessagePad
import mogo_msg.MogoReportMsg
import planning.RoboSweeperTaskIndexOuterClass
import java.text.SimpleDateFormat
import java.util.*
import kotlin.collections.component1
@@ -126,8 +123,6 @@ internal class DebugSettingView @JvmOverloads constructor(
private var logInfoView: LogInfoView? = null
private var logViewAttach = false
@Volatile
private var mAutoPilotStatusInfo: AutopilotStatusInfo? = null
private var mGnssInfo: MogoLocation? = null
private var accelerationFloatWindow: AccelerationFloatWindow? = null
@@ -932,7 +927,7 @@ internal class DebugSettingView @JvmOverloads constructor(
clipboardManager?.setPrimaryClip(
ClipData.newPlainText(
"DockVersion",
mAutoPilotStatusInfo?.dockVersion
CallerAutoPilotStatusListenerManager.getDockerVersion()?:""
)
)
ToastUtils.showLong("docker版本复制成功")
@@ -1090,13 +1085,8 @@ internal class DebugSettingView @JvmOverloads constructor(
/**
* 设置域控制器点击监听
*/
@SuppressLint("SetTextI18n")
private fun setDomainControllerCheckedChangeListener() {
// 初始化工控机 IP信息
val autoPilotIpAddress =
SharedPrefsMgr.getInstance(context)
.getString(MoGoConfig.AUTOPILOT_IP, FunctionBuildConfig.adasConnectIP)
etAutopilotIP.setText("192.168.1.")
etAutopilotIP.text?.let { etAutopilotIP.setSelection(it.length) }
//设置工控机IP
@@ -1586,8 +1576,9 @@ internal class DebugSettingView @JvmOverloads constructor(
} else {
tvIpcProtocolVersionInfo.text = "工控机协议版本:${AppConfigInfo.protocolVersionNumber}"
}
tvIpcVersionInfo.text = "MAP${mAutoPilotStatusInfo?.dockVersion}"
tvIpcVersionInfoKey.text = "MAP${mAutoPilotStatusInfo?.dockVersion}"
val dockerVersion = CallerAutoPilotStatusListenerManager.getDockerVersion()
tvIpcVersionInfo.text = "MAP$dockerVersion"
tvIpcVersionInfoKey.text = "MAP$dockerVersion"
tvMoGoMapVersion.text = "HD-Map版本${DebugConfig.getMapVersion()}"
tvMoGoMapVersionKey.text = "HD-Map版本${DebugConfig.getMapVersion()}"
tvGitBranchInfo.text = "Git分支${AppConfigInfo.workingBranchName}"
@@ -1658,12 +1649,7 @@ internal class DebugSettingView @JvmOverloads constructor(
"司机端Server启动"
}
else -> {
"乘客端${
when {
!AppConfigInfo.serverSn.isNullOrEmpty() -> "(司机屏SN是:${AppConfigInfo.serverSn?:""})"
else -> ""
}
}连接"
"乘客端${"(司机屏SN是:${AppConfigInfo.serverSn})"}连接"
}
}
}是否正常${
@@ -1696,11 +1682,10 @@ internal class DebugSettingView @JvmOverloads constructor(
}"
)
mAutoPilotStatusInfo?.let {
val autopilotJson = GsonUtils.toJson(it)
tvAutopilotInfo.text = autopilotJson
tvIpcInfo.text = autopilotJson
tvIpcInfoKey.text = autopilotJson
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfoJsonString().let {
tvAutopilotInfo.text = it
tvIpcInfo.text = it
tvIpcInfoKey.text = it
}
tvCmdbCarInfoContent.text = SharedPrefsMgr.getInstance(context).getString(SharedPrefsConstants.CAR_INFO)?:""
@@ -1780,8 +1765,7 @@ internal class DebugSettingView @JvmOverloads constructor(
/**
* 自动驾驶状态回调
*/
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
mAutoPilotStatusInfo = autoPilotStatusInfo
override fun onAutopilotStatusResponse(state: Int) {
setAutopilotConnectStatus()
}

View File

@@ -11,11 +11,9 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.deva.bindingcar.IPCUpgradeStateInfo
import com.mogo.eagle.core.data.temp.EventLogout
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager
@@ -44,7 +42,7 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor(
context,
attrs,
defStyleAttr
), IMoGoAutopilotStatusListener {
) {
companion object{
private const val TAG = "AutoPilotAndCheckView"
@@ -52,8 +50,6 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor(
private var clickListener: ClickListener? = null
private var keyBoardUtil: KeyBoardUtil? = null
@Volatile
private var connectStatus = false
private var lastTime = 0L
init {
@@ -174,7 +170,7 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor(
svLayout.post {
svLayout.fullScroll(View.FOCUS_DOWN)
}
if (!connectStatus) { //todo 单次获取
if (!CallerAutoPilotStatusListenerManager.getConnectStates()) {
ToastUtils.showShort("设置车速失败,请启动域控制器")
keyBoardUtil?.hideKeyboard()
return@setOnTouchListener true
@@ -267,20 +263,14 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor(
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
CallerAutopilotCarConfigListenerManager.addListener(TAG, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerAutoPilotStatusListenerManager.removeListener(TAG)
CallerAutopilotCarConfigListenerManager.removeListener(TAG)
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
connectStatus = autoPilotStatusInfo.connectStatus
}
interface ClickListener {
fun onClose(v: View)
fun showDebugPanelView()

View File

@@ -6,13 +6,12 @@ import android.util.TypedValue.COMPLEX_UNIT_PX
import android.view.LayoutInflater
import androidx.appcompat.content.res.AppCompatResources
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.autopilot.pnc.PncActionsHelper
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.BIZ_PNC_ACTIONS
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.FOUNDATION
import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult
import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight
import com.mogo.eagle.core.data.biz.trafficlight.isRed
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.BIZ_PNC_ACTIONS
import com.mogo.eagle.core.data.deva.bizconfig.FuncBizConfig.Companion.FOUNDATION
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningActionsListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener.Companion.STATUS_AUTOPILOT_RUNNING
@@ -40,9 +39,6 @@ class PncActionsView @JvmOverloads constructor(
@Volatile
private var mTrafficLightResult: TrafficLightResult? = null
@Volatile
private var mAutoPilotStatusInfo: AutopilotStatusInfo? = null
private val bgResources: Int
private val topMargin: Float
private val txtSize: Float
@@ -68,7 +64,7 @@ class PncActionsView @JvmOverloads constructor(
override fun onAttachedToWindow() {
super.onAttachedToWindow()
(tvHmiPncActions.layoutParams as MarginLayoutParams).topMargin = topMargin.toInt()
tvHmiPncActions.setTextSize(COMPLEX_UNIT_PX, txtSize.toFloat())
tvHmiPncActions.setTextSize(COMPLEX_UNIT_PX, txtSize)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
CallerPlanningActionsListenerManager.addListener(TAG, this)
@@ -82,10 +78,8 @@ class PncActionsView @JvmOverloads constructor(
CallerTrafficLightListenerManager.removeListener(TAG)
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
super.onAutopilotStatusResponse(autoPilotStatusInfo)
mAutoPilotStatusInfo = autoPilotStatusInfo
if (mAutoPilotStatusInfo!!.state != STATUS_AUTOPILOT_RUNNING) {
override fun onAutopilotStatusResponse(state: Int) {
if (state != STATUS_AUTOPILOT_RUNNING) {
UiThreadHandler.post {
this.background = null
tvHmiPncActions.text = ""
@@ -96,45 +90,43 @@ class PncActionsView @JvmOverloads constructor(
@BizConfig(FOUNDATION, "", BIZ_PNC_ACTIONS)
override fun pncActions(planningActionMsg: MessagePad.PlanningActionMsg) {
try {
mAutoPilotStatusInfo?.let {
UiThreadHandler.post {
if (it.state == STATUS_AUTOPILOT_RUNNING) {
var actions: String? = null
planningActionMsg.actionMsg?.let { it ->
try {
actions = PncActionsHelper.getAction(
it.drivingState.number,
it.drivingAction.number
)
} catch (e: Exception) {
e.printStackTrace()
}
//如果是存在云端红绿灯数据条件下,设置云端数据
if (PncActionsHelper.isWaitingTrafficlight(
it.drivingState.number,
it.drivingAction.number
)
&& mTrafficLightResult != null
&& getWaitTrafficLightTime().isNotBlank()
) {
actions += ",预计${getWaitTrafficLightTime()}秒后通过"
} else {
mTrafficLightResult = null
}
UiThreadHandler.post {
if (CallerAutoPilotStatusListenerManager.getState() == STATUS_AUTOPILOT_RUNNING) {
var actions: String? = null
planningActionMsg.actionMsg?.let { it ->
try {
actions = PncActionsHelper.getAction(
it.drivingState.number,
it.drivingAction.number
)
} catch (e: Exception) {
e.printStackTrace()
}
// update view
if (actions.isNullOrEmpty()) {
this.background = null
tvHmiPncActions.text = ""
//如果是存在云端红绿灯数据条件下,设置云端数据
if (PncActionsHelper.isWaitingTrafficlight(
it.drivingState.number,
it.drivingAction.number
)
&& mTrafficLightResult != null
&& getWaitTrafficLightTime().isNotBlank()
) {
actions += ",预计${getWaitTrafficLightTime()}秒后通过"
} else {
this.background =
AppCompatResources.getDrawable(context, bgResources)
tvHmiPncActions.text = actions
mTrafficLightResult = null
}
} else {
}
// update view
if (actions.isNullOrEmpty()) {
this.background = null
tvHmiPncActions.text = ""
} else {
this.background =
AppCompatResources.getDrawable(context, bgResources)
tvHmiPncActions.text = actions
}
} else {
this.background = null
tvHmiPncActions.text = ""
}
}
} catch (e: Exception) {

View File

@@ -6,7 +6,6 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
import com.mogo.eagle.core.data.msgbox.MsgBoxBean
@@ -16,7 +15,6 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.ThreadUtils
@@ -33,31 +31,22 @@ class TakeOverView @JvmOverloads constructor(
const val TAG = "TakeOverView"
}
private var autopilotStatus: Int = 0 //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中,7:平行驾驶中
private var isParallel: Boolean = false //是否是平行驾驶
init {
LayoutInflater.from(context).inflate(R.layout.view_take_over, this, true)
}
private var takeOver = false
private var isParallel: Boolean = false //是否是平行驾驶
override fun onAttachedToWindow() {
super.onAttachedToWindow()
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
}
/**
* 自动驾驶状态信息
*
* @param autoPilotStatusInfo 状态信息
*/
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
autopilotStatus = autoPilotStatusInfo.state
if(autoPilotStatusInfo.state == 7){
override fun onAutopilotStatusResponse(state: Int) {
if(state == 7){
isParallel = true
}else if(autoPilotStatusInfo.state == 0 || autoPilotStatusInfo.state == 1){
}else if(state == 0 || state == 1){
isParallel = false
}
}

View File

@@ -6,7 +6,6 @@ import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
@@ -37,7 +36,7 @@ class AutoPilotStatusView constructor(
private var mAutopilotStatus: Int = 0
init{
init {
initView(context)
}
@@ -119,8 +118,8 @@ class AutoPilotStatusView constructor(
}
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
setAutoPilotStatus(autoPilotStatusInfo.state)
override fun onAutopilotStatusResponse(state: Int) {
setAutoPilotStatus(state)
}
override fun onDetachedFromWindow() {

View File

@@ -6,7 +6,6 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_HMI
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
@@ -29,12 +28,7 @@ class CheckSystemView @JvmOverloads constructor(
const val TAG = "CheckSystemView"
}
@Volatile
private var connectStatus = false //是否连接工控机
@Volatile
private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中
private var dockerRebootDialog: DockerRebootDialog? = null
private var downloadStatus: String = "" //下载状态
private var upgradeStatus: String = "" //升级状态
@@ -54,7 +48,7 @@ class CheckSystemView @JvmOverloads constructor(
dockerRebootDialog = DockerRebootDialog(context)
dockerRebootDialog?.setClickListener(object : DockerRebootDialog.ClickListener {
override fun confirm() {
if (autopilotStatus == 2) {
if (CallerAutoPilotStatusListenerManager.getState() == 2) {
//当前处于自动驾驶状态不可进行重启Toast提示
ToastUtils.showShort("请先退出自动驾驶状态")
}
@@ -106,16 +100,15 @@ class CheckSystemView @JvmOverloads constructor(
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
connectStatus = autoPilotStatusInfo.connectStatus //单次
autopilotStatus = autoPilotStatusInfo.state
override fun onAutopilotConnectInfo(connectInfo: Boolean) {
super.onAutopilotConnectInfo(connectInfo)
ThreadUtils.runOnUiThread {
setViewStatus()
setViewStatus(connectInfo)
}
}
private fun setViewStatus() {
if (connectStatus) {
private fun setViewStatus(connectInfo:Boolean) {
if (connectInfo) {
viewCheckShutDown.requestFocus()
viewCheckShutDown.isClickable = true
viewCheckReboot.requestFocus()
@@ -124,7 +117,6 @@ class CheckSystemView @JvmOverloads constructor(
viewCheckShutDown.isClickable = false
viewCheckReboot.isClickable = false
}
}
}

View File

@@ -94,9 +94,8 @@ class SteeringWheelView : ConstraintLayout, IMoGoChassisSteeringStateListener,
private val mGoAutopilotStatusListener: IMoGoAutopilotStatusListener =
object : IMoGoAutopilotStatusListener {
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
override fun onAutopilotStatusResponse(state: Int) {
ThreadUtils.runOnUiThread {
val state = autoPilotStatusInfo.state
d("$M_BUS_P$TAG", "state = %s", state)
if (autopilotIV != null) {
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {

View File

@@ -5,7 +5,6 @@ import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.deva.bindingcar.AdUpgradeStateHelper
import com.mogo.eagle.core.data.deva.bindingcar.IPCUpgradeStateInfo
import com.mogo.eagle.core.data.map.MogoLocation
@@ -44,8 +43,6 @@ class SystemVersionView @JvmOverloads constructor(
}
private var dockerVersion: String? = null //工控机版本
private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中
private var ipcUpgradeStateInfo: IPCUpgradeStateInfo?=null
private var needQueryContainers: Boolean = false
@@ -320,17 +317,9 @@ class SystemVersionView @JvmOverloads constructor(
needQueryContainers = false
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
dockerVersion = autoPilotStatusInfo.dockVersion
autopilotStatus = autoPilotStatusInfo.state
CallerLogger.i(
"$M_HMI$TAG",
"onAutopilotStatusResponse dockerVersion=$dockerVersion , autopilotStatus=$autopilotStatus"
)
setViewStatus()
}
private fun setViewStatus() {
override fun onAutopilotDockerInfo(dockerVersion: String) {
super.onAutopilotDockerInfo(dockerVersion)
this.dockerVersion = dockerVersion
showCurrentAdVersion()
}

View File

@@ -5,16 +5,12 @@ import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.main.AppListActivity
import com.mogo.eagle.core.utilcode.kotlin.*
import com.mogo.eagle.core.utilcode.util.ActivityUtils
import com.mogo.eagle.core.utilcode.util.AppUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import kotlinx.android.synthetic.main.view_version_name.view.*
import kotlinx.coroutines.*
@@ -89,11 +85,12 @@ class VersionNameView @JvmOverloads constructor(
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
dockerVersion = autoPilotStatusInfo.dockVersion
override fun onAutopilotDockerInfo(dockerVersion: String) {
super.onAutopilotDockerInfo(dockerVersion)
this.dockerVersion = dockerVersion
showCurrentMapVersion()
//将工控机版本赋值给BadCase配置常量
CallerDevaToolsManager.dockerVersion(autoPilotStatusInfo.dockVersion)
CallerDevaToolsManager.dockerVersion(dockerVersion)
}
}