add xingyun obu

This commit is contained in:
lixiaopeng
2021-06-09 18:44:18 +08:00
parent b2cb12a095
commit 220d2f1aac
13 changed files with 138 additions and 48 deletions

View File

@@ -169,7 +169,7 @@ ext {
// obu sdk
obusdk : "com.zhidao.enterprise.smartv2x:smartv2x:1.0.0.3",
mebulaobu : 'com.zhidao.support.nebulaobu:nebulaobu:1.0.0.1',
mebulaobu : 'com.zhidao.support.nebulaobu:nebulaobu:1.0.0.3',
// 左侧面板
moduleleftpanel : "com.mogo.module:module-left-panel:${MOGO_MODULE_LEFT_PANEL_VERSION}",
// 左侧面板空实现

View File

@@ -6,4 +6,10 @@
<dimen name="module_v2n_tip_text_width">106px</dimen>
<dimen name="module_v2n_tip_text_margin_right">52px</dimen>
<dimen name="module_v2n_image_margin_left">37px</dimen>
<dimen name="module_v2x_brake_tip_width">435px</dimen>
<dimen name="module_v2x_brake_tip_height">186px</dimen>
<dimen name="module_v2x_brake_image_width">133px</dimen>
<dimen name="module_v2x_brake_image_margin_left">37px</dimen>
<dimen name="module_v2x_brake_image_margin_right">27px</dimen>
</resources>

View File

@@ -1128,6 +1128,10 @@
<dimen name="module_v2n_tip_text_width">100px</dimen>
<dimen name="module_v2n_tip_text_margin_right">28px</dimen>
<dimen name="module_v2n_image_margin_left">28px</dimen>
<dimen name="module_v2x_brake_tip_width">320px</dimen>
<dimen name="module_v2x_brake_tip_height">140px</dimen>
<dimen name="module_v2x_brake_image_margin_left">28px</dimen>
<dimen name="module_v2x_brake_image_margin_right">20px</dimen>
<dimen name="module_v2x_brake_image_width">100px</dimen>
</resources>

View File

@@ -1332,7 +1332,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
}
} else if (v.getId() == R.id.module_ext_enter_vr_mode) {
// 进入vr模式
Log.d("liyz", "enter --vr--");
mMApUIController.changeMapMode(EnumMapUI.Type_VR);
} else if (v.getId() == R.id.module_ext_exit_vr_mode) {
// 退出vr模式

View File

@@ -94,7 +94,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(':modules:mogo-module-obu')
// implementation rootProject.ext.dependencies.mebulaobu
implementation rootProject.ext.dependencies.mebulaobu
}

View File

