From bcddbfc3388fc924604b7f88542a6ef95c54f133 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Fri, 19 Jul 2024 18:54:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?[6.5.0][=E4=BA=8B=E4=BB=B6=E5=BC=B9?= =?UTF-8?q?=E6=A1=86]=20refactor:=20=E5=8F=B8=E6=9C=BA=E5=B1=8F=20UI=20?= =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/layout/taxi_base_fragment.xml | 21 ++++++++------- .../main/res/layout/taxi_p_base_fragment.xml | 1 + .../layout/unmanned_taxi_base_fragment.xml | 21 ++++++++------- .../res/layout/taxt_u_p_base_fragment.xml | 3 ++- .../hmi/ui/v2n/RoadV2NEventWindowView.kt | 26 ++++++++++++------- 5 files changed, 42 insertions(+), 30 deletions(-) diff --git a/OCH/taxi/driver/src/main/res/layout/taxi_base_fragment.xml b/OCH/taxi/driver/src/main/res/layout/taxi_base_fragment.xml index 8d7df3aebb..b0533871bc 100644 --- a/OCH/taxi/driver/src/main/res/layout/taxi_base_fragment.xml +++ b/OCH/taxi/driver/src/main/res/layout/taxi_base_fragment.xml @@ -159,6 +159,17 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + - - diff --git a/OCH/taxi/passenger/src/main/res/layout/taxi_p_base_fragment.xml b/OCH/taxi/passenger/src/main/res/layout/taxi_p_base_fragment.xml index 9f3240688d..e8cbfbfcff 100644 --- a/OCH/taxi/passenger/src/main/res/layout/taxi_p_base_fragment.xml +++ b/OCH/taxi/passenger/src/main/res/layout/taxi_p_base_fragment.xml @@ -236,6 +236,7 @@ app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + - - diff --git a/OCH/taxi/unmanned-passenger/src/main/res/layout/taxt_u_p_base_fragment.xml b/OCH/taxi/unmanned-passenger/src/main/res/layout/taxt_u_p_base_fragment.xml index f7ee5267fc..2ce34582f8 100644 --- a/OCH/taxi/unmanned-passenger/src/main/res/layout/taxt_u_p_base_fragment.xml +++ b/OCH/taxi/unmanned-passenger/src/main/res/layout/taxt_u_p_base_fragment.xml @@ -246,7 +246,8 @@ android:layout_marginEnd="@dimen/dp_60" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> - + + Date: Sat, 20 Jul 2024 20:39:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?[6.5.0]=E8=BF=90=E8=90=A5=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E9=92=AE=E7=82=B9=E5=87=BB=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/hmi/ui/setting/SOPSettingView.kt | 36 ++++++++++++ .../hmi/ui/utils/SOPAnalyticsManager.kt | 55 +++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/SOPAnalyticsManager.kt diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt index fe673db706..735f3dc67d 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/setting/SOPSettingView.kt @@ -33,6 +33,7 @@ import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.function.hmi.ui.tools.SweeperModeChangedConfirmDialog import com.mogo.eagle.core.function.call.unmanned.CallerUnmannedListenerManager import com.mogo.eagle.core.function.hmi.ui.utils.HmiActionLog.Companion.hmiAction +import com.mogo.eagle.core.function.hmi.ui.utils.SOPAnalyticsManager.clickEventAnalytics import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.vehicle.SweeperVehicleConfigUtils @@ -142,6 +143,7 @@ internal class SOPSettingView @JvmOverloads constructor( scV2XSwitch.setOnCheckedChangeListener { _, isChecked -> FunctionBuildConfig.v2xMainSwitch = isChecked hmiAction("SOP V2X总开关, ", isChecked) + clickEventAnalytics("V2X总开关",isChecked) if (isChecked) { //V2N总开关 scV2NSwitch.isChecked = FunctionBuildConfig.v2nMainSwitch @@ -190,6 +192,7 @@ internal class SOPSettingView @JvmOverloads constructor( //绿波通行(默认关闭) scGreenWaveSop.isEnabled = FunctionBuildConfig.v2nMainSwitch scV2NSwitch.setOnCheckedChangeListener { compoundButton, isChecked -> + clickEventAnalytics("V2N总开关",isChecked) if (isChecked) { //V2N新链路 scNewV2NData.isChecked = FunctionBuildConfig.isNewV2NData @@ -242,6 +245,7 @@ internal class SOPSettingView @JvmOverloads constructor( scRunRedLightSop.isEnabled = HmiBuildConfig.isShowObuV2iView scObuWeaknessTrafficSop.isEnabled = HmiBuildConfig.isShowObuV2iView scV2ISwitch.setOnCheckedChangeListener { compoundButton, isChecked -> + clickEventAnalytics("V2I总开关",isChecked) if (isChecked) { //V2I场景进PNC scV2iPnc.isChecked = FunctionBuildConfig.isV2IPnc @@ -288,6 +292,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("V2N新链路",isChecked) hmiAction("SOP 是否是V2N新链路(云->工控机->App)", isChecked) FunctionBuildConfig.isNewV2NData = isChecked @@ -304,6 +309,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("V2N场景进PNC",isChecked) hmiAction("SOP V2N场景进PNC, ", isChecked) CallerAutoPilotControlManager.sendV2nToPncCmd(isChecked) FunctionBuildConfig.isV2NPnc = isChecked @@ -315,6 +321,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("绿波通行",isChecked) hmiAction("SOP obu绿波通行, ", isChecked) HmiBuildConfig.isShowGreenWaveView = isChecked if (HmiBuildConfig.isShowGreenWaveView) { @@ -336,6 +343,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("V2I场景进PNC",isChecked) hmiAction("SOP V2I场景进PNC, ", isChecked) CallerAutoPilotControlManager.sendV2iToPncCmd(isChecked) FunctionBuildConfig.isV2IPnc = isChecked @@ -347,6 +355,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("闯红灯预警",isChecked) hmiAction("SOP obu闯红灯预警, ", isChecked) HmiBuildConfig.isShowRunRedLightView = isChecked if (HmiBuildConfig.isShowRunRedLightView) { @@ -368,6 +377,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("路侧弱势交通参与者",isChecked) hmiAction("SOP obu弱势交通控制, ", isChecked) HmiBuildConfig.isShowObuWeaknessTrafficView = isChecked } @@ -378,6 +388,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("V2V总开关",isChecked) hmiAction("SOP obuV2V开关, ", isChecked) HmiBuildConfig.isShowObuV2vView = isChecked } @@ -389,6 +400,7 @@ internal class SOPSettingView @JvmOverloads constructor( if (!compoundButton.isPressed) { return@setOnCheckedChangeListener } + clickEventAnalytics("OBU总开关",isChecked) hmiAction("SOP OBU控制总开关, ", isChecked) if (isChecked) { CallerObuApiManager.resetObuIpAddress(MogoObuConst.OBU_DEFAULT_IP) @@ -408,6 +420,7 @@ internal class SOPSettingView @JvmOverloads constructor( scMarkingObstacles.isChecked = FunctionBuildConfig.isPNCWarning scMarkingObstacles.setOnCheckedChangeListener { _, isChecked -> hmiAction("SOP 危险障碍物颜色标记开关, ", isChecked) + clickEventAnalytics("危险障碍物颜色标记",isChecked) FunctionBuildConfig.isPNCWarning = isChecked } if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { @@ -418,6 +431,7 @@ internal class SOPSettingView @JvmOverloads constructor( scRouteDynamicEffect.isChecked = HmiBuildConfig.isShowRouteStrategy scRouteDynamicEffect.setOnCheckedChangeListener { _, isChecked -> hmiAction("SOP 引导线动态效果, ", isChecked) + clickEventAnalytics("引导线动态效果",isChecked) HmiBuildConfig.isShowRouteStrategy = isChecked CallerDevaToolsManager.setRouteDynamicColorEnable(isChecked) } @@ -441,6 +455,7 @@ internal class SOPSettingView @JvmOverloads constructor( CallerMapUIServiceManager.getMapUIController()?.setIsDrawPointCloud(isChecked) CallerSopSettingManager.invokePointCloudListener(isChecked) hmiAction("SOP 是否渲染点云数据, ", isChecked) + clickEventAnalytics("点云效果",isChecked) } //自车光圈 @@ -461,6 +476,7 @@ internal class SOPSettingView @JvmOverloads constructor( return@setOnCheckedChangeListener } FunctionBuildConfig.isDisplayAnimEnable = isChecked + clickEventAnalytics("自车光圈",isChecked) } } @@ -475,6 +491,7 @@ internal class SOPSettingView @JvmOverloads constructor( return@setOnCheckedChangeListener } hmiAction("SOP 演示模式开关, ", !FunctionBuildConfig.isDemoMode) + clickEventAnalytics("美化模式",isChecked) FunctionBuildConfig.isDemoMode = !FunctionBuildConfig.isDemoMode CallerAutoPilotControlManager.setDemoMode(FunctionBuildConfig.isDemoMode) CallerHmiViewControlListenerManager.invokeFuncMode( @@ -497,6 +514,7 @@ internal class SOPSettingView @JvmOverloads constructor( scShowBagRecordWindow.setOnCheckedChangeListener { _, isChecked -> FunctionBuildConfig.isShowBagRecordWindow = isChecked hmiAction("SOP 是否展示录包弹窗, ", isChecked) + clickEventAnalytics("录包弹窗",isChecked) } //接管提醒 @@ -504,6 +522,7 @@ internal class SOPSettingView @JvmOverloads constructor( scTakeOverRemind.setOnCheckedChangeListener { _, isChecked -> FunctionBuildConfig.isTakeoverRemind = isChecked hmiAction("SOP 是否展示接管提醒, ", isChecked) + clickEventAnalytics("接管提醒",isChecked) } } @@ -518,6 +537,7 @@ internal class SOPSettingView @JvmOverloads constructor( hmiAction("SOP 绕障类功能开关, ", isChecked) CallerAutoPilotControlManager.sendDetouring(isChecked) FunctionBuildConfig.isDetouring = isChecked + clickEventAnalytics("绕障类功能",isChecked) } // 雨天模式,上一次勾选的数据 @@ -527,6 +547,7 @@ internal class SOPSettingView @JvmOverloads constructor( return@setOnCheckedChangeListener } hmiAction("SOP 雨天模式开关, ", isChecked) + clickEventAnalytics("雨天模式",isChecked) FunctionBuildConfig.isRainMode = isChecked CallerAutoPilotControlManager.setRainMode(isChecked) CallerHmiViewControlListenerManager.invokeFuncMode(FUNC_MODE_RAIN, isChecked) @@ -543,6 +564,7 @@ internal class SOPSettingView @JvmOverloads constructor( FunctionBuildConfig.isWeakNetSlowDown = isChecked CallerAutoPilotControlManager.sendWeakNetSlowDown(isChecked) hmiAction("SOP 弱网减速停车, ", isChecked) + clickEventAnalytics("弱网减速停车",isChecked) } //故障减速停车 @@ -551,6 +573,7 @@ internal class SOPSettingView @JvmOverloads constructor( FunctionBuildConfig.isFaultSlowDown = isChecked CallerAutoPilotControlManager.sendBreakdownSlowDown(isChecked) hmiAction("SOP 故障减速停车, ", isChecked) + clickEventAnalytics("故障减速停车",isChecked) } //融合模式 rgFusionMode.setOnCheckedChangeListener { _, p1 -> @@ -577,6 +600,7 @@ internal class SOPSettingView @JvmOverloads constructor( } } hmiAction("SOP 融合模式, ", FunctionBuildConfig.fusionMode) + clickEventAnalytics("融合模式",true) CallerAutoPilotControlManager.sendFusionMode(FunctionBuildConfig.fusionMode) } @@ -610,6 +634,7 @@ internal class SOPSettingView @JvmOverloads constructor( ToastUtils.showShort("变道绕障的目标障碍物速度阈值设置失败") hmiAction("SOP 变道绕障的目标障碍物速度阈值设置", "失败") } + clickEventAnalytics("变道速度阈值",true) } ivSpeedOverTakeReduce.setOnClickListener { @@ -640,6 +665,7 @@ internal class SOPSettingView @JvmOverloads constructor( ToastUtils.showShort("SOP 超车目标障碍物速度阈值设置失败") hmiAction("SOP 超车目标障碍物速度阈值设置", "失败") } + clickEventAnalytics("超车速度阈值",true) } if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { @@ -669,6 +695,7 @@ internal class SOPSettingView @JvmOverloads constructor( scTrafficLight.isChecked = !HmiBuildConfig.isShowTrafficLightView scTrafficLight.setOnCheckedChangeListener { _, isChecked -> hmiAction("SOP 红绿灯标识开关, ", isChecked) + clickEventAnalytics("红绿灯标识",isChecked) if (isChecked) { CallerHmiManager.showTrafficLightView() } else { @@ -680,6 +707,7 @@ internal class SOPSettingView @JvmOverloads constructor( scCarUnionTrafficLight.isChecked = HmiBuildConfig.isShowCarSourceTrafficLightView scCarUnionTrafficLight.setOnCheckedChangeListener { _, isChecked -> hmiAction("SOP 红绿灯车端来源标识开关, ", isChecked) + clickEventAnalytics("红绿灯车端融合标识",isChecked) HmiBuildConfig.isShowCarSourceTrafficLightView = isChecked } @@ -687,6 +715,7 @@ internal class SOPSettingView @JvmOverloads constructor( scConnectionSwitch.isChecked = HmiBuildConfig.isShowConnectionProgressView scConnectionSwitch.setOnCheckedChangeListener { _, isChecked -> hmiAction("SOP 系统启动状态展示, ", isChecked) + clickEventAnalytics("系统启动状态展示",isChecked) HmiBuildConfig.isShowConnectionProgressView = isChecked CallerHmiViewControlListenerManager.updateConnectionProgressView(isChecked) } @@ -695,6 +724,7 @@ internal class SOPSettingView @JvmOverloads constructor( scSpeedLimit.isChecked = HmiBuildConfig.isShowLimitingVelocityView scSpeedLimit.setOnCheckedChangeListener { _, isChecked -> hmiAction("SOP 限速标识开关, ", isChecked) + clickEventAnalytics("限速标识",isChecked) if (isChecked) { HmiBuildConfig.isShowLimitingVelocityView = true CallerHmiViewControlListenerManager.invokeVisible( @@ -714,6 +744,7 @@ internal class SOPSettingView @JvmOverloads constructor( scIPCReport.isChecked = FunctionBuildConfig.isReportWarning scIPCReport.setOnCheckedChangeListener { _, isChecked -> hmiAction("SOP 是否开启异常上报, ", isChecked) + clickEventAnalytics("异常上报提示",isChecked) FunctionBuildConfig.isReportWarning = isChecked } @@ -729,6 +760,7 @@ internal class SOPSettingView @JvmOverloads constructor( } else { CallerHmiManager.hidM1360LookAround() } + clickEventAnalytics("360环视",isChecked) } it.isChecked = CallerHmiManager.isM1360LookAroundShowing() } @@ -761,6 +793,7 @@ internal class SOPSettingView @JvmOverloads constructor( } CallerHmiManager.setTaxiUnmanedDriverLineRoutingVerifyMode(false) } + clickEventAnalytics("自主算路验证模式",isChecked) } it.isChecked = CallerHmiManager.isTaxiUnmanedDriverLineRoutingVerifyMode() } else { @@ -784,6 +817,7 @@ internal class SOPSettingView @JvmOverloads constructor( it.setOnCheckedChangeListener { _, isChecked -> CallerLogger.d(TAG, "发送开关数据:${isChecked}到乘客屏") CallerTelematicManager.sendMsgToAllClients(TelematicConstant.WEATHER_SWITCH_STATUS, (if (isChecked) "1" else "0").toByteArray()) + clickEventAnalytics("天气效果开关",isChecked) } } } @@ -822,6 +856,7 @@ internal class SOPSettingView @JvmOverloads constructor( }) confirmDialog.showSweeperModeChangeConfirmDialog() } + clickEventAnalytics("清扫云控业务",isChecked) } } else { switchView.isEnabled = false @@ -850,6 +885,7 @@ internal class SOPSettingView @JvmOverloads constructor( CallerUnmannedListenerManager.dispatchVirtualTaskPullTaskInterval(5) } } + clickEventAnalytics("Taxi无人化演练任务拉取时间间隔",true) } rgPullTime.visibility = if(AppIdentityModeUtils.isTaxiDriver(FunctionBuildConfig.appIdentityMode)) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/SOPAnalyticsManager.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/SOPAnalyticsManager.kt new file mode 100644 index 0000000000..bb0aaa0bc2 --- /dev/null +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/utils/SOPAnalyticsManager.kt @@ -0,0 +1,55 @@ +package com.mogo.eagle.core.function.hmi.ui.utils + +import com.mogo.commons.storage.SharedPrefsMgr +import com.mogo.commons.utils.MogoAnalyticUtils +import com.mogo.eagle.core.data.app.AppConfigInfo +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager +import com.mogo.eagle.core.utilcode.util.AppUtils + +/** + * 运营面板埋点统计管理 + */ +object SOPAnalyticsManager { + private const val sopButtonClick = "sop_button_click" + + private const val eventParamButtonName = "buttonName" //开关名称 + private const val eventParamButtonStatus = "buttonStatus" //开关状态 + private const val eventParamPlateNumber = "plateNumber" //车牌号 + private const val eventParamCarSn = "carSn" //鹰眼SN + private const val eventParamMapVersion = "mapVersion" //工控机版本 + private const val eventParamEyeVersion = "eyeVersion" //鹰眼版本 + + /** + * 运营面板开关点击状态统计 + * @param buttonName 开关名称 + * @param buttonStatus 开关状态 + * @param plateNumber 车牌号 + * @param carSn 鹰眼SN + * @param mapVersion 工控机版本 + * @param eyeVersion 鹰眼版本 + */ + private fun realSOPButtonEvent(buttonName: String,buttonStatus: Boolean,plateNumber: String, + carSn: String,mapVersion: String,eyeVersion: String){ + val clickButtonParams = HashMap() + clickButtonParams[eventParamButtonName] = buttonName + clickButtonParams[eventParamButtonStatus] = buttonStatus + clickButtonParams[eventParamPlateNumber] = plateNumber + clickButtonParams[eventParamCarSn] = carSn + clickButtonParams[eventParamMapVersion] = mapVersion + clickButtonParams[eventParamEyeVersion] = eyeVersion + MogoAnalyticUtils.track(sopButtonClick,clickButtonParams) + } + + /** + * 运营面板开关点击状态统计 + * @param buttonName 开关名称 + * @param buttonStatus 开关状态 + */ + fun clickEventAnalytics(buttonName: String, buttonStatus: Boolean){ + realSOPButtonEvent(buttonName,buttonStatus, AppConfigInfo.plateNumber, + SharedPrefsMgr.getInstance().sn, + CallerAutoPilotStatusListenerManager.getDockerVersion() ?: "", + AppUtils.getAppVersionName()) + } + +} \ No newline at end of file From 18c4c0625900537bdc41d95e46d55fa56e61345e Mon Sep 17 00:00:00 2001 From: xuxinchao Date: Sun, 21 Jul 2024 01:35:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?[6.5.0]=E7=BA=A2=E7=BB=BF=E7=81=AF=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E5=BC=82=E5=B8=B8=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hmi/ui/widget/FusionTrafficLightView.kt | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/FusionTrafficLightView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/FusionTrafficLightView.kt index 376027f50d..529285e630 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/FusionTrafficLightView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/widget/FusionTrafficLightView.kt @@ -16,7 +16,6 @@ import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager import com.mogo.eagle.core.function.hmi.R import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler -import java.util.LinkedList /** * 融合红绿灯View @@ -45,6 +44,8 @@ class FusionTrafficLightView @JvmOverloads constructor( private var currentLightState = TrafficLightEnum.BLACK //当前灯态 private var currentLightDuration = 0 //当前灯态倒计时 + private var previousLightStatus = TrafficLightEnum.BLACK //上一帧灯态 + private var previousLightDuration = 0 //上一帧灯态倒计时 private var redLightRoundNum = 0 //当前路口红灯出现的轮数 private var greenLightRoundNum = 0 //当前路口绿灯出现的轮数 @@ -82,11 +83,11 @@ class FusionTrafficLightView @JvmOverloads constructor( override fun disableTrafficLight() { super.disableTrafficLight() UiThreadHandler.post{ - mCurrentLightId = TrafficLightEnum.BLACK this@FusionTrafficLightView.visibility = GONE CallerHmiViewControlListenerManager.invokeV2XEvent(View.GONE, TAG) //将灯态轮归零 returnToZero() + resetLight() } } @@ -99,11 +100,21 @@ class FusionTrafficLightView @JvmOverloads constructor( yellowLightRoundNum = 0 //当前路口黄灯出现的轮数 } + /** + * 重置灯态 + */ + private fun resetLight(){ + currentLightState = TrafficLightEnum.BLACK + currentLightDuration = 0 + previousLightStatus = TrafficLightEnum.BLACK + previousLightDuration = 0 + } + /** * 判断是否进入新的一轮灯态 * @param currentState 当前灯态 */ - private fun judgeRoundNun(currentState: TrafficLightEnum): Boolean{ + private fun judgeRoundNum(currentState: TrafficLightEnum): Boolean{ if(currentLightState == currentState){ return false }else{ @@ -155,8 +166,30 @@ class FusionTrafficLightView @JvmOverloads constructor( if(this@FusionTrafficLightView.visibility == View.GONE && currentDuration < 1){ return@runOnUiThread } + /** + * 如果红绿灯显示过程中遇到突然灯态发生改变即当前灯态未倒计时完成灯态发生变化 + * (正常情况下不会出现此情况,兼容异常状态) + * 重置灯态占比和指针指向 + */ + if(previousLightStatus == TrafficLightEnum.BLACK && previousLightDuration == 0 + && currentState != TrafficLightEnum.BLACK && currentDuration != 0){ + previousLightStatus = currentState + previousLightDuration = currentDuration + }else{ + if((currentState != previousLightStatus && previousLightDuration >1) + || (currentState == previousLightStatus && previousLightDuration < currentDuration)){ + //灯态未倒计时到1,灯态发生变化(正常情况是倒计时到0,考虑到可能存在的异常情况,倒计时到1也算正常) + returnToZero() + resetLight() + }else{ + previousLightStatus = currentState + previousLightDuration = currentDuration + } + } + + //如果当前红绿灯视图为隐藏状态则设置为显示状态 - if(judgeRoundNun(currentState)){ + if(judgeRoundNum(currentState)){ if(this@FusionTrafficLightView.visibility == View.GONE){ this@FusionTrafficLightView.visibility = View.VISIBLE }