[6.4.0][启自驾指引] 优化轨迹下载状态展示逻辑
This commit is contained in:
@@ -245,12 +245,13 @@ internal class MoFangCommandExecutor {
|
||||
linkedLog?.record(mapOf("执行:${System.currentTimeMillis()}" to "$message, $json"))
|
||||
Log.d(TAG, "--- 启动自驾 ----入参:$json")
|
||||
//清扫车有FSM模块,魔方启动自驾时需要将Source修改为魔方,以便telamatics做区分并在转发时增加flag标记
|
||||
if (AppIdentityModeUtils.isSweeper(FunctionBuildConfig.appIdentityMode)) {
|
||||
CallerAutoPilotControlManager.startAutoPilotByMoFang(parameters)
|
||||
} else{
|
||||
CallerAutoPilotControlManager.startAutoPilot(parameters)
|
||||
if (CallerAutoPilotControlManager.isCanStartAutopilot(true)) {
|
||||
if (AppIdentityModeUtils.isSweeper(FunctionBuildConfig.appIdentityMode)) {
|
||||
CallerAutoPilotControlManager.startAutoPilotByMoFang(parameters)
|
||||
} else{
|
||||
CallerAutoPilotControlManager.startAutoPilot(parameters)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
Log.e(TAG, "error: ${t.message}, msg-> $msg")
|
||||
|
||||
@@ -3,8 +3,10 @@ package com.zhjt.mogo_core_function_devatools.status.flow.autopilot
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters.AutoPilotLine
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo.adas.data.AdasConstants
|
||||
import com.zhjt.mogo.adas.data.bean.MogoReport
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteDownloadStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteComplete
|
||||
@@ -24,11 +26,17 @@ internal class RouteDownloadImpl(ctx: Context) : IFlow<RouteDownloadStatus>(ctx)
|
||||
private const val TAG = "RouteDownloadImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var toDownloadLineId: Long? = null
|
||||
|
||||
private val extra by lazy { ConcurrentSkipListMap<Int, Any>() }
|
||||
|
||||
@Volatile
|
||||
private var isTriggerDownloadAgain: Boolean = false
|
||||
|
||||
@Volatile
|
||||
private var toDownloadLineInfo: AutoPilotLine? = null
|
||||
|
||||
@Volatile
|
||||
private var isTriggerDownloadByMe = false
|
||||
|
||||
override fun onCreate() {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
@@ -42,27 +50,52 @@ internal class RouteDownloadImpl(ctx: Context) : IFlow<RouteDownloadStatus>(ctx)
|
||||
super.onAutopilotStatusResponse(state)
|
||||
Logger.d(TAG, "--- onAutopilotStatusResponse -- 1 --: $state")
|
||||
if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) {
|
||||
val lineId = toDownloadLineId
|
||||
Logger.d(TAG, "--- onAutopilotStatusResponse -- 2 --: $lineId")
|
||||
if (lineId != null && lineId >= 0) {
|
||||
val info = toDownloadLineInfo
|
||||
Logger.d(TAG, "--- onAutopilotStatusResponse -- 2 --: $info")
|
||||
if (info != null) {
|
||||
extra.clear()
|
||||
send(RouteDownloadStatus(lineId, RouteComplete))
|
||||
toDownloadLineId = null
|
||||
send(RouteDownloadStatus(info.lineId, RouteComplete))
|
||||
toDownloadLineInfo = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotIpcConnectStatusChanged(
|
||||
status: AdasConstants.IpcConnectionStatus,
|
||||
reason: String?
|
||||
) {
|
||||
super.onAutopilotIpcConnectStatusChanged(status, reason)
|
||||
val info = toDownloadLineInfo
|
||||
val isConnected = CallerAutoPilotStatusListenerManager.isConnect()
|
||||
if (!isConnected && info != null && !isTriggerDownloadAgain) {
|
||||
Logger.d(TAG, "工控机断开了,但是轨迹未下载完成, 等待重新连接后,再次发送轨迹下载请求...")
|
||||
isTriggerDownloadAgain = true
|
||||
}
|
||||
|
||||
if (isConnected && isTriggerDownloadAgain && info != null) {
|
||||
Logger.d(TAG, "工控机连上了,重新发送下载请求, 用以更新下载状态...")
|
||||
isTriggerDownloadAgain = false
|
||||
isTriggerDownloadByMe = true
|
||||
CallerAutoPilotControlManager.sendTrajectoryDownloadReq(info)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotTrajectoryDownloadReq(autoPilotLine: AutoPilotLine, downloadType: Int) {
|
||||
super.onAutopilotTrajectoryDownloadReq(autoPilotLine, downloadType)
|
||||
Logger.d(TAG, "--- onAutopilotTrajectoryDownloadReq --: 1:$autoPilotLine, 2:$downloadType")
|
||||
val lineId = autoPilotLine.lineId
|
||||
if (downloadType == 0 && lineId >= 0) {
|
||||
val info = autoPilotLine.deepCopy()
|
||||
toDownloadLineInfo = info
|
||||
extra.clear()
|
||||
extra[0] = lineId to System.currentTimeMillis()
|
||||
toDownloadLineId = lineId
|
||||
send(RouteDownloadStatus(lineId = lineId, state = RouteNone).also {
|
||||
it.rawData = extra
|
||||
})
|
||||
extra[0] = info.lineId to info
|
||||
if (!isTriggerDownloadByMe) {
|
||||
send(RouteDownloadStatus(lineId = lineId, state = RouteNone).also {
|
||||
it.rawData = extra
|
||||
})
|
||||
} else {
|
||||
isTriggerDownloadByMe = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,37 +130,40 @@ internal class RouteDownloadImpl(ctx: Context) : IFlow<RouteDownloadStatus>(ctx)
|
||||
} catch (ignore: Exception) {
|
||||
}
|
||||
}
|
||||
extra[1] = lineId to "${System.currentTimeMillis()} => ($code,$toDownloadLineId)"
|
||||
Logger.d(
|
||||
TAG,
|
||||
"--- onAutopilotGuardian -- 3 --:lineId => $toDownloadLineId, parse_line_id: $lineId"
|
||||
)
|
||||
if (toDownloadLineId != lineId) {
|
||||
val info = toDownloadLineInfo
|
||||
extra[1] = lineId to info
|
||||
Logger.d(TAG, "--- onAutopilotGuardian -- 3 --:lineId => ${info?.lineId}, parse_line_id: $lineId")
|
||||
if (info?.lineId != lineId) {
|
||||
return
|
||||
}
|
||||
Logger.d(
|
||||
TAG,
|
||||
"--- onAutopilotGuardian -- 4 --:line_id => $lineId, code: ${guardianInfo.code}"
|
||||
)
|
||||
Logger.d(TAG, "--- onAutopilotGuardian -- 4 --:line_id => $lineId, code: ${guardianInfo.code}")
|
||||
when (code) {
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START -> { // 1. 轨迹管理_轨迹开始下载(本地已有对应轨迹也触发)
|
||||
extra[2] = lineId to System.currentTimeMillis()
|
||||
extra[2] = lineId to info
|
||||
send(RouteDownloadStatus(lineId, RouteStart).also { it.rawData = extra })
|
||||
}
|
||||
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING,
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS -> { // 2. 轨迹管理_轨迹下载成功(本地已有对应轨迹也触发)
|
||||
extra[3] = lineId to System.currentTimeMillis()
|
||||
if (code == MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING) {
|
||||
extra[3] = lineId to info
|
||||
} else {
|
||||
extra[4] = lineId to info
|
||||
}
|
||||
send(RouteDownloadStatus(lineId, RouteComplete).also { it.rawData = extra })
|
||||
toDownloadLineId = null
|
||||
toDownloadLineInfo = null
|
||||
}
|
||||
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE,
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING,
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_TIMEOUT -> {
|
||||
// 3. 轨迹管理_轨迹下载失败,本地无对应轨迹
|
||||
extra[4] = lineId to System.currentTimeMillis()
|
||||
if (code == MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE) {
|
||||
extra[5] = lineId to info
|
||||
} else {
|
||||
extra[6] = lineId to info
|
||||
}
|
||||
send(RouteDownloadStatus(lineId, RouteFailed).also { it.rawData = extra })
|
||||
toDownloadLineId = null
|
||||
toDownloadLineInfo = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,6 +192,9 @@ class AutopilotControlParameters {
|
||||
"timestamp_dpqp=$timestamp_dpqp)"
|
||||
}
|
||||
|
||||
fun deepCopy(): AutoPilotLine {
|
||||
return AutoPilotLine(this.lineId, this.lineName, this.trajUrl, this.trajMd5, this.stopUrl, this.stopMd5, this.timestamp, this.vehicleModel, this.trajUrl_dpqp, this.trajMd5_dpqp, this.stopUrl_dpqp, this.stopMd5_dpqp, this.timestamp_dpqp)
|
||||
}
|
||||
}
|
||||
|
||||
class AutoPilotLonLat {
|
||||
|
||||
Reference in New Issue
Block a user