[清扫车]删除SweeperTrafficDataView.java

This commit is contained in:
bxb
2023-01-17 15:08:33 +08:00
parent e2fd1f5493
commit bea96a1604

View File

@@ -1,201 +0,0 @@
package com.mogo.och.sweeper.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotVehicleStateListener;
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.v2x.CallLimitingVelocityListenerManager;
import com.mogo.eagle.core.function.hmi.ui.widget.TapPositionView;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
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.ChassisStatesOuterClass;
import planning.RoboSweeperTaskIndexOuterClass;
public class SweeperTrafficDataView extends ConstraintLayout {
private static final String TAG = "SweeperTrafficDataView";
private TapPositionView tapPositionView;//方向盘
private ImageView speedImage;//速度图标
private TextView speedTextView;//速度值
private TurnSignalView sweeperTurnSignal;//转向灯
private SweeperLimitingVelocityView sweeperLimitingVelocity;//限速
private TextView tvBattery;//电量百分比展示
private ImageView ivBgWaterWarning;//水位预警背景图
private ImageView ivWater;//水位图标
public SweeperTrafficDataView(@NonNull Context context) {
super(context);
}
public SweeperTrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
initView(context);
}
public SweeperTrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public SweeperTrafficDataView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
private void initView(@NonNull Context context) {
LayoutInflater.from(context).inflate(R.layout.sweeper_traffic_data, this);
tapPositionView = findViewById(R.id.sweeperTrafficPosition);
speedImage = findViewById(R.id.sweeperSpeedImage);
speedTextView = findViewById(R.id.sweeperSpeedText);
sweeperTurnSignal = findViewById(R.id.sweeperTurnSignal);
sweeperLimitingVelocity = findViewById(R.id.sweeperLimitingVelocity);
tvBattery = findViewById(R.id.tvBattery);
ivBgWaterWarning = findViewById(R.id.sweeperIvBgWaterWarning);
ivWater = findViewById(R.id.sweeperIvWater);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
//增加限速监听
CallLimitingVelocityListenerManager.INSTANCE.addListener(TAG,limitingVelocityListener);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallerAutopilotVehicleStateListenerManager.INSTANCE.removeListener(mIMoGoAutopilotVehicleStateListener);
CallLimitingVelocityListenerManager.INSTANCE.removeListener(limitingVelocityListener);
}
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
@Override
public void onSweeperFutianTaskIndexData(@NonNull RoboSweeperTaskIndexOuterClass.RoboSweeperTaskIndex roboSweeperTaskIndex) {
}
@Override
public void onSweeperFutianCleanSystemState(@NonNull ChassisStatesOuterClass.SweeperFuTianTaskSystemStates cleanSystemState) {
if (cleanSystemState!=null&&cleanSystemState.hasSecuCleanWaterTankLow()) {//清水箱水位低不能清洗作业报警信号
ivBgWaterWarning.setVisibility(View.VISIBLE);
ivWater.setSelected(true);
}else{
ivBgWaterWarning.setVisibility(View.GONE);
ivWater.setSelected(false);
}
}
@Override
public void onBMSSystemStates(@NonNull ChassisStatesOuterClass.BMSSystemStates bmsSystemStates) {
if (bmsSystemStates!=null){
tvBattery.setText(String.format("%s%",65));
}
}
/**
* 车辆转向灯
* @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 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 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);
}
};
/**
* 限速监听
*/
private final LimitingVelocityListener limitingVelocityListener = new LimitingVelocityListener(){
@Override
public void onLimitingVelocityChange(int limitingVelocity) {
//设置限速
sweeperLimitingVelocity.updateLimitingSpeed(limitingVelocity);
}
};
/**
* 速度设置
*/
public void updateSpeedWithValue(int newSpeed) {
if (speedTextView != null) {
speedTextView.setText(String.valueOf(newSpeed));
}
if (speedImage != null) {
speedImage.setBackgroundResource(newSpeed > 60 ? R.drawable.sweeper_traffic_data_speed_warning :R.drawable.sweeper_bg_traffic_data_speed);
}
}
}