[Delete]
删除mogo-module-obu 场景 Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
@@ -313,8 +313,6 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
|
||||
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_CHECK, "CheckProvider"));
|
||||
// 推送模块
|
||||
MogoModulePaths.addModule(new MogoModule(PushUIConstants.PATH, PushUIConstants.NAME));
|
||||
// 碰撞报警模块
|
||||
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_CRASH_WARNING, "IMogoCrashWarnProvider"));
|
||||
// ADAS模块(旧,慢慢被 域控制器模块 替换掉)
|
||||
MogoModulePaths.addBaseModule(new MogoModule(MogoServicePaths.PATH_ADAS, "AdasProvider"));
|
||||
// 全局语音唤醒
|
||||
|
||||
@@ -264,13 +264,6 @@ public class MogoServicePaths {
|
||||
@Deprecated
|
||||
public static final String PATH_TANLU_UI_API = "/tanlu/ui";
|
||||
|
||||
/**
|
||||
* 碰撞报警模块 已碰撞
|
||||
*/
|
||||
@Keep
|
||||
@Deprecated
|
||||
public static final String PATH_CRASH_WARNING = "/crash/warning";
|
||||
|
||||
/**
|
||||
* 在线好友面板
|
||||
*/
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
:modules:mogo-module-data
|
||||
:foudations:mogo-utils
|
||||
:skin:mogo-skin-support
|
||||
:tts:tts-base
|
||||
:tts:tts-zhi
|
||||
:tts:tts-pad
|
||||
:libraries:mogo-map-api
|
||||
:services:mogo-service-api
|
||||
:foudations:mogo-aicloud-services-sdk
|
||||
:foudations:mogo-commons
|
||||
:tts:tts-di
|
||||
:tts:tts-noop
|
||||
:skin:skin-support
|
||||
:skin:skin-support-appcompat
|
||||
:skin:skin-support-cardview
|
||||
:skin:skin-support-constraint-layout
|
||||
:skin:skin-support-design
|
||||
:libraries:map-autonavi
|
||||
:libraries:map-custom
|
||||
:libraries:mogo-map
|
||||
:modules:mogo-module-common
|
||||
:skin:mogo-skin-support-impl
|
||||
:skin:mogo-skin-support-noop
|
||||
:test:crashreport
|
||||
:test:crashreport-bugly
|
||||
:test:crashreport-noop
|
||||
:test:crashreport-upgrade
|
||||
:skin:mogo-skin-light
|
||||
:modules:mogo-module-obu
|
||||
:core:function-impl:mogo-core-function-obu-mogo
|
||||
:modules:mogo-module-adas
|
||||
:services:mogo-service
|
||||
:modules:mogo-module-map
|
||||
:core:function-impl:mogo-core-function-smp
|
||||
:modules:mogo-module-apps
|
||||
:modules:mogo-module-service
|
||||
:modules:mogo-module-share
|
||||
:modules:mogo-module-extensions
|
||||
:modules:mogo-module-v2x
|
||||
:modules:mogo-module-main
|
||||
:OCH:mogo-och
|
||||
:OCH:mogo-och-bus
|
||||
:OCH:mogo-och-noop
|
||||
:OCH:mogo-och-taxi
|
||||
:modules:mogo-module-push-base
|
||||
:modules:mogo-module-push-noop
|
||||
:modules:mogo-module-push
|
||||
:libraries:tanlulib
|
||||
:modules:mogo-module-monitor
|
||||
:modules:mogo-module-hmi
|
||||
@@ -25,7 +25,6 @@
|
||||
:test:crashreport-bugly
|
||||
:test:crashreport-noop
|
||||
:test:crashreport-upgrade
|
||||
:modules:mogo-module-obu
|
||||
:core:function-impl:mogo-core-function-obu-mogo
|
||||
:modules:mogo-module-adas
|
||||
:modules:mogo-module-service
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.mogo.utils.glide.GlideApp
|
||||
import com.mogo.utils.glide.GlideRoundedCornersTransform
|
||||
import com.mogo.utils.logger.Logger
|
||||
import de.hdodenhof.circleimageview.CircleImageView
|
||||
import kotlin.let as let
|
||||
|
||||
class CallingWindowManager private constructor() : IVoiceIntentListener {
|
||||
|
||||
|
||||
@@ -21,10 +21,8 @@ import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
@@ -46,12 +44,9 @@ import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipDrawable;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.navi.IMogoAimlessModeListener;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.navi.IMogoNavi;
|
||||
@@ -92,18 +87,14 @@ import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.IMogoStatusManager;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.LaunchUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.glide.GlideApp;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
import com.zhidao.manager.ts.TsThreshold;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -133,18 +124,14 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
private AnimNavInfoView animNavInfoView;
|
||||
private VrModeNavInfoView vrModeNavInfoView;
|
||||
|
||||
|
||||
private View mDisplayOverview;
|
||||
private ImageView mDisplayOverviewIcon;
|
||||
private TextView mDisplayOverviewText;
|
||||
|
||||
private IMogoServiceApis mApis;
|
||||
private IMogoMapService mService;
|
||||
private IMogoMapUIController mMApUIController;
|
||||
private IMogoLocationClient mMogoLocationClient;
|
||||
private IMogoNavi mMogoNavi;
|
||||
private IMogoFragmentManager mMogoFragmentManager;
|
||||
private IMogoMarkerManager mMogoMarkerManager;
|
||||
|
||||
private IMogoRegisterCenter mMogoRegisterCenter;
|
||||
private IMogoAnalytics mAnalytics;
|
||||
@@ -161,11 +148,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
private TextView mMsgCounter;
|
||||
|
||||
private ImageView mUserHeadImg;
|
||||
private View thresholdSetContainer;
|
||||
private EditText topEditC, frontLeftEditC, frontRightEditC, backLeftEditC, backRightEditC,
|
||||
bottomEditC;
|
||||
private EditText topEditS, frontLeftEditS, frontRightEditS, backLeftEditS, backRightEditS,
|
||||
bottomEditS;
|
||||
|
||||
private String[] mClickShareVoiceStrings;
|
||||
|
||||
@@ -173,11 +155,8 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
|
||||
private String[] mOuterGuideVoiceStrings;
|
||||
|
||||
private boolean isShowGuide;
|
||||
|
||||
|
||||
/**
|
||||
* 搜索莫模块
|
||||
* 搜索模块
|
||||
*/
|
||||
private boolean mIsLock = true;
|
||||
private TextView mCameraMode;
|
||||
@@ -186,17 +165,10 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
|
||||
private Rect mDisplayOverviewBounds;
|
||||
|
||||
private boolean toggle = false;
|
||||
|
||||
private TextView tvEnterVrMode;
|
||||
private TextView tvExitVrMode;
|
||||
|
||||
|
||||
private ConstraintLayout clTrafficLight;
|
||||
private TextView tvYellow;
|
||||
private TextView tvRed;
|
||||
private TextView tvGreen;
|
||||
|
||||
/**
|
||||
* 内部变量标识是否在vrMode,用于方法执行过滤,避免重复或异常调用
|
||||
*/
|
||||
@@ -227,11 +199,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
if (DebugConfig.isMapBased()) {
|
||||
return R.layout.module_ext_layout_entrance;
|
||||
} else {
|
||||
return R.layout.module_ext_layout_entrance_no_map;
|
||||
}
|
||||
return R.layout.module_ext_layout_entrance;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,7 +231,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mUploadRoadCondition.setOnClickListener(clickListener);
|
||||
mDisplayOverview = findViewById(R.id.module_ext_id_display_overview);
|
||||
mDisplayOverviewText = findViewById(R.id.module_ext_id_display_overview_text);
|
||||
mDisplayOverviewIcon = findViewById(R.id.module_ext_id_display_overview_icon);
|
||||
mMove2CurrentLocation = findViewById(R.id.module_entrance_id_move2_current_location);
|
||||
mUserHeadImg = findViewById(R.id.ivUserHeadImg);
|
||||
groupFix = findViewById(R.id.groupFix);
|
||||
@@ -334,26 +301,14 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
|
||||
dealWeatherContainer();
|
||||
|
||||
listenSeekNumber();
|
||||
|
||||
debugTopView();
|
||||
debugCrashWarn();
|
||||
|
||||
|
||||
etTimes = findViewById(R.id.etTimes);
|
||||
findViewById(R.id.btnFix).setOnClickListener(clickListener);
|
||||
|
||||
findViewById(R.id.debugPanel).setOnClickListener(clickListener);
|
||||
|
||||
initDebugPanel();
|
||||
|
||||
clTrafficLight = (ConstraintLayout) findViewById(R.id.cl_traffic_light);
|
||||
tvYellow = (TextView) findViewById(R.id.tv_yellow);
|
||||
tvRed = (TextView) findViewById(R.id.tv_red);
|
||||
tvGreen = (TextView) findViewById(R.id.tv_green);
|
||||
|
||||
|
||||
// 检查是否在vr模式
|
||||
if (mStatusManager.isVrMode()) {
|
||||
enterVrMode();
|
||||
@@ -405,67 +360,14 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().unregisterMogoLocationListener(TAG);
|
||||
localIsVrMode = false;
|
||||
clTrafficLight.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void debugCrashWarn() {
|
||||
thresholdSetContainer = findViewById(R.id.thresholdSetContainer);
|
||||
topEditC = findViewById(R.id.etTopC);
|
||||
frontLeftEditC = findViewById(R.id.etFrontLeftC);
|
||||
backLeftEditC = findViewById(R.id.etBackLeftC);
|
||||
frontRightEditC = findViewById(R.id.etFrontRightC);
|
||||
backRightEditC = findViewById(R.id.etBackRightC);
|
||||
bottomEditC = findViewById(R.id.etBottomC);
|
||||
|
||||
topEditS = findViewById(R.id.etTopS);
|
||||
frontLeftEditS = findViewById(R.id.etFrontLeftS);
|
||||
backLeftEditS = findViewById(R.id.etBackLeftS);
|
||||
frontRightEditS = findViewById(R.id.etFrontRightS);
|
||||
backRightEditS = findViewById(R.id.etBackRightS);
|
||||
bottomEditS = findViewById(R.id.etBottomS);
|
||||
|
||||
findViewById(R.id.btnClose).setOnClickListener(view -> {
|
||||
thresholdSetContainer.setVisibility(View.GONE);
|
||||
mApis.getAdasControllerApi().showADAS();
|
||||
});
|
||||
mUploadRoadCondition.setOnLongClickListener(v -> {
|
||||
mApis.getAdasControllerApi().closeADAS();
|
||||
thresholdSetContainer.setVisibility(View.VISIBLE);
|
||||
TsThreshold threshold = mApis.getCrashWarnProvider().getCurrentCrashThreshold();
|
||||
topEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC5()));
|
||||
topEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS5()));
|
||||
bottomEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC6()));
|
||||
bottomEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS6()));
|
||||
frontLeftEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC4()));
|
||||
frontLeftEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS4()));
|
||||
backLeftEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC3()));
|
||||
backLeftEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS3()));
|
||||
frontRightEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC1()));
|
||||
frontRightEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS1()));
|
||||
backRightEditC.setText(String.format(Locale.CHINA, "%d", threshold.getC2()));
|
||||
backRightEditS.setText(String.format(Locale.CHINA, "%d", threshold.getS2()));
|
||||
return true;
|
||||
});
|
||||
findViewById(R.id.btnSet).setOnClickListener(view -> {
|
||||
// 设置阈值
|
||||
TsThreshold threshold = new TsThreshold(
|
||||
Integer.parseInt(frontRightEditC.getText().toString()),
|
||||
Integer.parseInt(frontRightEditS.getText().toString()),
|
||||
Integer.parseInt(backRightEditC.getText().toString()),
|
||||
Integer.parseInt(backRightEditS.getText().toString()),
|
||||
Integer.parseInt(backLeftEditC.getText().toString()),
|
||||
Integer.parseInt(backLeftEditS.getText().toString()),
|
||||
Integer.parseInt(frontLeftEditC.getText().toString()),
|
||||
Integer.parseInt(frontLeftEditS.getText().toString()),
|
||||
Integer.parseInt(topEditC.getText().toString()),
|
||||
Integer.parseInt(topEditS.getText().toString()),
|
||||
Integer.parseInt(bottomEditC.getText().toString()),
|
||||
Integer.parseInt(bottomEditS.getText().toString())
|
||||
);
|
||||
mApis.getCrashWarnProvider().setCrashThreshold(threshold);
|
||||
thresholdSetContainer.setVisibility(View.GONE);
|
||||
mApis.getAdasControllerApi().showADAS();
|
||||
});
|
||||
|
||||
if (!DebugConfig.isMapBased()) {
|
||||
// 不基于地图的版本需要隐藏一些按钮
|
||||
@@ -610,7 +512,7 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
break;
|
||||
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (isShowGuide && isGreaterThanOneDay()) {
|
||||
if (isGreaterThanOneDay()) {
|
||||
if (motionEvent.getX() > 200) {
|
||||
showSlideMapVoiceGuide();
|
||||
}
|
||||
@@ -660,13 +562,11 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
mService = mApis.getMapServiceApi();
|
||||
mMogoRegisterCenter = mApis.getRegisterCenterApi();
|
||||
mMApUIController = mService.getMapUIController();
|
||||
mMogoLocationClient = mService.getSingletonLocationClient(getContext());
|
||||
mMogoNavi = mService.getNavi(getContext());
|
||||
mAnalytics = mApis.getAnalyticsApi();
|
||||
|
||||
mMogoRegisterCenter.registerMogoNaviListener(TYPE_ENTRANCE, this);
|
||||
mMogoRegisterCenter.registerMogoMapListener(TYPE_ENTRANCE, this);
|
||||
mMogoMarkerManager = mService.getMarkerManager(getContext());
|
||||
|
||||
mStatusManager.registerStatusChangedListener(TAG, StatusDescriptor.UPLOADING, this);
|
||||
mStatusManager.registerStatusChangedListener(TAG, StatusDescriptor.DISPLAY_OVERVIEW, this);
|
||||
@@ -923,103 +823,6 @@ public class EntranceFragment extends MvpFragment<EntranceView, EntrancePresente
|
||||
}
|
||||
}
|
||||
|
||||
private final int[] heights = new int[]{100, 200, 300};
|
||||
private int currentHeight;
|
||||
|
||||
private void debugTopView() {
|
||||
findViewById(R.id.btnDebugCtrlNaviView).setOnClickListener(view -> {
|
||||
if (!toggle) {
|
||||
TopViewAnimHelper.getInstance().showNaviView();
|
||||
} else {
|
||||
TopViewAnimHelper.getInstance().hideNaviView();
|
||||
}
|
||||
toggle = !toggle;
|
||||
});
|
||||
|
||||
findViewById(R.id.btnDebugCtrlSubView).setOnClickListener(view -> {
|
||||
View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null);
|
||||
TextView tv = v.findViewById(R.id.tvIndex);
|
||||
tv.setText("sub view height: " + currentHeight + ": " + v);
|
||||
mApis.getTopViewManager().addSubView(v, new IMogoTopViewStatusListener() {
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
Logger.d(TAG, "onSubViewAdded: " + view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
Logger.d(TAG, "onSubViewRemoved: " + view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
Logger.d(TAG, "beforeSubViewAddAnim: " + view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
Logger.d(TAG, "beforeSubViewRemoveAnim: " + view);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
findViewById(R.id.btnDebugCtrlTopView).setOnClickListener(view -> {
|
||||
View v = LayoutInflater.from(getContext()).inflate(R.layout.demo_top, null);
|
||||
TextView tv = v.findViewById(R.id.tvIndex);
|
||||
Random random = new Random();
|
||||
currentHeight = heights[random.nextInt(3)];
|
||||
tv.setText(" height: " + currentHeight + ": " + v);
|
||||
ViewGroup.LayoutParams params =
|
||||
new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, currentHeight);
|
||||
// mApis.getEntranceButtonController().addLeftFeatureView(v);
|
||||
|
||||
mApis.getTopViewManager().addView(v, params, new IMogoTopViewStatusListener() {
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
Logger.d(TAG, "onViewAdded: " + view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
Logger.d(TAG, "onViewRemoved: " + view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
Logger.d(TAG, "beforeViewAddAnim: " + view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
Logger.d(TAG, "beforeViewRemoveAnim: " + view);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
findViewById(R.id.btnDebugAddBottomLayerView).setOnClickListener(v -> {
|
||||
TextView tv = new TextView(getContext());
|
||||
tv.setText("entrance add");
|
||||
mApis.getEntranceButtonController().addBottomLayerView(tv, 50, 50);
|
||||
});
|
||||
findViewById(R.id.btnShowTextTip).setOnClickListener(v -> TipToast.tip("分享成功分享成功分享成功分享成功分享成功分享成功分享成功分享成功分享成功"));
|
||||
|
||||
findViewById(R.id.btnShowDrawableTip).setOnClickListener(v -> {
|
||||
mMsgContainer.setVisibility(View.VISIBLE);
|
||||
TipDrawable drawable =
|
||||
new TipDrawable(getResources().getDrawable(R.drawable.model_ext_default_user_head), 150, 150);
|
||||
TipToast.tip("分享成功", drawable);
|
||||
});
|
||||
|
||||
findViewById(R.id.btnShowDrawableTipNoSize).setOnClickListener(v -> {
|
||||
mMsgContainer.setVisibility(View.GONE);
|
||||
TipDrawable drawable =
|
||||
new TipDrawable(getResources().getDrawable(R.drawable.model_ext_default_user_head));
|
||||
TipToast.tip("分享成功", drawable);
|
||||
});
|
||||
}
|
||||
|
||||
private boolean mLastStatusIsVr = false;
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged(EnumMapUI ui) {
|
||||
if (mCameraMode == null) {
|
||||
|
||||
@@ -5,11 +5,10 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.extensions.utils.EntranceViewHolder;
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths;
|
||||
import com.mogo.module.extensions.utils.EntranceViewHolder;
|
||||
import com.mogo.service.entrance.ButtonIndex;
|
||||
import com.mogo.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.service.windowview.IMogoEntranceViewListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -17,17 +16,12 @@ import com.mogo.service.windowview.IMogoEntranceViewListener;
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
@Route( path = MogoServicePaths.PATH_ENTRANCE_BUTTON_API )
|
||||
@Route(path = MogoServicePaths.PATH_ENTRANCE_BUTTON_API)
|
||||
public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonController {
|
||||
|
||||
@Override
|
||||
public TextView getButton( ButtonIndex index ) {
|
||||
return MogoEntranceButtons.getButton( index );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBottomLayerView(View view) {
|
||||
EntranceViewHolder.getInstance().addBottomLayerView(view);
|
||||
public TextView getButton(ButtonIndex index) {
|
||||
return MogoEntranceButtons.getButton(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -40,15 +34,6 @@ public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonCont
|
||||
EntranceViewHolder.getInstance().removeBottomLayerView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLeftNoticeView(View view) {
|
||||
EntranceViewHolder.getInstance().showLeftNoticeView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideLeftNoticeView(View view) {
|
||||
EntranceViewHolder.getInstance().hideLeftNoticeView(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showLeftNoticeByType(int noticeType, int iconRes, String content) {
|
||||
@@ -61,17 +46,7 @@ public class MogoEntranceButtonControllerImpl implements IMogoEntranceButtonCont
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEntranceViewListener(IMogoEntranceViewListener listener) {
|
||||
EntranceViewHolder.getInstance().addEntranceViewListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntranceViewListener(IMogoEntranceViewListener listener) {
|
||||
EntranceViewHolder.getInstance().removeEntranceViewListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init( Context context ) {
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,261 +0,0 @@
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/thresholdSetContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000"
|
||||
android:padding="30dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTop"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="前保险杠设置(5)"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etTopC"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:hint="碰撞"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tvTop"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvTop" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etTopS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:hint="剐蹭"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintRight_toRightOf="@+id/tvTop"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvTop" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFrontLeft"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="左前门设置(4)"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/tvFrontRight"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etTopC" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etFrontLeftC"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="碰撞"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tvFrontLeft"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvFrontLeft" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etFrontLeftS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="剐蹭"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintRight_toRightOf="@+id/tvFrontLeft"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvFrontLeft" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvFrontRight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:text="右前门设置(1)"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tvFrontLeft"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etTopC" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etFrontRightC"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="碰撞"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tvFrontRight"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvFrontRight" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etFrontRightS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="剐蹭"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintRight_toRightOf="@+id/tvFrontRight"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvFrontRight" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBackLeft"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="左后门设置(3)"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toLeftOf="@+id/tvBackRight"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etFrontRightS" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBackLeftC"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="碰撞"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tvBackLeft"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvBackLeft" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBackLeftS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="剐蹭"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintRight_toRightOf="@+id/tvBackLeft"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvBackLeft" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBackRight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="右后门设置(2)"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toRightOf="@+id/tvBackLeft"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etFrontRightS" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBackRightC"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="碰撞"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tvBackRight"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvBackRight" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBackRightS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="剐蹭"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintRight_toRightOf="@+id/tvBackRight"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvBackRight" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBottom"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="后保险杠设置(6)"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/etBackRightS" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBottomC"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="碰撞"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/tvBottom"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvBottom" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etBottomS"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="20dp"
|
||||
android:gravity="center"
|
||||
android:hint="剐蹭"
|
||||
android:textColor="#fff"
|
||||
android:textColorHint="#ccc"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintRight_toRightOf="@+id/tvBottom"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvBottom" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnClose"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="关闭"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnSet"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="设置"
|
||||
android:textColor="#fff"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -25,53 +25,6 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_traffic_light"
|
||||
android:layout_width="@dimen/dp_212"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_marginTop="@dimen/dp_10"
|
||||
android:layout_marginRight="@dimen/dp_20"
|
||||
android:background="@drawable/view_traffic_light_vr_bg"
|
||||
android:translationZ="@dimen/dp_1"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_red"
|
||||
android:layout_width="@dimen/dp_52"
|
||||
android:layout_height="@dimen/dp_52"
|
||||
android:background="@drawable/red_light_vr_bg"
|
||||
android:translationZ="@dimen/dp_2"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/tv_green"
|
||||
app:layout_constraintStart_toEndOf="@+id/tv_yellow"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_yellow"
|
||||
android:layout_width="@dimen/dp_52"
|
||||
android:layout_height="@dimen/dp_52"
|
||||
android:layout_marginLeft="@dimen/dp_15"
|
||||
android:background="@drawable/yellow_light_vr_bg"
|
||||
android:translationZ="@dimen/dp_2"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_green"
|
||||
android:layout_width="@dimen/dp_52"
|
||||
android:layout_height="@dimen/dp_52"
|
||||
android:layout_marginRight="@dimen/dp_15"
|
||||
android:background="@drawable/green_light_vr_bg"
|
||||
android:translationZ="@dimen/dp_2"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/module_entrance_id_move2_current_location"
|
||||
android:layout_width="@dimen/module_ext_operation_panel_width"
|
||||
@@ -295,80 +248,6 @@
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugCtrlTopView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示隐藏TopView"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugCtrlSubView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示隐藏SubView"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugCtrlTopView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugCtrlNaviView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示隐藏导航view"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugCtrlSubView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugAddBottomLayerView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="增加底层view"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugCtrlNaviView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowTextTip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示文字tip"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugAddBottomLayerView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowDrawableTip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示图文tip"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnShowTextTip"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowDrawableTipNoSize"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示图文tip,没有大小"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnShowDrawableTip"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/groupTopViewDebug"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="btnShowDrawableTipNoSize,btnShowDrawableTip,btnShowTextTip,btnDebugCtrlNaviView,btnDebugCtrlSubView,btnDebugCtrlTopView,btnDebugAddBottomLayerView" />
|
||||
|
||||
<include
|
||||
layout="@layout/module_ext_layout_crash_threshold_set"
|
||||
android:visibility="gone" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etTimes"
|
||||
android:layout_width="400px"
|
||||
|
||||
@@ -1,302 +0,0 @@
|
||||
<?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"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/module_entrance_id_top_motion_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
layout="@layout/module_ext_layout_extensions"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<include
|
||||
layout="@layout/module_ext_include_seeking_help_notice"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/module_entrance_id_move2_current_location"
|
||||
android:layout_width="@dimen/module_ext_operation_panel_width"
|
||||
android:layout_height="@dimen/module_ext_operation_panel_move2_height"
|
||||
android:background="@drawable/module_ext_drawable_shadow_bg"
|
||||
android:scaleType="centerInside"
|
||||
android:src="@drawable/module_map_ic_move2_current_location"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_entrance_id_buttons_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/module_common_shadow_width_pos"
|
||||
android:layout_marginBottom="@dimen/module_common_shadow_width_pos"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_entrance_id_button1"
|
||||
android:layout_width="@dimen/module_ext_operation_panel_width"
|
||||
android:layout_height="@dimen/module_ext_operation_panel_width"
|
||||
android:layout_marginLeft="@dimen/module_entrance_id_button_marginLeft"
|
||||
android:background="@drawable/module_ext_shadow_bkg"
|
||||
android:gravity="center"
|
||||
android:padding="0dp"
|
||||
android:text="前方\n实况"
|
||||
android:textColor="@color/module_commons_FFF_333"
|
||||
android:textSize="@dimen/v2x_cancel_help_text_size"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_entrance_id_button2"
|
||||
android:layout_width="@dimen/module_ext_operation_panel_width"
|
||||
android:layout_height="@dimen/module_ext_operation_panel_width"
|
||||
android:layout_marginLeft="@dimen/module_entrance_id_button_marginLeft"
|
||||
android:layout_marginTop="@dimen/module_entrance_id_button_marginTop"
|
||||
android:background="@drawable/module_ext_drawable_shadow_bg"
|
||||
android:gravity="center"
|
||||
android:padding="0dp"
|
||||
android:text="取消\n求助"
|
||||
android:textColor="@color/module_commons_FFF_333"
|
||||
android:textSize="@dimen/v2x_cancel_help_text_size"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_entrance_id_exit_navi"
|
||||
android:layout_width="@dimen/module_ext_navi_exit_width"
|
||||
android:layout_height="@dimen/module_ext_navi_exit_height"
|
||||
android:layout_marginTop="@dimen/module_entrance_id_button_marginTop"
|
||||
android:background="@drawable/module_ext_dw_common_corner_bkg"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_ext_str_exit_navi"
|
||||
android:textColor="@color/module_commons_FFF_333"
|
||||
android:textSize="@dimen/module_ext_navi_exit_textSize"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_entrance_id_upload_road_condition"
|
||||
android:layout_width="@dimen/module_ext_operation_panel_share_no_map_width"
|
||||
android:layout_height="@dimen/module_ext_operation_panel_share_no_map_height"
|
||||
android:layout_marginLeft="@dimen/dp_8"
|
||||
android:layout_marginTop="@dimen/module_entrance_id_button_marginTop"
|
||||
android:layout_marginBottom="@dimen/module_common_btn_bottom"
|
||||
android:background="@drawable/module_ext_share_no_map_selector">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_entrance_id_upload"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/module_map_str_upload_road_condition"
|
||||
android:textColor="#FFFFFF"
|
||||
android:textSize="@dimen/module_ext_operation_panel_share_textSize"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_entrance_id_uploading"
|
||||
android:layout_width="@dimen/module_entrance_id_uploading_width"
|
||||
android:layout_height="@dimen/module_entrance_id_uploading_height"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/module_ext_ic_uploading_00010"
|
||||
android:textColor="#FFFFFF"
|
||||
android:visibility="gone" />
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/module_ext_id_top_container_shader"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/module_ext_top_container_shader_bg"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<com.mogo.module.extensions.navi.AnimNavInfoView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/module_ext_id_anim_nav_info"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_ext_id_north"
|
||||
android:layout_width="@dimen/module_ext_button_width"
|
||||
android:layout_height="@dimen/module_ext_button_height"
|
||||
android:layout_marginTop="@dimen/module_ext_camera_button_marginTop"
|
||||
android:background="@drawable/module_ext_dw_common_corner_bkg"
|
||||
android:drawableTop="@drawable/selector_icon_north_up"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="@dimen/dp_14"
|
||||
android:text="@string/mode_north_up"
|
||||
android:textColor="@color/module_ext_color_voice_text"
|
||||
android:textSize="@dimen/module_ext_north_textSize"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintRight_toRightOf="@+id/module_entrance_id_move2_current_location"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_map_id_navi_bg"
|
||||
app:layout_goneMarginTop="@dimen/module_ext_north_goneMarginTop"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_ext_id_destination_online_car"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/module_ext_button_height"
|
||||
android:layout_marginTop="@dimen/module_ext_camera_button_marginTop"
|
||||
android:background="@drawable/module_ext_dw_navi_info_panel_bkg"
|
||||
android:drawableLeft="@drawable/module_ext_destination_online_car_dw"
|
||||
android:drawablePadding="@dimen/module_ext_destination_online_car_drawablePadding"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="@dimen/module_ext_destination_online_car_paddingLeft"
|
||||
android:paddingRight="@dimen/module_ext_destination_online_car_paddingRight"
|
||||
android:text="@string/module_ext_destination_online_car_text"
|
||||
android:textColor="@color/module_ext_color_voice_text"
|
||||
android:textSize="@dimen/module_ext_north_textSize"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_map_id_navi_bg"
|
||||
app:layout_goneMarginTop="@dimen/module_ext_north_goneMarginTop"
|
||||
tools:visibility="visible" />
|
||||
<!--关联别的控件的头部容器-->
|
||||
<com.mogo.module.extensions.navi.TopView
|
||||
android:id="@+id/module_entrance_id_top_container"
|
||||
style="@style/NaviViewStyle"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintBottom_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<!--没有关联别的控件的头部弹窗容器-->
|
||||
<com.mogo.module.extensions.navi.TopView
|
||||
android:id="@+id/module_entrance_id_top_container_no_linkage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintBottom_toTopOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/module_ext_id_display_overview"
|
||||
android:layout_width="@dimen/module_ext_button_width"
|
||||
android:layout_height="@dimen/module_ext_button_height"
|
||||
android:layout_marginLeft="@dimen/module_common_shadow_width_pos"
|
||||
android:layout_marginTop="@dimen/module_ext_camera_button_marginTop"
|
||||
android:background="@drawable/module_ext_dw_common_corner_bkg"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="@+id/module_map_id_navi_bg"
|
||||
app:layout_constraintTop_toBottomOf="@+id/module_map_id_navi_bg"
|
||||
tools:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/module_ext_id_display_overview_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/module_ext_display_overview_icon_marginTop"
|
||||
android:src="@drawable/module_ext_ic_display_overview" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/module_ext_id_display_overview_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
android:text="全览"
|
||||
android:textColor="@color/module_ext_color_voice_text"
|
||||
android:textSize="@dimen/module_ext_display_overview_textSize_large"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugCtrlTopView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示隐藏TopView"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugCtrlSubView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示隐藏SubView"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugCtrlTopView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugCtrlNaviView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示隐藏导航view"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugCtrlSubView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnDebugAddBottomLayerView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="增加底层view"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugCtrlNaviView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowTextTip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示文字tip"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnDebugAddBottomLayerView"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowDrawableTip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示图文tip"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnShowTextTip"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowDrawableTipNoSize"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="显示图文tip,没有大小"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintBottom_toTopOf="@id/btnShowDrawableTip"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/groupTopViewDebug"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="btnShowDrawableTipNoSize,btnShowDrawableTip,btnShowTextTip,btnDebugCtrlNaviView,btnDebugCtrlSubView,btnDebugCtrlTopView,btnDebugAddBottomLayerView" />
|
||||
|
||||
<include
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
layout="@layout/include_debug_panel" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
1
modules/mogo-module-obu/.gitignore
vendored
1
modules/mogo-module-obu/.gitignore
vendored
@@ -1 +0,0 @@
|
||||
/build
|
||||
@@ -1,12 +0,0 @@
|
||||
#### 说明
|
||||
自研OBU感知预警模块,wiki: http://wiki.zhidaohulian.com/pages/viewpage.action?pageId=58209118
|
||||
接收OBU回调数据,进行UI呈现及相关业务
|
||||
|
||||
|
||||
硬件记录:
|
||||
|
||||
经纬度采用:WGS84坐标系
|
||||
自车信息:100毫秒回调一次(需要处理断连风险,采用Android系统自身定位信息「可能需要转换下坐标」)
|
||||
V2I场景:会有持续性通知,Status。需要有保底的情况进行超时清除事件;
|
||||
RV场景:收到即显示,收不到或断链的时候清除;
|
||||
多预警场景触发:HV,RV 会采用两个通道,同时触发的时候会采用集合的形式回调,优先级高的在最上面(待验证)
|
||||
@@ -1,56 +0,0 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.kotlinstdlibjdk7
|
||||
implementation rootProject.ext.dependencies.androidxccorektx
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
implementation rootProject.ext.dependencies.rxjava
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.obusdk
|
||||
implementation rootProject.ext.dependencies.carmanager
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
} else {
|
||||
implementation project(':modules:mogo-module-common')
|
||||
implementation project(':core:mogo-core-data')
|
||||
}
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
@@ -1,36 +0,0 @@
|
||||
# OBU
|
||||
|
||||
## 基本介绍
|
||||
OBU:安装在车上的车载单元,一台车安装一个
|
||||
RSU:路测单元,装在路边杆子上的
|
||||
|
||||
obu模块入口类是ObuManager
|
||||
|
||||
## 基本通信流程
|
||||
RSU与OBU可互相通信,OBU与OBU可互相通信,对于我们是黑盒,可以不用关心;
|
||||
OBU对外暴露两种通信方式:
|
||||
1. 以OBU为wifi热点,车机连接OBU后,与OBU进行通信,使用这种通信方式,分体机无法和工控机进行通信,而且分体机也没有网,无法和服务端进行通信,所以这种方式基本无用;
|
||||
2. 先用OBU连接车载路由,分体机也连接车载路由,拿到OBU的IP地址后,可与此IP(OBU)进行通信,使用这种通信方式,需要在车载路由上配置OBU的IP地址,__使其固定__,这样每次都连接同一IP地址即可,__目前使用的就是这种方式__;
|
||||
|
||||
## 需要处理的数据
|
||||
目前将obu返回的数据封装成了三种类型:
|
||||
1. 道路事件 MogoObuEventInfo
|
||||
2. 红绿灯信息 MogoObuTrafficLightInfo
|
||||
3. 自车定位 MogoObuLocationInfo
|
||||
目前只用到了道路事件和红绿灯信息,自车定位没有使用。
|
||||
|
||||
## 数据展示
|
||||
收到obu数据后,是在v2x模块进行的展示,关键类是V2XObuManager和v2x包下scenario/scene/obu下的类,其中一部分是在v2x展示,一部分是通过adas展示,但是在鹰眼模式可能都需要在智慧交通展示,所以做了一个中间类接收给adas的广播,用来处理在鹰眼模式下的展示,关键类AdasNoticeHelper;
|
||||
|
||||
## 通信方式
|
||||
通信方式分两种:__TCP通信__和__UDP通信__,不同的OBU通信方式也不一样。
|
||||
|
||||
### Cidi 希迪 obu
|
||||
cidi是接的sdk进行通信,由于sdk封装了ip地址设置这一步,也就是说ip地址在sdk层就已经固定了,无法修改,如果想有修改的话,需要需要把核心sdk抽取出来,重新封装sdk,此步骤可查阅源码进行分析,固定的IP地址为192.168.8.121;
|
||||
关键类是CidiObu;
|
||||
|
||||
### 华砺智行 obu
|
||||
目前应用在了苏州演示项目,采用tcp通信方式,关键类HualiObu,通信关键类是SimpleSocketManager;
|
||||
|
||||
### 大唐高鸿 obu
|
||||
目前应用在了国展演示项目,采用udp通信方式,关键类是NetCarObu,通信关键类是UdpSocketManager;
|
||||
@@ -1,3 +0,0 @@
|
||||
GROUP=com.mogo.module
|
||||
POM_ARTIFACT_ID=module-obu
|
||||
VERSION_CODE=1
|
||||
21
modules/mogo-module-obu/proguard-rules.pro
vendored
21
modules/mogo-module-obu/proguard-rules.pro
vendored
@@ -1,21 +0,0 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -1,5 +0,0 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.zhidao.mogo.module.obu">
|
||||
|
||||
/
|
||||
</manifest>
|
||||
@@ -1,271 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.service.IMogoServiceApis
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.mogo.module.obu.obu.BaseObu
|
||||
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.MogoObuTrafficLightInfo
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers.io
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* 模拟相关操作及数据的单例类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class MockUtil:Handler.Callback {
|
||||
companion object {
|
||||
const val TAG = "MockUtil"
|
||||
}
|
||||
|
||||
private var dataCallback: IObuCallback? = null
|
||||
|
||||
private lateinit var intervalObs: Disposable
|
||||
private lateinit var intervalObs2: Disposable
|
||||
|
||||
private lateinit var context: Context
|
||||
private lateinit var view:View
|
||||
|
||||
private val handler = Handler(this)
|
||||
|
||||
override fun handleMessage(msg: Message): Boolean {
|
||||
if (msg.what == 1001) {
|
||||
Logger.d(TAG,"准备添加调试view")
|
||||
val api = ARouter.getInstance().build(com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
|
||||
api.windowManagerApi.addView(view, 800, 300, false)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private var cLightStatus: String = "G"
|
||||
private var cSurplusTime: String = "10"
|
||||
|
||||
fun init(context: Context,obu:BaseObu){
|
||||
Logger.d(TAG, "使用模拟obu数据===")
|
||||
this.context = context
|
||||
dataCallback = obu.callback
|
||||
view = LayoutInflater.from(context).inflate(R.layout.mock_obu, null)
|
||||
// view.findViewById<Button>(R.id.btnVip).setOnClickListener {
|
||||
// val carEventInfo = MogoObuEventInfo()
|
||||
// carEventInfo.type = "vip变灯提醒"
|
||||
// carEventInfo.typeCode = "vip变灯提醒"
|
||||
// val r = Random.nextInt(0, 2)
|
||||
// carEventInfo.describe = when (r) {
|
||||
// 0 -> "已更改前方红绿灯状态,可优先通行"
|
||||
// else -> "已增加前方绿灯时间,可优先通行"
|
||||
// }
|
||||
// dataCallback?.onEventInfoCallback(carEventInfo)
|
||||
// }
|
||||
|
||||
// view.findViewById<Button>(R.id.btnPersonCrash).setOnClickListener {
|
||||
// obu.onMessageReceived("{\"pedestrain_information\": {\"pedestrian_crash_alarm\": 1}}".toByteArray())
|
||||
// }
|
||||
//
|
||||
// view.findViewById<Button>(R.id.btnCrossCrash).setOnClickListener {
|
||||
// obu.onMessageReceived("{\"intersection_crash\":{\"intersection_crash_alarm\":1}}".toByteArray())
|
||||
// }
|
||||
//
|
||||
// view.findViewById<Button>(R.id.btnOptimizeSpeed).setOnClickListener {
|
||||
// obu.onMessageReceived("{\"rush_redlight\": {\"glosa_info\": [{\"rush_redlight_alarm\": 1,\"advisory_speed\":40.0}]}}".toByteArray())
|
||||
// }
|
||||
//
|
||||
// view.findViewById<Button>(R.id.btnRushRedLight).setOnClickListener {
|
||||
// obu.onMessageReceived("{\"rush_redlight\": {\"glosa_info\": [{\"rush_redlight_alarm\": 0}]}}".toByteArray())
|
||||
// }
|
||||
|
||||
// view.findViewById<Button>(R.id.btnStartTrafficLight).setOnClickListener {
|
||||
// intervalMockData()
|
||||
// }
|
||||
//
|
||||
// view.findViewById<Button>(R.id.btnStopTrafficLight).setOnClickListener {
|
||||
// if (intervalObs != null&&!intervalObs.isDisposed) {
|
||||
// intervalObs.dispose()
|
||||
// }
|
||||
// }
|
||||
|
||||
view.findViewById<Button>(R.id.btnGreen).setOnClickListener {
|
||||
Logger.d(TAG,"准备发送绿灯信号")
|
||||
cLightStatus = "G"
|
||||
sendTrafficEvent()
|
||||
}
|
||||
view.findViewById<Button>(R.id.btnRed).setOnClickListener {
|
||||
Logger.d(TAG,"准备发送红灯信号")
|
||||
cLightStatus = "R"
|
||||
sendTrafficEvent()
|
||||
}
|
||||
view.findViewById<Button>(R.id.btnYello).setOnClickListener {
|
||||
Logger.d(TAG,"准备发送黄灯信号")
|
||||
cLightStatus = "Y"
|
||||
sendTrafficEvent()
|
||||
}
|
||||
view.findViewById<Button>(R.id.btnChangeTime).setOnClickListener {
|
||||
val random = Random.nextInt(100)
|
||||
Logger.d(TAG,"准备修改时间信息: $random")
|
||||
cSurplusTime = random.toString()
|
||||
sendTrafficEvent()
|
||||
}
|
||||
|
||||
view.findViewById<Button>(R.id.btnShowLimitSpeed).setOnClickListener{
|
||||
val random = Random.nextInt(200)
|
||||
// 发送当前限速到 adas
|
||||
val intent = Intent("com.mogo.launcher.adas")
|
||||
intent.putExtra("adas_speed_limit", random)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
handler.sendEmptyMessageDelayed(1001, 10000)
|
||||
|
||||
}
|
||||
|
||||
// fun init(context: Context, obuType: Int, callback: OnMessageReceiveListener? = null) {
|
||||
// Logger.d(TAG, "使用模拟obu数据===")
|
||||
// dataCallback = callback
|
||||
// val api = ARouter.getInstance().build(MogoServicePaths.PATH_SERVICE_APIS).navigation(context) as IMogoServiceApis
|
||||
// val view = LayoutInflater.from(context).inflate(R.layout.mock_obu, null)
|
||||
// view.findViewById<Button>(R.id.btnVip).setOnClickListener {
|
||||
// val carEventInfo = CarEventInfo()
|
||||
// carEventInfo.type = "vip变灯提醒"
|
||||
// carEventInfo.typeCode = "vip变灯提醒"
|
||||
// val r = Random.nextInt(0, 2)
|
||||
// carEventInfo.describe = when (r) {
|
||||
// 0 -> "已更改前方红绿灯状态,可优先通行"
|
||||
// else -> "已增加前方绿灯时间,可优先通行"
|
||||
// }
|
||||
// dataCallback?.showCarEventInfo(carEventInfo)
|
||||
// }
|
||||
//
|
||||
// view.findViewById<Button>(R.id.btnPersonCrash).setOnClickListener {
|
||||
// val carEventInfo = CarEventInfo()
|
||||
// carEventInfo.type = "行人碰撞预警"
|
||||
// carEventInfo.typeCode = "39"
|
||||
// carEventInfo.describe = "这个应该是随便写,反正也不用"
|
||||
// dataCallback?.showCarEventInfo(carEventInfo)
|
||||
// }
|
||||
// api.windowManagerApi.addView(view, 500, 300, false)
|
||||
// intervalMockData()
|
||||
// }
|
||||
|
||||
private fun intervalMockData() {
|
||||
intervalObs = Observable.interval(5000, TimeUnit.MILLISECONDS).map {
|
||||
it.toString()
|
||||
}.subscribeOn(io()).observeOn(io()).subscribe {
|
||||
debugTrafficLight()
|
||||
}
|
||||
// intervalObs2 = Observable.interval(5000,TimeUnit.MILLISECONDS).map {
|
||||
// it.toString()
|
||||
// }.subscribeOn(io()).observeOn(AndroidSchedulers.mainThread()).subscribe {
|
||||
// debugCarEvent()
|
||||
// }
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
intervalObs.dispose()
|
||||
intervalObs2.dispose()
|
||||
}
|
||||
|
||||
private fun sendTrafficEvent() {
|
||||
val trafficLightInfo = MogoObuTrafficLightInfo()
|
||||
trafficLightInfo.id = "12"
|
||||
trafficLightInfo.lightStatus = cLightStatus
|
||||
trafficLightInfo.surplusTime = cSurplusTime
|
||||
dataCallback?.onTrafficLightInfoCallback(trafficLightInfo)
|
||||
Logger.d(TAG, "发送红绿灯数据: $trafficLightInfo")
|
||||
|
||||
}
|
||||
|
||||
private fun debugCarEvent() {
|
||||
val random = Random.nextInt(0, 4)
|
||||
Logger.d(TAG, "random====$random")
|
||||
val carEventInfo = MogoObuEventInfo()
|
||||
when (random) {
|
||||
0 -> {
|
||||
// 绿波引导
|
||||
carEventInfo.type = "绿波车速引导"
|
||||
carEventInfo.typeCode = "13"
|
||||
val r = Random.nextInt(0, 3)
|
||||
carEventInfo.describe = when (r) {
|
||||
0 -> "保持当前车速行驶!"
|
||||
1 -> "建议50km/h车速行驶"
|
||||
else -> "建议30km/h ~ 50km/h 车速行驶"
|
||||
}
|
||||
dataCallback?.onEventInfoCallback(carEventInfo)
|
||||
}
|
||||
1 -> {
|
||||
// 前方急刹预警
|
||||
carEventInfo.type = "紧急制动预警"
|
||||
carEventInfo.typeCode = "06"
|
||||
carEventInfo.describe = "这个应该是随便写,反正也不用"
|
||||
dataCallback?.onEventInfoCallback(carEventInfo)
|
||||
}
|
||||
2 -> {
|
||||
// 行人碰撞预警
|
||||
carEventInfo.type = "行人碰撞预警"
|
||||
carEventInfo.typeCode = "39"
|
||||
carEventInfo.describe = "这个应该是随便写,反正也不用"
|
||||
dataCallback?.onEventInfoCallback(carEventInfo)
|
||||
}
|
||||
3 -> {
|
||||
// vip变灯提醒
|
||||
carEventInfo.type = "vip变灯提醒"
|
||||
carEventInfo.typeCode = "vip变灯提醒"
|
||||
val r = Random.nextInt(0, 2)
|
||||
carEventInfo.describe = when (r) {
|
||||
0 -> "已更改前方红绿灯状态,可优先通行"
|
||||
else -> "已增加前方绿灯时间,可优先通行"
|
||||
}
|
||||
dataCallback?.onEventInfoCallback(carEventInfo)
|
||||
}
|
||||
else -> {
|
||||
// 其他,不处理
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun debugTrafficLight() {
|
||||
Logger.d(TAG, "准备开始红绿灯模拟数据发送===")
|
||||
Thread.sleep(20_000)
|
||||
Logger.d(TAG, "开始红绿灯模拟数据发送===")
|
||||
val trafficLightInfo = MogoObuTrafficLightInfo()
|
||||
trafficLightInfo.id = "12"
|
||||
// 先来6秒红灯
|
||||
trafficLightInfo.lightStatus = "R"
|
||||
for (i in 0..5) {
|
||||
trafficLightInfo.surplusTime = (5 - i).toString()
|
||||
dataCallback?.onTrafficLightInfoCallback(trafficLightInfo)
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
// 停5秒
|
||||
Thread.sleep(4000)
|
||||
// 再来5秒黄灯
|
||||
trafficLightInfo.lightStatus = "Y"
|
||||
for (i in 0..5) {
|
||||
trafficLightInfo.surplusTime = (5 - i).toString()
|
||||
dataCallback?.onTrafficLightInfoCallback(trafficLightInfo)
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
// 停5秒
|
||||
Thread.sleep(4000)
|
||||
// 再来5秒绿灯
|
||||
trafficLightInfo.lightStatus = "G"
|
||||
for (i in 0..5) {
|
||||
trafficLightInfo.surplusTime = (5 - i).toString()
|
||||
dataCallback?.onTrafficLightInfoCallback(trafficLightInfo)
|
||||
Thread.sleep(1000)
|
||||
}
|
||||
Logger.d(TAG, "红绿灯模拟数据发送结束====")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu;
|
||||
|
||||
/**
|
||||
* obu涉及的常量汇总
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class ObuConstant {
|
||||
/**
|
||||
* 前碰撞预警,暂时不知道是干啥的
|
||||
*/
|
||||
public static final int TYPE_FRONT_COLLISION_WARNING = 101;
|
||||
|
||||
/**
|
||||
* 交叉路口碰撞预警
|
||||
*/
|
||||
public static final int TYPE_CROSS_COLLISION_WARNING = 102;
|
||||
|
||||
/**
|
||||
* 紧急制动预警
|
||||
*/
|
||||
public static final int TYPE_URGENCY_COLLISION_WARNING = 105;
|
||||
|
||||
/**
|
||||
* 绿波车速引导
|
||||
*/
|
||||
public static final int TYPE_OPTIMAL_SPEED_ADVISORY = 109;
|
||||
|
||||
/**
|
||||
* 行人碰撞预警
|
||||
*/
|
||||
public static final int TYPE_ROAD_USER_COLLISION_WARNING = 115;
|
||||
|
||||
/**
|
||||
* 为vip车辆变灯提醒
|
||||
*/
|
||||
public static final int TYPE_CHANGE_LIGHT_FOR_VIP = 116;
|
||||
|
||||
/**
|
||||
* 闯红灯预警
|
||||
*/
|
||||
public static final int TYPE_RUSH_RED_LIGHT = 117;
|
||||
/**
|
||||
* 盲区辅助
|
||||
*/
|
||||
public static final int TYPE_BLIND_ASSIST_WARN = 118;
|
||||
/**
|
||||
* 异常车辆预警
|
||||
*/
|
||||
public static final int TYPE_UNUSUAL_CAR_WARN = 119;
|
||||
/**
|
||||
* 道路危险情况预警
|
||||
*/
|
||||
public static final int TYPE_UNUSUAL_ROAD_WARN = 120;
|
||||
/**
|
||||
* 交通标牌提示
|
||||
*/
|
||||
public static final int TYPE_TRAFFIC_SIGN_INFO = 121;
|
||||
/**
|
||||
* 前方拥堵提醒
|
||||
*/
|
||||
public static final int TYPE_BLOCK_WARN = 122;
|
||||
/**
|
||||
* 紧急车辆提示预警
|
||||
*/
|
||||
public static final int TYPE_PRESSING_CAR_WARN = 123;
|
||||
/**
|
||||
* 已闯红灯提示
|
||||
*/
|
||||
public static final int TYPE_HAS_RUSH_RED_LIGHT = 124;
|
||||
/**
|
||||
* 车道汇合预警
|
||||
*/
|
||||
public static final int TYPE_LANE_CONVERGE_WARN = 125;
|
||||
/**
|
||||
* 限速预警
|
||||
*/
|
||||
public static final int TYPE_LIMIT_SPEED_WARN = 126;
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu
|
||||
|
||||
import android.content.Context
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.mogo.module.obu.obu.*
|
||||
import com.zhidao.mogo.module.obu.socket.IUdpSocketCallback
|
||||
|
||||
/**
|
||||
* obu provider
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class ObuManager {
|
||||
companion object {
|
||||
const val TAG = "ObuManger"
|
||||
}
|
||||
|
||||
// private var handler = Handler(Looper.getMainLooper(), this)
|
||||
|
||||
private lateinit var obu: IObu
|
||||
private lateinit var context: Context
|
||||
private var listener:IObuCallback? = null
|
||||
|
||||
fun init(context: Context) {
|
||||
Logger.d(TAG, "init=======${DebugConfig.getObuType()}")
|
||||
this.context = context
|
||||
obu = when (DebugConfig.getObuType()) {
|
||||
DebugConfig.OBU_TYPE_CIDI -> CidiObu()
|
||||
DebugConfig.OBU_TYPE_HUALI -> HualiObu()
|
||||
else -> NetCarObu()
|
||||
}
|
||||
obu.init(context)
|
||||
|
||||
}
|
||||
|
||||
fun registerObuDataChangedListener(listener: IObuCallback?) {
|
||||
this.listener = listener
|
||||
if (listener != null) {
|
||||
obu.registerObuCallback(listener)
|
||||
if(DebugConfig.isUseMockObuData() ) {
|
||||
val mockUtil = MockUtil()
|
||||
mockUtil.init(context, obu as BaseObu)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun resetObuType(obuType: Int) {
|
||||
Logger.d(TAG, "resetObuType: $obuType")
|
||||
obu.release()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.crashwarn
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.service.obu.IMogoCrashWarnProvider
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.manager.power.ZDPowerManager
|
||||
import com.zhidao.manager.ts.TsSensorChannel
|
||||
import com.zhidao.manager.ts.TsThreshold
|
||||
|
||||
/**
|
||||
* 碰撞报警provider
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
@Route(path = MogoServicePaths.PATH_CRASH_WARNING)
|
||||
class CrashWarningProvider:IMogoCrashWarnProvider {
|
||||
companion object{
|
||||
const val TAG = "CrashWarningProvider"
|
||||
}
|
||||
|
||||
val crashThreshold = TsThreshold(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
|
||||
|
||||
override fun setCrashThreshold(threshold: TsThreshold?) {
|
||||
ZDPowerManager.getInstance().setTsThreshold(threshold)
|
||||
}
|
||||
|
||||
override fun getCurrentCrashThreshold(): TsThreshold = crashThreshold
|
||||
|
||||
override fun init(context: Context) {
|
||||
Logger.d(TAG, "init---->")
|
||||
ZDPowerManager.getInstance().setTsBoxStatusListener(object : ZDPowerManager.TsBoxStatusListener{
|
||||
override fun onBoxSelfCheckChanged(p0: TsSensorChannel?) {
|
||||
}
|
||||
|
||||
override fun onTsCleanFlashChanged(p0: Int) {
|
||||
}
|
||||
|
||||
override fun onTsUpdateChanged(p0: Int) {
|
||||
}
|
||||
|
||||
override fun onBoxThresholdChanged(threshold: TsThreshold?) {
|
||||
threshold?.let {
|
||||
Logger.d(TAG, "获取到当前阈值==: $threshold")
|
||||
crashThreshold.copy(threshold)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onTsReadFlashCountChanged(p0: Int) {
|
||||
}
|
||||
|
||||
override fun onTimeChanged(p0: Int, p1: Int, p2: Int, p3: Int, p4: Int, p5: Int) {
|
||||
}
|
||||
|
||||
override fun onTsRestoreBackupDataChanged(p0: Int) {
|
||||
}
|
||||
|
||||
override fun onVersionChanged(p0: String?) {
|
||||
}
|
||||
|
||||
override fun onBoxSwitchChanged(p0: Int, p1: Int, p2: Int, p3: Int) {
|
||||
}
|
||||
/**
|
||||
* 碰撞报警事件
|
||||
* @param position 碰撞位置 1:右前车门,2:右后车门,3:左后车门,4:左前车门,5:前保险杠,6:后保险杠
|
||||
* @param levelH 高力度级数(1--5)
|
||||
* @param levelL 低力度级数 (1--5)
|
||||
*/
|
||||
override fun onAlarmChanged(position: Int, levelH: Int, levelL: Int) {
|
||||
// 发送广播通知adas
|
||||
Logger.d(TAG, "碰撞事件报警------ position: $position, levelH: $levelH,levelL: $levelL")
|
||||
val intent = Intent("com.mogo.launcher.action.CRASH_WARNING")
|
||||
intent.putExtra("position", position)
|
||||
intent.putExtra("levelH", levelH)
|
||||
intent.putExtra("levelL", levelL)
|
||||
context.sendBroadcast(intent)
|
||||
}
|
||||
|
||||
override fun onSerialNumChanged(p0: String?) {
|
||||
}
|
||||
|
||||
override fun onTsReadFlashDataChanged(p0: Int, p1: String?) {
|
||||
}
|
||||
|
||||
})
|
||||
val initResult = ZDPowerManager.getInstance().initTsDevice()
|
||||
Logger.d(TAG, "initDevice: $initResult")
|
||||
// 默认开启报警
|
||||
ZDPowerManager.getInstance().setTsAlarmSwitch(1)
|
||||
val getThresholdResult = ZDPowerManager.getInstance().tsBoxStatus
|
||||
Logger.d(TAG, "获取当前碰撞阈值: $getThresholdResult")
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu
|
||||
|
||||
import android.content.Context
|
||||
|
||||
abstract class BaseObu : IObu {
|
||||
var callback: IObuCallback? = null
|
||||
override fun init(context: Context) {
|
||||
}
|
||||
|
||||
override fun registerObuCallback(callback: IObuCallback) {
|
||||
this.callback = callback
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.utils.logger.Logger
|
||||
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.smartv2x.api.V2xController
|
||||
import com.zhidao.smartv2x.listener.OnMessageReceiveListener
|
||||
import com.zhidao.smartv2x.model.obu.CarEventInfo
|
||||
import com.zhidao.smartv2x.model.obu.CarLocationInfo
|
||||
import com.zhidao.smartv2x.model.obu.TrafficLightInfo
|
||||
|
||||
/**
|
||||
* 西迪obu
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class CidiObu : BaseObu(), Handler.Callback, OnMessageReceiveListener {
|
||||
companion object {
|
||||
const val TAG = "CidiObu"
|
||||
const val MSG_MONITOR_OBU_STATUS = 1001
|
||||
const val DEFAULT_MONITOR_TIME = 10_000L
|
||||
}
|
||||
|
||||
private val handler = Handler(this)
|
||||
override fun init(context: Context) {
|
||||
super.init(context)
|
||||
// 初始化sdk,注册数据回调等信息
|
||||
Logger.d(TAG,"init====")
|
||||
V2xController.getInstance().setMessageReceiveListener(this)
|
||||
handler.sendEmptyMessageDelayed(MSG_MONITOR_OBU_STATUS, DEFAULT_MONITOR_TIME)
|
||||
}
|
||||
|
||||
/**
|
||||
* 车辆位置信息回调接口
|
||||
*/
|
||||
override fun showCarLocationInfo(info: CarLocationInfo?) {
|
||||
Logger.v(TAG, "thread: ${Thread.currentThread()} showCarLocationInfo: ${info?.carId}")
|
||||
if (!DebugConfig.isUseMockObuData()) {
|
||||
// 不使用模拟数据时候不做此处理
|
||||
// 由于obu会频繁回调此接口,故10秒收不到此数据,则认为obu连接不正常,就断开重连一下
|
||||
handler.removeMessages(MSG_MONITOR_OBU_STATUS)
|
||||
handler.sendEmptyMessageDelayed(MSG_MONITOR_OBU_STATUS, DEFAULT_MONITOR_TIME)
|
||||
}
|
||||
|
||||
handler.post {
|
||||
if (info == null) {
|
||||
callback?.onLocationInfoCallback(null)
|
||||
}else {
|
||||
callback?.onLocationInfoCallback(MogoObuLocationInfo(info))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* UDP 收发消息回调接口
|
||||
*/
|
||||
override fun showOtherInfo(info: String?) {
|
||||
Logger.d(TAG, "thread: ${Thread.currentThread()} showOtherInfo: $info")
|
||||
}
|
||||
|
||||
/**
|
||||
* 交通信号灯信息回调接口
|
||||
* 17号路口红绿灯倒计时出现了,如果[TrafficLightInfo.lightStatus]为0,或者说,不为G/Y/R时,此条红绿灯数据无效
|
||||
*/
|
||||
override fun showTrafficLightInfo(info: TrafficLightInfo?) {
|
||||
Logger.d(TAG, "thread: ${Thread.currentThread()} showTrafficLightInfo: $info")
|
||||
Logger.d(TAG, "isTrafficLightInfoValid: ${isTrafficLightInfoValid(info)}")
|
||||
if (isTrafficLightInfoValid(info)) {
|
||||
handler.post {
|
||||
if (info == null) {
|
||||
callback?.onTrafficLightInfoCallback(null)
|
||||
}else{
|
||||
callback?.onTrafficLightInfoCallback(MogoObuTrafficLightInfo(info))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断红绿灯信息是否有效
|
||||
*
|
||||
* @return true 有效
|
||||
*/
|
||||
private fun isTrafficLightInfoValid(info: TrafficLightInfo?): Boolean {
|
||||
return info == null || (info.lightStatus == "G" || info.lightStatus == "Y" || info.lightStatus == "R")
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景触发事件信息回调接口
|
||||
*/
|
||||
override fun showCarEventInfo(info: CarEventInfo?) {
|
||||
Logger.d(TAG, "thread: ${Thread.currentThread()} showCarEventInfo: ${info?.type}")
|
||||
handler.post {
|
||||
if (info == null) {
|
||||
callback?.onEventInfoCallback(null)
|
||||
}else{
|
||||
callback?.onEventInfoCallback(MogoObuEventInfo(info))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg A [Message][android.os.Message] object
|
||||
* @return True if no further handling is desired
|
||||
*/
|
||||
override fun handleMessage(msg: Message?): Boolean {
|
||||
if (msg?.what == MSG_MONITOR_OBU_STATUS) {
|
||||
// obu未正常连接,需要重新连接
|
||||
Logger.d(TAG, "obu初始化")
|
||||
// V2xController.getInstance().release()
|
||||
// V2xController.getInstance().setMessageReceiveListener(this)
|
||||
V2xController.getInstance().init()
|
||||
// handler.sendEmptyMessageDelayed(MSG_MONITOR_OBU_STATUS, DEFAULT_MONITOR_TIME)
|
||||
// V2xController.getInstance().release()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
super.release()
|
||||
handler.removeMessages(MSG_MONITOR_OBU_STATUS)
|
||||
V2xController.getInstance().setMessageReceiveListener(null)
|
||||
V2xController.getInstance().release()
|
||||
}
|
||||
}
|
||||
@@ -1,312 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.SystemClock
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.mogo.module.obu.ObuConstant
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo
|
||||
import com.zhidao.mogo.module.obu.socket.IUdpSocketCallback
|
||||
import com.zhidao.mogo.module.obu.socket.SimpleSocketManager
|
||||
import org.json.JSONException
|
||||
import org.json.JSONObject
|
||||
import kotlin.experimental.xor
|
||||
|
||||
/**
|
||||
* 华砺智行obu 苏州演示项目用到的
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class HualiObu : BaseObu(), IUdpSocketCallback {
|
||||
// private val socketManager = UdpSocketManager(this)
|
||||
private val socketManager = SimpleSocketManager(this)
|
||||
|
||||
private val eventCacheMap = ArrayMap<String, Long>()
|
||||
|
||||
companion object {
|
||||
const val TAG = "HualiObu"
|
||||
const val IP_ADDRESS = "192.168.8.99"
|
||||
|
||||
// const val IP_ADDRESS = "172.31.3.18"
|
||||
const val PORT = 10005
|
||||
|
||||
/**
|
||||
* 红绿灯信息 key
|
||||
* 绿波车速和闯红灯都是根据这个key来解析json,同时,这个key也用于[eventCacheMap],用来表示闯红灯预警和绿波车速
|
||||
*/
|
||||
const val KEY_RUSH_RED_LIGHT = "rush_redlight"
|
||||
|
||||
/**
|
||||
* 交叉路口碰撞信息 key
|
||||
*/
|
||||
const val KEY_INTERSECTION_CRASH = "intersection_crash"
|
||||
|
||||
/**
|
||||
* 行人碰撞预警 key
|
||||
*/
|
||||
const val KEY_PEDESTRAIN_INFORMATION = "pedestrain_information"
|
||||
|
||||
/**
|
||||
* 事件上报事件间隔阈值
|
||||
*/
|
||||
const val EVENT_WARN_TIME_THRESHOLD = 25_000
|
||||
|
||||
|
||||
}
|
||||
|
||||
private val handler = Handler()
|
||||
|
||||
override fun init(context: Context) {
|
||||
super.init(context)
|
||||
socketManager.connect(IP_ADDRESS, PORT)
|
||||
Logger.d(TAG, "init")
|
||||
}
|
||||
|
||||
override fun onMessageReceived(msg: ByteArray) {
|
||||
// 接收到obu原始数据,处理数据
|
||||
// val m = String(msg)
|
||||
// Logger.d(TAG, "onMessageReceived: $m")
|
||||
// printByteArray(msg)
|
||||
try {
|
||||
parseObuProtocol(msg)
|
||||
} catch (e: JSONException) {
|
||||
e.printStackTrace()
|
||||
Logger.e(TAG,e,"obu数据解析json异常")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析obu数据
|
||||
*
|
||||
* @param ori 原始数据
|
||||
*/
|
||||
private fun parseObuProtocol(ori: ByteArray) {
|
||||
val effectiveData = if (DebugConfig.isUseMockObuData()) {
|
||||
ori
|
||||
} else {
|
||||
getEffectiveData(ori)
|
||||
}
|
||||
if (effectiveData != null) {
|
||||
val msg = String(effectiveData)
|
||||
Logger.d(TAG, "收到obu数据====${effectiveData.size}")
|
||||
val json = JSONObject(msg)
|
||||
val rushRedLight = json.optJSONObject(KEY_RUSH_RED_LIGHT)
|
||||
rushRedLight?.let {
|
||||
// 有闯红灯告警信息,绿波车速信息
|
||||
Logger.d(TAG, "收到闯红灯告警信息: \n $it")
|
||||
val currentLineDir = it.optInt("current_lane_man")
|
||||
Logger.d(TAG, "当前车道方向: $currentLineDir")
|
||||
val glosaInfo = it.optJSONArray("glosa_info")
|
||||
glosaInfo?.let { info ->
|
||||
Logger.d(TAG, "收到红绿灯信息: $info")
|
||||
var lastInfo: JSONObject? = null
|
||||
for (i in 0 until info.length()) {
|
||||
val j = info.optJSONObject(i)
|
||||
val lineDir = j.optInt("led_direction")
|
||||
val enable = j.optInt("lane_en", 0)
|
||||
if (lineDir == currentLineDir && enable == 1) {
|
||||
// 使能,且车道方向一致
|
||||
lastInfo = j
|
||||
}
|
||||
}
|
||||
lastInfo?.let { lightInfo ->
|
||||
if (isWarnEnable(KEY_RUSH_RED_LIGHT)) {
|
||||
val alert = lightInfo.optInt("rush_redlight_alarm", -1)
|
||||
val eventInfo = MogoObuEventInfo()
|
||||
when (alert) {
|
||||
0 -> {
|
||||
// 有闯红灯风险
|
||||
|
||||
Logger.d(TAG, "准备预警--闯红灯")
|
||||
eventInfo.mogoEventId = ObuConstant.TYPE_RUSH_RED_LIGHT
|
||||
eventInfo.describe = "当前车速经过路口会闯红灯,请减速!"
|
||||
callback?.let {
|
||||
handler.post {
|
||||
it.onEventInfoCallback(eventInfo)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1 -> {
|
||||
// 没有风险,给出建议车速,绿波车速
|
||||
Logger.d(TAG, "准备预警--绿波车速")
|
||||
eventInfo.mogoEventId = ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY
|
||||
val optSpeedInterval = lastInfo.optJSONArray("advisory_speed")
|
||||
val optSpeed = lastInfo.optInt("advisory_speed")
|
||||
if (optSpeedInterval == null) {
|
||||
// 不是速度区间,是具体速度值
|
||||
Logger.d(TAG, "建议速度值: $optSpeed")
|
||||
eventInfo.describe = "前方路口,建议车速 $optSpeed km/h"
|
||||
} else {
|
||||
Logger.d(TAG, "建议速度区间: ${optSpeedInterval[0]} ~ ${optSpeedInterval[1]}")
|
||||
val start = optSpeedInterval[0].toString().toInt()
|
||||
val end = optSpeedInterval[1].toString().toInt()
|
||||
val notice = if (start == end) {
|
||||
"前方路口,建议车速 $start km/h"
|
||||
} else {
|
||||
"前方路口,建议车速 $start 到 $end km/h"
|
||||
}
|
||||
eventInfo.describe = notice
|
||||
}
|
||||
callback?.let {
|
||||
handler.post {
|
||||
it.onEventInfoCallback(eventInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
Logger.e(TAG, "没有有效红绿灯预警信息")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "已经报过闯红灯预警了,待会再报")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val intersectionCrash = json.optJSONObject(KEY_INTERSECTION_CRASH)
|
||||
intersectionCrash?.let {
|
||||
// 有交叉路口碰撞预警信息
|
||||
Logger.d(TAG, "收到交叉路口碰撞信息: \n $it")
|
||||
if (isWarnEnable(KEY_INTERSECTION_CRASH)) {
|
||||
val alert = it.optInt("intersection_crash_alarm", 0)
|
||||
if (alert == 1) {
|
||||
// 有碰撞预警
|
||||
Logger.d(TAG, "准备预警--交叉口碰撞")
|
||||
val eventInfo = MogoObuEventInfo()
|
||||
eventInfo.mogoEventId = ObuConstant.TYPE_CROSS_COLLISION_WARNING
|
||||
callback?.let {
|
||||
handler.post {
|
||||
it.onEventInfoCallback(eventInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "已经提醒过交叉口碰撞了,等会儿再提醒")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
val pedestrainInformation = json.optJSONObject(KEY_PEDESTRAIN_INFORMATION)
|
||||
pedestrainInformation?.let {
|
||||
// 有人车冲突信息
|
||||
Logger.d(TAG, "收到人车冲突信息: \n $it")
|
||||
if (isWarnEnable(KEY_PEDESTRAIN_INFORMATION)) {
|
||||
val alert = it.optInt("pedestrian_stauts", 0)
|
||||
if (alert == 1) {
|
||||
// 有人车冲突
|
||||
Logger.d(TAG, "准备预警--行人碰撞")
|
||||
val eventInfo = MogoObuEventInfo()
|
||||
eventInfo.mogoEventId = ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING
|
||||
callback?.let {
|
||||
handler.post {
|
||||
it.onEventInfoCallback(eventInfo)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "已经上报过人车冲突,过会儿再上报")
|
||||
}
|
||||
|
||||
}
|
||||
val position = json.optJSONObject("position_3d")
|
||||
position?.let {
|
||||
// 定位信息
|
||||
Logger.d(TAG, "收到定位信息: \n $it")
|
||||
|
||||
}
|
||||
|
||||
val motion = json.optJSONObject("motion")
|
||||
motion?.let {
|
||||
// 行驶信息
|
||||
Logger.d(TAG, "收到行驶信息: \n $it")
|
||||
|
||||
}
|
||||
} else {
|
||||
Logger.e(TAG, "有效数据为空,无法解析")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否可以进行事件提醒
|
||||
* 目前是根据时间间隔阈值进行判断,[EVENT_WARN_TIME_THRESHOLD]内,同一事件只播报一次
|
||||
*
|
||||
* @return true 可上报 false 忽略此事件
|
||||
*/
|
||||
private fun isWarnEnable(key: String): Boolean {
|
||||
val time = eventCacheMap[key] ?: 0
|
||||
val current = SystemClock.elapsedRealtime()
|
||||
return if (time == 0L || current - time > EVENT_WARN_TIME_THRESHOLD) {
|
||||
eventCacheMap[key] = current
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从原始数据中,根据数据长度字节,取出有效数据
|
||||
*
|
||||
* @param oriMsg 原始数据
|
||||
* @return 有效数据
|
||||
*/
|
||||
private fun getEffectiveData(oriMsg: ByteArray): ByteArray? {
|
||||
val dataLengthInfo = ByteArray(4)
|
||||
System.arraycopy(oriMsg, 16, dataLengthInfo, 0, 4)
|
||||
// printByteArray(dataLengthInfo)
|
||||
val dataLength = convertTwoUnSignInt(dataLengthInfo)
|
||||
Logger.d(TAG, "解析后的长度: $dataLength")
|
||||
if (dataLength > oriMsg.size) {
|
||||
Logger.e(TAG, "数据长度超限制")
|
||||
return null
|
||||
}
|
||||
val parseData = ByteArray(dataLength + 21)
|
||||
System.arraycopy(oriMsg, 0, parseData, 0, parseData.size)
|
||||
return if (isAvailable(parseData)) {
|
||||
val msg = ByteArray(dataLength)
|
||||
System.arraycopy(parseData, 20, msg, 0, dataLength)
|
||||
msg
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据末位校验数据可用性
|
||||
*/
|
||||
private fun isAvailable(msg: ByteArray): Boolean {
|
||||
val checkSum = msg.last()
|
||||
var check = msg[0].xor(0xff.toByte())
|
||||
for (i in 1 until msg.size - 1) {
|
||||
check = check.xor(msg[i])
|
||||
}
|
||||
return checkSum == check
|
||||
}
|
||||
|
||||
private fun printByteArray(array: ByteArray) {
|
||||
val arrayBuilder = StringBuilder()
|
||||
array.forEach {
|
||||
val res = it.toInt() and 0xff
|
||||
arrayBuilder.append("0x")
|
||||
if (res < 16) {
|
||||
arrayBuilder.append("0")
|
||||
}
|
||||
arrayBuilder.append(Integer.toHexString(res)).append(", ")
|
||||
}
|
||||
Logger.d(TAG, arrayBuilder.toString())
|
||||
}
|
||||
|
||||
/**
|
||||
* byte数组转int
|
||||
*/
|
||||
private fun convertTwoUnSignInt(byteArray: ByteArray): Int =
|
||||
(byteArray[0].toInt() shl 24) or (byteArray[1].toInt() and 0xFF) or (byteArray[2].toInt() shl 8) or (byteArray[3].toInt() and 0xFF)
|
||||
|
||||
override fun release() {
|
||||
super.release()
|
||||
socketManager.release()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu
|
||||
|
||||
import android.content.Context
|
||||
|
||||
/**
|
||||
* Obu基本方法
|
||||
* @author tongchenfei
|
||||
*/
|
||||
interface IObu {
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
fun init(context: Context)
|
||||
|
||||
/**
|
||||
* 注册数据回调
|
||||
*/
|
||||
fun registerObuCallback(callback: IObuCallback)
|
||||
|
||||
/**
|
||||
* release
|
||||
*/
|
||||
fun release()
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu
|
||||
|
||||
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
|
||||
|
||||
/**
|
||||
* obu数据回调,目前是根据西迪的数据进行的封装
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
interface IObuCallback {
|
||||
/**
|
||||
* obu事件回调
|
||||
* @param eventInfo 事件信息
|
||||
*/
|
||||
fun onEventInfoCallback(eventInfo:MogoObuEventInfo?)
|
||||
|
||||
/**
|
||||
* obu定位信息回调
|
||||
* @param locationInfo 定位信息
|
||||
*/
|
||||
fun onLocationInfoCallback(locationInfo: MogoObuLocationInfo?)
|
||||
|
||||
/**
|
||||
* obu红绿灯信息回调
|
||||
* @param trafficLightInfo 红绿灯信息
|
||||
*/
|
||||
fun onTrafficLightInfoCallback(trafficLightInfo: MogoObuTrafficLightInfo?)
|
||||
}
|
||||
@@ -1,235 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.mogo.utils.logger.Logger
|
||||
import com.zhidao.mogo.module.obu.ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuTrafficLightInfo
|
||||
import com.zhidao.mogo.module.obu.socket.IUdpSocketStatusCallback
|
||||
import com.zhidao.mogo.module.obu.socket.UdpSocketManager
|
||||
import org.json.JSONObject
|
||||
|
||||
/**
|
||||
* 大唐高鸿obu
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class NetCarObu : BaseObu(), IUdpSocketStatusCallback, Handler.Callback {
|
||||
companion object {
|
||||
const val TAG = "NetCarObu"
|
||||
const val MSG_SEND_ACTIVATION_MSG = 1001
|
||||
const val MSG_RECONNECT = 1002
|
||||
const val SEND_ACTIVATION_MSG_DELAY = 4 * 1000L
|
||||
const val RECONNECT_DELAY = 10_000L
|
||||
const val TARGET_IP = "192.168.118.104"
|
||||
const val TARGET_PORT = 50500
|
||||
}
|
||||
|
||||
private lateinit var socketManager: UdpSocketManager
|
||||
|
||||
private val handler = Handler(this)
|
||||
|
||||
override fun init(context: Context) {
|
||||
super.init(context)
|
||||
Logger.d(TAG, "NetCar obu init")
|
||||
socketManager = UdpSocketManager(context = context, useDefaultAddress = true, callback = this)
|
||||
}
|
||||
|
||||
override fun isReady() {
|
||||
Logger.d(TAG, "udp is ready")
|
||||
// 1. 向obu注册
|
||||
sendRegisterMsg()
|
||||
}
|
||||
|
||||
private var unique: String = ""
|
||||
|
||||
override fun onMessageReceived(msg: ByteArray) {
|
||||
val response = String(msg)
|
||||
val json = JSONObject(response)
|
||||
Logger.d(TAG, "收到消息: $json")
|
||||
when (json.optInt("tag")) {
|
||||
1002 -> {
|
||||
// 查询状态成功,准备注册
|
||||
socketManager.defaultAddress?.let {
|
||||
socketManager.sendMsgTo(GsonUtil.jsonFromObject(Request(2001, NcsRegisteredData(it.ip, it.port))), TARGET_IP, TARGET_PORT)
|
||||
startReconnectTiming()
|
||||
}
|
||||
}
|
||||
2002 -> {
|
||||
// 响应注册
|
||||
val rsp = json.optInt("rsp", -1)
|
||||
if (rsp == 0) {
|
||||
// 注册成功, 等待激活
|
||||
unique = json.optString("unique", "")
|
||||
startActivationTiming()
|
||||
}
|
||||
}
|
||||
2004 -> {
|
||||
// 响应解除注册
|
||||
val rsp = json.optInt("rsp", -1)
|
||||
if (rsp == 0) {
|
||||
// 解除注册成功
|
||||
socketManager.release()
|
||||
}
|
||||
}
|
||||
2006 -> {
|
||||
// 响应激活
|
||||
val rsp = json.optInt("rsp", -1)
|
||||
if (rsp != 0) {
|
||||
// 激活失败,需要重新激活
|
||||
sendActivationMsg()
|
||||
} else {
|
||||
// 激活成功,重新计时
|
||||
startActivationTiming()
|
||||
}
|
||||
}
|
||||
2104 -> {
|
||||
// 红绿灯倒数秒数上报(车速引导)
|
||||
val dataJson = json.optJSONObject("data")
|
||||
if (dataJson != null) {
|
||||
// val lightInfo = dataJson.optJSONObject("phase")
|
||||
val lightInfoArray = dataJson.optJSONArray("phase")
|
||||
|
||||
if (lightInfoArray != null && lightInfoArray.length() > 0) {
|
||||
Logger.d(TAG, "lightInfo: $lightInfoArray")
|
||||
val lightInfo = lightInfoArray.getJSONObject(0)
|
||||
|
||||
val trafficLightInfo = MogoObuTrafficLightInfo()
|
||||
val color = lightInfo.optInt("color")
|
||||
if (color in 1..3) {
|
||||
// 有效颜色数据
|
||||
trafficLightInfo.lightStatus = when (color) {
|
||||
2 -> "R"
|
||||
3 -> "Y"
|
||||
else -> "G"
|
||||
}
|
||||
trafficLightInfo.surplusTime = lightInfo.optInt("time", 0).toString()
|
||||
callback?.onTrafficLightInfoCallback(trafficLightInfo)
|
||||
|
||||
// val end = lightInfo.optInt("guide_speed_max", -1)
|
||||
// val start = lightInfo.optInt("guide_speed_min", -1)
|
||||
// if (start != -1 && end != -1) {
|
||||
// val eventInfo = MogoObuEventInfo()
|
||||
// eventInfo.mogoEventId = TYPE_OPTIMAL_SPEED_ADVISORY
|
||||
// eventInfo.describe = "前方路口,建议车速 $start 到 $end km/h"
|
||||
// callback?.let {
|
||||
// handler.post {
|
||||
// it.onEventInfoCallback(eventInfo)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
} else {
|
||||
Logger.e(TAG, "红绿灯数据为空")
|
||||
}
|
||||
} else {
|
||||
Logger.e(TAG, "红绿灯数据为data空")
|
||||
}
|
||||
}
|
||||
2105 -> {
|
||||
// 事件上报
|
||||
val event = json.optJSONObject("data")
|
||||
if (event != null) {
|
||||
val type = event.optInt("type", 0) % 100000
|
||||
Logger.d(TAG, "事件id,取模后: $type")
|
||||
if (type == 4012) {
|
||||
// 前方行人预警
|
||||
val eventInfo = MogoObuEventInfo()
|
||||
eventInfo.mogoEventId = TYPE_ROAD_USER_COLLISION_WARNING
|
||||
handler.post {
|
||||
callback?.onEventInfoCallback(eventInfo)
|
||||
}
|
||||
} else if (type == 3005) {
|
||||
// 红绿灯变灯提醒
|
||||
val eventInfo = MogoObuEventInfo()
|
||||
eventInfo.type = "vip变灯提醒"
|
||||
eventInfo.typeCode = "vip变灯提醒"
|
||||
eventInfo.describe = "将为您变灯,vip车辆可优先通行"
|
||||
handler.post {
|
||||
callback?.onEventInfoCallback(eventInfo)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logger.e(TAG, "事件数据为空")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendRegisterMsg() {
|
||||
socketManager.defaultAddress?.let {
|
||||
socketManager.sendMsgTo(GsonUtil.jsonFromObject(Request<NcsRegisteredData>(2001, NcsRegisteredData(it.ip, it.port))), TARGET_IP, TARGET_PORT)
|
||||
startReconnectTiming()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启激活计时
|
||||
*/
|
||||
private fun startActivationTiming() {
|
||||
handler.removeMessages(MSG_SEND_ACTIVATION_MSG)
|
||||
handler.removeMessages(MSG_RECONNECT)
|
||||
handler.sendEmptyMessageDelayed(MSG_SEND_ACTIVATION_MSG, SEND_ACTIVATION_MSG_DELAY)
|
||||
}
|
||||
|
||||
private fun startReconnectTiming() {
|
||||
handler.removeMessages(MSG_RECONNECT)
|
||||
handler.sendEmptyMessageDelayed(MSG_RECONNECT, RECONNECT_DELAY)
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送激活数据
|
||||
*/
|
||||
private fun sendActivationMsg() {
|
||||
Logger.d(TAG, "准备发送激活消息====")
|
||||
socketManager.sendMsgTo(GsonUtil.jsonFromObject(NcsActivationRequest(unique = unique)), TARGET_IP, TARGET_PORT)
|
||||
startReconnectTiming()
|
||||
}
|
||||
|
||||
override fun handleMessage(msg: Message): Boolean {
|
||||
return when (msg.what) {
|
||||
MSG_SEND_ACTIVATION_MSG -> {
|
||||
sendActivationMsg()
|
||||
true
|
||||
}
|
||||
MSG_RECONNECT -> {
|
||||
if (!handler.hasMessages(MSG_SEND_ACTIVATION_MSG)) {
|
||||
// 没有等待激活,就进行重试
|
||||
Logger.d(TAG, "准备重连===")
|
||||
sendRegisterMsg()
|
||||
}
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
val firstMsg = "{\"tag\":1001}"
|
||||
|
||||
override fun release() {
|
||||
super.release()
|
||||
// 解除注册
|
||||
socketManager.sendMsgTo(GsonUtil.jsonFromObject(NcsUnRegisteredRequest(unique = unique)), TARGET_IP, TARGET_PORT)
|
||||
}
|
||||
|
||||
data class Request<T>(val tag: Int, val data: T)
|
||||
|
||||
/**
|
||||
* 注册请求data
|
||||
*/
|
||||
data class NcsRegisteredData(val ip: String, val port: Int)
|
||||
|
||||
/**
|
||||
* 解注册请求request
|
||||
*/
|
||||
data class NcsUnRegisteredRequest(val tag: Int = 2003, val unique: String)
|
||||
|
||||
/**
|
||||
* 激活请求
|
||||
*/
|
||||
data class NcsActivationRequest(val tag: Int = 2005, val unique: String)
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu.bean
|
||||
|
||||
import com.zhidao.mogo.module.obu.ObuConstant
|
||||
import com.zhidao.smartv2x.model.obu.CarEventInfo
|
||||
|
||||
/**
|
||||
* obu事件数据封装,根据西迪obu数据进行整理
|
||||
*
|
||||
* {"typeCode":"01","type":"前碰撞预警","describe":"等级:1"}
|
||||
*/
|
||||
class MogoObuEventInfo(){
|
||||
var typeCode:String? = null
|
||||
set(value){
|
||||
mogoEventId = parseObuEvent(value)
|
||||
field = value
|
||||
}
|
||||
var type:String? = null
|
||||
var describe:String? = null
|
||||
var mogoEventId:Int = 0
|
||||
override fun toString(): String {
|
||||
return "MogoObuEventInfo(typeCode=$typeCode, type=$type, describe=$describe)"
|
||||
}
|
||||
|
||||
constructor(info:CarEventInfo):this(){
|
||||
this.typeCode = info.typeCode
|
||||
this.type = info.type
|
||||
this.describe = info.describe
|
||||
}
|
||||
|
||||
private fun parseObuEvent(type: String?): Int {
|
||||
return when (type) {
|
||||
"06" -> // 紧急制动预警
|
||||
ObuConstant.TYPE_URGENCY_COLLISION_WARNING
|
||||
"13" -> // 绿波车速引导
|
||||
ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY
|
||||
"39" -> // 行人碰撞预警
|
||||
ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING
|
||||
"vip变灯提醒" -> ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP
|
||||
"01" -> ObuConstant.TYPE_FRONT_COLLISION_WARNING
|
||||
"02" -> ObuConstant.TYPE_CROSS_COLLISION_WARNING
|
||||
"04" -> ObuConstant.TYPE_BLIND_ASSIST_WARN
|
||||
"07" -> ObuConstant.TYPE_UNUSUAL_CAR_WARN
|
||||
"09" -> ObuConstant.TYPE_UNUSUAL_ROAD_WARN
|
||||
"11" -> ObuConstant.TYPE_RUSH_RED_LIGHT
|
||||
"14" -> ObuConstant.TYPE_TRAFFIC_SIGN_INFO
|
||||
"15" -> ObuConstant.TYPE_BLOCK_WARN
|
||||
"16" -> ObuConstant.TYPE_PRESSING_CAR_WARN
|
||||
"20" -> ObuConstant.TYPE_HAS_RUSH_RED_LIGHT
|
||||
"21" -> ObuConstant.TYPE_LANE_CONVERGE_WARN
|
||||
"10" -> ObuConstant.TYPE_LIMIT_SPEED_WARN
|
||||
null -> -1
|
||||
else -> type.toInt()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu.bean
|
||||
|
||||
import com.zhidao.smartv2x.model.obu.CarLocationInfo
|
||||
|
||||
/**
|
||||
* obu定位信息,根据西迪obu进行封装
|
||||
* {"carId":"1952999795","lat":28.089524299999997,"lng":112.9908293,"speed":"14"," direction":"10112","sateNum":"24","signal":"0"}
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class MogoObuLocationInfo() {
|
||||
var carId: String? = null
|
||||
var lat: Double? = 0.0
|
||||
var lon: Double? = 0.0
|
||||
var speed: String? = null
|
||||
var direction: String? = null
|
||||
var sateNum: String? = null
|
||||
var signal: String? = null
|
||||
override fun toString(): String {
|
||||
return "MogoObuLocationInfo(lat=$lat)"
|
||||
}
|
||||
|
||||
constructor(info:CarLocationInfo?) : this() {
|
||||
this.carId = info?.carId
|
||||
this.lat = info?.lat
|
||||
this.lon = info?.lng
|
||||
this.speed = info?.speed
|
||||
this.direction = info?.direction
|
||||
this.sateNum = info?.sateNum
|
||||
this.signal = info?.signal
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.obu.bean
|
||||
|
||||
import com.mogo.module.common.constants.TrafficLightConst.*
|
||||
import com.zhidao.smartv2x.model.obu.TrafficLightInfo
|
||||
|
||||
/**
|
||||
* obu信号灯数据,根据西迪obu进行封装
|
||||
* lightStatus:信号灯的当前状态 G/R/Y 分别对应 绿/红/黄
|
||||
* surplusTime:当前信号灯剩余时间 十进制 单位:秒
|
||||
* lightPriority:保留字段,暂无说明
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
class MogoObuTrafficLightInfo() {
|
||||
var id: String? = null
|
||||
var lightStatus: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
resetLightArray(value)
|
||||
}
|
||||
var surplusTime: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
resetSurplusTimeArray(value)
|
||||
}
|
||||
var lightPriority: String? = null
|
||||
|
||||
var lightArray: IntArray = IntArray(4) { 0 }
|
||||
var surplusTimeArray: Array<String> = Array(4) { "" }
|
||||
|
||||
constructor(info: TrafficLightInfo) : this() {
|
||||
this.id = info.id
|
||||
this.lightStatus = info.lightStatus
|
||||
this.surplusTime = info.surplusTime
|
||||
this.lightPriority = info.lightPriority
|
||||
|
||||
resetLightArray(lightStatus)
|
||||
resetSurplusTimeArray(surplusTime)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "MogoObuTrafficLightInfo(id=$id, lightStatus=$lightStatus, surplusTime=$surplusTime, lightPriority=$lightPriority, lightArray=${lightArray.contentToString()}, surplusTimeArray=${surplusTimeArray.contentToString()})"
|
||||
}
|
||||
|
||||
private fun resetLightArray(lightStatus: String?) {
|
||||
when (lightStatus) {
|
||||
"R" -> {
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_RED
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_RED
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
|
||||
}
|
||||
"Y" -> {
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_YELLOW
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_YELLOW
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
}
|
||||
"G" -> {
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GREEN
|
||||
}
|
||||
else -> {
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = TRAFFIC_LIGHT_COLOR_GRAY
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = TRAFFIC_LIGHT_COLOR_GRAY
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = TRAFFIC_LIGHT_COLOR_GRAY
|
||||
lightArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = TRAFFIC_LIGHT_COLOR_GRAY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resetSurplusTimeArray(surplusTime: String?) {
|
||||
surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_AROUND] = ""
|
||||
surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_LEFT] = surplusTime ?: ""
|
||||
surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_STRAIGHT] = surplusTime ?: ""
|
||||
surplusTimeArray[TRAFFIC_LIGHT_DIRECTION_TURN_RIGHT] = ""
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.socket
|
||||
|
||||
/**
|
||||
* udp 数据回调
|
||||
*/
|
||||
interface ISocketMsgCallback {
|
||||
/**
|
||||
* udp过来的字节码数据,目前已知数据类型就是ByteArray
|
||||
*
|
||||
* @param msg udp发过来的数据
|
||||
*/
|
||||
fun onMessageReceived(msg: ByteArray)
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.socket
|
||||
|
||||
/**
|
||||
* udp 数据回调
|
||||
*/
|
||||
interface IUdpSocketCallback {
|
||||
/**
|
||||
* udp过来的字节码数据,目前已知数据类型就是ByteArray
|
||||
*
|
||||
* @param msg udp发过来的数据
|
||||
*/
|
||||
fun onMessageReceived(msg: ByteArray)
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.socket
|
||||
|
||||
/**
|
||||
* udp状态回调
|
||||
*/
|
||||
interface IUdpSocketStatusCallback:ISocketMsgCallback {
|
||||
/**
|
||||
* udp连接准备完毕,指的是准备好接收数据了
|
||||
*/
|
||||
fun isReady()
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.socket
|
||||
|
||||
class SimpleAddress(val ip: String, val port: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return when (other) {
|
||||
is SimpleAddress -> other.ip == ip && port == port
|
||||
null -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return ip.hashCode() + port.hashCode()
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "SimpleAddress(ip='$ip', port=$port)"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.socket
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import com.mogo.utils.logger.Logger
|
||||
import java.io.*
|
||||
import java.lang.Exception
|
||||
import java.net.InetAddress
|
||||
import java.net.Socket
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* socket连接简单实现,仅支持连接一路socket,只接受数据
|
||||
*/
|
||||
class SimpleSocketManager(private val callback: IUdpSocketCallback? = null) {
|
||||
companion object {
|
||||
const val TAG = "SimpleSocketManager"
|
||||
}
|
||||
|
||||
private val dataCacheThread = HandlerThread("obu-data-cache")
|
||||
private val dataCacheHandler: Handler
|
||||
|
||||
init {
|
||||
dataCacheThread.start()
|
||||
dataCacheHandler = Handler(dataCacheThread.looper)
|
||||
}
|
||||
|
||||
private var socket: Socket? = null
|
||||
private val socketExecutor = Executors.newCachedThreadPool()
|
||||
fun connect(ip: String, port: Int) {
|
||||
socketExecutor.execute {
|
||||
realConnect(ip, port)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun realConnect(ip: String, port: Int) {
|
||||
try {
|
||||
Logger.d(TAG, "socket connect===ip: $ip, port: $port ====++++")
|
||||
val address = InetAddress.getByName(ip)
|
||||
Logger.d(TAG, "address: $address")
|
||||
socket = Socket(address, port)
|
||||
socket?.let {
|
||||
Logger.d(TAG, "socket连接基本成功,准备接受数据")
|
||||
// 超时时间10秒
|
||||
// it.soTimeout = 10_000
|
||||
|
||||
// Logger.d(TAG,"设置了超时时间")
|
||||
val buffer = ByteArray(2048)
|
||||
var result: Int
|
||||
do {
|
||||
result = it.getInputStream().read(buffer)
|
||||
if (result != -1) {
|
||||
Logger.d(TAG, "收到obu数据")
|
||||
val msg = ByteArray(buffer.size)
|
||||
System.arraycopy(buffer, 0, msg, 0, buffer.size)
|
||||
dataCacheHandler.post {
|
||||
callback?.onMessageReceived(msg)
|
||||
}
|
||||
}
|
||||
} while (result != -1)
|
||||
|
||||
}
|
||||
}catch (e:Exception){
|
||||
e.printStackTrace()
|
||||
Logger.e(TAG, e, "udp连接异常")
|
||||
Thread.sleep(10_000)
|
||||
connect(ip,port)
|
||||
}
|
||||
}
|
||||
|
||||
fun sendMessage(msg: String) {
|
||||
Logger.d(TAG, "暂不支持发送消息")
|
||||
}
|
||||
|
||||
fun release(){
|
||||
socket?.close()
|
||||
dataCacheHandler.looper.quitSafely()
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
package com.zhidao.mogo.module.obu.socket
|
||||
|
||||
import android.content.Context
|
||||
import android.net.wifi.WifiManager
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.util.ArrayMap
|
||||
import com.mogo.utils.NetworkUtils
|
||||
import com.mogo.utils.logger.Logger
|
||||
import java.lang.Thread.sleep
|
||||
import java.net.DatagramPacket
|
||||
import java.net.DatagramSocket
|
||||
import java.net.InetAddress
|
||||
import java.util.concurrent.Executors
|
||||
|
||||
/**
|
||||
* udp socket 管理类,统一管理udp socket数据接收和发送
|
||||
*/
|
||||
class UdpSocketManager(val context: Context? = null, useDefaultAddress: Boolean = false, private val callback: IUdpSocketStatusCallback? = null) {
|
||||
companion object {
|
||||
const val TAG = "Mogo-UdpSocketManager"
|
||||
const val DEFAULT_PORT = 50501
|
||||
const val DEFAULT_IP = "192.168.8.169"
|
||||
}
|
||||
|
||||
private val socketMap = ArrayMap<SimpleAddress, DatagramSocket>()
|
||||
private val socketExecutor = Executors.newCachedThreadPool()
|
||||
|
||||
private val dataCacheThread = HandlerThread("obu-data-cache")
|
||||
private val dataCacheHandler: Handler
|
||||
|
||||
var defaultAddress:SimpleAddress? = null
|
||||
|
||||
init {
|
||||
dataCacheThread.start()
|
||||
dataCacheHandler = Handler(dataCacheThread.looper)
|
||||
if (useDefaultAddress) {
|
||||
// 获取连接的wifi的ip地址
|
||||
if (context == null) {
|
||||
throw IllegalArgumentException("do not find context at constructor")
|
||||
}else{
|
||||
// defaultAddress = SimpleAddress(DEFAULT_IP, DEFAULT_PORT)
|
||||
// receiveMsgFrom(DEFAULT_IP, DEFAULT_PORT)
|
||||
if (NetworkUtils.isConnectedWifi(context)) {
|
||||
// 已经判定连接到了wifi
|
||||
generateDefaultAddress()
|
||||
}else{
|
||||
// 还没连接到wifi,需要等待,此处采用每隔一秒检查一次,不用再注册相关监听广播
|
||||
dataCacheHandler.post {
|
||||
while (!NetworkUtils.isConnectedWifi(context)) {
|
||||
sleep(1000)
|
||||
}
|
||||
// 已经连接到wifi
|
||||
generateDefaultAddress()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var isConnected = false
|
||||
|
||||
fun sendMsgTo(msg: String, ip: String, port: Int) {
|
||||
Logger.d(TAG, "sendMsg: $msg to $ip:$port")
|
||||
isConnected = true
|
||||
val address = SimpleAddress(ip, port)
|
||||
socketExecutor.execute(UdpSenderRunnable(address, msg))
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅获取连接wifi后的ip地址,使用默认端口进行数据接收
|
||||
*/
|
||||
private fun generateDefaultAddress(){
|
||||
context?.let {
|
||||
val wifiManager = it.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
||||
val wifiInfo = wifiManager.connectionInfo
|
||||
val ip = intIp2StringIp(wifiInfo.ipAddress)
|
||||
Logger.d(TAG, "获取到本机ip地址: $ip")
|
||||
defaultAddress = SimpleAddress(ip, DEFAULT_PORT)
|
||||
// 生成了默认地址,开始准备接受数据
|
||||
receiveMsgFrom(ip, DEFAULT_PORT)
|
||||
}
|
||||
}
|
||||
|
||||
private fun intIp2StringIp(ip: Int):String {
|
||||
return "${ip and 0xff}.${(ip shr 8) and 0xff}.${(ip shr 16) and 0xff}.${(ip shr 24) and 0xff}"
|
||||
}
|
||||
|
||||
private var isReady = false
|
||||
|
||||
fun receiveMsgFrom(ip: String, port: Int) {
|
||||
isConnected = true
|
||||
val address = SimpleAddress(ip, port)
|
||||
socketExecutor.execute(UdpReceiverRunnable(address))
|
||||
}
|
||||
|
||||
fun release() {
|
||||
isConnected = false
|
||||
socketMap.forEach {
|
||||
it.value.close()
|
||||
}
|
||||
}
|
||||
|
||||
inner class UdpSenderRunnable(private val address: SimpleAddress, private val msg: String) : Runnable {
|
||||
override fun run() {
|
||||
Logger.d(TAG, "${address}准备发送消息: $msg")
|
||||
var socket = socketMap[address]
|
||||
val netAddress = InetAddress.getByName(address.ip)
|
||||
if (socket == null) {
|
||||
socket = DatagramSocket(address.port)
|
||||
socketMap[address] = socket
|
||||
}
|
||||
socket.send(DatagramPacket(msg.toByteArray(), msg.toByteArray().size, netAddress, address.port))
|
||||
}
|
||||
}
|
||||
|
||||
inner class UdpReceiverRunnable(private val address: SimpleAddress) : Runnable {
|
||||
override fun run() {
|
||||
var socket = socketMap[address]
|
||||
Logger.d(TAG, "init receiver: $address")
|
||||
|
||||
if (socket == null) {
|
||||
socket = DatagramSocket(address.port)
|
||||
socketMap[address] = socket
|
||||
}
|
||||
val buffer = ByteArray(2048)
|
||||
val packet = DatagramPacket(buffer, buffer.size)
|
||||
while (isConnected) {
|
||||
if (socket.isClosed) {
|
||||
break
|
||||
}
|
||||
if (!isReady) {
|
||||
isReady = true
|
||||
callback?.isReady()
|
||||
}
|
||||
Logger.d(TAG, "准备接受消息====$address")
|
||||
socket.receive(packet)
|
||||
val msg = ByteArray(buffer.size)
|
||||
System.arraycopy(buffer, 0, msg, 0, buffer.size)
|
||||
dataCacheHandler.post {
|
||||
// 换一条线程处理
|
||||
callback?.onMessageReceived(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:columnCount="4">
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnGreen"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="绿灯"
|
||||
android:textSize="30sp"
|
||||
android:padding="10dp"
|
||||
android:background="#0f0" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnRed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="红灯"
|
||||
android:textSize="30sp"
|
||||
android:padding="10dp"
|
||||
android:background="#f00" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnYello"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="黄灯"
|
||||
android:textSize="30sp"
|
||||
android:padding="10dp"
|
||||
android:background="#F7F709" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnChangeTime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="改变时间"
|
||||
android:textSize="30sp"
|
||||
android:padding="10dp"
|
||||
android:background="#FF00FF" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnShowLimitSpeed"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="修改限速"
|
||||
android:textSize="30sp"
|
||||
android:padding="10dp"
|
||||
android:background="#FF00FF" />
|
||||
|
||||
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btnVip"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="vip同行" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btnRushRedLight"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="闯红灯" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btnOptimizeSpeed"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="绿波车速" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btnCrossCrash"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="交叉口碰撞" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btnPersonCrash"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="行人碰撞" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btnStartTrafficLight"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="开始红绿灯倒计时" />-->
|
||||
|
||||
<!-- <Button-->
|
||||
<!-- android:id="@+id/btnStopTrafficLight"-->
|
||||
<!-- android:layout_width="wrap_content"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:text="停止红绿灯倒计时" />-->
|
||||
|
||||
</GridLayout>
|
||||
@@ -79,7 +79,6 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.modulecommon
|
||||
implementation rootProject.ext.dependencies.moduleservice
|
||||
implementation rootProject.ext.dependencies.moduleobu
|
||||
implementation rootProject.ext.dependencies.callchatprovider
|
||||
|
||||
implementation rootProject.ext.dependencies.mogo_core_res
|
||||
@@ -92,7 +91,6 @@ dependencies {
|
||||
implementation project(':services:mogo-service-api')
|
||||
implementation project(':modules:mogo-module-common')
|
||||
implementation project(':modules:mogo-module-service')
|
||||
implementation project(':modules:mogo-module-obu')
|
||||
implementation project(':modules:mogo-module-carchattingprovider')
|
||||
|
||||
implementation project(':core:mogo-core-res')
|
||||
|
||||
@@ -149,8 +149,7 @@ public class V2XModuleProvider implements
|
||||
intentFilter.addAction(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
localBroadcastManager.registerReceiver(localReceiver, intentFilter);
|
||||
|
||||
// obu数据转发初始化
|
||||
V2XObuManager.getInstance().init(context);
|
||||
|
||||
if (V2XServiceManager.getMoGoStatusManager().isTopContainerReady()) {
|
||||
V2XServiceManager.getV2XRefreshModel().queryRoadData(MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
}
|
||||
|
||||
@@ -1,395 +0,0 @@
|
||||
package com.mogo.module.v2x;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.listener.V2XLocationListener;
|
||||
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
|
||||
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.service.entrance.IMogoEntranceButtonController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
import com.zhidao.mogo.module.obu.ObuManager;
|
||||
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 org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.V2XServiceManager.getContext;
|
||||
import static com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario.ACTION_LAUNCHER_ADAS_APP_BIZ;
|
||||
|
||||
//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;
|
||||
|
||||
/**
|
||||
* obu数据管理类封装
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuManager implements IObuCallback, Handler.Callback {
|
||||
private static final String TAG = V2XObuManager.class.getSimpleName();
|
||||
|
||||
private static final long DEFAULT_INTERVAL_TIME = 30_000L;
|
||||
|
||||
private V2XObuManager() {
|
||||
}
|
||||
|
||||
private volatile static V2XObuManager instance = null;
|
||||
|
||||
public static V2XObuManager getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (V2XObuManager.class) {
|
||||
if (instance == null) {
|
||||
instance = new V2XObuManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private static final int MSG_HIDE_TRAFFIC_LIGHT = 1001;
|
||||
private static final long DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY = 1500L;
|
||||
private final Handler handler = new Handler(this);
|
||||
private final ObuTypeExchangeReceiver obuTypeExchangeReceiver = new ObuTypeExchangeReceiver();
|
||||
private ObuManager obuManager;
|
||||
final String icw_data = "02000114010000000000001effd7892b11a4440af70100142a03000907e506100e2917019000005662010a45000b0000220847162c000037970010000a17f6215c459478b6010347ac045000090a0006012c01f4009600080073007300730073000b000000000000000000000000000000002b000037780000247300003261000000000000426c827f47001200100000000000000000000021220000349a006c0010000a17f63ecb45947ba301030000332c0010000a17f642e945947bea010300004d580010000a17f6435545947e4e0103000054c40010000a17f6413a45947f96010300005c300010000a17f62c2845947d140103000070e40010000a17f5fdb14594786001030000992000060004ffec2710";
|
||||
|
||||
public void init(Context context) {
|
||||
Logger.d(MODULE_NAME, "obuManager初始化--");
|
||||
//之前内部对接的obu
|
||||
obuManager = new ObuManager();
|
||||
obuManager.init(context);
|
||||
obuManager.registerObuDataChangedListener(this);
|
||||
|
||||
//使用adas部门obu sdk (星云)
|
||||
// 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 星云obu数据监听
|
||||
*/
|
||||
// private OnObuListener listener = new OnObuListener() {
|
||||
// @Override
|
||||
// public void onRegister() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onConnectFail(boolean isNeedReconnect) {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onUnregister() {
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onObuInfo(ObuInfo info) {
|
||||
// }
|
||||
//
|
||||
// @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(2);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
private void handleSdkObu(int type) {
|
||||
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
|
||||
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
|
||||
|
||||
V2XObuEventEntity urgencyEvent = new V2XObuEventEntity();
|
||||
if (type == ObuConstant.TYPE_CROSS_COLLISION_WARNING) { //交叉路口碰撞预警
|
||||
urgencyEvent.setType(ObuConstant.TYPE_CROSS_COLLISION_WARNING);
|
||||
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_CROING_WARN_TEXT);
|
||||
} else if (type == ObuConstant.TYPE_URGENCY_COLLISION_WARNING) { // 前车紧急制动预警
|
||||
urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
|
||||
urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
|
||||
} else { //TODO
|
||||
// urgencyEvent.setType(ObuConstant.TYPE_URGENCY_COLLISION_WARNING);
|
||||
// urgencyEvent.setDesc(V2XObuEventScenario.URGENCY_COLLISION_WARN_TEXT);
|
||||
}
|
||||
|
||||
messageEntity.setContent(urgencyEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用来处理30秒内不重复播报的情况
|
||||
*/
|
||||
private final Map<String, Long> intervalMap = new ArrayMap<>();
|
||||
|
||||
private int parseObuEvent(String type) {
|
||||
switch (type) {
|
||||
case "06":
|
||||
// 紧急制动预警
|
||||
return ObuConstant.TYPE_URGENCY_COLLISION_WARNING;
|
||||
case "13":
|
||||
// 绿波车速引导
|
||||
return ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY;
|
||||
case "39":
|
||||
// 行人碰撞预警
|
||||
return ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING;
|
||||
case "vip变灯提醒":
|
||||
return ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private final MogoLocation[] historyPath = new MogoLocation[2];
|
||||
|
||||
private float computeCarAngle(MogoLocation location) {
|
||||
float angle = 0f;
|
||||
if (historyPath[0] != null) {
|
||||
historyPath[1] = historyPath[0];
|
||||
}
|
||||
historyPath[0] = location;
|
||||
|
||||
if (historyPath[1] != null && historyPath[0] != null) {
|
||||
double carAngle =
|
||||
DrivingDirectionUtils.getCarAngle(
|
||||
historyPath[1].getLatitude(), historyPath[1].getLongitude(),
|
||||
historyPath[0].getLatitude(), historyPath[0].getLongitude()
|
||||
);
|
||||
// 这里是真实的车辆角度
|
||||
angle = (float) carAngle;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
private static final String CALL_ADAS_SHOW_TRAFFIC_LIGHT = "2";
|
||||
private static final String CALL_ADAS_HIDE_TRAFFIC_LIGHT = "1";
|
||||
|
||||
private void sendTrafficLightStatusToAdas(String status, MogoObuTrafficLightInfo trafficLightInfo) {
|
||||
if (V2XObuEventScenario.getInstance().isInChangeLightForVip()) {
|
||||
status = CALL_ADAS_HIDE_TRAFFIC_LIGHT;
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_LAUNCHER_ADAS_APP_BIZ);
|
||||
JSONObject json = new JSONObject();
|
||||
// String action "1" - 隐藏 "2" - 显示
|
||||
json.put("action", status);
|
||||
if (trafficLightInfo != null) {
|
||||
if (trafficLightInfo.getLightStatus() == null) {
|
||||
json.put("lightStatus", "G");
|
||||
} else {
|
||||
json.put("lightStatus", trafficLightInfo.getLightStatus());
|
||||
}
|
||||
if (trafficLightInfo.getSurplusTime() == null) {
|
||||
json.put("surplusTime", "0");
|
||||
} else {
|
||||
json.put("surplusTime", trafficLightInfo.getSurplusTime());
|
||||
}
|
||||
JSONArray lightJsonArray = new JSONArray(trafficLightInfo.getLightArray());
|
||||
JSONArray surplusTimeJsonArray = new JSONArray(trafficLightInfo.getSurplusTimeArray());
|
||||
json.put("lightArray", lightJsonArray);
|
||||
json.put("surplusTimeArray", surplusTimeJsonArray);
|
||||
}
|
||||
String data = json.toString();
|
||||
Logger.d(MODULE_NAME, "发送红绿灯广播: " + data);
|
||||
intent.putExtra("data", data);
|
||||
intent.putExtra("type", 2);
|
||||
getContext().sendBroadcast(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(MODULE_NAME, e, "发送红绿灯广播异常==");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (msg.what == MSG_HIDE_TRAFFIC_LIGHT) {
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_HIDE_TRAFFIC_LIGHT, null);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEventInfoCallback(MogoObuEventInfo info) {
|
||||
//Logger.d("V2X_OBU_EVENT", "carEventInfo==" + info);
|
||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||
//Logger.d("V2X_OBU_EVENT", "vr模式下不展示obu事件");
|
||||
return;
|
||||
}
|
||||
Long last = intervalMap.get(info.getTypeCode());
|
||||
if (last == null) {
|
||||
last = 0L;
|
||||
}
|
||||
// int eventType = parseObuEvent(info.getTypeCode());
|
||||
int eventType = info.getMogoEventId();
|
||||
if (eventType == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY && DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
// 加一个容错机制,如果已经驶过绿波车速路口,那么再收到绿波车速obu事件,就不再上报
|
||||
MogoLocation currentLocation = V2XLocationListener.getInstance().getLastCarLocation();
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
currentLocation.getLongitude(),
|
||||
currentLocation.getLatitude(),
|
||||
V2XObuEventScenario.getInstance().getOptimalCrossing().getLon(),
|
||||
V2XObuEventScenario.getInstance().getOptimalCrossing().getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
);
|
||||
if (0 > eventAngle || eventAngle > 20) {
|
||||
Logger.e(MODULE_NAME, "超出绿波引导点范围,不处理此次事件===" + eventAngle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (SystemClock.elapsedRealtime() - last > DEFAULT_INTERVAL_TIME || DebugConfig.getObuType() == DebugConfig.OBU_TYPE_HUALI) {
|
||||
// 距离上次记录超过三十秒,继续相关逻辑,如果不超过三十秒,忽略此次事件
|
||||
// 华砺智行obu暂时去掉此判断
|
||||
intervalMap.put(info.getTypeCode(), SystemClock.elapsedRealtime());
|
||||
V2XMessageEntity<V2XObuEventEntity> messageEntity = new V2XMessageEntity<>();
|
||||
messageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_OBU_EVENT);
|
||||
switch (eventType) {
|
||||
case ObuConstant
|
||||
.TYPE_OPTIMAL_SPEED_ADVISORY:
|
||||
// 绿波车速引导
|
||||
V2XObuEventEntity optimalEvent = new V2XObuEventEntity();
|
||||
optimalEvent.setType(ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY);
|
||||
optimalEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(optimalEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_URGENCY_COLLISION_WARNING:
|
||||
// 前车紧急制动预警
|
||||
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);
|
||||
V2XServiceManager.getMogoEntranceButtonController().showLeftNoticeByType(IMogoEntranceButtonController.NOTICE_TYPE_SUDDENLY_BREAK, R.drawable.module_v2x_suddenly_break, "前车急刹,保持车距");
|
||||
break;
|
||||
case ObuConstant.TYPE_ROAD_USER_COLLISION_WARNING:
|
||||
// 行人预警,给adas发送广播即可
|
||||
V2XPushMessageEntity entity = new V2XPushMessageEntity();
|
||||
// 盲区行人预警的sceneId-100003
|
||||
entity.setSceneId("100003");
|
||||
entity.setTts("前方行人,注意减速");
|
||||
entity.setExpireTime(30_000);
|
||||
entity.setAlarmContent("前方行人,注意减速");
|
||||
ADASUtils.broadcastToADAS(getContext(), entity);
|
||||
break;
|
||||
case ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP:
|
||||
// vip变灯提醒
|
||||
V2XObuEventEntity changeLightEvent = new V2XObuEventEntity();
|
||||
changeLightEvent.setType(ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP);
|
||||
changeLightEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(changeLightEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_RUSH_RED_LIGHT:
|
||||
// 闯红灯预警
|
||||
V2XObuEventEntity rushRedLightEvent = new V2XObuEventEntity();
|
||||
rushRedLightEvent.setType(ObuConstant.TYPE_RUSH_RED_LIGHT);
|
||||
rushRedLightEvent.setDesc(info.getDescribe());
|
||||
messageEntity.setContent(rushRedLightEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
case ObuConstant.TYPE_CROSS_COLLISION_WARNING:
|
||||
// 交叉口碰撞预警
|
||||
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
|
||||
TestOnLineCarUtils.getV2XScenarioCrossCrash();
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
|
||||
break;
|
||||
case ObuConstant.TYPE_BLIND_ASSIST_WARN:
|
||||
case ObuConstant.TYPE_HAS_RUSH_RED_LIGHT:
|
||||
case ObuConstant.TYPE_LANE_CONVERGE_WARN:
|
||||
case ObuConstant.TYPE_LIMIT_SPEED_WARN:
|
||||
case ObuConstant.TYPE_PRESSING_CAR_WARN:
|
||||
case ObuConstant.TYPE_TRAFFIC_SIGN_INFO:
|
||||
case ObuConstant.TYPE_BLOCK_WARN:
|
||||
case ObuConstant.TYPE_FRONT_COLLISION_WARNING:
|
||||
case ObuConstant.TYPE_UNUSUAL_CAR_WARN:
|
||||
case ObuConstant.TYPE_UNUSUAL_ROAD_WARN:
|
||||
// 暂无设计图,先简单显示
|
||||
V2XObuEventEntity tmpEvent = new V2XObuEventEntity();
|
||||
tmpEvent.setType(eventType);
|
||||
tmpEvent.setDesc(info.getType() + "--" + info.getDescribe());
|
||||
messageEntity.setContent(tmpEvent);
|
||||
V2XObuEventScenario.getInstance().init(messageEntity);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "未超过时限,不展示事件");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationInfoCallback(MogoObuLocationInfo locationInfo) {
|
||||
if (ObuConfig.useObuLocation) {
|
||||
MogoLocation currentLocation = new MogoLocation();
|
||||
|
||||
double coor[] = CoordinateUtils.transformWgsToGcj(locationInfo.getLat(), locationInfo.getLon());
|
||||
|
||||
currentLocation.setLatitude(coor[1]);
|
||||
currentLocation.setLongitude(coor[0]);
|
||||
currentLocation.setBearing(computeCarAngle(currentLocation));
|
||||
|
||||
V2XObuEventScenario.getInstance().updateLocation(currentLocation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrafficLightInfoCallback(MogoObuTrafficLightInfo trafficLightInfo) {
|
||||
handler.removeMessages(MSG_HIDE_TRAFFIC_LIGHT);
|
||||
if (trafficLightInfo == null) {
|
||||
Logger.d("V2X_OBU_EVENT", "红绿灯数据为空===");
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_HIDE_TRAFFIC_LIGHT, null);
|
||||
} else {
|
||||
Logger.d("V2X_OBU_EVENT", "红绿灯数据==" + trafficLightInfo);
|
||||
handler.sendEmptyMessageDelayed(MSG_HIDE_TRAFFIC_LIGHT,
|
||||
DEFAULT_HIDE_TRAFFIC_LIGHT_DELAY);
|
||||
sendTrafficLightStatusToAdas(CALL_ADAS_SHOW_TRAFFIC_LIGHT, trafficLightInfo);
|
||||
}
|
||||
}
|
||||
|
||||
class ObuTypeExchangeReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
int obuType = intent.getIntExtra("obuType", DebugConfig.OBU_TYPE_CIDI);
|
||||
obuManager.resetObuType(obuType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package com.mogo.module.v2x.listener;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
import com.mogo.map.location.IMogoLocationListener;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearchListener;
|
||||
@@ -27,12 +29,10 @@ import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.observer.CarLocationSubject;
|
||||
import com.mogo.module.v2x.observer.V2XOptimalRouteObserver;
|
||||
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
|
||||
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
import com.mogo.module.v2x.utils.DrivingDirectionUtils;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.module.v2x.utils.MarkerUtils;
|
||||
import com.mogo.module.v2x.utils.ObuConfig;
|
||||
import com.mogo.module.v2x.utils.TrackUtils;
|
||||
import com.mogo.module.v2x.utils.V2XSQLiteUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
@@ -41,8 +41,6 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
@@ -222,10 +220,6 @@ public class V2XLocationListener
|
||||
V2XServiceManager.getIMogoTrafficUploadProvider().verifyCurrentTrafficStatus();
|
||||
}
|
||||
}
|
||||
if (!ObuConfig.useObuLocation) {
|
||||
// 绿波车速引导刷新划线
|
||||
V2XObuEventScenario.getInstance().updateLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
public MogoLocation getLastCarLocation() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.module.v2x.scenario.scene.help;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.CountDownTimer;
|
||||
import android.view.View;
|
||||
@@ -23,8 +25,6 @@ import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.storage.SharedPrefsMgr;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* @ProjectName: MoGoModulSafeDriving
|
||||
* @Package: com.mogo.module.v2x.scenario.scene
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.marker.OptimalSpeedMarkerView;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
|
||||
|
||||
/**
|
||||
* 绿波车速的marker
|
||||
*/
|
||||
class OptimalSpeedMarker implements IV2XMarker<MogoLatLng> {
|
||||
|
||||
private IMogoMarker optimalMarker = null;
|
||||
|
||||
@Override
|
||||
public void drawPOI(MogoLatLng entity) {
|
||||
Logger.d(MODULE_NAME, "绘制绿波marker===" + entity);
|
||||
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(entity.getLat())
|
||||
.longitude(entity.getLon())
|
||||
.anchor(0.5f, 0.9f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_OPTIMAL_SPEED_MARKER, optionsRipple);
|
||||
optimalMarker.setInfoWindowAdapter(new SimpleWindow3DAdapter(new OptimalSpeedMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker.showInfoWindow();
|
||||
} else {
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new OptimalSpeedMarkerView(V2XServiceManager.getContext())));
|
||||
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_OPTIMAL_SPEED_MARKER, optionsRipple);
|
||||
}
|
||||
if (optimalMarker != null) {
|
||||
optimalMarker.setClickable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
Logger.d(MODULE_NAME, "准备清除绿波marker");
|
||||
if (optimalMarker != null) {
|
||||
Logger.d(MODULE_NAME, "清除绿波marker===" + optimalMarker);
|
||||
optimalMarker.remove();
|
||||
optimalMarker = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
import com.mogo.module.service.Utils;
|
||||
import com.mogo.module.v2x.V2XObuManager;
|
||||
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.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
import com.zhidao.mogo.module.obu.obu.bean.MogoObuEventInfo;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* obu场景界面管理
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuEventScenario extends AbsV2XScenario<V2XObuEventEntity> implements Handler.Callback {
|
||||
|
||||
public static final String URGENCY_COLLISION_WARN_TEXT_ONE = "前车急刹,注意保持安全距离!";
|
||||
public static final String URGENCY_COLLISION_WARN_TEXT = "前车急刹";
|
||||
public static final String URGENCY_CROING_WARN_TEXT = "注意交叉路口车辆";
|
||||
|
||||
private static final int MSG_CLOSE_OBU_WINDOW = 1001;
|
||||
private static final int DEFAULT_EXPIRE_TIME = 20_000;
|
||||
|
||||
private static final float DEFAULT_VIP_CROSSING_DISTANCE = 100F;
|
||||
|
||||
/**
|
||||
* 可以关闭绿波引导的距离路口的最大距离,单位是米
|
||||
*/
|
||||
private static final float DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL = 10F;
|
||||
|
||||
private IMogoPolyline optimalLine = null;
|
||||
private MogoLatLng defaultTarget = new MogoLatLng(39.969326, 116.407788);
|
||||
|
||||
private MogoLatLng optimalCrossing = new MogoLatLng(40.196431,116.738011);
|
||||
// private MogoLatLng vipCrossing = new MogoLatLng(40.200467,116.745498);
|
||||
|
||||
|
||||
private MogoLatLng vipCrossing1 = new MogoLatLng(40.200467,116.745498);
|
||||
private MogoLatLng vipCrossing2 = new MogoLatLng(40.200491,116.738535);
|
||||
private List<MogoLatLng> vipCrossingList = Arrays.asList(vipCrossing1, vipCrossing2);
|
||||
|
||||
private V2XObuEventScenario() {
|
||||
}
|
||||
|
||||
private volatile static V2XObuEventScenario instance = null;
|
||||
|
||||
public static V2XObuEventScenario getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (V2XObuEventScenario.class) {
|
||||
if (instance == null) {
|
||||
instance = new V2XObuEventScenario();
|
||||
instance.setV2XWindow(new V2XObuEventWindow(V2XServiceManager.getContext()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private V2XMessageEntity<V2XObuEventEntity> lastMessage = null;
|
||||
|
||||
private OptimalSpeedMarker optimalSpeedMarker = null;
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper(), this);
|
||||
|
||||
@Override
|
||||
public void init(@Nullable V2XMessageEntity<V2XObuEventEntity> v2XMessageEntity) {
|
||||
Logger.d(MODULE_NAME, "obu场景初始化: " + v2XMessageEntity);
|
||||
setV2XMessageEntity(v2XMessageEntity);
|
||||
if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY&& DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
// 如果需要区分路口,就在这里做一下判断,给默认目标点赋值
|
||||
defaultTarget = optimalCrossing;
|
||||
if (optimalSpeedMarker == null) {
|
||||
optimalSpeedMarker = new OptimalSpeedMarker();
|
||||
} else {
|
||||
optimalSpeedMarker.clearPOI();
|
||||
}
|
||||
} else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
// vip变灯提醒
|
||||
isInChangeLightForVip = true;
|
||||
V2XObuManager.getInstance().onTrafficLightInfoCallback(null);
|
||||
|
||||
if (optimalSpeedMarker == null) {
|
||||
optimalSpeedMarker = new OptimalSpeedMarker();
|
||||
} else {
|
||||
optimalSpeedMarker.clearPOI();
|
||||
}
|
||||
} else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_CROSS_COLLISION_WARNING && !isCrossWarning) {
|
||||
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_CROING_WARN_TEXT);
|
||||
isCrossWarning = true;
|
||||
} else if (v2XMessageEntity.getContent().getType() == ObuConstant.TYPE_URGENCY_COLLISION_WARNING && !isUrgenchyWarning) {
|
||||
AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE);
|
||||
isUrgenchyWarning = true;
|
||||
}
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
private boolean isCrossWarning;
|
||||
private boolean isUrgenchyWarning;
|
||||
|
||||
|
||||
/**
|
||||
* 展示场景
|
||||
* <p>
|
||||
* 此场景需要语音提示和弹窗
|
||||
*/
|
||||
@Override
|
||||
public void show() {
|
||||
// AIAssist.getInstance(V2XServiceManager.getContext()).speakTTSVoice(URGENCY_COLLISION_WARN_TEXT_ONE);
|
||||
showWindow();
|
||||
if (handler.hasMessages(MSG_CLOSE_OBU_WINDOW)) {
|
||||
handler.removeMessages(MSG_CLOSE_OBU_WINDOW);
|
||||
}
|
||||
handler.sendEmptyMessageDelayed(MSG_CLOSE_OBU_WINDOW, DEFAULT_EXPIRE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示Window
|
||||
*/
|
||||
@Override
|
||||
public void showWindow() {
|
||||
if (lastMessage != null && lastMessage.getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "上一条消息是绿波,发送隐藏广播===");
|
||||
// 上一条信息是绿波,需要隐藏上一条信息
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
}
|
||||
|
||||
if (lastMessage != null && lastMessage.getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"上一条是vip变灯,需要先把线隐藏===");
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = getV2XMessageEntity();
|
||||
getV2XWindow().show(getV2XMessageEntity().getContent());
|
||||
getV2XWindow().setWindowStatusListener(new V2XWindowStatusListener() {
|
||||
@Override
|
||||
public void onViewShow() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewClose() {
|
||||
// 只在上滑关闭topview的时候回调
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "关闭绿波浮窗,通知adas==");
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"关闭vip变灯浮窗,隐藏line");
|
||||
isInChangeLightForVip = false;
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = null;
|
||||
}
|
||||
});
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
// 给adas发送显示绿波的广播
|
||||
Logger.d(MODULE_NAME, "收到绿波时间,发送广播给adas");
|
||||
sendBroadcastToAdas(CALL_ADAS_SHOW_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"收到vip变灯,画线");
|
||||
drawLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭Window
|
||||
*/
|
||||
@Override
|
||||
public void closeWindow() {
|
||||
Logger.d(MODULE_NAME, "obu场景关闭window");
|
||||
handler.removeMessages(MSG_CLOSE_OBU_WINDOW);
|
||||
getV2XWindow().close();
|
||||
// 给adas发送隐藏绿波的广播
|
||||
if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_OPTIMAL_SPEED_ADVISORY) {
|
||||
Logger.d(MODULE_NAME, "关闭绿波浮窗,通知adas==");
|
||||
sendBroadcastToAdas(CALL_ADAS_HIDE_OPTIMAL);
|
||||
} else if (getV2XMessageEntity().getContent().getType() == ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP) {
|
||||
Logger.d(MODULE_NAME,"关闭vip变灯浮窗");
|
||||
isInChangeLightForVip = false;
|
||||
hideLine();
|
||||
}
|
||||
lastMessage = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示按钮
|
||||
*/
|
||||
@Override
|
||||
public void showButton() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭按钮
|
||||
*/
|
||||
@Override
|
||||
public void closeButton() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制POI
|
||||
*/
|
||||
@Override
|
||||
public void drawPOI() {
|
||||
if (optimalSpeedMarker != null) {
|
||||
Logger.d(MODULE_NAME, "绘制obu Poi点");
|
||||
optimalSpeedMarker.drawPOI(defaultTarget);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除POI
|
||||
*/
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
if (optimalSpeedMarker != null) {
|
||||
Logger.d(MODULE_NAME, "清除obu Poi点");
|
||||
optimalSpeedMarker.clearPOI();
|
||||
optimalSpeedMarker = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当定位发生变化时,调用此方法,在此方法中,根据当前状态判断是否需要消费此定位事件
|
||||
* <p>
|
||||
* 主要目的是更新绿波速度引导的划线
|
||||
*
|
||||
* @param currentLocation 更新后的定位信息
|
||||
*/
|
||||
public void updateLocation(MogoLocation currentLocation) {
|
||||
MogoLatLng currentLatLng = new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
if (optimalLine != null) {
|
||||
float distance = Utils.calculateLineDistance(defaultTarget, currentLatLng);
|
||||
if (distance <= DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL) {
|
||||
// 目标点和自身点小于DEFAULT_DISTANCE_TO_CLOSE_OPTIMAL的时候,隐藏绿波车速
|
||||
closeWindow();
|
||||
} else {
|
||||
// 线不为空就更新位置,线为空了,也就隐藏了
|
||||
optimalLine.setPoints(Arrays.asList(currentLatLng, defaultTarget));
|
||||
}
|
||||
}
|
||||
|
||||
// 判断当前位置与vip点的距离,来判断是否触发vip通行
|
||||
for (MogoLatLng crossing : vipCrossingList) {
|
||||
float distance = Utils.calculateLineDistance(currentLatLng, crossing);
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
currentLocation.getLongitude(),
|
||||
currentLocation.getLatitude(),
|
||||
crossing.getLon(),
|
||||
crossing.getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
);
|
||||
//Logger.d("V2X_OBU_VIP", "监测是否需要进行vip弹框提醒\ndistance: " + distance + "\neventAngle: " + eventAngle + "\ntarget: " + crossing + "\ncurrent: " + currentLatLng);
|
||||
if (distance <= DEFAULT_VIP_CROSSING_DISTANCE && 0 <= eventAngle && eventAngle <= 20) {
|
||||
//距离小于DEFAULT_VIP_CROSSING_DISTANCE,且夹角在0~20(说明在前方),则触发vip通行
|
||||
defaultTarget = crossing;
|
||||
handler.post(() -> {
|
||||
MogoObuEventInfo eventInfo = new MogoObuEventInfo();
|
||||
eventInfo.setType("vip变灯提醒");
|
||||
eventInfo.setTypeCode("vip变灯提醒");
|
||||
eventInfo.setDescribe("将为您变灯,vip车辆可优先通行");
|
||||
V2XObuManager.getInstance().onEventInfoCallback(eventInfo);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg A {@link Message Message} object
|
||||
* @return True if no further handling is desired
|
||||
*/
|
||||
@Override
|
||||
public boolean handleMessage(Message msg) {
|
||||
if (msg.what == MSG_CLOSE_OBU_WINDOW) {
|
||||
Logger.d(MODULE_NAME, "V2X Obu scenario expire===");
|
||||
closeWindow();
|
||||
isCrossWarning = false;
|
||||
isUrgenchyWarning = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final String ACTION_LAUNCHER_ADAS_APP_BIZ = "com.mogo.launcher.adas.app.biz";
|
||||
private static final String CALL_ADAS_SHOW_OPTIMAL = "2";
|
||||
private static final String CALL_ADAS_HIDE_OPTIMAL = "1";
|
||||
|
||||
private void sendBroadcastToAdas(String status) {
|
||||
if (status.equals(CALL_ADAS_SHOW_OPTIMAL)) {
|
||||
// 给adas发送显示绿波的广播,同时自己也要开始划线
|
||||
if(DebugConfig.getObuType() == DebugConfig.OBU_TYPE_CIDI) {
|
||||
drawLine();
|
||||
}
|
||||
} else {
|
||||
// 给adas发送隐藏绿波的广播,同时自己也需要结束划线动画
|
||||
hideLine();
|
||||
}
|
||||
try {
|
||||
Intent intent = new Intent(ACTION_LAUNCHER_ADAS_APP_BIZ);
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("action", status);
|
||||
String data = json.toString();
|
||||
Logger.d(MODULE_NAME, "发送绿波广播: " + data);
|
||||
intent.putExtra("data", data);
|
||||
intent.putExtra("type", 1);
|
||||
V2XServiceManager.getContext().sendBroadcast(intent);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Logger.e(MODULE_NAME, e, "发送绿波广播异常==");
|
||||
}
|
||||
}
|
||||
|
||||
public MogoLatLng getOptimalCrossing(){
|
||||
return optimalCrossing;
|
||||
}
|
||||
public float cacheZoomLevel = 16f;
|
||||
/**
|
||||
* 开始划线,同时添加marker,调整地图比例尺
|
||||
*/
|
||||
private void drawLine() {
|
||||
Logger.d(MODULE_NAME, "绘制绿波车速的线=====");
|
||||
if (optimalLine != null) {
|
||||
optimalLine.remove();
|
||||
}
|
||||
// 绘制marker
|
||||
drawPOI();
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(16).useGradient(true).colorValues(Arrays.asList(Color.parseColor("#FF1DAAA5"), Color.parseColor("#3337DED9")));
|
||||
|
||||
// 当前车辆位置
|
||||
MogoLatLng carLocation = V2XServiceManager.getNavi().getCarLocation();
|
||||
if (carLocation != null) {
|
||||
options.add(carLocation);
|
||||
} else {
|
||||
options.add(V2XServiceManager.getV2XStatusManager().getLocation());
|
||||
}
|
||||
// 目标车辆位置
|
||||
options.add(defaultTarget);
|
||||
|
||||
// 绘制线的对象
|
||||
optimalLine = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
|
||||
cacheZoomLevel = V2XServiceManager.getMapUIController().getZoomLevel();
|
||||
Logger.d(MODULE_NAME, "V2xObuEventScenario cacheZoomLevel==" + cacheZoomLevel);
|
||||
V2XServiceManager.getMapUIController().changeZoom(16);
|
||||
// V2XServiceManager.getMapUIController().changeZoom(17);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束划线,同时隐藏marker
|
||||
*/
|
||||
private void hideLine() {
|
||||
Logger.d(MODULE_NAME, "隐藏绿波车速的线====");
|
||||
clearPOI();
|
||||
if (optimalLine != null) {
|
||||
optimalLine.remove();
|
||||
optimalLine = null;
|
||||
}
|
||||
V2XServiceManager.getMapUIController().changeZoom(cacheZoomLevel);
|
||||
}
|
||||
|
||||
private volatile boolean isInChangeLightForVip = false;
|
||||
|
||||
/**
|
||||
* 是否在显示vip通行
|
||||
* @return true - 在显示vip通行
|
||||
*/
|
||||
public boolean isInChangeLightForVip(){
|
||||
return isInChangeLightForVip;
|
||||
}
|
||||
}
|
||||
@@ -1,193 +0,0 @@
|
||||
package com.mogo.module.v2x.scenario.scene.obu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.module.common.entity.V2XObuEventEntity;
|
||||
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.service.windowview.IMogoTopViewStatusListener;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.mogo.module.obu.ObuConstant;
|
||||
|
||||
import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
|
||||
/**
|
||||
* obu事件window
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class V2XObuEventWindow extends FrameLayout implements IV2XWindow<V2XObuEventEntity> {
|
||||
public V2XObuEventWindow(@NonNull Context context) {
|
||||
this(context,null);
|
||||
}
|
||||
|
||||
public V2XObuEventWindow(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs,0);
|
||||
}
|
||||
|
||||
public V2XObuEventWindow(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initView(context);
|
||||
}
|
||||
|
||||
private ImageView ivTypeIcon;
|
||||
private TextView tvType, tvDesc;
|
||||
|
||||
private void initView(Context context){
|
||||
Logger.d(MODULE_NAME,"初始化obu场景view");
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示1/2窗口
|
||||
*
|
||||
* 目前只处理如下obu事件
|
||||
* 绿波车速: {@link com.zhidao.mogo.module.obu.ObuConstant#TYPE_OPTIMAL_SPEED_ADVISORY}
|
||||
* 前车急刹: {@link com.zhidao.mogo.module.obu.ObuConstant#TYPE_URGENCY_COLLISION_WARNING}
|
||||
* vip车辆变灯提示(暂无回调,暂不处理)
|
||||
* @param entity
|
||||
*/
|
||||
@Override
|
||||
public void show(V2XObuEventEntity entity) {
|
||||
Logger.d(MODULE_NAME, "ObuEventWindow show " + entity);
|
||||
switch (entity.getType()) {
|
||||
case ObuConstant
|
||||
.TYPE_OPTIMAL_SPEED_ADVISORY:
|
||||
// 绿波车速引导
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_optimal_speed);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("车速引导");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_green);
|
||||
break;
|
||||
case ObuConstant.TYPE_URGENCY_COLLISION_WARNING:
|
||||
// 前车急刹预警 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);
|
||||
break;
|
||||
case ObuConstant.TYPE_CROSS_COLLISION_WARNING:
|
||||
// 交叉路口碰撞预警
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_car_collide_warning);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("交叉路口碰撞预警");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
case ObuConstant.TYPE_CHANGE_LIGHT_FOR_VIP:
|
||||
// vip变灯提醒
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_traffic_light);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("优先通行");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_green);
|
||||
break;
|
||||
case ObuConstant.TYPE_RUSH_RED_LIGHT:
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_rush_red_light);
|
||||
tvDesc.setText(entity.getDesc());
|
||||
tvType.setText("红灯警告");
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
case ObuConstant.TYPE_BLIND_ASSIST_WARN:
|
||||
case ObuConstant.TYPE_HAS_RUSH_RED_LIGHT:
|
||||
case ObuConstant.TYPE_LANE_CONVERGE_WARN:
|
||||
case ObuConstant.TYPE_LIMIT_SPEED_WARN:
|
||||
case ObuConstant.TYPE_PRESSING_CAR_WARN:
|
||||
case ObuConstant.TYPE_TRAFFIC_SIGN_INFO:
|
||||
case ObuConstant.TYPE_BLOCK_WARN:
|
||||
case ObuConstant.TYPE_FRONT_COLLISION_WARNING:
|
||||
case ObuConstant.TYPE_UNUSUAL_CAR_WARN:
|
||||
case ObuConstant.TYPE_UNUSUAL_ROAD_WARN:
|
||||
// 暂无设计图,先简单显示
|
||||
String[] descInfo = entity.getDesc().split("--");
|
||||
String t = null;
|
||||
String d = null;
|
||||
if (descInfo.length == 2) {
|
||||
t = descInfo[0];
|
||||
d = descInfo[1];
|
||||
}else{
|
||||
t = "未知类型";
|
||||
d = entity.getDesc();
|
||||
}
|
||||
ivTypeIcon.setImageResource(R.drawable.v2x_icon_obu_urgency_collision);
|
||||
tvDesc.setText(d);
|
||||
tvType.setText(t);
|
||||
tvType.setBackgroundResource(R.drawable.bg_v2x_event_type_read);
|
||||
break;
|
||||
default:
|
||||
Logger.w(MODULE_NAME, "其他obu类型,暂不处理: " + entity.getType());
|
||||
break;
|
||||
}
|
||||
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 210);
|
||||
V2XServiceManager.getMogoTopViewManager().addView(this, params,topViewStatusListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭1/2窗口
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
V2XServiceManager.getMogoTopViewManager().removeView(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回窗体
|
||||
*
|
||||
* @return 当前窗体
|
||||
*/
|
||||
@Override
|
||||
public View getView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private V2XWindowStatusListener statusListener = null;
|
||||
|
||||
/**
|
||||
* 设置Window状态监听
|
||||
*
|
||||
* @param listener 监听器
|
||||
*/
|
||||
@Override
|
||||
public void setWindowStatusListener(V2XWindowStatusListener listener) {
|
||||
statusListener = listener;
|
||||
}
|
||||
|
||||
private IMogoTopViewStatusListener topViewStatusListener = new IMogoTopViewStatusListener() {
|
||||
@Override
|
||||
public void onViewAdded(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRemoved(View view) {
|
||||
if (statusListener != null) {
|
||||
statusListener.onViewClose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewAddAnim(View view) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeViewRemoveAnim(View view) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import com.mogo.module.v2x.R;
|
||||
*/
|
||||
public class V2XEventPanelHistoryCountView extends LinearLayout {
|
||||
private RelativeLayout mLlEventMore;
|
||||
private ImageView mBtnShowOrHidePanels;
|
||||
private TextView mTvEventCount;
|
||||
|
||||
public V2XEventPanelHistoryCountView(Context context) {
|
||||
@@ -37,9 +36,8 @@ public class V2XEventPanelHistoryCountView extends LinearLayout {
|
||||
super(context, attrs, defStyleAttr);
|
||||
LayoutInflater.from(context).inflate(R.layout.view_event_panel_history_count, this);
|
||||
|
||||
mLlEventMore = (RelativeLayout) findViewById(R.id.llEventMore);
|
||||
mBtnShowOrHidePanels = (ImageView) findViewById(R.id.btnShowOrHidePanels);
|
||||
mTvEventCount = (TextView) findViewById(R.id.tvEventCount);
|
||||
mLlEventMore = findViewById(R.id.llEventMore);
|
||||
mTvEventCount = findViewById(R.id.tvEventCount);
|
||||
|
||||
if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_LENOVO) {
|
||||
mLlEventMore.setVisibility(VISIBLE);
|
||||
|
||||
@@ -241,13 +241,6 @@ public interface IMogoServiceApis extends IProvider {
|
||||
*/
|
||||
IMogoTanluUiProvider getTanluUiApi();
|
||||
|
||||
/**
|
||||
* 获取crashWarnProvider
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
IMogoCrashWarnProvider getCrashWarnProvider();
|
||||
|
||||
/**
|
||||
* 在线车辆面板
|
||||
*
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.service.windowview.IMogoEntranceViewListener;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -13,54 +12,10 @@ import com.mogo.service.windowview.IMogoEntranceViewListener;
|
||||
* 入口按钮
|
||||
*/
|
||||
public interface IMogoEntranceButtonController extends IProvider {
|
||||
|
||||
/**
|
||||
* 前车急刹
|
||||
*/
|
||||
int NOTICE_TYPE_SUDDENLY_BREAK = 1001;
|
||||
/**
|
||||
* vip变灯通行
|
||||
*/
|
||||
int NOTICE_TYPE_VIP = 1002;
|
||||
/**
|
||||
* 行人碰撞预警
|
||||
*/
|
||||
int NOTICE_TYPE_PEOPLE_WARN = 1003;
|
||||
/**
|
||||
* 逆向超车
|
||||
*/
|
||||
int NOTICE_TYPE_ILLEGAL_OVERTAKE = 1004;
|
||||
/**
|
||||
* 后方危险车辆提醒
|
||||
*/
|
||||
int NOTICE_TYPE_DANGEROUS_CAR_WARN = 1005;
|
||||
/**
|
||||
* 特殊车辆快速通过
|
||||
*/
|
||||
int NOTICE_TYPE_SPECIAL_CAR_WARN = 1006;
|
||||
/**
|
||||
* 自车求助
|
||||
*/
|
||||
int NOTICE_TYPE_SEEK_HELP = 1007;
|
||||
/**
|
||||
* 交通事故识别
|
||||
*/
|
||||
int NOTICE_TYPE_ACCIDENT_WARN = 1008;
|
||||
|
||||
/**
|
||||
* 障碍物体绕行
|
||||
*/
|
||||
int NOTICE_TYPE_OBSTACLE_WARN = 1009;
|
||||
|
||||
/**
|
||||
* 障碍车辆绕行
|
||||
*/
|
||||
int NOTICE_TYPE_OBSTACLE_CAR_WARN = 1010;
|
||||
|
||||
/**
|
||||
* 拥堵路线推荐
|
||||
*/
|
||||
int NOTICE_TYPE_CONGESTION_RECOMMENDED = 1011;
|
||||
|
||||
/**
|
||||
* 获取入口按钮实例
|
||||
@@ -70,13 +25,6 @@ public interface IMogoEntranceButtonController extends IProvider {
|
||||
*/
|
||||
TextView getButton(ButtonIndex index);
|
||||
|
||||
/**
|
||||
* 添加低层级view,使用ViewGroup.addView(v,0)实现
|
||||
*
|
||||
* @param view 将要添加的view
|
||||
*/
|
||||
void addBottomLayerView(View view);
|
||||
|
||||
/**
|
||||
* 添加低层级view,使用ViewGroup.addView(v,0)实现
|
||||
* 可指定x,y位置
|
||||
@@ -108,24 +56,10 @@ public interface IMogoEntranceButtonController extends IProvider {
|
||||
*/
|
||||
void removeLeftFeatureView(View view);
|
||||
|
||||
/**
|
||||
* 设置vr模式下,左下角提示view
|
||||
*
|
||||
* @param view 目前是adas提示和求助
|
||||
*/
|
||||
void showLeftNoticeView(View view);
|
||||
|
||||
/**
|
||||
* 隐藏vr模式下,左下角提示view,需要与{@link #showLeftNoticeView(View)}成对使用
|
||||
*
|
||||
* @param view 待隐藏view
|
||||
*/
|
||||
void hideLeftNoticeView(View view);
|
||||
|
||||
/**
|
||||
* 根据noticeType添加左侧提示
|
||||
*
|
||||
* @param noticeType {@link #NOTICE_TYPE_SUDDENLY_BREAK}...
|
||||
* @param noticeType {@link #NOTICE_TYPE_SEEK_HELP}...
|
||||
* @param iconRes 本地 icon res
|
||||
* @param content 提示内容
|
||||
*/
|
||||
@@ -134,21 +68,8 @@ public interface IMogoEntranceButtonController extends IProvider {
|
||||
/**
|
||||
* 移除noticeType,需要与{@link #showLeftNoticeByType(int, int, String)}成对使用
|
||||
*
|
||||
* @param noticeType {@link #NOTICE_TYPE_SUDDENLY_BREAK}...
|
||||
* @param noticeType {@link #NOTICE_TYPE_SEEK_HELP}...
|
||||
*/
|
||||
void hideLeftNoticeByType(int noticeType);
|
||||
|
||||
/**
|
||||
* 添加view状态回调监听
|
||||
*
|
||||
* @param listener 回调监听
|
||||
*/
|
||||
void addEntranceViewListener(IMogoEntranceViewListener listener);
|
||||
|
||||
/**
|
||||
* 移除view状态回调监听
|
||||
*
|
||||
* @param listener 回调监听
|
||||
*/
|
||||
void removeEntranceViewListener(IMogoEntranceViewListener listener);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.mogo.service.module.IMogoMarkerService;
|
||||
import com.mogo.service.module.IMogoRegisterCenter;
|
||||
import com.mogo.service.monitor.IMogoMonitorProvider;
|
||||
import com.mogo.service.network.IMogoNetwork;
|
||||
import com.mogo.service.obu.IMogoCrashWarnProvider;
|
||||
import com.mogo.service.share.IMogoShareManager;
|
||||
import com.mogo.service.share.IMogoTanluProvider;
|
||||
import com.mogo.service.share.IMogoTanluUiProvider;
|
||||
@@ -207,11 +206,6 @@ public class MogoServiceApis implements IMogoServiceApis {
|
||||
return getApiInstance(IMogoTanluUiProvider.class, MogoServicePaths.PATH_TANLU_UI_API);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoCrashWarnProvider getCrashWarnProvider() {
|
||||
return getApiInstance(IMogoCrashWarnProvider.class, MogoServicePaths.PATH_CRASH_WARNING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoOnlineCarListPanelProvider getOnlineCarPanelApi() {
|
||||
return getApiInstance(IMogoOnlineCarListPanelProvider.class, MogoServicePaths.PATH_ONLINE_CAR_PANEL);
|
||||
|
||||
@@ -56,7 +56,6 @@ include ':libraries:mogo-map'
|
||||
// OLD业务模块
|
||||
include ':modules:tanlulib'
|
||||
include ':modules:mogo-module-monitor'
|
||||
include ':modules:mogo-module-obu'
|
||||
include ':modules:mogo-module-adas'
|
||||
include ':modules:mogo-module-map'
|
||||
include ':modules:mogo-module-common'
|
||||
|
||||
Reference in New Issue
Block a user