[routing]

[fea]
[不设置站点 去下发轨迹]
This commit is contained in:
yangyakun
2025-05-26 16:36:26 +08:00
parent c284e8bf12
commit 1a0c7c8f91
3 changed files with 145 additions and 111 deletions

View File

@@ -176,6 +176,7 @@ class RoutingSelectModel : ViewModel() {
// Routing 从这里解析出经停信息,轨迹信息,并调用下载轨迹接口
LineManager.initAutopilotControlParametersFromContrai()?.let {
CallerLogger.d(TAG,"下发下载轨迹信息:${it}")
OchChainLogManager.writeChainLogRouting("[启自驾]","下发下载轨迹信息:${it}")
CallerAutoPilotControlManager.sendTrajectoryDownloadReq(it)
}
}

View File

@@ -43,7 +43,7 @@ import kotlin.properties.Delegates
* 订单中
*/
object LineManager : CallerBase<ILineCallback>() {
const val TAG = M_OCHCOMMON+"LineManager"
const val TAG = M_OCHCOMMON + "LineManager"
const val firstStationFirstStartAutopilotFlag = 0
const val middleStationFirstStartAutopilotFlag = 1
@@ -55,7 +55,7 @@ object LineManager : CallerBase<ILineCallback>() {
@JvmStatic
private var _lineInfos: LineInfo? = null
val lineInfos:LineInfo?
val lineInfos: LineInfo?
@JvmStatic
get() = _lineInfos
@@ -64,7 +64,7 @@ object LineManager : CallerBase<ILineCallback>() {
*/
@JvmStatic
private var _contraiInfo: ContraiInfo? = null
val contraiInfo:ContraiInfo?
val contraiInfo: ContraiInfo?
@JvmStatic
get() = _contraiInfo
@@ -97,9 +97,9 @@ object LineManager : CallerBase<ILineCallback>() {
* 2 中间站点触发
* 3 新的站点第一次启动自驾成功后
*/
var autopilotFlag : Int by Delegates.observable(firstStationFirstStartAutopilotFlag) { _, oldValue, newValue ->
if(oldValue!=newValue){
d(TAG,"autopilotFlag old=$oldValue new=$newValue")
var autopilotFlag: Int by Delegates.observable(firstStationFirstStartAutopilotFlag) { _, oldValue, newValue ->
if (oldValue != newValue) {
d(TAG, "autopilotFlag old=$oldValue new=$newValue")
}
}
@@ -114,23 +114,24 @@ object LineManager : CallerBase<ILineCallback>() {
CallerEagleBaseFunctionCall4OchManager.setOchAutopilotOrderId(newValue)
isFirstStartAutopilot = true
M_LISTENERS.forEach {
it.value.onAutopilotIdChange(oldValue,newValue)
it.value.onAutopilotIdChange(oldValue, newValue)
}
if(!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)&&
!AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)&&
if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) &&
!AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode) &&
!AppIdentityModeUtils.isScheduled(FunctionBuildConfig.appIdentityMode)
){
) {
val (start, end) = getStations()
if(start!=null&&end!=null){
val ochInfo = OchInfo(0, mutableListOf(start.toMogoLocation(), end.toMogoLocation()))
if (start != null && end != null) {
val ochInfo =
OchInfo(0, mutableListOf(start.toMogoLocation(), end.toMogoLocation()))
CallerDataCenterBizListener.invokeOchInfo(ochInfo)
OchChainLogManager.writeChainLogMap("向地图传参数", "参数信息:${ochInfo}")
d(TAG,"向地图传参数_参数信息:${ochInfo}")
}else{
d(TAG, "向地图传参数_参数信息:${ochInfo}")
} else {
val ochInfo = OchInfo(0, mutableListOf())
CallerDataCenterBizListener.invokeOchInfo(ochInfo)
OchChainLogManager.writeChainLogMap("向地图传参数", "参数信息:${ochInfo}")
d(TAG,"向地图传参数_参数信息:${ochInfo}")
d(TAG, "向地图传参数_参数信息:${ochInfo}")
}
}
}
@@ -166,9 +167,13 @@ object LineManager : CallerBase<ILineCallback>() {
* 在终点10m 范围内向地盘查询是否到站
* [com.mogo.och.bridge.autopilot.autopilot.OchAutoPilotStatusListenerManager.onAutoPilotStation]
*/
val token = CallerAutoPilotControlManager.sendSsmFuncQueryAutoPilotStation(teleOrderId)
OchChainLogManager.writeChainLogAutopilot("到站逻辑","距离站点:$distance 请求token$token")
d(TAG,"到站逻辑_距离站点$distance 请求token$token")
val token =
CallerAutoPilotControlManager.sendSsmFuncQueryAutoPilotStation(teleOrderId)
OchChainLogManager.writeChainLogAutopilot(
"到站逻辑",
"距离站点:$distance 请求token$token"
)
d(TAG, "到站逻辑_距离站点$distance 请求token$token")
}
}
}
@@ -187,7 +192,7 @@ object LineManager : CallerBase<ILineCallback>() {
}
}
fun searchAutopilotState(){
fun searchAutopilotState() {
CallerAutoPilotControlManager.sendSsmFuncQueryAutoPilotInfo()
}
@@ -195,10 +200,10 @@ object LineManager : CallerBase<ILineCallback>() {
* [searchAutopilotState] 方法请求的返回值
*/
fun invokeSetIsFirstAutopilot(orderId: String?, firstAutopilotFlag: Boolean, count: Int) {
if (this.teleOrderId==orderId){
if(count>=1){
if (this.teleOrderId == orderId) {
if (count >= 1) {
teleIsFirstStartAutopilot = false
}else{
} else {
teleIsFirstStartAutopilot = true
}
}
@@ -210,20 +215,23 @@ object LineManager : CallerBase<ILineCallback>() {
fun setStartAndEndStation(startStation: BusStationBean?, endStation: BusStationBean?) {
this.startStation = startStation
this.endStation = endStation
if(startStation==null||endStation==null){
if (startStation == null || endStation == null) {
clearAutopilotControlParameters()
}else {
} else {
setAutopilotControlParameters()
}
OchChainLogManager.writeChainLogAutopilot("自驾参数", "站点信息:${startStation}---${endStation}")
d(TAG,"自驾参数 设置站点_站点信息:${startStation}---${endStation}")
OchChainLogManager.writeChainLogAutopilot(
"自驾参数",
"站点信息:${startStation}---${endStation}"
)
d(TAG, "自驾参数 设置站点_站点信息:${startStation}---${endStation}")
}
fun setContraiInfo(contraiInfo: ContraiInfo?){
fun setContraiInfo(contraiInfo: ContraiInfo?) {
this._contraiInfo = contraiInfo
setAutopilotControlParameters()
OchChainLogManager.writeChainLogAutopilot("自驾参数", "轨迹信息:${contraiInfo}")
d(TAG,"自驾参数 设置轨迹_轨迹信息:${contraiInfo}")
d(TAG, "自驾参数 设置轨迹_轨迹信息:${contraiInfo}")
}
@JvmStatic
@@ -243,12 +251,12 @@ object LineManager : CallerBase<ILineCallback>() {
sb.append(it.value)
}
OchChainLogManager.writeChainLogAutopilot("设置线路", "$sb")
d(TAG,"自驾参数 设置线路_线路信息:${_lineInfos}_${sb}")
d(TAG, "自驾参数 设置线路_线路信息:${_lineInfos}_${sb}")
CallerEagleBaseFunctionCall4OchManager.updateOrderLine(sb.toString())
}
}
OchChainLogManager.writeChainLogAutopilot("设置线路", "线路信息:$_lineInfos")
d(TAG,"自驾参数 设置线路_线路信息:${_lineInfos}")
d(TAG, "自驾参数 设置线路_线路信息:${_lineInfos}")
}
fun getStations(): Pair<BusStationBean?, BusStationBean?> {
@@ -295,8 +303,8 @@ object LineManager : CallerBase<ILineCallback>() {
}
}
fun getLineInfo(function: (lineInfo: LineInfo) -> Unit){
_lineInfos?.let { line->
fun getLineInfo(function: (lineInfo: LineInfo) -> Unit) {
_lineInfos?.let { line ->
function.invoke(line)
return
}
@@ -312,7 +320,7 @@ object LineManager : CallerBase<ILineCallback>() {
}
}
private fun setAutopilotControlParameters(){
private fun setAutopilotControlParameters() {
getStationsWithLine { start, end, lineInfo ->
val parameters = initAutopilotControlParameters()
if (null == parameters) {
@@ -322,7 +330,7 @@ object LineManager : CallerBase<ILineCallback>() {
d(TAG, "AutopilotControlParameters is update.")
if (lineInfo.isFirstStation(start)) {
autopilotFlag = firstStationFirstStartAutopilotFlag
}else{
} else {
autopilotFlag = middleStationFirstStartAutopilotFlag
}
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(parameters)
@@ -333,14 +341,18 @@ object LineManager : CallerBase<ILineCallback>() {
val endStationLocation = MogoLocation()
endStationLocation.latitude = end.gcjLat
endStationLocation.longitude = end.gcjLon
TrajectoryAndDistanceManager.setStationPoint(startStationLocation, endStationLocation, lineInfo.lineId)
OchLocationManager.addGCJ02Listener(TAG,1, mMapLocationListener)
TrajectoryAndDistanceManager.setStationPoint(
startStationLocation,
endStationLocation,
lineInfo.lineId
)
OchLocationManager.addGCJ02Listener(TAG, 1, mMapLocationListener)
// 恢复启动自驾信息
searchAutopilotState()
}
}
private fun clearAutopilotControlParameters(){
private fun clearAutopilotControlParameters() {
CallerAutoPilotStatusListenerManager.updateAutopilotControlParameters(null)
TrajectoryAndDistanceManager.setStationPoint(null, null, null)
autopilotId = ""
@@ -381,20 +393,21 @@ object LineManager : CallerBase<ILineCallback>() {
fun initAutopilotControlParameters(): AutopilotControlParameters? {
var parameters: AutopilotControlParameters? = null
getStationsWithLine { start, end, lineInfo ->
this.autopilotId = "${lineInfo.lineId}_${start.siteId}_${end.siteId}_${lineInfo.orderId}"
this.autopilotId =
"${lineInfo.lineId}_${start.siteId}_${end.siteId}_${lineInfo.orderId}"
this.teleOrderId = lineInfo.genAutopilotId()
}
getStationsWithLineAndContrai { start, end, lineInfo, contrai ->
parameters = AutopilotControlParameters()
parameters?.routeID = lineInfo.lineId.toInt()
parameters?.routeName = lineInfo.lineName
parameters?.startName = start.name?:""
parameters?.endName = end.name?:""
parameters?.startName = start.name ?: ""
parameters?.endName = end.name ?: ""
parameters?.startLatLon = AutoPilotLonLat(start.lat, start.lon)
parameters?.endLatLon = AutoPilotLonLat(end.lat, end.lon)
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
parameters?.vehicleType = 9
}else{
} else {
parameters?.vehicleType = 10
}
parameters?.orderId = this.teleOrderId
@@ -419,20 +432,21 @@ object LineManager : CallerBase<ILineCallback>() {
)
}
if(endStation?.passPoints?.isNotEmpty() == true &&
endStation?.blackPoints?.isNotEmpty() == true){
if (endStation?.passPoints?.isNotEmpty() == true &&
endStation?.blackPoints?.isNotEmpty() == true
) {
val (wayLatLons, blackLatLons) = endStation!!.getWayBlackLatLons()
parameters?.wayLatLons = wayLatLons
parameters?.blackLatLons = blackLatLons
CallerLogger.d(TAG,"从站点获取经停点和禁行点")
}else{
CallerLogger.d(TAG, "从站点获取经停点和禁行点")
} else {
val (wayLatLons, blackLatLons) = contrai.getWayBlackLatLons()
parameters?.wayLatLons = wayLatLons
parameters?.blackLatLons = blackLatLons
CallerLogger.d(TAG,"从轨迹获取经停点和禁行点")
CallerLogger.d(TAG, "从轨迹获取经停点和禁行点")
}
}
CallerLogger.d(TAG,"${parameters?.wayLatLons}\n${parameters?.blackLatLons}")
CallerLogger.d(TAG, "${parameters?.wayLatLons}\n${parameters?.blackLatLons}")
if (parameters == null) {
ToastUtils.showShort("未设置起始或终点站点")
}
@@ -441,52 +455,56 @@ object LineManager : CallerBase<ILineCallback>() {
fun initAutopilotControlParametersFromContrai(): AutopilotControlParameters? {
var parameters: AutopilotControlParameters? = null
getStationsWithLine { start, end, lineInfo ->
this.autopilotId = "${lineInfo.lineId}_${start.siteId}_${end.siteId}_${lineInfo.orderId}"
this.teleOrderId = lineInfo.genAutopilotId()
}
getStationsWithLineAndContrai { start, end, lineInfo, contrai ->
parameters = AutopilotControlParameters()
parameters?.routeID = lineInfo.lineId.toInt()
parameters?.routeName = lineInfo.lineName
parameters?.startName = start.name?:""
parameters?.endName = end.name?:""
parameters?.startLatLon = AutoPilotLonLat(start.lat, start.lon)
parameters?.endLatLon = AutoPilotLonLat(end.lat, end.lon)
if(AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){
parameters?.vehicleType = 9
}else{
parameters?.vehicleType = 10
}
parameters?.orderId = this.teleOrderId
parameters?.firstStationFlag = autopilotFlag
parameters?.firstAutopilotFlag = teleIsFirstStartAutopilot
if (parameters?.autoPilotLine == null) {
parameters?.autoPilotLine = AutoPilotLine(
lineInfo.lineId,
lineInfo.lineName,
contrai.csvFileUrl,
contrai.csvFileMd5,
contrai.txtFileUrl,
contrai.txtFileMd5,
contrai.contrailSaveTime,
"",
"",
"",
"",
"",
0L
)
this.autopilotId = "${lineInfos?.lineId}_${startStation?.siteId}_${endStation?.siteId}_${lineInfos?.orderId}"
this.teleOrderId = lineInfos?.genAutopilotId() ?: ""
parameters = AutopilotControlParameters()
parameters.routeID = lineInfos?.lineId?.toInt()?:0
parameters.routeName = lineInfos?.lineName?:""
lineInfos?.siteInfos?.let {
if(it.size>=0){
parameters.startLatLon = AutoPilotLonLat(it.first().lat, it.first().lon)
parameters.endLatLon = AutoPilotLonLat(it[1].lat, it[1].lon)
parameters.startName = it.first().name ?: ""
parameters.endName = it[1].name ?: ""
}
val (wayLatLons, blackLatLons) = contrai.getWayBlackLatLons()
parameters?.wayLatLons = wayLatLons
parameters?.blackLatLons = blackLatLons
CallerLogger.d(TAG,"从轨迹获取经停点和禁行点")
}
if (parameters == null) {
ToastUtils.showShort("未设置起始或终点站点")
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
parameters.vehicleType = 9
} else {
parameters.vehicleType = 10
}
parameters.orderId = this.teleOrderId
parameters.firstStationFlag = autopilotFlag
parameters.firstAutopilotFlag = teleIsFirstStartAutopilot
if (parameters.autoPilotLine == null) {
parameters.autoPilotLine = AutoPilotLine(
lineInfos?.lineId?:0L,
lineInfos?.lineName?:"",
contraiInfo?.csvFileUrl?:"",
contraiInfo?.csvFileMd5?:"",
contraiInfo?.txtFileUrl?:"",
contraiInfo?.txtFileMd5?:"",
contraiInfo?.contrailSaveTime?:System.currentTimeMillis(),
"",
"",
"",
"",
"",
0L
)
}
if(contraiInfo!=null) {
val (wayLatLons, blackLatLons) = contraiInfo!!.getWayBlackLatLons()
parameters.wayLatLons = wayLatLons
parameters.blackLatLons = blackLatLons
}
CallerLogger.d(TAG, "从轨迹获取经停点和禁行点")
return parameters
}
@@ -494,13 +512,13 @@ object LineManager : CallerBase<ILineCallback>() {
// 启动自动驾驶
fun startAutopilot() {
if(startStation ==null|| endStation ==null){
if (startStation == null || endStation == null) {
ToastUtils.showShort("未设置起始或终点站点")
return
}
startStation?.let {
if(!it.isLeaving){
if (!it.isLeaving) {
ToastUtils.showShort("请滑动出发后再启动自驾")
return
}
@@ -516,10 +534,10 @@ object LineManager : CallerBase<ILineCallback>() {
OchAutopilotAnalytics.triggerClickStartAutopilotTime(System.currentTimeMillis())
//1、判断轨迹url是否可用
if(_contraiInfo ==null){
if (_contraiInfo == null) {
ToastUtils.showLong("无发布轨迹, 请发布后重试")
return
}else{
} else {
if (FunctionBuildConfig.isPassStartAutopilotCommand
&& TextUtils.isEmpty(_contraiInfo!!.csvFileUrl)
&& TextUtils.isEmpty(_contraiInfo!!.csvFileMd5)
@@ -552,7 +570,7 @@ object LineManager : CallerBase<ILineCallback>() {
return
}
triggerStartServiceEvent(false,0,"")
triggerStartServiceEvent(false, 0, "")
val parameters = initAutopilotControlParameters()
if (null == parameters) {
@@ -560,10 +578,11 @@ object LineManager : CallerBase<ILineCallback>() {
return
}
val sessionId = startAutoPilot(parameters)
val sessionId = startAutoPilot(parameters)
OchAutopilotAnalytics.triggerUpdateStartAutoPilotSessionId(sessionId)
d(TAG,
d(
TAG,
"行程日志-开启自动驾驶====" + GsonUtil.jsonFromObject(parameters)
+ " startLatLon=" + parameters.startName + "endLatLon=" + parameters.endName +
"isRestart = " + isFirstStartAutopilot
@@ -577,7 +596,7 @@ object LineManager : CallerBase<ILineCallback>() {
private fun triggerUnableStartAPReasonEvent() {
getStationsWithLine { start, end, line ->
OchAutopilotAnalytics.triggerUnableStartAPReasonEvent(
start.name?:"", end.name?:"",line.lineId.toString() , "",
start.name ?: "", end.name ?: "", line.lineId.toString(), "",
OCHAdasAbilityManager.getInstance().autopilotUnAbilityReason
)
}
@@ -588,32 +607,32 @@ object LineManager : CallerBase<ILineCallback>() {
* 1: 通过can消息发送自驾状态确定启动自驾成功
* 2通过FSM 反馈确定启动自驾成功
*/
fun triggerStartServiceEvent(send: Boolean,source:Int,type:String) {
fun triggerStartServiceEvent(send: Boolean, source: Int, type: String) {
getStationsWithLine { start, end, lineInfo ->
OchAutopilotAnalytics.triggerStartAutopilotEvent(
isFirstStartAutopilot,
send,
start.name?:"",
end.name?:"",
start.name ?: "",
end.name ?: "",
lineInfo.lineId.toInt(),
"",
System.currentTimeMillis(),
type,
source
)
if(send){// 启动自驾成功回调
if (send) {// 启动自驾成功回调
teleIsFirstStartAutopilot = false
isFirstStartAutopilot = false
autopilotFlag = norFirstStartAutopilotFlag
M_LISTENERS.forEach {
it.value.startAutopilotSuccess(source,autopilotId)
it.value.startAutopilotSuccess(source, autopilotId)
}
}
}
}
@JvmStatic
fun invokeStartAutopilotTimeOut(){
fun invokeStartAutopilotTimeOut() {
M_LISTENERS.forEach {
it.value.startAutopilotTimeOut()
}
@@ -621,9 +640,13 @@ object LineManager : CallerBase<ILineCallback>() {
@JvmStatic
fun invokeStartAutopilotFailure(startFailedCode: String, startFailedMessage: String) {
OchAutopilotAnalytics.triggerStartAutopilotFailureEventByAdas(startFailedCode,startFailedMessage,System.currentTimeMillis())
OchAutopilotAnalytics.triggerStartAutopilotFailureEventByAdas(
startFailedCode,
startFailedMessage,
System.currentTimeMillis()
)
M_LISTENERS.forEach {
it.value.startAutopilotFailure(startFailedCode,startFailedMessage)
it.value.startAutopilotFailure(startFailedCode, startFailedMessage)
}
}
@@ -634,16 +657,19 @@ object LineManager : CallerBase<ILineCallback>() {
}
fun compareFSMAndOchOrderId(autopilotIdFromFsm: String?) {
if(autopilotIdFromFsm == teleOrderId){
if (autopilotIdFromFsm == teleOrderId) {
// 地盘有和上层一样 不用操作
}else{
if(autopilotIdFromFsm.isNullOrEmpty()){
} else {
if (autopilotIdFromFsm.isNullOrEmpty()) {
// 地盘没有 不做操作
}else{
} else {
// 地盘有但是和och出不一样
// todo 需要och 重新出发轨迹下载操作
ToastUtils.showShort("${autopilotIdFromFsm}_${teleOrderId}_自动驾驶id不同请排查")
OchChainLogManager.writeChainLogAutopilot("自驾Id","${autopilotIdFromFsm}_${teleOrderId}_自动驾驶id不同请排查")
OchChainLogManager.writeChainLogAutopilot(
"自驾Id",
"${autopilotIdFromFsm}_${teleOrderId}_自动驾驶id不同请排查"
)
// val initAutopilotControlParameters = initAutopilotControlParameters()
// if (initAutopilotControlParameters!==null&&initAutopilotControlParameters.autoPilotLine!=null
// && contraiInfo!=null

View File

@@ -59,4 +59,11 @@ class TopSwitchBizView: WindowRelativeLayout, SwtichBizeModel.SwtichLineViewCall
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
RoutingManager.getRoutingView()?.let {
routingSwitchView.removeView(it)
}
}
}