[6.4.4]冷启动加载View
This commit is contained in:
@@ -463,10 +463,20 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
header: MessagePad.Header?,
|
||||
statusInfo: SystemStatusInfo.StatusInfo?
|
||||
) {
|
||||
if(statusInfo!=null && statusInfo.hasAutoPilotReady()){
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().ssmAutoPilotReady = statusInfo.autoPilotReady
|
||||
}else{
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().ssmAutoPilotReady = false
|
||||
}
|
||||
invokeAutopilotStatusRespByQuery(statusInfo)
|
||||
}
|
||||
|
||||
override fun onSystemStatus(header: MessagePad.Header?, statusInf: SsmInfo.SsmStatusInf?) {
|
||||
if(statusInf!=null && statusInf.hasAutoPilotReady()){
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().ssmAutoPilotReady = statusInf.autoPilotReady
|
||||
}else{
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().ssmAutoPilotReady = false
|
||||
}
|
||||
invokeSystemStatus(statusInf)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,23 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.os.CountDownTimer
|
||||
import android.util.AttributeSet
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.zhjt.mogo.adas.data.AdasConstants
|
||||
import kotlinx.android.synthetic.main.view_connection_process.view.clConnectionTip
|
||||
import kotlinx.android.synthetic.main.view_connection_process.view.pbConnectionProgress
|
||||
import kotlinx.android.synthetic.main.view_connection_process.view.tvConnectionStatus
|
||||
import kotlinx.android.synthetic.main.view_connection_process.view.tvConnectionTipContent
|
||||
import kotlinx.android.synthetic.main.view_connection_process.view.tvConnectionTipTitle
|
||||
import system_master.SsmInfo
|
||||
import system_master.SystemStatusInfo
|
||||
|
||||
@@ -26,12 +34,23 @@ class ConnectionProcessView @JvmOverloads constructor(
|
||||
|
||||
companion object {
|
||||
const val TAG = "ConnectionProcessView"
|
||||
const val DISMISS_WAITING_TIME = 3000L //冷启动视图消失时间
|
||||
const val LOAD_SSM_WAITING_TIME = 300000L //SSM加载超时等待时间
|
||||
const val AUTOPILOT_READY_WAITING_TIME = 600000L //冷启动超时等待时间
|
||||
const val RECONNECTION_TIME = 60000L //域控重连时间
|
||||
}
|
||||
|
||||
private var isFirstTimeConnect = true //是否是第一次连接域控,默认是首次连接
|
||||
private var isDisconnectTimeout = false //是否连接域控超时1分钟
|
||||
private var ipcConnectStatus = false //连接域控状态,默认是未连接
|
||||
private var ssmConnectStatus = false //SSM连接状态,默认是未连接
|
||||
private var autopilotReadyStatus = false //冷启动状态,默认是未冷启动成功
|
||||
private var currentProcess = 25 //加载进度,展示时即为25(域控已连接成功)
|
||||
private var dismissTimer: CountDownTimer ?= null //连接视图消失倒计时
|
||||
private var connectSSMTimer: CountDownTimer ?= null //连接SSM等待倒计时
|
||||
private var autopilotReadyTimer: CountDownTimer ?= null //冷启动等待倒计时
|
||||
private var disconnectTimer: CountDownTimer ?= null //域控断连超时1分钟倒计时
|
||||
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_connection_process, this, true)
|
||||
@@ -39,7 +58,7 @@ class ConnectionProcessView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun initView(){
|
||||
|
||||
this.visibility = View.GONE
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
@@ -56,9 +75,23 @@ class ConnectionProcessView @JvmOverloads constructor(
|
||||
status: AdasConstants.IpcConnectionStatus,
|
||||
reason: String?
|
||||
) {
|
||||
ipcConnectStatus = status == AdasConstants.IpcConnectionStatus.CONNECTED
|
||||
if(ipcConnectStatus){
|
||||
isFirstTimeConnect = false
|
||||
if(status == AdasConstants.IpcConnectionStatus.CONNECTED){
|
||||
//域控连接成功
|
||||
if(CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().ssmAutoPilotReady){
|
||||
dismissConnectionView()
|
||||
}else{
|
||||
connectIPCSuccess()
|
||||
}
|
||||
isDisconnectTimeout = false
|
||||
disconnectTimer?.cancel()
|
||||
}else{
|
||||
if(ipcConnectStatus && disconnectTimer == null && !isDisconnectTimeout){
|
||||
//域控断连1分钟超时倒计时
|
||||
disconnectCountDown()
|
||||
//如果SSM或者冷启动倒计时已经启动则取消
|
||||
connectSSMTimer?.cancel()
|
||||
autopilotReadyTimer?.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,8 +101,12 @@ class ConnectionProcessView @JvmOverloads constructor(
|
||||
* HQ、M1 MAP350开始弃用,其他车型MAP360开始弃用
|
||||
*/
|
||||
override fun onAutopilotStatusRespByQuery(status: SystemStatusInfo.StatusInfo) {
|
||||
ssmConnectStatus = true
|
||||
autopilotReadyStatus = status.autoPilotReady
|
||||
//SSM连接成功
|
||||
connectSSMSuccess()
|
||||
//冷启动成功
|
||||
if(status.autoPilotReady){
|
||||
autopilotReady()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,17 +116,239 @@ class ConnectionProcessView @JvmOverloads constructor(
|
||||
* @param statusInf 数据
|
||||
*/
|
||||
override fun onSystemStatus(statusInf: SsmInfo.SsmStatusInf) {
|
||||
//SSM连接成功
|
||||
connectSSMSuccess()
|
||||
//冷启动成功
|
||||
if(statusInf.autoPilotReady){
|
||||
autopilotReady()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 域控连接成功
|
||||
*/
|
||||
private fun connectIPCSuccess(){
|
||||
if(!ipcConnectStatus){
|
||||
showIPCConnectSuccessView()
|
||||
//开始连接SSM超时等待倒计时
|
||||
connectSSMProcess()
|
||||
}
|
||||
ipcConnectStatus = true
|
||||
isFirstTimeConnect = false
|
||||
}
|
||||
|
||||
/**
|
||||
* SSM连接成功
|
||||
*/
|
||||
private fun connectSSMSuccess(){
|
||||
if(!ssmConnectStatus){
|
||||
showSSMConnectSuccessView()
|
||||
//取消连接SSM超时等待倒计时
|
||||
connectSSMTimer?.cancel()
|
||||
//开始启动冷启动等待倒计时
|
||||
autopilotReadyProcess()
|
||||
}
|
||||
ssmConnectStatus = true
|
||||
autopilotReadyStatus = statusInf.autoPilotReady
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 冷启动成功
|
||||
*/
|
||||
private fun autopilotReady(){
|
||||
if(!autopilotReadyStatus){
|
||||
showAutopilotReadySuccessView()
|
||||
//取消冷启动超时等待倒计时
|
||||
autopilotReadyTimer?.cancel()
|
||||
//开启3秒倒计时,隐藏连接过程视图
|
||||
dismissWaitingView()
|
||||
}
|
||||
autopilotReadyStatus = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示域控连接成功视图
|
||||
*/
|
||||
private fun showIPCConnectSuccessView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
this.visibility = View.VISIBLE
|
||||
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_progress_style)
|
||||
pbConnectionProgress.progress = 25
|
||||
tvConnectionStatus.text = "系统启动中..."
|
||||
clConnectionTip.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示SSM连接成功视图
|
||||
*/
|
||||
private fun showSSMConnectSuccessView(){
|
||||
ThreadUtils.runOnUiThread{
|
||||
this.visibility = View.VISIBLE
|
||||
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_progress_style)
|
||||
pbConnectionProgress.progress = 50
|
||||
tvConnectionStatus.text = "系统启动中..."
|
||||
clConnectionTip.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示冷启动成功视图
|
||||
*/
|
||||
private fun showConnectionSuccessView(){
|
||||
|
||||
private fun showAutopilotReadySuccessView(){
|
||||
ThreadUtils.runOnUiThread{
|
||||
this.visibility = View.VISIBLE
|
||||
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_success_style)
|
||||
pbConnectionProgress.progress = 100
|
||||
tvConnectionStatus.text = "系统启动成功"
|
||||
clConnectionTip.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示域控连接失败视图
|
||||
*/
|
||||
private fun showIPCConnectFailView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
this.visibility = View.VISIBLE
|
||||
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
|
||||
pbConnectionProgress.progress = 25
|
||||
tvConnectionStatus.text = "系统启动异常"
|
||||
clConnectionTip.visibility = View.VISIBLE
|
||||
tvConnectionTipTitle.text = "Telematics连接异常"
|
||||
tvConnectionTipContent.text = "建议重启车辆并上报问题"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示SSM连接失败视图
|
||||
*/
|
||||
private fun showSSMConnectFailView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
this.visibility = View.VISIBLE
|
||||
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
|
||||
pbConnectionProgress.progress = 50
|
||||
tvConnectionStatus.text = "系统启动异常"
|
||||
clConnectionTip.visibility = View.VISIBLE
|
||||
tvConnectionTipTitle.text = "SSM连接异常"
|
||||
tvConnectionTipContent.text = "建议重启车辆并上报问题"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示SSM冷启动失败视图
|
||||
*/
|
||||
private fun showAutopilotReadyFailView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
this.visibility = View.VISIBLE
|
||||
pbConnectionProgress.progressDrawable = ContextCompat.getDrawable(context, R.drawable.connection_fail_style)
|
||||
pbConnectionProgress.progress = 100
|
||||
tvConnectionStatus.text = "系统启动异常"
|
||||
clConnectionTip.visibility = View.VISIBLE
|
||||
tvConnectionTipTitle.text = "系统冷启动异常"
|
||||
tvConnectionTipContent.text = "建议重启车辆并上报问题"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新进度条进度
|
||||
*/
|
||||
private fun updateProcess(){
|
||||
currentProcess++
|
||||
pbConnectionProgress.progress = currentProcess
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示连接过程视图展示
|
||||
*/
|
||||
private fun showConnectionView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
this.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消连接过程视图展示
|
||||
*/
|
||||
private fun dismissConnectionView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
this.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消除连接过程视图
|
||||
*/
|
||||
private fun dismissWaitingView(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
dismissTimer = object: CountDownTimer(DISMISS_WAITING_TIME, DISMISS_WAITING_TIME){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
dismissConnectionView()
|
||||
}
|
||||
}
|
||||
dismissTimer?.start()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接SSM过程
|
||||
*/
|
||||
private fun connectSSMProcess(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
connectSSMTimer = object: CountDownTimer(LOAD_SSM_WAITING_TIME,12000){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
updateProcess()
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
//展示连接SSM失败视图
|
||||
showSSMConnectFailView()
|
||||
}
|
||||
}
|
||||
connectSSMTimer?.start()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 冷启动过程
|
||||
*/
|
||||
private fun autopilotReadyProcess(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
currentProcess = 50
|
||||
autopilotReadyTimer = object: CountDownTimer(AUTOPILOT_READY_WAITING_TIME,12000){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
updateProcess()
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
//展示冷启动失败视图
|
||||
showAutopilotReadyFailView()
|
||||
}
|
||||
}
|
||||
autopilotReadyTimer?.start()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 域控断连一分钟倒计时
|
||||
*/
|
||||
private fun disconnectCountDown(){
|
||||
ThreadUtils.runOnUiThread {
|
||||
disconnectTimer = object: CountDownTimer(RECONNECTION_TIME,RECONNECTION_TIME){
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
isDisconnectTimeout = true
|
||||
}
|
||||
}
|
||||
disconnectTimer?.start()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<!--缩放范围-->
|
||||
<scale android:scaleWidth="100%">
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_30"/>
|
||||
<corners android:radius="@dimen/dp_30" />
|
||||
<gradient
|
||||
android:startColor="#20AAFF"
|
||||
android:endColor="#004DFF"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
<shape>
|
||||
<corners android:radius="@dimen/dp_30"/>
|
||||
<gradient
|
||||
android:startColor="#00FF90"
|
||||
android:endColor="#1EAD57"
|
||||
android:startColor="#1EAD57"
|
||||
android:endColor="#00FF90"
|
||||
android:angle="0"/>
|
||||
</shape>
|
||||
</scale>
|
||||
|
||||
@@ -1,63 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="@dimen/dp_1003"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/pb_connection_progress"
|
||||
android:id="@+id/pbConnectionProgress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="@dimen/dp_1003"
|
||||
android:layout_height="@dimen/dp_60"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
android:progress="50"
|
||||
android:progress="25"
|
||||
android:paddingBottom="@dimen/dp_10"
|
||||
android:paddingStart="@dimen/dp_3"
|
||||
android:paddingEnd="@dimen/dp_3"
|
||||
android:background="@drawable/bg_connection_progress"
|
||||
android:progressDrawable="@drawable/connection_progress_style" />
|
||||
android:progressDrawable="@drawable/connection_progress_style"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_connection_status"
|
||||
android:id="@+id/tvConnectionStatus"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="@id/pb_connection_progress"
|
||||
app:layout_constraintRight_toRightOf="@id/pb_connection_progress"
|
||||
app:layout_constraintTop_toTopOf="@id/pb_connection_progress"
|
||||
app:layout_constraintBottom_toBottomOf="@id/pb_connection_progress"
|
||||
app:layout_constraintLeft_toLeftOf="@id/pbConnectionProgress"
|
||||
app:layout_constraintRight_toRightOf="@id/pbConnectionProgress"
|
||||
app:layout_constraintTop_toTopOf="@id/pbConnectionProgress"
|
||||
app:layout_constraintBottom_toBottomOf="@id/pbConnectionProgress"
|
||||
android:textSize="@dimen/sp_32"
|
||||
android:textColor="@color/white"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:paddingBottom="@dimen/dp_10"
|
||||
/>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_connection_tip"
|
||||
android:id="@+id/clConnectionTip"
|
||||
android:layout_width="@dimen/dp_600"
|
||||
android:layout_height="@dimen/dp_186"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/pb_connection_progress"
|
||||
app:layout_constraintBottom_toTopOf="@id/pbConnectionProgress"
|
||||
android:layout_marginBottom="@dimen/dp_10"
|
||||
android:background="@drawable/bg_connection_tip"
|
||||
>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_connection_tip"
|
||||
android:id="@+id/ivConnectionTip"
|
||||
android:layout_width="@dimen/dp_110"
|
||||
android:layout_height="@dimen/dp_110"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="@dimen/dp_33"
|
||||
android:layout_marginTop="@dimen/dp_40"
|
||||
android:layout_marginTop="@dimen/dp_28"
|
||||
android:src="@drawable/icon_connection_tip"
|
||||
android:scaleType="fitXY"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_connection_tip_title"
|
||||
android:id="@+id/tvConnectionTipTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_connection_tip"
|
||||
app:layout_constraintLeft_toRightOf="@id/iv_connection_tip"
|
||||
app:layout_constraintTop_toTopOf="@id/ivConnectionTip"
|
||||
app:layout_constraintLeft_toRightOf="@id/ivConnectionTip"
|
||||
android:layout_marginStart="@dimen/dp_28"
|
||||
android:textSize="@dimen/sp_40"
|
||||
android:textColor="@color/white"
|
||||
@@ -65,11 +70,12 @@
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_connection_tip_content"
|
||||
android:id="@+id/tvConnectionTipContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="@id/iv_connection_tip"
|
||||
app:layout_constraintLeft_toRightOf="@id/iv_connection_tip"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ivConnectionTip"
|
||||
app:layout_constraintLeft_toRightOf="@id/ivConnectionTip"
|
||||
android:layout_marginStart="@dimen/dp_28"
|
||||
android:textSize="@dimen/sp_32"
|
||||
android:textColor="@color/white"
|
||||
/>
|
||||
|
||||
@@ -61,6 +61,12 @@ open class AutopilotStatusInfo : Serializable, Cloneable {
|
||||
@Volatile
|
||||
var pilotmode = 0
|
||||
|
||||
/**
|
||||
* SSM冷启动是否成功 false不成功 true成功
|
||||
*/
|
||||
@Volatile
|
||||
var ssmAutoPilotReady = false
|
||||
|
||||
// 默认未连接
|
||||
@Volatile
|
||||
var ipcConnStatus = AdasConstants.IpcConnectionStatus.DISCONNECTED
|
||||
|
||||
Reference in New Issue
Block a user