[6.2.0]
[charter] [速度、自动驾驶状态]
This commit is contained in:
@@ -12,6 +12,7 @@ import androidx.constraintlayout.widget.Group
|
||||
import com.magic.mogo.och.charter.R
|
||||
import com.magic.mogo.och.charter.constant.CharterConst
|
||||
import com.magic.mogo.och.charter.view.SlidePanelView
|
||||
import com.magic.mogo.och.charter.view.autopilot.AutopilotStatusView
|
||||
import com.mogo.commons.mvp.IView
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.commons.mvp.Presenter
|
||||
@@ -54,16 +55,13 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
|
||||
private val TAG = "BaseBusTabFragment"
|
||||
|
||||
private var ctvAutopilotStatus: RelativeLayout? = null
|
||||
private var ctvAutopilotStatusIv: ImageView? = null
|
||||
private var ctvAutopilotStatusTv: TextView? = null
|
||||
private var ctvAutopilotStatus: AutopilotStatusView? = null
|
||||
protected var mSettingBtn: RelativeLayout? = null
|
||||
protected var mBadcaseBtn: RelativeLayout? = null
|
||||
protected var mAICollectBtn: RelativeLayout? = null
|
||||
private var flStationPanelContainer: FrameLayout? = null
|
||||
private var mapBizView: MapBizView? = null
|
||||
private var groupTestPanel: Group? = null
|
||||
private var mTrafficDataView: TrafficDataView? = null
|
||||
protected var slidePanelView: SlidePanelView? = null
|
||||
//远景和中景的切换
|
||||
private var mSwitchMapModeImage: ImageView? = null
|
||||
@@ -87,16 +85,13 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
override fun initViews() {
|
||||
mapBizView = findViewById(R.id.mapBizView)
|
||||
groupTestPanel = findViewById(R.id.groupTestPanel)
|
||||
ctvAutopilotStatus = findViewById(R.id.module_mogo_och_autopilot_status)
|
||||
ctvAutopilotStatusIv = findViewById(R.id.bus_autopilot_btn_iv)
|
||||
ctvAutopilotStatusTv = findViewById(R.id.bus_autopolot_btn_tv)
|
||||
ctvAutopilotStatus = findViewById(R.id.autopilot_status)
|
||||
flStationPanelContainer = findViewById(R.id.module_mogo_och_station_panel_container)
|
||||
|
||||
slidePanelView = findViewById(R.id.charter_slide_panel)
|
||||
slidePanelView?.setText(resources.getString(R.string.charter_back_car))
|
||||
slidePanelView?.setOnSlidePanelMoveToEndListener(onSlideToEndListener)
|
||||
|
||||
mTrafficDataView = findViewById<View>(R.id.bus_arc) as TrafficDataView?
|
||||
LayoutInflater.from(context).inflate(getStationPanelViewId(), flStationPanelContainer)
|
||||
mSwitchMapModeLayout = findViewById(R.id.bus_switch_model_layout)
|
||||
mSwitchMapModeImage = findViewById(R.id.bus_switch_model_icon)
|
||||
@@ -122,12 +117,6 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
}
|
||||
})
|
||||
initListener()
|
||||
setAutopilotBtnStatus(getState())
|
||||
ctvAutopilotStatus!!.setOnClickListener(object : OnPreventFastClickListener() {
|
||||
override fun onClickImpl(v: View) {
|
||||
restartAutopilot()
|
||||
}
|
||||
})
|
||||
|
||||
// 模拟 不可自动驾驶,目前场景是刚开机,adas还未和工控机连接
|
||||
findViewById<View>(R.id.btnAutopilotDisable)!!.setOnClickListener { view: View? ->
|
||||
@@ -194,6 +183,11 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
}
|
||||
})
|
||||
smallMapView = findViewById(R.id.smallMapView)
|
||||
|
||||
ctvAutopilotStatus?.setOnLongClickListener {
|
||||
debugTestBar()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
@@ -308,90 +302,6 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
SoundPoolHelper.getSoundPoolHelper().playSoundWithRedId(context, R.raw.bus_di)
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变自动驾驶状态
|
||||
*
|
||||
* @param autopilotStatus 0:不可用 1:可用状态 2:自动驾驶中
|
||||
*/
|
||||
fun onAutopilotStatusChanged(autopilotStatus: Int) {
|
||||
requireActivity().runOnUiThread {
|
||||
changeAutopilotBtnView(
|
||||
autopilotStatus,
|
||||
isAnimateRunning
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setAutopilotBtnStatus(autopilotStatus: Int) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
|
||||
== autopilotStatus
|
||||
) { //0不可用
|
||||
ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_disable))
|
||||
ctvAutopilotStatusTv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_runnig_tv)
|
||||
ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_disable_autopilot_icon)
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
ctvAutopilotStatus!!.isClickable = true
|
||||
ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_autopilot_0_1_status_bg)
|
||||
}else{
|
||||
ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_ic_autopilot)
|
||||
ctvAutopilotStatusTv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_runnig_tv)
|
||||
ctvAutopilotStatus!!.isClickable = true
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用
|
||||
ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_autopilot_0_1_status_bg)
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {
|
||||
ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_autopilot_2_status_bg)
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING
|
||||
== autopilotStatus){
|
||||
ctvAutopilotStatusTv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_pingxing_tv)
|
||||
ctvAutopilotStatus!!.isClickable = false
|
||||
ctvAutopilotStatus!!.background = getDrawable(R.drawable.charter_pingxingjiashi)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open fun updateAutopilotStatus(autopilotStatus: Int) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
== autopilotStatus
|
||||
) { //2 running
|
||||
ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_right_autopilot_icon)
|
||||
ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
ctvAutopilotStatusTv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_success_tv)
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
ctvAutopilotStatus!!.isClickable = false
|
||||
} else {
|
||||
ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_wrong_autopilot_icon)
|
||||
ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
ctvAutopilotStatusTv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_failure_tv)
|
||||
ctvAutopilotStatus!!.isClickable = false
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
}
|
||||
UiThreadHandler.postDelayed({ setAutopilotBtnStatus(autopilotStatus) }, 1000)
|
||||
}
|
||||
|
||||
private fun changeAutopilotBtnView(autopilotStatus: Int, isAnimateRunning: Boolean) {
|
||||
if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
!= autopilotStatus
|
||||
) {
|
||||
// 主动开启自动驾驶中,不为2(为0、1)则继续loading
|
||||
return
|
||||
}
|
||||
if (isAnimateRunning) {
|
||||
stopAnimAndUpdateBtnStatus()
|
||||
} else {
|
||||
setAutopilotBtnStatus(autopilotStatus)
|
||||
}
|
||||
}
|
||||
|
||||
open fun stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(getState())
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -408,74 +318,13 @@ abstract class CharterBaseFragment<V : IView?, P : Presenter<V>?>() :
|
||||
*/
|
||||
abstract fun getStationPanelViewId(): Int
|
||||
|
||||
/**
|
||||
* 重新开启自动驾驶
|
||||
*/
|
||||
abstract fun restartAutopilot()
|
||||
|
||||
/**
|
||||
* 模拟自动驾驶返回状态
|
||||
*
|
||||
* @param status
|
||||
*/
|
||||
private fun debugAutoPilotStatus(status: Int){
|
||||
setAutopilotBtnStatus(status)
|
||||
}
|
||||
/**
|
||||
* 开启自动驾驶中间动画
|
||||
*/
|
||||
@SuppressLint("ObjectAnimatorBinding")
|
||||
open fun startAutopilotAnimation() {
|
||||
isAnimateRunning = true
|
||||
ctvAutopilotStatusTv!!.text = resources.getString(R.string.charter_loading_autopilot_tv)
|
||||
ctvAutopilotStatusTv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
ctvAutopilotStatus!!.isClickable = true
|
||||
ctvAutopilotStatusIv!!.setImageResource(R.drawable.charter_loading_autopilot_icon)
|
||||
if (autopilotLoadingAnimator == null) {
|
||||
autopilotLoadingAnimator =
|
||||
ObjectAnimator.ofFloat(ctvAutopilotStatusIv, "rotation", 0f, 360f)
|
||||
autopilotLoadingAnimator?.interpolator = LinearInterpolator()
|
||||
autopilotLoadingAnimator?.repeatCount = -1 //无限循环
|
||||
autopilotLoadingAnimator?.duration = 1000 //设置持续时间
|
||||
}
|
||||
autopilotLoadingAnimator!!.start() //动画开始
|
||||
startingAutoApilotCountDown()
|
||||
}
|
||||
|
||||
private fun startingAutoApilotCountDown() {
|
||||
//10s 若自动驾驶没有开启,则结束动画
|
||||
UiThreadHandler.postDelayed({
|
||||
//未启动成功做处理
|
||||
if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(getState())
|
||||
}
|
||||
}, CharterConst.TIMER_START_AUTOPILOT_INTERVAL)
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止自动驾驶中间动画
|
||||
*/
|
||||
protected open fun stopAutopilotAnimation() {
|
||||
if (autopilotLoadingAnimator != null) {
|
||||
autopilotLoadingAnimator!!.end()
|
||||
ctvAutopilotStatusIv!!.clearAnimation()
|
||||
autopilotLoadingAnimator = null
|
||||
isAnimateRunning = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 迈速表实时更新
|
||||
*
|
||||
* @param newSpeed
|
||||
*/
|
||||
open fun updateSpeedView(newSpeed: Float) {
|
||||
val speed = (abs(newSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值
|
||||
if (mTrafficDataView != null) {
|
||||
mTrafficDataView!!.updateSpeedWithValue(speed)
|
||||
}
|
||||
ctvAutopilotStatus?.setAutopilotBtnStatus(status)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.magic.mogo.och.charter.callback
|
||||
|
||||
import com.magic.mogo.och.charter.manager.BeautifyManager
|
||||
|
||||
interface IBeautifyModeCallback {
|
||||
fun dispatchStatus(typeEnum: BeautifyManager.ChangeTypeEnum)
|
||||
}
|
||||
@@ -168,13 +168,6 @@ class DriverM1Fragment : CharterBaseFragment<DriverM1Fragment?, DriverM1Presente
|
||||
return R.layout.charter_fragment_driver_m1
|
||||
}
|
||||
|
||||
override fun restartAutopilot() {
|
||||
//启动自驾
|
||||
if (!isAnimateRunning) {
|
||||
mPresenter?.restartAutopilot()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTagName(): String {
|
||||
return TAG
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.magic.mogo.och.charter.manager
|
||||
|
||||
import com.magic.mogo.och.charter.callback.IBeautifyModeCallback
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
|
||||
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
object BeautifyManager {
|
||||
|
||||
private val TAG = BeautifyManager::class.java.simpleName
|
||||
|
||||
enum class ChangeTypeEnum{
|
||||
BEAUTIFY_TYPE,// 美化模式变化
|
||||
ORDER_STATU_CHANGE,// 订单状态发生变化
|
||||
ARRIVED_DEST,// 到站
|
||||
STOPSITE_SUCCESS// 靠边停车成功
|
||||
}
|
||||
|
||||
private val orderStatusChangeListeners = ConcurrentHashMap<String, IBeautifyModeCallback>()
|
||||
|
||||
@Volatile
|
||||
@JvmField
|
||||
var isBeautifyMode = false
|
||||
|
||||
init {
|
||||
isBeautifyMode = FunctionBuildConfig.isDemoMode
|
||||
BizLoopManager.setLoopFunction(TAG, LoopInfo(3, ::checkDemoMode))
|
||||
}
|
||||
|
||||
private fun checkDemoMode() {
|
||||
if(isBeautifyMode!=FunctionBuildConfig.isDemoMode){
|
||||
isBeautifyMode = FunctionBuildConfig.isDemoMode
|
||||
notifyViewChange(ChangeTypeEnum.BEAUTIFY_TYPE)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun setStatusChangeListener(
|
||||
tag: String,
|
||||
orderStatusChangeListener: IBeautifyModeCallback?
|
||||
) {
|
||||
if (tag.isBlank()) return
|
||||
if (orderStatusChangeListener == null) {
|
||||
orderStatusChangeListeners.remove(tag)
|
||||
return
|
||||
}
|
||||
orderStatusChangeListeners[tag] = orderStatusChangeListener
|
||||
}
|
||||
|
||||
|
||||
fun notifyViewChange(typeEnum: ChangeTypeEnum){
|
||||
CallerLogger.d(TAG,"美化模式变化原因:${typeEnum}")
|
||||
orderStatusChangeListeners.forEach {
|
||||
it.value.dispatchStatus(typeEnum)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,8 +36,7 @@ import mogo_msg.MogoReportMsg
|
||||
*/
|
||||
class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
Presenter<DriverM1Fragment?>(view),ILoginCallback, DriverM1OrderCallback, ChangeDestCallback,
|
||||
IMoGoAutopilotStatusListener, OCHPlanningActionsCallback,
|
||||
IDriverM1ControllerStatusCallback {
|
||||
IMoGoAutopilotStatusListener, OCHPlanningActionsCallback{
|
||||
|
||||
companion object{
|
||||
private const val TAG = "DriverM1Presenter"
|
||||
@@ -55,7 +54,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
StopSideManager.addListener(TAG,this)
|
||||
DriverM1Model.get().setDriverM1OrderCallback(this)
|
||||
DriverM1Model.get().setChangeDestCallback(this)
|
||||
DriverM1Model.get().setControllerStatusCallback(this)
|
||||
}
|
||||
|
||||
private fun releaseListener() {
|
||||
@@ -63,7 +61,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
DriverM1Model.get().setDriverM1OrderCallback(null)
|
||||
DriverM1Model.get().setChangeDestCallback(null)
|
||||
DriverM1Model.get().setControllerStatusCallback(null)
|
||||
}
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
@@ -92,13 +89,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
DriverM1Model.get().logout()
|
||||
}
|
||||
|
||||
fun restartAutopilot() {
|
||||
// todo 启动自驾必须有订单路线
|
||||
if (DriverM1Model.get().isHaveOrder()) {
|
||||
DriverM1Model.get().restartAutopilot()
|
||||
}
|
||||
}
|
||||
|
||||
fun driverEndLease() {
|
||||
DriverM1Model.get().driverEndLease()
|
||||
}
|
||||
@@ -145,7 +135,6 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
mView?.onAutopilotStatusChanged(state)
|
||||
when(state){
|
||||
// IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> { //
|
||||
//
|
||||
@@ -193,21 +182,4 @@ class DriverM1Presenter(view: DriverM1Fragment?) :
|
||||
}
|
||||
}
|
||||
|
||||
override fun startOpenAutopilot() {
|
||||
ThreadUtils.runOnUiThread {
|
||||
mView?.startAutopilotAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onStartAdasFailure() {
|
||||
ThreadUtils.runOnUiThread {
|
||||
mView?.stopAnimAndUpdateBtnStatus()
|
||||
}
|
||||
}
|
||||
|
||||
override fun updateSpeed(gnssInfo: MogoLocation) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
mView?.updateSpeedView(gnssInfo.gnssSpeed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
package com.magic.mogo.och.charter.view.autopilot
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.animation.LinearInterpolator
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.findViewTreeViewModelStoreOwner
|
||||
import com.magic.mogo.och.charter.R
|
||||
import com.magic.mogo.och.charter.constant.CharterConst
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.ResourceUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.charter_autopilot_status.view.bus_autopilot_btn_iv
|
||||
import kotlinx.android.synthetic.main.charter_autopilot_status.view.bus_autopolot_btn_tv
|
||||
|
||||
/**
|
||||
* 剩余时间和结束订单入口
|
||||
*/
|
||||
class AutopilotStatusView : RelativeLayout,AutopilotStatusViewModel.IAutopilotStatusCallback {
|
||||
|
||||
private val TAG = "AutopilotStatusView"
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
|
||||
|
||||
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attributeSet,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
var viewModel:AutopilotStatusViewModel?=null
|
||||
|
||||
var isAnimateRunning = false
|
||||
|
||||
private var autopilotLoadingAnimator: ObjectAnimator? = null
|
||||
|
||||
private fun initView() {
|
||||
LayoutInflater.from(context).inflate(R.layout.charter_autopilot_status, this, true)
|
||||
onClick {
|
||||
if (!isAnimateRunning) {
|
||||
viewModel?.restartAutopilot()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun startAutopilotAnimation() {
|
||||
isAnimateRunning = true
|
||||
bus_autopolot_btn_tv!!.text = resources.getString(R.string.charter_loading_autopilot_tv)
|
||||
bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
isClickable = true
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_loading_autopilot_icon)
|
||||
if (autopilotLoadingAnimator == null) {
|
||||
autopilotLoadingAnimator =
|
||||
ObjectAnimator.ofFloat(bus_autopilot_btn_iv, "rotation", 0f, 360f)
|
||||
autopilotLoadingAnimator?.interpolator = LinearInterpolator()
|
||||
autopilotLoadingAnimator?.repeatCount = -1 //无限循环
|
||||
autopilotLoadingAnimator?.duration = 1000 //设置持续时间
|
||||
}
|
||||
autopilotLoadingAnimator!!.start() //动画开始
|
||||
startingAutoApilotCountDown()
|
||||
}
|
||||
|
||||
override fun stopAnimAndUpdateBtnStatus() {
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.getState())
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusChanged(autopilotStatus: Int) {
|
||||
if (isAnimateRunning && IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
!= autopilotStatus
|
||||
) {
|
||||
// 主动开启自动驾驶中,不为2(为0、1)则继续loading
|
||||
return
|
||||
}
|
||||
if (isAnimateRunning) {
|
||||
stopAnimAndUpdateBtnStatus()
|
||||
} else {
|
||||
setAutopilotBtnStatus(autopilotStatus)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startingAutoApilotCountDown() {
|
||||
//10s 若自动驾驶没有开启,则结束动画
|
||||
UiThreadHandler.postDelayed({
|
||||
//未启动成功做处理
|
||||
if (isAnimateRunning) { // 只判断动画是否在进行,根据自动驾驶当前状态去设置自动驾驶状态
|
||||
stopAutopilotAnimation()
|
||||
updateAutopilotStatus(CallerAutoPilotStatusListenerManager.getState())
|
||||
}
|
||||
}, CharterConst.TIMER_START_AUTOPILOT_INTERVAL)
|
||||
}
|
||||
|
||||
fun updateAutopilotStatus(autopilotStatus: Int) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
== autopilotStatus
|
||||
) { //2 running
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_right_autopilot_icon)
|
||||
bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_success_tv)
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
isClickable = false
|
||||
} else {
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_wrong_autopilot_icon)
|
||||
bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_failure_tv)
|
||||
isClickable = false
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
}
|
||||
UiThreadHandler.postDelayed({ setAutopilotBtnStatus(autopilotStatus) }, 1000)
|
||||
}
|
||||
|
||||
fun setAutopilotBtnStatus(autopilotStatus: Int) {
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE
|
||||
== autopilotStatus
|
||||
) { //0不可用
|
||||
bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_disable))
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_runnig_tv)
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_disable_autopilot_icon)
|
||||
// ctvAutopilotStatus!!.isSelected = false
|
||||
isClickable = true
|
||||
background = ResourceUtils.getDrawable(R.drawable.charter_autopilot_0_1_status_bg)
|
||||
}else{
|
||||
bus_autopolot_btn_tv!!.setTextColor(resources.getColor(R.color.charter_autopilot_text_color_normal))
|
||||
bus_autopilot_btn_iv!!.setImageResource(R.drawable.charter_ic_autopilot)
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_runnig_tv)
|
||||
isClickable = true
|
||||
if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE == autopilotStatus) { //1可用
|
||||
background =
|
||||
ResourceUtils.getDrawable(R.drawable.charter_autopilot_0_1_status_bg)
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING == autopilotStatus) {
|
||||
background =
|
||||
ResourceUtils.getDrawable(R.drawable.charter_autopilot_2_status_bg)
|
||||
} else if (IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING == autopilotStatus){
|
||||
bus_autopolot_btn_tv!!.text =
|
||||
resources.getString(R.string.charter_loading_autopilot_pingxing_tv)
|
||||
isClickable = false
|
||||
background = ResourceUtils.getDrawable(R.drawable.charter_pingxingjiashi)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止自动驾驶中间动画
|
||||
*/
|
||||
protected open fun stopAutopilotAnimation() {
|
||||
if (autopilotLoadingAnimator != null) {
|
||||
autopilotLoadingAnimator!!.end()
|
||||
bus_autopilot_btn_iv!!.clearAnimation()
|
||||
autopilotLoadingAnimator = null
|
||||
isAnimateRunning = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
viewModel = findViewTreeViewModelStoreOwner()?.let {
|
||||
ViewModelProvider(it).get(AutopilotStatusViewModel::class.java)
|
||||
}
|
||||
viewModel?.setAutopilotStatusCallback(this)
|
||||
setAutopilotBtnStatus(CallerAutoPilotStatusListenerManager.getState())
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
try {
|
||||
initView()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.magic.mogo.och.charter.view.autopilot
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.magic.mogo.och.charter.callback.IDriverM1ControllerStatusCallback
|
||||
import com.magic.mogo.och.charter.model.DriverM1Model
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
|
||||
class AutopilotStatusViewModel: ViewModel(), IDriverM1ControllerStatusCallback,
|
||||
IMoGoAutopilotStatusListener {
|
||||
|
||||
private val TAG = AutopilotStatusViewModel::class.java.simpleName
|
||||
|
||||
private var viewCallback:IAutopilotStatusCallback?=null
|
||||
|
||||
|
||||
init {
|
||||
DriverM1Model.get().setControllerStatusCallback(this)
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
this.viewCallback = null
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
fun setAutopilotStatusCallback(viewCallback:IAutopilotStatusCallback){
|
||||
this.viewCallback = viewCallback
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
fun restartAutopilot() {
|
||||
// todo 启动自驾必须有订单路线
|
||||
if (DriverM1Model.get().isHaveOrder()) {
|
||||
DriverM1Model.get().restartAutopilot()
|
||||
}
|
||||
}
|
||||
|
||||
interface IAutopilotStatusCallback{
|
||||
fun startAutopilotAnimation()
|
||||
fun stopAnimAndUpdateBtnStatus()
|
||||
fun onAutopilotStatusChanged(state: Int)
|
||||
}
|
||||
|
||||
override fun startOpenAutopilot() {
|
||||
ThreadUtils.runOnUiThread( {
|
||||
this.viewCallback?.startAutopilotAnimation()
|
||||
},ThreadUtils.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun onStartAdasFailure() {
|
||||
ThreadUtils.runOnUiThread( {
|
||||
this.viewCallback?.stopAnimAndUpdateBtnStatus()
|
||||
},ThreadUtils.MODE.QUEUE)
|
||||
}
|
||||
|
||||
override fun updateSpeed(gnssInfo: MogoLocation) {
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(state: Int) {
|
||||
ThreadUtils.runOnUiThread( {
|
||||
this.viewCallback?.onAutopilotStatusChanged(state)
|
||||
},ThreadUtils.MODE.QUEUE)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.magic.mogo.och.charter.view.carstatus
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.lifecycle.findViewTreeViewModelStoreOwner
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.TrafficDataView
|
||||
|
||||
class CarStatusView : TrafficDataView, CarStatusViewModel.ICarStatusCallback {
|
||||
|
||||
private val TAG = "CarStatusView"
|
||||
|
||||
constructor(context: Context) : super(context)
|
||||
|
||||
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
|
||||
|
||||
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
|
||||
context,
|
||||
attributeSet,
|
||||
defStyleAttr
|
||||
)
|
||||
|
||||
var viewModel:CarStatusViewModel?=null
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
viewModel = findViewTreeViewModelStoreOwner()?.let {
|
||||
ViewModelProvider(it).get(CarStatusViewModel::class.java)
|
||||
}
|
||||
viewModel?.setAutopilotStatusCallback(this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
|
||||
override fun updateSpeedWithCurrentValue(speed: Int) {
|
||||
updateSpeedWithValue(speed)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.magic.mogo.och.charter.view.carstatus
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.magic.mogo.och.charter.model.DriverM1Model
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import kotlin.math.abs
|
||||
|
||||
class CarStatusViewModel: ViewModel(), IMoGoAutopilotStatusListener,
|
||||
IMoGoChassisLocationGCJ02Listener {
|
||||
|
||||
private val TAG = CarStatusViewModel::class.java.simpleName
|
||||
|
||||
private var viewCallback:ICarStatusCallback?=null
|
||||
|
||||
|
||||
init {
|
||||
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
this.viewCallback = null
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(DriverM1Model.TAG)
|
||||
}
|
||||
|
||||
fun setAutopilotStatusCallback(viewCallback:ICarStatusCallback){
|
||||
this.viewCallback = viewCallback
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(DriverM1Model.TAG, 10, this)
|
||||
}
|
||||
|
||||
interface ICarStatusCallback{
|
||||
fun updateSpeedWithCurrentValue(speed:Int)
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
mogoLocation?.let {
|
||||
val speed = (abs(it.gnssSpeed) * 3.6f).toInt() // 倒车时工控机反馈定位信息中speed为负值
|
||||
ThreadUtils.runOnUiThread( {
|
||||
viewCallback?.updateSpeedWithCurrentValue(speed)
|
||||
},ThreadUtils.MODE.QUEUE)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="@dimen/dp_616"
|
||||
android:layout_height="@dimen/dp_180"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/charter_autopilot_0_1_status_bg"
|
||||
tools:parentTag="RelativeLayout">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_autopilot_btn_iv"
|
||||
android:layout_width="73dp"
|
||||
android:layout_height="73dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/charter_ic_autopilot" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_autopolot_btn_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="28dp"
|
||||
android:layout_toRightOf="@+id/bus_autopilot_btn_iv"
|
||||
android:text="自动驾驶"
|
||||
android:textColor="@color/charter_autopilot_text_color_normal"
|
||||
android:textSize="@dimen/dp_40"
|
||||
android:textStyle="bold" />
|
||||
</merge>
|
||||
@@ -29,7 +29,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
<!--车速档位加速度-->
|
||||
<FrameLayout
|
||||
<com.magic.mogo.och.charter.view.carstatus.CarStatusView
|
||||
android:id="@+id/fl_speed"
|
||||
android:layout_width="@dimen/dp_616"
|
||||
android:layout_height="@dimen/dp_320"
|
||||
@@ -37,14 +37,8 @@
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.TrafficDataView
|
||||
android:id="@+id/bus_arc"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<!--V2X预警红色边框-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.V2XWarningView
|
||||
@@ -160,38 +154,17 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
<!--自驾状态和启动开关-->
|
||||
<RelativeLayout
|
||||
android:id="@+id/module_mogo_och_autopilot_status"
|
||||
|
||||
<com.magic.mogo.och.charter.view.autopilot.AutopilotStatusView
|
||||
android:id="@+id/autopilot_status"
|
||||
android:layout_width="@dimen/dp_616"
|
||||
android:layout_height="@dimen/dp_180"
|
||||
android:layout_marginLeft="@dimen/dp_13"
|
||||
android:background="@drawable/charter_autopilot_0_1_status_bg"
|
||||
android:gravity="center"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/fl_speed"
|
||||
tools:visibility="visible">
|
||||
tools:visibility="visible"
|
||||
android:layout_marginLeft="@dimen/dp_13"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/bus_autopilot_btn_iv"
|
||||
android:layout_width="73dp"
|
||||
android:layout_height="73dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:src="@drawable/charter_ic_autopilot" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bus_autopolot_btn_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="28dp"
|
||||
android:layout_toRightOf="@+id/bus_autopilot_btn_iv"
|
||||
android:text="自动驾驶"
|
||||
android:textColor="@color/charter_autopilot_text_color_normal"
|
||||
android:textSize="@dimen/dp_40"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</RelativeLayout>
|
||||
<!--订单状态-->
|
||||
<FrameLayout
|
||||
android:id="@+id/module_mogo_och_station_panel_container"
|
||||
@@ -199,7 +172,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/dp_13"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/module_mogo_och_autopilot_status"
|
||||
app:layout_constraintTop_toBottomOf="@id/autopilot_status"
|
||||
app:layout_goneMarginTop="@dimen/dp_530" />
|
||||
|
||||
<!--订单信息-->
|
||||
|
||||
@@ -52,7 +52,7 @@ object BeautifyManager {
|
||||
|
||||
|
||||
fun notifyViewChange(typeEnum: ChangeTypeEnum){
|
||||
CallerLogger.d(StatusBarView.TAG,"美化模式变化原因:${typeEnum}")
|
||||
CallerLogger.d(TAG,"美化模式变化原因:${typeEnum}")
|
||||
orderStatusChangeListeners.forEach {
|
||||
it.value.dispatchStatus(typeEnum)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user