[code_opt_3.3.0] code opt
This commit is contained in:
@@ -174,7 +174,7 @@ internal class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
svLayout.post {
|
||||
svLayout.fullScroll(View.FOCUS_DOWN)
|
||||
}
|
||||
if (!connectStatus) {
|
||||
if (!connectStatus) { //todo 单次获取
|
||||
ToastUtils.showShort("设置车速失败,请启动域控制器")
|
||||
keyBoardUtil?.hideKeyboard()
|
||||
return@setOnTouchListener true
|
||||
|
||||
@@ -107,7 +107,7 @@ class CheckSystemView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
connectStatus = autoPilotStatusInfo.connectStatus
|
||||
connectStatus = autoPilotStatusInfo.connectStatus //单次
|
||||
autopilotStatus = autoPilotStatusInfo.state
|
||||
ThreadUtils.runOnUiThread {
|
||||
setViewStatus()
|
||||
|
||||
@@ -6,8 +6,6 @@ import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.widget.FrameLayout
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.datacenter.union.ILimitingVelocityListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
|
||||
@@ -18,8 +16,7 @@ class SpeedPanelView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : FrameLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
ILimitingVelocityListener {
|
||||
) : FrameLayout(context, attrs, defStyleAttr), ILimitingVelocityListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "SpeedPanelView"
|
||||
@@ -27,8 +24,6 @@ class SpeedPanelView @JvmOverloads constructor(
|
||||
|
||||
var mContext: Context
|
||||
var mSpeedChartView: SpeedChartView
|
||||
@Volatile
|
||||
var mLatLng: MogoLocation? = null
|
||||
|
||||
init {
|
||||
setBackgroundResource(R.drawable.yi_biao_pan_bg_nor)
|
||||
@@ -47,31 +42,22 @@ class SpeedPanelView @JvmOverloads constructor(
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerLimitingVelocityListenerManager.addListener(TAG, this)
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this)
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
mogoLocation?.let {
|
||||
mLatLng = mogoLocation
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLimitingVelocityChange(limitingVelocity: Int, sourceType: DataSourceType) {
|
||||
super.onLimitingVelocityChange(limitingVelocity, sourceType)
|
||||
mLatLng?.let {
|
||||
UiThreadHandler.post {
|
||||
val speed = (it.gnssSpeed * 3.6f).toInt()
|
||||
mSpeedChartView.setArcColor(Color.parseColor(if (speed > limitingVelocity) "#DB3137" else "#3E77F6"))
|
||||
mSpeedChartView.setValues(speed)
|
||||
setBackgroundResource(if (speed > limitingVelocity) R.drawable.yi_biao_pan_bg_speeding else R.drawable.yi_biao_pan_bg_nor)
|
||||
}
|
||||
UiThreadHandler.post {
|
||||
val speed =
|
||||
(CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02().gnssSpeed * 3.6f).toInt()
|
||||
mSpeedChartView.setArcColor(Color.parseColor(if (speed > limitingVelocity) "#DB3137" else "#3E77F6"))
|
||||
mSpeedChartView.setValues(speed)
|
||||
setBackgroundResource(if (speed > limitingVelocity) R.drawable.yi_biao_pan_bg_speeding else R.drawable.yi_biao_pan_bg_nor)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerLimitingVelocityListenerManager.removeListener(TAG)
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,7 +43,6 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
const val TAG = "SystemVersionView"
|
||||
}
|
||||
|
||||
private var connectStatus = false
|
||||
private var dockerVersion: String? = null //工控机版本
|
||||
private var autopilotStatus: Int? = null //自动驾驶状态 0代表不可自动驾驶,1代表可自动驾驶,2代表自动驾驶中
|
||||
|
||||
@@ -322,20 +321,12 @@ class SystemVersionView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
|
||||
connectStatus = autoPilotStatusInfo.connectStatus
|
||||
dockerVersion = autoPilotStatusInfo.dockVersion
|
||||
autopilotStatus = autoPilotStatusInfo.state
|
||||
CallerLogger.i(
|
||||
"$M_HMI$TAG",
|
||||
"onAutopilotStatusResponse connectStatus=$connectStatus , dockerVersion=$dockerVersion , autopilotStatus=$autopilotStatus"
|
||||
"onAutopilotStatusResponse dockerVersion=$dockerVersion , autopilotStatus=$autopilotStatus"
|
||||
)
|
||||
// if(needQueryContainers && !AdUpgradeStateHelper.isUpgradeableStatus()){
|
||||
// dockerVersion?.let {
|
||||
// //查询是否有新的工控机docker版本
|
||||
// CallerBindingcarManager.getBindingcarProvider().queryContainers(MoGoAiCloudClient.getInstance().aiCloudClientConfig.sn,dockerVersion)
|
||||
// needQueryContainers = false
|
||||
// }
|
||||
// }
|
||||
setViewStatus()
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ public class TrafficDataView extends ConstraintLayout implements
|
||||
} else {
|
||||
accTextView.setText("- " + accStr);
|
||||
}
|
||||
int state = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getState();
|
||||
int state = CallerAutoPilotStatusListenerManager.INSTANCE.getState();
|
||||
if (state < STATUS_AUTOPILOT_RUNNING) {
|
||||
if (mBrake > 0) {
|
||||
brakeStatus.setImageResource(R.drawable.traffic_data_brake);
|
||||
|
||||
@@ -176,200 +176,11 @@ public class PassengerLauncherActivity extends MainActivity implements IMogoInte
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
private long startPressTime = 0; //开始按减时间
|
||||
private boolean isPressEnd = false; //按键是否结束
|
||||
private boolean isCombinationKey = false; //是否是组合按键
|
||||
|
||||
private long pressADownTime = 0;
|
||||
private long pressAUpTime = 0;
|
||||
private long pressBDownTime = 0;
|
||||
private long pressBUpTime = 0;
|
||||
private long pressCDownTime = 0;
|
||||
private long pressCUpTime = 0;
|
||||
private long pressDDownTime = 0;
|
||||
private long pressDUpTime = 0;
|
||||
private long pressEDownTime = 0;
|
||||
private long pressEUpTime = 0;
|
||||
|
||||
|
||||
/**
|
||||
* 魔方按键分发 提测前注释 ToastUtils TODO
|
||||
*
|
||||
* @param event
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
// Log.d(TAG, "dispatchKeyEvent code = " + event.getKeyCode() + "--action = " + event.getAction() + "----" + event);
|
||||
String bluetoothName = SharedPrefsMgr.getInstance(getContext()).getString("BLUETOOTH");
|
||||
if (!isPressEnd) {
|
||||
Log.e(TAG, "dispatchKeyEvent bluetoothName = " + bluetoothName);
|
||||
}
|
||||
if (bluetoothName.equals("MINI_KEYBOARD")) {
|
||||
if (!isPressEnd) {
|
||||
isPressEnd = true;
|
||||
startPressTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_A) { //单击 -1,长按无操作,AB组合-2
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressADownTime = System.currentTimeMillis();
|
||||
Log.d(TAG, "dispatchKeyEvent A down pressADownTime = " + pressADownTime + "---" + (pressADownTime - startPressTime) + "----isCombinationKey = " + isCombinationKey + "--pressBDownTime = " + pressBDownTime);
|
||||
if ((pressADownTime - startPressTime) > 350 && (pressADownTime - startPressTime) < 1800 && pressBDownTime > 0) {
|
||||
ToastUtils.showShort("方块 A 按AB组合 -2 ");
|
||||
sendAcc(true, -2);
|
||||
isCombinationKey = true;
|
||||
}
|
||||
if (!isCombinationKey) {
|
||||
if ((pressADownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按A 无 操作 ");
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressAUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
Log.e(TAG, "dispatchKeyEvent A up pressAUpTime = " + pressAUpTime + "---" + (pressAUpTime - startPressTime) + "--pressBDownTime = " + pressBDownTime);
|
||||
if ((pressAUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击A -1 ");
|
||||
sendAcc(true, -1);
|
||||
}
|
||||
pressAUpTime = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_B) {//单击复原,长按+1,AB组合-2
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressBDownTime = System.currentTimeMillis();
|
||||
Log.d(TAG, "dispatchKeyEvent B down pressBDownTime = " + pressBDownTime + "--差-" + (pressBDownTime - startPressTime) + "---isCombinationKey = " + isCombinationKey + "--pressADownTime = " + pressADownTime);
|
||||
if ((pressBDownTime - startPressTime) > 350 && (pressBDownTime - startPressTime) < 1800 && pressADownTime > 0) {
|
||||
ToastUtils.showShort("方块 B 按AB组合 ");
|
||||
sendAcc(true, -2);
|
||||
isCombinationKey = true;
|
||||
}
|
||||
if (!isCombinationKey) {
|
||||
if ((pressBDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按B =1 ");
|
||||
sendAcc(true, +1);
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressBUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
Log.e(TAG, "dispatchKeyEvent B up pressBUpTime = " + pressBUpTime + "--差-" + (pressBUpTime - startPressTime) + "--pressADownTime = " + pressADownTime);
|
||||
if ((pressBUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击B 0 ");
|
||||
sendAcc(false, 0.0);
|
||||
}
|
||||
pressBDownTime = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_C) { //单击左变道,长按无操作
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressCDownTime = System.currentTimeMillis();
|
||||
if (!isCombinationKey) {
|
||||
if ((pressCDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按C 无操作 ");
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressCUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
if ((pressCUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击C ← 向左变道 ");
|
||||
CallerAutoPilotControlManager.INSTANCE.sendOperatorChangeLaneLeft();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_D) { //单击向右变道,双击无操作
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressDDownTime = System.currentTimeMillis();
|
||||
if (!isCombinationKey) {
|
||||
if ((pressDDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按D 无操作 ");
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressDUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
if ((pressDUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击D → 向右变道 ");
|
||||
CallerAutoPilotControlManager.INSTANCE.sendOperatorChangeLaneRight();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (event.getKeyCode() == KeyEvent.KEYCODE_E) { //单击启动自驾,长按鸣笛
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
pressEDownTime = System.currentTimeMillis();
|
||||
if (!isCombinationKey) {
|
||||
if ((pressEDownTime - startPressTime) > 1900) {
|
||||
ToastUtils.showShort("方块 长按E 鸣笛 ");
|
||||
CallerAutoPilotControlManager.INSTANCE.sendOperatorSetHorn(1);
|
||||
if (timerHorn == null) {
|
||||
timerHorn = new Timer();
|
||||
}
|
||||
timerHorn.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotControlManager.INSTANCE.sendOperatorSetHorn(2);
|
||||
timerHorn = null;
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
} else if (event.getAction() == KeyEvent.ACTION_UP) {
|
||||
pressEUpTime = System.currentTimeMillis();
|
||||
isPressEnd = false;
|
||||
isCombinationKey = false;
|
||||
if ((pressEUpTime - startPressTime) < 300) {
|
||||
ToastUtils.showShort("方块 单击E 开启自动驾驶 ");
|
||||
CallerAutoPilotControlManager.INSTANCE.startAutoPilot(CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo().getAutopilotControlParameters());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkinModeChange(int skinMode) {
|
||||
|
||||
}
|
||||
|
||||
private synchronized void sendAcc(boolean isSend, double acc) {
|
||||
if (isSend) {
|
||||
accelerated = acc;
|
||||
if (timerAcc == null) {
|
||||
timerAcc = new Timer();
|
||||
timerAcc.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
CallerAutoPilotControlManager.INSTANCE.sendOperatorSetAcceleratedSpeed(accelerated);
|
||||
}
|
||||
}, 0, 500);
|
||||
}
|
||||
} else {
|
||||
if (timerAcc != null) {
|
||||
timerAcc.cancel();
|
||||
timerAcc = null;
|
||||
}
|
||||
CallerAutoPilotControlManager.INSTANCE.sendOperatorSetAcceleratedSpeed(acc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化蓝牙广播
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user