工控机docker重启逻辑完善和UI隐藏

完善了docker的重启逻辑,由于本期暂时不上该功能,故暂时把UI入口进行隐藏
This commit is contained in:
xuxinchao
2022-02-18 18:25:35 +08:00
parent 1e7266ec34
commit 2304b9708f
14 changed files with 272 additions and 20 deletions

View File

@@ -310,9 +310,16 @@ public class MoGoAdasListenerImpl implements OnAdasListener {
}
}
/**
* 命令返回结果
* @param info 结果返回实体
*/
@Override
public void onSSHResult(SSHResult info) {
if(info!=null && "docker restart autocar_default_1".equals(info.cmd)){
CallerHmiManager.INSTANCE.showDockerRebootResult(info.code, info.msg);
}else{
Logger.d(TAG,"onSSHResult : result info is null");
}
}
}

View File

@@ -342,6 +342,25 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
onBadCaseHide = onHide
}
/**
* 工控机重启返回结果
* @param code
* @param msg
*/
override fun showDockerRebootResult(code: Int, msg: String) {
ThreadUtils.runOnUiThread{
if(code>=-1){
//重启成功
ToastUtils.showShort("重启成功")
}else{
//重启失败
msg?.let {
ToastUtils.showShort(it)
}
}
}
}
private fun showBadCasesFloat(dismiss: (() -> Unit)?) {
Log.d("QQQ", "showBadCaseToolsFloat")
context?.let { it ->

View File

@@ -124,6 +124,7 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
fun showAdUpgradeStatus(upgradeMode: Int,downloadStatus : Int,currentProgress : Int,totalProgress : Int
,downloadVersion : String,upgradeStatus : Int){
systemVersionView?.showAdUpgradeStatus(upgradeMode,downloadStatus,currentProgress, totalProgress, downloadVersion, upgradeStatus)
checkSystemView?.setAdUpgradeStatus(downloadStatus, upgradeStatus)
}
override fun onAttachedToWindow() {

View File

@@ -0,0 +1,60 @@
package com.mogo.eagle.core.function.hmi.ui.tools
import android.content.Context
import android.widget.TextView
import androidx.lifecycle.LifecycleObserver
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.module.common.dialog.BaseFloatDialog
/**
* @author XuXinChao
* @description 重启自动驾驶docker确认对话框
* @since: 2022/2/17
*/
class DockerRebootDialog(context: Context): BaseFloatDialog(context), LifecycleObserver {
companion object {
const val TAG = "DockerRebootDialog"
}
private var rebootConfirm : TextView? = null
private var rebootCancel : TextView? = null
private var clickListener: ClickListener? = null
init{
setContentView(R.layout.dialog_docker_reboot)
setCanceledOnTouchOutside(true)
rebootConfirm=findViewById(R.id.tv_reboot_confirm)
rebootCancel=findViewById(R.id.tv_reboot_cancel)
rebootConfirm?.setOnClickListener{
Logger.i(TAG,"rebootConfirm click")
clickListener?.confirm()
dismiss()
}
rebootCancel?.setOnClickListener {
Logger.i(TAG,"rebootCancel click")
clickListener?.cancel()
dismiss()
}
}
fun setClickListener(clickListener: ClickListener) {
this.clickListener = clickListener
}
fun showUpgradeDialog(){
if(isShowing){
return
}
show()
}
interface ClickListener{
fun confirm()
fun cancel()
}
}

View File

@@ -6,11 +6,16 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import com.mogo.eagle.core.data.autopilot.AdUpgradeStateHelper
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
import com.mogo.eagle.core.function.hmi.ui.tools.DockerRebootDialog
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.ToastUtils
import kotlinx.android.synthetic.main.view_check_system.view.*
class CheckSystemView @JvmOverloads constructor(
@@ -23,7 +28,12 @@ class CheckSystemView @JvmOverloads constructor(
const val TAG = "CheckSystemView"
}
private var connectStatus = false
private var connectStatus = false //是否连接工控机
private var autopilotStatus:Int ?=null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中
private var dockerRebootDialog: DockerRebootDialog? = null
private var downloadStatus: Int=-1 //下载状态
private var upgradeStatus: Int=-1 //升级状态
init {
LayoutInflater.from(context).inflate(R.layout.view_check_system, this, true)
@@ -31,17 +41,45 @@ class CheckSystemView @JvmOverloads constructor(
}
private fun initView() {
//todo view状态注意消息回执
viewCheckShutDown.setOnClickListener {
//dialog
// showSystemOperationWindow()
}
viewCheckReboot.setOnClickListener {
//dialog
// showSystemOperationWindow()
if(dockerRebootDialog == null){
dockerRebootDialog = DockerRebootDialog(context)
dockerRebootDialog?.setClickListener(object : DockerRebootDialog.ClickListener{
override fun confirm() {
if(autopilotStatus==2){
//当前处于自动驾驶状态不可进行重启Toast提示
ToastUtils.showShort("请先退出自动驾驶状态")
}else if(AdUpgradeStateHelper.showCannotReboot(downloadStatus, upgradeStatus)){
//当工控机处于下载或者升级状态,需要先进行升级
ToastUtils.showShort("请先完成新自动驾驶系统的下载/升级")
} else{
//确认重启
Logger.i(TAG,"reboot confirm")
CallerAutoPilotManager.setIPCReboot()
}
}
override fun cancel() {
//取消重启
Logger.i(TAG,"reboot cancel")
}
})
}
dockerRebootDialog?.showUpgradeDialog()
}
}
fun setAdUpgradeStatus(downloadStatus : Int,upgradeStatus : Int){
this.downloadStatus=downloadStatus
this.upgradeStatus=upgradeStatus
}
private fun showSystemOperationWindow(view: View) {
WarningFloat.with(context).setGravity(Gravity.CENTER).setLayout(view)
.setImmersionStatusBar(true).show()
@@ -59,6 +97,7 @@ class CheckSystemView @JvmOverloads constructor(
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
connectStatus = autoPilotStatusInfo.connectStatus
autopilotStatus = autoPilotStatusInfo.state
setViewStatus()
}
@@ -72,6 +111,7 @@ class CheckSystemView @JvmOverloads constructor(
viewCheckShutDown.isClickable = false
viewCheckReboot.isClickable = false
}
}
}

View File

@@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="840px"
android:layout_height="584px"
android:background="@color/upgrade_dialog_bg_color"
android:background="@color/dialog_bg_color"
app:roundLayoutRadius="32px"
>

View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<com.mogo.eagle.core.widget.RoundConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="840px"
android:layout_height="470px"
android:background="@color/dialog_bg_color"
app:roundLayoutRadius="32px"
>
<TextView
android:id="@+id/tv_reboot_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/check_system_reboot_title"
android:textSize="56px"
android:textColor="#FFFFFFFF"
android:layout_marginTop="50px"
/>
<TextView
android:id="@+id/tv_reboot_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_reboot_title"
android:text="@string/check_system_reboot_tips"
android:textColor="#FFFFFFFF"
android:textSize="43px"
android:layout_marginTop="50px"
/>
<View
android:id="@+id/view_horizontal_line"
android:layout_width="match_parent"
android:layout_height="2px"
android:background="#66B8BFE8"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_reboot_tips"
android:layout_marginTop="80px"
/>
<View
android:id="@+id/view_vertical_line"
android:layout_width="3px"
android:layout_height="0dp"
android:background="#66B8BFE8"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/view_horizontal_line"
app:layout_constraintBottom_toBottomOf="parent"
/>
<TextView
android:id="@+id/tv_reboot_confirm"
android:layout_width="400px"
android:layout_height="100px"
android:text="@string/confirm"
android:textColor="#FFFFFFFF"
android:textSize="46px"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/view_horizontal_line"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@id/view_vertical_line"
/>
<TextView
android:id="@+id/tv_reboot_cancel"
android:layout_width="400px"
android:layout_height="100px"
android:text="@string/cancel"
android:textColor="#FFFFFFFF"
android:textSize="46px"
android:gravity="center"
app:layout_constraintTop_toBottomOf="@id/view_horizontal_line"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="@id/view_vertical_line"
app:layout_constraintRight_toRightOf="parent"
/>
</com.mogo.eagle.core.widget.RoundConstraintLayout>

View File

@@ -3,18 +3,20 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="960px"
android:layout_height="match_parent"
android:layout_height="2000px"
android:background="@color/notice_check_dialog_bg_color">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent">
<View
android:layout_width="14px"
@@ -145,7 +147,8 @@
android:layout_marginTop="94px"
android:background="@color/color_FF2966EC"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/llSpeedPosition" />
app:layout_constraintTop_toBottomOf="@id/llSpeedPosition"
android:visibility="gone"/>
<TextView
android:id="@+id/tvSystemOperation"
@@ -158,7 +161,8 @@
android:textColor="@color/color_FFFFFF"
android:textSize="42px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/llSpeedPosition" />
app:layout_constraintTop_toBottomOf="@id/llSpeedPosition"
android:visibility="gone"/>
<com.mogo.eagle.core.function.hmi.ui.widget.CheckSystemView
android:id="@+id/checkSystemView"
@@ -166,7 +170,8 @@
android:layout_height="wrap_content"
android:layout_marginTop="40px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSystemOperation" />
app:layout_constraintTop_toBottomOf="@id/tvSystemOperation"
android:visibility="gone"/>
<View
android:id="@+id/viewSystemVersion"
@@ -225,4 +230,5 @@
android:background="@drawable/icon_close_nor"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -14,7 +14,8 @@
android:src="@drawable/check_shut_down"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:visibility="gone"/>
<TextView
android:id="@+id/tvCheckShutDown"
@@ -27,13 +28,14 @@
android:textColor="@color/color_FFA7B6F0"
android:textSize="32px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/viewCheckShutDown" />
app:layout_constraintTop_toBottomOf="@id/viewCheckShutDown"
android:visibility="gone"/>
<ImageView
android:id="@+id/viewCheckReboot"
android:layout_width="150px"
android:layout_height="150px"
android:layout_marginStart="405px"
android:layout_marginStart="113px"
android:clickable="true"
android:src="@drawable/check_reboot"
app:layout_constraintLeft_toLeftOf="parent"
@@ -44,12 +46,13 @@
android:id="@+id/tvCheckReboot"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="448px"
android:layout_marginTop="23px"
android:gravity="center"
android:text="@string/check_system_reboot"
android:textColor="@color/color_FFA7B6F0"
android:textSize="32px"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/viewCheckShutDown" />
app:layout_constraintLeft_toLeftOf="@id/viewCheckReboot"
app:layout_constraintRight_toRightOf="@id/viewCheckReboot"
app:layout_constraintTop_toBottomOf="@id/viewCheckReboot" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -41,6 +41,6 @@
<color name="version_upgradeable_start_color">#029DFF</color>
<color name="version_upgradeable_end_color">#0056FF</color>
<color name="version_upgrading_color">#3B4577</color>
<color name="upgrade_dialog_bg_color">#3B4577</color>
<color name="dialog_bg_color">#3B4577</color>
</resources>

View File

@@ -25,6 +25,9 @@
<string name="check_system_operation">系统运行</string>
<string name="check_system_shut_down">关机</string>
<string name="check_system_reboot">重启</string>
<string name="check_system_reboot_title">重启提示</string>
<string name="check_system_reboot_tips">是否重启自动驾驶系统?</string>
<!--系统版本-->
<string name="check_system_version">系统版本</string>

View File

@@ -36,6 +36,15 @@ class AdUpgradeStateHelper {
return isDownloading(downloadStatus) || isDownloadFinish(downloadStatus,upgradeStatus) || getUpgradeStatus() || isUpgradeFailed(upgradeStatus)
}
/**
* 如果工控机处于升级、下载过程中,则不能进行重启
* @param downloadStatus 下载状态
* @param upgradeStatus 升级状态
*/
fun showCannotReboot(downloadStatus: Int,upgradeStatus: Int): Boolean{
return isDownloading(downloadStatus)|| isDownloadFinish(downloadStatus,upgradeStatus) || getUpgradeStatus()
}
/**
* 工控机是否处于“下载中”状态
* @param downloadStatus 下载状态

View File

@@ -187,4 +187,11 @@ interface IMoGoWaringProvider {
* [onHide]回调不用关心,可以不注册
*/
fun registerBadCaseCallback(onShow:() -> View, onHide: (() -> Unit)?)
/**
* 工控机重启返回结果
* @param code
* @param msg
*/
fun showDockerRebootResult(code: Int,msg: String)
}

View File

@@ -265,5 +265,14 @@ object CallerHmiManager : CallerBase() {
fun registerBadCaseCallback(onShow:() -> View, onHide: (() -> Unit)?) {
waringProviderApi?.registerBadCaseCallback(onShow, onHide)
}
/**
* 工控机重启返回结果
* @param code
* @param msg
*/
fun showDockerRebootResult(code: Int,msg: String){
waringProviderApi?.showDockerRebootResult(code, msg)
}
}