[610][adas]添加能否启动平行驾驶接口,修改类型名

This commit is contained in:
xinfengkun
2023-09-15 11:35:00 +08:00
parent f7d5462bed
commit ddd9897152
22 changed files with 450 additions and 84 deletions

View File

@@ -58,7 +58,7 @@ import com.zhjt.mogo.adas.data.bean.AdasParam
import com.zhidao.support.adas.high.common.ProtocolStatus
import com.zhjt.mogo.adas.data.AiCloudTask
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.sweeper.bootable.SweeperBootable
import com.zhjt.mogo.adas.data.sweeper.task.SweeperTask
import com.zhjt.mogo.adas.data.sweeper.task.s_r.SweeperTaskSuspendResume
@@ -885,7 +885,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
*/
override fun onAutopilotAbility(
isAutopilotAbility: Boolean,
unableAutopilotReasons: ArrayList<UnableAutopilotReason>?
unableAutopilotReasons: ArrayList<UnableLaunchReason>?
) {
if (unableAutopilotReasons != null && unableAutopilotReasons.size > 0) {
autopilotAbilityCheck(isAutopilotAbility, unableAutopilotReasons.toString())
@@ -893,6 +893,16 @@ class MoGoAdasListenerImpl : OnAdasListener {
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReasons)
}
override fun onParallelDrivingAbility(
isParallelDrivingAbility: Boolean,
unableParallelDrivingReasons: java.util.ArrayList<UnableLaunchReason>?
) {
CallerParallelDrivingActionsListenerManager.invokeParallelDrivingAbility(
isParallelDrivingAbility,
unableParallelDrivingReasons
)
}
@ChainLog(
linkChainLog = CHAIN_TYPE_SOCKET_AUTOPILOT,
linkCode = CHAIN_SOURCE_ADAS,

View File

@@ -9,6 +9,7 @@ import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
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.CallerAutopilotActionsListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerParallelDrivingActionsListenerManager
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
@@ -39,10 +40,12 @@ class MoGoAdasMsgConnectStatusListenerImpl :
init {
CallerCloudListenerManager.addListener(TAG, this)
CallerAutopilotActionsListenerManager.setConnected(AdasManager.getInstance().ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED)
CallerParallelDrivingActionsListenerManager.setConnected(AdasManager.getInstance().ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED)
}
override fun onConnectionIPCStatus(ipcConnectionStatus: Int, reason: String?) {
CallerAutopilotActionsListenerManager.setConnected(ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED)
CallerParallelDrivingActionsListenerManager.setConnected(ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED)
AppConfigInfo.connectStatusDescribe = reason
when (ipcConnectionStatus) {
Constants.IPC_CONNECTION_STATUS.CONNECTED -> {

View File

@@ -21,8 +21,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerParallelDrivingListener
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason.SourceType
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.SourceType
import mogo.yycp.paralleldriving.protocol.ParallelDrivingRequest.ParallelRequest
import mogo.yycp.paralleldriving.protocol.ParallelTaskProcessNoticeOuterClass
@@ -121,7 +121,7 @@ class ParallelDriveView @JvmOverloads constructor(
override fun onAutopilotAbility(
isAutopilotAbility: Boolean,
unableAutopilotReasons: ArrayList<UnableAutopilotReason>?
unableAutopilotReasons: ArrayList<UnableLaunchReason>?
) {
// 是否可平行驾驶
val isAvailable = isAvailable(unableAutopilotReasons)
@@ -173,7 +173,7 @@ class ParallelDriveView @JvmOverloads constructor(
}
}
private fun isAvailable(unableAutopilotReasons: ArrayList<UnableAutopilotReason>?): Boolean {
private fun isAvailable(unableAutopilotReasons: ArrayList<UnableLaunchReason>?): Boolean {
var unavailable = false
unableAutopilotReasons?.forEach {
if (it.source.ordinal == SourceType.CHASSIS.ordinal) {

View File

@@ -1,6 +1,6 @@
package com.mogo.eagle.core.function.api.autopilot
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
/**
@@ -11,5 +11,5 @@ interface IMoGoAutopilotActionsListener {
/**
* pnc actions 决策 驾驶的意图
*/
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?)
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableLaunchReason>?)
}

View File

@@ -0,0 +1,13 @@
package com.mogo.eagle.core.function.api.autopilot
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
/**
* 平行驾驶能力 能否启动平行驾驶
*/
interface IMoGoParallelDrivingActionsListener {
fun onParallelDrivingAbility(isParallelDrivingAbility: Boolean, unableParallelDrivingReasons: ArrayList<UnableLaunchReason>?)
}

View File

@@ -2,7 +2,7 @@ package com.mogo.eagle.core.function.call.autopilot
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
import com.mogo.eagle.core.function.call.base.CallerBase
import com.zhjt.mogo.adas.data.bean.UnableAutopilotReason
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
/**
@@ -12,7 +12,7 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
@Volatile
private var isConnected = false
private var isAutopilotAbility: Boolean = false
private var unableAutopilotReasons: ArrayList<UnableAutopilotReason>? = null
private var unableAutopilotReasons: ArrayList<UnableLaunchReason>? = null
init {
isAutopilotAbility = false
@@ -20,9 +20,14 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
// printLog("初始化")
}
private fun disconnectedReason(): ArrayList<UnableAutopilotReason> {
val list = ArrayList<UnableAutopilotReason>()
list.add(UnableAutopilotReason(UnableAutopilotReason.SourceType.LIB, "未连接自动驾驶系统"))
private fun disconnectedReason(): ArrayList<UnableLaunchReason> {
val list = ArrayList<UnableLaunchReason>()
list.add(
UnableLaunchReason(
UnableLaunchReason.SourceType.LIB,
"未连接自动驾驶系统"
)
)
return list
}
@@ -37,7 +42,7 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
* 获取不能启动自驾的原因
* null表示没有任何原因证证明isAutopilotAbility为true
*/
fun getUnableAutopilotReasons(): ArrayList<UnableAutopilotReason>? {
fun getUnableAutopilotReasons(): ArrayList<UnableLaunchReason>? {
return unableAutopilotReasons
}
@@ -53,15 +58,15 @@ object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsL
@Synchronized
fun invokeAutopilotAbility(
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableAutopilotReason>?
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableLaunchReason>?
) {
if (isConnected) {
var isEquals: Boolean = true
if (unableAutopilotReasons != null && this.unableAutopilotReasons != null) {
unableAutopilotReasons.let { onw ->
onw.sortWith(compareBy(UnableAutopilotReason::hashCode));
onw.sortWith(compareBy(UnableLaunchReason::hashCode));
this.unableAutopilotReasons?.let { old ->
old.sortWith(compareBy(UnableAutopilotReason::hashCode));
old.sortWith(compareBy(UnableLaunchReason::hashCode));
isEquals = onw.toTypedArray() contentEquals old.toTypedArray()
// Log.i(
// "ddd",

View File

@@ -0,0 +1,99 @@
package com.mogo.eagle.core.function.call.autopilot
import android.util.Log
import com.mogo.eagle.core.function.api.autopilot.IMoGoParallelDrivingActionsListener
import com.mogo.eagle.core.function.call.base.CallerBase
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
/**
* 是否可以启动平行驾驶管理
*/
object CallerParallelDrivingActionsListenerManager :
CallerBase<IMoGoParallelDrivingActionsListener>() {
@Volatile
private var isConnected = false
private var isParallelDrivingAbility: Boolean = false
private var unableParallelDrivingReasons: ArrayList<UnableLaunchReason>? = null
init {
isParallelDrivingAbility = false
unableParallelDrivingReasons = disconnectedReason()
}
private fun disconnectedReason(): ArrayList<UnableLaunchReason> {
val list = ArrayList<UnableLaunchReason>()
list.add(
UnableLaunchReason(
UnableLaunchReason.SourceType.LIB,
"未连接自动驾驶系统"
)
)
return list
}
/**
* 能否启动平行驾驶
*/
fun isParallelDrivingAbility(): Boolean {
return isParallelDrivingAbility
}
/**
* 获取不能启动平行驾驶的原因
* null表示没有任何原因证证明isParallelDrivingAbility为true
*/
fun getUnableParallelDrivingReasons(): ArrayList<UnableLaunchReason>? {
return unableParallelDrivingReasons
}
fun setConnected(isConnected: Boolean) {
if (this.isConnected != isConnected) {
this.isConnected = isConnected
this.isParallelDrivingAbility = isConnected
unableParallelDrivingReasons = if (isConnected) null else disconnectedReason()
notification()
}
}
@Synchronized
fun invokeParallelDrivingAbility(
isAutopilotAbility: Boolean, unableAutopilotReasons: ArrayList<UnableLaunchReason>?
) {
if (isConnected) {
var isEquals: Boolean = true
if (unableAutopilotReasons != null && this.unableParallelDrivingReasons != null) {
unableAutopilotReasons.let { onw ->
onw.sortWith(compareBy(UnableLaunchReason::hashCode));
this.unableParallelDrivingReasons?.let { old ->
old.sortWith(compareBy(UnableLaunchReason::hashCode));
isEquals = onw.toTypedArray() contentEquals old.toTypedArray()
}
}
} else isEquals =
!(unableAutopilotReasons != null || this.unableParallelDrivingReasons != null)
if (this.isParallelDrivingAbility != isAutopilotAbility || !isEquals) {
this.isParallelDrivingAbility = isAutopilotAbility
this.unableParallelDrivingReasons = unableAutopilotReasons
notification()
}
}
}
private fun notification() {
Log.i(
"xfk",
"是否可以启动平行驾驶=" + isParallelDrivingAbility + if (unableParallelDrivingReasons == null) "" else unableParallelDrivingReasons.toString()
)
M_LISTENERS.forEach {
val listener = it.value
listener.onParallelDrivingAbility(
isParallelDrivingAbility,
unableParallelDrivingReasons
)
}
}
}