[6.4.0][启动自驾指引] 添加是否可启自驾的状态监听
This commit is contained in:
@@ -70,6 +70,21 @@ object CallerAutoPilotControlManager {
|
||||
* @param controlParameters 开启自动驾驶的控制参数
|
||||
*/
|
||||
fun startAutoPilot(controlParameters: AutopilotControlParameters?) {
|
||||
if (controlParameters == null) {
|
||||
//LogUtils.eTag(TAG, "自动驾驶控制参数异常,请检查参数信息")
|
||||
return
|
||||
}
|
||||
providerApi?.startAutoPilot(controlParameters)
|
||||
// 更新记录在全局的控制参数
|
||||
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(controlParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
* 启自驾前,是否要拦截
|
||||
* @param isShowTip true: 展示Toast+语音提示; false:不展示Toast+语音提示
|
||||
*
|
||||
*/
|
||||
fun isCanStartAutopilot(isShowTip: Boolean): Boolean {
|
||||
/**
|
||||
* 方向盘: 1<<0
|
||||
* 油门 : 1<<1
|
||||
@@ -80,49 +95,52 @@ object CallerAutoPilotControlManager {
|
||||
*/
|
||||
val exceptionValue = CallerDevaToolsManager.getExceptionStatusBeforeLaunchAutopilot()
|
||||
if (exceptionValue != 0) {
|
||||
val sb = StringBuilder("请检查车辆")
|
||||
if ((exceptionValue and 1) != 0) {
|
||||
sb.append("方向盘$")
|
||||
}
|
||||
if (((exceptionValue and (1 shl 1)) != 0)) {
|
||||
sb.append("油门$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 2)) != 0) {
|
||||
sb.append("刹车$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 3)) != 0) {
|
||||
sb.append("双闪$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 4)) != 0) {
|
||||
sb.append("档位$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 5)) != 0 || ((exceptionValue and (1 shl 6)) != 0)) {
|
||||
sb.setLength(0)
|
||||
sb.append("轨迹未就绪,请稍后重试")
|
||||
}
|
||||
val voiceText = sb.toString().let { str ->
|
||||
val count = str.count { it == '$' }
|
||||
if (count == 1) {
|
||||
str.replace("$", "")
|
||||
} else {
|
||||
str.removeSuffix("$").replace("$", "、")
|
||||
if (isShowTip) {
|
||||
val sb = StringBuilder("请检查车辆")
|
||||
if ((exceptionValue and 1) != 0) {
|
||||
sb.append("方向盘$")
|
||||
}
|
||||
if (((exceptionValue and (1 shl 1)) != 0)) {
|
||||
sb.append("油门$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 2)) != 0) {
|
||||
sb.append("刹车$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 3)) != 0) {
|
||||
sb.append("双闪$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 4)) != 0) {
|
||||
sb.append("档位$")
|
||||
}
|
||||
if ((exceptionValue and (1 shl 5)) != 0 || ((exceptionValue and (1 shl 6)) != 0)) {
|
||||
sb.setLength(0)
|
||||
sb.append("轨迹未就绪,请稍后重试")
|
||||
}
|
||||
val voiceText = sb.toString().let { str ->
|
||||
val count = str.count { it == '$' }
|
||||
if (count == 1) {
|
||||
str.replace("$", "")
|
||||
} else {
|
||||
str.removeSuffix("$").replace("$", "、")
|
||||
}
|
||||
}
|
||||
Logger.d(TAG, "voiceText: $voiceText")
|
||||
ToastUtils.showShort(voiceText)
|
||||
AppStateManager.currentActivity()?.also {
|
||||
AIAssist.getInstance(it).speakTTSVoice(voiceText)
|
||||
}
|
||||
}
|
||||
Logger.d(TAG, "voiceText: $voiceText")
|
||||
ToastUtils.showShort(voiceText)
|
||||
AppStateManager.currentActivity()?.also {
|
||||
AIAssist.getInstance(it).speakTTSVoice(voiceText)
|
||||
}
|
||||
return
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
if (controlParameters == null) {
|
||||
//LogUtils.eTag(TAG, "自动驾驶控制参数异常,请检查参数信息")
|
||||
return
|
||||
}
|
||||
providerApi?.startAutoPilot(controlParameters)
|
||||
// 更新记录在全局的控制参数
|
||||
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(controlParameters)
|
||||
fun addStartAutopilotStateListener(tag: String, listener: (Boolean) -> Unit) {
|
||||
CallerDevaToolsManager.registerStartAutopilotStateListener(tag, listener)
|
||||
}
|
||||
|
||||
fun removeStartAutopilotStateListener(tag: String) {
|
||||
CallerDevaToolsManager.unRegisterStartAutopilotStateListener(tag)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -367,4 +367,12 @@ object CallerDevaToolsManager {
|
||||
fun getExceptionStatusBeforeLaunchAutopilot(): Int {
|
||||
return devaToolsProviderApi?.getExceptionStatusBeforeLaunchAutopilot() ?: 0
|
||||
}
|
||||
|
||||
fun registerStartAutopilotStateListener(tag: String, block: (isCanStartAutopilot: Boolean) -> Unit) {
|
||||
devaToolsProviderApi?.registerStartAutopilotStateListener(tag, block)
|
||||
}
|
||||
|
||||
fun unRegisterStartAutopilotStateListener(tag: String) {
|
||||
devaToolsProviderApi?.unRegisterStartAutopilotStateListener(tag)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user