[dev_arch_opt_3.0]

[Change]
[
1、临时修改清扫车异常,如果合并到dev_robosweeper-d_app-module_221230_1.1.0分支,这里修改可以不提交
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-01-29 15:44:35 +08:00
parent 9a5def9afa
commit 741fe10d40

View File

@@ -6,9 +6,18 @@ import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.TextView;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGearStateListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisSteeringStateListener;
import com.mogo.eagle.core.function.api.v2x.LimitingVelocityListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotVehicleStateListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGearStateListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisSteeringStateListenerManager;
import com.mogo.eagle.core.function.call.v2x.CallLimitingVelocityListenerManager;
import com.mogo.eagle.core.function.hmi.ui.widget.TapPositionView;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
@@ -17,13 +26,12 @@ import com.mogo.och.sweeper.R;
import org.jetbrains.annotations.NotNull;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import chassis.Chassis;
import chassis.VehicleStateOuterClass;
public class SweeperTrafficDataView extends ConstraintLayout {
public class SweeperTrafficDataView extends ConstraintLayout
implements IMoGoChassisLamplightListener,
IMoGoChassisSteeringStateListener,
IMoGoChassisGearStateListener {
private static final String TAG = "SweeperTrafficDataView";
private TapPositionView tapPositionView;//方向盘
private ImageView speedImage;//速度图标
@@ -58,7 +66,10 @@ public class SweeperTrafficDataView extends ConstraintLayout {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
//添加 底盘灯光数据 监听
CallerChassisLamplightListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisSteeringStateListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisGearStateListenerManager.INSTANCE.addListener(TAG, this);
//增加限速监听
CallLimitingVelocityListenerManager.INSTANCE.addListener(TAG,limitingVelocityListener);
}
@@ -66,90 +77,68 @@ public class SweeperTrafficDataView extends ConstraintLayout {
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.removeListener(mIMoGoAutopilotVehicleStateListener);
// 移除 底盘灯光数据 监听
CallerChassisLamplightListenerManager.INSTANCE.removeListener(TAG);
CallerChassisSteeringStateListenerManager.INSTANCE.removeListener(TAG);
CallerChassisGearStateListenerManager.INSTANCE.removeListener(TAG);
CallLimitingVelocityListenerManager.INSTANCE.removeListener(limitingVelocityListener);
}
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
@Override
public void onSweeperFutianCleanSystemState(@NonNull VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
}
/**
* 车辆转向灯
* @param lightSwitch
*/
@Override
public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) {
//转向灯状态 0是正常 1是左转 2是右转
if (lightSwitch != null) {
CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString());
if (lightSwitch.getNumber()==1){
sweeperTurnSignal.showLeftSignal();
}else if(lightSwitch.getNumber()==2){
sweeperTurnSignal.showRightSignal();
}else{
sweeperTurnSignal.showDirection();
}
/**
* 车辆转向灯
* @param lightSwitch
*/
@Override
public void onAutopilotLightSwitchData(@org.jetbrains.annotations.Nullable Chassis.LightSwitch lightSwitch) {
//转向灯状态 0是正常 1是左转 2是右转
if (lightSwitch != null) {
CallerLogger.INSTANCE.d(TAG, "车辆转向灯:" + lightSwitch.toString());
if (lightSwitch.getNumber()==1){
sweeperTurnSignal.showLeftSignal();
}else if(lightSwitch.getNumber()==2){
sweeperTurnSignal.showRightSignal();
}else{
sweeperTurnSignal.showDirection();
}
}
}
/**
* 刹车灯
* @param brakeLight
*/
@Override
public void onAutopilotBrakeLightData(boolean brakeLight) {
CallerLogger.INSTANCE.d(TAG, "刹车灯:" + brakeLight);
/**
* 刹车灯
* @param brakeLight
*/
@Override
public void onAutopilotBrakeLightData(boolean brakeLight) {
CallerLogger.INSTANCE.d(TAG, "刹车灯:" + brakeLight);
}
/**
* 方向盘转向角 左+右-
* @param steering
*/
@Override
public void onAutopilotSteeringData(float steering) {
CallerLogger.INSTANCE.d(TAG, "steering原始值====" + steering);
if (Math.abs(steering) < 1) {
steering = 0;
}
CallerLogger.INSTANCE.d(TAG, "steering忽略小数点后====" + (int) steering);
}
/**
* 方向盘转向角 左+右-
* @param steering
*/
@Override
public void onAutopilotSteeringData(float steering) {
CallerLogger.INSTANCE.d(TAG, "steering原始值====" + steering);
if (Math.abs(steering) < 1) {
steering = 0;
/**
* 档位
* @param gear
*/
@Override
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
CallerLogger.INSTANCE.d(TAG, "司机屏档位" + gear.toString());
ThreadUtils.runOnUiThread(() -> {
if (tapPositionView != null) {
tapPositionView.updateWithGear(gear);
}
CallerLogger.INSTANCE.d(TAG, "steering忽略小数点后====" + (int) steering);
}
});
}
/**
* 档位
* @param gear
*/
@Override
public void onAutopilotGearData(@NotNull Chassis.GearPosition gear) {
CallerLogger.INSTANCE.d(TAG, "司机屏档位" + gear.toString());
ThreadUtils.runOnUiThread(() -> {
if (tapPositionView != null) {
tapPositionView.updateWithGear(gear);
}
});
}
@Override
public void onAutopilotDataException(long timestamp) {
}
@Override
public void onAutopilotAcc(float carAcc) {
}
@Override
public void onAutopilotBrake(float brake) {
CallerLogger.INSTANCE.d(TAG, "刹车:" + brake);
}
@Override
public void onAutopilotThrottle(float throttle) {
CallerLogger.INSTANCE.d(TAG, "油门:" + throttle);
}
};
/**
* 限速监听
*/
@@ -172,4 +161,5 @@ public class SweeperTrafficDataView extends ConstraintLayout {
speedImage.setBackgroundResource(newSpeed > 60 ? R.drawable.sweeper_traffic_data_speed_warning :R.drawable.sweeper_bg_traffic_data_speed);
}
}
}