From 72442211b6f3e4d0bc80a6e645b6a702e6553231 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Wed, 11 Dec 2024 16:02:00 +0800 Subject: [PATCH 01/15] =?UTF-8?q?[682]=E4=BB=8Edev=5Frobotaxi-d=5F241202?= =?UTF-8?q?=5F6.8.2=E6=8B=89=E5=8F=96=E6=96=B0=E5=BB=BA6.8.6=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E6=B5=8B=E8=AF=95=E5=90=84=E4=B8=AA=E7=A1=AC=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9f3a269301..b19c16438b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -92,8 +92,8 @@ WEBSOCKET_VERSION=1.1.7 applicationId=com.mogo.launcer applicationName=IntelligentPilot # RoboBus司机端:2.5.1;RoboTaxi司机端:2.5.1;RoboTaxi乘客端:1.0.0 -versionCode=6008002 -versionName=6.8.2 +versionCode=6008006 +versionName=6.8.6 ################# 新架构模块Maven版本管理 ################# MOGO_CORE_FUNCTION_HMI_VERSION=0.0.58.10 From c050550c46db3d49b24205b429cd4f8becafbf01 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 11 Dec 2024 16:20:15 +0800 Subject: [PATCH 02/15] [6.8.2] fix data bug --- .../datacenter/autopilot/MoGoAutopilotControlProvider.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt index 6186e5f1cf..6dce39b47c 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt @@ -31,6 +31,7 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListene import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotControlProvider import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.FUNC_MODE_RAIN import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider +import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerIpcConnectStateToastManager import com.mogo.eagle.core.function.call.cloud.CallerCloudCertManager @@ -164,6 +165,8 @@ class MoGoAutopilotControlProvider : setDemoMode(FunctionBuildConfig.isDemoMode) setFusionColor(FunctionBuildConfig.isFusionColor) setIgnoreConditionDraw(FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData) + sendV2iToPncCmd(FunctionBuildConfig.v2iToPNC) + sendV2nToPncCmd(FunctionBuildConfig.v2nTotalSwitch) msgHandler.synMsgToAllClients() } }, 1000, 10000) From 69ca8d230cf105244d9836b37b71fa603d003ff0 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 11 Dec 2024 16:23:18 +0800 Subject: [PATCH 03/15] [6.8.2] bug fix --- .../datacenter/autopilot/MoGoAutopilotControlProvider.kt | 2 -- .../autopilot/adapter/MoGoAdasMsgConnectStatusListenerImpl.kt | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt index 6dce39b47c..8f626a0b93 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt @@ -165,8 +165,6 @@ class MoGoAutopilotControlProvider : setDemoMode(FunctionBuildConfig.isDemoMode) setFusionColor(FunctionBuildConfig.isFusionColor) setIgnoreConditionDraw(FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData) - sendV2iToPncCmd(FunctionBuildConfig.v2iToPNC) - sendV2nToPncCmd(FunctionBuildConfig.v2nTotalSwitch) msgHandler.synMsgToAllClients() } }, 1000, 10000) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasMsgConnectStatusListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasMsgConnectStatusListenerImpl.kt index 68bc83db76..1011bed827 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasMsgConnectStatusListenerImpl.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasMsgConnectStatusListenerImpl.kt @@ -143,6 +143,8 @@ class MoGoAdasMsgConnectStatusListenerImpl : CallerAutoPilotControlManager.setRainMode(FunctionBuildConfig.isRainMode) // 6.6.2 版本默认开启,与海江确认过,默认发盲区模式 CallerAutoPilotControlManager.sendFusionMode(2) + CallerAutoPilotControlManager.sendV2iToPncCmd(FunctionBuildConfig.v2iToPNC) + CallerAutoPilotControlManager.sendV2nToPncCmd(FunctionBuildConfig.v2nTotalSwitch) } AdasConstants.IpcConnectionStatus.CONNECTING -> { From 33e474ea7fc084adfb97e21b5abd719937d36eaa Mon Sep 17 00:00:00 2001 From: yangyakun Date: Thu, 12 Dec 2024 12:06:24 +0800 Subject: [PATCH 04/15] =?UTF-8?q?[6.8.2]=20[fix]=20[=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E8=B7=AF=E5=8F=A3=E4=BA=8B=E4=BB=B6]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/m2/layout/shuttle_p_m2_fragment.xml | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml b/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml index 81567e8f78..a5d1564386 100644 --- a/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml +++ b/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml @@ -146,39 +146,39 @@ app:layout_constraintBottom_toTopOf="@+id/video_fragment" app:layout_constraintEnd_toEndOf="parent" /> - - + + + + + + + + + + - - + + + + + + + + + + - - + + + + + + + + + + + Date: Thu, 5 Dec 2024 16:17:50 +0800 Subject: [PATCH 05/15] =?UTF-8?q?[6.8.2][Opt]=E4=B8=BB=E5=8A=A8=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E5=88=B0=E5=90=8C=E4=B8=80=E4=B8=AA=E7=BA=BF=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java index 57bf744cfd..6b182d290b 100644 --- a/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java +++ b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java @@ -401,7 +401,13 @@ public class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack { List ttsEntityList = new ArrayList<>(); ttsEntityList.add(new LangTtsEntity(tts, LanguageType.CHINESE)); MultiLangTtsEntity ttsEntity = new MultiLangTtsEntity(ttsEntityList); - speakMultiLangTTSWithLevel(ttsEntity, level); + if (Thread.currentThread() != Looper.getMainLooper().getThread()) { + UiThreadHandler.post(() -> { + speakMultiLangTTSWithLevel(ttsEntity, level); + }, QUEUE); + } else { + speakMultiLangTTSWithLevel(ttsEntity, level); + } } private void speakMultiLangTTSWithLevel(MultiLangTtsEntity ttsEntity,int ttsLevel) { From 0bc223ab3b8102d25ba92c446f62b808b3d2702c Mon Sep 17 00:00:00 2001 From: zhongchao Date: Wed, 18 Dec 2024 15:53:10 +0800 Subject: [PATCH 06/15] [6.8.2] fix bug of voice level point --- .../biz/v2x/v2n/scenario/scene/road/V2XRoadEventScenario.java | 2 +- .../v2n/scenario/scene/warning/V2XFrontWarningScenario.java | 2 +- .../core/function/datacenter/v2x/TrafficLightDispatcher.kt | 3 ++- .../eagle/core/function/hmi/ui/v2n/RoadV2NEventWindowView.kt | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XRoadEventScenario.java b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XRoadEventScenario.java index 815ef4eac3..463882c204 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XRoadEventScenario.java +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/road/V2XRoadEventScenario.java @@ -134,7 +134,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario imp ); CallerHmiManager.INSTANCE.warningV2X(poiType, alarmText, ttsText, this,WarningDirectionEnum.ALERT_WARNING_TOP, - TimeUnit.SECONDS.toMillis(5), AIAssist.LEVEL2, false); + TimeUnit.SECONDS.toMillis(5), AIAssist.NEW_LEVEL_2, false); //消息埋点 V2XEventAnalyticsManager.INSTANCE.triggerV2XEvent(poiType,alarmText,ttsText, DataSourceType.AICLOUD, CommunicationType.V2N); } diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/warning/V2XFrontWarningScenario.java b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/warning/V2XFrontWarningScenario.java index f64e97698b..44c9598e1e 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/warning/V2XFrontWarningScenario.java +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/warning/V2XFrontWarningScenario.java @@ -88,7 +88,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChas CallerHmiManager.INSTANCE.warningV2X(v2xType + "", getAlertContentForFrontWarning(mMarkerEntity), mMarkerEntity.getTts(), this,getDirection(), - TimeUnit.SECONDS.toMillis(5), AIAssist.LEVEL2, false); + TimeUnit.SECONDS.toMillis(5), AIAssist.NEW_LEVEL_2, false); //消息埋点 V2XEventAnalyticsManager.INSTANCE.triggerV2XEvent(v2xType,getAlertContentForFrontWarning(mMarkerEntity).toString(), mMarkerEntity.getTts(), DataSourceType.AICLOUD, CommunicationType.V2N); diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt index 5607717009..59d9ff213b 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/v2x/TrafficLightDispatcher.kt @@ -5,6 +5,7 @@ import android.os.CountDownTimer import android.os.Handler import android.util.Log import com.mogo.commons.voice.AIAssist +import com.mogo.commons.voice.AIAssist.NEW_LEVEL_2 import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightResult import com.mogo.eagle.core.data.biz.trafficlight.TrafficLightStatus import com.mogo.eagle.core.data.biz.trafficlight.currentRoadTrafficLight @@ -232,7 +233,7 @@ class TrafficLightDispatcher : IMoGoAutopilotIdentifyListener, IMoGoTrafficLight if((light.state == FusionTrafficLightOuterClass.FusionLightState.STATE_YELLOW_FUSION || light.state ==FusionTrafficLightOuterClass.FusionLightState.STATE_RED_FUSION) && light.duration < 5 && light.nextState == FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION){ //语音播放:红灯即将变绿 - AIAssist.getInstance(mContext).speakTTSVoice("红灯即将变绿") + AIAssist.getInstance(mContext).speakTTSVoiceWithLevel("红灯即将变绿", NEW_LEVEL_2) isTurnGreen = true } } diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/RoadV2NEventWindowView.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/RoadV2NEventWindowView.kt index 207f5bb072..7451c5eb3c 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/RoadV2NEventWindowView.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/v2n/RoadV2NEventWindowView.kt @@ -484,7 +484,7 @@ class RoadV2NEventWindowView @JvmOverloads constructor( "更新时间:${DateTimeUtils.getTimeText(dataBean.timestamp, DateTimeUtils.HH_mm_ss)}" if (dataBean.isNeedTTS && !TextUtils.isEmpty(dataBean.ttsStr)) { AIAssist.getInstance(context) - .speakTTSVoiceWithLevel(dataBean.ttsStr, AIAssist.LEVEL0) + .speakTTSVoiceWithLevel(dataBean.ttsStr, AIAssist.NEW_LEVEL_2) } when (dataBean.eventType) { RoadV2NEventType.TEXT -> { From 70cb6b528e7e69a085dd888ec5a4874e1ff8ee84 Mon Sep 17 00:00:00 2001 From: xyz Date: Fri, 20 Dec 2024 10:14:28 +0800 Subject: [PATCH 07/15] =?UTF-8?q?[6.8.2]=201=E3=80=81=E6=89=BE=E5=9B=9E?= =?UTF-8?q?=E8=9E=8D=E5=90=88=E7=BA=A2=E7=BB=BF=E7=81=AF=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/m2/layout/shuttle_p_m2_fragment.xml | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml b/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml index a5d1564386..0e9431c390 100644 --- a/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml +++ b/OCH/shuttle/passenger_weaknet/src/main/res/m2/layout/shuttle_p_m2_fragment.xml @@ -157,28 +157,28 @@ - - - - - - - - - - + + - - - - - - - - - - - + + Date: Thu, 19 Dec 2024 10:08:20 +0800 Subject: [PATCH 08/15] =?UTF-8?q?[6.8.4]=20=E5=8D=87=E7=BA=A7AICloudSDK?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8DDNS=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gradle.properties b/gradle.properties index 9f3a269301..2e957ff0d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -64,21 +64,21 @@ bytex.ASM_API=ASM7 LOGLIB_VERSION=1.10.18 ######## MogoAiCloudSDK Version ######## # 网络请求LOGLIB_VERSION -MOGO_NETWORK_VERSION=1.4.7.58 +MOGO_NETWORK_VERSION=1.4.7.59 # 鉴权 -MOGO_PASSPORT_VERSION=1.4.7.58 +MOGO_PASSPORT_VERSION=1.4.7.59 # 长链接 -MOGO_SOCKET_VERSION=1.4.7.58 +MOGO_SOCKET_VERSION=1.4.7.59 # 数据采集 -MOGO_REALTIME_VERSION=1.4.7.58 +MOGO_REALTIME_VERSION=1.4.7.59 # 直播推流 -MOGO_LIVE_VERSION=1.4.7.58 +MOGO_LIVE_VERSION=1.4.7.59 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.4.7.58 +MOGO_TRAFFICLIVE_VERSION=1.4.7.59 # 定位服务 -MOGO_LOCATION_VERSION=1.4.7.58 +MOGO_LOCATION_VERSION=1.4.7.59 # 远程通讯模块 -MOGO_TELEMATIC_VERSION=1.4.7.58 +MOGO_TELEMATIC_VERSION=1.4.7.59 # 动态换肤SDK MOGO_SKIN_VERSION=1.4.7.49.19 ######## MogoAiCloudSDK Version ######## From 16e4b66db431dcc4035ff02cf381fe444df666aa Mon Sep 17 00:00:00 2001 From: xuxinchao Date: Fri, 20 Dec 2024 17:28:02 +0800 Subject: [PATCH 09/15] =?UTF-8?q?[main]=E8=BF=90=E8=90=A5=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=BC=80=E6=94=BE=E5=A4=96=E5=B1=8F=E6=AC=A2=E8=BF=8E?= =?UTF-8?q?=E8=AF=AD=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/res/xml/operate_panel_preference_headers.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_headers.xml b/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_headers.xml index 9d3a450447..dc020a7d7a 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_headers.xml +++ b/core/function-impl/mogo-core-function-hmi/src/main/res/xml/operate_panel_preference_headers.xml @@ -31,10 +31,10 @@ android:key="mofang" android:layout="@layout/layout_operate_panel_preference_header" android:title="蘑方" /> - - - - - + \ No newline at end of file From f2c11bac3c65dc112f8f6c5f28238dfdd7364ccf Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Fri, 20 Dec 2024 20:12:43 +0800 Subject: [PATCH 10/15] =?UTF-8?q?[684][led]=E6=B7=BB=E5=8A=A0=E6=98=8E?= =?UTF-8?q?=E9=91=AB=E4=BA=AELED=E5=A4=96=E9=9D=A2=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eagle/core/function/DataCenterProvider.kt | 6 +- .../autopilot/MoGoAutopilotControlProvider.kt | 9 +- .../autopilot/adapter/MoGoAdasListenerImpl.kt | 102 ++++++- .../hmi/ui/operate/OperatePanelLayout.kt | 7 +- libraries/mogo-hardware-devices/build.gradle | 7 +- .../support/device/led/BackLedUIViewModel.kt | 161 +++++++++++ .../support/device/led/BaseLedUIViewModel.kt | 256 ++++++++++++++++++ .../support/device/led/FrontLedUIViewModel.kt | 93 +++++++ .../support/device/led/LedSourceManager.kt | 212 +++++++++++++++ .../java/com/mogo/support/device/led/LedUI.kt | 96 +++++++ 10 files changed, 942 insertions(+), 7 deletions(-) create mode 100644 libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BackLedUIViewModel.kt create mode 100644 libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt create mode 100644 libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/FrontLedUIViewModel.kt create mode 100644 libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt create mode 100644 libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedUI.kt diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/DataCenterProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/DataCenterProvider.kt index 70c4c444e4..eb59fa9351 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/DataCenterProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/DataCenterProvider.kt @@ -12,6 +12,7 @@ import com.mogo.eagle.core.function.datacenter.location.MoGoLocationDispatcher import com.mogo.eagle.core.function.datacenter.v2x.SpeedLimitDispatcher import com.mogo.eagle.core.function.datacenter.v2x.TrafficLightDispatcher import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils +import com.mogo.support.device.led.LedSourceManager @Route(path = MogoServicePaths.PATH_DATA_CENTER_MODULE) class DataCenterProvider : IDataCenterProvider { @@ -25,14 +26,15 @@ class DataCenterProvider : IDataCenterProvider { MoGoLocationDispatcher.initListener() mContext = context mContext?.let { + val isPassenger = AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) + LedSourceManager.init(!isPassenger) CallerDataCenterBizManager.init() CallerMsgBoxManager.queryAllMessages(it) TrafficLightDispatcher.INSTANCE.initServer(it) SpeedLimitDispatcher.INSTANCE.initLimit(it) - if (AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode)) { + if (isPassenger) { IotManager.init() } - } } diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt index 8f626a0b93..f0a5c625e4 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoAutopilotControlProvider.kt @@ -31,7 +31,6 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListene import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotControlProvider import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.FUNC_MODE_RAIN import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider -import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager import com.mogo.eagle.core.function.call.autopilot.CallerIpcConnectStateToastManager import com.mogo.eagle.core.function.call.cloud.CallerCloudCertManager @@ -55,6 +54,7 @@ import com.mogo.eagle.core.utilcode.util.ParseVersionUtils import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.eagle.core.utilcode.util.ToastUtils import com.mogo.eagle.core.utilcode.util.UiThreadHandler +import com.mogo.support.device.led.LedSourceManager import com.mogo.telematic.MogoProtocolMsg import com.mogo.telematic.MogoProtocolMsg.NORMAL_DATA import com.mogo.telematic.MogoProtocolMsg.SYNC_FUSION_COLOR_STATUS @@ -1025,6 +1025,13 @@ class MoGoAutopilotControlProvider : */ override fun sendTripInfo(type: Int, lineName: String, departureStopName: String,arrivalStopName: String, isLastStop: Boolean) { AdasManager.getInstance().sendTripInfoReq(type, lineName, departureStopName,arrivalStopName, isLastStop) + LedSourceManager.updateTripInfoData( + type, + lineName, + departureStopName, + arrivalStopName, + isLastStop + ) } /** diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt index 426052a342..ce4d52e000 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/adapter/MoGoAdasListenerImpl.kt @@ -91,16 +91,17 @@ import com.mogo.eagle.core.function.call.obu.CallerObuWarningSpatListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_D_C import com.mogo.eagle.core.utilcode.util.DeviceUtils +import com.mogo.support.device.led.LedSourceManager 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.chain.AdasChain -import com.zhjt.mogo.adas.data.bean.AdasParam import com.zhidao.support.adas.high.common.ProtocolStatus import com.zhjt.mogo.adas.common.MessageType import com.zhjt.mogo.adas.data.AdasConstants import com.zhjt.mogo.adas.data.AdasConstants.NodeExistState import com.zhjt.mogo.adas.data.AiCloudTask +import com.zhjt.mogo.adas.data.bean.AdasParam import com.zhjt.mogo.adas.data.bean.AutopilotStatistics import com.zhjt.mogo.adas.data.bean.LaunchConditionData import com.zhjt.mogo.adas.data.bean.NodeStateInfo @@ -133,6 +134,7 @@ import prediction.Prediction import record_cache.RecordPanelOuterClass import system_master.SsmInfo import system_master.SystemStatusInfo +import kotlin.math.roundToInt /** * 适配ADAS 回调监听分发,这里不做业务,只做数据包装及分发处理 @@ -176,6 +178,7 @@ class MoGoAdasListenerImpl : OnAdasListener { ) override fun onGnssInfo(header: MessagePad.Header, gnssInfo: MessagePad.GnssInfo) { CallerChassisGnssListenerManager.invokeChassisGnssListener(gnssInfo) + LedSourceManager.updateAccelerationData(gnssInfo.acceleration) if (gnssInfo != null) { // 同步更新经纬度和系统时间至 AutoPilotStatusListener CallerAutoPilotStatusListenerManager.updateAutoPilotLocAndTime( @@ -278,6 +281,15 @@ class MoGoAdasListenerImpl : OnAdasListener { override fun onLightSwitch(light: Chassis.LightSwitch) { //转向灯数据 CallerChassisStatesListenerManager.invokeAutopilotLightSwitchData(light) + var type = 0 + if (Chassis.LightSwitch.LIGHT_LEFT == light) { + type = 1 + } else if (Chassis.LightSwitch.LIGHT_RIGHT == light) { + type = 2 + } else if (Chassis.LightSwitch.LIGHT_FLASH == light) { + type = 3 + } + LedSourceManager.updateTurnSignalData(type) } //自动驾驶状态 @@ -320,6 +332,8 @@ class MoGoAdasListenerImpl : OnAdasListener { header: MessagePad.Header?, trafficLights: FusionTrafficLightOuterClass.FusionTrafficLights? ) { + //此分发新开线程,在invokeAutopilotPerceptionTrafficLight 前分发避免 invokeAutopilotPerceptionTrafficLight中存在耗时操作影响LED数据更新 + transitionTurnToLedData(trafficLights) if (trafficLights != null) { CallerAutopilotIdentifyListenerManager.invokeAutopilotPerceptionTrafficLight( trafficLights @@ -327,6 +341,92 @@ class MoGoAdasListenerImpl : OnAdasListener { } } + /** + * LED屏幕数据转换 + * 只能放在这 LedSourceManager LIB中并未依赖ADAS数据源 + */ + private fun transitionTurnToLedData(trafficLights: FusionTrafficLightOuterClass.FusionTrafficLights?) { + var stateTurnRound = -1 + var durationTurnRound = -1 + var stateTurnLeft = -1 + var durationTurnLeft = -1 + var stateStraight = -1 + var durationStraight = -1 + var stateTurnRight = -1 + var durationTurnRight = -1 + if (trafficLights != null) { + if (trafficLights.uTurn != null) { + val uTurn = trafficLights.uTurn + stateTurnRound = transitionTurnType(uTurn.state) + if (uTurn.duration > 0) { + durationTurnRound = uTurn.duration.roundToInt() + } + } + if (trafficLights.left != null) { + val left = trafficLights.left + stateTurnLeft = transitionTurnType(left.state) + if (left.duration > 0) { + durationTurnLeft = left.duration.roundToInt() + } + } + if (trafficLights.straight != null) { + val straight = trafficLights.straight + stateStraight = transitionTurnType(straight.state) + if (straight.duration > 0) { + durationStraight = straight.duration.roundToInt() + } + } + if (trafficLights.right != null) { + val right = trafficLights.right + stateTurnRight = transitionTurnType(right.state) + if (right.duration > 0) { + durationTurnRight = right.duration.roundToInt() + } + } + //来源是自车没有倒计时 不管域控发的倒计时是什么值 + if (trafficLights.source == 0) { + durationTurnRound = -1 + durationTurnLeft = -1 + durationStraight = -1 + durationTurnRight = -1 + } + } + LedSourceManager.updateTrafficLightData( + stateTurnRound, + durationTurnRound, + stateTurnLeft, + durationTurnLeft, + stateStraight, + durationStraight, + stateTurnRight, + durationTurnRight + ) + } + + private fun transitionTurnType(state: FusionTrafficLightOuterClass.FusionLightState?): Int { + var type = -1 + state?.let { + type = when (it) { + FusionTrafficLightOuterClass.FusionLightState.STATE_RED_FUSION -> { + 2 + } + + FusionTrafficLightOuterClass.FusionLightState.STATE_YELLOW_FUSION -> { + 3 + } + + FusionTrafficLightOuterClass.FusionLightState.STATE_GREEN_FUSION -> { + 4 + } + + else -> { + -1 + } + } + } + return type + } + //他车轨迹预测 override fun onPredictionObstacleTrajectory( header: MessagePad.Header?, diff --git a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt index 9824d618a4..7538a4e18c 100644 --- a/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt +++ b/core/function-impl/mogo-core-function-hmi/src/main/java/com/mogo/eagle/core/function/hmi/ui/operate/OperatePanelLayout.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.os.SystemClock import android.util.AttributeSet import android.util.Log -import android.view.Gravity import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -57,7 +56,6 @@ import com.mogo.eagle.core.function.hmi.ui.operate.preferences.PreferenceWithWel import com.mogo.eagle.core.function.hmi.ui.tools.SweeperModeChangedConfirmDialog 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.floating.MoGoPopWindow import com.mogo.eagle.core.utilcode.kotlin.onClick import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger @@ -67,6 +65,7 @@ import com.mogo.eagle.core.utilcode.rv.divider.CommonDividerItemDecoration import com.mogo.eagle.core.utilcode.util.AppStateManager import com.mogo.eagle.core.utilcode.util.GsonUtils.* import com.mogo.eagle.core.utilcode.util.ToastUtils +import com.mogo.support.device.led.LedSourceManager import com.zhjt.mogo.adas.data.AdasConstants import com.zhjt.mogo.adas.data.bean.AdasParam import kotlinx.android.synthetic.main.layout_operate_panel.view.iv_operate_panel_close @@ -1521,6 +1520,10 @@ class OperatePanelLayout : LinearLayout { FunctionBuildConfig.welcomeWords = preference.extras.getString(PreferenceWithWelcomeWords.KEY_BUNDLE_CURRENT_EDIT_TEXT_VALUE) hmiAction("外屏欢迎语", FunctionBuildConfig.welcomeWords ?: "") clickEventAnalytics("外屏欢迎语", true) + LedSourceManager.foreverChangeWelcomeHint( + context?.applicationContext, + FunctionBuildConfig.welcomeWords + ) } return super.onPreferenceClick(preference) } diff --git a/libraries/mogo-hardware-devices/build.gradle b/libraries/mogo-hardware-devices/build.gradle index c8f23195be..163c607572 100644 --- a/libraries/mogo-hardware-devices/build.gradle +++ b/libraries/mogo-hardware-devices/build.gradle @@ -1,6 +1,7 @@ plugins { id 'com.android.library' id 'kotlin-android' + id 'org.jetbrains.kotlin.android' } android { @@ -30,10 +31,14 @@ android { lintOptions { abortOnError false } - + kotlinOptions { + jvmTarget = "1.8" + } } dependencies { implementation rootProject.ext.dependencies.androidxappcompat api rootProject.ext.dependencies.serialport + implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.5" + implementation rootProject.ext.dependencies.view_model_scope } diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BackLedUIViewModel.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BackLedUIViewModel.kt new file mode 100644 index 0000000000..c71f742f72 --- /dev/null +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BackLedUIViewModel.kt @@ -0,0 +1,161 @@ +package com.mogo.support.device.led + +import android.util.Log +import com.mogo.support.device.manager.cpower5a.LedScreenCpower5aManager +import com.mogo.support.device.manager.cpower5a.common.LedScreen +import com.mogo.support.device.manager.cpower5a.common.Program + +/** + * 后屏 + */ +open class BackLedUIViewModel : BaseLedUIViewModel() { + companion object { + const val TAG = "BackLedUIViewModel" + + val supportUIList = mutableSetOf().also { + it += WelcomeUI::class.simpleName + it += FinishUI::class.simpleName + it += RouteInfoUI::class.simpleName + it += StationReportUI::class.simpleName + it += ArriveStationUI::class.simpleName + it += LeaveStationUI::class.simpleName + it += EmergencyBrakeUI::class.simpleName + it += TrafficLightUI::class.simpleName + it += TurnSignalUI::class.simpleName + it += RoadWorkAheadWarningUI::class.simpleName + } + } + + override suspend fun receive(msg: LedUI) { + if (supportUIList.contains(msg.javaClass.simpleName)) { + Log.i( + FrontLedUIViewModel.TAG, + "receive --> ${msg.javaClass.simpleName}[priority=${msg.priority}] " + ) + super.receive(msg) + } else { + Log.i( + FrontLedUIViewModel.TAG, + "receive --> 不支持的类型,放弃 ${msg.javaClass.simpleName}[priority=${msg.priority}] " + ) + } + } + + override fun handleLedUIShow(ledUI: LedUI) { + super.handleLedUIShow(ledUI) + when (ledUI) { + is WelcomeUI -> { + LedScreenCpower5aManager.getInstance().playProgramWelcome( + null, + LedScreen.OUTWARD_BACK, + ledUI.hintMsg, + ledUI.isForever + ) + Log.e(TAG, "后屏 播放欢迎语:${ledUI.hintMsg} 是否永久展示:${ledUI.isForever}") + } + + is FinishUI -> { + LedScreenCpower5aManager.getInstance().playProgramFinish( + LedScreen.OUTWARD_BACK, + ledUI.hintMsg, + ) + Log.e(TAG, "后屏 播放结束语:${ledUI.hintMsg}") + } + + is RouteInfoUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineInformation(LedScreen.OUTWARD_BACK, ledUI.lineName) + Log.e(TAG, "后屏 播放线路信息:${ledUI.lineName}") + } + + is StationReportUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineStationReport( + LedScreen.OUTWARD_BACK, + ledUI.stationName, + ledUI.state + ) + Log.e(TAG, "后屏 播放报站 站点:${ledUI.stationName} 状态:${ledUI.state}") + } + + is ArriveStationUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineStationReportHint( + LedScreen.OUTWARD_BACK, + "车辆进站" + ) + Log.e(TAG, "后屏 播放车辆进站") + } + + is LeaveStationUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineStationReportHint( + LedScreen.OUTWARD_BACK, + "车辆起步" + ) + Log.e(TAG, "后屏 播放车辆起步") + } + + is EmergencyBrakeUI -> { + LedScreenCpower5aManager.getInstance() + .playProgram(LedScreen.OUTWARD_BACK, Program.REMIND_FRONT_CAR_EMERGENCY_BRAKE) + Log.e(TAG, "后屏 车辆急刹") + } + + is RoadWorkAheadWarningUI -> { + LedScreenCpower5aManager.getInstance() + .playProgram(LedScreen.OUTWARD_BACK, Program.REMIND_ROAD_WORK_AHEAD) + Log.e(TAG, "后屏 道路施工") + } + + is TurnSignalUI -> { + var program: Program? = null + program = when (ledUI.type) { + 1 -> { + Program.REMIND_TURN_LEFT + } + + 2 -> { + Program.REMIND_TURN_RIGHT + } + + 3 -> { + Program.REMIND_VEHICLE_ANOMALY + } + + else -> { + null + } + } + program?.let { + LedScreenCpower5aManager.getInstance() + .playProgram( + LedScreen.OUTWARD_BACK, + it + ) + } + Log.e(TAG, "后屏 播放节目${program}") + } + + is TrafficLightUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramTrafficLights( + LedScreen.OUTWARD_BACK, + ledUI.stateTurnRound, ledUI.durationTurnRound, + ledUI.stateTurnLeft, ledUI.durationTurnLeft, + ledUI.stateStraight, ledUI.durationStraight, + ledUI.stateTurnRight, ledUI.durationTurnRight + ) + Log.e( + TAG, + "后屏 播放信号灯节目 掉头:${ledUI.stateTurnRound} 掉头倒计时:${ledUI.durationTurnRound}\n" + + "左转:${ledUI.stateTurnLeft} 左转倒计时:${ledUI.durationTurnLeft}\n" + + "直行:${ledUI.stateStraight} 直行倒计时:${ledUI.stateStraight}\n" + + "右转:${ledUI.stateTurnRight} 右转倒计时:${ledUI.durationTurnRight}\n" + ) + } + } + + } + +} \ No newline at end of file diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt new file mode 100644 index 0000000000..4670e57a84 --- /dev/null +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt @@ -0,0 +1,256 @@ +package com.mogo.support.device.led + +import android.util.Log +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.ViewModel +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.Job +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import java.util.PriorityQueue +import kotlin.math.ceil + +open class BaseLedUIViewModel : ViewModel() { + companion object { + const val TAG = "LedUIViewModel" + val DEFAULT_UI = WelcomeUI() + } + + private var baseUICountDownJob: Job? = null + private var currentLedUI: LedUI + private var currentCountDownJob: Job? = null + private val restoreLedUIQueue = PriorityQueue() + + private val currentLedUILiveData = MutableLiveData() + + private var currentRouteInfoUI: RouteInfoUI? = null//当前线路信息UI + private var currentStationReportUI: StationReportUI? = null//当前报站信息 + + + init { + currentLedUI = DEFAULT_UI + } + + fun start() { + viewModelScope.launch { + restoreLastUI() + } + } + + /** + * 更新线路信息 + */ + fun updateCurrentRouteInfo(lineName: String) { + Log.i(TAG, "线路信息更新 线路名称:$lineName") + currentRouteInfoUI = RouteInfoUI(lineName) + } + + /** + * 更新报站信息 + */ + fun updateCurrentStationReport(stationName: String, state: String) { + Log.i(TAG, "报站信息更新 ${state}:$stationName 站点状态") + currentStationReportUI = StationReportUI(stationName, state) + } + + open suspend fun receive(msg: LedUI) { + Log.e( + TAG, + "receive --> ${msg.javaClass.simpleName}[priority=${msg.priority}] current:${currentLedUI.javaClass.simpleName}[priority=${currentLedUI.priority}]" + ) + if (msg.priority > currentLedUI.priority) { + //优先级低但是需要打断恢复,放入队列,否则直接舍弃 + if (msg.interruptRestore) { + Log.i( + TAG, + "receive --> 优先级低,放入等待队列 ${msg.javaClass.simpleName}[priority=${msg.priority}]" + ) + if (msg is LedUICountDown) { + val countdown = if (msg.countDownSeconds < 0) 0 else msg.countDownSeconds + + // 如果是打断恢复的,不重新设置值 + if (msg.absCountDownTimestamp == 0L) { + msg.absCountDownTimestamp = + System.currentTimeMillis() + countdown * 1000L + } + } + restoreLedUIQueue.offer(msg) + } else { + Log.i( + TAG, + "receive --> 优先级低,舍弃 ${msg.javaClass.simpleName}[priority=${msg.priority}]" + ) + } + } else { + // 打断当前 UI + Log.i( + TAG, + "receive --> 优先级高或相等,打断当前 ${msg.javaClass.simpleName}[priority=${msg.priority}]" + ) + if (msg is LedUIDataChange) { + if (msg.isShow) { + showUI(msg) + } else { + // 删除恢复队列中数据 + removeRestoreLedUI(msg) + // 当前正在展示,取消展示 + if (currentLedUI.javaClass.simpleName == msg.javaClass.simpleName) { + dismissUI(msg) + } + } + } else { + showUI(msg) + } + } + + } + + suspend fun reset() { + Log.i(TAG, "reset()") + viewModelScope.launch { + currentLedUI = DEFAULT_UI + restoreLedUIQueue.clear() + currentCountDownJob?.cancel() + baseUICountDownJob?.cancel() + cancelBasicUISwitch() + currentRouteInfoUI = null + currentStationReportUI = null + } + } + + private suspend fun showUI(msg: LedUI) { + Log.i(TAG, "showUI ledUI=${msg.javaClass.simpleName}[priority=${msg.priority}]") + // 如果当前类型是 需要打断恢复的,放入等待队列 + if (currentLedUI.interruptRestore) { + restoreLedUIQueue.offer(msg) + } + + currentCountDownJob?.also { + it.cancel() + } + cancelBasicUISwitch() + + handleLedUIShow(msg) + currentLedUI = msg + + // 倒计时类型的 处理倒计时逻辑 + if (msg is LedUICountDown) { + val countdown = if (msg.countDownSeconds < 0) 0 else msg.countDownSeconds + Log.d(TAG, "LedUICountDown delay=${msg.countDownSeconds}秒") + + // 如果是打断恢复的,不重新设置值 + if (msg.absCountDownTimestamp == 0L) { + msg.absCountDownTimestamp = + System.currentTimeMillis() + countdown * 1000L + } + + viewModelScope.launch { + val delaySeconds = + if (msg.absCountDownTimestamp > 0) { + ceil((msg.absCountDownTimestamp - System.currentTimeMillis()) / 1000.0).toInt() + } else + countdown + Log.d(TAG, "设置currentCountDownJob delay=${delaySeconds}秒") + delay(delaySeconds * 1000L) + restoreLastUI() + }.also { currentCountDownJob = it } + } + } + + private suspend fun dismissUI(msg: LedUI) { + Log.i(TAG, "dismissUI ledUI=${msg.javaClass.simpleName}[priority=${msg.priority}]") + currentCountDownJob?.also { + it.cancel() + } + removeRestoreLedUI(msg) + restoreLastUI() + } + + private suspend fun restoreLastUI() { + //恢复打断 + val restoreUI = pollRestoreLedUI() + if (restoreUI != null) { + showUI(restoreUI) + } else { + // 启动 车辆基础状态 切换 + startBasicUISwitchLoop() + } + } + + private suspend fun startBasicUISwitchLoop() { + if (currentRouteInfoUI != null) { + showUI(currentRouteInfoUI!!) + } else if (currentStationReportUI != null) { + showUI(currentStationReportUI!!) + } else { + showUI(WelcomeUI()) + } + basicUISwitchInternal() + } + + private fun cancelBasicUISwitch() { + Log.i(TAG, "cancelBaseUISwitch()") + kotlin.runCatching { baseUICountDownJob?.cancel() } + } + + private suspend fun basicUISwitchInternal() { + Log.i(TAG, "baseUISwitchInternal()") + cancelBasicUISwitch() + viewModelScope.launch { + delay(10 * 1000L) + if (currentLedUI.javaClass.simpleName == WelcomeUI::class.simpleName) { + if (currentRouteInfoUI != null) { + showUI(currentRouteInfoUI!!) + } else { + showUI(WelcomeUI()) + } + } else if (currentLedUI.javaClass.simpleName == RouteInfoUI::class.simpleName) { + if (currentStationReportUI != null) { + showUI(currentStationReportUI!!) + } else { + showUI(WelcomeUI()) + } + } else if (currentLedUI.javaClass.simpleName == StationReportUI::class.simpleName) { + showUI(WelcomeUI()) + } + basicUISwitchInternal() + }.also { baseUICountDownJob = it } + } + + /** + * 控制屏幕 UI 展示 + */ + protected open fun handleLedUIShow(ledUI: LedUI) { + currentLedUILiveData.postValue(ledUI) + } + + /** + * 过滤队列中时间戳小于指定时间的消息,取出优先级最高的消息 + */ + private fun pollRestoreLedUI(): LedUI? { + while (restoreLedUIQueue.isNotEmpty()) { + val message = restoreLedUIQueue.poll() + if (message is LedUICountDown) { + if (message.countDownSeconds > 0 && message.absCountDownTimestamp > System.currentTimeMillis()) { + return message + } + } else { + return message + } + } + return null + } + + /** + * 从等待队列中删除目标类型数据 + */ + private fun removeRestoreLedUI(msg: LedUI) { + val toRemove = restoreLedUIQueue.filter { + it.javaClass == msg.javaClass || + (it is LedUICountDown && it.countDownSeconds > 0 + && it.absCountDownTimestamp <= System.currentTimeMillis()) + } + restoreLedUIQueue.removeAll(toRemove.toSet()) + } + +} \ No newline at end of file diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/FrontLedUIViewModel.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/FrontLedUIViewModel.kt new file mode 100644 index 0000000000..3130d6292c --- /dev/null +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/FrontLedUIViewModel.kt @@ -0,0 +1,93 @@ +package com.mogo.support.device.led + +import android.util.Log +import com.mogo.support.device.manager.cpower5a.LedScreenCpower5aManager +import com.mogo.support.device.manager.cpower5a.common.LedScreen + +/** + * 前屏幕 + */ +class FrontLedUIViewModel : BaseLedUIViewModel() { + companion object { + const val TAG = "FrontLedUIViewModel" + + val supportUIList = mutableSetOf().also { + it += WelcomeUI::class.simpleName + it += FinishUI::class.simpleName + it += RouteInfoUI::class.simpleName + it += StationReportUI::class.simpleName + it += ArriveStationUI::class.simpleName + it += LeaveStationUI::class.simpleName + } + } + + override suspend fun receive(msg: LedUI) { + if (supportUIList.contains(msg.javaClass.simpleName)) { + Log.i(TAG, "receive --> ${msg.javaClass.simpleName}[priority=${msg.priority}] ") + super.receive(msg) + } else { + Log.i( + TAG, + "receive --> 不支持的类型,放弃 ${msg.javaClass.simpleName}[priority=${msg.priority}] " + ) + } + } + + override fun handleLedUIShow(ledUI: LedUI) { + super.handleLedUIShow(ledUI) + when (ledUI) { + is WelcomeUI -> { + LedScreenCpower5aManager.getInstance().playProgramWelcome( + null, + LedScreen.OUTWARD_FRONT, + ledUI.hintMsg, + ledUI.isForever + ) + Log.e(TAG, "前屏 播放欢迎语:${ledUI.hintMsg} 是否永久展示:${ledUI.isForever}") + } + + is FinishUI -> { + LedScreenCpower5aManager.getInstance().playProgramFinish( + LedScreen.OUTWARD_FRONT, + ledUI.hintMsg, + ) + Log.e(TAG, "前屏 播放结束语:${ledUI.hintMsg}") + } + + is RouteInfoUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineInformation(LedScreen.OUTWARD_FRONT, ledUI.lineName) + Log.e(TAG, "前屏 播放线路信息:${ledUI.lineName}") + } + + is StationReportUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineStationReport( + LedScreen.OUTWARD_FRONT, + ledUI.stationName, + ledUI.state + ) + Log.e(TAG, "前屏 播放报站 站点:${ledUI.stationName} 状态:${ledUI.state}") + } + + is ArriveStationUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineStationReportHint( + LedScreen.OUTWARD_FRONT, + "车辆进站" + ) + Log.e(TAG, "前屏 播放车辆进站") + } + + is LeaveStationUI -> { + LedScreenCpower5aManager.getInstance() + .playProgramLineStationReportHint( + LedScreen.OUTWARD_FRONT, + "车辆起步" + ) + Log.e(TAG, "前屏 播放车辆起步") + } + } + } + +} \ No newline at end of file diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt new file mode 100644 index 0000000000..8030607c25 --- /dev/null +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt @@ -0,0 +1,212 @@ +package com.mogo.support.device.led + + +import android.content.Context +import com.mogo.support.device.manager.cpower5a.LedScreenCpower5aManager +import com.mogo.support.device.manager.cpower5a.common.LedScreen +import com.mogo.support.device.manager.cpower5a.common.TrafficLightState +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import kotlin.properties.Delegates + +object LedSourceManager { + private val frontViewModel: FrontLedUIViewModel by lazy { + FrontLedUIViewModel() // 初始化 + } + private val backViewModel: BackLedUIViewModel by lazy { + BackLedUIViewModel() // 初始化 + } + private var typeTurnSignal = 0;//转向灯状态 0:无灯;1:左转;2:右转;3:双闪 + private var lastUpdateEmergencyBrakeTime = 0L//上次触发急刹展示的时间 + private var isDriver by Delegates.notNull() + + fun init(isDriver: Boolean) { + this.isDriver = isDriver + } + + + private fun receiveUI(ledUI: LedUI) { + GlobalScope.launch(Dispatchers.IO) { + frontViewModel.receive(ledUI) + backViewModel.receive(ledUI) + } + } + + //更新线路信息 + private fun updateLineNameUI(lineName: String) { + GlobalScope.launch(Dispatchers.IO) { + frontViewModel.updateCurrentRouteInfo(lineName) + backViewModel.updateCurrentRouteInfo(lineName) + } + } + + //更新报站信息 + private fun updateStationReportUI(stationName: String, state: String) { + GlobalScope.launch(Dispatchers.IO) { + frontViewModel.updateCurrentStationReport(stationName, state) + backViewModel.updateCurrentStationReport(stationName, state) + } + + } + + + /** + * 更新转向灯 + * type: 0:无灯;1:左转;2:右转;3:双闪 + */ + fun updateTurnSignalData(type: Int) { + if (isDriver) { + if (typeTurnSignal != type) { + typeTurnSignal = type + receiveUI(TurnSignalUI(type != 0, type)) + } + } + + } + + /** + * 车辆急刹 + */ + fun updateAccelerationData(acceleration: Double) { + if (isDriver) { + if (acceleration <= -2) { + val now = System.currentTimeMillis() + if (now - lastUpdateEmergencyBrakeTime > 60 * 1000L) {//1m内不进行多次提示 + lastUpdateEmergencyBrakeTime = now + receiveUI(EmergencyBrakeUI()) + } + } + } + } + + /** + * 更新红绿灯数据 + * state -1:表示 null; 0:表示 CLEAR; 1:表示 NONE; 2:表示 RED; 3:表示 YELLOW; 4:表示 GREEN; + */ + fun updateTrafficLightData( + stateTurnRound: Int, durationTurnRound: Int, + stateTurnLeft: Int, durationTurnLeft: Int, + stateStraight: Int, durationStraight: Int, + stateTurnRight: Int, durationTurnRight: Int + ) { + if (isDriver) { + var stateTurnRoundTemp: TrafficLightState? = null + var stateTurnLeftTemp: TrafficLightState? = null + var stateStraightTemp: TrafficLightState? = null + var stateTurnRightTemp: TrafficLightState? = null + + var durationTurnRoundTemp = durationTurnRound + var durationTurnLeftTemp = durationTurnLeft + var durationStraightTemp = durationStraight + var durationTurnRightTemp = durationTurnRight + + var isShow = true + if (stateTurnRound == -1 && stateTurnLeft == -1 && stateStraight == -1 && stateTurnRight == -1) { + isShow = false + durationTurnRoundTemp = -1 + durationTurnLeftTemp = -1 + durationStraightTemp = -1 + durationTurnRightTemp = -1 + } else { + stateTurnRoundTemp = transitionTurnType(stateTurnRound) + stateTurnLeftTemp = transitionTurnType(stateTurnLeft) + stateStraightTemp = transitionTurnType(stateStraight) + stateTurnRightTemp = transitionTurnType(stateTurnRight) + } + + receiveUI( + TrafficLightUI( + isShow, + stateTurnRoundTemp, durationTurnRoundTemp, + stateTurnLeftTemp, durationTurnLeftTemp, + stateStraightTemp, durationStraightTemp, + stateTurnRightTemp, durationTurnRightTemp + ) + ) + } + } + + private fun transitionTurnType(type: Int): TrafficLightState { + return when (type) { + 2 -> { + TrafficLightState.RED + } + + 3 -> { + TrafficLightState.YELLOW + } + + 4 -> { + TrafficLightState.GREEN + } + + else -> { + TrafficLightState.NONE + } + } + } + + /** + * 发生行程相关 + * type=1或2的时 需要参数 lineName + * type=3或4的时 需要参数 lineName departureStopName arrivalStopName isLastStop + * type=5时 不需要任何参数 + * + * @param type 事件类型, 1:行程开始, 2:行程结束, 3:出站, 4:进站, 5:城市占道施工预警 + * @param lineName 路线名 + * @param departureStopName 出站站点名 + * @param arrivalStopName 下一站到达站点名 + * @param isLastStop 是否最终站 + */ + fun updateTripInfoData( + type: Int, + lineName: String, + departureStopName: String, + arrivalStopName: String, + isLastStop: Boolean + ) { + if (isDriver) { + if (lineName.isNotEmpty()) { + updateLineNameUI(lineName) + } + if (type == 1) { + //开始 + updateLineNameUI(lineName); + } else if (type == 2) { + //结束 + receiveUI(FinishUI()) + } else if (type == 3) { + //出站 + if (arrivalStopName.isNotEmpty()) { + updateStationReportUI(arrivalStopName, "下一站") + } + } else if (type == 4) { + //进站 + if (departureStopName.isNotEmpty()) { + updateStationReportUI( + departureStopName, if (isLastStop) { + "终点站" + } else { + "下一站" + } + ) + } + } else if (type == 5) { + //道路施工 + receiveUI(RoadWorkAheadWarningUI()) + } + } + } + + /** + * 永久更改欢迎节目显示内容 + * context如果是null会设置失败 + */ + fun foreverChangeWelcomeHint(context: Context?, hintMsg: String?) { + LedScreenCpower5aManager.getInstance() + .playProgramWelcome(context, LedScreen.OUTWARD_FRONT, hintMsg, true) + LedScreenCpower5aManager.getInstance() + .playProgramWelcome(context, LedScreen.OUTWARD_BACK, hintMsg, true) + } +} \ No newline at end of file diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedUI.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedUI.kt new file mode 100644 index 0000000000..7eb0260137 --- /dev/null +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedUI.kt @@ -0,0 +1,96 @@ +package com.mogo.support.device.led + +import com.mogo.support.device.manager.cpower5a.common.TrafficLightState + +open class LedUI( + var priority: Int = 0, + var interruptRestore: Boolean = false, +) : Comparable { + override fun compareTo(other: LedUI): Int = other.priority - this.priority + override fun toString(): String { + return "LedUI(priority=$priority, interruptRestore=$interruptRestore)" + } +} + +open class LedUIBaseSwitch( + priority: Int = 0, + interruptRestore: Boolean = false, +) : LedUI(priority, interruptRestore) { + override fun toString(): String { + return "LedUIBaseSwitch() ${super.toString()}" + } +} + +open class LedUIDataChange( + var isShow: Boolean = false, + priority: Int = 0, + interruptRestore: Boolean = false, +) : LedUI(priority, interruptRestore) { + override fun toString(): String { + return "LedUIDataChange(isShow=$isShow) ${super.toString()}" + } +} + +open class LedUICountDown( + open var countDownSeconds: Int = 0, + open var absCountDownTimestamp: Long = 0L, + priority: Int = 0, + interruptRestore: Boolean = false, +) : LedUI(priority, interruptRestore) { + override fun toString(): String { + return "LedUICountDown(countDownSeconds=$countDownSeconds, absCountDownTimestamp=$absCountDownTimestamp) ${super.toString()}" + } +} + + +//欢迎提示 +class WelcomeUI(val hintMsg: String? = null, val isForever: Boolean = false) : + LedUIBaseSwitch(priority = 5) { +} + +//结束提示 +class FinishUI(val hintMsg: String = "感谢一路相伴") : + LedUICountDown(priority = 5, countDownSeconds = 10) + +//线路信息提示 +class RouteInfoUI(val lineName: String) : LedUIBaseSwitch(priority = 5) + +//报站提示 +class StationReportUI(val stationName: String, val state: String) : LedUIBaseSwitch(priority = 5) + +//进站提示 暂时没用 +class ArriveStationUI() : + LedUICountDown(priority = 0, countDownSeconds = 10) + +//出站提示 暂时没用 +class LeaveStationUI() : + LedUICountDown(priority = 0, countDownSeconds = 10) + + +/** + * 转向灯提示 + * type: 0:无灯;1:左转;2:右转;3:双闪 + */ +class TurnSignalUI(isShow: Boolean, val type: Int) : + LedUIDataChange(isShow = isShow, priority = 3, interruptRestore = true) + + +//急刹提示 +class EmergencyBrakeUI() : + LedUICountDown(priority = 1, countDownSeconds = 5) + +//信号灯提示 +class TrafficLightUI( + isShow: Boolean, + val stateTurnRound: TrafficLightState?, val durationTurnRound: Int, + val stateTurnLeft: TrafficLightState?, val durationTurnLeft: Int, + val stateStraight: TrafficLightState?, val durationStraight: Int, + val stateTurnRight: TrafficLightState?, val durationTurnRight: Int +) : + LedUIDataChange(isShow = isShow, priority = 4, interruptRestore = true) + + +//前方施工提示 +class RoadWorkAheadWarningUI() : LedUICountDown(priority = 2, countDownSeconds = 10) + + From 3a221c3e1bd4d4bbb2d177af9013dcf0a0d6bed3 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Mon, 23 Dec 2024 15:17:07 +0800 Subject: [PATCH 11/15] =?UTF-8?q?[684][app]=E4=BF=AE=E6=94=B9=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E4=B8=BA686?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 6a2ccf1c3c..4c44b6bacf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -151,7 +151,7 @@ MATRIX_VERSION=2.0.8 # 公交模式司机端版本号 -DRIVER_VERSION=6.8.2 +DRIVER_VERSION=6.8.6 # 公交模式乘客端端版本号 -PASSENGER_VERSION=5.8.2 +PASSENGER_VERSION=5.8.6 From 48332c1eaf61c106bbce9afbeb8c49d79fa0494a Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Tue, 24 Dec 2024 19:51:41 +0800 Subject: [PATCH 12/15] =?UTF-8?q?[684][app]=E5=8D=87=E7=BA=A7LED=20?= =?UTF-8?q?=E5=BA=93=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libraries/mogo-hardware-devices/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/mogo-hardware-devices/build.gradle b/libraries/mogo-hardware-devices/build.gradle index 163c607572..89e6cd9a55 100644 --- a/libraries/mogo-hardware-devices/build.gradle +++ b/libraries/mogo-hardware-devices/build.gradle @@ -39,6 +39,6 @@ android { dependencies { implementation rootProject.ext.dependencies.androidxappcompat api rootProject.ext.dependencies.serialport - implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.5" + implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.6" implementation rootProject.ext.dependencies.view_model_scope } From e7a8916d12fcdde654471e1d2a38e4612a2764e9 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Wed, 25 Dec 2024 14:16:06 +0800 Subject: [PATCH 13/15] =?UTF-8?q?[684][hardware]=E5=8D=87=E7=BA=A7LED=20?= =?UTF-8?q?=E5=BA=93=E7=89=88=E6=9C=AC=201.0.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libraries/mogo-hardware-devices/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/mogo-hardware-devices/build.gradle b/libraries/mogo-hardware-devices/build.gradle index 89e6cd9a55..73bceadf18 100644 --- a/libraries/mogo-hardware-devices/build.gradle +++ b/libraries/mogo-hardware-devices/build.gradle @@ -39,6 +39,6 @@ android { dependencies { implementation rootProject.ext.dependencies.androidxappcompat api rootProject.ext.dependencies.serialport - implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.6" + implementation "com.mogo.support.device.manager:led_screen_cpower5a:1.0.7" implementation rootProject.ext.dependencies.view_model_scope } From 2b405f64210216ff819612f704d1173a2313f609 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Wed, 25 Dec 2024 15:19:00 +0800 Subject: [PATCH 14/15] =?UTF-8?q?[684][hardware]LED=E5=B1=8F=E5=B9=95=20?= =?UTF-8?q?=E7=BA=A2=E7=BB=BF=E7=81=AF=E4=B8=8D=E6=B6=88=E5=A4=B1=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../support/device/led/BaseLedUIViewModel.kt | 14 +++--- .../support/device/led/LedSourceManager.kt | 49 +++++++++++++++++++ 2 files changed, 56 insertions(+), 7 deletions(-) diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt index 4670e57a84..9facfa6489 100644 --- a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt @@ -53,7 +53,7 @@ open class BaseLedUIViewModel : ViewModel() { currentStationReportUI = StationReportUI(stationName, state) } - open suspend fun receive(msg: LedUI) { + open fun receive(msg: LedUI) { Log.e( TAG, "receive --> ${msg.javaClass.simpleName}[priority=${msg.priority}] current:${currentLedUI.javaClass.simpleName}[priority=${currentLedUI.priority}]" @@ -105,7 +105,7 @@ open class BaseLedUIViewModel : ViewModel() { } - suspend fun reset() { + fun reset() { Log.i(TAG, "reset()") viewModelScope.launch { currentLedUI = DEFAULT_UI @@ -118,7 +118,7 @@ open class BaseLedUIViewModel : ViewModel() { } } - private suspend fun showUI(msg: LedUI) { + private fun showUI(msg: LedUI) { Log.i(TAG, "showUI ledUI=${msg.javaClass.simpleName}[priority=${msg.priority}]") // 如果当前类型是 需要打断恢复的,放入等待队列 if (currentLedUI.interruptRestore) { @@ -157,7 +157,7 @@ open class BaseLedUIViewModel : ViewModel() { } } - private suspend fun dismissUI(msg: LedUI) { + private fun dismissUI(msg: LedUI) { Log.i(TAG, "dismissUI ledUI=${msg.javaClass.simpleName}[priority=${msg.priority}]") currentCountDownJob?.also { it.cancel() @@ -166,7 +166,7 @@ open class BaseLedUIViewModel : ViewModel() { restoreLastUI() } - private suspend fun restoreLastUI() { + private fun restoreLastUI() { //恢复打断 val restoreUI = pollRestoreLedUI() if (restoreUI != null) { @@ -177,7 +177,7 @@ open class BaseLedUIViewModel : ViewModel() { } } - private suspend fun startBasicUISwitchLoop() { + private fun startBasicUISwitchLoop() { if (currentRouteInfoUI != null) { showUI(currentRouteInfoUI!!) } else if (currentStationReportUI != null) { @@ -193,7 +193,7 @@ open class BaseLedUIViewModel : ViewModel() { kotlin.runCatching { baseUICountDownJob?.cancel() } } - private suspend fun basicUISwitchInternal() { + private fun basicUISwitchInternal() { Log.i(TAG, "baseUISwitchInternal()") cancelBasicUISwitch() viewModelScope.launch { diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt index 8030607c25..8cd5ab27f0 100644 --- a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/LedSourceManager.kt @@ -2,6 +2,7 @@ package com.mogo.support.device.led import android.content.Context +import android.os.CountDownTimer import com.mogo.support.device.manager.cpower5a.LedScreenCpower5aManager import com.mogo.support.device.manager.cpower5a.common.LedScreen import com.mogo.support.device.manager.cpower5a.common.TrafficLightState @@ -21,6 +22,10 @@ object LedSourceManager { private var lastUpdateEmergencyBrakeTime = 0L//上次触发急刹展示的时间 private var isDriver by Delegates.notNull() + //红绿灯定时器,超时未更新隐藏红绿灯 + @Volatile + private var lightCountDownTimer: CountDownTimer? = null + private var lastLightTime: Long = System.currentTimeMillis() fun init(isDriver: Boolean) { this.isDriver = isDriver } @@ -80,6 +85,47 @@ object LedSourceManager { } } + private fun updateLightCountDownTimer(){ + lastLightTime = System.currentTimeMillis() + if (lightCountDownTimer == null) { + lightCountDownTimer = object : CountDownTimer(300000, 500) { + override fun onTick(millisUntilFinished: Long) { + if ((System.currentTimeMillis() - lastLightTime) > 1000) { + //隐藏红绿灯显示 + receiveUI( + TrafficLightUI( + false, + null, -1, + null, -1, + null, -1, + null, -1 + ) + ) + lightCountDownTimer?.cancel() + lightCountDownTimer = null + } + } + + override fun onFinish() { + //隐藏红绿灯显示 + receiveUI( + TrafficLightUI( + false, + null, -1, + null, -1, + null, -1, + null, -1 + ) + ) + lightCountDownTimer?.cancel() + lightCountDownTimer = null + } + + } + lightCountDownTimer?.start() + } + } + /** * 更新红绿灯数据 * state -1:表示 null; 0:表示 CLEAR; 1:表示 NONE; 2:表示 RED; 3:表示 YELLOW; 4:表示 GREEN; @@ -101,6 +147,7 @@ object LedSourceManager { var durationStraightTemp = durationStraight var durationTurnRightTemp = durationTurnRight + updateLightCountDownTimer() var isShow = true if (stateTurnRound == -1 && stateTurnLeft == -1 && stateStraight == -1 && stateTurnRight == -1) { isShow = false @@ -176,6 +223,8 @@ object LedSourceManager { } else if (type == 2) { //结束 receiveUI(FinishUI()) + frontViewModel.reset() + backViewModel.reset() } else if (type == 3) { //出站 if (arrivalStopName.isNotEmpty()) { From d5e3455f6f81b90935b556bc5a0bfb58e8c9cbb3 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Wed, 25 Dec 2024 16:03:03 +0800 Subject: [PATCH 15/15] =?UTF-8?q?[686][hardware]LED=E5=B1=8F=E5=B9=95=20?= =?UTF-8?q?=E7=BA=A2=E7=BB=BF=E7=81=AF=E4=B8=8D=E6=B6=88=E5=A4=B1=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo/support/device/led/BaseLedUIViewModel.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt index 9facfa6489..a0ac9b56eb 100644 --- a/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt +++ b/libraries/mogo-hardware-devices/src/main/java/com/mogo/support/device/led/BaseLedUIViewModel.kt @@ -53,7 +53,7 @@ open class BaseLedUIViewModel : ViewModel() { currentStationReportUI = StationReportUI(stationName, state) } - open fun receive(msg: LedUI) { + open suspend fun receive(msg: LedUI) { Log.e( TAG, "receive --> ${msg.javaClass.simpleName}[priority=${msg.priority}] current:${currentLedUI.javaClass.simpleName}[priority=${currentLedUI.priority}]" @@ -118,7 +118,7 @@ open class BaseLedUIViewModel : ViewModel() { } } - private fun showUI(msg: LedUI) { + private suspend fun showUI(msg: LedUI) { Log.i(TAG, "showUI ledUI=${msg.javaClass.simpleName}[priority=${msg.priority}]") // 如果当前类型是 需要打断恢复的,放入等待队列 if (currentLedUI.interruptRestore) { @@ -157,7 +157,7 @@ open class BaseLedUIViewModel : ViewModel() { } } - private fun dismissUI(msg: LedUI) { + private suspend fun dismissUI(msg: LedUI) { Log.i(TAG, "dismissUI ledUI=${msg.javaClass.simpleName}[priority=${msg.priority}]") currentCountDownJob?.also { it.cancel() @@ -166,7 +166,7 @@ open class BaseLedUIViewModel : ViewModel() { restoreLastUI() } - private fun restoreLastUI() { + private suspend fun restoreLastUI() { //恢复打断 val restoreUI = pollRestoreLedUI() if (restoreUI != null) { @@ -177,7 +177,7 @@ open class BaseLedUIViewModel : ViewModel() { } } - private fun startBasicUISwitchLoop() { + private suspend fun startBasicUISwitchLoop() { if (currentRouteInfoUI != null) { showUI(currentRouteInfoUI!!) } else if (currentStationReportUI != null) { @@ -193,7 +193,7 @@ open class BaseLedUIViewModel : ViewModel() { kotlin.runCatching { baseUICountDownJob?.cancel() } } - private fun basicUISwitchInternal() { + private suspend fun basicUISwitchInternal() { Log.i(TAG, "baseUISwitchInternal()") cancelBasicUISwitch() viewModelScope.launch {