Merge branch 'dev_arch_opt_3.0' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_arch_opt_3.0

This commit is contained in:
xinfengkun
2023-01-10 17:31:00 +08:00
8 changed files with 425 additions and 487 deletions

View File

@@ -1,36 +1,22 @@
package com.mogo.eagle.core.function.datacenter.autopilot.adapter;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_DEVA;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.eagle.core.data.constants.MoGoConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager;
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import org.jetbrains.annotations.NotNull;
import chassis.Chassis;
import mogo.telematics.pad.MessagePad;
public class MoGoHandAdasMsgManager implements
IMoGoAutopilotCarConfigListener,
IMoGoChassisGnssInfoListener,
IMoGoChassisLamplightListener {
IMoGoAutopilotCarConfigListener{
private final String TAG = "AdasEventManager";
@@ -39,8 +25,6 @@ public class MoGoHandAdasMsgManager implements
private MoGoHandAdasMsgManager(Context context) {
CallerAutopilotCarConfigListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisGnssInfoListenerManager.INSTANCE.addListener(TAG, this);
CallerChassisLamplightListenerManager.INSTANCE.addListener(TAG, this);
mContext = context;
}
@@ -55,13 +39,6 @@ public class MoGoHandAdasMsgManager implements
return moGoHandAdasMsgManager;
}
private int turnLightTimes = 0;
private boolean isOnTurnLight = false;
private int turnLight = 0;
private volatile boolean isShowTurnLight = false;
private int brakeLight = -1;
public void getConfig() {
com.elegant.utils.UiThreadHandler.postDelayed(new Runnable() {
@Override
@@ -71,51 +48,6 @@ public class MoGoHandAdasMsgManager implements
}, 0);
}
private int setTurnLightState(int turn_light) {
if (turn_light == 0) {
if (isOnTurnLight) {
if (turnLightTimes >= 10) {
isOnTurnLight = false;
turnLight = 0;
}
turnLightTimes++;
}
} else if (turn_light == 1) {
turnLightTimes = 0;
isOnTurnLight = true;
turnLight = 1;
} else if (turn_light == 2) {
turnLightTimes = 0;
isOnTurnLight = true;
turnLight = 2;
}
return turnLight;
}
@Override
public void onAutopilotLightSwitchData(Chassis.LightSwitch lightSwitch) {
// TODO @李小鹏 这里需要修改为由HMI 监听数据变换来更新UI而不是由数据驱动UI
//can数据转发 转向灯状态 0是正常 1是左转 2是右转
// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示
if (lightSwitch != null) {
int state = setTurnLightState(lightSwitch.getNumber());
CallerLogger.INSTANCE.d(M_DEVA + "TurnLight", "---onAutopilotLightSwitchData ---state = " + state + "---lightSwitch.getNumber() = " + lightSwitch.getNumber());
if (state == 1 || state == 2) {
isShowTurnLight = true;
CallerHmiManager.INSTANCE.showBrakeLight(0);
} else {
isShowTurnLight = false;
}
CallerHmiManager.INSTANCE.showTurnLight(state);
}
// }
}
@Override
public void onAutopilotBrakeLightData(boolean brakeLight) {
}
@Override
public void onAutopilotCarConfig(@NotNull MessagePad.CarConfigResp carConfigResp) {
if (carConfigResp != null && !TextUtils.isEmpty(carConfigResp.getMacAddress())) {
@@ -124,23 +56,5 @@ public class MoGoHandAdasMsgManager implements
}
}
@Override
public void onAutopilotCarStateData(@Nullable MessagePad.GnssInfo gnssInfo) {
//根据加速度判断 是否刹车
// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示
if (gnssInfo != null) {
//设置刹车信息
if (gnssInfo.getAcceleration() < SharedPrefsMgr.getInstance(mContext).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5F)) {
brakeLight = 1;
} else {
brakeLight = 0;
}
CallerLogger.INSTANCE.d(M_DEVA + "BrakeLight", "---onAutopilotLightSwitchData ---Acceleration = " + gnssInfo.getAcceleration() + "-- brakeLight = " + brakeLight);
if (!isShowTurnLight) {
CallerHmiManager.INSTANCE.showBrakeLight(brakeLight);
}
// }
}
}
}