From b8abf1050c924579dca1af5fed78f50ea0e61e3a Mon Sep 17 00:00:00 2001 From: tongchenfei Date: Mon, 11 Jan 2021 14:18:18 +0800 Subject: [PATCH] opt BlockStrategy.kt --- .idea/gradle.xml | 1 + .../zhidao/mogo/module/obu/ObuConstant.java | 36 +++++++++++++++++++ .../module/obu/obu/bean/MogoObuEventInfo.kt | 12 +++++++ .../share/strategyreceiver/BlockStrategy.kt | 8 ++--- .../com/mogo/module/v2x/V2XObuManager.java | 19 +++++++++- .../scenario/scene/obu/V2XObuEventWindow.java | 26 ++++++++++++++ 6 files changed, 97 insertions(+), 5 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 5974cf305a..9d8d20d50d 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -84,6 +84,7 @@ diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuConstant.java b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuConstant.java index d6b9513901..0ad1b3d846 100644 --- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuConstant.java +++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/ObuConstant.java @@ -40,4 +40,40 @@ public class ObuConstant { * 闯红灯预警 */ public static final int TYPE_RUSH_RED_LIGHT = 117; + /** + * 盲区辅助 + */ + public static final int TYPE_BLIND_ASSIST_WARN = 118; + /** + * 异常车辆预警 + */ + public static final int TYPE_UNUSUAL_CAR_WARN = 119; + /** + * 道路危险情况预警 + */ + public static final int TYPE_UNUSUAL_ROAD_WARN = 120; + /** + * 交通标牌提示 + */ + public static final int TYPE_TRAFFIC_SIGN_INFO = 121; + /** + * 前方拥堵提醒 + */ + public static final int TYPE_BLOCK_WARN = 122; + /** + * 紧急车辆提示预警 + */ + public static final int TYPE_PRESSING_CAR_WARN = 123; + /** + * 已闯红灯提示 + */ + public static final int TYPE_HAS_RUSH_RED_LIGHT = 124; + /** + * 车道汇合预警 + */ + public static final int TYPE_LANE_CONVERGE_WARN = 125; + /** + * 限速预警 + */ + public static final int TYPE_LIMIT_SPEED_WARN = 126; } diff --git a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuEventInfo.kt b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuEventInfo.kt index 549ea38278..5df4f03ce5 100644 --- a/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuEventInfo.kt +++ b/modules/mogo-module-obu/src/main/java/com/zhidao/mogo/module/obu/obu/bean/MogoObuEventInfo.kt @@ -36,6 +36,18 @@ class MogoObuEventInfo(){ "39" -> // 行人碰撞预警 ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING "vip变灯提醒" -> ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP + "01" -> ObuConstant.TYPE_FRONT_COLLISION_WARNING + "02" -> ObuConstant.TYPE_CROSS_COLLISION_WARNING + "04" -> ObuConstant.TYPE_BLIND_ASSIST_WARN + "07" -> ObuConstant.TYPE_UNUSUAL_CAR_WARN + "09" -> ObuConstant.TYPE_UNUSUAL_ROAD_WARN + "11" -> ObuConstant.TYPE_RUSH_RED_LIGHT + "14" -> ObuConstant.TYPE_TRAFFIC_SIGN_INFO + "15" -> ObuConstant.TYPE_BLOCK_WARN + "16" -> ObuConstant.TYPE_PRESSING_CAR_WARN + "20" -> ObuConstant.TYPE_HAS_RUSH_RED_LIGHT + "21" -> ObuConstant.TYPE_LANE_CONVERGE_WARN + "10" -> ObuConstant.TYPE_LIMIT_SPEED_WARN null -> -1 else -> type.toInt() } diff --git a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt index 6bb1360d4f..c0994641dc 100644 --- a/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt +++ b/modules/mogo-module-share/src/main/java/com/mogo/module/share/strategyreceiver/BlockStrategy.kt @@ -58,7 +58,7 @@ private const val SPEED_NORMAL_COUNT = "SPEED _NORMAL_COUNT" */ class BlockStrategy(private val context: Context, private val apis: IMogoServiceApis) { private var startRecordTime: Long = 0 - private var speedCacheList = ArrayList() + private var speedCacheList = ArrayList() /** * 停车标志位,当速度为0时加1,超过[STOP_FLAG_THRESHOLD]判定为停车,不认为是拥堵,这组数据无效 @@ -99,9 +99,9 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService speedCacheList.clear() } - speedCacheList.add(speed) + speedCacheList.add(currentSpeed) - if (speed == 0F) { + if (currentSpeed == 0) { stopFlag++ } else if (stopFlag < STOP_FLAG_THRESHOLD) { // 如果本次计算期间,stopFlag还没超过阈值,就置为零,如果超过阈值了,说明本次计算期间存在超过阈值的停止次数,就舍弃掉本次计算 @@ -132,7 +132,7 @@ class BlockStrategy(private val context: Context, private val apis: IMogoService // 到达时间限制,上报速度,数据清空 if (stopFlag < STOP_FLAG_THRESHOLD) { // 停车标志位小于阈值,判定不是停车,计算平均值,进行上报 - var sum = 0F + var sum = 0 speedCacheList.forEach { sum += it } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java index 901c5f05fc..c2dd021a72 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XObuManager.java @@ -180,7 +180,7 @@ public class V2XObuManager implements IObuCallback, Handler.Callback { public void onEventInfoCallback(MogoObuEventInfo info) { Logger.d("V2X_OBU_EVENT", "carEventInfo==" + info); if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { - Logger.d("V2X_OBU_EVENT","vr模式下不展示obu事件"); + Logger.d("V2X_OBU_EVENT", "vr模式下不展示obu事件"); return; } Long last = intervalMap.get(info.getTypeCode()); @@ -263,6 +263,23 @@ public class V2XObuManager implements IObuCallback, Handler.Callback { intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity); LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); break; + case ObuConstant.TYPE_BLIND_ASSIST_WARN: + case ObuConstant.TYPE_HAS_RUSH_RED_LIGHT: + case ObuConstant.TYPE_LANE_CONVERGE_WARN: + case ObuConstant.TYPE_LIMIT_SPEED_WARN: + case ObuConstant.TYPE_PRESSING_CAR_WARN: + case ObuConstant.TYPE_TRAFFIC_SIGN_INFO: + case ObuConstant.TYPE_BLOCK_WARN: + case ObuConstant.TYPE_FRONT_COLLISION_WARNING: + case ObuConstant.TYPE_UNUSUAL_CAR_WARN: + case ObuConstant.TYPE_UNUSUAL_ROAD_WARN: + // 暂无设计图,先简单显示 + V2XObuEventEntity tmpEvent = new V2XObuEventEntity(); + tmpEvent.setType(eventType); + tmpEvent.setDesc(info.getType()+"--"+info.getDescribe()); + messageEntity.setContent(tmpEvent); + V2XObuEventScenario.getInstance().init(messageEntity); + break; default: break; } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java index 2bf04a71f1..5b686a320c 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/obu/V2XObuEventWindow.java @@ -94,6 +94,32 @@ public class V2XObuEventWindow extends FrameLayout implements IV2XWindow