Revert "[MapDataUpdate]高精地图数据采集代码提交"

This reverts commit 5294dc9c
This commit is contained in:
renwj
2022-02-15 18:31:27 +08:00
parent 7f98695652
commit 0fc8034938
11 changed files with 4 additions and 325 deletions

View File

@@ -51,7 +51,7 @@ dependencies {
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.adasHigh
implementation rootProject.ext.dependencies.mogocustommapoperational
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
implementation rootProject.ext.dependencies.mogoserviceapi
implementation rootProject.ext.dependencies.modulecommon

View File

@@ -1,175 +0,0 @@
package com.mogo.eagle.core.function.impl.collect
import android.content.Context
import android.text.TextUtils
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.cloud.passport.IMoGoTokenCallback
import com.mogo.cloud.passport.MoGoAiCloudClient
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.zhidaoauto.map.operational.MapCollectionTaskRecive
import com.zhidaoauto.map.operational.abs.OnTaskListener
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.atomic.AtomicReference
@Route(path = MogoServicePaths.PATH_MAP_DATA_COLLECT_PROVIDER)
class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener, IMoGoMapLocationListener, IMoGoTokenCallback {
companion object {
const val TAG = "MoGoMapDataCollect"
}
private val executor by lazy {
AtomicReference<MapCollectionTaskRecive?>(null)
}
private val listeners by lazy {
CopyOnWriteArrayList<IMoGoMapDataCollectProvider.OnMapCollectCmdListener>()
}
private val map: MutableMap<Int, Status> by lazy {
ConcurrentHashMap()
}
override val functionName: String = TAG
override fun init(context: Context?) {
CallerMapLocationListenerManager.addListener(functionName, this)
executor.set(context?.let { MapCollectionTaskRecive(it) })
executor.get()?.setOnTaskListener(this)
val carSn = MoGoAiCloudClientConfig.getInstance().sn
if (!TextUtils.isEmpty(carSn)) {
executor.get()?.setCarSn(carSn)
}
MoGoAiCloudClient.getInstance().addTokenCallbacks(this)
Logger.d(TAG, "--------- init --------")
Logger.d(TAG, "executor: ${ executor.get()?.hashCode() ?: 0 }")
}
override fun onDestroy() {
CallerMapLocationListenerManager.removeListener(TAG)
Logger.d(TAG, "--------- onDestroy --------")
executor.get()?.let {
it.setOnTaskListener(null)
it.destory()
}
listeners.clear()
map.clear()
}
override fun registerOnMapCollectTaskListener(listener: IMoGoMapDataCollectProvider.OnMapCollectCmdListener?) {
Logger.d(TAG, "--------- registerOnMapCollectTaskListener --------")
listener ?: return
if (listeners.contains(listener)) {
return
}
listeners += listener
}
override fun unRegisterOnMapCollectTaskListener(listener: IMoGoMapDataCollectProvider.OnMapCollectCmdListener?) {
Logger.d(TAG, "--------- unRegisterOnMapCollectTaskListener --------")
listener ?: return
if (!listeners.contains(listener)) {
return
}
listeners.remove(listener)
}
override fun finish(
id: Int,
state: Int,
gpsPath: String,
videoPath: String,
reason: String
) {
Logger.d(TAG, "-- finish:[$id, $state, $gpsPath, $videoPath, $reason]")
try {
if (isInValidStatus()) {
Logger.w(TAG, "-- finish: 状态无效")
return
}
if (!map.containsKey(id)) {
Logger.w(TAG, "-- finish: 无相关指令")
return
}
Logger.d(TAG, "-- finish: 结束任务[$id]")
executor.get()?.finishTask(id, state, gpsPath, videoPath, reason)
} catch (e : Throwable) {
e.printStackTrace()
Logger.e(TAG, "-- finish:\n$e");
} finally {
map[id] = Status.FINISH
}
}
override fun onTaskFinish(id: Int, time: Long) {
Logger.d(TAG, "地图模块下发结束采集指令 -> [$id, $time]")
if (!map.containsKey(id) || map[id] == Status.FINISH) {
Logger.w(TAG, "地图模块下发结束采集指令 -> 任务[$id]已经提前完成,无需再次请求自动驾驶模块结束采集")
return
}
Logger.d(TAG, "地图模块下发结束采集指令 -> [$id, $time] -> 调用自动驾驶模块,结束数据采集")
listeners.forEach {
it.onMapCollectEnd(id, time)
}
}
override fun onTaskStart(id: Int, time: Long) {
Logger.d(TAG, "地图模块下发开始采集指令 -> [$id, $time]")
map[id] = Status.INIT
listeners.forEach {
it.onMapCollectStart(id, time)
}
map[id] = Status.START
}
override fun onLocationChanged(location: MogoLocation?) {
location ?: return
executor.get()?.onMapChange(
location.longitude,
location.latitude,
location.bearing,
location.speed,
location.provider == "GPS_SELF")
}
private fun isInValidStatus(): Boolean {
if (map.isEmpty()) {
return true
}
val iterator = map.iterator()
while (iterator.hasNext()) {
val next = iterator.next()
if (next.value == Status.FINISH) {
iterator.remove()
}
}
if (map.filter { it.value == Status.START }.isEmpty()) {
return true
}
return false
}
override fun onTokenGot(token: String?, sn: String?) {
Logger.d(TAG, "-- onTokenGot --> $sn")
sn?.let {
executor.get()?.setCarSn(it)
}
}
override fun onError(code: Int, msg: String?) = Unit
private sealed class Status {
object INIT : Status() //初始状态
object START : Status() //开始状态
object FINISH : Status() //完成状态
}
}