[状态栏]Can数据状态获取逻辑优化

This commit is contained in:
renwj
2022-05-27 17:00:56 +08:00
parent 86c21ddf07
commit 430328ea7f
21 changed files with 92 additions and 68 deletions

View File

@@ -289,7 +289,7 @@ public class BusPassengerModel {
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener(){
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
}
@Override

View File

@@ -6,6 +6,7 @@ import android.location.Location;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.LifecycleOwner;
import com.mogo.commons.mvp.Presenter;
@@ -279,6 +280,6 @@ public class BusPresenter extends Presenter<BusFragment>
}
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
}
}

View File

@@ -484,7 +484,7 @@ public class TaxiPassengerModel implements IOCHTaxiPassengerNaviChangedCallback
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
}
@Override

View File

@@ -1043,7 +1043,7 @@ public class TaxiModel {
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() {
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
}
@Override

View File

@@ -1,5 +1,6 @@
package com.mogo.eagle.core.function.autopilot.adapter
import android.util.*
import chassis.VehicleStateOuterClass
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.config.HdMapBuildConfig
@@ -139,6 +140,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
header: MessagePad.Header,
vehicleState: VehicleStateOuterClass.VehicleState?
) {
if (vehicleState != null) {
//转向灯数据
CallerAutopilotVehicleStateListenerManager.invokeAutopilotLightSwitchData(vehicleState.light)
@@ -149,10 +151,7 @@ class MoGoAdasListenerImpl : OnAdasListener {
//挂挡档位数据
CallerAutopilotVehicleStateListenerManager.invokeAutopilotGearData(vehicleState.gear)
} else {
/**
* 底盘没有返回数据
*/
CallerAutopilotVehicleStateListenerManager.invokeAutopilotNotData(header.timestamp.toLong())
CallerAutopilotVehicleStateListenerManager.invokeAutopilotDataException(header.timestamp.toLong())
}
}

View File

@@ -36,6 +36,7 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
private var connectStatus = false
override fun onConnectionIPCStatus(ipcConnectionStatus: Int, reason: String?) {
CallerAutoPilotStatusListenerManager.invokeAutoPilotIPCStatusChanged(ipcConnectionStatus, reason)
if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
CallerLogger.d("$M_ADAS_IMPL$TAG", "webSocket 连接成功")
connectStatus = true

View File

@@ -7,7 +7,6 @@ import android.util.Log;
import androidx.annotation.Nullable;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.constants.MoGoConfig;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener;
@@ -20,7 +19,6 @@ 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.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.util.GsonUtils;
import org.jetbrains.annotations.NotNull;
@@ -150,7 +148,6 @@ public class MoGoHandAdasMsgManager implements
}
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotDataException(long timestamp) {
}
}

View File

