eagle_1030 限速标识 接入hmi
This commit is contained in:
@@ -5,6 +5,7 @@ import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_V2X_MODULE
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoFunctionServerProvider
|
||||
import com.mogo.eagle.core.function.call.trafficlight.CallTrafficLightManager
|
||||
import com.mogo.eagle.core.function.v2x.speedlimit.SpeedLimitDataManager
|
||||
import com.mogo.eagle.core.function.v2x.vip.VipCarManager
|
||||
|
||||
@Route(path = PATH_V2X_MODULE)
|
||||
@@ -16,6 +17,7 @@ class V2XProvider : IMoGoFunctionServerProvider {
|
||||
override fun init(context: Context) {
|
||||
CallTrafficLightManager.getTrafficLightProvider().initTrafficLightServer(context)
|
||||
VipCarManager.INSTANCE.initServer(context)
|
||||
SpeedLimitDataManager.getInstance().start();
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mogo.eagle.core.function.v2x.speedlimit;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class SpeedLimitDataManager implements IMogoCarLocationChangedListener2 {
|
||||
|
||||
private static SpeedLimitDataManager instance ;
|
||||
private Location mLocation;
|
||||
// private static Context mContext;
|
||||
private Timer mTimer;
|
||||
private SpeedLimitDataManager(){
|
||||
}
|
||||
public static SpeedLimitDataManager getInstance(){
|
||||
if (instance == null){
|
||||
synchronized (SpeedLimitDataManager.class){
|
||||
if (instance == null){
|
||||
instance = new SpeedLimitDataManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
private class SpeedTimerTask extends TimerTask{
|
||||
@Override
|
||||
public void run() {
|
||||
if (mLocation != null){
|
||||
int speedLimmit = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getSpeedLimmit(mLocation.getLongitude(),mLocation.getLatitude(),mLocation.getBearing());
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int speed = (int) (mLocation.getSpeed() * 3.6f);
|
||||
Logger.e("lianglihui","SpeedTimerTask : "+ speed+" - "+ speedLimmit);
|
||||
if (speed > speedLimmit){
|
||||
CallerHmiManager.INSTANCE.showLimitingVelocity(speedLimmit);
|
||||
}else {
|
||||
CallerHmiManager.INSTANCE.disableLimitingVelocity();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void start(){
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerCarLocationChangedListener("SpeedLimitDataManager",this);
|
||||
mTimer = new Timer();
|
||||
mTimer.schedule(new SpeedTimerTask(), new Date(),1000);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
mLocation = latLng;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user