[fea]
[shuttle 启动自驾功能]
This commit is contained in:
yangyakun
2024-09-20 13:16:15 +08:00
parent 0195b7616f
commit cd12408c50
154 changed files with 799 additions and 228 deletions

View File

@@ -371,14 +371,9 @@ public class OrderModel {
}
private final OchAdasStartFailureCallback mAdasStartFailureListener = new OchAdasStartFailureCallback() {
@Override
public void brakeStatusChanged(boolean isBrakeAvailable) {
}
@Override
public void onStartAutopilotFailure(@NotNull String startFailedCode, @NonNull String startFailedMessage) {
OchAutopilotAnalytics.INSTANCE.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage, System.currentTimeMillis());
if (mPassengerCallback != null && !FunctionBuildConfig.isDemoMode){
CallerLogger.e( M_BUS + TAG, "mAdasStartFailureListener = "+startFailedMessage );
mPassengerCallback.onStartAdasFailure();

View File

@@ -307,8 +307,6 @@ class DriverM1Model {
startFailedCode: String,
startFailedMessage: String
) {
OchAutopilotAnalytics
.triggerStartAutopilotFailureEventByAdas(startFailedCode, startFailedMessage,System.currentTimeMillis())
if (mControllerStatusCallback != null) {
d(SceneConstant.M_CHARTER_D + TAG,
@@ -316,9 +314,6 @@ class DriverM1Model {
mControllerStatusCallback?.onStartAdasFailure()
}
}
override fun brakeStatusChanged(isBrakeAvailable: Boolean) {
}
}
//监听网络变化,避免启动机器时无网导致无法更新订单信息

View File

@@ -7,6 +7,4 @@ package com.mogo.och.common.module.callback
interface OchAdasStartFailureCallback {
fun onStartAutopilotFailure(startFailedCode : String, startFailedMessage : String)
fun brakeStatusChanged(isBrakeAvailable: Boolean)
}

View File

@@ -10,9 +10,12 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerParallelDrivingActionsListenerManager;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
import com.mogo.eagle.core.utilcode.util.ParseVersionUtils;
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
import com.mogo.och.common.module.manager.autopilot.line.LineManager;
import com.zhjt.mogo.adas.data.bean.AutopilotStatistics;
import com.zhjt.mogo.adas.data.bean.LaunchConditionData;
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason;
@@ -123,7 +126,7 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
" onAutopilotAbility =" + unableAutopilotReasons.toString());
if (unableAutopilotReasons.toString().contains(UnableLaunchReason.SourceType.CHASSIS.name())
&& unableAutopilotReasons.toString().contains(UnableLaunchReason.UnableType.CHASSIS_BRAKE.name())) {
failureCallback.brakeStatusChanged(isAutopilotAbility);
//failureCallback.brakeStatusChanged(isAutopilotAbility);
}
}
@@ -136,6 +139,9 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
startFailedCode = statistics.failedMessage.getCode();
startFailedMessage = statistics.failedMessage.getMsg();
failureCallback.onStartAutopilotFailure(startFailedCode, startFailedMessage);
if(!AppIdentityModeUtils.isSweeper(FunctionBuildConfig.appIdentityMode)){
LineManager.invokeStartAutopilotFailure(startFailedCode, startFailedMessage);
}
Logger.d(TAG, String.format("statistics-startFailedCode = s%; startFailedMessage = s%",
startFailedCode, startFailedMessage));
}

View File

