[adas lib]能否启动自驾以及启动命令下发后成功或失败统计优化
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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?)
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,17 @@ 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 +53,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;
|
||||
|
||||
|
||||
@@ -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