diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt
index 8a6df5ac1d..c165e1244d 100644
--- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt
+++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt
@@ -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)
}
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ConnectionProcessView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ConnectionProcessView.kt
index 68309d846d..e9ead64430 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ConnectionProcessView.kt
+++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/ConnectionProcessView.kt
@@ -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()
+ }
+ }
}
\ No newline at end of file
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_error_style.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_fail_style.xml
similarity index 100%
rename from core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_error_style.xml
rename to core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_fail_style.xml
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_progress_style.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_progress_style.xml
index 31733610a2..ddb1f746d8 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_progress_style.xml
+++ b/core/function-impl/mogo-core-function-hmi/src/main/res/drawable/connection_progress_style.xml
@@ -5,7 +5,7 @@
-
+
diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_connection_process.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_connection_process.xml
index d9d926fa9b..56254574dd 100644
--- a/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_connection_process.xml
+++ b/core/function-impl/mogo-core-function-hmi/src/main/res/layout/view_connection_process.xml
@@ -1,63 +1,68 @@
+ android:progressDrawable="@drawable/connection_progress_style"
+ />
diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt
index 3a3b6d3e5d..8de1893862 100644
--- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt
+++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt
@@ -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