@@ -95,6 +95,7 @@ object OchAutoPilotManager : IMoGoReceiveReceivedAckListener, IMoGoFsm2024Listen
@JvmStatic
fun startAutoPilot(controlParameters: AutopilotControlParameters?): Long {
val sessionId = CallerAutoPilotControlManager.startAutoPilot(controlParameters)
LineManager.isReStartAutopilot = false
globalSessionId.set(sessionId)
fsmBackSessionId.set(-1L)
OchAutopilotAnalytics.triggerStartAutopilotParameters(controlParameters, sessionId)

View File

@@ -9,6 +9,7 @@ import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.common.module.R
import com.mogo.och.common.module.manager.autopilot.autopilot.bean.ArrivedStation
import com.mogo.och.common.module.manager.autopilot.line.LineManager
import com.mogo.och.common.module.manager.autopilot.trajectory.TrajectoryManager
import com.mogo.och.common.module.utils.CallerBase
import com.zhjt.mogo.adas.data.AdasConstants
@@ -25,7 +26,15 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
const val TAG = "OCHAutoPilotStatusListenerManager"
private var autopilotState: Int by Delegates.observable(0) { _, oldValue, newValue ->
private var canStartAutopilot:Boolean? by Delegates.observable(null) { _, oldValue, newValue ->
if (oldValue != newValue) {
M_LISTENERS.forEach {
val listener = it.value
listener.canStartAutopilot(newValue?:false)
}
}
}
private var _autopilotState: Int by Delegates.observable(0) { _, oldValue, newValue ->
if (oldValue != newValue) {
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
if(oldValue==IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING){
@@ -38,6 +47,9 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
}
}
}
if(newValue==IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
LineManager.triggerStartServiceEvent(true, 0)
}
M_LISTENERS.forEach {
val listener = it.value
@@ -45,12 +57,19 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
}
}
}
val autopilotState:Int
get() = _autopilotState
init {
//2021.11.1 鹰眼架构整合由IMoGoAutopilotStatusListener逐步替代IMogoAdasOCHCallback接口
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
CallerAutoPilotControlManager.addStartAutopilotStateListener(TAG,this)
}
override fun doSomeAfterAddListener(tag: String, listener: IOchAutopilotStatusListener) {
super.doSomeAfterAddListener(tag, listener)
listener.onAutopilotStatusResponse(_autopilotState)
}
override fun onAutopilotTrajectoryDownloadReq(
autoPilotLine: AutopilotControlParameters.AutoPilotLine,
downloadType: Int
@@ -63,7 +82,7 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
}
override fun onAutopilotStatusResponse(state: Int) {
autopilotState = state
_autopilotState = state
}
override fun onAutopilotDockerInfo(dockerVersion: String) {
@@ -172,10 +191,7 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
}
override fun invoke(canStartAutopilot: Boolean) {
M_LISTENERS.forEach {
val listener = it.value
listener.canStartAutopilot(canStartAutopilot)
}
this.canStartAutopilot = canStartAutopilot
}
override fun onAutopilotStatusResponseFromCan(state: Int) {
@@ -184,5 +200,10 @@ object OchAutoPilotStatusListenerManager : CallerBase<IOchAutopilotStatusListene
val listener = it.value
listener.onAutopilotStatusResponseFromCan(state)
}
when (state) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
LineManager.triggerStartServiceEvent(true,1)
}
}
}
}

View File

