Merge branch 'dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0' of http://gitlab.zhidaoauto.com/zhjt/AndroidApp/MoGoEagleEye into dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0
This commit is contained in:
@@ -2,6 +2,8 @@ package com.mogo.och.bus.passenger.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import android.widget.CompoundButton
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.Fragment
|
||||
@@ -16,6 +18,7 @@ import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.presenter.BusPassengerFunctionPresenter
|
||||
import kotlinx.android.synthetic.m1.bus_p_function_fragment.*
|
||||
|
||||
|
||||
/**
|
||||
* @author: yangyakun
|
||||
* @date: 2023/1/28
|
||||
@@ -72,10 +75,21 @@ class BusPassengerFunctionFragment :
|
||||
override fun getTagName(): String = TAG
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
//dialog?.setCancelable(false)
|
||||
}
|
||||
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
dialog?.window?.let {
|
||||
BarUtils.hideStatusBarAndSticky(it)
|
||||
it.addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
||||
dialog?.setOnShowListener { _ ->
|
||||
it.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE)
|
||||
BarUtils.hideStatusBarAndSticky(it)
|
||||
}
|
||||
}
|
||||
//dialog?.setCancelable(false)
|
||||
}
|
||||
|
||||
private val videoListener = CompoundButton.OnCheckedChangeListener { _, isChecked ->
|
||||
@@ -140,7 +154,7 @@ class BusPassengerFunctionFragment :
|
||||
override fun show(manager: FragmentManager, tag: String?) {
|
||||
try {
|
||||
var cls = this.javaClass.superclass ?: return
|
||||
while (cls != null) {
|
||||
while (true) {
|
||||
if (cls.name == "java.lang.Object") {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -12,12 +12,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotStatisticsList
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.och.common.module.callback.OchAdasStartFailureCallback;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatistics;
|
||||
|
||||
import chassis.Chassis;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* Created on 2022/10/9
|
||||
* 工控机状态信息回调(判断是否能否启动自动驾驶的回调)
|
||||
@@ -78,36 +74,9 @@ public class OCHAdasAbilityManager implements IMoGoAutopilotActionsListener, IMo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotAbility(@Nullable AutopilotAbility ability) {
|
||||
isAutopilotAbility = true;
|
||||
autopilotAbilityReason = null;
|
||||
if (ability.gear == null || ability.gear == Chassis.GearPosition.GEAR_P ||
|
||||
ability.gear == Chassis.GearPosition.GEAR_R) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "挡位不正常";
|
||||
}
|
||||
|
||||
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode) &&
|
||||
ability.gear == Chassis.GearPosition.GEAR_N){ //bus档位不正常
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "挡位不正常";
|
||||
}
|
||||
|
||||
if (isAutopilotAbility)
|
||||
if (ability.brake > 0) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "制动踏板被踩下";
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_STARTING) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "系统正在启动";
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_EXITING) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "系统正在关闭";
|
||||
}
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
|
||||
this.isAutopilotAbility = isAutopilotAbility;
|
||||
this.autopilotAbilityReason = unableAutopilotReason;
|
||||
Logger.d(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@ if (!isAndroidTestBuild()) {
|
||||
crash_fix {
|
||||
enable true
|
||||
}
|
||||
memory_leak {
|
||||
enable true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
140
app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt
Normal file
140
app/src/main/java/com/mogo/launcher/lancet/MemoryLeakFix.kt
Normal file
@@ -0,0 +1,140 @@
|
||||
package com.mogo.launcher.lancet
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.annotation.*
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.fragment.app.*
|
||||
import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
||||
import com.knightboost.lancet.api.*
|
||||
import com.knightboost.lancet.api.annotations.*
|
||||
import com.knightboost.lancet.api.annotations.Weaver
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import io.netty.util.internal.ConcurrentSet
|
||||
import java.lang.ref.*
|
||||
import java.lang.reflect.Modifier
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@Keep
|
||||
@Weaver
|
||||
@Group("memory_leak")
|
||||
class MemoryLeakFix {
|
||||
|
||||
@Insert
|
||||
@ImplementedInterface("java.lang.Runnable")
|
||||
@TargetMethod(methodName = "run")
|
||||
fun runProxy() {
|
||||
if (AccessSyntheticUtils.isTargetAlive(This.get())) {
|
||||
Origin.callVoid()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class AccessSyntheticUtils {
|
||||
|
||||
companion object {
|
||||
|
||||
private val fields = ConcurrentHashMap<String, WeakReference<Any>>()
|
||||
private val observers = ConcurrentSet<String>()
|
||||
|
||||
@JvmStatic
|
||||
fun isTargetAlive(obj: Any): Boolean {
|
||||
try {
|
||||
val clazz = obj.javaClass
|
||||
if (!clazz.isAnonymousClass) {
|
||||
return true
|
||||
}
|
||||
val key = clazz.name
|
||||
return (fields[key] ?: clazz.declaredFields.find {
|
||||
it.isSynthetic &&
|
||||
((it.modifiers and Modifier.STATIC) == 0) &&
|
||||
(View::class.java.isAssignableFrom(it.type) or
|
||||
Context::class.java.isAssignableFrom(it.type) or
|
||||
Fragment::class.java.isAssignableFrom(it.type) or
|
||||
android.app.Fragment::class.java.isAssignableFrom(it.type) or
|
||||
Dialog::class.java.isAssignableFrom(it.type)
|
||||
)
|
||||
}?.let {
|
||||
it.isAccessible = true
|
||||
val wf = WeakReference(it.get(obj), ReferenceQueue())
|
||||
fields[key] = wf
|
||||
wf
|
||||
})?.also {
|
||||
if (it.isEnqueued) {
|
||||
//对像被垃圾回收了
|
||||
fields.remove(key)
|
||||
}
|
||||
}?.get()?.let { t ->
|
||||
var lifecycle: Lifecycle? = null
|
||||
val ret = when (t) {
|
||||
is View -> {
|
||||
lifecycle = t.lifecycleOwner.lifecycle
|
||||
ViewCompat.isAttachedToWindow(t)
|
||||
}
|
||||
is Activity -> {
|
||||
lifecycle = t.findViewById<View>(android.R.id.content)?.lifecycleOwner?.lifecycle
|
||||
!t.isFinishing && !t.isDestroyed
|
||||
}
|
||||
is Fragment -> {
|
||||
lifecycle = t.lifecycle
|
||||
!t.isDetached
|
||||
}
|
||||
is android.app.Fragment -> {
|
||||
lifecycle = t.view?.lifecycleOwner?.lifecycle
|
||||
!t.isDetached
|
||||
}
|
||||
is Dialog -> {
|
||||
t.window?.decorView?.let {
|
||||
v ->
|
||||
lifecycle = v.lifecycleOwner.lifecycle
|
||||
ViewCompat.isAttachedToWindow(v)
|
||||
} ?: false
|
||||
}
|
||||
else -> {
|
||||
true
|
||||
}
|
||||
}
|
||||
if (!ret) {
|
||||
assignFinalFieldNull(obj, t.javaClass)
|
||||
} else {
|
||||
val l = lifecycle
|
||||
if (l != null && !observers.contains(key)) {
|
||||
observers.add(key)
|
||||
l.addObserver(object : LifecycleEventObserver {
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Event) {
|
||||
if (event == ON_DESTROY) {
|
||||
assignFinalFieldNull(obj, t.javaClass)
|
||||
observers.remove(key)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
ret
|
||||
} ?: true
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
private fun assignFinalFieldNull(obj: Any, fieldType: Class<*>) {
|
||||
try {
|
||||
obj.javaClass.declaredFields.find {
|
||||
it.isSynthetic &&
|
||||
((it.modifiers and Modifier.STATIC) == 0) && it.type == fieldType
|
||||
}?.also {
|
||||
it.isAccessible = true
|
||||
it.set(obj, null)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public class DataDistribution {
|
||||
|
||||
public String cutDown(String str) {
|
||||
if (isCutDown && str.length() > 650) {
|
||||
str = str.substring(0, 650) + "\n(已缩短。如需查看完整数据,请勾选日志存储复选框)";
|
||||
str = str.substring(0, 650) + "\n(已缩短。如需查看完整数据,请勾选日志缩短复选框)";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,10 @@ public class ConfigAdapter extends BaseAdapter<Config, ConfigAdapter.ViewHolder>
|
||||
}
|
||||
viewHolder.name.setText(data.name);
|
||||
viewHolder.value.setText(data.value);
|
||||
|
||||
if (data.color == -1) {
|
||||
data.color = R.color.colorSlateGray;
|
||||
}
|
||||
viewHolder.value.setTextColor(mContext.getResources().getColor(data.color));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,6 +48,10 @@ public abstract class BaseAdapter<D, VH extends BaseViewHolder> extends Recycler
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<D> getData() {
|
||||
return mDatas;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<D> listener) {
|
||||
mItemClick = listener;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
package com.zhidao.adas.client.bean;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Config {
|
||||
public final String name;
|
||||
public final String value;
|
||||
public String value;
|
||||
public int color = -1;
|
||||
|
||||
public Config(String name, String value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Config config = (Config) o;
|
||||
return Objects.equals(name, config.name);
|
||||
}
|
||||
|
||||
public void cover(Config config) {
|
||||
this.value = config.value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,6 @@ import com.zhidao.support.adas.high.AdasOptions;
|
||||
import com.zhidao.support.adas.high.OnAdasConnectStatusListener;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.OnMultiDeviceListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatistics;
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.ByteUtil;
|
||||
@@ -121,7 +120,6 @@ import java.util.Locale;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import bag_manager.BagManagerOuterClass;
|
||||
import chassis.Chassis;
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
import chassis.VehicleStateOuterClass;
|
||||
import function_state_management.FunctionStates;
|
||||
@@ -184,8 +182,6 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
private ListPopupWindow listPopupWindow;
|
||||
private FloatWindow floatWindow;
|
||||
private View include_title;
|
||||
private boolean isAutopilotAbility = true;
|
||||
private String autopilotAbilityReason;
|
||||
private List<SpecialVehicleBean> specialVehicleBeanList;//特种车辆
|
||||
private long errorDataUpdateTime = 0;
|
||||
// @Override
|
||||
@@ -860,47 +856,12 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotAbility(AutopilotAbility ability) {
|
||||
isAutopilotAbility = true;
|
||||
autopilotAbilityReason = null;
|
||||
if (ability.gear == null || ability.gear == Chassis.GearPosition.GEAR_P || ability.gear == Chassis.GearPosition.GEAR_R) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "挡位不正常";
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
|
||||
if (fromFragment instanceof VersionFragment) {
|
||||
VersionFragment fragment = (VersionFragment) fromFragment;
|
||||
fragment.autopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
if (ability.brake > 0) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "制动踏板被踩下";
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
if (ability.statusInfo == null) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "系统Topic不正常";
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_STARTING) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "系统正在启动";
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_EXITING) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "系统正在关闭";
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
if (ability.statusInfo.getSysState() == SystemStatusInfo.SystemState.SYS_FAULT) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = "系统异常";
|
||||
}
|
||||
if (isAutopilotAbility)
|
||||
for (SystemStatusInfo.HealthInfo healthInfo : ability.statusInfo.getHealthInfoList()) {
|
||||
if (healthInfo.getState() == SystemStatusInfo.HealthState.FAULT) {
|
||||
isAutopilotAbility = false;
|
||||
autopilotAbilityReason = healthInfo.getName() + " 节点异常";
|
||||
break;
|
||||
}
|
||||
}
|
||||
Log.i(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + autopilotAbilityReason);
|
||||
Log.i(TAG, "是否可以启动自动驾驶=" + isAutopilotAbility + " 原因=" + unableAutopilotReason);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1012,7 +973,12 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
BasicInfoReq info = new BasicInfoReq(header, basicInfoReq, sdf);
|
||||
DataDistribution.getInstance().addData(info);
|
||||
AdasManager.getInstance().sendBasicInfoResp("", 0, com.zhidao.support.adas.high.common.Constants.TERMINAL_ROLE.DEBUG);
|
||||
showToastCenter("收到车机基础信息请求:" + info.toString());
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showToastCenter("收到车机基础信息请求:" + info.toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.zhidao.adas.client.adapter.InterfaceAdapter;
|
||||
import com.zhidao.adas.client.base.BaseFragment;
|
||||
import com.zhidao.adas.client.bean.Config;
|
||||
import com.zhidao.adas.client.bean.InterfaceModel;
|
||||
import com.zhidao.adas.client.utils.RandomColor;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
@@ -211,11 +212,47 @@ public class VersionFragment extends BaseFragment {
|
||||
VersionCompatibility versionCompatibility = AdasManager.getInstance().getVersionCompatibility();
|
||||
list.add(new Config("版本兼容性:", versionCompatibility == null ? null : versionCompatibility.toString()));
|
||||
}
|
||||
|
||||
list.add(new Config("ADAS LIB版本:", AdasManager.getInstance().getAdasVersion()));
|
||||
list.add(new Config("APP构建时间:", BuildConfig.BUILD_TIME));
|
||||
list.add(getAutopilotAbilityConfig(""));
|
||||
adapter.setData(list);
|
||||
}
|
||||
|
||||
private Config getAutopilotAbilityConfig(String value) {
|
||||
return new Config("能否启动自动驾驶:", value);
|
||||
}
|
||||
|
||||
public void autopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
|
||||
List<Config> list = adapter.getData();
|
||||
if (list != null) {
|
||||
Config temp = getAutopilotAbilityConfig(isAutopilotAbility + ",原因:" + unableAutopilotReason);
|
||||
int index = list.indexOf(temp);
|
||||
if (index < 0) {
|
||||
list.add(temp);
|
||||
if (getActivity() != null)
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyItemInserted(list.size() - 1);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Config config = list.get(index);
|
||||
config.cover(temp);
|
||||
config.color = RandomColor.randomColor();
|
||||
if (getActivity() != null)
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
adapter.notifyItemChanged(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRefreshView() {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zhidao.adas.client.utils;
|
||||
|
||||
import com.zhidao.adas.client.R;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class RandomColor {
|
||||
//随机颜色,且不与上一次重复
|
||||
private static Random randomColor;
|
||||
private static int tempColorIndex;
|
||||
private static int[] colors = {R.color.color1, R.color.color2, R.color.color3, R.color.color4, R.color.color5};
|
||||
|
||||
public static int randomColor() {
|
||||
randomColorTemp();
|
||||
return colors[tempColorIndex];
|
||||
}
|
||||
|
||||
private static void randomColorTemp() {
|
||||
if (randomColor == null)
|
||||
randomColor = new Random();
|
||||
int colorInt = randomColor.nextInt(colors.length);
|
||||
if (tempColorIndex == colorInt) {
|
||||
randomColorTemp();
|
||||
} else {
|
||||
tempColorIndex = colorInt;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,11 @@
|
||||
<color name="connect_status_connected">#32CD32</color>
|
||||
<color name="connect_status_disconnected">#DC143C</color>
|
||||
<color name="connect_status_connecting">#FF00FF</color>
|
||||
<color name="connect_status_disconnecting">#DAA520</color>
|
||||
<color name="connect_status_disconnecting">#3333FF </color>
|
||||
<color name="connect_status_search_address">#1E90FF</color>
|
||||
<color name="color1">#FFC0CB</color>
|
||||
<color name="color2">#FF8F00</color>
|
||||
<color name="color3">#FFE500</color>
|
||||
<color name="color4">#B9ED3E</color>
|
||||
<color name="color5">#2EEDEB</color>
|
||||
</resources>
|
||||
|
||||
@@ -45,7 +45,6 @@ import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.AdasOptions;
|
||||
import com.zhidao.support.adas.high.OnAdasConnectStatusListener;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatistics;
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS;
|
||||
@@ -587,6 +586,11 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void initAdas() {
|
||||
CupidLogUtils.e(TAG, "--->初始化");
|
||||
@@ -855,10 +859,6 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotAbility(AutopilotAbility ability) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartAutopilotFailed(MogoReportMsg.MogoReportMessage message) {
|
||||
|
||||
@@ -35,7 +35,7 @@ buildscript {
|
||||
classpath 'com.mogo.cloud:systrace:1.0.1'
|
||||
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.18'
|
||||
classpath 'com.mogo.sticky:service:1.0.8'
|
||||
classpath 'io.github.knight-zxw:lancet-plugin:0.0.1'
|
||||
classpath 'io.github.knight-zxw:lancet-plugin:0.0.4'
|
||||
|
||||
// classpath ("com.tencent.matrix:matrix-gradle-plugin:0.6.6") { changing = true }
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ ext {
|
||||
|
||||
|
||||
//========================= LancetX ===================
|
||||
lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.1",
|
||||
lancetx_runtime : "io.github.knight-zxw:lancet-runtime:0.0.4",
|
||||
|
||||
//========================= autosize ======================
|
||||
androidautoSize : 'com.github.JessYanCoding:AndroidAutoSize:v1.2.1',
|
||||
|
||||
@@ -57,6 +57,9 @@ dependencies {
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.androidxroomruntime
|
||||
kapt rootProject.ext.dependencies.androidxroomcompiler
|
||||
implementation rootProject.ext.dependencies.androidxroomktx
|
||||
|
||||
implementation project(':foudations:mogo-commons')
|
||||
implementation project(':core:mogo-core-data')
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.eagle.function.biz
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.biz.IMoGoFuncBizProvider
|
||||
@@ -10,6 +11,8 @@ import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.d
|
||||
import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager
|
||||
import com.mogo.eagle.function.biz.notice.NoticeSocketManager.Companion.noticeSocketManager
|
||||
import com.mogo.eagle.function.biz.notice.network.NoticeNetWorkManager
|
||||
import com.mogo.eagle.function.biz.v2x.overview.OverViewDataManager
|
||||
import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb
|
||||
import com.mogo.eagle.function.biz.v2x.speedlimit.SpeedLimitDispatcher
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.MogoTrafficLightManager
|
||||
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightDispatcher
|
||||
@@ -68,6 +71,18 @@ class FuncBizProvider : IMoGoFuncBizProvider {
|
||||
cronTaskManager.clear()
|
||||
}
|
||||
|
||||
override fun fetchInfStructures() {
|
||||
OverViewDataManager.fetchInfStructures()
|
||||
}
|
||||
|
||||
override fun getAllV2XEvents() {
|
||||
OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn)
|
||||
}
|
||||
|
||||
override fun initOverViewDb(context: Context) {
|
||||
OverviewDb.getDb(context)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
noticeSocketManager.release()
|
||||
dispatchAutoPilotManager.release()
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
package com.mogo.eagle.function.biz.v2x.overview
|
||||
|
||||
import androidx.lifecycle.*
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.overview.db.OverviewDb
|
||||
import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi
|
||||
import com.mogo.eagle.core.function.overview.remote.V2XEvent
|
||||
import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb
|
||||
import com.mogo.eagle.function.biz.v2x.overview.remote.OverViewServiceApi
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
object OverViewDataManager {
|
||||
@@ -26,37 +28,8 @@ object OverViewDataManager {
|
||||
OverviewDb.getDb(AbsMogoApplication.getApp()).overviewDao()
|
||||
}
|
||||
|
||||
private val _infStructures = MutableLiveData<List<Infrastructure>>()
|
||||
private val _V2XEvents = MutableLiveData<List<V2XEvent>>()
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
val infStructures
|
||||
get() = _infStructures
|
||||
|
||||
private val _infStructuresMap = _infStructures
|
||||
.switchMap { infStructures ->
|
||||
liveData {
|
||||
val map = HashMap<String, ArrayList<Infrastructure>>()
|
||||
infStructures.forEach {
|
||||
val geoHash = it.geoHash
|
||||
if (geoHash == null) {
|
||||
return@forEach
|
||||
} else {
|
||||
if (!map.containsKey(geoHash)) {
|
||||
val list = ArrayList<Infrastructure>()
|
||||
list.add(it)
|
||||
map[geoHash] = list
|
||||
} else {
|
||||
map[geoHash]?.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
emit(map)
|
||||
}
|
||||
}
|
||||
val infStructuresMap
|
||||
get() = _infStructuresMap
|
||||
|
||||
fun fetchInfStructures() {
|
||||
ProcessLifecycleOwner.get().lifecycleScope.launch {
|
||||
val data = try {
|
||||
@@ -67,8 +40,27 @@ object OverViewDataManager {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
data?.let {
|
||||
_infStructures.value = it
|
||||
data?.let { infStructures ->
|
||||
withContext(Dispatchers.Default) {
|
||||
val map = HashMap<String, ArrayList<Infrastructure>>()
|
||||
infStructures.forEach {
|
||||
val geoHash = it.geoHash
|
||||
if (geoHash == null) {
|
||||
return@forEach
|
||||
} else {
|
||||
if (!map.containsKey(geoHash)) {
|
||||
val list = ArrayList<Infrastructure>()
|
||||
list.add(it)
|
||||
map[geoHash] = list
|
||||
} else {
|
||||
map[geoHash]?.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
CallerFuncBizListenerManager.invokeInfStructures(map)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,13 +105,11 @@ object OverViewDataManager {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
it?.apply {
|
||||
_V2XEvents.value = this
|
||||
CallerFuncBizListenerManager.invokeV2XEvents(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getV2XEventLiveData() = _V2XEvents
|
||||
|
||||
fun stopQueryV2XEvents() {
|
||||
disposable?.dispose()
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.overview.db
|
||||
package com.mogo.eagle.function.biz.v2x.overview.db
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Query
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.overview.db
|
||||
package com.mogo.eagle.function.biz.v2x.overview.db
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.overview.remote
|
||||
package com.mogo.eagle.function.biz.v2x.overview.remote
|
||||
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.GET
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mogo.eagle.function.biz.v2x.overview.remote
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
|
||||
|
||||
@Keep
|
||||
data class V2XEventResult (
|
||||
@SerializedName("result")
|
||||
var result: Result?
|
||||
): BaseData()
|
||||
|
||||
@Keep
|
||||
data class Result(
|
||||
@SerializedName("eventList")
|
||||
var v2XEventList: List<V2XEvent>?
|
||||
)
|
||||
@@ -105,6 +105,7 @@ class MoGoAutopilotControlProvider :
|
||||
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
|
||||
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
|
||||
.setClient(false)
|
||||
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
|
||||
// .setSubscribeInterfaceOptions(subscribeInterfaceOptions)//
|
||||
.build()
|
||||
|
||||
@@ -195,6 +196,7 @@ class MoGoAutopilotControlProvider :
|
||||
val options = AdasOptions
|
||||
.Builder()
|
||||
.setClient(true)
|
||||
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
|
||||
.build()
|
||||
AdasManager.getInstance()
|
||||
.create(options, MoGoAdasMsgConnectStatusListenerImpl())
|
||||
@@ -222,6 +224,7 @@ class MoGoAutopilotControlProvider :
|
||||
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
|
||||
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
|
||||
.setClient(false)// 乘客端直连工控机改为false
|
||||
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
|
||||
.build()
|
||||
AdasManager.getInstance().create(options, MoGoAdasMsgConnectStatusListenerImpl())
|
||||
//////////////////////////////////注意先后顺序,AdasManager.getInstance().create后才可以设置监听/////////////////////////////////////////////
|
||||
|
||||
@@ -59,7 +59,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.support.obu.ObuScene
|
||||
import com.zhidao.support.adas.high.AdasManager
|
||||
import com.zhidao.support.adas.high.OnAdasListener
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatistics
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
@@ -608,8 +607,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
|
||||
* 是否可以启动自动驾驶
|
||||
* 使用方法查看:app_ipc_monitoring/uiMainActivity/onAutopilotAbility
|
||||
*/
|
||||
override fun onAutopilotAbility(ability: AutopilotAbility?) {
|
||||
invokeAutopilotAbility(ability)
|
||||
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
|
||||
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -538,8 +538,6 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
|
||||
}
|
||||
}
|
||||
|
||||
private var isRedLight = false
|
||||
private var isGreenLight = false
|
||||
private var isShowGreenWave = false
|
||||
private var isShowRunRedLight = false
|
||||
|
||||
@@ -662,11 +660,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
|
||||
}
|
||||
|
||||
// 红灯
|
||||
2, 3 -> { //todo 小鹏
|
||||
if (!isRedLight) {
|
||||
isRedLight = true
|
||||
}
|
||||
isGreenLight = false
|
||||
2, 3 -> {
|
||||
CallerTrafficLightListenerManager.showTrafficLight(
|
||||
TrafficLightEnum.RED,
|
||||
DataSourceType.TELEMATIC
|
||||
@@ -676,11 +670,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
|
||||
}
|
||||
|
||||
// 绿灯
|
||||
4, 5, 6 -> { //todo 小鹏
|
||||
if (!isGreenLight) {
|
||||
isGreenLight = true
|
||||
}
|
||||
isRedLight = false
|
||||
4, 5, 6 -> {
|
||||
CallerTrafficLightListenerManager.showTrafficLight(
|
||||
TrafficLightEnum.GREEN,
|
||||
DataSourceType.TELEMATIC
|
||||
|
||||
@@ -635,382 +635,322 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息的方位 车辆相关
|
||||
*/
|
||||
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
|
||||
// CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification")
|
||||
return when (targetClassification) {
|
||||
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
|
||||
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
|
||||
/**
|
||||
* 获取消息的方位 车辆相关
|
||||
*/
|
||||
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
|
||||
// CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification")
|
||||
return when (targetClassification) {
|
||||
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
|
||||
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
|
||||
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
|
||||
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
|
||||
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT,
|
||||
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT
|
||||
-> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
|
||||
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT,
|
||||
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT
|
||||
-> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT,
|
||||
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT
|
||||
-> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
|
||||
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT,
|
||||
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT
|
||||
-> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT,
|
||||
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
|
||||
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT,
|
||||
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT,
|
||||
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
|
||||
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT,
|
||||
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
|
||||
|
||||
MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
|
||||
else -> WarningDirectionEnum.ALERT_WARNING_ALL
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
*
|
||||
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截
|
||||
*
|
||||
* @see com.mogo.module.common.enums.EventTypeEnum
|
||||
*/
|
||||
private fun handleSdkObu(
|
||||
appId: String,
|
||||
direction: WarningDirectionEnum,
|
||||
status: Int,
|
||||
level: Int,
|
||||
info: MogoObuRvWarningData
|
||||
) {
|
||||
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的
|
||||
var alertContent: String = ""
|
||||
var ttsContent: String = ""
|
||||
var changeVisualAngle = false
|
||||
when (appId) {
|
||||
//交叉路口碰撞预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
|
||||
}
|
||||
|
||||
//交叉路口碰撞预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
|
||||
}
|
||||
|
||||
//左转辅助预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
|
||||
}
|
||||
|
||||
//盲区预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> {
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
|
||||
if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
|
||||
) { //左后
|
||||
changeVisualAngle = true
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
alertContent = String.format(alertContent, "左")
|
||||
} else if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
|
||||
) { //右后
|
||||
changeVisualAngle = true
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
alertContent = String.format(alertContent, "右")
|
||||
}
|
||||
}
|
||||
|
||||
// 变道预警,注意左后车辆/注意右后车辆
|
||||
MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
|
||||
if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
|
||||
) {
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
alertContent = String.format(alertContent, "左")
|
||||
} else if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
|
||||
) {
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
alertContent = String.format(alertContent, "右")
|
||||
}
|
||||
}
|
||||
|
||||
//逆向超车预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
|
||||
}
|
||||
|
||||
//紧急制动预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
|
||||
}
|
||||
|
||||
//异常车辆提醒
|
||||
MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
|
||||
alertContent = String.format(alertContent, direction.desc)
|
||||
ttsContent = String.format(ttsContent, direction.desc)
|
||||
}
|
||||
|
||||
//车辆失控预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
|
||||
alertContent = String.format(alertContent, direction.desc)
|
||||
ttsContent = String.format(ttsContent, direction.desc)
|
||||
}
|
||||
//车辆失控预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
|
||||
}
|
||||
|
||||
// 这里处理固定的提示信息,包括了<紧急车辆提醒>
|
||||
else -> { //TODO
|
||||
// ttsContent = EventTypeEnumNew.getWarningTts(appId.toString())
|
||||
// alertContent = EventTypeEnumNew.getWarningContent(appId.toString())
|
||||
MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
|
||||
else -> WarningDirectionEnum.ALERT_WARNING_ALL
|
||||
}
|
||||
}
|
||||
|
||||
when (status) {
|
||||
// 添加,更新 add的时候,可能级别是2,
|
||||
MogoObuConstants.STATUS.ADD,
|
||||
MogoObuConstants.STATUS.UPDATE -> {
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
|
||||
)
|
||||
if (level == 2 || level == 3) {
|
||||
//不显示弹框,其它保留
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent
|
||||
)
|
||||
).apply {
|
||||
sourceType = DataSourceType.OBU
|
||||
}
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
object : IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
super.onShow()
|
||||
if (changeVisualAngle) {
|
||||
CallerVisualAngleManager.changeVisualAngle(TooClose)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
|
||||
if (changeVisualAngle) {
|
||||
CallerVisualAngleManager.changeVisualAngle(Default())
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
//显示警告红边
|
||||
CallerHmiManager.showWarning(direction)
|
||||
/**
|
||||
* 构造对应展示数据和场景 根据obu的场景,add change delete确定是否展示
|
||||
*
|
||||
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截
|
||||
*
|
||||
* @see com.mogo.module.common.enums.EventTypeEnum
|
||||
*/
|
||||
private fun handleSdkObu(
|
||||
appId: String,
|
||||
direction: WarningDirectionEnum,
|
||||
status: Int,
|
||||
level: Int,
|
||||
info: MogoObuRvWarningData
|
||||
) {
|
||||
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的
|
||||
var alertContent: String = ""
|
||||
var ttsContent: String = ""
|
||||
var changeVisualAngle = false
|
||||
when (appId) {
|
||||
//交叉路口碰撞预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
|
||||
}
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
|
||||
//交叉路口碰撞预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
|
||||
}
|
||||
|
||||
//左转辅助预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
|
||||
}
|
||||
|
||||
//盲区预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> {
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
|
||||
if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
|
||||
) { //左后
|
||||
changeVisualAngle = true
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
alertContent = String.format(alertContent, "左")
|
||||
} else if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
|
||||
) { //右后
|
||||
changeVisualAngle = true
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
alertContent = String.format(alertContent, "右")
|
||||
}
|
||||
}
|
||||
|
||||
// 变道预警,注意左后车辆/注意右后车辆
|
||||
MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
|
||||
if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
|
||||
) {
|
||||
ttsContent = String.format(ttsContent, "左")
|
||||
alertContent = String.format(alertContent, "左")
|
||||
} else if (
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
|
||||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
|
||||
) {
|
||||
ttsContent = String.format(ttsContent, "右")
|
||||
alertContent = String.format(alertContent, "右")
|
||||
}
|
||||
}
|
||||
|
||||
//逆向超车预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
|
||||
}
|
||||
|
||||
//紧急制动预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
|
||||
}
|
||||
|
||||
//异常车辆提醒
|
||||
MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
|
||||
alertContent = String.format(alertContent, direction.desc)
|
||||
ttsContent = String.format(ttsContent, direction.desc)
|
||||
}
|
||||
|
||||
//车辆失控预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
|
||||
alertContent = String.format(alertContent, direction.desc)
|
||||
ttsContent = String.format(ttsContent, direction.desc)
|
||||
}
|
||||
//车辆失控预警
|
||||
MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> {
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
|
||||
}
|
||||
|
||||
// 这里处理固定的提示信息,包括了<紧急车辆提醒>
|
||||
else -> { //TODO
|
||||
// ttsContent = EventTypeEnumNew.getWarningTts(appId.toString())
|
||||
// alertContent = EventTypeEnumNew.getWarningContent(appId.toString())
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
MogoObuConstants.STATUS.DELETE -> {
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
// CallerHmiManager.disableWarningV2X((appId + direction.direction))
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理红绿灯
|
||||
*/
|
||||
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<SpatLight>) {
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId"
|
||||
)
|
||||
when (status) {
|
||||
// 添加
|
||||
MogoObuConstants.STATUS.ADD,
|
||||
MogoObuConstants.STATUS.UPDATE
|
||||
-> {
|
||||
if (lights != null && lights.isNotEmpty()) {
|
||||
changeTrafficLightStatus(appId, lights)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
MogoObuConstants.STATUS.DELETE -> {
|
||||
// 移除顶部弹窗
|
||||
CallerTrafficLightListenerManager.disableTrafficLight()
|
||||
isShowGreenWave = false
|
||||
isShowRunRedLight = false
|
||||
isYellowLight = false
|
||||
// lightCountDownRed = 1
|
||||
// lightCountDownGreen = 1
|
||||
// lightCountDownYellow = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var isRedLight = false
|
||||
private var isGreenLight = false
|
||||
private var isYellowLight = false
|
||||
private var isShowGreenWave = false
|
||||
private var isShowRunRedLight = false
|
||||
|
||||
// private var lightCountDownRed : Int = 1
|
||||
// private var lightCountDownGreen : Int = 1
|
||||
// private var lightCountDownYellow : Int = 1
|
||||
|
||||
|
||||
/**
|
||||
* 修改红绿灯
|
||||
*/
|
||||
@Synchronized
|
||||
private fun changeTrafficLightStatus(
|
||||
appId: Int,
|
||||
lights: List<SpatLight>
|
||||
) {
|
||||
var ttsContent = ""
|
||||
var alertContent = ""
|
||||
//这里需要根据真实数据确定 index 取值方式
|
||||
val currentLight = lights[0]
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}"
|
||||
)
|
||||
// 闯红灯预警,绿波通行和闯红灯是互斥的
|
||||
when (appId) {
|
||||
0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效
|
||||
|
||||
}
|
||||
1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次
|
||||
if (!isShowRunRedLight) {
|
||||
isShowRunRedLight = true
|
||||
when (status) {
|
||||
// 添加,更新 add的时候,可能级别是2,
|
||||
MogoObuConstants.STATUS.ADD,
|
||||
MogoObuConstants.STATUS.UPDATE -> {
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"changeTrafficLightStatus 闯红灯 --------> "
|
||||
"new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
|
||||
)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
alertContent,
|
||||
ttsContent
|
||||
)
|
||||
).apply {
|
||||
sourceType = DataSourceType.OBU
|
||||
}
|
||||
)
|
||||
|
||||
CallerHmiManager.warningV2X(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
alertContent,
|
||||
ttsContent// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候
|
||||
if (!isShowGreenWave) {
|
||||
isShowGreenWave = true
|
||||
|
||||
var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6)
|
||||
var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6)
|
||||
if (minSpeedTemp == maxSpeedTemp) {
|
||||
minSpeedTemp -= 5
|
||||
}
|
||||
|
||||
val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp"
|
||||
val adviceSpeedTts = "$minSpeedTemp 到 $maxSpeedTemp"
|
||||
|
||||
// val adviceSpeed =
|
||||
// "${Math.round(currentLight.suggestMinSpeed*3.6)} - ${Math.round(currentLight.suggestMaxSpeed*3.6)}"
|
||||
// val adviceSpeedTts =
|
||||
// "${Math.round(currentLight.suggestMinSpeed*3.6)} 到 ${Math.round(currentLight.suggestMaxSpeed*3.6)}"
|
||||
|
||||
ttsContent =
|
||||
String.format(
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
|
||||
adviceSpeedTts
|
||||
)
|
||||
alertContent =
|
||||
String.format(
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
|
||||
adviceSpeed
|
||||
)
|
||||
|
||||
val maxSpeed = currentLight.suggestMaxSpeed
|
||||
if (maxSpeed > 0) {
|
||||
if (level == 2 || level == 3) {
|
||||
//不显示弹框,其它保留
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent
|
||||
)
|
||||
).apply {
|
||||
sourceType = DataSourceType.OBU
|
||||
}
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
appId,
|
||||
alertContent,
|
||||
ttsContent,// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
object : IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
super.onShow()
|
||||
if (changeVisualAngle) {
|
||||
CallerVisualAngleManager.changeVisualAngle(TooClose)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
|
||||
if (changeVisualAngle) {
|
||||
CallerVisualAngleManager.changeVisualAngle(Default())
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
//显示警告红边
|
||||
CallerHmiManager.showWarning(direction)
|
||||
}
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
MogoObuConstants.STATUS.DELETE -> {
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
|
||||
// 移除顶部弹窗
|
||||
// CallerHmiManager.disableWarningV2X((appId + direction.direction))
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理红绿灯
|
||||
*/
|
||||
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<SpatLight>) {
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId"
|
||||
)
|
||||
when (status) {
|
||||
// 添加
|
||||
MogoObuConstants.STATUS.ADD,
|
||||
MogoObuConstants.STATUS.UPDATE
|
||||
-> {
|
||||
if (lights != null && lights.isNotEmpty()) {
|
||||
changeTrafficLightStatus(appId, lights)
|
||||
}
|
||||
}
|
||||
// 删除
|
||||
MogoObuConstants.STATUS.DELETE -> {
|
||||
// 移除顶部弹窗
|
||||
CallerTrafficLightListenerManager.disableTrafficLight()
|
||||
isShowGreenWave = false
|
||||
isShowRunRedLight = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var isYellowLight = false
|
||||
private var isShowGreenWave = false
|
||||
private var isShowRunRedLight = false
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 修改红绿灯
|
||||
*/
|
||||
@Synchronized
|
||||
private fun changeTrafficLightStatus(
|
||||
appId: Int,
|
||||
lights: List<SpatLight>
|
||||
) {
|
||||
var ttsContent = ""
|
||||
var alertContent = ""
|
||||
//这里需要根据真实数据确定 index 取值方式
|
||||
val currentLight = lights[0]
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}"
|
||||
)
|
||||
// 闯红灯预警,绿波通行和闯红灯是互斥的
|
||||
when (appId) {
|
||||
0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效
|
||||
|
||||
}
|
||||
1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次
|
||||
if (!isShowRunRedLight) {
|
||||
isShowRunRedLight = true
|
||||
CallerLogger.d(
|
||||
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
|
||||
"changeTrafficLightStatus 闯红灯 --------> "
|
||||
)
|
||||
ttsContent =
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
|
||||
alertContent =
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
alertContent,
|
||||
ttsContent
|
||||
)
|
||||
@@ -1020,51 +960,80 @@ private fun changeTrafficLightStatus(
|
||||
)
|
||||
|
||||
CallerHmiManager.warningV2X(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
|
||||
alertContent,
|
||||
ttsContent// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候
|
||||
if (!isShowGreenWave) {
|
||||
isShowGreenWave = true
|
||||
|
||||
var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6)
|
||||
var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6)
|
||||
if (minSpeedTemp == maxSpeedTemp) {
|
||||
minSpeedTemp -= 5
|
||||
}
|
||||
|
||||
val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp"
|
||||
val adviceSpeedTts = "$minSpeedTemp 到 $maxSpeedTemp"
|
||||
|
||||
ttsContent =
|
||||
String.format(
|
||||
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
|
||||
adviceSpeedTts
|
||||
)
|
||||
alertContent =
|
||||
String.format(
|
||||
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
|
||||
adviceSpeed
|
||||
)
|
||||
|
||||
val maxSpeed = currentLight.suggestMaxSpeed
|
||||
if (maxSpeed > 0) {
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
alertContent,
|
||||
ttsContent
|
||||
)
|
||||
).apply {
|
||||
sourceType = DataSourceType.OBU
|
||||
}
|
||||
)
|
||||
|
||||
CallerHmiManager.warningV2X(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
|
||||
alertContent,
|
||||
ttsContent// 只有第一次才tts,防止更新的时候不断的提醒
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
when (currentLight.light) {
|
||||
// 灯光不可用
|
||||
0 -> {
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.BLACK)
|
||||
}
|
||||
// 红灯
|
||||
2, 3 -> {
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.RED)
|
||||
}
|
||||
|
||||
// 绿灯
|
||||
4, 5, 6 -> {
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.GREEN)
|
||||
}
|
||||
|
||||
// 黄灯
|
||||
7, 8 -> {
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.YELLOW)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
when (currentLight.light) {
|
||||
// 灯光不可用
|
||||
0 -> {
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.BLACK)
|
||||
}
|
||||
// 红灯
|
||||
2, 3 -> {
|
||||
if (!isRedLight) { //todo 小鹏
|
||||
isRedLight = true
|
||||
}
|
||||
isGreenLight = false
|
||||
isYellowLight = false
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.RED)
|
||||
val red = currentLight.countDown.toInt()
|
||||
}
|
||||
|
||||
// 绿灯
|
||||
4, 5, 6 -> { //todo 小鹏
|
||||
if (!isGreenLight) {
|
||||
isGreenLight = true
|
||||
}
|
||||
isRedLight = false
|
||||
isYellowLight = false
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.GREEN)
|
||||
val green = currentLight.countDown.toInt()
|
||||
}
|
||||
|
||||
// 黄灯
|
||||
7, 8 -> {
|
||||
if (!isYellowLight) {
|
||||
isYellowLight = true
|
||||
}
|
||||
isRedLight = false
|
||||
isGreenLight = false
|
||||
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.YELLOW)
|
||||
val yellow = currentLight.countDown.toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,34 +343,34 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
|
||||
}
|
||||
|
||||
override fun showSmallFragment() {
|
||||
// 加载全览模式图层
|
||||
val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
|
||||
.navigation() as BaseFragment
|
||||
activity?.supportFragmentManager?.beginTransaction()
|
||||
?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
|
||||
if (!fragmentOverview.isAdded) {
|
||||
add(
|
||||
R.id.module_main_id_smp_fragment,
|
||||
fragmentOverview,
|
||||
fragmentOverview.tagName
|
||||
)
|
||||
} else {
|
||||
show(fragmentOverview)
|
||||
}.commitAllowingStateLoss()
|
||||
}
|
||||
CallerDevaToolsManager.hideStatusBar()
|
||||
// // 加载全览模式图层
|
||||
// val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
|
||||
// .navigation() as BaseFragment
|
||||
// activity?.supportFragmentManager?.beginTransaction()
|
||||
// ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
|
||||
// if (!fragmentOverview.isAdded) {
|
||||
// add(
|
||||
// R.id.module_main_id_smp_fragment,
|
||||
// fragmentOverview,
|
||||
// fragmentOverview.tagName
|
||||
// )
|
||||
// } else {
|
||||
// show(fragmentOverview)
|
||||
// }.commitAllowingStateLoss()
|
||||
// }
|
||||
// CallerDevaToolsManager.hideStatusBar()
|
||||
}
|
||||
|
||||
override fun hideSmallFragment() {
|
||||
val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
|
||||
.navigation() as BaseFragment
|
||||
activity?.supportFragmentManager?.beginTransaction()
|
||||
?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
|
||||
if (fragmentOverview.isVisible) {
|
||||
hide(fragmentOverview)
|
||||
}
|
||||
}
|
||||
?.commitAllowingStateLoss()
|
||||
// val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
|
||||
// .navigation() as BaseFragment
|
||||
// activity?.supportFragmentManager?.beginTransaction()
|
||||
// ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
|
||||
// if (fragmentOverview.isVisible) {
|
||||
// hide(fragmentOverview)
|
||||
// }
|
||||
// }
|
||||
// ?.commitAllowingStateLoss()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,12 +22,12 @@ import com.mogo.eagle.core.data.constants.MoGoConfig;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts;
|
||||
import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener;
|
||||
import com.mogo.eagle.core.function.call.biz.CallerFuncBizManager;
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsUpgradeListenerManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
|
||||
import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb;
|
||||
import com.mogo.eagle.core.function.overview.db.OverviewDb;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
@@ -194,7 +194,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
}
|
||||
|
||||
private void initOverviewDb() {
|
||||
OverviewDb.Companion.getDb(this);
|
||||
CallerFuncBizManager.getBizProvider().initOverViewDb(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.mogo.eagle.core.data.map.CenterLine
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
|
||||
import com.mogo.eagle.core.function.business.MapPointCloudSubscriber
|
||||
@@ -20,20 +19,11 @@ import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData
|
||||
import com.mogo.eagle.core.function.overview.obtainViewModel
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.map.IMogoMap
|
||||
import com.mogo.map.MogoMapView
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
/**
|
||||
* 本地数据库查询出来的红绿灯、摄像头等数据
|
||||
*/
|
||||
object InfStructureManager {
|
||||
|
||||
// 每个GeoHash网格对应的新基建Bean
|
||||
private val _infMap by lazy {
|
||||
HashMap<String, ArrayList<Infrastructure>>()
|
||||
}
|
||||
|
||||
// 全局路径规划中所有点的GeoHash网格对应的新基建数据集合
|
||||
private val _pathMap by lazy {
|
||||
HashMap<String, ArrayList<Infrastructure>>()
|
||||
}
|
||||
|
||||
private val _planningList by lazy {
|
||||
ArrayList<MessagePad.Location>()
|
||||
}
|
||||
|
||||
fun saveData(map: HashMap<String, java.util.ArrayList<Infrastructure>>) {
|
||||
if (_infMap.isNotEmpty()) {
|
||||
_infMap.clear()
|
||||
}
|
||||
_infMap.putAll(map)
|
||||
}
|
||||
|
||||
fun getData(): Map<String, ArrayList<Infrastructure>> = _infMap
|
||||
|
||||
fun savePathData(map: HashMap<String, java.util.ArrayList<Infrastructure>>) {
|
||||
if (_pathMap.isNotEmpty()) {
|
||||
_pathMap.clear()
|
||||
}
|
||||
_pathMap.putAll(map)
|
||||
}
|
||||
|
||||
fun getPathData(): Map<String, ArrayList<Infrastructure>> = _pathMap
|
||||
|
||||
fun savePlanningData(planningList: List<MessagePad.Location>) {
|
||||
if (_planningList.isNotEmpty()) {
|
||||
_planningList.clear()
|
||||
}
|
||||
_planningList.addAll(planningList)
|
||||
}
|
||||
|
||||
fun getPlanningData() = _planningList
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProviders
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
|
||||
fun <T : ViewModel> AppCompatActivity.obtainViewModel(viewModelClass: Class<T>) =
|
||||
ViewModelProviders.of(this, ViewModelFactory.getInstance(application)).get(viewModelClass)
|
||||
|
||||
fun <T : ViewModel> Fragment.obtainViewModel(viewModelClass: Class<T>) =
|
||||
ViewModelProviders.of(this, ViewModelFactory.getInstance(AbsMogoApplication.getApp())).get(viewModelClass)
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Application
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.mogo.eagle.core.function.overview.db.OverviewDao
|
||||
import com.mogo.eagle.core.function.overview.db.OverviewDb
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel
|
||||
|
||||
class ViewModelFactory private constructor(
|
||||
private val overviewDao: OverviewDao
|
||||
) : ViewModelProvider.NewInstanceFactory() {
|
||||
|
||||
override fun <T : ViewModel> create(modelClass: Class<T>) =
|
||||
with(modelClass) {
|
||||
when {
|
||||
isAssignableFrom(OverViewModel::class.java) ->
|
||||
OverViewModel(overviewDao)
|
||||
else ->
|
||||
throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}")
|
||||
}
|
||||
} as T
|
||||
|
||||
companion object {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Volatile private var INSTANCE: ViewModelFactory? = null
|
||||
|
||||
fun getInstance(application: Application) =
|
||||
INSTANCE ?: synchronized(ViewModelFactory::class.java) {
|
||||
INSTANCE ?: ViewModelFactory(
|
||||
OverviewDb.getDb(application).overviewDao())
|
||||
.also { INSTANCE = it }
|
||||
}
|
||||
|
||||
@VisibleForTesting fun destroyInstance() {
|
||||
INSTANCE = null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,17 +20,16 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.api.v2x.IFuncBizProvider
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showVideoDialog
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager.getData
|
||||
import com.mogo.eagle.core.function.overview.OverViewDataManager
|
||||
import com.mogo.eagle.core.function.overview.remote.V2XEvent
|
||||
import com.mogo.eagle.core.function.smp.MakerWithCount
|
||||
import com.mogo.eagle.core.function.smp.MarkerDrawerManager
|
||||
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.callback
|
||||
@@ -40,7 +39,6 @@ import com.mogo.eagle.core.function.smp.MarkerDrawerManager.planningPoints
|
||||
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.startLoopCalCarLocation
|
||||
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.updateRoutePoints
|
||||
import com.mogo.eagle.core.function.smp.V2XMarkerView
|
||||
import com.mogo.eagle.core.utilcode.kotlin.lifecycleOwner
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isTaxi
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
@@ -69,6 +67,8 @@ class OverMapView @JvmOverloads constructor(
|
||||
private val pathMap: MutableMap<String?, ArrayList<Infrastructure>?> = HashMap()
|
||||
private val posInfMap: MutableMap<LatLng?, ArrayList<Infrastructure>?> = HashMap()
|
||||
|
||||
private var geoHashInfMap: HashMap<String, java.util.ArrayList<Infrastructure>>? = null
|
||||
|
||||
// =============绘制轨迹线相关=============
|
||||
private var mCarMarker: Marker? = null
|
||||
private var mCompassMarker: Marker? = null
|
||||
@@ -189,18 +189,17 @@ class OverMapView @JvmOverloads constructor(
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
OverViewDataManager.infStructuresMap.observe(lifecycleOwner) { list ->
|
||||
InfStructureManager.saveData(list)
|
||||
}
|
||||
// 查询本地数据库中的摄像头数据
|
||||
OverViewDataManager.fetchInfStructures()
|
||||
CallerFuncBizListenerManager.addListener(TAG, object : IFuncBizProvider {
|
||||
override fun onInfStructures(map: HashMap<String, ArrayList<Infrastructure>>?) {
|
||||
geoHashInfMap = map
|
||||
}
|
||||
|
||||
override fun onV2XEvents(v2xEvents: List<V2XEvent>?) {
|
||||
showV2XEventMarkers(v2xEvents)
|
||||
}
|
||||
})
|
||||
// 主动查一次全局路径规划的数据
|
||||
getGlobalPath()
|
||||
// 定时查询V2X事件
|
||||
OverViewDataManager.getV2XEventLiveData().observe(lifecycleOwner) {
|
||||
showV2XEventMarkers(it)
|
||||
}
|
||||
OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn)
|
||||
}
|
||||
|
||||
private fun setUpMap() {
|
||||
@@ -297,32 +296,45 @@ class OverMapView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
startLoopCalCarLocation()
|
||||
UiThreadHandler.post { drawInfrastructureMarkers(locationList) }
|
||||
UiThreadHandler.post {
|
||||
if (geoHashInfMap.isNullOrEmpty()) {
|
||||
UiThreadHandler.postDelayed({
|
||||
drawInfrastructureMarkers(locationList)
|
||||
}, 1000)
|
||||
} else {
|
||||
drawInfrastructureMarkers(locationList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示V2X事件的Marker
|
||||
*/
|
||||
fun showV2XEventMarkers(v2XEvents: List<V2XEvent>?) {
|
||||
private fun showV2XEventMarkers(v2XEvents: List<V2XEvent>?) {
|
||||
if (v2XEvents == null || v2XEvents.isEmpty()) return
|
||||
clearV2XMarkers()
|
||||
val markerOptionsList = ArrayList<MarkerOptions>()
|
||||
for ((_, _, _, center, _, _, poiType, coordinateType) in v2XEvents) {
|
||||
for (v2xEvent in v2XEvents) {
|
||||
val center = v2xEvent.center
|
||||
if (center != null) {
|
||||
center.lon
|
||||
val markerOption = MarkerOptions()
|
||||
var latLng: LatLng = if (coordinateType == null || coordinateType == 0) {
|
||||
LatLng(center.lat, center.lon)
|
||||
} else {
|
||||
// wgs84坐标系需转成高德坐标系
|
||||
coordinateConverterWgsToGcj(mContext!!, center.lat, center.lon)
|
||||
}
|
||||
var latLng: LatLng =
|
||||
if (v2xEvent.coordinateType == null || v2xEvent.coordinateType == 0) {
|
||||
LatLng(center.lat, center.lon)
|
||||
} else {
|
||||
// wgs84坐标系需转成高德坐标系
|
||||
coordinateConverterWgsToGcj(
|
||||
mContext!!,
|
||||
center.lat,
|
||||
center.lon
|
||||
)
|
||||
}
|
||||
markerOption.position(latLng)
|
||||
markerOption.anchor(0.13f, 1f)
|
||||
markerOption.icon(
|
||||
BitmapDescriptorFactory.fromBitmap(
|
||||
getV2XBitmap(
|
||||
poiType
|
||||
v2xEvent.poiType
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -364,7 +376,6 @@ class OverMapView @JvmOverloads constructor(
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
|
||||
CallerPlanningRottingListenerManager.removeListener(TAG)
|
||||
OverViewDataManager.stopQueryV2XEvents()
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
|
||||
@@ -386,7 +397,8 @@ class OverMapView @JvmOverloads constructor(
|
||||
* @param locationList
|
||||
*/
|
||||
private fun drawInfrastructureMarkers(locationList: List<MessagePad.Location>?) {
|
||||
if (locationList == null) return
|
||||
val infMap = geoHashInfMap
|
||||
if (locationList == null || infMap.isNullOrEmpty()) return
|
||||
if (pathMap.isNotEmpty()) {
|
||||
pathMap.clear()
|
||||
}
|
||||
@@ -399,7 +411,7 @@ class OverMapView @JvmOverloads constructor(
|
||||
// 网格内的轨迹点只取一次s
|
||||
if (!pathMap.containsKey(geoHash)) {
|
||||
// 从缓存的新基建数据中去取对应geoHash的新基建数据集合
|
||||
infList = getData()[geoHash]
|
||||
infList = infMap[geoHash]
|
||||
if (infList != null) {
|
||||
pathMap[geoHash] = infList
|
||||
}
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
package com.mogo.eagle.core.function.overview.vm
|
||||
|
||||
import androidx.lifecycle.*
|
||||
import com.mogo.commons.constants.HostConst
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
|
||||
import com.mogo.eagle.core.function.overview.db.OverviewDao
|
||||
import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi
|
||||
import com.mogo.eagle.core.function.overview.remote.V2XEvent
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class OverViewModel(
|
||||
private val overviewDao: OverviewDao
|
||||
) : ViewModel() {
|
||||
private val _infStructures = MutableLiveData<List<Infrastructure>>()
|
||||
private val _V2XEvents = MutableLiveData<List<V2XEvent>>()
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
companion object {
|
||||
const val TAG = "OverViewModel"
|
||||
}
|
||||
|
||||
val infStructures
|
||||
get() = _infStructures
|
||||
|
||||
private val _infStructuresMap = _infStructures
|
||||
.switchMap { infStructures ->
|
||||
liveData {
|
||||
val map = HashMap<String, ArrayList<Infrastructure>>()
|
||||
infStructures.forEach {
|
||||
val geoHash = it.geoHash
|
||||
if (geoHash == null) {
|
||||
return@forEach
|
||||
} else {
|
||||
if (!map.containsKey(geoHash)) {
|
||||
val list = ArrayList<Infrastructure>()
|
||||
list.add(it)
|
||||
map[geoHash] = list
|
||||
} else {
|
||||
map[geoHash]?.add(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
emit(map)
|
||||
}
|
||||
}
|
||||
val infStructuresMap
|
||||
get() = _infStructuresMap
|
||||
|
||||
fun fetchInfStructures() {
|
||||
viewModelScope.launch {
|
||||
val data = try {
|
||||
// 只查找摄像头
|
||||
overviewDao.listInfStructures(0)
|
||||
// overviewDao.listAllInfStructures()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
data?.let {
|
||||
_infStructures.value = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun updateGeoHash(id: Int, geoHash: String) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
overviewDao.updateGeoHash(id, geoHash)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getAllV2XEventsByLineId(sn: String) {
|
||||
if (disposable != null && !disposable!!.isDisposed) {
|
||||
disposable!!.dispose()
|
||||
}
|
||||
|
||||
// 1分钟查询一次
|
||||
disposable = Observable.interval(2000, 60000, TimeUnit.MILLISECONDS)
|
||||
.flatMap {
|
||||
val lineId = getLineId()
|
||||
if (lineId > 0) {
|
||||
MoGoRetrofitFactory.getInstance(HostConst.getHost())
|
||||
.create(OverViewServiceApi::class.java)
|
||||
.queryAllV2XEventsByLineId(lineId.toString(), sn)
|
||||
.map {
|
||||
if (it.code == 200 || it.code == 0) {
|
||||
CallerLogger.d(SceneConstant.M_MAP + TAG, "请求成功,size为:${it.result?.v2XEventList?.size}")
|
||||
return@map it.result?.v2XEventList
|
||||
} else {
|
||||
CallerLogger.d(SceneConstant.M_MAP + TAG, "请求失败,code为:${it.code}")
|
||||
return@map ArrayList()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Observable.just(ArrayList())
|
||||
}
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
it?.apply {
|
||||
_V2XEvents.value = this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getV2XEventLiveData() = _V2XEvents
|
||||
|
||||
fun stopQueryV2XEvents() {
|
||||
disposable?.dispose()
|
||||
}
|
||||
|
||||
private fun getLineId(): Long {
|
||||
var lineId: Long = -1
|
||||
val parameter = getAutoPilotStatusInfo()
|
||||
.autopilotControlParameters
|
||||
if (parameter != null) {
|
||||
if (parameter.autoPilotLine != null) {
|
||||
lineId = parameter.autoPilotLine!!.lineId
|
||||
CallerLogger.d(SceneConstant.M_MAP + TAG, "lineId为:$lineId")
|
||||
} else {
|
||||
CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter.autoPilotLine为null")
|
||||
}
|
||||
} else {
|
||||
CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter为null")
|
||||
}
|
||||
return lineId
|
||||
}
|
||||
}
|
||||
@@ -1,550 +0,0 @@
|
||||
package com.mogo.eagle.core.function.smp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.Bundle;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptor;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CameraPosition;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.LatLngBounds;
|
||||
import com.amap.api.maps.model.Marker;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.maps.model.PolylineOptions;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.Infrastructure;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager;
|
||||
import com.mogo.eagle.core.function.overview.remote.Center;
|
||||
import com.mogo.eagle.core.function.overview.remote.V2XEvent;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ch.hsr.geohash.GeoHash;
|
||||
import kotlin.Pair;
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* 小地图的方向View
|
||||
* 监听自动驾驶路径结束,结束高德地图导航
|
||||
*
|
||||
* @author donghongyu
|
||||
* @date 12/14/20 4:40 PM
|
||||
*/
|
||||
public class AMapCustomView
|
||||
extends RelativeLayout
|
||||
implements IMoGoChassisLocationGCJ02Listener {
|
||||
public static final String TAG = "AMapCustomView";
|
||||
private TextureMapView mAMapView;
|
||||
private AMap mAMap;
|
||||
private int zoomLevel = 15;
|
||||
private CameraUpdate mCameraUpdate;
|
||||
private Context mContext;
|
||||
private float mTilt = 60f;
|
||||
private TextView overLayerView;
|
||||
private boolean calculate = false;
|
||||
|
||||
// 全局路径规划中的GeoHash网格
|
||||
private Map<String, ArrayList<Infrastructure>> pathMap = new HashMap();
|
||||
private Map<LatLng, ArrayList<Infrastructure>> posInfMap = new HashMap();
|
||||
|
||||
// =============绘制轨迹线相关=============
|
||||
private Marker mCarMarker;
|
||||
private Marker mCompassMarker;
|
||||
private Marker mStartMarker;
|
||||
private Marker mEndMarker;
|
||||
private Polyline mBottomPolyline;
|
||||
private Polyline mCoveredPolyline;
|
||||
// 计算索引并设置对应的Bitmap
|
||||
BitmapDescriptor arrivedBitmap;
|
||||
BitmapDescriptor unArrivedBitmap;
|
||||
// 绘制轨迹线的集合
|
||||
private List<BitmapDescriptor> textureList = new ArrayList<>();
|
||||
private List<Integer> texIndexList = new ArrayList<>();
|
||||
|
||||
private MogoLocation mLocation;
|
||||
private boolean isFirstLocation = true;
|
||||
CustomMapStyleOptions mCustomMapStyleOptions;
|
||||
|
||||
ArrayList<Marker> currMarkerList;
|
||||
|
||||
public AMapCustomView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public AMapCustomView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public AMapCustomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
try {
|
||||
initView(context);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void initView(Context context) {
|
||||
mContext = context;
|
||||
View smpView = LayoutInflater.from(context).inflate(R.layout.module_overview_map_view, this);
|
||||
mAMapView = smpView.findViewById(R.id.aMapView);
|
||||
overLayerView = findViewById(R.id.overLayer);
|
||||
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset));
|
||||
arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_arrived);
|
||||
unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_un_arrive);
|
||||
} else {
|
||||
overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset_bus));
|
||||
arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow_arrived_img);
|
||||
unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_smooth_route);
|
||||
}
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
|
||||
initAMapView(context);
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
|
||||
//设置全览模式
|
||||
overLayerView.setOnClickListener(v -> {
|
||||
displayCustomOverView();
|
||||
});
|
||||
}
|
||||
|
||||
private void initAMapView(Context context) {
|
||||
Log.d(TAG, "initAMapView");
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
|
||||
mAMap = mAMapView.getMap();
|
||||
mCustomMapStyleOptions = new CustomMapStyleOptions();
|
||||
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
mCustomMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style.data"));
|
||||
mCustomMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra.data"));
|
||||
} else {
|
||||
mCustomMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style_bus.data"));
|
||||
mCustomMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra_bus.data"));
|
||||
}
|
||||
mAMap.setOnMapLoadedListener(() -> {
|
||||
Log.d(TAG, "---onMapLoaded---");
|
||||
if (mCustomMapStyleOptions != null) {
|
||||
// 加载自定义样式
|
||||
mCustomMapStyleOptions.setEnable(true);
|
||||
// 设置自定义样式
|
||||
mAMap.setCustomMapStyle(mCustomMapStyleOptions);
|
||||
}
|
||||
// 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效
|
||||
mAMap.setTrafficEnabled(false);
|
||||
});
|
||||
setUpMap();
|
||||
customOptions();
|
||||
}
|
||||
|
||||
private void setUpMap() {
|
||||
// 地图文字标注
|
||||
mAMap.showMapText(true);
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap.moveCamera(mCameraUpdate);
|
||||
//设置地图的样式
|
||||
UiSettings uiSettings = mAMap.getUiSettings();
|
||||
//地图缩放级别的交换按钮
|
||||
uiSettings.setZoomControlsEnabled(false);
|
||||
//所有手势
|
||||
uiSettings.setAllGesturesEnabled(true);
|
||||
//隐藏指南针
|
||||
uiSettings.setCompassEnabled(false);
|
||||
//设置倾斜手势是否可用。
|
||||
uiSettings.setTiltGesturesEnabled(true);
|
||||
//隐藏默认的定位按钮
|
||||
uiSettings.setMyLocationButtonEnabled(false);
|
||||
//设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
uiSettings.setLogoBottomMargin(-150);
|
||||
Log.d(TAG, "before onMapLoaded");
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义导航View和路况状态
|
||||
*/
|
||||
private void customOptions() {
|
||||
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon))
|
||||
.anchor(0.5f, 0.5f));
|
||||
mCompassMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_custom_corner))
|
||||
.anchor(0.5f, 0.5f));
|
||||
} else {
|
||||
mCarMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon))
|
||||
.anchor(0.5f, 0.5f));
|
||||
mCompassMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_corner))
|
||||
.anchor(0.5f, 0.5f));
|
||||
}
|
||||
|
||||
mStartMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start)));
|
||||
mEndMarker = mAMap.addMarker(new MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end)));
|
||||
}
|
||||
|
||||
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() {
|
||||
|
||||
/**
|
||||
* 根据全路径获取起始点和经停点进行导航路线绘制
|
||||
* 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测
|
||||
* 室内某个bag包自动驾驶启动8s后返回
|
||||
*/
|
||||
@Override
|
||||
public void onAutopilotRotting(@org.jetbrains.annotations.Nullable MessagePad.GlobalPathResp globalPathResp) {
|
||||
Log.d(TAG, "onAutopilotRotting");
|
||||
if (globalPathResp != null) {
|
||||
handlePlanningData(globalPathResp.getWayPointsList());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void handlePlanningData(List<MessagePad.Location> locationList) {
|
||||
if (locationList == null || locationList.size() == 0) return;
|
||||
List list = locationList;
|
||||
// 转成高德坐标系并存储
|
||||
MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext);
|
||||
List<LatLng> planningPointList = MarkerDrawerManager.INSTANCE.getPlanningPoints();
|
||||
UiThreadHandler.post(() -> {
|
||||
displayCustomOverView();
|
||||
drawStartAndEndMarker(planningPointList);
|
||||
});
|
||||
MarkerDrawerManager.INSTANCE.setCallback((points, locIndex) -> {
|
||||
// 每1s刷新一下轨迹线
|
||||
UiThreadHandler.post(() -> {
|
||||
if (points.size() > 0) {
|
||||
drawPolyline(points, locIndex);
|
||||
}
|
||||
});
|
||||
});
|
||||
MarkerDrawerManager.INSTANCE.startLoopCalCarLocation();
|
||||
UiThreadHandler.post(() -> {
|
||||
drawInfrastructureMarkers(locationList);
|
||||
});
|
||||
}
|
||||
|
||||
public void showV2XEventMarkers(List<V2XEvent> v2XEvents) {
|
||||
if (v2XEvents == null || v2XEvents.size() <= 0) return;
|
||||
clearV2XMarkers();
|
||||
ArrayList<MarkerOptions> markerOptionsList = new ArrayList<>();
|
||||
for (V2XEvent event : v2XEvents) {
|
||||
Center center = event.getCenter();
|
||||
if (center != null) {
|
||||
center.getLon();
|
||||
MarkerOptions markerOption = new MarkerOptions();
|
||||
LatLng latLng;
|
||||
if (event.getCoordinateType() == null || event.getCoordinateType() == 0) {
|
||||
latLng = new LatLng(center.getLat(), center.getLon());
|
||||
} else {
|
||||
// wgs84坐标系需转成高德坐标系
|
||||
latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, center.getLat(), center.getLon());
|
||||
}
|
||||
markerOption.position(latLng);
|
||||
markerOption.anchor(0.13f, 1f);
|
||||
markerOption.icon(BitmapDescriptorFactory.fromBitmap(getV2XBitmap(event.getPoiType())));
|
||||
markerOptionsList.add(markerOption);
|
||||
}
|
||||
}
|
||||
if (markerOptionsList.size() > 0) {
|
||||
drawV2XMarkers(markerOptionsList);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawV2XMarkers(ArrayList<MarkerOptions> markerOptionsList) {
|
||||
currMarkerList = mAMap.addMarkers(markerOptionsList, false);
|
||||
}
|
||||
|
||||
private Bitmap getV2XBitmap(String poiType) {
|
||||
V2XMarkerView marker = new V2XMarkerView(getContext(), null, 0, poiType);
|
||||
marker.measure(View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 229), View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 96), View.MeasureSpec.EXACTLY));
|
||||
marker.layout(0, 0, marker.getMeasuredWidth(), marker.getMeasuredHeight());
|
||||
Bitmap bitmap = Bitmap.createBitmap(marker.getWidth(), marker.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
marker.draw(new Canvas(bitmap));
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
public void clearV2XMarkers() {
|
||||
if (currMarkerList != null) {
|
||||
for (Marker marker : currMarkerList) {
|
||||
marker.destroy();
|
||||
}
|
||||
currMarkerList = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
|
||||
CallerPlanningRottingListenerManager.INSTANCE.removeListener(TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onInterceptTouchEvent(MotionEvent ev) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void onCreateView(Bundle savedInstanceState) {
|
||||
if (mAMapView != null) {
|
||||
mAMapView.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
if (mAMapView != null) {
|
||||
mAMapView.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
if (mAMapView != null) {
|
||||
mAMapView.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
if (mAMapView != null) {
|
||||
mAMapView.onDestroy();
|
||||
}
|
||||
|
||||
if (mAMapView != null) {
|
||||
mAMapView.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCustomPolyline() {
|
||||
if (mBottomPolyline != null) {
|
||||
mBottomPolyline.remove();
|
||||
}
|
||||
if (mCoveredPolyline != null) {
|
||||
mCoveredPolyline.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制新基建Markers(比如:摄像头)
|
||||
*
|
||||
* @param locationList
|
||||
*/
|
||||
private void drawInfrastructureMarkers(List<MessagePad.Location> locationList) {
|
||||
if (locationList == null) return;
|
||||
if (!pathMap.isEmpty()) {
|
||||
pathMap.clear();
|
||||
}
|
||||
String geoHash;
|
||||
ArrayList<Infrastructure> infList;
|
||||
for (int i = 0; i < locationList.size(); i++) {
|
||||
LatLng latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, locationList.get(i));
|
||||
geoHash = GeoHash.withCharacterPrecision(latLng.latitude, latLng.longitude, 7).toBase32();
|
||||
// 网格内的轨迹点只取一次s
|
||||
if (!pathMap.containsKey(geoHash)) {
|
||||
// 从缓存的新基建数据中去取对应geoHash的新基建数据集合
|
||||
infList = InfStructureManager.INSTANCE.getData().get(geoHash);
|
||||
if (infList != null) {
|
||||
pathMap.put(geoHash, infList);
|
||||
}
|
||||
}
|
||||
}
|
||||
drawInfMarkers(pathMap);
|
||||
}
|
||||
|
||||
//todo 扶风 需重构此处,封装至 全览
|
||||
public void drawInfMarkers(Map<String, ArrayList<Infrastructure>> infStruMap) {
|
||||
// 绘制新基建数据
|
||||
if (!posInfMap.isEmpty()) {
|
||||
posInfMap.clear();
|
||||
}
|
||||
ArrayList<MarkerOptions> markerOptionsList = new ArrayList();
|
||||
for (ArrayList<Infrastructure> structureList : infStruMap.values()) {
|
||||
// 每个GeoHash内根据坐标系象限分散开摄像头icon显示
|
||||
|
||||
MarkerOptions markerOption = new MarkerOptions();
|
||||
LatLng latLng = new LatLng(Double.valueOf(structureList.get(0).getLat()),
|
||||
Double.valueOf(structureList.get(0).getLon()));
|
||||
markerOption.position(latLng);
|
||||
Bitmap bitmap = getBitmap(structureList.size());
|
||||
markerOption.icon(BitmapDescriptorFactory.fromBitmap(
|
||||
bitmap
|
||||
));
|
||||
markerOption.zIndex(2f);
|
||||
posInfMap.put(latLng, structureList);
|
||||
markerOptionsList.add(markerOption);
|
||||
}
|
||||
mAMap.addMarkers(markerOptionsList, false);
|
||||
mAMap.setOnMarkerClickListener(marker -> {
|
||||
List<Infrastructure> infList = posInfMap.get(marker.getPosition());
|
||||
// 如果是摄像头
|
||||
if (infList != null) {
|
||||
CallerHmiManager.INSTANCE.showVideoDialog(infList);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
private Bitmap getBitmap(int count) {
|
||||
MakerWithCount marker = new MakerWithCount(getContext());
|
||||
marker.setCount(count);
|
||||
|
||||
marker.measure(View.MeasureSpec.makeMeasureSpec(116, View.MeasureSpec.EXACTLY),
|
||||
View.MeasureSpec.makeMeasureSpec(116, View.MeasureSpec.EXACTLY));
|
||||
marker.layout(0, 0, marker.getMeasuredWidth(), marker.getMeasuredHeight());
|
||||
Bitmap bitmap = Bitmap.createBitmap(marker.getWidth(), marker.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
marker.draw(new Canvas(bitmap));
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入自定义全览模式
|
||||
*/
|
||||
private void displayCustomOverView() {
|
||||
ArrayList<LatLng> linePointsLatLng = MarkerDrawerManager.INSTANCE.getPlanningPoints();
|
||||
if (linePointsLatLng.size() > 1) {
|
||||
//圈定地图显示范围
|
||||
//存放经纬度
|
||||
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
|
||||
for (int i = 0; i < linePointsLatLng.size(); i++) {
|
||||
boundsBuilder.include(linePointsLatLng.get(i));
|
||||
}
|
||||
LatLng currentLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
|
||||
boundsBuilder.include(currentLatLng);
|
||||
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder().tilt(mTilt).build();
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100));
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
} else {
|
||||
//设置希望展示的地图缩放级别
|
||||
CameraPosition cameraPosition = new CameraPosition.Builder()
|
||||
.target(mCarMarker.getPosition()).tilt(0).zoom(zoomLevel).build();
|
||||
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制自车
|
||||
*
|
||||
* @param location
|
||||
*/
|
||||
private void drawCarMarker(MogoLocation location) {
|
||||
if (location == null) return;
|
||||
if (mCarMarker != null) {
|
||||
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
|
||||
mCarMarker.setRotateAngle((float) (360 - location.getHeading()));
|
||||
mCarMarker.setPosition(currentLatLng);
|
||||
mCarMarker.setToTop();
|
||||
if (mCompassMarker != null) {
|
||||
mCompassMarker.setRotateAngle((float) (360 - location.getHeading()));
|
||||
mCompassMarker.setPosition(currentLatLng);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制起始点、终点
|
||||
*/
|
||||
private void drawStartAndEndMarker(List<LatLng> coordinates) {
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker.setVisible(false);
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker.setVisible(false);
|
||||
}
|
||||
if (coordinates.size() > 2) {
|
||||
// 设置开始结束Marker位置
|
||||
|
||||
LatLng startLatLng = coordinates.get(0);
|
||||
LatLng endLatLng = coordinates.get(coordinates.size() - 1);
|
||||
|
||||
mStartMarker.setPosition(startLatLng);
|
||||
mEndMarker.setPosition(endLatLng);
|
||||
mStartMarker.setVisible(true);
|
||||
mEndMarker.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制轨迹线
|
||||
*
|
||||
* @param coordinates
|
||||
* @param locIndex
|
||||
*/
|
||||
private void drawPolyline(List<LatLng> coordinates, int locIndex) {
|
||||
if (textureList.size() > 0) {
|
||||
textureList.clear();
|
||||
}
|
||||
if (texIndexList.size() > 0) {
|
||||
texIndexList.clear();
|
||||
}
|
||||
for (int i = 0; i < coordinates.size(); i++) {
|
||||
if (i <= locIndex) {
|
||||
// 已走过的置灰
|
||||
textureList.add(arrivedBitmap);
|
||||
} else {
|
||||
// 未走过的纹理
|
||||
textureList.add(unArrivedBitmap);
|
||||
}
|
||||
texIndexList.add(i);
|
||||
}
|
||||
if (mAMap != null && coordinates.size() > 2) {
|
||||
//设置线段纹理
|
||||
PolylineOptions polylineOptions = new PolylineOptions();
|
||||
polylineOptions.addAll(coordinates);
|
||||
polylineOptions.width(14); //线段宽度
|
||||
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
|
||||
polylineOptions.setCustomTextureList(textureList);
|
||||
polylineOptions.setCustomTextureIndex(texIndexList);
|
||||
// 绘制线
|
||||
mBottomPolyline = mCoveredPolyline;
|
||||
mCoveredPolyline = mAMap.addPolyline(polylineOptions);
|
||||
if (mBottomPolyline != null) {
|
||||
mBottomPolyline.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
mLocation = gnssInfo;
|
||||
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(gnssInfo.getLongitude(), gnssInfo.getLatitude()));
|
||||
drawCarMarker(gnssInfo);
|
||||
if (isFirstLocation) {
|
||||
displayCustomOverView();
|
||||
isFirstLocation = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,163 +0,0 @@
|
||||
package com.mogo.eagle.core.function.smp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.mvp.BaseFragment;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.data.constants.MoGoFragmentPaths;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager;
|
||||
import com.mogo.eagle.core.function.overview.ViewModelExtKt;
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 2021/5/19 10:50 上午
|
||||
* 全览模式Fragment
|
||||
*/
|
||||
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
|
||||
public class OverviewMapFragment extends BaseFragment
|
||||
implements IMogoSmallMapProvider {
|
||||
private final String TAG = "OverviewMapFragment";
|
||||
protected AMapCustomView mAMapCustomView;
|
||||
private OverViewModel mViewModel;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_overview_map_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState) {
|
||||
super.initViews(savedInstanceState);
|
||||
mAMapCustomView = mRootView.findViewById(R.id.smallMapDirectionView);
|
||||
mAMapCustomView.onCreateView(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPanel() {
|
||||
if (mAMapCustomView != null) {
|
||||
mAMapCustomView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePanel() {
|
||||
if (mAMapCustomView != null) {
|
||||
mAMapCustomView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startQueryV2XEvents() {
|
||||
if (isAdded()) {
|
||||
if (mViewModel != null) {
|
||||
mViewModel.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearV2XMarkers() {
|
||||
if (isAdded()) {
|
||||
if (mAMapCustomView != null) {
|
||||
mAMapCustomView.clearV2XMarkers();
|
||||
}
|
||||
if (mViewModel != null) {
|
||||
mViewModel.stopQueryV2XEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mAMapCustomView != null) {
|
||||
mAMapCustomView.onResume();
|
||||
}
|
||||
mAMapCustomView.handlePlanningData(InfStructureManager.INSTANCE.getPlanningData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
// 主动查一次全局路径规划的数据
|
||||
CallerAutoPilotControlManager.INSTANCE.getGlobalPath();
|
||||
queryV2XEvents();
|
||||
}
|
||||
|
||||
private void queryV2XEvents() {
|
||||
mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
|
||||
mViewModel.getV2XEventLiveData().observe(this.getViewLifecycleOwner(), v2XEvents -> {
|
||||
mAMapCustomView.showV2XEventMarkers(v2XEvents);
|
||||
});
|
||||
mViewModel.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Taxi的下发的轨迹id
|
||||
*/
|
||||
private long getLineId() {
|
||||
long lineId = -1;
|
||||
AutopilotControlParameters parameter = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo()
|
||||
.getAutopilotControlParameters();
|
||||
if (parameter != null) {
|
||||
if (parameter.autoPilotLine != null) {
|
||||
lineId = parameter.autoPilotLine.getLineId();
|
||||
}
|
||||
}
|
||||
return lineId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (mAMapCustomView != null) {
|
||||
mAMapCustomView.onPause();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mAMapCustomView != null) {
|
||||
mAMapCustomView.onDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,350 @@
|
||||
package com.mogo.eagle.core.function.smp.view
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.annotation.UiThread
|
||||
import com.amap.api.maps.*
|
||||
import com.amap.api.maps.model.*
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import java.util.*
|
||||
import kotlin.math.floor
|
||||
|
||||
class SmallMapView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
IMoGoPlanningRottingListener,
|
||||
IMoGoAutopilotStatusListener {
|
||||
|
||||
private var mAMapNaviView: TextureMapView? = null
|
||||
private var mAMap: AMap? = null
|
||||
private var mCarMarker: Marker? = null
|
||||
private var mStartMarker: Marker? = null
|
||||
private var mEndMarker: Marker? = null
|
||||
private val zoomLevel = 15
|
||||
private val mCoordinatesLatLng: MutableList<LatLng> = ArrayList()
|
||||
private var mPolyline: Polyline? = null
|
||||
private var mCameraUpdate: CameraUpdate? = null
|
||||
private var mContext: Context? = null
|
||||
private var mLocation: MogoLocation? = null
|
||||
|
||||
private var autoPilotStatus = 0
|
||||
|
||||
companion object {
|
||||
const val TAG = "SmallMapView"
|
||||
}
|
||||
|
||||
init {
|
||||
try {
|
||||
initView(context)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
// =================必须通知高德地图生命周期的变化=================
|
||||
fun onCreateView(savedInstanceState: Bundle?) {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView!!.onCreate(savedInstanceState)
|
||||
}
|
||||
}
|
||||
|
||||
fun onResume() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView!!.onResume()
|
||||
}
|
||||
}
|
||||
|
||||
fun onPause() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView!!.onPause()
|
||||
}
|
||||
}
|
||||
|
||||
fun onDestroy() {
|
||||
if (mAMapNaviView != null) {
|
||||
mAMapNaviView!!.onDestroy()
|
||||
}
|
||||
}
|
||||
// =================必须通知高德地图生命周期的变化=================
|
||||
|
||||
fun convert(coordinates: List<MogoLatLng>) {
|
||||
mCoordinatesLatLng.clear()
|
||||
val latLngs = coordinateConverterFrom84ForList(mContext, coordinates)
|
||||
mCoordinatesLatLng.addAll(latLngs)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun drawablePolyline() {
|
||||
clearPolyline()
|
||||
if (mAMap != null) {
|
||||
if (mCoordinatesLatLng.size > 2) {
|
||||
// 设置开始结束Marker位置
|
||||
mStartMarker!!.position = mCoordinatesLatLng[0]
|
||||
mEndMarker!!.position = mCoordinatesLatLng[mCoordinatesLatLng.size - 1]
|
||||
mStartMarker!!.setToTop()
|
||||
mStartMarker!!.isVisible = true
|
||||
mEndMarker!!.isVisible = true
|
||||
mEndMarker!!.setToTop()
|
||||
|
||||
|
||||
//存放所有点的经纬度
|
||||
val boundsBuilder = LatLngBounds.Builder()
|
||||
for (i in mCoordinatesLatLng.indices) {
|
||||
//把所有点都include进去(LatLng类型)
|
||||
boundsBuilder.include(mCoordinatesLatLng[i])
|
||||
}
|
||||
//第二个参数为四周留空宽度
|
||||
mAMap!!.animateCamera(
|
||||
CameraUpdateFactory.newLatLngBounds(
|
||||
boundsBuilder.build(),
|
||||
30
|
||||
)
|
||||
)
|
||||
// 绘制线
|
||||
mPolyline = mAMap!!.addPolyline(
|
||||
PolylineOptions()
|
||||
.addAll(mCoordinatesLatLng)
|
||||
.color(Color.argb(255, 31, 127, 255))
|
||||
.width(12f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun clearPolyline() {
|
||||
if (mPolyline != null) {
|
||||
mPolyline!!.remove()
|
||||
}
|
||||
if (mStartMarker != null) {
|
||||
mStartMarker!!.isVisible = false
|
||||
}
|
||||
if (mEndMarker != null) {
|
||||
mEndMarker!!.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView(context: Context) {
|
||||
mContext = context
|
||||
val smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this)
|
||||
mAMapNaviView = smpView.findViewById(R.id.aMapNaviView)
|
||||
initAMapView()
|
||||
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, this)
|
||||
CallerPlanningRottingListenerManager.addListener(TAG, this)
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
|
||||
startTask()
|
||||
}
|
||||
|
||||
private fun initAMapView() {
|
||||
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel.toFloat())
|
||||
mAMap = mAMapNaviView!!.map
|
||||
// 关闭地图文字标注
|
||||
mAMap?.showMapText(false)
|
||||
// 设置导航地图模式,aMap是地图控制器对象。
|
||||
mAMap?.mapType = AMap.MAP_TYPE_NIGHT
|
||||
// 关闭显示实时路况图层,aMap是地图控制器对象。
|
||||
mAMap?.isTrafficEnabled = false
|
||||
// 设置 锚点 图标
|
||||
mCarMarker = if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
|
||||
mAMap?.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon))
|
||||
.anchor(0.5f, 0.5f)
|
||||
)
|
||||
} else {
|
||||
mAMap?.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon))
|
||||
.anchor(0.5f, 0.5f)
|
||||
)
|
||||
}
|
||||
mStartMarker = mAMap?.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start))
|
||||
)
|
||||
mEndMarker = mAMap?.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end))
|
||||
)
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(MapAssetStyleUtils.getAssetsStyle(context, "over_view_style.data"))
|
||||
.setStyleExtraData(
|
||||
MapAssetStyleUtils.getAssetsExtraStyle(
|
||||
context,
|
||||
"over_view_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap?.setCustomMapStyle(customMapStyleOptions)
|
||||
//设置希望展示的地图缩放级别
|
||||
mAMap?.moveCamera(mCameraUpdate)
|
||||
// 设置地图的样式
|
||||
val uiSettings = mAMap?.uiSettings
|
||||
uiSettings?.isZoomControlsEnabled = false // 地图缩放级别的交换按钮
|
||||
uiSettings?.setAllGesturesEnabled(false) // 所有手势
|
||||
uiSettings?.isMyLocationButtonEnabled = false // 显示默认的定位按钮
|
||||
uiSettings?.setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
|
||||
mAMap?.setOnMapLoadedListener(AMap.OnMapLoadedListener {
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG,
|
||||
"smp---onMapLoaded"
|
||||
)
|
||||
// 加载自定义样式
|
||||
val customMapStyleOptions1 = CustomMapStyleOptions()
|
||||
.setEnable(true)
|
||||
.setStyleData(MapAssetStyleUtils.getAssetsStyle(context, "over_view_style.data"))
|
||||
.setStyleExtraData(
|
||||
MapAssetStyleUtils.getAssetsExtraStyle(
|
||||
context,
|
||||
"over_view_style_extra.data"
|
||||
)
|
||||
)
|
||||
// 设置自定义样式
|
||||
mAMap?.setCustomMapStyle(customMapStyleOptions1)
|
||||
mAMapNaviView!!.map.setPointToCenter(
|
||||
mAMapNaviView!!.width / 2,
|
||||
mAMapNaviView!!.height / 2
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
private fun startTask() {
|
||||
val mTimer = Timer()
|
||||
mTimer.schedule(UpdateLocationTask(), 1000, 200)
|
||||
}
|
||||
|
||||
private inner class UpdateLocationTask : TimerTask() {
|
||||
override fun run() {
|
||||
if (mLocation != null) {
|
||||
if (mCarMarker == null) {
|
||||
mCarMarker = mAMap!!.addMarker(
|
||||
MarkerOptions()
|
||||
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
|
||||
.anchor(0.5f, 0.5f)
|
||||
)
|
||||
}
|
||||
if (mCarMarker == null) {
|
||||
return
|
||||
}
|
||||
val currentLatLng = LatLng(mLocation!!.latitude, mLocation!!.longitude)
|
||||
val bearing = floor(mLocation!!.heading).toFloat()
|
||||
//更新车辆位置
|
||||
mCarMarker!!.position = currentLatLng
|
||||
if (mCoordinatesLatLng.size > 1) {
|
||||
// 结束位置
|
||||
val endLatLng = mCoordinatesLatLng[mCoordinatesLatLng.size - 1]
|
||||
val calculateDistance = CoordinateUtils.calculateLineDistance(
|
||||
endLatLng.latitude, endLatLng.longitude,
|
||||
currentLatLng.latitude, currentLatLng.longitude
|
||||
)
|
||||
CallerLogger.d(
|
||||
SceneConstant.M_MAP + TAG,
|
||||
"calculateDistance=$calculateDistance"
|
||||
)
|
||||
if (calculateDistance <= 5) {
|
||||
clearPolyline()
|
||||
mCoordinatesLatLng.clear()
|
||||
}
|
||||
}
|
||||
val cameraPosition: CameraPosition =
|
||||
CameraPosition.Builder().target(mCarMarker!!.position).tilt(0f).bearing(bearing)
|
||||
.zoom(zoomLevel.toFloat()).build()
|
||||
mAMap?.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun coordinateConverterFrom84(mContext: Context?, mogoLatLng: MogoLatLng): LatLng {
|
||||
val mCoordinateConverter = CoordinateConverter(mContext)
|
||||
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS)
|
||||
mCoordinateConverter.coord(LatLng(mogoLatLng.lat, mogoLatLng.lon))
|
||||
return mCoordinateConverter.convert()
|
||||
}
|
||||
|
||||
private fun coordinateConverterFrom84ForList(
|
||||
mContext: Context?,
|
||||
mogoLatLngList: List<MogoLatLng>
|
||||
): List<LatLng> {
|
||||
val list: MutableList<LatLng> = ArrayList()
|
||||
for (m in mogoLatLngList) {
|
||||
val mogoLatLng = coordinateConverterFrom84(mContext, m)
|
||||
list.add(mogoLatLng)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
if (mogoLocation == null) {
|
||||
return
|
||||
}
|
||||
mLocation = mogoLocation
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
val tempStatus = autoPilotStatusInfo.pilotmode
|
||||
if (tempStatus != 1) {
|
||||
UiThreadHandler.post {
|
||||
clearPolyline()
|
||||
}
|
||||
} else if (tempStatus == 1 && autoPilotStatus == 0) {
|
||||
getGlobalPath()
|
||||
}
|
||||
autoPilotStatus = tempStatus
|
||||
}
|
||||
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
if (globalPathResp == null || globalPathResp.wayPointsList.size == 0) {
|
||||
return
|
||||
}
|
||||
val latLngList: MutableList<MogoLatLng> = ArrayList()
|
||||
for (routeModel in globalPathResp.wayPointsList) {
|
||||
latLngList.add(MogoLatLng(routeModel.latitude, routeModel.longitude))
|
||||
}
|
||||
if (latLngList.size > 0) {
|
||||
UiThreadHandler.post {
|
||||
convert(latLngList)
|
||||
drawablePolyline()
|
||||
}
|
||||
} else {
|
||||
UiThreadHandler.post {
|
||||
clearPolyline()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
|
||||
CallerPlanningRottingListenerManager.removeListener(TAG)
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.mogo.eagle.core.function.smp.AMapCustomView
|
||||
android:id="@+id/smallMapDirectionView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -94,7 +94,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback,
|
||||
V2XManager.init(V2XConfig.Builder().also {
|
||||
it.aiCloudConfig(MoGoAiCloudClientConfig.getInstance())
|
||||
it.context(context)
|
||||
it.loggable(true)
|
||||
it.loggable(false)
|
||||
it.distanceForTriggerRefresh(200f) //行驶超过200(包含)米,刷新道路周边信息(短链请求)
|
||||
it.durationForTriggerRefresh(
|
||||
60,
|
||||
|
||||
@@ -16,17 +16,6 @@ public class V2XConst {
|
||||
public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
|
||||
public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
|
||||
|
||||
/**
|
||||
* V2X 测试控制面板广播Action
|
||||
*/
|
||||
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
|
||||
|
||||
public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast";
|
||||
|
||||
|
||||
public static final String V2X_ROAD_PRODUCE = "v2x_road_produce";
|
||||
|
||||
public static final String LAUNCHER_ICON_CLICK = "Launcher_Icon_Click";
|
||||
|
||||
/**
|
||||
* V2X预警日志tag
|
||||
|
||||
@@ -57,10 +57,6 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
// 提取之前存储的场景
|
||||
if (v2XMessageEntity != null) {
|
||||
// 广播给应用内部其它模块
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(Utils.getApp()).sendBroadcast(intent);
|
||||
// 如果没有拿到之前的,根据类型分发
|
||||
switch (v2XMessageEntity.getType()) {
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:
|
||||
|
||||
@@ -38,8 +38,6 @@ class AiRoadMarker {
|
||||
|
||||
private val marker by lazy { AtomicReference<Marker>() }
|
||||
|
||||
private val carLocation by lazy { AtomicReference<Triple<Double, Double, Double>>() }
|
||||
|
||||
private val overlayManager by lazy {
|
||||
CallerMapUIServiceManager.getOverlayManager(
|
||||
AbsMogoApplication.getApp()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.test
|
||||
|
||||
class TestConsts {
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
/**
|
||||
* V2X 测试控制面板广播Action
|
||||
*/
|
||||
@JvmField
|
||||
val BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType"
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class TestV2XReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
try {
|
||||
this.mContext = context;
|
||||
int sceneType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
int sceneType = intent.getIntExtra(TestConsts.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
|
||||
|
||||
// 分发场景
|
||||
dispatchSceneTest(sceneType);
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
package com.mogo.eagle.core.function.overview.remote
|
||||
package com.mogo.eagle.core.data.v2x
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
|
||||
|
||||
@Keep
|
||||
data class V2XEventResult (
|
||||
@SerializedName("result")
|
||||
var result: Result?
|
||||
): BaseData()
|
||||
|
||||
@Keep
|
||||
data class Result(
|
||||
@SerializedName("eventList")
|
||||
var v2XEventList: List<V2XEvent>?
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class V2XEvent(
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.eagle.core.function.api.autopilot
|
||||
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility
|
||||
|
||||
|
||||
/**
|
||||
* pnc actions 决策 驾驶的意图
|
||||
@@ -11,5 +9,5 @@ interface IMoGoAutopilotActionsListener {
|
||||
/**
|
||||
* pnc actions 决策 驾驶的意图
|
||||
*/
|
||||
fun onAutopilotAbility(ability: AutopilotAbility?)
|
||||
fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?)
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mogo.eagle.core.function.api.biz
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.eagle.core.data.camera.CameraEntity
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
|
||||
|
||||
@@ -51,4 +52,10 @@ interface IMoGoFuncBizProvider : IMoGoFunctionServerProvider {
|
||||
*/
|
||||
fun closeCameraLive()
|
||||
|
||||
/*----------------------------------------全览模式----------------------------------------*/
|
||||
fun fetchInfStructures()
|
||||
|
||||
fun getAllV2XEvents()
|
||||
|
||||
fun initOverViewDb(context: Context)
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.eagle.core.function.api.v2x
|
||||
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
|
||||
interface IFuncBizProvider {
|
||||
/**
|
||||
* 查询衡阳所有的摄像头数据
|
||||
*/
|
||||
fun onInfStructures(map: HashMap<String, ArrayList<Infrastructure>>?) {}
|
||||
|
||||
/**
|
||||
* 根据lineId获取整条道路的V2X事件
|
||||
*/
|
||||
fun onV2XEvents(v2xEvents: List<V2XEvent>?) {}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.mogo.eagle.core.function.call.autopilot
|
||||
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotActionsListener
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility
|
||||
|
||||
|
||||
/**
|
||||
@@ -11,10 +10,10 @@ import com.zhidao.support.adas.high.bean.AutopilotAbility
|
||||
object CallerAutopilotActionsListenerManager : CallerBase<IMoGoAutopilotActionsListener>() {
|
||||
|
||||
@Synchronized
|
||||
fun invokeAutopilotAbility(ability: AutopilotAbility?) {
|
||||
fun invokeAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onAutopilotAbility(ability)
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
object CallerRoboBusJinlvM1StatesListenerManager : CallerBase<IMoGoRoboBusJinlvM1StatesListener>() {
|
||||
|
||||
/**
|
||||
* 电池管理系统
|
||||
* 金旅M1
|
||||
*/
|
||||
fun invokeRoboBusJinlvM1States(states: VehicleStateOuterClass.RoboBusJinlvM1State) {
|
||||
M_LISTENERS.forEach {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.mogo.eagle.core.function.call.biz
|
||||
|
||||
import androidx.annotation.MainThread
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
import com.mogo.eagle.core.function.api.v2x.IFuncBizProvider
|
||||
import com.mogo.eagle.core.function.call.base.CallerBase
|
||||
|
||||
object CallerFuncBizListenerManager: CallerBase<IFuncBizProvider>() {
|
||||
|
||||
private var map: HashMap<String, java.util.ArrayList<Infrastructure>>? = null
|
||||
|
||||
override fun doSomeAfterAddListener(tag: String, listener: IFuncBizProvider) {
|
||||
listener.onInfStructures(map)
|
||||
}
|
||||
|
||||
@MainThread
|
||||
fun invokeInfStructures(map: HashMap<String, java.util.ArrayList<Infrastructure>>) {
|
||||
this.map = map
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onInfStructures(map)
|
||||
}
|
||||
}
|
||||
|
||||
@MainThread
|
||||
fun invokeV2XEvents(v2xEvents: List<V2XEvent>?) {
|
||||
M_LISTENERS.forEach {
|
||||
val listener = it.value
|
||||
listener.onV2XEvents(v2xEvents)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,9 +20,9 @@ object CallerSmpManager : CallerBase<Any>() {
|
||||
get() = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_SMP)
|
||||
.navigation() as IMogoSmallMapProvider
|
||||
|
||||
private val mogoOverViewMapProvider: IMogoSmallMapProvider
|
||||
get() = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
|
||||
.navigation() as IMogoSmallMapProvider
|
||||
// private val mogoOverViewMapProvider: IMogoSmallMapProvider
|
||||
// get() = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
|
||||
// .navigation() as IMogoSmallMapProvider
|
||||
|
||||
private val v2xProvider: IV2XEventProvider
|
||||
get() = ARouter.getInstance().build(MogoServicePaths.PATH_V2X_MODULE)
|
||||
@@ -65,22 +65,22 @@ object CallerSmpManager : CallerBase<Any>() {
|
||||
if (Thread.currentThread() !== Looper.getMainLooper().thread) {
|
||||
UiThreadHandler.post {
|
||||
v2xProvider.queryWholeRoadEvents()
|
||||
mogoOverViewMapProvider.startQueryV2XEvents()
|
||||
// mogoOverViewMapProvider.startQueryV2XEvents()
|
||||
}
|
||||
} else {
|
||||
v2xProvider.queryWholeRoadEvents()
|
||||
mogoOverViewMapProvider.startQueryV2XEvents()
|
||||
// mogoOverViewMapProvider.startQueryV2XEvents()
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun clearV2XMarkers() {
|
||||
if (Thread.currentThread() !== Looper.getMainLooper().thread) {
|
||||
UiThreadHandler.post {
|
||||
mogoOverViewMapProvider.clearV2XMarkers()
|
||||
}
|
||||
} else {
|
||||
mogoOverViewMapProvider.clearV2XMarkers()
|
||||
}
|
||||
// if (Thread.currentThread() !== Looper.getMainLooper().thread) {
|
||||
// UiThreadHandler.post {
|
||||
// mogoOverViewMapProvider.clearV2XMarkers()
|
||||
// }
|
||||
// } else {
|
||||
// mogoOverViewMapProvider.clearV2XMarkers()
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import static com.zhidao.support.adas.high.chain.AdasChain.CHAIN_LINK_ADAS;
|
||||
import static com.zhidao.support.adas.high.chain.AdasChain.CHAIN_LINK_LOG_CONNECT_STATUS;
|
||||
import static com.zhidao.support.adas.high.chain.AdasChain.CHAIN_LINK_LOG_WEB_SOCKET_AUTOPILOT;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
|
||||
@@ -79,6 +81,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
private RawUnpack rawUnpack;//业务数据拆包
|
||||
private RawPack rawPack;//数据打包
|
||||
private DispatchHandler defaultDispatchHandler;//默认分发线程分发
|
||||
private DispatchHandler statusQueryRespDispatchHandler;//状态查询应答分发线程分发
|
||||
private final Map<MessagePad.MessageType, DispatchHandler> dispatchHandlers = new HashMap<>();//其他分发线程
|
||||
private Timer checkCompatibilityTimer;//检查版本兼容性定时器 连接成功后5秒内等待工控机发送配置信息
|
||||
private int seqSpecialVehicle = 0;//特种车辆命令发送次数
|
||||
@@ -181,6 +184,12 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
//启用线程分发
|
||||
defaultDispatchHandler = new DispatchHandler(MessagePad.MessageType.MsgTypeDefault, this);//默认分发线程 不要添加到Map中
|
||||
initOtherDispatchHandler();
|
||||
AutopilotAbilityManager.getInstance().setOnAutopilotAbilityListener(new AutopilotAbilityManager.OnAutopilotAbilityListener() {
|
||||
@Override
|
||||
public void onStatusQuery() {
|
||||
statusQueryRespDispatchHandler.start();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -234,8 +243,9 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
// dispatchHandlers.put(MessagePad.MessageType.MsgTypeWarn, new DispatchHandler(MessagePad.MessageType.MsgTypeWarn, this));
|
||||
//到站提醒
|
||||
// dispatchHandlers.put(MessagePad.MessageType.MsgTypeArrivalNotification, new DispatchHandler(MessagePad.MessageType.MsgTypeArrivalNotification, this));
|
||||
//状态查询应答
|
||||
// dispatchHandlers.put(MessagePad.MessageType.MsgTypeStatusQueryResp, new DispatchHandler(MessagePad.MessageType.MsgTypeStatusQueryResp, this));
|
||||
//状态查询应答 TODO 此线程更新频率目前为3秒,但是由于会在此接口中做一些其他数据处理,所以单独开启线程
|
||||
statusQueryRespDispatchHandler = new DispatchHandler(MessagePad.MessageType.MsgTypeStatusQueryResp, this);
|
||||
dispatchHandlers.put(MessagePad.MessageType.MsgTypeStatusQueryResp, statusQueryRespDispatchHandler);
|
||||
//数据采集配置
|
||||
// dispatchHandlers.put(MessagePad.MessageType.MsgTypeRecordDataConfigResp, new DispatchHandler(MessagePad.MessageType.MsgTypeRecordDataConfigResp, this));
|
||||
//Planning决策状态
|
||||
@@ -412,6 +422,20 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHandler(MessagePad.MessageType type, Handler handler) {
|
||||
if (type == MessagePad.MessageType.MsgTypeStatusQueryResp) {
|
||||
AutopilotAbilityManager.getInstance().setHandler(handler);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHandleMessage(MessagePad.MessageType type, Message msg) {
|
||||
if (type == MessagePad.MessageType.MsgTypeStatusQueryResp) {
|
||||
AutopilotAbilityManager.getInstance().onHandleMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分发和解析
|
||||
*
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import com.zhidao.support.adas.high.common.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.subscribe.SubscribeInterfaceOptions;
|
||||
|
||||
import java.util.HashSet;
|
||||
@@ -124,6 +125,17 @@ public class AdasOptions {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份/车型
|
||||
*
|
||||
* @param identityMode 车型
|
||||
* @return
|
||||
*/
|
||||
public Builder setIdentityMode(String identityMode) {
|
||||
options.setIdentityMode(identityMode);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AdasOptions build() {
|
||||
return options;
|
||||
}
|
||||
@@ -141,6 +153,7 @@ public class AdasOptions {
|
||||
options.ipcAssignIP = null;
|
||||
options.ipcFixationIP = null;
|
||||
options.subscribeInterfaceOptions = null;
|
||||
options.setIdentityMode("");
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -183,4 +196,8 @@ public class AdasOptions {
|
||||
public void setSubscribeInterfaceOptions(SubscribeInterfaceOptions subscribeInterfaceOptions) {
|
||||
this.subscribeInterfaceOptions = subscribeInterfaceOptions;
|
||||
}
|
||||
|
||||
public void setIdentityMode(String identityMode) {
|
||||
AutopilotAbilityManager.getInstance().setIdentityMode(identityMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import com.mogo.support.obu.ObuScene;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatistics;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
|
||||
@@ -263,9 +262,10 @@ public interface OnAdasListener {
|
||||
/**
|
||||
* 是否有能力启动自动驾驶
|
||||
*
|
||||
* @param ability 是否可以启动自动驾驶
|
||||
* @param isAutopilotAbility 是否能启动自动驾驶
|
||||
* @param unableAutopilotReason 不能启动自动驾驶原因
|
||||
*/
|
||||
void onAutopilotAbility(AutopilotAbility ability);
|
||||
void onAutopilotAbility(boolean isAutopilotAbility, String unableAutopilotReason);
|
||||
|
||||
/**
|
||||
* 启动自动驾驶失败回调
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import chassis.Chassis;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 自动驾驶能力 能否启动自动驾驶
|
||||
* 未赋值表示接口通讯异常或者工控机相关节点异常 如果回调持续都是未赋值的状态表示此问题是持久性的
|
||||
*/
|
||||
public class AutopilotAbility {
|
||||
/**
|
||||
* 刹车踏板开度 0~100
|
||||
* -1表示未赋值
|
||||
* 值为0时表示 制动踏板未踩下
|
||||
*/
|
||||
public final float brake;
|
||||
/**
|
||||
* 挡位
|
||||
* null表示未赋值
|
||||
* 挡位处于P挡和R挡时不能启动自动驾驶
|
||||
*/
|
||||
public final Chassis.GearPosition gear;
|
||||
/**
|
||||
* 状态查询结果
|
||||
* null表示未赋值
|
||||
* 不能启动自动驾驶的判断
|
||||
* statusInfo.getHealthInfoList().get().getState()== SystemStatusInfo.HealthState.FAULT
|
||||
* statusInfo.getSysState()== SystemStatusInfo.SystemState.SYS_STARTING
|
||||
* statusInfo.getSysState()== SystemStatusInfo.SystemState.SYS_EXITING
|
||||
* statusInfo.getSysState()== SystemStatusInfo.SystemState.SYS_FAULT
|
||||
*/
|
||||
public final SystemStatusInfo.StatusInfo statusInfo;
|
||||
|
||||
public AutopilotAbility(float brake, Chassis.GearPosition gear, SystemStatusInfo.StatusInfo statusInfo) {
|
||||
this.brake = brake;
|
||||
this.gear = gear;
|
||||
this.statusInfo = statusInfo;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,6 @@ public class AutopilotStatistics {
|
||||
* 0 成功
|
||||
* 1 失败
|
||||
* 2 取消
|
||||
* 3 超时
|
||||
* {@link com.zhidao.support.adas.high.common.Constants.AUTOPILOT_START_STATUS}
|
||||
*/
|
||||
@Define.AutopilotStartStatus
|
||||
@@ -37,10 +36,7 @@ public class AutopilotStatistics {
|
||||
*/
|
||||
public final MogoReportMsg.MogoReportMessage failedMessage;
|
||||
|
||||
public AutopilotStatistics(@Define.AutopilotStartStatus int status,
|
||||
long usedTime,
|
||||
MessagePad.SetAutopilotModeReq req,
|
||||
MogoReportMsg.MogoReportMessage failedMessage) {
|
||||
public AutopilotStatistics(@Define.AutopilotStartStatus int status, long usedTime, MessagePad.SetAutopilotModeReq req, MogoReportMsg.MogoReportMessage failedMessage) {
|
||||
this.status = status;
|
||||
this.usedTime = usedTime;
|
||||
this.req = req;
|
||||
|
||||
@@ -1,37 +1,88 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotAbility;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import chassis.Chassis;
|
||||
import chassis.VehicleStateOuterClass;
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
import system_master.SystemStatusInfo;
|
||||
|
||||
/**
|
||||
* 是否可以启动自动驾驶能力检测
|
||||
* 目前监控了底盘的一些状态和查询节点状态应答的数据
|
||||
* 没有使用监控事件报告的原因是因为,部分异常没进行正常恢复通知,例如收到了异常监控数据,但是异常恢复之后没有恢复的通知
|
||||
*
|
||||
* <p>
|
||||
* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态
|
||||
*/
|
||||
public class AutopilotAbilityManager {
|
||||
private static final String TAG = AutopilotAbilityManager.class.getSimpleName();
|
||||
private static final int WHAT_TIMEOUT = 0;
|
||||
private static final int DEFAULT_TIMEOUT = 1500;
|
||||
private static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测时间
|
||||
private static final String[] NODE_INFO_STATE = {"未知状态 ", "依赖未就绪 ", "启动中 ", "运行 ", "停止 ", "无法启动状态 ", "人为启动状态 ", "人为关闭状态 "};
|
||||
private static volatile AutopilotAbilityManager INSTANCE;
|
||||
|
||||
private OnAdasListener listener;
|
||||
private volatile Timer timer;
|
||||
private final Pattern pattern = Pattern.compile("\\d+.\\d+.\\d+");
|
||||
private ChassisStatesOuterClass.ChassisStates chassisStates;
|
||||
private Handler handler;
|
||||
private OnAutopilotAbilityListener onAutopilotAbilityListener;
|
||||
/**
|
||||
* 身份/车型
|
||||
*/
|
||||
private String identityMode;
|
||||
|
||||
private VehicleStateOuterClass.VehicleState vehicleState;
|
||||
public interface OnAutopilotAbilityListener {
|
||||
void onStatusQuery();//查询是被调用
|
||||
}
|
||||
|
||||
/**
|
||||
* 身份规则定义根据app/productFlavors/README.md
|
||||
* * taxi司机屏 Taxi_Driver_Base (东风、红旗司机端)
|
||||
* * taxi乘客屏 Taxi_Passenger_Base (东风、红旗乘客端)
|
||||
* * bus司机屏 Bus_Driver_Base (金旅小巴司机端)
|
||||
* * Bus_Driver_Van (开沃小巴司机端)
|
||||
* * bus乘客屏 Bus_Passenger_Base (金旅、开沃小巴乘客端)
|
||||
* * Bus_Passenger_M1 (M1小巴乘客端)
|
||||
* * Bus_Passenger_M2 (M2小巴乘客端)
|
||||
* * 清扫车 Sweeper_Driver_FT (福田清扫车司机端)
|
||||
* <p>
|
||||
* 此定义不区分角色,只区分业务线和车型
|
||||
*/
|
||||
private interface IDENTITY_MODE {
|
||||
String TAXI_DRIVER_BASE = "Taxi_Driver_Base";//(东风、红旗司机端)
|
||||
String TAXI_PASSENGER_BASE = "Taxi_Passenger_Base";//(东风、红旗乘客端)
|
||||
String BUS_DRIVER_BASE = "Bus_Driver_Base";//(金旅小巴司机端)
|
||||
String BUS_DRIVER_VAN = "Bus_Driver_Van";//(开沃小巴司机端)
|
||||
String BUS_PASSENGER_BASE = "Bus_Passenger_Base";//(金旅、开沃小巴乘客端)
|
||||
String BUS_PASSENGER_M1 = "Bus_Passenger_M1";//(M1小巴乘客端)
|
||||
String BUS_PASSENGER_M2 = "Bus_Passenger_M2";//(M2小巴乘客端)
|
||||
String SWEEPER_DRIVER_FT = "Sweeper_Driver_FT";//(福田清扫车司机端)
|
||||
}
|
||||
|
||||
|
||||
public void setIdentityMode(String identityMode) {
|
||||
this.identityMode = identityMode;
|
||||
}
|
||||
|
||||
public void setOnAdasListener(OnAdasListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public void setOnAutopilotAbilityListener(OnAutopilotAbilityListener onAutopilotAbilityListener) {
|
||||
this.onAutopilotAbilityListener = onAutopilotAbilityListener;
|
||||
}
|
||||
|
||||
private AutopilotAbilityManager() {
|
||||
}
|
||||
|
||||
@@ -47,19 +98,147 @@ public class AutopilotAbilityManager {
|
||||
}
|
||||
|
||||
public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
if (listener != null) {
|
||||
float brake = -1;
|
||||
Chassis.GearPosition gear = null;
|
||||
if (vehicleState != null) {
|
||||
brake = vehicleState.getBrake();
|
||||
gear = vehicleState.getGear();
|
||||
}
|
||||
listener.onAutopilotAbility(new AutopilotAbility(brake, gear, statusInfo));
|
||||
if (handler != null) {
|
||||
if (handler.hasMessages(WHAT_TIMEOUT))
|
||||
handler.removeMessages(WHAT_TIMEOUT);
|
||||
}
|
||||
onCallback(statusInfo);
|
||||
}
|
||||
|
||||
public void setVehicleState(VehicleStateOuterClass.VehicleState vehicleState) {
|
||||
this.vehicleState = vehicleState;
|
||||
public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) {
|
||||
this.chassisStates = chassisStates;
|
||||
}
|
||||
|
||||
private void onCallback(SystemStatusInfo.StatusInfo statusInfo) {
|
||||
//金旅、开沃小巴乘客端 不能启动自动驾驶
|
||||
if (IDENTITY_MODE.BUS_PASSENGER_BASE.equalsIgnoreCase(identityMode)) {
|
||||
return;
|
||||
}
|
||||
boolean isAutopilotAbility = true;//是否能启动自动驾驶
|
||||
String unableAutopilotReason = null;//不能启动自动驾驶原因
|
||||
//检测节点状态相关
|
||||
if (statusInfo != null) {
|
||||
int version = -1;
|
||||
if (statusInfo.hasMasterVersion()) {
|
||||
//截取Master Version
|
||||
String masterVersion = statusInfo.getMasterVersion();
|
||||
if (!TextUtils.isEmpty(masterVersion)) {
|
||||
try {
|
||||
Matcher matcher = pattern.matcher(masterVersion);
|
||||
if (matcher.find()) {
|
||||
String group = matcher.group();
|
||||
if (!TextUtils.isEmpty(group)) {
|
||||
String v = group.split("\\.")[0];
|
||||
version = Integer.parseInt(v);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (version > 1) {
|
||||
isAutopilotAbility = statusInfo.getAutoPilotReady();
|
||||
if (!isAutopilotAbility) {
|
||||
SystemStatusInfo.NodeFaultList nodeFaultList = statusInfo.getAutoPilotUnreadyList();
|
||||
if (nodeFaultList.getSum() > 0) {
|
||||
List<SystemStatusInfo.NodeInfo> list = nodeFaultList.getNodeList();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (SystemStatusInfo.NodeInfo info : list) {
|
||||
builder.append(info.getNodeName());
|
||||
int state = info.getState();
|
||||
if (state < NODE_INFO_STATE.length) {
|
||||
builder.append(NODE_INFO_STATE[state]);
|
||||
} else {
|
||||
builder.append("未知 ");
|
||||
}
|
||||
}
|
||||
unableAutopilotReason = builder.toString();
|
||||
} else {
|
||||
unableAutopilotReason = "未知";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SystemStatusInfo.SystemState systemState = statusInfo.getSysState();
|
||||
if (systemState != SystemStatusInfo.SystemState.SYS_RUNNING && systemState != SystemStatusInfo.SystemState.PILOT_READY) {
|
||||
isAutopilotAbility = false;
|
||||
if (systemState == SystemStatusInfo.SystemState.SYS_STARTING) {
|
||||
unableAutopilotReason = "系统正在启动";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.SYS_EXITING) {
|
||||
unableAutopilotReason = "系统正在关闭";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.SYS_FAULT) {
|
||||
unableAutopilotReason = "系统异常";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.AUTO_PILOT_STARTING) {
|
||||
unableAutopilotReason = "正在开始自动驾驶";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.AUTO_PILOT_RUNNING) {
|
||||
unableAutopilotReason = "自动驾驶运行中";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.REMOTE_PILOT_STARTING) {
|
||||
unableAutopilotReason = "平行驾驶启动中";
|
||||
} else if (systemState == SystemStatusInfo.SystemState.REMOTE_PILOT_RUNNING) {
|
||||
unableAutopilotReason = "平行驾驶运行中";
|
||||
} else {
|
||||
unableAutopilotReason = "未知";
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isAutopilotAbility = false;//是否能启动自动驾驶
|
||||
unableAutopilotReason = "SSM状态查询超时无响应";//不能启动自动驾驶原因
|
||||
}
|
||||
//检测底盘相关
|
||||
if (chassisStates != null) {
|
||||
if (isAutopilotAbility) {
|
||||
if (chassisStates.hasBrakeSystemStates()) {
|
||||
float brake = chassisStates.getBrakeSystemStates().getBrakePedalResponsePosition();
|
||||
if (brake > 0) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "制动踏板被踩下";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isAutopilotAbility) {
|
||||
/**
|
||||
* 档位状态判断 目前判断的车型包括 东风Taxi 红旗Taxi 金旅Bus 金旅M1 金旅M1 福田清扫车 开沃
|
||||
* TODO 如果 identityMode 未赋值以及目前已知其他车型判断逻辑跟东风Taxi和红旗 走
|
||||
*/
|
||||
if (chassisStates.hasGearSystemStates()) {
|
||||
Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition();
|
||||
if (TextUtils.isEmpty(identityMode)) {
|
||||
identityMode = "";
|
||||
}
|
||||
//开沃任何档位都能启动自驾
|
||||
if (!IDENTITY_MODE.BUS_DRIVER_VAN.equalsIgnoreCase(identityMode)) {
|
||||
//金旅Bus和清扫车 档位不正常
|
||||
if (IDENTITY_MODE.BUS_DRIVER_BASE.equalsIgnoreCase(identityMode) || IDENTITY_MODE.SWEEPER_DRIVER_FT.equalsIgnoreCase(identityMode)) {
|
||||
if (gear == Chassis.GearPosition.GEAR_N) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "挡位不正常";
|
||||
}
|
||||
} else {
|
||||
//东风Taxi和红旗 司机端和乘客端 档位不正常
|
||||
if (gear == Chassis.GearPosition.GEAR_P || gear == Chassis.GearPosition.GEAR_R) {
|
||||
isAutopilotAbility = false;
|
||||
unableAutopilotReason = "挡位不正常";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO 关于手刹:不同车型的实现不同所以目前没法使用此字段
|
||||
// if (isAutopilotAbility) {
|
||||
// //电子驻车制动系统
|
||||
// if (chassisStates.hasEpbSystemStates()) {
|
||||
// ChassisStatesOuterClass.EPBSystemStates epb = chassisStates.getEpbSystemStates();
|
||||
// if (epb.hasEpbEnableState()){
|
||||
// epb.getEpbWorkState();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (listener != null) {
|
||||
listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
@@ -68,7 +247,15 @@ public class AutopilotAbilityManager {
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (onAutopilotAbilityListener != null) {
|
||||
onAutopilotAbilityListener.onStatusQuery();
|
||||
}
|
||||
AdasManager.getInstance().sendStatusQueryReq();
|
||||
if (handler != null) {
|
||||
if (handler.hasMessages(WHAT_TIMEOUT))
|
||||
handler.removeMessages(WHAT_TIMEOUT);
|
||||
handler.sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
}, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步
|
||||
}
|
||||
@@ -79,8 +266,18 @@ public class AutopilotAbilityManager {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
this.vehicleState = null;
|
||||
handler = null;
|
||||
this.chassisStates = null;
|
||||
}
|
||||
|
||||
public void setHandler(Handler handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
public void onHandleMessage(Message msg) {
|
||||
if (msg.what == WHAT_TIMEOUT) {
|
||||
onCallback(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,13 +16,6 @@ import mogo_msg.MogoReportMsg;
|
||||
* 自动驾驶状态检查/统计
|
||||
*/
|
||||
public class AutopilotReview {
|
||||
/**
|
||||
* 默认启动自驾超时时间
|
||||
*/
|
||||
private static final long DEFAULT_TIMEOUT = 15 * 1000L;
|
||||
|
||||
|
||||
private Timer timer;
|
||||
/**
|
||||
* 下发的启动自动驾驶命令
|
||||
*/
|
||||
@@ -45,7 +38,6 @@ public class AutopilotReview {
|
||||
}
|
||||
|
||||
private void onCallback(@Define.AutopilotStartStatus int status) {
|
||||
stopTimer();
|
||||
long usedTime = SystemClock.elapsedRealtime() - startTime;
|
||||
if (listener != null) {
|
||||
listener.onReview(new AutopilotStatistics(status, usedTime, startReq, failedMessage));
|
||||
@@ -56,25 +48,6 @@ public class AutopilotReview {
|
||||
}
|
||||
|
||||
|
||||
private void startTimer() {
|
||||
if (timer == null) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
//超时
|
||||
onCallback(Constants.AUTOPILOT_START_STATUS.TIMEOUT);
|
||||
}
|
||||
}, DEFAULT_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
private void stopTimer() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾命令
|
||||
@@ -86,7 +59,6 @@ public class AutopilotReview {
|
||||
//启动自动驾驶
|
||||
startReq = req;
|
||||
startTime = SystemClock.elapsedRealtime();
|
||||
startTimer();
|
||||
} else {
|
||||
onCallback(Constants.AUTOPILOT_START_STATUS.CANCEL);
|
||||
}
|
||||
|
||||
@@ -126,10 +126,6 @@ public class Constants {
|
||||
* 取消
|
||||
*/
|
||||
int CANCEL = 2;
|
||||
/**
|
||||
* 超时
|
||||
*/
|
||||
int TIMEOUT = 3;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,8 +49,7 @@ public final class Define {
|
||||
|
||||
@IntDef(flag = true, value = {Constants.AUTOPILOT_START_STATUS.SUCCESSFUL,
|
||||
Constants.AUTOPILOT_START_STATUS.FAILED,
|
||||
Constants.AUTOPILOT_START_STATUS.CANCEL,
|
||||
Constants.AUTOPILOT_START_STATUS.TIMEOUT})
|
||||
Constants.AUTOPILOT_START_STATUS.CANCEL})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface AutopilotStartStatus {
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.zhidao.support.adas.high.common;
|
||||
|
||||
/**
|
||||
* 监控事件报告中定义的事件以及解释
|
||||
* 根据MAP2.10.0消息定义编写
|
||||
* 根据MAP2.11.0消息定义编写
|
||||
*/
|
||||
public class MogoReport {
|
||||
public static final String RESULT_AUTOPILOT_SYSTEM_UNSTARTED = "RESULT_AUTOPILOT_SYSTEM_UNSTARTED";
|
||||
@@ -12,33 +12,15 @@ public class MogoReport {
|
||||
public static final String RESULT_REMOTEPILOT_INFERIOR = "RESULT_REMOTEPILOT_INFERIOR";
|
||||
public static final String RESULT_SHOW_WARNING = "RESULT_SHOW_WARNING";
|
||||
|
||||
// private static final String RESULT_DISCONNECTED_WITH_PAD = "RESULT_DISCONNECTED_WITH_PAD";
|
||||
// private static final String RESULT_PAD_CANNOT_CONNECT_TELEMATICS = "RESULT_PAD_CANNOT_CONNECT_TELEMATICS";
|
||||
// private static final String RESULT_PAD_INFO_LOST = "RESULT_PAD_INFO_LOST";
|
||||
// private static final String RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS = "RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS";
|
||||
// private static final String RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS = "RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS";
|
||||
// private static final String RESULT_PAD_CANNOT_GET_OBSTACLE_INFO = "RESULT_PAD_CANNOT_GET_OBSTACLE_INFO";
|
||||
// private static final String RESULT_NO_CONNECTION_TO_AICLOUD = "RESULT_NO_CONNECTION_TO_AICLOUD";
|
||||
// private static final String RESULT_AICLOUD_INFO_LOST = "RESULT_AICLOUD_INFO_LOST";
|
||||
// private static final String RESULT_CANNOT_CHANGE_LIGHT = "RESULT_CANNOT_CHANGE_LIGHT";
|
||||
|
||||
public enum Result {
|
||||
AUTOPILOT_SYSTEM_UNSTARTED(RESULT_AUTOPILOT_SYSTEM_UNSTARTED, "自动驾驶系统启动过程中出错,pad可能无法连接,云端监控可能无法上报"),
|
||||
AUTOPILOT_DISABLE(RESULT_AUTOPILOT_DISABLE, "无法启动自动驾驶"),
|
||||
AUTOPILOT_INFERIOR(RESULT_AUTOPILOT_INFERIOR, "自动驾驶部分功能受影响,演示模式可以考虑强行启动,需联系人员排查问题。\n例如定位偏移,camera无数据,算法严重丢帧,属于自动驾驶可以启动,但是效果受影响。"),
|
||||
AUTOPILOT_INFERIOR(RESULT_AUTOPILOT_INFERIOR, "自动驾驶部分功能受严重影响,演示模式可以考虑强行启动,非演示模式下建议停止自动驾驶,联系人员排查问题。\n例如定位偏移,camera无数据,算法非常严重的丢帧,属于自动驾驶可以启动,但是效果受影响。"),
|
||||
REMOTEPILOT_DISABLE(RESULT_REMOTEPILOT_DISABLE, "无法启动远程驾驶"),
|
||||
REMOTEPILOT_INFERIOR(RESULT_REMOTEPILOT_INFERIOR, "远程驾驶部分功能受影响。例如网络高延迟"),
|
||||
SHOW_WARNING(RESULT_SHOW_WARNING, "一般为过渡状态,存在不确定因素,有可能对自动驾驶有微弱影响,需要在pad端显示为黄色告警。\n如果偶尔上报该result可忽略,如果频繁上报需联系人员进行排查。 目前仅有RTK无法确认状态事件。");
|
||||
|
||||
// DISCONNECTED_WITH_PAD(RESULT_DISCONNECTED_WITH_PAD, "未检测到来自pad的链接,如果只报了这个result,可以通过后台/远程驾驶启动自动驾驶"),
|
||||
// PAD_CANNOT_CONNECT_TELEMATICS(RESULT_PAD_INFO_LOST, "Pad无法连接到工控机"),
|
||||
// PAD_INFO_LOST(RESULT_PAD_CANNOT_CONNECT_TELEMATICS, "Pad工控机之间指令信息丢失"),
|
||||
// PAD_CANNOT_GET_AUTOPILOT_STATUS(RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS, "Pad端无法拿到自动驾驶状态信息"),
|
||||
// PAD_CANNOT_GET_GNS_CHASSIS_STATUS(RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS, "Pad端无法拿到自车状态和底盘状态信息"),
|
||||
// PAD_CANNOT_GET_OBSTACLE_INFO(RESULT_PAD_CANNOT_GET_OBSTACLE_INFO, "Pad端无法拿到障碍物信息"),
|
||||
// NO_CONNECTION_TO_AICLOUD(RESULT_NO_CONNECTION_TO_AICLOUD, "无法和云端通信"),
|
||||
// AICLOUD_INFO_LOST(RESULT_AICLOUD_INFO_LOST, "云端工控机之间信息丢失"),
|
||||
// CANNOT_CHANGE_LIGHT(RESULT_CANNOT_CHANGE_LIGHT, "变灯失败");
|
||||
|
||||
/**
|
||||
* 消息result code
|
||||
@@ -69,25 +51,6 @@ public class MogoReport {
|
||||
return REMOTEPILOT_INFERIOR.desc;
|
||||
case RESULT_SHOW_WARNING:
|
||||
return SHOW_WARNING.desc;
|
||||
|
||||
// case RESULT_DISCONNECTED_WITH_PAD:
|
||||
// return DISCONNECTED_WITH_PAD.desc;
|
||||
// case RESULT_PAD_CANNOT_CONNECT_TELEMATICS:
|
||||
// return PAD_CANNOT_CONNECT_TELEMATICS.desc;
|
||||
// case RESULT_PAD_INFO_LOST:
|
||||
// return PAD_INFO_LOST.desc;
|
||||
// case RESULT_PAD_CANNOT_GET_AUTOPILOT_STATUS:
|
||||
// return PAD_CANNOT_GET_AUTOPILOT_STATUS.desc;
|
||||
// case RESULT_PAD_CANNOT_GET_GNS_CHASSIS_STATUS:
|
||||
// return PAD_CANNOT_GET_GNS_CHASSIS_STATUS.desc;
|
||||
// case RESULT_PAD_CANNOT_GET_OBSTACLE_INFO:
|
||||
// return PAD_CANNOT_GET_OBSTACLE_INFO.desc;
|
||||
// case RESULT_NO_CONNECTION_TO_AICLOUD:
|
||||
// return NO_CONNECTION_TO_AICLOUD.desc;
|
||||
// case RESULT_AICLOUD_INFO_LOST:
|
||||
// return AICLOUD_INFO_LOST.desc;
|
||||
// case RESULT_CANNOT_CHANGE_LIGHT:
|
||||
// return CANNOT_CHANGE_LIGHT.desc;
|
||||
default:
|
||||
return resultCode;
|
||||
|
||||
@@ -104,6 +67,7 @@ public class MogoReport {
|
||||
public static final String ACTION_CHECK_GEAR = "ACTION_CHECK_GEAR";
|
||||
public static final String ACTION_CHECK_NETWORK = "ACTION_CHECK_NETWORK";
|
||||
public static final String ACTION_TRY_AGAIN_LATER = "ACTION_TRY_AGAIN_LATER";
|
||||
public static final String ACTION_REMOTEPILOT_REQUEST = "ACTION_REMOTEPILOT_REQUEST";
|
||||
|
||||
public enum Action {
|
||||
|
||||
@@ -114,7 +78,8 @@ public class MogoReport {
|
||||
REBOOT_VEHICLE(ACTION_REBOOT_VEHICLE, "重启车辆"),
|
||||
CHECK_GEAR(ACTION_CHECK_GEAR, "检查车辆档位等影响自动驾驶的因素"),
|
||||
CHECK_NETWORK(ACTION_CHECK_NETWORK, "检查网络连接和路由器等影响通信的因素"),
|
||||
TRY_AGAIN_LATER(ACTION_TRY_AGAIN_LATER, "请稍后重试");
|
||||
TRY_AGAIN_LATER(ACTION_TRY_AGAIN_LATER, "请稍后重试"),
|
||||
REMOTEPILOT_REQUEST(ACTION_REMOTEPILOT_REQUEST, "请求远程驾驶");
|
||||
|
||||
/**
|
||||
* 消息Action code
|
||||
@@ -303,6 +268,20 @@ public class MogoReport {
|
||||
String TASK_CONFIG_EMPTY = "ERECORD_TASK_CONFIG_EMPTY";//配置为空
|
||||
String TASK_QUEUE_EMPTY = "ERECORD_TASK_QUEUE_EMPTY";//数据队列为空
|
||||
}
|
||||
|
||||
/**
|
||||
* 平行驾驶相关异常
|
||||
*/
|
||||
interface EPARALLEL {
|
||||
String AICLOUD_CONNECTION_ERROR = "EPARALLEL_AICLOUD_CONNECTION_ERROR";//平行驾驶长连接异常
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆处于困境,等待平行驾驶接管
|
||||
*/
|
||||
interface EVEHICLE {
|
||||
String IN_TROUBLE = "EVEHICLE_IN_TROUBLE";//planning 检测到车处于困境,把困境状态汇报给 SSM,ssm 发出该事件,等待驾舱端开始平行驾驶
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -344,9 +323,10 @@ public class MogoReport {
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统状态 常规信息
|
||||
* 系统状态
|
||||
*/
|
||||
interface ISYS {
|
||||
/*******常规信息*******/
|
||||
String STARTING = "ISYS_STARTING";//系统启动中
|
||||
String RUNNING = "ISYS_RUNNING";//所有Xavier启动完成
|
||||
String EXITING = "ISYS_EXITING";//系统退出中
|
||||
@@ -362,19 +342,14 @@ public class MogoReport {
|
||||
String SYSTEM_IN_IDLE = "ISYS_SYSTEM_IN_IDLE";//系统进入空闲状态
|
||||
String SYSTEM_OUT_IDLE = "ISYS_SYSTEM_OUT_IDLE";//系统退出空闲状态
|
||||
|
||||
String FUNC_YY_START = "ISYS_FUNC_YY_START";//产品状态检查开始
|
||||
String FUNC_YY_FINISH = "ISYS_FUNC_YY_FINISH";//产品状态达成(第一次ready)
|
||||
String FUNC_YY_TIMEOUT = "ISYS_FUNC_YY_TIMEOUT";//产品状态检查超时
|
||||
String FUNC_YY_ABORT = "ISYS_FUNC_YY_ABORT";//产品状态检查中止
|
||||
String FUNC_YY_UNREADY = "ISYS_FUNC_YY_UNREADY";//产品状态未就绪
|
||||
String FUNC_YY_READY = "ISYS_FUNC_YY_READY";//产品状态就绪
|
||||
|
||||
/*******轨迹下载相关*******/
|
||||
String INIT_TRAJECTORY_START = "ISYS_INIT_TRAJECTORY_START";//轨迹管理_轨迹开始下载
|
||||
String INIT_TRAJECTORY_SUCCESS = "ISYS_INIT_TRAJECTORY_SUCCESS";//轨迹管理_轨迹下载成功
|
||||
String INIT_TRAJECTORY_FAILURE = "ISYS_INIT_TRAJECTORY_FAILURE";//轨迹管理_轨迹下载失败,本地无对应轨迹
|
||||
String INIT_TRAJECTORY_WARNING = "ISYS_INIT_TRAJECTORY_WARNING";//轨迹管理_轨迹下载失败,本地有对应轨迹,认为成功
|
||||
String INIT_TRAJECTORY_TIMEOUT = "ISYS_INIT_TRAJECTORY_TIMEOUT";//轨迹管理_轨迹下载超时
|
||||
|
||||
/*******配置更新相关*******/
|
||||
String CONFIG_UPDATE_HADMAP = "ISYS_CONFIG_UPDATE_HADMAP";//需要重启升级高精地图
|
||||
String CONFIG_UPDATE_AI_MODEL = "ISYS_CONFIG_UPDATE_AI_MODEL";//需要重启升级AI模型
|
||||
String CONFIG_UPDATE_SLAM_MAP = "ISYS_CONFIG_UPDATE_SLAM_MAP";//需要重启升级SLAM地图
|
||||
@@ -390,13 +365,65 @@ public class MogoReport {
|
||||
interface ISSM {
|
||||
String INIT = "ISSM_INIT";//SSM系统上电初始化
|
||||
String RESTARTED = "ISSM_RESTARTED";//SSM系统发生重启
|
||||
String MODE_XX_START = "ISSM_MODE_XX_START";//SSM变更模式开始
|
||||
String MODE_XX_FINISH = "ISSM_MODE_XX_FINISH";//SSM变更模式完成(第一次ready
|
||||
String MODE_XX_ABORT = "ISSM_MODE_XX_ABORT";//SSM变更模式中止
|
||||
String MODE_XX_TIMEOUT = "ISSM_MODE_XX_TIMEOUT";//SSM变更模式超时
|
||||
String MODE_XX_READY = "ISSM_MODE_XX_READY";//SSM模式就绪
|
||||
String MODE_XX_UNREADY = "ISSM_MODE_XX_UNREADY";//SSM未就绪
|
||||
|
||||
// String MODE_XX_START = "ISSM_MODE_XX_START";//SSM变更模式开始
|
||||
// String MODE_XX_FINISH = "ISSM_MODE_XX_FINISH";//SSM变更模式完成(第一次ready
|
||||
// String MODE_XX_ABORT = "ISSM_MODE_XX_ABORT";//SSM变更模式中止
|
||||
// String MODE_XX_TIMEOUT = "ISSM_MODE_XX_TIMEOUT";//SSM变更模式超时
|
||||
// String MODE_XX_READY = "ISSM_MODE_XX_READY";//SSM模式就绪
|
||||
// String MODE_XX_UNREADY = "ISSM_MODE_XX_UNREADY";//SSM未就绪
|
||||
|
||||
//以上6组被注释掉的字段 中的MODE_XX分别替换成MODE_RUN、MODE_IDLE、MODE_STOP
|
||||
|
||||
String MODE_RUN_START = "ISSM_MODE_RUN_START";//SSM变更模式开始
|
||||
String MODE_RUN_FINISH = "ISSM_MODE_RUN_FINISH";//SSM变更模式完成(第一次ready
|
||||
String MODE_RUN_ABORT = "ISSM_MODE_RUN_ABORT";//SSM变更模式中止
|
||||
String MODE_RUN_TIMEOUT = "ISSM_MODE_RUN_TIMEOUT";//SSM变更模式超时
|
||||
String MODE_RUN_READY = "ISSM_MODE_RUN_READY";//SSM模式就绪
|
||||
String MODE_RUN_UNREADY = "ISSM_MODE_RUN_UNREADY";//SSM未就绪
|
||||
|
||||
String MODE_IDLE_START = "ISSM_MODE_IDLE_START";//SSM变更模式开始
|
||||
String MODE_IDLE_FINISH = "ISSM_MODE_IDLE_FINISH";//SSM变更模式完成(第一次ready
|
||||
String MODE_IDLE_ABORT = "ISSM_MODE_IDLE_ABORT";//SSM变更模式中止
|
||||
String MODE_IDLE_TIMEOUT = "ISSM_MODE_IDLE_TIMEOUT";//SSM变更模式超时
|
||||
String MODE_IDLE_READY = "ISSM_MODE_IDLE_READY";//SSM模式就绪
|
||||
String MODE_IDLE_UNREADY = "ISSM_MODE_IDLE_UNREADY";//SSM未就绪
|
||||
|
||||
String MODE_STOP_START = "ISSM_MODE_STOP_START";//SSM变更模式开始
|
||||
String MODE_STOP_FINISH = "ISSM_MODE_STOP_FINISH";//SSM变更模式完成(第一次ready
|
||||
String MODE_STOP_ABORT = "ISSM_MODE_STOP_ABORT";//SSM变更模式中止
|
||||
String MODE_STOP_TIMEOUT = "ISSM_MODE_STOP_TIMEOUT";//SSM变更模式超时
|
||||
String MODE_STOP_READY = "ISSM_MODE_STOP_READY";//SSM模式就绪
|
||||
String MODE_STOP_UNREADY = "ISSM_MODE_STOP_UNREADY";//SSM未就绪
|
||||
|
||||
// String FUNC_YY_START = "ISSM_FUNC_YY_START";//产品状态检查开始
|
||||
// String FUNC_YY_FINISH = "ISSM_FUNC_YY_FINISH";//产品状态达成(第一次ready)
|
||||
// String FUNC_YY_TIMEOUT = "ISSM_FUNC_YY_TIMEOUT";//产品状态检查超时
|
||||
// String FUNC_YY_ABORT = "ISSM_FUNC_YY_ABORT";//产品状态检查中止
|
||||
// String FUNC_YY_UNREADY = "ISSM_FUNC_YY_UNREADY";//产品状态未就绪
|
||||
// String FUNC_YY_READY = "ISSM_FUNC_YY_READY";//产品状态就绪
|
||||
|
||||
//以上6组被注释掉的字段 中的FUNC_YY分别替换成FUNC_COLD_START、FUNC_AUTO_PILOT、FUNC_REMOTE_PILOT
|
||||
String FUNC_COLD_START_START = "ISSM_FUNC_COLD_START_START";//产品状态检查开始
|
||||
String FUNC_COLD_START_FINISH = "ISSM_FUNC_COLD_START_FINISH";//产品状态达成(第一次ready)
|
||||
String FUNC_COLD_START_TIMEOUT = "ISSM_FUNC_COLD_START_TIMEOUT";//产品状态检查超时
|
||||
String FUNC_COLD_START_ABORT = "ISSM_FUNC_COLD_START_ABORT";//产品状态检查中止
|
||||
String FUNC_COLD_START_UNREADY = "ISSM_FUNC_COLD_START_UNREADY";//产品状态未就绪
|
||||
String FUNC_COLD_START_READY = "ISSM_FUNC_COLD_START_READY";//产品状态就绪
|
||||
|
||||
String FUNC_AUTO_PILOT_START = "ISSM_FUNC_AUTO_PILOT_START";//产品状态检查开始
|
||||
String FUNC_AUTO_PILOT_FINISH = "ISSM_FUNC_AUTO_PILOT_FINISH";//产品状态达成(第一次ready)
|
||||
String FUNC_AUTO_PILOT_TIMEOUT = "ISSM_FUNC_AUTO_PILOT_TIMEOUT";//产品状态检查超时
|
||||
String FUNC_AUTO_PILOT_ABORT = "ISSM_FUNC_AUTO_PILOT_ABORT";//产品状态检查中止
|
||||
String FUNC_AUTO_PILOT_UNREADY = "ISSM_FUNC_AUTO_PILOT_UNREADY";//产品状态未就绪
|
||||
String FUNC_AUTO_PILOT_READY = "ISSM_FUNC_AUTO_PILOT_READY";//产品状态就绪
|
||||
|
||||
String FUNC_REMOTE_PILOT_START = "ISSM_FUNC_REMOTE_PILOT_START";//产品状态检查开始
|
||||
String FUNC_REMOTE_PILOT_FINISH = "ISSM_FUNC_REMOTE_PILOT_FINISH";//产品状态达成(第一次ready)
|
||||
String FUNC_REMOTE_PILOT_TIMEOUT = "ISSM_FUNC_REMOTE_PILOT_TIMEOUT";//产品状态检查超时
|
||||
String FUNC_REMOTE_PILOT_ABORT = "ISSM_FUNC_REMOTE_PILOT_ABORT";//产品状态检查中止
|
||||
String FUNC_REMOTE_PILOT_UNREADY = "ISSM_FUNC_REMOTE_PILOT_UNREADY";//产品状态未就绪
|
||||
String FUNC_REMOTE_PILOT_READY = "ISSM_FUNC_REMOTE_PILOT_READY";//产品状态就绪
|
||||
}
|
||||
|
||||
interface IAGENT {
|
||||
@@ -427,6 +454,20 @@ public class MogoReport {
|
||||
String TASK_AUTO = "IRECORDER_TASK_AUTO";//自动录包任务创建
|
||||
String TASK_CMD = "IRECORDER_TASK_CMD";//指令录包任务创建
|
||||
}
|
||||
|
||||
/**
|
||||
* 平行驾驶相关
|
||||
*/
|
||||
interface IPARALLEL {
|
||||
String AICLOUD_CONNECTION_OK = "IPARALLEL_AICLOUD_CONNECTION_OK";//长连接连接恢复后, 5s 内如果长连状态一直 ok 的话,会触发该事件 建议鹰眼展示该事件
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆处于困境相关
|
||||
*/
|
||||
interface IVEHICLE {
|
||||
String NOT_IN_TROUBLE = "IVEHICLE_NOT_IN_TROUBLE";//车辆脱离困境,恢复正常,可继续开始自动驾驶了 触发频率:处于困境中,触发一次; 脱困后,触发一次 云端驾舱会接入该事件 建议鹰眼也接入,展示困境状态/脱困状态
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.common.AutopilotAbilityManager;
|
||||
import com.zhidao.support.adas.high.protocol.RawData;
|
||||
|
||||
import chassis.ChassisStatesOuterClass;
|
||||
@@ -14,6 +15,7 @@ public class ChassisStatesMessage extends MyAbstractMessageHandler {
|
||||
@Override
|
||||
public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException {
|
||||
ChassisStatesOuterClass.ChassisStates chassisStates = ChassisStatesOuterClass.ChassisStates.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue());
|
||||
AutopilotAbilityManager.getInstance().setChassisStates(chassisStates);
|
||||
if (adasListener != null) {
|
||||
adasListener.onChassisStates(raw.getHeader(), chassisStates);
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.MogoReport;
|
||||
import com.zhidao.support.adas.high.protocol.RawData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mogo_msg.MogoReportMsg;
|
||||
|
||||
@@ -19,9 +20,28 @@ import mogo_msg.MogoReportMsg;
|
||||
*/
|
||||
public class ReportMessage extends MyAbstractMessageHandler {
|
||||
private final AutopilotReview autopilotReview;
|
||||
private final Set<String> startAutopilotFailCode = new HashSet<String>();//启动自驾失败Code
|
||||
|
||||
public ReportMessage(AutopilotReview autopilotReview) {
|
||||
this.autopilotReview = autopilotReview;
|
||||
initStartAutopilotFailCode();
|
||||
}
|
||||
|
||||
private void initStartAutopilotFailCode() {
|
||||
//ssm_master的失败事件
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.AUTOPILOT_FAILED);//在尝试启动自动驾驶,但是超过指定时间后底盘未进入,会发送此事件
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.ROUTING_REQ_TIMEOUT);//算路请求响应超时或轨迹加载超时
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.PLANNING_CHANGE_FAILIED);//planning切换失败(仅df hq有此事件)
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.ESYS.CHECK_TRAJECTORY_FAILURE);//轨迹下载检查不可用
|
||||
//controller的失败事件 EMAP_ENTRY_AUTOPILOT_XXX 底盘启动失败
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_CANADAPTER_TIMEOUT);//can_adapter消息超时未进入自驾
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_PLANNING_TIMEOUT);//PLANNING消息超时未进自驾
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_LOCATION_TIMEOUT);//定位消息超时未进自驾
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_BRAKE);//制动踏板干预未进自驾
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_ACCEL);//加速踏板干预未进自驾
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_STEER);//方向盘干预未进自驾
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_GEAR_SWITCH);//档位切换干预未进自驾
|
||||
startAutopilotFailCode.add(MogoReport.Code.Error.EMAP.ENTRY_AUTOPILOT_FOR_OTHER_CTL);//其他干预未进自驾,请检查仪表盘和开关项(如双闪,制动灯灯等 可在msg中补充原因信息)
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,8 +56,8 @@ public class ReportMessage extends MyAbstractMessageHandler {
|
||||
}
|
||||
AdasChannel.calculateTimeConsumingBusiness("监控事件报告", nowTime);
|
||||
//分发自动驾驶启动失败相关回调
|
||||
List<String> results = mogoReportMessage.getResultList();
|
||||
if (!results.isEmpty() && results.contains(MogoReport.RESULT_AUTOPILOT_DISABLE)) {
|
||||
String code = mogoReportMessage.getCode();
|
||||
if (startAutopilotFailCode.contains(code)) {
|
||||
if (adasListener != null) {
|
||||
adasListener.onStartAutopilotFailed(mogoReportMessage);//启动自动驾驶失败回调
|
||||
}
|
||||
|
||||
@@ -23,13 +23,13 @@ public class VehicleStateMessage extends MyAbstractMessageHandler {
|
||||
public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException {
|
||||
VehicleStateOuterClass.VehicleState vehicleState = VehicleStateOuterClass.VehicleState.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue());
|
||||
AdasChannel.calculateTimeConsumingOnDispatchRaw("底盘信息", raw.receiveTime);
|
||||
AutopilotAbilityManager.getInstance().setVehicleState(vehicleState);
|
||||
long nowTime = 0;
|
||||
if (CupidLogUtils.isEnableLog())
|
||||
nowTime = SystemClock.elapsedRealtime();
|
||||
ChassisStatesOuterClass.ChassisStates chassisStates = compatibility(adasListener, raw, vehicleState);
|
||||
if (adasListener != null) {
|
||||
//TODO 暂时关闭新老兼容
|
||||
//compatibility(adasListener, raw, vehicleState);
|
||||
//TODO 暂时关闭老底盘转发 后期 会删除 onVehicleState
|
||||
//adasListener.onChassisStates(raw.getHeader(), chassisStates);
|
||||
adasListener.onVehicleState(raw.getHeader(), vehicleState);
|
||||
}
|
||||
AdasChannel.calculateTimeConsumingBusiness("底盘信息", nowTime);
|
||||
@@ -46,15 +46,12 @@ public class VehicleStateMessage extends MyAbstractMessageHandler {
|
||||
* fuel_value robo_taxi_state robo_bus_state
|
||||
* robo_bus_jinlv_m1_state
|
||||
*/
|
||||
private void compatibility(OnAdasListener adasListener, RawData raw, VehicleStateOuterClass.VehicleState vehicleState) throws InvalidProtocolBufferException {
|
||||
private ChassisStatesOuterClass.ChassisStates compatibility(OnAdasListener adasListener, RawData raw, VehicleStateOuterClass.VehicleState vehicleState) throws InvalidProtocolBufferException {
|
||||
/**************老地盘转换成新地盘PB***************/
|
||||
ChassisStatesOuterClass.ChassisStates.Builder builder = ChassisStatesOuterClass.ChassisStates.newBuilder();
|
||||
//工控机所用Header
|
||||
if (vehicleState.hasHeader()) {
|
||||
HeaderOuterClass.Header outHeader = vehicleState.getHeader();
|
||||
if (outHeader != null) {
|
||||
builder.setHeader(HeaderOuterClass.Header.parseFrom(vehicleState.getHeader().toByteArray()));
|
||||
}
|
||||
builder.setHeader(HeaderOuterClass.Header.parseFrom(vehicleState.getHeader().toByteArray()));
|
||||
}
|
||||
setBCMSystemStates(builder, vehicleState);
|
||||
setSteerSystemStates(builder, vehicleState);
|
||||
@@ -66,45 +63,41 @@ public class VehicleStateMessage extends MyAbstractMessageHandler {
|
||||
//电子驻车制动系统
|
||||
if (vehicleState.hasEpb()) {
|
||||
Chassis.EPBWorkStatus old = vehicleState.getEpb();
|
||||
if (old != null) {
|
||||
ChassisStatesOuterClass.EPBWorkStates epb = null;
|
||||
if (old == Chassis.EPBWorkStatus.EPBSTATUS_NONE) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_NONE;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASED) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASED;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED_FAIL) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED_FAIL;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASE_FAIL) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASE_FAIL;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_FAULT) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_FAULT;
|
||||
}
|
||||
if (epb != null) {
|
||||
builder.setEpbSystemStates(ChassisStatesOuterClass.EPBSystemStates.newBuilder()
|
||||
.setEpbWorkState(epb));
|
||||
}
|
||||
ChassisStatesOuterClass.EPBWorkStates epb = null;
|
||||
if (old == Chassis.EPBWorkStatus.EPBSTATUS_NONE) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_NONE;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASED) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASED;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_LOCKED_FAIL) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_LOCKED_FAIL;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_RELEASE_FAIL) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_RELEASE_FAIL;
|
||||
} else if (old == Chassis.EPBWorkStatus.EPBSTATUS_FAULT) {
|
||||
epb = ChassisStatesOuterClass.EPBWorkStates.EPB_STATE_FAULT;
|
||||
}
|
||||
if (epb != null) {
|
||||
builder.setEpbSystemStates(ChassisStatesOuterClass.EPBSystemStates.newBuilder()
|
||||
.setEpbWorkState(epb));
|
||||
}
|
||||
}
|
||||
// 整车故障状态
|
||||
if (vehicleState.hasVehiclefaultlevel()) {
|
||||
Chassis.VehicleFaultLevel vehicleFaultLevel = vehicleState.getVehiclefaultlevel();
|
||||
if (vehicleFaultLevel != null) {
|
||||
ChassisStatesOuterClass.VehicleFaultLevels vehicleFaultLevels = null;
|
||||
if (vehicleFaultLevel == Chassis.VehicleFaultLevel.None_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.NONE_FAULT;
|
||||
} else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.General_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.GENERAL_FAULT;
|
||||
} else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Serious_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.SERIOUS_FAULT;
|
||||
} else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Critical_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.CRITICAL_FAULT;
|
||||
}
|
||||
if (vehicleFaultLevels != null) {
|
||||
builder.setVehicleChassisFaultInformation(ChassisStatesOuterClass.VehicleChassisFaultInformation.newBuilder()
|
||||
.setVehiclefaultlevel(vehicleFaultLevels));
|
||||
}
|
||||
ChassisStatesOuterClass.VehicleFaultLevels vehicleFaultLevels = null;
|
||||
if (vehicleFaultLevel == Chassis.VehicleFaultLevel.None_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.NONE_FAULT;
|
||||
} else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.General_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.GENERAL_FAULT;
|
||||
} else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Serious_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.SERIOUS_FAULT;
|
||||
} else if (vehicleFaultLevel == Chassis.VehicleFaultLevel.Critical_Fault) {
|
||||
vehicleFaultLevels = ChassisStatesOuterClass.VehicleFaultLevels.CRITICAL_FAULT;
|
||||
}
|
||||
if (vehicleFaultLevels != null) {
|
||||
builder.setVehicleChassisFaultInformation(ChassisStatesOuterClass.VehicleChassisFaultInformation.newBuilder()
|
||||
.setVehiclefaultlevel(vehicleFaultLevels));
|
||||
}
|
||||
}
|
||||
//电量
|
||||
@@ -113,25 +106,21 @@ public class VehicleStateMessage extends MyAbstractMessageHandler {
|
||||
}
|
||||
//清扫车(福田)清扫控制系统状态
|
||||
if (vehicleState.hasSweeperFutianCleanSystemState()) {
|
||||
VehicleStateOuterClass.SweeperFuTianCleanSystemState sweeperFuTianCleanSystemState = vehicleState.getSweeperFutianCleanSystemState();
|
||||
if (sweeperFuTianCleanSystemState != null) {
|
||||
byte[] bytes = sweeperFuTianCleanSystemState.toByteArray();
|
||||
builder.setTaskSystemStates(ChassisStatesOuterClass.TaskSystemStates.newBuilder()
|
||||
.setSweeperFutianTaskSystemStates(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates.parseFrom(bytes)));//鹰眼已用 清扫车专用
|
||||
}
|
||||
byte[] bytes = vehicleState.getSweeperFutianCleanSystemState().toByteArray();
|
||||
builder.setTaskSystemStates(ChassisStatesOuterClass.TaskSystemStates.newBuilder()
|
||||
.setSweeperFutianTaskSystemStates(ChassisStatesOuterClass.SweeperFuTianTaskSystemStates.parseFrom(bytes)));//鹰眼已用 清扫车专用
|
||||
}
|
||||
adasListener.onChassisStates(raw.getHeader(), builder.build());
|
||||
ChassisStatesOuterClass.ChassisStates chassisStates = builder.build();
|
||||
AutopilotAbilityManager.getInstance().setChassisStates(chassisStates);
|
||||
return chassisStates;
|
||||
}
|
||||
|
||||
|
||||
private void setChassisAutopilotAssistanceInformation(ChassisStatesOuterClass.ChassisStates.Builder builder, VehicleStateOuterClass.VehicleState vehicleState) {
|
||||
ChassisStatesOuterClass.ChassisAutopilotAssistanceInformation.Builder chassisAutopilotAssistanceInformation = null;
|
||||
if (vehicleState.hasPilotMode()) {
|
||||
Chassis.PilotMode pilotMode = vehicleState.getPilotMode();
|
||||
if (pilotMode != null) {
|
||||
chassisAutopilotAssistanceInformation = ChassisStatesOuterClass.ChassisAutopilotAssistanceInformation.newBuilder();
|
||||
chassisAutopilotAssistanceInformation.setChassisPilotModeState(pilotMode);
|
||||
}
|
||||
chassisAutopilotAssistanceInformation = ChassisStatesOuterClass.ChassisAutopilotAssistanceInformation.newBuilder();
|
||||
chassisAutopilotAssistanceInformation.setChassisPilotModeState(vehicleState.getPilotMode());
|
||||
}
|
||||
if (vehicleState.hasEmergencyStopSwitch()) {
|
||||
if (chassisAutopilotAssistanceInformation == null) {
|
||||
@@ -151,12 +140,9 @@ public class VehicleStateMessage extends MyAbstractMessageHandler {
|
||||
private void setGearSystemStates(ChassisStatesOuterClass.ChassisStates.Builder builder, VehicleStateOuterClass.VehicleState vehicleState) {
|
||||
ChassisStatesOuterClass.GearSystemStates.Builder gearSystemStates = null;
|
||||
if (vehicleState.hasGear()) {
|
||||
Chassis.GearPosition gear = vehicleState.getGear();
|
||||
if (gear != null) {
|
||||
gearSystemStates = ChassisStatesOuterClass.GearSystemStates.newBuilder();
|
||||
//挂挡档位数据
|
||||
gearSystemStates.setGearPosition(gear);//鹰眼已用
|
||||
}
|
||||
gearSystemStates = ChassisStatesOuterClass.GearSystemStates.newBuilder();
|
||||
//挂挡档位数据
|
||||
gearSystemStates.setGearPosition(vehicleState.getGear());//鹰眼已用
|
||||
}
|
||||
if (vehicleState.hasGearSwitchInference()) {
|
||||
if (gearSystemStates == null) {
|
||||
@@ -278,12 +264,9 @@ public class VehicleStateMessage extends MyAbstractMessageHandler {
|
||||
private void setBCMSystemStates(ChassisStatesOuterClass.ChassisStates.Builder builder, VehicleStateOuterClass.VehicleState vehicleState) {
|
||||
ChassisStatesOuterClass.BCMSystemStates.Builder bcmSystemStates = null;
|
||||
if (vehicleState.hasLight()) {
|
||||
Chassis.LightSwitch light = vehicleState.getLight();
|
||||
if (light != null) {
|
||||
bcmSystemStates = ChassisStatesOuterClass.BCMSystemStates.newBuilder();
|
||||
//转向灯数据
|
||||
bcmSystemStates.setTurnLightState(light);//鹰眼已用
|
||||
}
|
||||
bcmSystemStates = ChassisStatesOuterClass.BCMSystemStates.newBuilder();
|
||||
//转向灯数据
|
||||
bcmSystemStates.setTurnLightState(vehicleState.getLight());//鹰眼已用
|
||||
}
|
||||
if (vehicleState.hasBrakeLightStatus()) {
|
||||
if (bcmSystemStates == null) {
|
||||
|
||||
@@ -22,11 +22,16 @@ import mogo.telematics.pad.MessagePad;
|
||||
public class DispatchHandler {
|
||||
private final MessagePad.MessageType messageType;
|
||||
private final OnDispatchHandlerListener listener;
|
||||
private static final int WHAT_DISPATCH = 999999;
|
||||
private HandlerThread mThread;
|
||||
private BaseHandler mBaseHandler;
|
||||
|
||||
public interface OnDispatchHandlerListener {
|
||||
void onDispatchRaw(MessagePad.MessageType name, RawData raw);
|
||||
void onHandler(MessagePad.MessageType type, Handler handler);
|
||||
|
||||
void onHandleMessage(MessagePad.MessageType type, Message msg);
|
||||
|
||||
void onDispatchRaw(MessagePad.MessageType type, RawData raw);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +40,16 @@ public class DispatchHandler {
|
||||
this.messageType = messageType;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (mThread == null) {
|
||||
String name = "Dispatch-" + messageType.name().replace("MsgType", "");
|
||||
mThread = new HandlerThread(name);
|
||||
mThread.start();
|
||||
initHandler(mThread.getLooper());
|
||||
listener.onHandler(messageType, mBaseHandler);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (mBaseHandler != null) {
|
||||
mBaseHandler.removeCallbacksAndMessages(null);
|
||||
@@ -47,14 +62,10 @@ public class DispatchHandler {
|
||||
}
|
||||
|
||||
public void sendRawMessage(RawData raw) {
|
||||
if (mThread == null) {
|
||||
String name = "Dispatch-" + messageType.name().replace("MsgType", "");
|
||||
mThread = new HandlerThread(name);
|
||||
mThread.start();
|
||||
initHandler(mThread.getLooper());
|
||||
}
|
||||
start();
|
||||
Message msg = Message.obtain();
|
||||
msg.obj = raw;
|
||||
msg.what = WHAT_DISPATCH;
|
||||
mBaseHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
@@ -67,16 +78,19 @@ public class DispatchHandler {
|
||||
* @param msg
|
||||
*/
|
||||
protected void handleMessage(Message msg) {
|
||||
//TODO 计算耗时 临时测试
|
||||
if (CupidLogUtils.isEnableLog())
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (mThread != null) {
|
||||
MessageQueue queue = mThread.getLooper().getQueue();
|
||||
CupidLogUtils.i("TimeConsuming", mThread.getName() + " 当前消息队列是否处于空闲状态=" + queue.isIdle());
|
||||
if (msg.what == WHAT_DISPATCH) {
|
||||
//TODO 计算耗时 临时测试
|
||||
if (CupidLogUtils.isEnableLog())
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (mThread != null) {
|
||||
MessageQueue queue = mThread.getLooper().getQueue();
|
||||
CupidLogUtils.i("TimeConsuming", mThread.getName() + " 当前消息队列是否处于空闲状态=" + queue.isIdle());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
listener.onDispatchRaw(messageType, (RawData) msg.obj);
|
||||
listener.onDispatchRaw(messageType, (RawData) msg.obj);
|
||||
} else {
|
||||
listener.onHandleMessage(messageType, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user