Merge remote-tracking branch 'origin/dev_robotaxi-d_231031_6.2.0' into dev_robotaxi-d_231031_6.2.0

This commit is contained in:
xuxinchao
2023-11-09 11:50:21 +08:00
17 changed files with 612 additions and 279 deletions

View File

@@ -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() {

View File

@@ -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)
}

View File

@@ -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
}

View File

@@ -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)
}
}
}

View File

@@ -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)
}
}
}

View File

@@ -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()
}
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}

View File

@@ -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)
}
}
}

View File

@@ -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>

View File

@@ -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" />
<!--订单信息-->

View File

@@ -0,0 +1,7 @@
package com.mogo.och.charter.passenger.callback
import com.mogo.och.charter.passenger.utils.BeautifyManager
interface IBeautifyModeCallback {
fun dispatchStatus(typeEnum: BeautifyManager.ChangeTypeEnum)
}

View File

@@ -30,6 +30,7 @@ import com.mogo.och.charter.passenger.callback.*
import com.mogo.och.charter.passenger.constant.CharterPassengerConst
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
import com.mogo.och.charter.passenger.net.BusPassengerServiceManager
import com.mogo.och.charter.passenger.utils.BeautifyManager
import com.mogo.och.common.module.wigets.toast.ToastCharterUtils
import com.mogo.och.charter.passenger.utils.VoiceFocusManager
import com.mogo.och.common.module.bean.dpmsg.BaseDPMsg
@@ -736,6 +737,7 @@ object CharterPassengerModel {
d(M_BUS_P + TAG, "${this.orderInfo?.orderNo}新的状态:$orderStatus")
OchChainLogManager.writeChainLog(this.orderInfo.toString(),"新的状态:$orderStatus")
this.orderStatus = orderStatus
BeautifyManager.notifyViewChange(BeautifyManager.ChangeTypeEnum.ORDER_STATU_CHANGE)
for (callback in orderStatusChangeListeners.values) {
callback.onStatusChange(this.orderStatus)
}
@@ -964,6 +966,7 @@ object CharterPassengerModel {
if (order != null && lineId != null && siteId != null) {
OchChainLogManager.writeChainLog(this.orderInfo.toString(),"到站成功:${order.siteName}")
BeautifyManager.notifyViewChange(BeautifyManager.ChangeTypeEnum.ARRIVED_DEST)
VoiceManager.arrivedStation(
order.siteName!!,
order.siteNameKr ?: "",

View File

@@ -32,6 +32,7 @@ import com.mogo.och.charter.passenger.receive.DriverMessage
import com.mogo.och.charter.passenger.ui.MainFragment
import com.mogo.och.charter.passenger.ui.overmapview.MakerWithSiteName
import com.mogo.och.charter.passenger.ui.overmapview.MakerWithSiteNamewithCheck
import com.mogo.och.charter.passenger.utils.BeautifyManager
import com.mogo.och.common.module.biz.network.OchCommonServiceCallback
import com.mogo.och.common.module.manager.autopilotmanager.OCHAdasAbilityManager
import com.mogo.och.common.module.manager.stopsidemanager.StopSideManager
@@ -208,6 +209,7 @@ class BusPassengerPresenter(view: MainFragment?) :
}
StopSideStatus.EndingSuccess -> {
BeautifyManager.notifyViewChange(BeautifyManager.ChangeTypeEnum.STOPSITE_SUCCESS)
ToastCharterUtils.showToastShort("靠边停车成功")
VoiceNotice.showNotice(
context.getString(R.string.charter_p_stop_site_success),

View File

@@ -1,6 +1,5 @@
package com.mogo.och.charter.passenger.ui.statusbar
import android.annotation.SuppressLint
import android.content.Context
import android.os.SystemClock
import android.util.AttributeSet
@@ -14,22 +13,25 @@ import chassis.ChassisStatesOuterClass
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoBatteryManagementSystemListener
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerBatteryManagementSystemListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.util.ClickUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.och.charter.passenger.R
import com.mogo.och.charter.passenger.bean.response.OrderInfoResponse
import com.mogo.och.charter.passenger.callback.IBeautifyModeCallback
import com.mogo.och.charter.passenger.model.CharterPassengerModel
import com.mogo.och.charter.passenger.model.OrderStatusEnum
import com.mogo.och.charter.passenger.ui.debugview.DebugEvent
import com.mogo.och.charter.passenger.utils.BeautifyManager
import com.mogo.och.common.module.manager.loopmanager.BizLoopManager
import com.mogo.och.common.module.manager.loopmanager.LoopInfo
import com.mogo.och.common.module.manager.stopsidemanager.StopSideManager
import com.mogo.och.common.module.manager.stopsidemanager.StopSideStatus
import kotlinx.android.synthetic.main.charter_p_statusview_datetime.view.aciv_connect_driver_status
import kotlinx.android.synthetic.main.charter_p_statusview_datetime.view.actv_auto_status
import kotlinx.android.synthetic.main.charter_p_statusview_datetime.view.bizz_view
@@ -44,7 +46,8 @@ class StatusBarView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoSkinModeChangeListener, IViewControlListener, IMoGoBatteryManagementSystemListener, IMoGoAutopilotStatusListener {
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoBatteryManagementSystemListener, IMoGoAutopilotStatusListener,
IBeautifyModeCallback {
companion object {
const val TAG = "StatusBarView"
@@ -85,17 +88,12 @@ class StatusBarView @JvmOverloads constructor(
params.height = AutoSizeUtils.dp2px(context,47f)
layoutParams = params
}
//添加view控制
CallerHmiViewControlListenerManager.addListener(TAG,this)
CallerHmiViewControlListenerManager.setListenerHz(TAG,5)
// 添加换肤监听
CallerSkinModeListenerManager.addListener(TAG, this)
//电池电量监听
CallerBatteryManagementSystemListenerManager.addListener(TAG,this)
//自动驾驶状态监听
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
updateStatusBarRightView(FunctionBuildConfig.isDemoMode, "demoMode", DemoModeView(this.context))
BeautifyManager.setStatusChangeListener(TAG,this)
bizz_view.setOnClickListener { continuousClick(bizz) }
@@ -104,8 +102,7 @@ class StatusBarView @JvmOverloads constructor(
progress.progress = 50
tv_power_cos.text = "50%"
val state = CallerAutoPilotStatusListenerManager.getState()
setAutoPilotStatusInfo(state)
setAutoPilotStatusInfo(CallerAutoPilotStatusListenerManager.getState())
BizLoopManager.setLoopFunction(TAG, LoopInfo(3, ::showConnectStatusWithDriver))
}
@@ -122,27 +119,60 @@ class StatusBarView @JvmOverloads constructor(
}
private fun setAutoPilotStatusInfo(state: Int) {
when (state) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
actv_auto_status.text = "安全接管"
if (FunctionBuildConfig.isDemoMode) {// 美化模式
val gnssSpeed = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().gnssSpeed
actv_auto_status.text = "自动驾驶"
when (CharterPassengerModel.getCurrentOrderStatus()) {
OrderStatusEnum.Nothing -> {// 初始状态
//是否强制绘制引导线
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
}
OrderStatusEnum.NoOrderUnuse -> {//无订单车闲置
//是否强制绘制引导线
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
}
OrderStatusEnum.OrderNoLine -> {//有订单无线路
//是否强制绘制引导线
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
}
OrderStatusEnum.OrdersWithLine -> {//有订单有线路 是否到站
//是否强制绘制引导线
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = gnssSpeed>0.3
CharterPassengerModel.getCurrentOrderInfo()?.let {
if(it.arriveStatus == OrderInfoResponse.ARRIVED){
// 到站不绘制引导线
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
return
}
if (StopSideManager.stopSiteStatus== StopSideStatus.EndingSuccess) {
// 靠边停车成功不绘制引导线
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
return
}
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = true
}
}
OrderStatusEnum.NoOrderUse -> {// 无订单车不闲置
//是否强制绘制引导线
FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false
}
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> {
actv_auto_status.text = "安全接管中"
}else{
when (state) {
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_DISABLE -> {
actv_auto_status.text = "安全接管中"
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_ENABLE -> {
actv_auto_status.text = "安全接管中"
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
actv_auto_status.text = "自动驾驶中"
}
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING -> {
actv_auto_status.text = "远程代驾中"
}
else -> {}
}
IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING -> {
actv_auto_status.text = "自动驾驶中"
}
IMoGoAutopilotStatusListener.STATUS_PARALLEL_DRIVING -> {
actv_auto_status.text = "远程代驾中"
}
else -> {}
}
}
override fun onSkinModeChange(skinMode: Int) {
when (skinMode) {
0 -> setStatusBarDarkOrLight(false)
1 -> setStatusBarDarkOrLight(true)
}
}
@@ -152,21 +182,16 @@ class StatusBarView @JvmOverloads constructor(
}
}
override fun updateStatusBarLeftView(insert: Boolean, tag: String, viewGroup: ViewGroup) {
}
@SuppressLint("SetTextI18n")
override fun updateStatusBarDownloadView(insert: Boolean, tag: String, progress: Int) {
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
CallerHmiViewControlListenerManager.removeListener(TAG)
CallerSkinModeListenerManager.removeListener(TAG)
CallerDevaToolsManager.hideStatusBar()
//定时任务
BizLoopManager.removeLoopFunction(TAG)
//电池电量监听
CallerBatteryManagementSystemListenerManager.removeListener(TAG)
//自动驾驶状态监听
CallerAutoPilotStatusListenerManager.removeListener(TAG)
BeautifyManager.setStatusChangeListener(TAG,null)
}
override fun onBatteryManagementSystemStates(states: ChassisStatesOuterClass.BMSSystemStates) {
@@ -179,5 +204,11 @@ class StatusBarView @JvmOverloads constructor(
tv_power_cos.text = "${bmsSoc.roundToInt()}%"
}
}
override fun dispatchStatus(typeEnum: BeautifyManager.ChangeTypeEnum) {
UiThreadHandler.post( {
setAutoPilotStatusInfo(CallerAutoPilotStatusListenerManager.getState())
},UiThreadHandler.MODE.QUEUE)
}
}

View File

@@ -0,0 +1,61 @@
package com.mogo.och.charter.passenger.utils
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.och.charter.passenger.callback.IBeautifyModeCallback
import com.mogo.och.charter.passenger.ui.statusbar.StatusBarView
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)
}
}
}

View File

@@ -8,7 +8,7 @@
<com.mogo.eagle.core.function.view.MapBizView
android:id="@+id/mapBizView"
app:styleMode="MAP_STYLE_DAY_VR"
app:carPosition="-0.5"
app:carPosition="-1"
app:default_perspective="MAP_STYLE_VR_ERHAI_B2"
app:isWeatherEnable="false"
app:locationIcon3DRes="@raw/m2"