@@ -11,6 +11,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.DateTimeUtils
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager
import com.mogo.och.common.module.manager.autopilot.line.LineManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.manager.loop.BizLoopManager
@@ -58,7 +59,7 @@ object OchAutopilotAnalytics {
/**
* 正式把参数传给底层
* 正式启动自驾把参数传给底层
*/
fun triggerStartAutopilotParameters(controlParameters: AutopilotControlParameters?, sessionId: Long){
val params = HashMap<String, Any>()
@@ -115,6 +116,7 @@ object OchAutopilotAnalytics {
private val timeOutRunnable = Runnable {
// 15s内未开启上报失败埋点
triggerStartAutopilotFailureEvent("", "15s后app等待超时", System.currentTimeMillis())
LineManager.invokeStartAutopilotTimeOut()
}
/**

View File

@@ -6,4 +6,10 @@ public interface ILineCallback {
default void drawLineSuccess(){}
default void drawLineFail(){}
default void startAutopilotSuccess(){}
default void startAutopilotTimeOut(){}
default void startAutopilotFailure(String startFailedCode,String startFailedMessage){}
}

View File

@@ -1,18 +1,30 @@
package com.mogo.och.common.module.manager.autopilot.line
import android.text.TextUtils
import com.elegant.network.utils.GsonUtil
import com.mogo.commons.env.ProjectUtils
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLonLat
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLocation
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.map.CallerMapGlobalTrajectoryDrawManager
import com.mogo.eagle.core.function.call.order.CallerOrderListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
import com.mogo.eagle.core.utilcode.util.StringUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.startAutoPilot
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics
import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.utils.CallerBase
import com.mogo.och.common.module.voice.VoiceNotice
import com.mogo.och.data.bean.BusStationBean
import com.mogo.och.data.bean.ContraiInfo
import com.mogo.och.data.bean.LineInfo
@@ -45,10 +57,15 @@ object LineManager : CallerBase<ILineCallback>() {
*/
var endStation: BusStationBean? = null
var isReStartAutopilot = true
/**
* 设置站点信息
*/
fun setStartAndEndStation(startStation: BusStationBean?, endStation: BusStationBean?) {
if(this.startStation!=startStation||this.endStation!=endStation){
isReStartAutopilot = true
}
this.startStation = startStation
this.endStation = endStation
if(startStation==null||endStation==null){
@@ -167,10 +184,19 @@ object LineManager : CallerBase<ILineCallback>() {
}
d(M_BUS + TAG, "AutopilotControlParameters is update.")
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(parameters)
val startStationLocation = MogoLocation()
startStationLocation.latitude = start.gcjLat
startStationLocation.longitude = start.gcjLon
val endStationLocation = MogoLocation()
endStationLocation.latitude = end.gcjLat
endStationLocation.longitude = end.gcjLon
TrajectoryAndDistanceManager.setStationPoint(startStationLocation, endStationLocation, lineInfo.lineId)
}
}
private fun clearAutopilotControlParameters(){
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(null)
TrajectoryAndDistanceManager.setStationPoint(null, null, null)
}
fun hasDrawnGlobalTrajectory(): Boolean {
@@ -239,5 +265,116 @@ object LineManager : CallerBase<ILineCallback>() {
return parameters
}
// 启动自动驾驶
fun startAutopilot() {
/**
* 存在Session
*/
if (!OchAutoPilotManager.canStartAutopilotBySessionId()) {
return
}
OchAutopilotAnalytics.triggerClickStartAutopilotTime(System.currentTimeMillis())
//1、判断轨迹url是否可用
if(contraiInfo==null){
ToastUtils.showLong("无发布轨迹, 请发布后重试")
return
}else{
if (FunctionBuildConfig.isPassStartAutopilotCommand
&& TextUtils.isEmpty(contraiInfo!!.csvFileUrl)
&& TextUtils.isEmpty(contraiInfo!!.csvFileMd5)
) {
ToastUtils.showLong("无发布轨迹, 请发布后重试")
e(
TAG, "isPassStartAutopilotCommand = " +
FunctionBuildConfig.isPassStartAutopilotCommand
+ "busRoutesResult.csvFileUrl = " + LineManager.contraiInfo!!.csvFileUrl
)
return
}
}
//2、6个条件判断
if (!CallerAutoPilotControlManager.isCanStartAutopilot(true, 0)) {
return
}
// 3、距离轨迹15m计算
val resion = OchAutoPilotManager.canStartAutoPilotByDistance(contraiInfo!!.lineId)
if (!StringUtils.isEmpty(resion)) {
ToastUtils.showShort(resion)
VoiceNotice.showNotice(resion)
return
}
//4、ssm 给出数据
if (!OchAutoPilotManager.canStartAutoPilotSSM()) {
triggerUnableStartAPReasonEvent()
return
}
triggerStartServiceEvent(false,0)
val parameters = initAutopilotControlParameters()
if (null == parameters) {
e(M_BUS + TAG, "行程日志-AutopilotControlParameters is empty.")
return
}
val sessionId = startAutoPilot(parameters)
OchAutopilotAnalytics.triggerUpdateStartAutoPilotSessionId(sessionId)
d(
M_BUS + TAG,
"行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)
+ " startLatLon=" + parameters.startName + "endLatLon=" + parameters.endName +
"isRestart = " + LineManager.isReStartAutopilot
)
M_LISTENERS.forEach {
it.value.startAutopilotSuccess()
}
}
private fun triggerUnableStartAPReasonEvent() {
getStationsWithLine { start, end, line ->
OchAutopilotAnalytics.triggerUnableStartAPReasonEvent(
start.name, end.name,line.lineId.toString() , "",
OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason
)
}
}
fun triggerStartServiceEvent(send: Boolean,source:Int) {
getStations { start, end ->
OchAutopilotAnalytics.triggerStartAutopilotEvent(
isReStartAutopilot,
send,
start.name,
end.name,
lineInfos!!.lineId.toInt(),
"",
System.currentTimeMillis(),
source
)
}
}
@JvmStatic
fun invokeStartAutopilotTimeOut(){
M_LISTENERS.forEach {
it.value.startAutopilotTimeOut()
}
}
@JvmStatic
fun invokeStartAutopilotFailure(startFailedCode: String, startFailedMessage: String) {
OchAutopilotAnalytics.triggerStartAutopilotFailureEventByAdas(startFailedCode,startFailedMessage,System.currentTimeMillis())
M_LISTENERS.forEach {
it.value.startAutopilotFailure(startFailedCode,startFailedMessage)
}
}
}

View File

@@ -0,0 +1,210 @@
package com.mogo.och.common.module.wigets.autopilot
import android.animation.ObjectAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.animation.LinearInterpolator
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.findViewTreeViewModelStoreOwner
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.common.module.R
import com.mogo.och.common.module.manager.autopilot.autopilot.IOchAutopilotStatusListener
import com.mogo.och.common.module.utils.BigFrameAnimatorContainer
import com.mogo.och.common.module.utils.ResourcesUtils
import kotlinx.android.synthetic.main.common_autopilot_view.view.aciv_autopilot_running_ani
import kotlinx.android.synthetic.main.common_autopilot_view.view.aciv_autopilot_state
import kotlinx.android.synthetic.main.common_autopilot_view.view.actv_autopilot_head
import kotlinx.android.synthetic.main.common_autopilot_view.view.actv_autopilot_state
import kotlinx.android.synthetic.main.common_autopilot_view.view.actv_pxjs_state
class AutopilotState @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IOchAutopilotStatusListener,
AutopilotStateModel.AutopilotStateCallback {
private val TAG = "AutopilotState"
private var viewModel:AutopilotStateModel?=null
private var autopilotStateAnimator: BigFrameAnimatorContainer?=null
private lateinit var autopilotLoadingAnimator: ObjectAnimator
private fun initView() {
LayoutInflater.from(context).inflate(R.layout.common_autopilot_view, this, true)
autopilotStateAnimator = BigFrameAnimatorContainer(R.array.in_auto, 31, aciv_autopilot_running_ani)
autopilotLoadingAnimator = ObjectAnimator.ofFloat(aciv_autopilot_state, "rotation", 0f, 360f);
autopilotLoadingAnimator.interpolator = LinearInterpolator()
autopilotLoadingAnimator.repeatCount = -1 //无限循环
autopilotLoadingAnimator.duration = 1000 //无限循环
onClick {
startAutopilot()
}
}
fun startAutopilot(){
viewModel?.startAutopilot()
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
viewModel = findViewTreeViewModelStoreOwner()?.let {
ViewModelProvider(it).get(AutopilotStateModel::class.java)
}
viewModel?.setViewCallback(this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
}
init {
try {
initView()
} catch (e: Exception) {
e.printStackTrace()
}
}
override fun startAutopilotAnimation() {
CallerLogger.d(TAG,"播放启动自驾动画")
aciv_autopilot_state.setImageResource(R.drawable.common_autopilot_enable)
actv_pxjs_state.visibility = GONE
actv_autopilot_head.visibility = VISIBLE
actv_autopilot_state.visibility = VISIBLE
actv_autopilot_head.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.text = ResourcesUtils.getString(R.string.common_autopilot_starting)
actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
AutopilotState@this.isEnabled = false
autopilotLoadingAnimator.start()
}
override fun stopAutopilotAnimation() {
CallerLogger.d(TAG,"结束启动自驾动画")
aciv_autopilot_state.setImageResource(R.drawable.common_autopilot_enable)
actv_pxjs_state.visibility = GONE
actv_autopilot_head.visibility = VISIBLE
actv_autopilot_state.visibility = VISIBLE
actv_autopilot_head.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.text = ResourcesUtils.getString(R.string.common_autopilot_starting)
actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
AutopilotState@this.isEnabled = false
autopilotLoadingAnimator.cancel()
}
override fun inAutopilot() {
CallerLogger.d(TAG,"展示自驾中UI")
aciv_autopilot_state.setImageResource(R.drawable.common_autopilot_running)
actv_pxjs_state.visibility = GONE
actv_autopilot_head.visibility = VISIBLE
actv_autopilot_state.visibility = VISIBLE
actv_autopilot_head.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
actv_autopilot_state.text = ResourcesUtils.getString(R.string.common_autopilot_running)
actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
AutopilotState@this.isEnabled = false
aciv_autopilot_running_ani.visibility = VISIBLE
autopilotStateAnimator?.start()
autopilotLoadingAnimator.cancel()
}
override fun autopilotDisable() {
CallerLogger.d(TAG,"不可启动自驾")
aciv_autopilot_state.setImageResource(R.drawable.common_autopilot_unenable)
actv_pxjs_state.visibility = GONE
actv_autopilot_head.visibility = VISIBLE
actv_autopilot_state.visibility = VISIBLE
actv_autopilot_head.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.text = ResourcesUtils.getString(R.string.common_autopilot_start)
actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
AutopilotState@this.isEnabled = false
aciv_autopilot_running_ani.visibility = GONE
autopilotStateAnimator?.stop()
autopilotLoadingAnimator.cancel()
}
override fun canStartAutopilot() {
CallerLogger.d(TAG,"可以启动自驾")
aciv_autopilot_state.setImageResource(R.drawable.common_autopilot_enable)
actv_pxjs_state.visibility = GONE
actv_autopilot_head.visibility = VISIBLE
actv_autopilot_state.visibility = VISIBLE
actv_autopilot_head.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
actv_autopilot_state.text = ResourcesUtils.getString(R.string.common_autopilot_start)
actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
AutopilotState@this.isEnabled = true
aciv_autopilot_running_ani.visibility = GONE
autopilotStateAnimator?.stop()
autopilotLoadingAnimator.cancel()
}
override fun inRemoteDriver() {
CallerLogger.d(TAG,"展示平行驾驶中UI")
aciv_autopilot_state.setImageResource(R.drawable.common_autopilot_running)
actv_pxjs_state.visibility = VISIBLE
actv_autopilot_head.visibility = GONE
actv_autopilot_state.visibility = GONE
actv_autopilot_head.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
actv_autopilot_state.text = ResourcesUtils.getString(R.string.common_autopilot_start)
actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
AutopilotState@this.isEnabled = false
aciv_autopilot_running_ani.visibility = VISIBLE
autopilotStateAnimator?.start()
autopilotLoadingAnimator.cancel()
}
override fun startAutopilotSuccess() {
}
override fun startAutopilotFail() {
CallerLogger.d(TAG,"启动自动驾驶失败")
aciv_autopilot_state.setImageResource(R.drawable.common_autopilot_fail)
actv_pxjs_state.visibility = GONE
actv_autopilot_head.visibility = VISIBLE
actv_autopilot_state.visibility = VISIBLE
actv_autopilot_head.setTextColor(ResourcesUtils.getColor(R.color.common_B3FFFFFF))
actv_autopilot_state.setTextColor(ResourcesUtils.getColor(R.color.common_FF4E41))
actv_autopilot_state.text = ResourcesUtils.getString(R.string.common_autopilot_fail)
actv_pxjs_state.setTextColor(ResourcesUtils.getColor(R.color.common_19FFCB))
AutopilotState@this.isEnabled = false
aciv_autopilot_running_ani.visibility = VISIBLE
autopilotStateAnimator?.stop()
autopilotLoadingAnimator.cancel()
}
}

View File

@@ -0,0 +1,154 @@
package com.mogo.och.common.module.wigets.autopilot
import android.text.TextUtils
import androidx.lifecycle.ViewModel
import com.elegant.network.utils.GsonUtil
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_BUS
import com.mogo.eagle.core.utilcode.util.StringUtils
import com.mogo.eagle.core.utilcode.util.ToastUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback
import com.mogo.och.common.module.manager.autopilot.OCHAdasAbilityManager
import com.mogo.och.common.module.manager.autopilot.autopilot.IOchAutopilotStatusListener
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.canStartAutoPilotByDistance
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.canStartAutoPilotSSM
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotManager.startAutoPilot
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutoPilotStatusListenerManager
import com.mogo.och.common.module.manager.autopilot.autopilot.OchAutopilotAnalytics
import com.mogo.och.common.module.manager.autopilot.line.ILineCallback
import com.mogo.och.common.module.manager.autopilot.line.LineManager
import com.mogo.och.common.module.manager.distance.TrajectoryAndDistanceManager
import com.mogo.och.common.module.manager.logchainanalytic.OchChainLogManager
import com.mogo.och.common.module.manager.loop.BizLoopManager
import com.mogo.och.common.module.voice.VoiceNotice.showNotice
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicLong
/**
* @author XuXinChao
* @description BadCase录包管理页面
* @since: 2022/12/15
*/
class AutopilotStateModel : ViewModel(), IOchAutopilotStatusListener, ILineCallback{
private val TAG = AutopilotStateModel::class.java.simpleName
private var viewCallback:AutopilotStateCallback?=null
private val isPalyStartAni = AtomicBoolean(false)
override fun onCleared() {
this.viewCallback = null
OchAutoPilotStatusListenerManager.removeListener(TAG)
LineManager.removeListener(TAG)
}
fun setViewCallback(viewCallback:AutopilotStateCallback){
this.viewCallback = viewCallback
OchAutoPilotStatusListenerManager.addListener(TAG,this)
LineManager.addListener(TAG,this)
}
override fun onAutopilotStatusResponse(state: Int) {
OchChainLogManager.writeChainLog("自驾信息","自驾状态变化:${state}")
autopilotStateChange()
}
override fun canStartAutopilot(canStart: Boolean) {
OchChainLogManager.writeChainLog("自驾信息","能否启动自驾:${canStart}")
autopilotStateChange()
}
private fun autopilotStateChange(){
BizLoopManager.runInMainThread{
OchChainLogManager.writeChainLog("自驾信息","自驾状态:${OchAutoPilotStatusListenerManager.autopilotState} 能否启动自驾:${CallerAutoPilotControlManager.isCanStartAutopilot(false)}")
when (OchAutoPilotStatusListenerManager.autopilotState) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE-> {// 不可用 不可启动自驾
this.viewCallback?.autopilotDisable()
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE-> {
if (!CallerAutoPilotControlManager.isCanStartAutopilot(false)) {// 不可用
this.viewCallback?.autopilotDisable()
} else {// 部分可用
this.viewCallback?.canStartAutopilot()
}
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING-> {// 自驾中
this.viewCallback?.stopAutopilotAnimation()
this.viewCallback?.inAutopilot()
}
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING-> {// 平行驾驶中
this.viewCallback?.stopAutopilotAnimation()
this.viewCallback?.inRemoteDriver()
}
}
}
}
fun startAutopilot() {
OchChainLogManager.writeChainLog("自驾信息","启动自驾")
LineManager.startAutopilot()
}
override fun startAutopilotSuccess() {
OchChainLogManager.writeChainLog("自驾信息","启动自驾成功")
BizLoopManager.runInMainThread {
this.viewCallback?.startAutopilotAnimation()
isPalyStartAni.set(true)
}
}
override fun startAutopilotTimeOut() {
OchChainLogManager.writeChainLog("自驾信息","启动自驾超时失败")
BizLoopManager.runInMainThread{
this.viewCallback?.stopAutopilotAnimation()
this.viewCallback?.startAutopilotFail()
this.isPalyStartAni.set(false)
UiThreadHandler.postDelayed({
autopilotStateChange()
},1000,UiThreadHandler.MODE.QUEUE)
}
}
override fun startAutopilotFailure(startFailedCode: String?, startFailedMessage: String?) {
OchChainLogManager.writeChainLog("自驾信息","底盘强制失败原因:${startFailedCode}_${startFailedMessage}")
BizLoopManager.runInMainThread{
this.viewCallback?.stopAutopilotAnimation()
this.viewCallback?.startAutopilotFail()
this.isPalyStartAni.set(false)
UiThreadHandler.postDelayed({
autopilotStateChange()
},1000,UiThreadHandler.MODE.QUEUE)
}
}
interface AutopilotStateCallback{
//开始动画
fun startAutopilotAnimation()
//结束动画
fun stopAutopilotAnimation()
// 进入自动驾驶
fun inAutopilot()
// 自动驾驶不可用
fun autopilotDisable()
// 可用启动自驾
fun canStartAutopilot()
// 进入平行驾驶
fun inRemoteDriver()
// 启动自驾成功
fun startAutopilotSuccess()
// 启动自驾失败
fun startAutopilotFail()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Some files were not shown because too many files have changed in this diff Show More