增加了事件处理时间
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.mogo.module.common.entity;
|
||||
|
||||
import com.mogo.utils.sqlite.annotation.DbDatabase;
|
||||
import com.mogo.utils.sqlite.annotation.DbField;
|
||||
import com.mogo.utils.sqlite.annotation.DbTable;
|
||||
|
||||
/**
|
||||
* V2X 道路历史事件
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
@DbDatabase(dbName = "MoGoScenario.db")
|
||||
@DbTable(tableName = "tb_history_scenario")
|
||||
public class V2XHistoryScenarioData {
|
||||
|
||||
/**
|
||||
* 事件类型
|
||||
*/
|
||||
@DbField(fieldName = "scenarioType")
|
||||
public Integer scenarioType;
|
||||
|
||||
/**
|
||||
* 事件触发时间
|
||||
*/
|
||||
@DbField(fieldName = "triggerTime")
|
||||
public Long triggerTime;
|
||||
|
||||
/**
|
||||
* 事件json
|
||||
*/
|
||||
@DbField(fieldName = "eventJsonData")
|
||||
public String eventJsonData;
|
||||
|
||||
public Integer getScenarioType() {
|
||||
return scenarioType;
|
||||
}
|
||||
|
||||
public void setScenarioType(Integer scenarioType) {
|
||||
this.scenarioType = scenarioType;
|
||||
}
|
||||
|
||||
public String getEventJsonData() {
|
||||
return eventJsonData;
|
||||
}
|
||||
|
||||
public void setEventJsonData(String eventJsonData) {
|
||||
this.eventJsonData = eventJsonData;
|
||||
}
|
||||
|
||||
public Long getTriggerTime() {
|
||||
return triggerTime;
|
||||
}
|
||||
|
||||
public void setTriggerTime(Long triggerTime) {
|
||||
this.triggerTime = triggerTime;
|
||||
}
|
||||
}
|
||||
@@ -140,12 +140,12 @@ public class V2XModuleProvider implements
|
||||
intentFilter.addAction(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
|
||||
localBroadcastManager.registerReceiver(localReceiver, intentFilter);
|
||||
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// // TODO 这是测试页面
|
||||
// V2XServiceManager
|
||||
// .getIMogoWindowManager()
|
||||
// .addView(new V2XTestConsoleWindow(context), 0, 0, false);
|
||||
// }
|
||||
if (BuildConfig.DEBUG) {
|
||||
// TODO 这是测试页面
|
||||
V2XServiceManager
|
||||
.getIMogoWindowManager()
|
||||
.addView(new V2XTestConsoleWindow(context), 0, 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void initVoice(Context context) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Intent;
|
||||
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import com.mogo.module.common.entity.V2XHistoryScenarioData;
|
||||
import com.mogo.module.common.entity.V2XMessageEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.scenario.IV2XScenarioManager;
|
||||
@@ -15,10 +16,13 @@ import com.mogo.module.v2x.scenario.scene.park.V2XIllegalParkScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.push.V2XPushEventScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.road.V2XRoadEventScenario;
|
||||
import com.mogo.module.v2x.scenario.scene.seek.V2XSeekHelpScenario;
|
||||
import com.mogo.module.v2x.utils.TimeUtils;
|
||||
import com.mogo.module.v2x.utils.ToastUtils;
|
||||
import com.mogo.module.v2x.utils.V2XUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.mogo.utils.network.utils.GsonUtil;
|
||||
import com.mogo.utils.sqlite.BaseDaoFactory;
|
||||
import com.mogo.utils.sqlite.IBaseDao;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -36,6 +40,11 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
private AbsV2XScenario mV2XScenario;
|
||||
private HashMap<Integer, AbsV2XScenario> mV2XScenarioSet = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 场景数据管理
|
||||
*/
|
||||
private static IBaseDao<V2XHistoryScenarioData> mScenarioDao;
|
||||
|
||||
private V2XScenarioManager() {
|
||||
}
|
||||
|
||||
@@ -44,6 +53,7 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
synchronized (V2XScenarioManager.class) {
|
||||
if (mV2XScenarioManager == null) {
|
||||
mV2XScenarioManager = new V2XScenarioManager();
|
||||
mScenarioDao = BaseDaoFactory.Companion.getInstance().getBaseDao(V2XUtils.getApp(), V2XHistoryScenarioData.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,6 +68,17 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
V2XUtils.runOnUiThread(() -> {
|
||||
// 提取之前存储的场景
|
||||
if (v2XMessageEntity != null) {
|
||||
try {
|
||||
// 进行数据库存储
|
||||
V2XHistoryScenarioData v2XHistoryScenarioData = new V2XHistoryScenarioData();
|
||||
v2XHistoryScenarioData.setScenarioType(v2XMessageEntity.getType());
|
||||
v2XHistoryScenarioData.setTriggerTime(TimeUtils.getNowMills());
|
||||
v2XHistoryScenarioData.setEventJsonData(GsonUtil.jsonFromObject(v2XMessageEntity.getContent()));
|
||||
mScenarioDao.insert(v2XHistoryScenarioData);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 广播给应用内部其它模块
|
||||
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
|
||||
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
|
||||
|
||||
Reference in New Issue
Block a user