opt delay time
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -11,6 +12,7 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.drawer.bean.SpeedData;
|
||||
import com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedResult;
|
||||
|
||||
@@ -104,7 +106,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if (marker != null && !marker.isDestroyed()) {
|
||||
// Log.d(TAG, "发现缓存marker id : " + uniqueKey);
|
||||
updateCacheMarkerRes(marker, recognizedListResult);
|
||||
renderAdasOneFrame(true, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
} else {
|
||||
// 新增添加进差集
|
||||
newDiffSet.add(recognizedListResult);
|
||||
@@ -125,7 +127,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
continue;
|
||||
}
|
||||
// Log.d(TAG, "新增marker id : " + uniqueKey);
|
||||
renderAdasOneFrame(false, marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches);
|
||||
}
|
||||
}
|
||||
sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches);
|
||||
@@ -244,7 +246,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
* @param recognizedListResult {@link ADASRecognizedResult}
|
||||
* @param newAdasRecognizedMarkersCaches 缓存集合
|
||||
*/
|
||||
private void renderAdasOneFrame(boolean useCache, IMogoMarker marker,
|
||||
private void renderAdasOneFrame(IMogoMarker marker,
|
||||
String uniqueKey,
|
||||
ADASRecognizedResult recognizedListResult,
|
||||
Map<String, IMogoMarker> newAdasRecognizedMarkersCaches) {
|
||||
@@ -265,7 +267,6 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
// Log.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
|
||||
|
||||
mLastPositions.put(uniqueKey, recognizedListResult);
|
||||
// if (useCache) {
|
||||
// Log.d(TAG, "使用缓存 id : " + uniqueKey);
|
||||
long interval = 45;
|
||||
if (lastPosition != null) {
|
||||
@@ -275,12 +276,6 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
long cost = System.currentTimeMillis() - start;
|
||||
final long intervalRef = interval - cost;
|
||||
marker.addDynamicAnchorPosition(renderLoc, (float) recognizedListResult.heading, intervalRef);
|
||||
// }
|
||||
// else {
|
||||
// Log.d(TAG, "未使用缓存 id : " + uniqueKey);
|
||||
// marker.setRotateAngle(((float) recognizedListResult.heading));
|
||||
// marker.setPosition(recognizedListResult.lat, recognizedListResult.lon);
|
||||
// }
|
||||
String carColor = recognizedListResult.color;
|
||||
if (TextUtils.isEmpty(carColor)) {
|
||||
carColor = getModelRenderColor(recognizedListResult.type, FROM_ADAS, recognizedListResult.speed, recognizedListResult.lon, recognizedListResult.lat, recognizedListResult.heading);
|
||||
@@ -288,9 +283,18 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
marker.setAnchorColor(carColor);
|
||||
|
||||
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
|
||||
// if (shouldShowSpeed(recognizedListResult.type)) {
|
||||
// showSelfSpeed(marker, recognizedListResult.speed, recognizedListResult.uuid, recognizedListResult.type, recognizedListResult.heading, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
// }
|
||||
|
||||
if (shouldShowSpeed(recognizedListResult.type)) {
|
||||
Message msg = mRenderThreadHandler.obtainMessage();
|
||||
msg.obj = new SpeedData(marker
|
||||
, recognizedListResult.speed
|
||||
, recognizedListResult.uuid
|
||||
, recognizedListResult.type
|
||||
, recognizedListResult.heading
|
||||
, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
msg.what = MSG_DISPLAY_SPEED;
|
||||
msg.sendToTarget();
|
||||
}
|
||||
Log.d("ADAS数据延时", "render 刷新一台车 cost : " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)));
|
||||
}
|
||||
|
||||
@@ -315,7 +319,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.anchor(0.5f, 0.75f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.anchorColor(carColor)
|
||||
|
||||
@@ -15,12 +15,14 @@ import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.module.common.drawer.bean.SpeedData;
|
||||
import com.mogo.module.common.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -48,6 +50,11 @@ class BaseDrawer {
|
||||
*/
|
||||
public static final int MAP_RENDER_FRAME_FREQUENCY = 30;
|
||||
|
||||
/**
|
||||
* 显示速度
|
||||
*/
|
||||
public static final int MSG_DISPLAY_SPEED = 11;
|
||||
|
||||
/**
|
||||
* 移动点的时间间隔
|
||||
*/
|
||||
@@ -60,7 +67,7 @@ class BaseDrawer {
|
||||
|
||||
protected final Context mContext;
|
||||
|
||||
private TextView mSpeedView;
|
||||
private static TextView mSpeedView;
|
||||
|
||||
public BaseDrawer() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
@@ -79,6 +86,7 @@ class BaseDrawer {
|
||||
}
|
||||
|
||||
private static Handler mWorkThreadHandler;
|
||||
protected static Handler mRenderThreadHandler = null;
|
||||
|
||||
/**
|
||||
* 处理 marker 移除的线程
|
||||
@@ -107,6 +115,29 @@ class BaseDrawer {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (mRenderThreadHandler == null) {
|
||||
mRenderThreadHandler = new Handler(WorkThreadHandler.newInstance("render-thread-" + new Random().nextLong()).getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_DISPLAY_SPEED) {
|
||||
if (msg.obj instanceof SpeedData) {
|
||||
showSpeed((SpeedData) msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private static void showSpeed(SpeedData speedData) {
|
||||
showSelfSpeed(speedData.getMarker()
|
||||
, speedData.getSpeed()
|
||||
, speedData.getUuid()
|
||||
, speedData.getType()
|
||||
, speedData.getHeading()
|
||||
, speedData.getIsVrMode());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,7 +363,7 @@ class BaseDrawer {
|
||||
* @param speed 是否显示速度
|
||||
* @param isVrMode 是否是vrMode
|
||||
*/
|
||||
public void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
|
||||
public static void showSelfSpeed(IMogoMarker mogoMarker, double speed, String uuid, int type, double heading, boolean isVrMode) {
|
||||
Log.d("EmArrow", "showSelf uuid : " + uuid + " speed : " + speed);
|
||||
if (mogoMarker == null || mogoMarker.isDestroyed()) {
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -19,6 +20,7 @@ import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.api.CallChatApi;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.drawer.bean.SpeedData;
|
||||
import com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.service.adas.IMogoADASController;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -332,7 +334,15 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
|
||||
newSnapshotCaches.put(uniqueKey, marker);
|
||||
if (shouldShowSpeed(cloudRoadData.getType())) {
|
||||
showSelfSpeed(marker, cloudRoadData.getSpeed(), cloudRoadData.getUuid(), cloudRoadData.getType(), cloudRoadData.getHeading(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
Message msg = mRenderThreadHandler.obtainMessage();
|
||||
msg.obj = new SpeedData(marker
|
||||
, cloudRoadData.getSpeed()
|
||||
, cloudRoadData.getUuid()
|
||||
, cloudRoadData.getType()
|
||||
, cloudRoadData.getHeading()
|
||||
, MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
msg.what = MSG_DISPLAY_SPEED;
|
||||
msg.sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.mogo.module.common.drawer.bean;
|
||||
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
/**
|
||||
* 速度显示对象
|
||||
*/
|
||||
public class SpeedData {
|
||||
|
||||
public IMogoMarker marker;
|
||||
public double speed;
|
||||
public String uuid;
|
||||
public int type;
|
||||
public double heading;
|
||||
public boolean isVrMode;
|
||||
|
||||
public SpeedData(IMogoMarker marker, double speed, String uuid, int type, double heading, boolean isVrMode) {
|
||||
this.marker = marker;
|
||||
this.speed = speed;
|
||||
this.uuid = uuid;
|
||||
this.type = type;
|
||||
this.heading = heading;
|
||||
this.isVrMode = isVrMode;
|
||||
}
|
||||
|
||||
public IMogoMarker getMarker() {
|
||||
return marker;
|
||||
}
|
||||
|
||||
public void setMarker(IMogoMarker marker) {
|
||||
this.marker = marker;
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(double speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public boolean getIsVrMode() {
|
||||
return isVrMode;
|
||||
}
|
||||
|
||||
public void setIsVrMode(boolean isVrMode) {
|
||||
this.isVrMode = isVrMode;
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,21 @@ public class MogoADASController implements IMogoADASController {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接收 adas 识别数据线程
|
||||
*/
|
||||
private final Handler mAdasRecognizedRecHandler = new Handler(WorkThreadHandler.newInstance("AdasRecognizedRecThread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.obj instanceof List) {
|
||||
handleAdasRecognizedData((List<RectInfo.RectBean>) msg.obj);
|
||||
} else if (msg.obj == null) {
|
||||
handleAdasRecognizedData(null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 接收 adas 定位数据线程
|
||||
*/
|
||||
@@ -269,12 +284,14 @@ public class MogoADASController implements IMogoADASController {
|
||||
if (rectInfo.getModels() != null && !rectInfo.getModels().isEmpty()) {
|
||||
List<RectInfo.RectBean> beans = rectInfo.getModels();
|
||||
try {
|
||||
handleAdasRecognizedData(beans);
|
||||
Message message = mAdasRecognizedRecHandler.obtainMessage();
|
||||
message.obj = beans;
|
||||
message.sendToTarget();
|
||||
Log.i("ADAS数据延时", "接收数据 -> 发出 cost :" + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Log.i("ADAS数据延时", "接收数据 -> 发出 cost :" + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms");
|
||||
DebugConfig.setStatus(DebugConfig.sAdasRecognized, true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user