@@ -4,11 +4,12 @@ import android.content.*
import android.util.*
import chassis.Chassis.GearPosition
import chassis.Chassis.LightSwitch
import com.mogo.eagle.core.data.autopilot.*
import com.mogo.eagle.core.function.api.autopilot.*
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.utilcode.kotlin.*
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
import com.zhjt.mogo_core_function_devatools.status.entity.CanStatus
import kotlinx.coroutines.*
internal class CanImpl(ctx: Context): IFlow<CanStatus>(ctx), IMoGoAutopilotVehicleStateListener, IMoGoAutopilotStatusListener {
@@ -16,44 +17,61 @@ internal class CanImpl(ctx: Context): IFlow<CanStatus>(ctx), IMoGoAutopilotVehic
const val TAG = "CanImpl"
}
private var job: Job? = null
override fun onCreate() {
Log.d(TAG, "-- onCreate --")
send(CanStatus(false))
send(CanStatus(CallerAutoPilotManager.isConnected()))
CallerAutopilotVehicleStateListenerManager.addListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
super.onAutopilotStatusResponse(autoPilotStatusInfo)
if (!CallerAutoPilotManager.isConnected()) {
send(CanStatus(false))
}
override fun onAutopilotLightSwitchData(lightSwitch: LightSwitch?) {
send(CanStatus(CallerAutoPilotManager.isConnected()))
timeOutCheck()
}
override fun onAutopilotLightSwitchData(lightSwitch: LightSwitch?) {
send(CanStatus(true))
}
override fun onAutopilotBrakeLightData(brakeLight: Boolean) {
send(CanStatus(true))
send(CanStatus(CallerAutoPilotManager.isConnected()))
timeOutCheck()
}
override fun onAutopilotSteeringData(steering: Float) {
send(CanStatus(true))
send(CanStatus(CallerAutoPilotManager.isConnected()))
timeOutCheck()
}
override fun onAutopilotGearData(gear: GearPosition) {
send(CanStatus(true))
send(CanStatus(CallerAutoPilotManager.isConnected()))
timeOutCheck()
}
override fun onAutopilotNotData(timestamp: Long) {
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
super.onAutopilotIpcConnectStatusChanged(status, reason)
send(CanStatus(CallerAutoPilotManager.isConnected()))
timeOutCheck()
}
override fun onAutopilotDataException(timestamp: Long) {
super.onAutopilotDataException(timestamp)
send(CanStatus(false))
timeOutCheck()
}
private fun timeOutCheck() {
job?.safeCancel()
launch(Dispatchers.Default) {
delay(1000)
send(CanStatus(false))
}.also { job = it }
}
override fun onDestroy() {
super.onDestroy()
job?.safeCancel()
Log.d(TAG, "-- onDestroy --")
CallerAutoPilotStatusListenerManager.removeListener(TAG)
CallerAutopilotVehicleStateListenerManager.removeListener(TAG)
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
}

View File

@@ -22,13 +22,11 @@ internal class IpcImpl(ctx: Context): IFlow<IpcStatus>(ctx), IMoGoAutopilotStatu
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
super.onAutopilotStatusResponse(autoPilotStatusInfo)
Log.d(TAG, "-- onAutopilotStatusResponse -- state: ${autoPilotStatusInfo.state}")
if (state != autoPilotStatusInfo.state) {
override fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {
super.onAutopilotIpcConnectStatusChanged(status, reason)
if (state != status) {
checkAndSend()
state = autoPilotStatusInfo.state
state = status
}
}

View File

@@ -5,8 +5,7 @@ import android.util.*
import com.mogo.eagle.core.function.api.autopilot.*
import com.mogo.eagle.core.function.call.autopilot.*
import com.zhjt.mogo_core_function_devatools.status.entity.*
import com.zhjt.mogo_core_function_devatools.status.entity.TracingStatus
import com.zhjt.mogo_core_function_devatools.status.flow.IFlow
import com.zhjt.mogo_core_function_devatools.status.flow.*
import mogo_msg.MogoReportMsg.MogoReportMessage
internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopilotStatusListener {
@@ -29,8 +28,8 @@ internal class TracingImpl(ctx: Context): IFlow<TracingStatus>(ctx), IMoGoAutopi
override fun onAutopilotGuardian(guardianInfo: MogoReportMessage?) {
super.onAutopilotGuardian(guardianInfo)
val current = guardianInfo?.code
Log.d(TAG, "-- onAutopilotGuardian --: $current")
if (current != null && current != old) {
Log.d(TAG, "-- onAutopilotGuardian --")
send(TracingStatus(current.toState()))
old = current
}

View File

@@ -1,5 +1,6 @@
package com.zhjt.mogo_core_function_devatools.status.model
import android.util.*
import androidx.lifecycle.*
import com.mogo.eagle.core.function.call.autopilot.*
import com.zhjt.mogo_core_function_devatools.status.entity.CanStatus
@@ -43,6 +44,8 @@ internal class StatusModel : ViewModel() {
val nv = ArrayList(v).also { it.updateOrInsert(s) }
val data = Pair(getExceptionStatus(nv), nv)
old.set(data)
Log.d(TAG, "status: $s")
Log.d(TAG, "data: ${data.second}")
status.postValue(data)
}
}
@@ -80,7 +83,9 @@ internal class StatusModel : ViewModel() {
}
}
is TracingStatus -> {
if (CallerAutoPilotManager.isConnected() && s.state.isException()) {
if (CallerAutoPilotManager.isConnected() &&
(CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().pilotmode == 1) &&
s.state.isException()) {
s
} else {
null

View File

@@ -38,6 +38,8 @@ import static com.zhjt.dispatch.model.DispatchServiceModel.DISPATCH_RESULT_AFFIR
import static com.zhjt.dispatch.model.DispatchServiceModel.DISPATCH_RESULT_MANUAL_CANCEL;
import static com.zhjt.dispatch.model.DispatchServiceModel.DISPATCH_RESULT_TIMER_CANCEL;
import androidx.annotation.Nullable;
import mogo.telematics.pad.MessagePad;
import mogo_msg.MogoReportMsg;
@@ -335,6 +337,6 @@ public class DispatchAutoPilotManager implements IMogoOnMessageListener<Dispatch
}
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
}
}

View File

@@ -9,13 +9,11 @@ import android.graphics.Color
import android.os.Build
import android.text.Html
import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import androidx.annotation.RequiresApi
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
import androidx.core.content.ContextCompat.getSystemService
import androidx.recyclerview.widget.LinearLayoutManager
import chassis.Chassis
import com.mogo.cloud.passport.MoGoAiCloudClient
@@ -1779,10 +1777,6 @@ class DebugSettingView @JvmOverloads constructor(
}
}
override fun onAutopilotNotData(timestamp: Long) {
}
/**
* 吐司提示
*/

View File

@@ -101,8 +101,9 @@ public class SteeringWheelView extends ConstraintLayout {
}
private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() {
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
}
@Override
@@ -150,10 +151,6 @@ public class SteeringWheelView extends ConstraintLayout {
};
private final IMoGoAutopilotVehicleStateListener mIMoGoAutopilotVehicleStateListener = new IMoGoAutopilotVehicleStateListener() {
@Override
public void onAutopilotNotData(long timestamp) {
}
/**
* 车辆转向灯
@@ -223,6 +220,11 @@ public class SteeringWheelView extends ConstraintLayout {
});
}
@Override
public void onAutopilotDataException(long timestamp) {
}
};
/**

View File

@@ -75,10 +75,6 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
FragmentStackTransactionListener,
IMoGoAutopilotStatusListener {
@Override
public void onAutopilotNotData(long timestamp) {
}
protected static final String TAG = "MainActivity";
private static final int REQUEST_CODE_DIALOG = 100;
@@ -393,6 +389,9 @@ public class MainActivity extends MvpActivity<MainView, MainPresenter> implement
public void onAutopilotGuardian(@Nullable MogoReportMsg.MogoReportMessage guardianInfo) {
}
@Override
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) { }
@Override
public void onAutopilotSNRequest() {
}

View File

@@ -4,6 +4,8 @@ import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.commons.mvp.BaseFragment;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
@@ -55,10 +57,6 @@ public class SmallMapFragment extends BaseFragment
SmpServiceManager.init(getContext());
}
@Override
public void onAutopilotNotData(long timestamp) {
}
@Override
protected void initViews(Bundle savedInstanceState) {
super.initViews(savedInstanceState);
@@ -159,6 +157,10 @@ public class SmallMapFragment extends BaseFragment
}
@Override
public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) {
}
@Override
public void onAutopilotRotting(MessagePad.GlobalPathResp globalPathResp) {
if (globalPathResp == null || globalPathResp.getWayPointsList().size() == 0) {

View File

@@ -36,9 +36,9 @@ interface IMoGoAutopilotStatusListener {
fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) {}
/**
* 工控机底盘没有返回数据
* 工控机连接状态回调
*/
fun onAutopilotNotData(timestamp: Long) {}
fun onAutopilotIpcConnectStatusChanged(status: Int, reason: String?) {}
companion object {

View File

@@ -31,8 +31,9 @@ interface IMoGoAutopilotVehicleStateListener {
*/
fun onAutopilotGearData(gear: Chassis.GearPosition)
/**
* 底盘没有返回数据
* 没有自车状态数据
*/
fun onAutopilotNotData(timestamp: Long)
fun onAutopilotDataException(timestamp: Long){}
}

View File

@@ -167,12 +167,21 @@ object CallerAutoPilotStatusListenerManager : CallerBase() {
@Synchronized
fun invokeAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) {
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val tag = it.key
val listener = it.value
autoPilotMessageCode = guardianInfo?.code ?: ""
listener.onAutopilotGuardian(guardianInfo)
}
}
/**
* 工控机与车机连接状态回调
*/
fun invokeAutoPilotIPCStatusChanged(ipcConnectionStatus: Int, reason: String?) {
M_AUTOPILOT_STATUS_LISTENERS.forEach {
val listener = it.value
listener.onAutopilotIpcConnectStatusChanged(ipcConnectionStatus, reason)
}
}
}

View File

@@ -114,13 +114,10 @@ object CallerAutopilotVehicleStateListenerManager : CallerBase() {
return this.timeStamp
}
/**
* 底盘没有返回数据
*/
fun invokeAutopilotNotData(timestamp: Long) {
fun invokeAutopilotDataException(timestamp: Long) {
M_AUTOPILOT_VEHICLE_LISTENERS.forEach{
val listener = it.value
listener.onAutopilotNotData(timestamp)
listener.onAutopilotDataException(timestamp)
}
}
}

View File

@@ -211,6 +211,6 @@ public class MogoRouteOverlayManager implements
}
@Override
public void onAutopilotNotData(long timestamp) {
public void onAutopilotIpcConnectStatusChanged(int status, @androidx.annotation.Nullable String reason) {
}
}