Merge branch 'dev_robotaxi-d_240401_6.4.0' into dev_robotaxi-d_240401_6.4.0_work_order
@@ -40,6 +40,7 @@ import com.tencent.matrix.trace.config.TraceConfig
|
||||
import com.zhjt.mogo_core_function_devatools.apm.*
|
||||
import com.mogo.eagle.core.function.api.upgrade.*
|
||||
import com.mogo.weak.network.SdtManager
|
||||
import com.zhjt.mogo.adas.data.bean.ReceivedAck.Status
|
||||
import com.zhjt.mogo_core_function_devatools.adas.PowerOffManager
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.BadCaseManager
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
@@ -60,6 +61,8 @@ import com.zhjt.mogo_core_function_devatools.perf.MoGoCpuUsageProviderImpl
|
||||
import com.zhjt.mogo_core_function_devatools.report.IPCReportManager.Companion.iPCReportManager
|
||||
import com.zhjt.mogo_core_function_devatools.scene.SceneManager.Companion.sceneManager
|
||||
import com.zhjt.mogo_core_function_devatools.status.StatusManager
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteDownloadStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.ui.AutoPilotLaunchBeforeView
|
||||
import com.zhjt.mogo_core_function_devatools.strict.*
|
||||
import com.zhjt.mogo_core_function_devatools.trace.TraceManager.Companion.traceManager
|
||||
import com.zhjt.mogo_core_function_devatools.tts.TtsManager.Companion.ttsManager
|
||||
@@ -67,6 +70,9 @@ import com.zhjt.mogo_core_function_devatools.upgrade.UpgradeManager.Companion.up
|
||||
import com.zhjt.mogo_core_function_devatools.weaknetwork.DetectResultImpl
|
||||
import com.zhjt.mogo_core_function_devatools.weaknetwork.WeakNetworkStrategy
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_DEVA_TOOLS)
|
||||
class DevaToolsProvider : IDevaToolsProvider {
|
||||
@@ -81,7 +87,6 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
|
||||
private val strictModeProvider by lazy { StrictModeProviderImpl() }
|
||||
|
||||
|
||||
private val lookAroundDataProvider by lazy { MoGoLookAroundProviderImpl() }
|
||||
|
||||
private val mofangProvider by lazy { MoGoMoFangProviderImpl() }
|
||||
@@ -95,6 +100,22 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
@Volatile
|
||||
private var mDockerVersion: String? = null
|
||||
|
||||
private var container: WeakReference<ViewGroup>? = null
|
||||
|
||||
private val downloadCallbacks by lazy { ConcurrentHashMap<String, ArrayList<(Int) -> Unit>>() }
|
||||
|
||||
private val statusListener by lazy {
|
||||
object : StatusManager.IStatusListener {
|
||||
override fun onStatusChanged(data: List<com.zhjt.mogo_core_function_devatools.status.entity.Status>, hasException: Boolean) {
|
||||
data.filterIsInstance(RouteDownloadStatus::class.java).forEach { s ->
|
||||
downloadCallbacks.values.flatten().forEach { listener ->
|
||||
listener.invoke(s.state.ordinal)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun init(context: Context) {
|
||||
mContext = context
|
||||
}
|
||||
@@ -135,6 +156,7 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
block.init(it)
|
||||
block.start()
|
||||
}
|
||||
StatusManager.addListener(TAG, statusListener)
|
||||
}
|
||||
|
||||
override fun checkMonitorDb() {
|
||||
@@ -483,4 +505,29 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
override fun setNetworkMode(isDebug: Boolean) {
|
||||
WeakNetworkStrategy.setDebug(isDebug)
|
||||
}
|
||||
|
||||
override fun attachAutopilotStatusView(ctx: Context, group: ViewGroup) {
|
||||
StatusManager.init(ctx)
|
||||
if (group.childCount > 0) {
|
||||
if (group.visibility != View.VISIBLE) {
|
||||
group.visibility = View.VISIBLE
|
||||
}
|
||||
return
|
||||
}
|
||||
this.container = WeakReference(group)
|
||||
val child = AutoPilotLaunchBeforeView(ctx)
|
||||
group.addView(child, ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
|
||||
}
|
||||
|
||||
override fun getExceptionStatusBeforeLaunchAutopilot(): Int {
|
||||
return StatusManager.getExceptionStatusBeforeLaunchAutopilot()
|
||||
}
|
||||
|
||||
override fun registerRouteDownloadListener(tag: String, block: (state: Int) -> Unit) {
|
||||
downloadCallbacks.getOrPut(tag) { ArrayList() }.add(block)
|
||||
}
|
||||
|
||||
override fun unRegisterRouteDownloadListener(tag: String) {
|
||||
downloadCallbacks.remove(tag)
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import android.Manifest
|
||||
import android.content.*
|
||||
import android.content.pm.PackageManager.PERMISSION_GRANTED
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.os.Process
|
||||
import android.os.SystemClock
|
||||
import android.util.Log
|
||||
@@ -14,10 +15,13 @@ import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.core.log.record.*
|
||||
import com.mogo.core.log.record.config.*
|
||||
import com.mogo.core.log.record.config.crash.CrashConfig
|
||||
import com.mogo.core.log.record.config.extra.IExtraFileToUpload
|
||||
import com.mogo.core.log.record.config.extra.ToUploadFile
|
||||
import com.mogo.core.log.record.config.state.IStateProvider
|
||||
import com.mogo.core.log.record.model.UploadError
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.function.api.devatools.logcat.*
|
||||
import com.mogo.eagle.core.utilcode.download.DownloadUtils
|
||||
import com.zhidao.loglib.bean.RemoteLogPushContent
|
||||
import com.zhjt.mogo_core_function_devatools.BuildConfig
|
||||
import com.zhjt.mogo_core_function_devatools.logcat.checker.AnrLogChecker
|
||||
@@ -25,6 +29,7 @@ import com.zhjt.mogo_core_function_devatools.logcat.config.LogRecordConfig
|
||||
import com.zhjt.mogo_core_function_devatools.logcat.uploader.*
|
||||
import kotlinx.coroutines.*
|
||||
import java.io.*
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeUnit.MINUTES
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicLong
|
||||
@@ -45,13 +50,12 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
|
||||
private val lastUploadTime by lazy { AtomicLong(0) }
|
||||
|
||||
override fun init(context: Context) {
|
||||
val zip = File(context.getExternalFilesDir(null), "logcat/zip")
|
||||
val builder = LogcatConfig.Builder().context(context)
|
||||
.recordPeriod(MINUTES.toMillis(5)) // 5分钟一个文件
|
||||
.maxSizeInLogDir((512 * 1024 * 1024).toLong()) // 512M最大容量
|
||||
.recordDir(File(context.getExternalFilesDir(null), "logcat"))
|
||||
.pid(Process.myPid())
|
||||
.generateZipDir(zip.absolutePath)
|
||||
.generateZipDir(File(context.getExternalFilesDir(null), "logcat/zip").absolutePath)
|
||||
.stateProvider(object : IStateProvider {
|
||||
override fun provide(divider: String?): Map<String, Any?> {
|
||||
return mutableMapOf<String, Any?>().also { itx ->
|
||||
@@ -104,6 +108,18 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
|
||||
itx["协议版本号"] = AppConfigInfo.protocolVersionNumber
|
||||
itx["${divider}-7"] = divider
|
||||
itx["角色"] = AppConfigInfo.role
|
||||
val downloads = try {
|
||||
DownloadUtils.getAllDownloadRecords()
|
||||
} catch (t: Throwable) {
|
||||
emptyList()
|
||||
}
|
||||
if (downloads.isNotEmpty()) {
|
||||
itx["${divider}-8"] = divider
|
||||
itx["下载汇总"] = "(${downloads.size})"
|
||||
downloads.forEach {
|
||||
itx[it.first] = "\n\r----------------------------------------------------------${it.second}\n\r"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -114,26 +130,26 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
|
||||
.systemTags("ActivityManager")
|
||||
.checker(AnrLogChecker())
|
||||
}
|
||||
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// builder.crashConfig(
|
||||
// CrashConfig.Builder()
|
||||
// .enabled(true)
|
||||
// .crashDir(File(context.getExternalFilesDir(null), "logcat/crash"))
|
||||
// .nativeCrash(true)
|
||||
// .anr(true)
|
||||
// .javaCrash(true)
|
||||
// .build()
|
||||
// )
|
||||
// }
|
||||
LogcatManager.init(builder)
|
||||
scope.launch {
|
||||
try {
|
||||
zip.takeIf { it.exists() }?.deleteRecursively()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
if (BuildConfig.DEBUG) {
|
||||
builder.crashConfig(
|
||||
CrashConfig.Builder()
|
||||
.enabled(true)
|
||||
.crashDir(File(context.getExternalFilesDir(null), "crash"))
|
||||
.expireDuration(TimeUnit.DAYS.toMillis(3))
|
||||
.javaCrash(true)
|
||||
.nativeCrash(true)
|
||||
.anr(true)
|
||||
.build()
|
||||
)
|
||||
}
|
||||
builder.extraFilesToUpload(object : IExtraFileToUpload {
|
||||
override fun filesToUpload(): List<ToUploadFile> {
|
||||
return ArrayList<ToUploadFile>().also {
|
||||
it.add(ToUploadFile(File(Environment.getExternalStorageDirectory(), "MLog")))
|
||||
}
|
||||
}
|
||||
})
|
||||
LogcatManager.init(builder)
|
||||
}
|
||||
|
||||
override fun target(): Class<RemoteLogPushContent> {
|
||||
@@ -195,8 +211,8 @@ internal class MoGoLogRecordProviderImpl: IMoGoLogRecordProvider,
|
||||
return LogcatManager.export()
|
||||
}
|
||||
|
||||
override fun upload(): Unit = runBlocking {
|
||||
val state = LogcatManager.upload(0, System.currentTimeMillis())
|
||||
override fun upload(startTime: Long, endTime: Long): Unit = runBlocking {
|
||||
val state = LogcatManager.upload(startTime, endTime)
|
||||
if (state is UploadError) {
|
||||
throw AssertionError(state.toString())
|
||||
}
|
||||
|
||||
@@ -19,10 +19,17 @@ import com.zhjt.mogo_core_function_devatools.status.entity.RTKStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.Status
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.*
|
||||
//import com.zhjt.mogo_core_function_devatools.status.entity.NetStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteStart //import com.zhjt.mogo_core_function_devatools.status.entity.NetStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.model.StatusModel
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.OverViewImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.AcceleratorImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.BrakeImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.DoubleFlashImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.GearImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.RouteDownloadImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.SpeedImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.SteerImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.can.CanImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.gps.GpsImpl
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.ipc.IpcImpl
|
||||
@@ -33,17 +40,24 @@ import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import java.lang.ref.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
|
||||
object StatusManager {
|
||||
|
||||
private const val TAG = "StatusManager"
|
||||
|
||||
private lateinit var model: StatusModel
|
||||
private var hasInit = false
|
||||
private val listeners by lazy { CopyOnWriteArrayList<IStatusListener>() }
|
||||
private val listeners by lazy { ConcurrentHashMap<String, IStatusListener>() }
|
||||
private var container: WeakReference<ViewGroup>? = null
|
||||
|
||||
private val last by lazy { AtomicReference<List<Status>>() }
|
||||
|
||||
private val dispatcher by lazy {
|
||||
ThreadPoolExecutor(1, 2, 1, TimeUnit.MINUTES, LinkedBlockingQueue(128), Executors.defaultThreadFactory(), DiscardOldestPolicy()).asCoroutineDispatcher() + CoroutineName("stats-manager-impl")
|
||||
}
|
||||
|
||||
private val flows: ArrayList<IFlow<out Status>> by lazy {
|
||||
ArrayList()
|
||||
}
|
||||
@@ -77,20 +91,54 @@ object StatusManager {
|
||||
is TracingStatus -> TracingImpl(ctx)
|
||||
is RTKStatus -> RTKImpl(ctx)
|
||||
is OverViewStatus -> OverViewImpl(ctx)
|
||||
is SteerStatus -> SteerImpl(ctx)
|
||||
is AcceleratorStatus -> AcceleratorImpl(ctx)
|
||||
is BrakeStatus -> BrakeImpl(ctx)
|
||||
is DoubleFlashStatus -> DoubleFlashImpl(ctx)
|
||||
is GearStatus -> GearImpl(ctx)
|
||||
is SpeedStatus -> SpeedImpl(ctx)
|
||||
is RouteDownloadStatus -> RouteDownloadImpl(ctx)
|
||||
}
|
||||
}.also { flows += it }
|
||||
for (f in flows) {
|
||||
ctx.lifeCycleScope.launch(Dispatchers.Default) {
|
||||
ctx.lifeCycleScope.launch(dispatcher) {
|
||||
f.asFlow().collect {
|
||||
model.update(it)
|
||||
}
|
||||
}
|
||||
f.onCreate()
|
||||
}
|
||||
|
||||
model.status.observe(ctx.lifeCycleOwner) {
|
||||
listeners.forEach { itx ->
|
||||
itx.onStatusChanged(it.second, it.first != null)
|
||||
ctx.lifeCycleScope.launch(dispatcher) {
|
||||
model.status.asFlow().collect {
|
||||
listeners.values.forEach { itx ->
|
||||
val current = it.second
|
||||
val previous = last.get()
|
||||
val changed = ArrayList<Status>()
|
||||
if (previous == null) {
|
||||
changed.addAll(current)
|
||||
} else {
|
||||
val l1 = current.size
|
||||
val l2 = previous.size
|
||||
var index = 0
|
||||
while (index < l1 && index < l2) {
|
||||
val d1 = current[index]
|
||||
val d2 = previous[index]
|
||||
if (d1 != d2) {
|
||||
changed += d1
|
||||
}
|
||||
index++
|
||||
}
|
||||
while (index < l1) {
|
||||
changed += current[index++]
|
||||
}
|
||||
}
|
||||
if (changed.isNotEmpty()) {
|
||||
withContext(Dispatchers.Main) {
|
||||
itx.onStatusChanged(changed, it.first != null)
|
||||
}
|
||||
}
|
||||
last.set(current)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,6 +168,39 @@ object StatusManager {
|
||||
flows.clear()
|
||||
}
|
||||
|
||||
fun addListener(tag: String, listener: IStatusListener) {
|
||||
if (listeners.containsKey(tag)) {
|
||||
return
|
||||
}
|
||||
listeners[tag] = listener
|
||||
}
|
||||
|
||||
fun removeListener(tag: String) {
|
||||
listeners.remove(tag)
|
||||
}
|
||||
|
||||
fun getExceptionStatusBeforeLaunchAutopilot(): Int {
|
||||
var ret = 0
|
||||
model.status.value?.second?.filter {
|
||||
it is IAutopilotPreLaunchStatus
|
||||
}?.forEachIndexed { index, status ->
|
||||
val shl = 1 shl index
|
||||
if (status.isException()) {
|
||||
ret = if (status is RouteDownloadStatus) {
|
||||
if (status.state == RouteStart) {
|
||||
ret or shl
|
||||
} else {
|
||||
ret or (shl shl 1)
|
||||
}
|
||||
} else {
|
||||
ret or shl
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
interface IStatusListener {
|
||||
fun onStatusChanged(data: List<Status>, hasException: Boolean)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.entity
|
||||
|
||||
import com.mogo.eagle.core.data.status.StatusSummaryEntity
|
||||
import com.mogo.eagle.core.function.api.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteFailed
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteNone
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteStart
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.*
|
||||
|
||||
@@ -250,7 +250,7 @@ class OverViewStatus(var hasException: Boolean = false): Status() {
|
||||
fun String.toState(msg: String?): Tracing? {
|
||||
val ss = msg?.split("|")
|
||||
var extra: Map<String, String>? = null
|
||||
if (ss != null && ss.isNotEmpty()) {
|
||||
if (!ss.isNullOrEmpty()) {
|
||||
val sb = StringBuilder()
|
||||
for (element in ss) {
|
||||
sb.append(element)
|
||||
@@ -290,3 +290,199 @@ fun String.toState(msg: String?): Tracing? {
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
interface IAutopilotPreLaunchStatus
|
||||
|
||||
/**
|
||||
* 速度
|
||||
*/
|
||||
data class SpeedStatus(val speed: Float): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 方向盘转角
|
||||
*/
|
||||
data class SteerStatus(val angle: Float, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return isError
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as SteerStatus
|
||||
|
||||
if (angle != other.angle) return false
|
||||
if (isError != other.isError) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = angle.hashCode()
|
||||
result = 31 * result + isError.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 油门
|
||||
*/
|
||||
data class AcceleratorStatus(val angle: Float, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return isError
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as AcceleratorStatus
|
||||
|
||||
if (angle != other.angle) return false
|
||||
if (isError != other.isError) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = angle.hashCode()
|
||||
result = 31 * result + isError.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 刹车
|
||||
*/
|
||||
data class BrakeStatus(val angle: Float, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return isError
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as BrakeStatus
|
||||
|
||||
if (angle != other.angle) return false
|
||||
if (isError != other.isError) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = angle.hashCode()
|
||||
result = 31 * result + isError.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 双闪
|
||||
*/
|
||||
data class DoubleFlashStatus(val type: Int, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return isError
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as DoubleFlashStatus
|
||||
|
||||
if (type != other.type) return false
|
||||
if (isError != other.isError) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = type
|
||||
result = 31 * result + isError.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 挡位
|
||||
*/
|
||||
data class GearStatus(val value: Int, var isError: Boolean = false): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return isError
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as GearStatus
|
||||
|
||||
if (value != other.value) return false
|
||||
if (isError != other.isError) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = value
|
||||
result = 31 * result + isError.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
enum class RouteState {
|
||||
RouteNone,
|
||||
RouteStart,
|
||||
RouteComplete,
|
||||
RouteFailed
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 轨迹下载状态
|
||||
*/
|
||||
data class RouteDownloadStatus(val lineId: Long = -1, val state: RouteState = RouteNone): Status(), IAutopilotPreLaunchStatus {
|
||||
|
||||
override fun isException(): Boolean {
|
||||
return state == RouteStart || state == RouteFailed
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as RouteDownloadStatus
|
||||
|
||||
if (lineId != other.lineId) return false
|
||||
if (state != other.state) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = lineId.hashCode()
|
||||
result = 31 * result + state.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.autopilot
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisThrottleStateListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisThrottleStateListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_THROTTLE
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
|
||||
internal class AcceleratorImpl(ctx: Context): IFlow<AcceleratorStatus>(ctx), IMoGoChassisThrottleStateListener, IMoGoAutopilotActionsListener {
|
||||
|
||||
|
||||
companion object {
|
||||
private const val TAG = "AcceleratorImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var last: Float? = null
|
||||
|
||||
@Volatile
|
||||
private var isError: Boolean = false
|
||||
|
||||
override fun onCreate() {
|
||||
CallerChassisThrottleStateListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotActionsListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
CallerChassisThrottleStateListenerManager.removeListener(TAG)
|
||||
CallerAutopilotActionsListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotThrottle(throttle: Float) {
|
||||
super.onAutopilotThrottle(throttle)
|
||||
if (last != throttle) {
|
||||
send(AcceleratorStatus(throttle, isError))
|
||||
last = throttle
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_THROTTLE } != null) {
|
||||
isError = true
|
||||
send(AcceleratorStatus(last ?: 0.0f, true))
|
||||
} else {
|
||||
isError = false
|
||||
send(AcceleratorStatus(last ?: 0.0f, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.autopilot
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisBrakeStateListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisBrakeStateListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_BRAKE
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_THROTTLE
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.BrakeStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.autopilot.AcceleratorImpl.Companion
|
||||
|
||||
internal class BrakeImpl(ctx: Context): IFlow<BrakeStatus>(ctx), IMoGoChassisBrakeStateListener, IMoGoAutopilotActionsListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "BrakeImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var last: Float = 0.0f
|
||||
|
||||
@Volatile
|
||||
private var isError: Boolean = false
|
||||
|
||||
override fun onCreate() {
|
||||
CallerChassisBrakeStateListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotActionsListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
CallerChassisBrakeStateListenerManager.removeListener(TAG)
|
||||
CallerAutopilotActionsListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotBrake(brake: Float) {
|
||||
super.onAutopilotBrake(brake)
|
||||
|
||||
if (last != brake) {
|
||||
send(BrakeStatus(brake, isError))
|
||||
last = brake
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_BRAKE } != null) {
|
||||
isError = true
|
||||
send(BrakeStatus(last, true))
|
||||
} else {
|
||||
isError = false
|
||||
send(BrakeStatus(last, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.autopilot
|
||||
|
||||
import android.content.Context
|
||||
import chassis.Chassis.LightSwitch
|
||||
import chassis.Chassis.LightSwitch.LIGHT_FLASH
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_HAZARD_LIGHTS
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_THROTTLE
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.DoubleFlashStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
|
||||
internal class DoubleFlashImpl(ctx: Context): IFlow<DoubleFlashStatus>(ctx), IMoGoChassisLamplightListener, IMoGoAutopilotActionsListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "DoubleFlashImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var isError: Boolean = false
|
||||
|
||||
override fun onCreate() {
|
||||
CallerChassisLamplightListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotActionsListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
CallerChassisLamplightListenerManager.removeListener(TAG)
|
||||
CallerAutopilotActionsListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotLightSwitchData(lightSwitch: LightSwitch?) {
|
||||
super.onAutopilotLightSwitchData(lightSwitch)
|
||||
Logger.d(TAG, "-- onAutopilotLightSwitchData --: $lightSwitch")
|
||||
if (lightSwitch == LIGHT_FLASH) {
|
||||
send(DoubleFlashStatus(lightSwitch.number, isError))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_HAZARD_LIGHTS } != null) {
|
||||
isError = true
|
||||
send(DoubleFlashStatus(LIGHT_FLASH.number, true))
|
||||
} else {
|
||||
isError = false
|
||||
send(DoubleFlashStatus(LIGHT_FLASH.number, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.autopilot
|
||||
|
||||
import android.content.Context
|
||||
import chassis.Chassis.GearPosition
|
||||
import chassis.Chassis.GearPosition.GEAR_NONE
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGearStateListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGearStateListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_GEAR
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.GearStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
|
||||
internal class GearImpl(ctx: Context): IFlow<GearStatus>(ctx), IMoGoChassisGearStateListener, IMoGoAutopilotActionsListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "GeerImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var last: GearPosition = GEAR_NONE
|
||||
|
||||
@Volatile
|
||||
private var isError: Boolean = false
|
||||
|
||||
override fun onCreate() {
|
||||
CallerChassisGearStateListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotActionsListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
CallerChassisGearStateListenerManager.removeListener(TAG)
|
||||
CallerAutopilotActionsListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotGearData(gear: GearPosition) {
|
||||
if (last != gear) {
|
||||
send(GearStatus(gear.number, isError))
|
||||
last = gear
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_GEAR } != null) {
|
||||
isError = true
|
||||
send(GearStatus(last.number, true))
|
||||
} else {
|
||||
isError = false
|
||||
send(GearStatus(last.number, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
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.CallerAutoPilotStatusListenerManager
|
||||
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
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteFailed
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.RouteState.RouteStart
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
import mogo_msg.MogoReportMsg.MogoReportMessage
|
||||
import java.lang.Exception
|
||||
|
||||
|
||||
internal class RouteDownloadImpl(ctx: Context): IFlow<RouteDownloadStatus>(ctx), IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "RouteDownloadImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var toDownloadLineId: Long = Long.MIN_VALUE
|
||||
|
||||
override fun onCreate() {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotTrajectoryDownloadReq(autoPilotLine: AutoPilotLine, downloadType: Int) {
|
||||
super.onAutopilotTrajectoryDownloadReq(autoPilotLine, downloadType)
|
||||
if (downloadType == 0) {
|
||||
toDownloadLineId = autoPilotLine.lineId
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
|
||||
super.onAutopilotGuardian(guardianInfo)
|
||||
var lineId = -1L
|
||||
if (MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_START == guardianInfo?.code ||
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_SUCCESS == guardianInfo?.code ||
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_FAILURE == guardianInfo?.code ||
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_WARNING == guardianInfo?.code ||
|
||||
MogoReport.Code.Info.ISYS.INIT_TRAJECTORY_TIMEOUT == guardianInfo?.code
|
||||
) {
|
||||
val msg = guardianInfo.msg
|
||||
try {
|
||||
val regex = Regex("lineid:(\\d+)")
|
||||
val matchResult = regex.find(msg)
|
||||
if (matchResult != null) {
|
||||
lineId = matchResult.groupValues[1].toLong()
|
||||
}
|
||||
} catch (ignore: Exception) { }
|
||||
if (lineId == -1L) {
|
||||
try {
|
||||
val regex = Regex("lineID=(\\d+)")
|
||||
val matchResult = regex.find(msg)
|
||||
if (matchResult != null) {
|
||||
lineId = matchResult.groupValues[1].toLong()
|
||||
}
|
||||
} catch (ignore: Exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
if (toDownloadLineId != lineId) {
|
||||
return
|
||||
}
|
||||
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters()
|
||||
if (guardianInfo == null || !guardianInfo.hasCode())
|
||||
return
|
||||
when (guardianInfo.code) {
|
||||
"ISYS_INIT_TRAJECTORY_START" -> { // 1. 轨迹管理_轨迹开始下载(本地已有对应轨迹也触发)
|
||||
send(RouteDownloadStatus(lineId, RouteStart))
|
||||
}
|
||||
"ISYS_INIT_TRAJECTORY_SUCCESS" -> { // 2. 轨迹管理_轨迹下载成功(本地已有对应轨迹也触发)
|
||||
send(RouteDownloadStatus(lineId, RouteComplete))
|
||||
toDownloadLineId = Long.MIN_VALUE
|
||||
}
|
||||
"ISYS_INIT_TRAJECTORY_FAILURE" -> { // 3. 轨迹管理_轨迹下载失败,本地无对应轨迹
|
||||
send(RouteDownloadStatus(lineId, RouteFailed))
|
||||
toDownloadLineId = Long.MIN_VALUE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.autopilot
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisThrottleStateListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisThrottleStateListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_THROTTLE
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.SpeedStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
|
||||
internal class SpeedImpl(ctx: Context): IFlow<SpeedStatus>(ctx), IMoGoChassisLocationGCJ02Listener {
|
||||
|
||||
|
||||
companion object {
|
||||
private const val TAG = "SpeedImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var last: Float? = null
|
||||
|
||||
override fun onCreate() {
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, 5, this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (last != mogoLocation?.gnssSpeed) {
|
||||
send(SpeedStatus(mogoLocation?.gnssSpeed ?: 0f))
|
||||
last = mogoLocation?.gnssSpeed
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.flow.autopilot
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisSteeringStateListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotActionsListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisSteeringStateListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchData
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason
|
||||
import com.zhjt.mogo.adas.data.bean.UnableLaunchReason.UnableType.CHASSIS_STEERING
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
|
||||
|
||||
internal class SteerImpl(ctx: Context): IFlow<SteerStatus>(ctx), IMoGoChassisSteeringStateListener, IMoGoAutopilotActionsListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "SteerImpl"
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var last: Float = 0f
|
||||
|
||||
override fun onCreate() {
|
||||
CallerChassisSteeringStateListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotActionsListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
CallerChassisSteeringStateListenerManager.removeListener(TAG)
|
||||
CallerAutopilotActionsListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onAutopilotSteeringData(steering: Float) {
|
||||
if (last != steering) {
|
||||
send(SteerStatus(steering))
|
||||
last = steering
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableLaunchData: UnableLaunchData?, unableAutopilotReasons: ArrayList<UnableLaunchReason>?) {
|
||||
Logger.d(TAG, "onAutopilotAbility->($isAutopilotAbility, $unableLaunchData, ${unableAutopilotReasons?.joinToString(",")}")
|
||||
if (!isAutopilotAbility && unableAutopilotReasons != null && unableAutopilotReasons.find { it.unableType == CHASSIS_STEERING } != null) {
|
||||
send(SteerStatus(last, true))
|
||||
} else {
|
||||
send(SteerStatus(last, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import androidx.lifecycle.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.*
|
||||
//import com.zhjt.mogo_core_function_devatools.status.entity.NetStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing.UNKNOWN
|
||||
import java.util.concurrent.atomic.*
|
||||
import kotlin.Pair
|
||||
|
||||
@@ -21,6 +20,13 @@ internal class StatusModel : ViewModel() {
|
||||
it += RTKStatus("", -1)
|
||||
// it += NetStatus(false)
|
||||
// it += GpsStatus(enabled = false, isGranted = false)
|
||||
it += SteerStatus(0.0f)
|
||||
it += AcceleratorStatus(0.0f)
|
||||
it += BrakeStatus(0.0f)
|
||||
it += DoubleFlashStatus(0)
|
||||
it += GearStatus(0)
|
||||
it += RouteDownloadStatus()
|
||||
it += SpeedStatus(0f)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.zhjt.mogo_core_function_devatools.status.ui
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import chassis.Chassis.GearPosition
|
||||
import chassis.Chassis.GearPosition.GEAR_D
|
||||
import chassis.Chassis.GearPosition.GEAR_N
|
||||
import chassis.Chassis.GearPosition.GEAR_NONE
|
||||
import chassis.Chassis.GearPosition.GEAR_P
|
||||
import chassis.Chassis.GearPosition.GEAR_R
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
import com.zhjt.mogo_core_function_devatools.status.StatusManager
|
||||
import com.zhjt.mogo_core_function_devatools.status.StatusManager.IStatusListener
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.AcceleratorStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.BrakeStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.DoubleFlashStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.GearStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotPreLaunchStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.SpeedStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.Status
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.SteerStatus
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.gear_d
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.gear_n
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.gear_p
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.gear_r
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_brake_or_accelerator
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_double_flash
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.iv_steer
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.speed
|
||||
import kotlinx.android.synthetic.main.layout_autopilot_launch_before.view.tv_brake_or_accelerator
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import kotlin.math.abs
|
||||
|
||||
class AutoPilotLaunchBeforeView: LinearLayout, IStatusListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "AutoPilotLaunchBeforeView"
|
||||
}
|
||||
|
||||
constructor(context: Context) : this(context, null)
|
||||
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
|
||||
LayoutInflater.from(context).inflate(R.layout.layout_autopilot_launch_before, this, true)
|
||||
background = ContextCompat.getDrawable(context, R.drawable.icon_bg_autopilot_status)
|
||||
setPadding(AutoSizeUtils.dp2px(context, 27f), AutoSizeUtils.dp2px(context, 33f), AutoSizeUtils.dp2px(context, 30f), AutoSizeUtils.dp2px(context, 30f))
|
||||
}
|
||||
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
StatusManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
StatusManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
override fun onStatusChanged(data: List<Status>, hasException: Boolean) {
|
||||
data.filter { it is IAutopilotPreLaunchStatus }.forEach { status ->
|
||||
val isError = status.isException() && CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().state != IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING
|
||||
when(status) {
|
||||
is GearStatus -> {
|
||||
val position = try { GearPosition.valueOf(status.value) } catch (ignore: Throwable) { GEAR_NONE }
|
||||
gear_n?.isEnabled = false
|
||||
gear_n?.isSelected = false
|
||||
gear_p?.isEnabled = false
|
||||
gear_p?.isSelected =false
|
||||
gear_r?.isEnabled = false
|
||||
gear_r?.isSelected = false
|
||||
gear_d?.isEnabled = false
|
||||
gear_d?.isSelected = false
|
||||
if (position != GEAR_NONE) {
|
||||
when(position) {
|
||||
GEAR_N -> if (isError) gear_n?.isEnabled = true else gear_n?.isSelected = true
|
||||
GEAR_R -> if (isError) gear_r?.isEnabled = true else gear_r?.isSelected = true
|
||||
GEAR_P -> if (isError) gear_p?.isEnabled = true else gear_p?.isSelected = true
|
||||
GEAR_D -> if (isError) gear_d?.isEnabled = true else gear_d?.isSelected = true
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
is AcceleratorStatus -> {
|
||||
val angle = status.angle
|
||||
iv_brake_or_accelerator?.isSelected = isError
|
||||
tv_brake_or_accelerator?.text = "a:${angle.toInt()}"
|
||||
}
|
||||
is BrakeStatus -> {
|
||||
val angle = status.angle
|
||||
iv_brake_or_accelerator?.isSelected = isError
|
||||
tv_brake_or_accelerator?.text = "a:-${angle.toInt()}"
|
||||
}
|
||||
is DoubleFlashStatus -> {
|
||||
iv_double_flash?.isSelected = isError
|
||||
}
|
||||
is SteerStatus -> {
|
||||
iv_steer?.isSelected = isError
|
||||
}
|
||||
is SpeedStatus -> {
|
||||
speed?.text = "${(abs(status.speed) * 3.6f).toInt()}"
|
||||
}
|
||||
else -> {
|
||||
Logger.d(TAG, "other state: $status")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import androidx.recyclerview.widget.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.rv.divider.*
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.IAutopilotPreLaunchStatus
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.Status
|
||||
import com.zhjt.mogo_core_function_devatools.status.model.StatusModel
|
||||
import com.zhjt.mogo_core_function_devatools.status.ui.adapter.StatusAdapter
|
||||
@@ -47,12 +48,13 @@ internal class StatusView(private val model: StatusModel, ctx: Context): Constra
|
||||
.horizontalInnerSpace(10.PX)
|
||||
.build()
|
||||
)
|
||||
val adapter = model.status.value?.let { data -> StatusAdapter(context, data.second) }?.also { adapter -> itx.adapter = adapter }
|
||||
val adapter = model.status.value?.let { data -> StatusAdapter(context, data.second.filter { it !is IAutopilotPreLaunchStatus }) }?.also { adapter -> itx.adapter = adapter }
|
||||
adapter?.let { _ ->
|
||||
model.status.observeForever(Observer<Pair<Status?, ArrayList<Status>>> { data ->
|
||||
val old = adapter.data
|
||||
val result = DiffUtil.calculateDiff(StatusDiffCallback(old, data.second))
|
||||
adapter.data = data.second
|
||||
val update = data.second.filter { it !is IAutopilotPreLaunchStatus }
|
||||
val result = DiffUtil.calculateDiff(StatusDiffCallback(old, update))
|
||||
adapter.data = update
|
||||
result.dispatchUpdatesTo(adapter)
|
||||
}.also { observer = it })
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus.Tracing
|
||||
import com.zhjt.mogo_core_function_devatools.status.ui.adapter.StatusAdapter.StatusViewHolder
|
||||
import me.jessyan.autosize.AutoSizeCompat
|
||||
|
||||
internal class StatusAdapter(val ctx: Context, var data: ArrayList<Status>): RecyclerView.Adapter<StatusViewHolder>() {
|
||||
internal class StatusAdapter(val ctx: Context, var data: List<Status>): RecyclerView.Adapter<StatusViewHolder>() {
|
||||
|
||||
companion object {
|
||||
const val TAG = "StatusAdapter"
|
||||
@@ -169,6 +169,9 @@ internal class StatusAdapter(val ctx: Context, var data: ArrayList<Status>): Rec
|
||||
is OverViewStatus -> {
|
||||
""
|
||||
}
|
||||
else -> {
|
||||
throw AssertionError()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.zhjt.mogo_core_function_devatools.status.ui.diff
|
||||
import androidx.recyclerview.widget.*
|
||||
import com.zhjt.mogo_core_function_devatools.status.entity.Status
|
||||
|
||||
internal class StatusDiffCallback(private val old: ArrayList<Status>, private val update: ArrayList<Status>): DiffUtil.Callback() {
|
||||
internal class StatusDiffCallback(private val old: List<Status>, private val update: List<Status>): DiffUtil.Callback() {
|
||||
|
||||
override fun getOldListSize(): Int = old.size
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:color="@color/white" android:state_selected="true" />
|
||||
<item android:color="#F73B3C" android:state_enabled="true" />
|
||||
<item android:color="#343C63" android:state_enabled="false"/>
|
||||
</selector>
|
||||
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 24 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 4.6 KiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_selected="true" android:drawable="@drawable/icon_brake_or_accelerator_red" />
|
||||
<item android:drawable="@drawable/icon_brake_or_accelerator_blue" />
|
||||
</selector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_selected="true" android:drawable="@drawable/icon_double_flash_red" />
|
||||
<item android:drawable="@drawable/icon_double_flash_blue" />
|
||||
</selector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_selected="true" android:drawable="@drawable/icon_steer_red" />
|
||||
<item android:drawable="@drawable/icon_steer_blue" />
|
||||
</selector>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid android:color="#141B47" />
|
||||
<corners android:radius="@dimen/dp_60" />
|
||||
</shape>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<color xmlns:android="http://schemas.android.com/apk/res/android" android:color="@color/white">
|
||||
|
||||
</color>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:parentTag="android.widget.LinearLayout"
|
||||
tools:layout_width="@dimen/dp_624"
|
||||
tools:layout_height="@dimen/dp_269"
|
||||
tools:orientation="horizontal"
|
||||
tools:background="@drawable/icon_bg_autopilot_status"
|
||||
tools:paddingTop="@dimen/dp_33"
|
||||
tools:paddingBottom="@dimen/dp_30"
|
||||
tools:paddingStart="@dimen/dp_27"
|
||||
tools:paddingEnd="@dimen/dp_30">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/speed_chart_parent"
|
||||
android:layout_width="@dimen/dp_184"
|
||||
android:layout_height="@dimen/dp_200"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/icon_bg_speed">
|
||||
<TextView
|
||||
android:id="@+id/speed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/dp_74"
|
||||
android:textColor="@color/white"
|
||||
tools:text="65"
|
||||
android:text="0"
|
||||
android:layout_marginBottom="@dimen/dp_2"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/dp_32"
|
||||
android:text="Km/h"
|
||||
android:textColor="@color/white"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="@dimen/dp_200"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingEnd="@dimen/dp_34">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginStart="@dimen/dp_34"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:background="@drawable/bg_geer_position"
|
||||
android:paddingStart="@dimen/dp_53"
|
||||
android:paddingEnd="@dimen/dp_53"
|
||||
android:paddingTop="@dimen/dp_6"
|
||||
android:paddingBottom="@dimen/dp_6">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gear_p"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="P"
|
||||
android:textSize="@dimen/dp_36"
|
||||
android:enabled="false"
|
||||
android:layout_marginEnd="@dimen/dp_32"
|
||||
android:textColor="@color/color_geer_position_selector"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gear_r"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="R"
|
||||
android:textSize="@dimen/dp_36"
|
||||
android:enabled="false"
|
||||
android:layout_marginEnd="@dimen/dp_32"
|
||||
android:textColor="@color/color_geer_position_selector"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gear_n"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="N"
|
||||
android:textSize="@dimen/dp_36"
|
||||
android:enabled="false"
|
||||
android:layout_marginEnd="@dimen/dp_32"
|
||||
android:textColor="@color/color_geer_position_selector"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gear_d"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="D"
|
||||
android:textSize="@dimen/dp_36"
|
||||
android:enabled="false"
|
||||
android:textColor="@color/color_geer_position_selector"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_34"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginTop="@dimen/dp_23">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_steer"
|
||||
android:layout_width="@dimen/dp_55"
|
||||
android:layout_height="@dimen/dp_55"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:src="@drawable/bg_autopilot_steer"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_double_flash"
|
||||
android:layout_width="@dimen/dp_55"
|
||||
android:layout_height="@dimen/dp_55"
|
||||
android:layout_marginEnd="@dimen/dp_20"
|
||||
android:src="@drawable/bg_autopilot_double_flash"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_brake_or_accelerator"
|
||||
android:layout_width="@dimen/dp_55"
|
||||
android:layout_height="@dimen/dp_55"
|
||||
android:src="@drawable/bg_autopilot_brake_or_accelerator"
|
||||
android:layout_marginEnd="@dimen/dp_14"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_brake_or_accelerator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/dp_34"
|
||||
android:layout_marginTop="-1dp"
|
||||
android:textColor="@color/white"
|
||||
android:text="a:-0.0"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||