From 471c45f68d6e561fdfbf9dd4c42bc6c5f345cd37 Mon Sep 17 00:00:00 2001 From: liujing Date: Mon, 29 Mar 2021 11:44:35 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=84=E8=AD=A6=E6=A8=A1=E6=8B=9F=E6=95=B0?= =?UTF-8?q?=E6=8D=AEtts=E6=92=AD=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/entity/V2XWarningEntity.java | 75 ++++++++++++++++--- .../scene/warning/V2XWarningWindow.java | 7 +- .../res/raw/scenario_warning_event_data.json | 2 +- 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java index b771aee1ac..502ce0fd55 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java @@ -9,8 +9,8 @@ import java.io.Serializable; */ public class V2XWarningEntity implements Serializable { - //事件类型 碰撞预警/盲区变道预警... - private String type; + //事件类型 行人0/自行车1/摩托车2/小汽车3/公交车4 + private int type; //目标物类型 private String targetType; //目标物位置 @@ -30,7 +30,49 @@ public class V2XWarningEntity implements Serializable { //速度 private float speed; - public void setType(String type) { + private String tipContent; + + private String tts; + + public void setTipContent(int type) { + switch (type) { + case 0: + this.tipContent = "行人碰撞预警"; + break; + case 1: + case 3: + case 4: + this.tipContent = "前车碰撞预警"; + break; + case 2: + this.tipContent = "摩托车碰撞预警"; + break; + default: + break; + } + } + + public void setTts(int type) { + switch (type) { + case 0: + this.tts = "注意行人"; + break; + case 1: + this.tts = "注意自行车"; + break; + case 2: + this.tts = "注意摩托车"; + break; + case 3: + case 4: + this.tts = "注意前方车辆"; + break; + default: + break; + } + } + + public void setType(int type) { this.type = type; } @@ -74,7 +116,7 @@ public class V2XWarningEntity implements Serializable { this.speed = speed; } - public String getType() { + public int getType() { return type; } @@ -102,7 +144,6 @@ public class V2XWarningEntity implements Serializable { return distance; } - public int getFrom() { return from; } @@ -119,20 +160,36 @@ public class V2XWarningEntity implements Serializable { return speed; } + public String getTipContent() { + if (this.tipContent == null) { + setTipContent(type); + } + return tipContent; + } + + public String getTts() { + if (tts == null) { + setTts(type); + } + return tts; + } + @Override public String toString() { return "V2XWarningEntity{" + - "type='" + type + '\'' + + "type=" + type + ", targetType='" + targetType + '\'' + ", lat=" + lat + ", lon=" + lon + ", distance=" + distance + ", collisionLat=" + collisionLat + ", collisionLon=" + collisionLon + - ", from='" + from + '\'' + - ", angle='" + angle + '\'' + - ", direction='" + direction + '\'' + + ", from=" + from + + ", angle=" + angle + + ", direction=" + direction + ", speed=" + speed + + ", tipContent='" + tipContent + '\'' + + ", tts='" + tts + '\'' + '}'; } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java index 6907d43f22..5e0406c42e 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningWindow.java @@ -8,12 +8,15 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import com.mogo.commons.voice.AIAssist; +import com.mogo.commons.voice.VoicePreemptType; import com.mogo.module.common.entity.V2XWarningEntity; import com.mogo.module.v2x.R; import com.mogo.module.v2x.V2XServiceManager; import com.mogo.module.v2x.listener.V2XWindowStatusListener; import com.mogo.module.v2x.scenario.scene.V2XBasWindow; import com.mogo.module.v2x.scenario.view.IV2XWindow; +import com.mogo.module.v2x.utils.V2XUtils; import com.mogo.utils.logger.Logger; /** @@ -59,7 +62,9 @@ public class V2XWarningWindow extends V2XBasWindow implements IV2XWindow { public void show(Object entity) { if (entity != null) { mV2XWarningEntity = (V2XWarningEntity) entity; - distance.setText(String.valueOf(mV2XWarningEntity.getDistance())+"米"); + distance.setText(String.valueOf(mV2XWarningEntity.getDistance()) + "米"); + warningTextView.setText(mV2XWarningEntity.getTipContent()); + AIAssist.getInstance(V2XUtils.getApp()).speakTTSVoice(mV2XWarningEntity.getTts()); } if (runnableV2XEvent == null) { runnableV2XEvent = () -> { diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json index 674c3c1601..1f31458761 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json @@ -1,5 +1,5 @@ { - "type":3, + "type":0, "targetType": "1", "lat":39.9760799115428, "lon":116.411360351446,