+ * 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态 + */ +public class AutopilotAbility230 { + private static final String TAG = AutopilotAbility230.class.getSimpleName(); + private static final long DEFAULT_DETECTION_TIME = 3 * 1000L;//默认检测时间 + private volatile Timer timer; + private ChassisStatesOuterClass.ChassisStates chassisStates; + + public AutopilotAbility230() { + } + + + public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) { + this.chassisStates = chassisStates; + } + + private void onCallback() { + //金旅、开沃小巴乘客端 不能启动自动驾驶 + if (AutopilotAbilityManager.getInstance().isBusPassenger()) { + return; + } + boolean isAutopilotAbility = true;//是否能启动自动驾驶 + String unableAutopilotReason = null;//不能启动自动驾驶原因 + //检测底盘相关 + if (chassisStates != null) { + 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 (!AutopilotAbilityManager.getInstance().isBusDriverVan()) { + if (chassisStates.hasGearSystemStates()) { + Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition(); + //金旅Bus和清扫车 档位不正常 + if (AutopilotAbilityManager.getInstance().isBusDriver()) { + if (gear == Chassis.GearPosition.GEAR_N || gear == Chassis.GearPosition.GEAR_R) { + isAutopilotAbility = false; + unableAutopilotReason = "档位不正常"; + } + } else if (AutopilotAbilityManager.getInstance().isSweeperDriverFutian()) { + 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 (AutopilotAbilityManager.getInstance().getListener() != null) { + AutopilotAbilityManager.getInstance().getListener().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason); + } + } + + public synchronized void start() { + if (timer == null) { + timer = new Timer(); + timer.schedule(new TimerTask() { + @Override + public void run() { + onCallback(); + } + }, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步 + } + } + + public synchronized void stop() { + if (timer != null) { + timer.cancel(); + timer = null; + } + this.chassisStates = null; + } + + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotAbilityManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/autopilot/ability/AutopilotAbility250.java similarity index 61% rename from libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotAbilityManager.java rename to libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/autopilot/ability/AutopilotAbility250.java index 03ec76b745..01bf359101 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AutopilotAbilityManager.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/autopilot/ability/AutopilotAbility250.java @@ -1,106 +1,41 @@ -package com.zhidao.support.adas.high.common; +package com.zhidao.support.adas.high.common.autopilot.ability; -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 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.ChassisStatesOuterClass; import system_master.SystemStatusInfo; /** - * 是否可以启动自动驾驶能力检测 + * 是否可以启动自动驾驶能力检测 工控机版本>=250使用此类 * 目前监控了底盘的一些状态和查询节点状态应答的数据 * 没有使用监控事件报告的原因是因为,部分异常没进行正常恢复通知,例如收到了异常监控数据,但是异常恢复之后没有恢复的通知 *
* 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态 */ -public class AutopilotAbilityManager { - private static final String TAG = AutopilotAbilityManager.class.getSimpleName(); +public class AutopilotAbility250 { + private static final String TAG = AutopilotAbility250.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; - public interface OnAutopilotAbilityListener { - void onStatusQuery();//查询是被调用 + public AutopilotAbility250() { } - /** - * 身份规则定义根据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 (福田清扫车司机端) - *
- * 此定义不区分角色,只区分业务线和车型 - */ - 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() { - } - - public static AutopilotAbilityManager getInstance() { - if (INSTANCE == null) { - synchronized (AutopilotAbilityManager.class) { - if (INSTANCE == null) { - INSTANCE = new AutopilotAbilityManager(); - } - } - } - return INSTANCE; - } public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) { - if (handler != null) { - if (handler.hasMessages(WHAT_TIMEOUT)) - handler.removeMessages(WHAT_TIMEOUT); + if (AutopilotAbilityManager.getInstance().getHandler() != null) { + if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT)) + AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT); } onCallback(statusInfo); } @@ -111,7 +46,7 @@ public class AutopilotAbilityManager { private void onCallback(SystemStatusInfo.StatusInfo statusInfo) { //金旅、开沃小巴乘客端 不能启动自动驾驶 - if (IDENTITY_MODE.BUS_PASSENGER_BASE.equalsIgnoreCase(identityMode)) { + if (AutopilotAbilityManager.getInstance().isBusPassenger()) { return; } boolean isAutopilotAbility = true;//是否能启动自动驾驶 @@ -122,20 +57,7 @@ public class AutopilotAbilityManager { 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(); - } - } + version = AutopilotAbilityManager.getInstance().parseVersion(false, masterVersion); } //如果 maser version 大于1,还需要判断AutoPilotReady字段是否存在,以确保MAP版本和SSM Maser版本不陪配情况逻辑能正常执行 if (version > 1 && statusInfo.hasAutoPilotReady()) { @@ -204,24 +126,26 @@ public class AutopilotAbilityManager { * 档位状态判断 目前判断的车型包括 东风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)) { + //开沃任何档位都能启动自驾 + if (!AutopilotAbilityManager.getInstance().isBusDriverVan()) { + if (chassisStates.hasGearSystemStates()) { + Chassis.GearPosition gear = chassisStates.getGearSystemStates().getGearPosition(); //金旅Bus和清扫车 档位不正常 - if (IDENTITY_MODE.BUS_DRIVER_BASE.equalsIgnoreCase(identityMode) || IDENTITY_MODE.SWEEPER_DRIVER_FT.equalsIgnoreCase(identityMode)) { + if (AutopilotAbilityManager.getInstance().isBusDriver()) { if (gear == Chassis.GearPosition.GEAR_N || gear == Chassis.GearPosition.GEAR_R) { isAutopilotAbility = false; - unableAutopilotReason = "挡位不正常"; + unableAutopilotReason = "档位不正常"; + } + } else if (AutopilotAbilityManager.getInstance().isSweeperDriverFutian()) { + 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 = "挡位不正常"; + unableAutopilotReason = "档位不正常"; } } } @@ -239,8 +163,8 @@ public class AutopilotAbilityManager { // } // } } - if (listener != null) { - listener.onAutopilotAbility(isAutopilotAbility, unableAutopilotReason); + if (AutopilotAbilityManager.getInstance().getListener() != null) { + AutopilotAbilityManager.getInstance().getListener().onAutopilotAbility(isAutopilotAbility, unableAutopilotReason); } } @@ -250,14 +174,14 @@ public class AutopilotAbilityManager { timer.schedule(new TimerTask() { @Override public void run() { - if (onAutopilotAbilityListener != null) { - onAutopilotAbilityListener.onStatusQuery(); + if (AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener() != null) { + AutopilotAbilityManager.getInstance().getOnAutopilotAbilityListener().onStatusQuery(); } AdasManager.getInstance().sendStatusQueryReq(); - if (handler != null) { - if (handler.hasMessages(WHAT_TIMEOUT)) - handler.removeMessages(WHAT_TIMEOUT); - handler.sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT); + if (AutopilotAbilityManager.getInstance().getHandler() != null) { + if (AutopilotAbilityManager.getInstance().getHandler().hasMessages(WHAT_TIMEOUT)) + AutopilotAbilityManager.getInstance().getHandler().removeMessages(WHAT_TIMEOUT); + AutopilotAbilityManager.getInstance().getHandler().sendEmptyMessageDelayed(WHAT_TIMEOUT, DEFAULT_TIMEOUT); } } }, 2000L, DEFAULT_DETECTION_TIME);//延迟执行,避免刚连接成功后底盘信息无法及时同步 @@ -269,18 +193,15 @@ public class AutopilotAbilityManager { timer.cancel(); timer = 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); } } + + } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/autopilot/ability/AutopilotAbilityManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/autopilot/ability/AutopilotAbilityManager.java new file mode 100644 index 0000000000..1e80fe6805 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/autopilot/ability/AutopilotAbilityManager.java @@ -0,0 +1,274 @@ +package com.zhidao.support.adas.high.common.autopilot.ability; + +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; + +import com.zhidao.support.adas.high.AdasManager; +import com.zhidao.support.adas.high.OnAdasListener; +import com.zhidao.support.adas.high.common.Constants; +import com.zhidao.support.adas.high.common.CupidLogUtils; + +import java.util.Timer; +import java.util.TimerTask; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import chassis.ChassisStatesOuterClass; +import mogo.telematics.pad.MessagePad; +import system_master.SystemStatusInfo; + +/** + * 是否可以启动自动驾驶能力检测 + * 目前监控了底盘的一些状态和查询节点状态应答的数据 + * 没有使用监控事件报告的原因是因为,部分异常没进行正常恢复通知,例如收到了异常监控数据,但是异常恢复之后没有恢复的通知 + *
+ * 此定时器不能停止 鹰眼中存在UI更新依赖循环查询系统状态 + */ +public class AutopilotAbilityManager { + private static final String TAG = AutopilotAbilityManager.class.getSimpleName(); + private static volatile AutopilotAbilityManager INSTANCE; + private OnAdasListener listener; + private final Pattern pattern = Pattern.compile("\\d+\\.\\d+\\.\\d+"); + private Handler handler; + private OnAutopilotAbilityListener onAutopilotAbilityListener; + private int dockerVersion = -1;//工控机版本 + private AutopilotAbility230 autopilotAbility230; + private AutopilotAbility250 autopilotAbility250; + private Timer startTimer; + /** + * 身份/车型 + */ + private String identityMode; + + 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 (福田清扫车司机端) + *
+ * 此定义不区分角色,只区分业务线和车型 + */ + 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";//(福田清扫车司机端) + } + + private AutopilotAbilityManager() { + } + + public static AutopilotAbilityManager getInstance() { + if (INSTANCE == null) { + synchronized (AutopilotAbilityManager.class) { + if (INSTANCE == null) { + INSTANCE = new AutopilotAbilityManager(); + } + } + } + return INSTANCE; + } + + public void setIdentityMode(String identityMode) { + this.identityMode = identityMode; + } + + public void setCarConfig(MessagePad.CarConfigResp carConfig) { + if (dockerVersion == -1) { + String v = carConfig.getDockVersion(); + int version = parseVersion(true, v); + if (version != -1) { + stopTimer(); + dockerVersion = version; + Log.i("dddd", "工控机版本=" + dockerVersion); + initAutopilotAbility(); + } + } + } + + public void setOnAdasListener(OnAdasListener listener) { + this.listener = listener; + } + + public OnAdasListener getListener() { + return listener; + } + + public void setHandler(Handler handler) { + this.handler = handler; + } + + public Handler getHandler() { + return handler; + } + + public void setOnAutopilotAbilityListener(OnAutopilotAbilityListener onAutopilotAbilityListener) { + this.onAutopilotAbilityListener = onAutopilotAbilityListener; + } + + public OnAutopilotAbilityListener getOnAutopilotAbilityListener() { + return onAutopilotAbilityListener; + } + + + public void setStatusInfo(SystemStatusInfo.StatusInfo statusInfo) { + if (autopilotAbility250 != null) { + autopilotAbility250.setStatusInfo(statusInfo); + } + } + + public void setChassisStates(ChassisStatesOuterClass.ChassisStates chassisStates) { + if (autopilotAbility230 != null) { + autopilotAbility230.setChassisStates(chassisStates); + } + if (autopilotAbility250 != null) { + autopilotAbility250.setChassisStates(chassisStates); + } + } + + public void onHandleMessage(Message msg) { + if (autopilotAbility250 != null) { + autopilotAbility250.onHandleMessage(msg); + } + } + + private void initAutopilotAbility() { + if (dockerVersion >= 250) { + stop230(); + if (autopilotAbility250 == null) { + autopilotAbility250 = new AutopilotAbility250(); + autopilotAbility250.start(); + } + } else { + stop250(); + if (autopilotAbility230 == null) { + autopilotAbility230 = new AutopilotAbility230(); + autopilotAbility230.start(); + } + + } + } + + private void stop230() { + if (autopilotAbility230 != null) { + autopilotAbility230.stop(); + autopilotAbility230 = null; + } + } + + private void stop250() { + if (autopilotAbility250 != null) { + autopilotAbility250.stop(); + autopilotAbility250 = null; + } + } + + private void stopTimer() { + if (startTimer != null) { + startTimer.cancel(); + startTimer = null; + } + } + + /** + * 连接工控机成功调用此函数,如果dockerVersion还未获取到将启动最低版本的启动自动驾驶能力检测 + * 此函数为保险措施 以防无法获取工控机版本时 也能 正常执行逻辑 + */ + public synchronized void start() { + if (startTimer == null) { + startTimer = new Timer(); + startTimer.schedule(new TimerTask() { + @Override + public void run() { + if (dockerVersion == -1 && AdasManager.getInstance().getIpcConnectionStatus() == Constants.IPC_CONNECTION_STATUS.CONNECTED) { + dockerVersion = 230; + initAutopilotAbility(); + } + } + }, 8000L);//延迟执行,避免刚连接成功后底盘信息无法及时同步 + } + + } + + public synchronized void stop() { + stopTimer(); + stop230(); + stop250(); + handler = null; + dockerVersion = -1; + } + + + /** + * 解析版本 格式 xxx.xxx.xxx(x的数量不固定) + * + * @param isUserAll 是否使用全部截取数据 true:表示 12.34.56 截取之后 123456 false:表示12.34.56 截取之后 12 + * @param ver 版本字符串 + * @return -1表示解析失败 + */ + public int parseVersion(boolean isUserAll, String ver) { + int version = -1; + if (!TextUtils.isEmpty(ver)) { + try { + Matcher matcher = pattern.matcher(ver); + if (matcher.find()) { + String group = matcher.group(); + if (!TextUtils.isEmpty(group)) { + if (isUserAll) { + group = group.replace(".", ""); + } else { + group = group.split("\\.")[0]; + } + version = Integer.parseInt(group); + } + } + } catch (Exception e) { + CupidLogUtils.e(TAG, "版本解析失败=" + ver, e); + } + } + return version; + } + + /** + * 金旅、开沃小巴乘客端 + */ + public boolean isBusPassenger() { + return IDENTITY_MODE.BUS_PASSENGER_BASE.equalsIgnoreCase(identityMode); + } + + /** + * 开沃小巴司机端 + */ + public boolean isBusDriverVan() { + return IDENTITY_MODE.BUS_DRIVER_VAN.equalsIgnoreCase(identityMode); + } + + /** + * 金旅小巴司机端 + */ + public boolean isBusDriver() { + return IDENTITY_MODE.BUS_DRIVER_BASE.equalsIgnoreCase(identityMode); + } + + /** + * 福田清扫车司机端 + */ + public boolean isSweeperDriverFutian() { + return IDENTITY_MODE.SWEEPER_DRIVER_FT.equalsIgnoreCase(identityMode); + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/CarConfigRespMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/CarConfigRespMessage.java index 61c6d1b9f4..7a63aed0b6 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/CarConfigRespMessage.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/CarConfigRespMessage.java @@ -7,6 +7,7 @@ import com.zhidao.support.adas.high.AdasChannel; import com.zhidao.support.adas.high.AdasManager; import com.zhidao.support.adas.high.OnAdasListener; import com.zhidao.support.adas.high.common.CupidLogUtils; +import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager; import com.zhidao.support.adas.high.protocol.RawData; import mogo.telematics.pad.MessagePad; @@ -20,6 +21,7 @@ public class CarConfigRespMessage extends MyAbstractMessageHandler { public void handlerMsg(RawData raw, OnAdasListener adasListener) throws InvalidProtocolBufferException { MessagePad.CarConfigResp carConfigResp = MessagePad.CarConfigResp.parser().parseFrom(raw.originalData.toByteArray(), raw.getOffsetValue(), raw.getPackageLengthValue() - raw.getOffsetValue()); AdasChannel.calculateTimeConsumingOnDispatchRaw("车机基础信息应答", raw.receiveTime); + AutopilotAbilityManager.getInstance().setCarConfig(carConfigResp); AdasManager.getInstance().setCarConfig(carConfigResp); long nowTime = 0; if (CupidLogUtils.isEnableLog()) diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java index 081a1a9a58..edb7d6f1a0 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ChassisStatesMessage.java @@ -2,7 +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.common.autopilot.ability.AutopilotAbilityManager; import com.zhidao.support.adas.high.protocol.RawData; import chassis.ChassisStatesOuterClass; diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/StatusQueryRespMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/StatusQueryRespMessage.java index be81f42258..2d37f3ced7 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/StatusQueryRespMessage.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/StatusQueryRespMessage.java @@ -5,7 +5,7 @@ import android.os.SystemClock; import com.google.protobuf.InvalidProtocolBufferException; import com.zhidao.support.adas.high.AdasChannel; import com.zhidao.support.adas.high.OnAdasListener; -import com.zhidao.support.adas.high.common.AutopilotAbilityManager; +import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager; import com.zhidao.support.adas.high.common.CupidLogUtils; import com.zhidao.support.adas.high.protocol.RawData; diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java index 0b3575b12a..567249f372 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java @@ -5,7 +5,7 @@ import android.os.SystemClock; import com.google.protobuf.InvalidProtocolBufferException; import com.zhidao.support.adas.high.AdasChannel; import com.zhidao.support.adas.high.OnAdasListener; -import com.zhidao.support.adas.high.common.AutopilotAbilityManager; +import com.zhidao.support.adas.high.common.autopilot.ability.AutopilotAbilityManager; import com.zhidao.support.adas.high.common.CupidLogUtils; import com.zhidao.support.adas.high.protocol.RawData; @@ -141,7 +141,7 @@ public class VehicleStateMessage extends MyAbstractMessageHandler { ChassisStatesOuterClass.GearSystemStates.Builder gearSystemStates = null; if (vehicleState.hasGear()) { gearSystemStates = ChassisStatesOuterClass.GearSystemStates.newBuilder(); - //挂挡档位数据 + //档位数据 gearSystemStates.setGearPosition(vehicleState.getGear());//鹰眼已用 } if (vehicleState.hasGearSwitchInference()) { diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/hdcache/IHdCacheListener.kt b/libraries/mogo-map-api/src/main/java/com/mogo/map/hdcache/IHdCacheListener.kt index 4761e40fff..9492c60ba7 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/hdcache/IHdCacheListener.kt +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/hdcache/IHdCacheListener.kt @@ -2,4 +2,6 @@ package com.mogo.map.hdcache interface IHdCacheListener { fun onMapHdCacheProgress(cityId: Int, progress: Double) + + fun onMapHdCacheResult(cityId: Int, state: Int)// 0失败,1成功 } \ No newline at end of file diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java index 8235fe8a36..93093c74f7 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -358,4 +358,6 @@ public interface IMogoMapUIController { * @return */ boolean isCityDataCached(); + + void cancelDownloadCacheData(); } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java index 68c15404f3..09aea37182 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.java @@ -58,6 +58,7 @@ import com.mogo.map.utils.ResIdCache; import com.zhidaoauto.map.sdk.open.MapAutoApi; import com.zhidaoauto.map.sdk.open.abs.MapStatusListener; import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener; +import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener; import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener; import com.zhidaoauto.map.sdk.open.abs.OnMapLoadedListener; import com.zhidaoauto.map.sdk.open.abs.OnMapStyleListener; @@ -1051,17 +1052,35 @@ public class AMapViewWrapper implements IMogoMapView, Integer id = HDMapUtils.getHDCityCode(gdCityCode); if (id != null) { hdCacheListener = listener; - mMapView.getMapAutoViewHelper().cacheHDDataByCity(id, (cityId, progress) -> { - if (Thread.currentThread() == Looper.getMainLooper().getThread()) { - if (hdCacheListener != null) { - hdCacheListener.onMapHdCacheProgress(cityId, progress * 100); - } - } else { - UiThreadHandler.post(() -> { + mMapView.getMapAutoViewHelper().cacheHDDataByCity(id, new OnHdDataDownByCityListener() { + @Override + public void onMapHDDataCacheProgressByCity(int cityId, double progress) { + if (Thread.currentThread() == Looper.getMainLooper().getThread()) { if (hdCacheListener != null) { hdCacheListener.onMapHdCacheProgress(cityId, progress * 100); } - }); + } else { + UiThreadHandler.post(() -> { + if (hdCacheListener != null) { + hdCacheListener.onMapHdCacheProgress(cityId, progress * 100); + } + }); + } + } + + @Override + public void onMapHDDataCacheStateByCity(int i, int state) {// 0失败,1成功 + if (Thread.currentThread() == Looper.getMainLooper().getThread()) { + if (hdCacheListener != null) { + hdCacheListener.onMapHdCacheResult(i, state); + } + } else { + UiThreadHandler.post(() -> { + if (hdCacheListener != null) { + hdCacheListener.onMapHdCacheResult(i, state); + } + }); + } } }); } @@ -1084,6 +1103,13 @@ public class AMapViewWrapper implements IMogoMapView, } } } - return true; + return false; + } + + @Override + public void cancelDownloadCacheData() { + if (mMapView.getMapAutoViewHelper() != null) { + mMapView.getMapAutoViewHelper().cancelCacheHDData(); + } } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java index fbbb4ab578..9554442fea 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java @@ -464,6 +464,13 @@ public class MogoMapUIController implements IMogoMapUIController { if (mDelegate != null) { return mDelegate.isCityDataCached(); } - return true; + return false; + } + + @Override + public void cancelDownloadCacheData() { + if (mDelegate != null) { + mDelegate.cancelDownloadCacheData(); + } } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/location/GDLocationClient.java b/libraries/mogo-map/src/main/java/com/mogo/map/location/GDLocationClient.java deleted file mode 100644 index 2dfa892d3d..0000000000 --- a/libraries/mogo-map/src/main/java/com/mogo/map/location/GDLocationClient.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.mogo.map.location; - -import android.content.Context; - -import com.amap.api.location.AMapLocation; -import com.amap.api.location.AMapLocationClient; -import com.amap.api.location.AMapLocationClientOption; -import com.amap.api.location.AMapLocationListener; -import com.mogo.commons.AbsMogoApplication; -import com.mogo.commons.constants.SharedPrefsConstants; -import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; - -/** - * 封装高德地图通过设备GPS获取到的位置信息,频率1s一次,坐标系为CJC20 - * 这里的数据仅用于非高精度业务 - */ -public class GDLocationClient implements AMapLocationListener, IMogoGDLocationClient { - - private volatile static GDLocationClient gdLocationClient; - private static final byte[] obj = new byte[0]; - - public static GDLocationClient getInstance(Context context) { - if (gdLocationClient == null) { - synchronized (obj) { - if (gdLocationClient == null) { - gdLocationClient = new GDLocationClient(context); - } - } - } - return gdLocationClient; - } - - //声明LocationClient对象 - private AMapLocationClient mLocationClient; - private String mCityCode; - private AMapLocation mapLocation; - - private GDLocationClient(Context context) { - AMapLocationClient.updatePrivacyShow(context, true, true); - AMapLocationClient.updatePrivacyAgree(context, true); - try { - mLocationClient = new AMapLocationClient(context); - - //初始化定位参数 - //声明mLocationOption对象 - AMapLocationClientOption mLocationOption = new AMapLocationClientOption(); - //设置定位监听 - mLocationClient.setLocationListener(this); - //设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式 - mLocationOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy); - //设置定位间隔,单位毫秒,默认为2000ms - mLocationOption.setInterval(1000); - //设置定位参数 - mLocationClient.setLocationOption(mLocationOption); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public void start() { - if (mLocationClient != null) { - mLocationClient.startLocation(); - } - } - - @Override - public void stop() { - if (mLocationClient != null) { - mLocationClient.stopLocation(); - } - } - - @Override - public void onLocationChanged(AMapLocation aMapLocation) { - if (aMapLocation != null) { - mapLocation = aMapLocation; - String cityCode = aMapLocation.getCityCode(); - if (cityCode != null && !cityCode.isEmpty()) { - mCityCode = aMapLocation.getCityCode(); - SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()) - .putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode); - } - } - } - - @Override - public String getLastCityCode() { - return mCityCode; - } - - @Override - public double getLastLat() { - return mapLocation != null ? mapLocation.getLatitude() : 0.0; - } - - @Override - public double getLastLon() { - return mapLocation != null ? mapLocation.getLongitude() : 0.0; - } -} diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/location/GDLocationClient.kt b/libraries/mogo-map/src/main/java/com/mogo/map/location/GDLocationClient.kt new file mode 100644 index 0000000000..8945ded1cf --- /dev/null +++ b/libraries/mogo-map/src/main/java/com/mogo/map/location/GDLocationClient.kt @@ -0,0 +1,147 @@ +package com.mogo.map.location + +import android.content.Context +import com.amap.api.location.AMapLocation +import com.amap.api.location.AMapLocationClient +import com.amap.api.location.AMapLocationClientOption +import com.amap.api.location.AMapLocationListener +import com.mogo.commons.AbsMogoApplication +import com.mogo.commons.constants.SharedPrefsConstants +import com.mogo.eagle.core.data.map.MogoLocation +import com.mogo.eagle.core.function.call.map.CallerGaoDeMapLocationListenerManager +import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr +import com.mogo.eagle.core.utilcode.util.CoordinateTransform +import com.mogo.eagle.core.utilcode.util.TimeUtils + +/** + * 封装高德地图通过设备GPS获取到的位置信息,频率1s一次,坐标系为CJC20 + * 这里的数据仅用于非高精度业务 + */ +class GDLocationClient private constructor(context: Context) : AMapLocationListener, + IMogoGDLocationClient { + //声明LocationClient对象 + private lateinit var mLocationClient: AMapLocationClient + private var mCityCode: String = "" + private var mapLocation: AMapLocation? = null + + /** + * 最后一次高德定位返回的位置信息 + */ + private var lastGaoDeLocation: MogoLocation = MogoLocation() + + init { + AMapLocationClient.updatePrivacyShow(context, true, true) + AMapLocationClient.updatePrivacyAgree(context, true) + try { + mLocationClient = AMapLocationClient(context) + + //初始化定位参数 + //声明mLocationOption对象 + val mLocationOption = AMapLocationClientOption() + //设置定位监听 + mLocationClient.setLocationListener(this) + //设置定位模式为高精度模式,Battery_Saving为低功耗模式,Device_Sensors是仅设备模式 + mLocationOption.locationMode = AMapLocationClientOption.AMapLocationMode.Hight_Accuracy + //设置定位间隔,单位毫秒,默认为2000ms + mLocationOption.interval = 1000 + //设置定位参数 + mLocationClient.setLocationOption(mLocationOption) + } catch (e: Exception) { + e.printStackTrace() + } + } + + override fun start() { + if (mLocationClient != null) { + mLocationClient.startLocation() + } + } + + override fun stop() { + if (mLocationClient != null) { + mLocationClient.stopLocation() + } + } + + override fun onLocationChanged(aMapLocation: AMapLocation) { + // 更新GNSS 信息 + lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills() + + // 将高德中的一些用于业务的数据进行融合,例如:CityCode、address等 + mapLocation?.let { + // 转换 GCJ02-->WGS84 坐标 + val wgs84Location = + CoordinateTransform.GCJ02ToWGS84(it.longitude, it.latitude) + + lastGaoDeLocation.longitude = wgs84Location[0] + lastGaoDeLocation.latitude = wgs84Location[1] + lastGaoDeLocation.heading = it.bearing.toDouble() + lastGaoDeLocation.gnssSpeed = it.speed + lastGaoDeLocation.altitude = it.altitude + lastGaoDeLocation.satelliteTime = it.time + lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills() + + lastGaoDeLocation.locType = 1 // 定位类型为高德坐标(网路或者硬件定位) + lastGaoDeLocation.satellite = 4 + + lastGaoDeLocation.cityName = it.city + lastGaoDeLocation.cityCode = it.cityCode + lastGaoDeLocation.provider = it.provider + lastGaoDeLocation.address = it.address + lastGaoDeLocation.district = it.district + lastGaoDeLocation.province = it.province + lastGaoDeLocation.adCode = it.adCode + lastGaoDeLocation.locationDetail = it.locationDetail + lastGaoDeLocation.poiName = it.poiName + lastGaoDeLocation.aoiName = it.aoiName + lastGaoDeLocation.street = it.street + lastGaoDeLocation.streetNum = it.streetNum + lastGaoDeLocation.description = it.description + lastGaoDeLocation.buildingId = it.buildingId + lastGaoDeLocation.floor = it.floor + lastGaoDeLocation.errorCode = it.errorCode + lastGaoDeLocation.errorInfo = it.errorInfo + } + + // 回掉给监听者 + CallerGaoDeMapLocationListenerManager.invokeMoGoLocationChanged(lastGaoDeLocation) + + mapLocation = aMapLocation + val cityCode = aMapLocation.cityCode + if (cityCode != null && !cityCode.isEmpty()) { + mCityCode = aMapLocation.cityCode + SharedPrefsMgr.getInstance(AbsMogoApplication.getApp()) + .putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode) + } + } + + override fun getLastCityCode(): String { + return mCityCode + } + + override fun getLastLat(): Double { + return if (mapLocation != null) mapLocation!!.latitude else 0.0 + } + + override fun getLastLon(): Double { + return if (mapLocation != null) mapLocation!!.longitude else 0.0 + } + + companion object { + @Volatile + private var gdLocationClient: GDLocationClient? = null + private val obj = ByteArray(0) + + @JvmStatic + fun getInstance(context: Context): GDLocationClient? { + if (gdLocationClient == null) { + synchronized(obj) { + if (gdLocationClient == null) { + gdLocationClient = GDLocationClient(context) + } + } + } + return gdLocationClient + } + } +} \ No newline at end of file diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java index f48f36cc66..090f1ccbd4 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/uicontroller/AMapUIController.java @@ -403,6 +403,13 @@ public class AMapUIController implements IMogoMapUIController { if (mClient != null) { return mClient.isCityDataCached(); } - return true; + return false; + } + + @Override + public void cancelDownloadCacheData() { + if (mClient != null) { + mClient.cancelDownloadCacheData(); + } } } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/utils/PointInterpolatorUtil.java b/libraries/mogo-map/src/main/java/com/mogo/map/utils/PointInterpolatorUtil.java index 063da4fb7c..a985d9b90c 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/utils/PointInterpolatorUtil.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/utils/PointInterpolatorUtil.java @@ -1,9 +1,9 @@ package com.mogo.map.utils; -import com.mogo.cloud.commons.utils.CoordinateUtils; import com.mogo.eagle.core.data.map.LonLatPoint; import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; +import com.mogo.eagle.core.utilcode.util.CoordinateUtils; import java.util.ArrayList; import java.util.List; diff --git a/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java b/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java index ac22671363..ac143c2920 100644 --- a/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java +++ b/test/crashreport-apmbyte/src/main/java/com/mogo/test/crashreport/apm/ApmCrashReportProvider.java @@ -13,6 +13,8 @@ import com.bytedance.apm.insight.ApmInsightInitConfig; import com.mogo.commons.constants.SharedPrefsConstants; import com.mogo.commons.debug.DebugConfig; import com.mogo.eagle.core.data.bindingcar.CarInfo; +import com.mogo.eagle.core.data.config.FunctionBuildConfig; +import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr; import com.mogo.eagle.core.utilcode.util.CommonUtils; @@ -96,6 +98,7 @@ public class ApmCrashReportProvider implements ITestCrashReportProvider { crash.addTags("CITYCODE", mCityCode); crash.addTags("LATITUDE", mLat); crash.addTags("LONGITUTE", mLogt); + crash.addTags("CAR_TYPE", AppIdentityModeUtils.INSTANCE.getBuildCarType(FunctionBuildConfig.appIdentityMode)); // crash.setReportUrl("www.xxx.com"); // 私有化部署:私有化部署才配置上报地址 // crash.addTags("key", "value"); // 自定义筛选tag, 按需添加、可多次覆盖