From 741fe10d400ba0d20586450d00410796269fdef0 Mon Sep 17 00:00:00 2001 From: donghongyu Date: Sun, 29 Jan 2023 15:44:35 +0800 Subject: [PATCH] =?UTF-8?q?[dev=5Farch=5Fopt=5F3.0]=20[Change]=20[=201?= =?UTF-8?q?=E3=80=81=E4=B8=B4=E6=97=B6=E4=BF=AE=E6=94=B9=E6=B8=85=E6=89=AB?= =?UTF-8?q?=E8=BD=A6=E5=BC=82=E5=B8=B8=EF=BC=8C=E5=A6=82=E6=9E=9C=E5=90=88?= =?UTF-8?q?=E5=B9=B6=E5=88=B0dev=5Frobosweeper-d=5Fapp-module=5F221230=5F1?= =?UTF-8?q?.1.0=E5=88=86=E6=94=AF=EF=BC=8C=E8=BF=99=E9=87=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8F=AF=E4=BB=A5=E4=B8=8D=E6=8F=90=E4=BA=A4=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../sweeper/view/SweeperTrafficDataView.java | 152 ++++++++---------- 1 file changed, 71 insertions(+), 81 deletions(-) diff --git a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java index 4164276bcf..4be12b9e35 100644 --- a/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java +++ b/OCH/mogo-och-sweeper/src/main/java/com/mogo/och/sweeper/view/SweeperTrafficDataView.java @@ -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); } } + }