[6.2.10][蘑方功能优化] 代码逻辑优化
This commit is contained in:
@@ -49,8 +49,10 @@ import com.zhjt.mogo_core_function_devatools.mofang.MoFangAnalyticUtils.Companio
|
||||
import com.zhjt.mogo_core_function_devatools.mofang.MoFangAnalyticUtils.Companion.EVENT_EXECUTE_PARAMS_SPEED
|
||||
import com.zhjt.mogo_core_function_devatools.mofang.MoFangAnalyticUtils.Companion.EVENT_EXECUTE_PARAMS_TYPE
|
||||
import mogo_msg.MogoReportMsg
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
|
||||
internal class MoFangCommandExecutor {
|
||||
|
||||
@@ -72,8 +74,6 @@ internal class MoFangCommandExecutor {
|
||||
|
||||
private val autoPilotState by lazy { AtomicInteger(CallerAutoPilotStatusListenerManager.getState()) }
|
||||
|
||||
private val ipcConnectState by lazy { AtomicBoolean(CallerAutoPilotStatusListenerManager.isConnect()) }
|
||||
|
||||
fun setLinkedLog(log: MoFangLinkedLog) {
|
||||
this.linkedLog = log
|
||||
}
|
||||
@@ -127,14 +127,20 @@ internal class MoFangCommandExecutor {
|
||||
autoPilotState.set(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
Log.d(TAG, "收到工控机连接状态回调 -> status: $status, reason: $reason")
|
||||
val prev = ipcConnectState.get()
|
||||
val current = CallerAutoPilotStatusListenerManager.isConnect()
|
||||
if (!current && prev) {
|
||||
Log.d(TAG, "工控机连接断开了: -> status: $status, reason: $reason")
|
||||
private val prevTime by lazy { AtomicLong(0) }
|
||||
|
||||
private val handlerCallback = Handler.Callback { msg ->
|
||||
if (isRegister.compareAndSet(false, true)) {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, listener)
|
||||
}
|
||||
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
val current = SystemClock.elapsedRealtime()
|
||||
val last = prevTime.get()
|
||||
if (last == 0L || TimeUnit.MILLISECONDS.toSeconds(current - last) >= 30) {
|
||||
prevTime.set(current)
|
||||
CallerMsgBoxManager.saveMsgBox(MsgBoxBean(MsgBoxType.V2X, V2XMsg(
|
||||
EventTypeEnumNew.TYPE_IPC_DISCONNECT_FOR_MO_FANG.poiType,
|
||||
EventTypeEnumNew.TYPE_IPC_DISCONNECT_FOR_MO_FANG.content,
|
||||
@@ -142,14 +148,20 @@ internal class MoFangCommandExecutor {
|
||||
""
|
||||
)))
|
||||
}
|
||||
ipcConnectState.set(current)
|
||||
MoFangAnalyticUtils.track(EVENT_EXECUTE, mutableMapOf(
|
||||
EVENT_EXECUTE_PARAMS_KEYCODE to "disconnect",
|
||||
EVENT_EXECUTE_PARAMS_TYPE to -1,
|
||||
EVENT_EXECUTE_PARAMS_LON to -1.0,
|
||||
EVENT_EXECUTE_PARAMS_LAT to -1.0,
|
||||
EVENT_EXECUTE_PARAMS_SPEED to -1.0f,
|
||||
EVENT_EXECUTE_PARAMS_ACC to -1.0f,
|
||||
EVENT_EXECUTE_PARAMS_HEADING to -1.0,
|
||||
EVENT_EXECUTE_PARAMS_LINE_ID to -1L,
|
||||
EVENT_EXECUTE_PARAMS_DOCKER_VERSION to "-1")
|
||||
)
|
||||
return@Callback true
|
||||
}
|
||||
}
|
||||
|
||||
private val handlerCallback = Handler.Callback { msg ->
|
||||
if (isRegister.compareAndSet(false, true)) {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, listener)
|
||||
}
|
||||
val message = whatToString(msg.what, ", msg_info:[obj:${msg.obj}, arg1: ${msg.arg1}, arg2: ${msg.arg2}]")
|
||||
linkedLog?.record(mapOf("收到:${System.currentTimeMillis()}" to "$message"))
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.mogo.eagle.core.function.api.devatools.mofang.IMoGoMoFangProvider.OnM
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.tv_icon_1
|
||||
import kotlinx.android.synthetic.main.layout_mofang_status.view.tv_icon_2
|
||||
@@ -80,7 +81,10 @@ class MoFangStatusView : LinearLayout, OnMoFangStatusListener, IMoGoAutopilotSta
|
||||
Log.d(TAG, "收到工控机自驾状态回调 -> state: $state, last: $last")
|
||||
if (last != state) {
|
||||
if (last == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
reset()
|
||||
Log.d(TAG, "自驾改成非自驾,重置状态")
|
||||
UiThreadHandler.post {
|
||||
reset()
|
||||
}
|
||||
}
|
||||
autoPilotState.set(state)
|
||||
}
|
||||
@@ -89,6 +93,11 @@ class MoFangStatusView : LinearLayout, OnMoFangStatusListener, IMoGoAutopilotSta
|
||||
override fun onMoFangBatteryChanged(battery: Int) {}
|
||||
|
||||
override fun onMoFangClicked(keyCode: Int) {
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
ToastUtils.showShort("工控机连接异常,无法执行魔方命令")
|
||||
return
|
||||
}
|
||||
|
||||
if (keyCode == KeyEvent.KEYCODE_A) {
|
||||
if (tv_icon_2?.tag != 2 && tv_icon_2?.isSelected == true) {
|
||||
tv_icon_2?.isSelected = false
|
||||
@@ -159,6 +168,10 @@ class MoFangStatusView : LinearLayout, OnMoFangStatusListener, IMoGoAutopilotSta
|
||||
}
|
||||
|
||||
override fun onMoFangLongClicked(keyCode: Int) {
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
ToastUtils.showShort("工控机连接异常,无法执行魔方命令")
|
||||
return
|
||||
}
|
||||
if (keyCode == KeyEvent.KEYCODE_A) {
|
||||
if (tv_icon_2?.tag != 2 && tv_icon_2?.isSelected == true) {
|
||||
tv_icon_2?.isSelected = false
|
||||
@@ -202,6 +215,10 @@ class MoFangStatusView : LinearLayout, OnMoFangStatusListener, IMoGoAutopilotSta
|
||||
}
|
||||
|
||||
override fun onMoFangCombineClicked(vararg keyCodes: Int) {
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
ToastUtils.showShort("工控机连接异常,无法执行魔方命令")
|
||||
return
|
||||
}
|
||||
if (keyCodes.size != 2) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.view_blue_tooth.view.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
@@ -72,7 +73,7 @@ open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListen
|
||||
}
|
||||
|
||||
override fun onDisconnected() {
|
||||
post {
|
||||
UiThreadHandler.post {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_ipc_disconnected))
|
||||
}
|
||||
@@ -82,14 +83,14 @@ open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListen
|
||||
override fun onConnected(networkType: NetworkUtils.NetworkType?) {
|
||||
when(power.get()) {
|
||||
-1 -> {
|
||||
post {
|
||||
UiThreadHandler.post {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_low_power))
|
||||
}
|
||||
}
|
||||
}
|
||||
1 -> {
|
||||
post {
|
||||
UiThreadHandler.post {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_normal_power))
|
||||
}
|
||||
@@ -101,12 +102,27 @@ open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListen
|
||||
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
if (!CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
if (ivMoFangStatus?.tag == 0) {
|
||||
ivMoFangStatus?.tag = 1
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_ipc_disconnected))
|
||||
UiThreadHandler.post {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_ipc_disconnected))
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
ivMoFangStatus?.tag = 0
|
||||
UiThreadHandler.post {
|
||||
when(power.get()) {
|
||||
-1 -> {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_low_power))
|
||||
}
|
||||
}
|
||||
1 -> {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_normal_power))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +147,7 @@ open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListen
|
||||
if (CallerAutoPilotStatusListenerManager.isConnect()) {
|
||||
if (battery <= 30) {
|
||||
power.set(-1)
|
||||
post {
|
||||
UiThreadHandler.post {
|
||||
runCatching {
|
||||
val prev = prevTime.get()
|
||||
val current = SystemClock.elapsedRealtime()
|
||||
@@ -144,7 +160,7 @@ open class BlueToothView: LinearLayout, IMoGoMoFangProvider.OnMoFangStatusListen
|
||||
}
|
||||
} else {
|
||||
power.set(1)
|
||||
post {
|
||||
UiThreadHandler.post {
|
||||
runCatching {
|
||||
ivMoFangStatus?.background = (ContextCompat.getDrawable(context, R.drawable.icon_mofang_normal_power))
|
||||
}
|
||||
|
||||
@@ -1319,6 +1319,7 @@ enum class EventTypeEnumNew(
|
||||
TYPE_USECASE_ID_LCW.poiType -> TYPE_USECASE_ID_LCW.poiTypeSrcVr
|
||||
TYPE_USECASE_ID_EVW.poiType -> TYPE_USECASE_ID_EVW.poiTypeSrcVr
|
||||
TYPE_USECASE_ID_LTA.poiType -> TYPE_USECASE_ID_LTA.poiTypeSrcVr
|
||||
TYPE_IPC_DISCONNECT_FOR_MO_FANG.poiType -> TYPE_IPC_DISCONNECT_FOR_MO_FANG.poiTypeSrcVr
|
||||
else -> {
|
||||
R.drawable.icon_default
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user