[6.2.10][蘑方功能优化] 代码逻辑优化

This commit is contained in:
renwj
2024-02-07 17:23:02 +08:00
parent c31009bc76
commit bf6e86fa40
4 changed files with 71 additions and 25 deletions

View File

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