@@ -14,6 +14,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
import com.mogo.map.location.MogoLocation;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.entity.V2XMessageEntity;
@@ -25,7 +26,9 @@ import com.mogo.module.v2x.utils.ADASUtils;
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
import com.mogo.module.v2x.utils.ObuConfig;
import com.mogo.module.v2x.utils.TestOnLineCarUtils;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.service.entrance.IMogoEntranceButtonController;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import com.zhidao.mogo.module.obu.ObuConstant;
import com.zhidao.mogo.module.obu.ObuManager;
@@ -33,10 +36,11 @@ import com.zhidao.mogo.module.obu.obu.IObuCallback;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuLocationInfo;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo;
//import com.zhidao.support.nebulaobu.NebulaObuClient;
//import com.zhidao.support.nebulaobu.OnObuListener;
//import com.zhidao.support.nebulaobu.model.ActiveSafetyInfo;
//import com.zhidao.support.nebulaobu.model.ObuInfo;
import com.zhidao.support.nebulaobu.NebulaObuClient;
import com.zhidao.support.nebulaobu.OnObuListener;
import com.zhidao.support.nebulaobu.model.ActiveSafetyInfo;
import com.zhidao.support.nebulaobu.model.ObuInfo;
import com.zhidao.support.nebulaobu.model.ObuInfoMore;
import org.json.JSONArray;
import org.json.JSONObject;
@@ -87,53 +91,71 @@ public class V2XObuManager implements IObuCallback, Handler.Callback {
obuManager.init(context);
obuManager.registerObuDataChangedListener(this);
Logger.d("liyz", "obuManager初始化------> ");
//使用adas部门obu sdk (星云)
// NebulaObuClient.getInstance().init(context);
// NebulaObuClient.getInstance().registerObu(100);
// NebulaObuClient.getInstance().registerObuListener(listener);
NebulaObuClient.getInstance().init(context);
NebulaObuClient.getInstance().registerObu(100);
NebulaObuClient.getInstance().registerObuListener(listener);
IntentFilter filter = new IntentFilter("com.mogo.launcher.v2x.action.EXCHANGE_OBU_TYPE");
context.registerReceiver(obuTypeExchangeReceiver, filter);
}
// public void release() {
// NebulaObuClient.getInstance().unregisterObu();
// NebulaObuClient.getInstance().unregisterObuListener();
// }
public void release() {
NebulaObuClient.getInstance().unregisterObu();
NebulaObuClient.getInstance().unregisterObuListener();
}
/**
* 星云obu数据监听
*/
// private OnObuListener listener = new OnObuListener() {
// @Override
// public void onRegister() {
// Log.d("liyz", "onRegister ------> ");
// }
//
// @Override
// public void onConnectFail(boolean isNeedReconnect) {
// Log.d("liyz", "onConnectFail ------> ");
// }
//
// @Override
// public void onUnregister() {
// Log.d("liyz", "onUnregister ------> ");
// }
//
// @Override
// public void onObuInfo(ObuInfo info) {
// Log.d("liyz", "onObuInfo ------> ");
// }
//
// @Override
// public void onWarningInfo(List<ActiveSafetyInfo> infoList) {
// Log.d("liyz", "onWarningInfo ------> ");
// }
// };
private OnObuListener listener = new OnObuListener() {
@Override
public void onRegister() {
}
@Override
public void onConnectFail(boolean isNeedReconnect) {
Logger.d("liyz", "onConnectFail ------> ");
}
@Override
public void onUnregister() {
}
@Override
public void onObuInfo(ObuInfo info) {
Logger.d("liyz", "onObuInfo ------> " + info.toString());
}
@Override
public void onWarningInfo(List<ActiveSafetyInfo> infoList) {
if (infoList != null) {
if (infoList.size() > 0) { //一般只有一个
ActiveSafetyInfo info = infoList.get(0);
Logger.d("liyz", "onWarningInfo type ------> " + info.getWarningtype() + "--size = " + infoList.size());
if (info.getWarningtype() == 3) {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
handleSdkObu();
}
}
}
}
}
};
private void handleSdkObu() {
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
// 前车紧急制动预警
V2XObuEventEntity urgencyEvent = new V2XObuEventEntity();
urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
messageEntity.setContent(urgencyEvent);
V2XObuEventScenario.getInstance().init(messageEntity);
}
/**
* 用来处理30秒内不重复播报的情况

View File

@@ -5,6 +5,7 @@ import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.commons.voice.AIAssist;
@@ -20,6 +21,7 @@ import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.listener.V2XWindowStatusListener;
import com.mogo.module.v2x.scenario.impl.AbsV2XScenario;
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.utils.logger.Logger;
import com.zhidao.mogo.module.obu.ObuConstant;
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
@@ -40,7 +42,8 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
*/
public class V2XObuEventScenario extends AbsV2XScenario<V2XObuEventEntity> implements Handler.Callback {
public static final String URGENCY_COLLISION_WARN_TEXT = "前车急刹,注意保持安全距离!";
public static final String URGENCY_COLLISION_WARN_TEXT_ONE = "前车急刹,注意保持安全距离!";
public static final String URGENCY_COLLISION_WARN_TEXT = "前车急刹";
private static final int MSG_CLOSE_OBU_WINDOW = 1001;
private static final int DEFAULT_EXPIRE_TIME = 20_000;
@@ -118,7 +121,7 @@ public class V2XObuEventScenario extends AbsV2XScenario<V2XObuEventEntity> imple
*/
@Override
public void show() {
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(getV2XMessageEntity().getContent().getDesc());
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE);
showWindow();
if (handler.hasMessages(MSG_CLOSE_OBU_WINDOW)) {
handler.removeMessages(MSG_CLOSE_OBU_WINDOW);

View File

@@ -17,6 +17,7 @@ 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.view.IV2XWindow;
import com.mogo.module.v2x.utils.ToastUtils;
import com.mogo.service.windowview.IMogoTopViewStatusListener;
import com.mogo.utils.logger.Logger;
import com.zhidao.mogo.module.obu.ObuConstant;
@@ -47,7 +48,7 @@ public class V2XObuEventWindow extends FrameLayout implements IV2XWindow<V2XObuE
private void initView(Context context){
Logger.d(MODULE_NAME,"初始化obu场景view");
LayoutInflater.from(context).inflate(R.layout.window_simple_obu_event_detail, this);
LayoutInflater.from(context).inflate(R.layout.window_simple_obu_event_detail_vr, this);
ivTypeIcon = findViewById(R.id.ivObuTypeIcon);
tvType = findViewById(R.id.tvObuType);
tvDesc = findViewById(R.id.tvObuDesc);
@@ -65,6 +66,7 @@ public class V2XObuEventWindow extends FrameLayout implements IV2XWindow<V2XObuE
@Override
public void show(V2XObuEventEntity entity) {
Logger.d(MODULE_NAME, "ObuEventWindow show " + entity);
Logger.d("liyz", "ObuEventWindow show " + entity + "--type = " + entity.getType());
switch (entity.getType()) {
case ObuConstant
.TYPE_OPTIMAL_SPEED_ADVISORY:
@@ -75,8 +77,8 @@ public class V2XObuEventWindow extends FrameLayout implements IV2XWindow<V2XObuE
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_green);
break;
case ObuConstant.TYPE_URGENCY_COLLISION_WARNING:
// 前车急刹预警
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_urgency_collision);
// 前车急刹预警 v2x_icon_obu_urgency_collision
ivTypeIcon.setImageResource(R.drawable.v2x_icon_ahead_car_brake);
tvDesc.setText(entity.getDesc());
tvType.setText("前车急刹");
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@@ -29,7 +29,7 @@
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_3"
android:text="前车急刹"
android:textColor="@color/white"
android:textColor="@color/v2x_white"
android:textSize="@dimen/dp_24"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@+id/ivObuTypeIcon"

View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="@dimen/module_v2x_brake_tip_width"
android:layout_height="@dimen/module_v2x_brake_tip_height"
android:layout_marginTop="@dimen/dp_20"
android:layout_gravity="center_horizontal"
android:background="@drawable/v2x_front_warning_bg">
<ImageView
android:id="@+id/ivObuTypeIcon"
android:layout_width="@dimen/module_v2x_brake_image_width"
android:layout_height="@dimen/module_v2x_brake_image_width"
android:layout_marginStart="@dimen/module_v2x_brake_image_margin_left"
android:src="@drawable/v2x_icon_ahead_car_brake"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvObuType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_20"
android:background="@drawable/bg_v2x_event_type_read"
android:gravity="center"
android:paddingLeft="@dimen/dp_10"
android:paddingTop="@dimen/dp_3"
android:paddingRight="@dimen/dp_10"
android:paddingBottom="@dimen/dp_3"
android:text="前车急刹"
android:textColor="@color/v2x_white"
android:textSize="@dimen/dp_24"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/tvObuDesc"
app:layout_constraintLeft_toRightOf="@+id/ivObuTypeIcon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<TextView
android:id="@+id/tvObuDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/module_v2x_brake_image_margin_right"
android:layout_marginTop="@dimen/dp_10"
android:text="前车急刹"
android:textColor="@color/v2x_white"
android:textSize="@dimen/dp_32"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="@+id/tvObuType"
app:layout_constraintTop_toBottomOf="@+id/tvObuType" />
</androidx.constraintlayout.widget.ConstraintLayout>