[清扫车] feat: 底盘数据回调,增加最小时间间隔判断,避免回调太频繁导致阻塞;
This commit is contained in:
@@ -736,6 +736,11 @@ public class SweeperOperatePanelView extends LinearLayout {
|
||||
});
|
||||
}
|
||||
|
||||
// 当前时间戳
|
||||
private long mCurrentTimeMillis;
|
||||
// 底盘数据回调时间间隔
|
||||
private static final long VEHICLE_STATE_INTERVAL_MILLIS = 500L;
|
||||
|
||||
/**
|
||||
* 底盘数据透传listener
|
||||
*/
|
||||
@@ -774,6 +779,13 @@ public class SweeperOperatePanelView extends LinearLayout {
|
||||
|
||||
@Override
|
||||
public void onSweeperFutianCleanSystemState(@NonNull VehicleStateOuterClass.SweeperFuTianCleanSystemState cleanSystemState) {
|
||||
long current = System.currentTimeMillis();
|
||||
if (current - mCurrentTimeMillis <= VEHICLE_STATE_INTERVAL_MILLIS) {
|
||||
return;
|
||||
}
|
||||
mCurrentTimeMillis = current;
|
||||
|
||||
Log.d(TAG, "onSweeperFutianCleanSystemState");
|
||||
// 第一次进入时同步底盘状态,只拿第一次的数据
|
||||
if (mSyncingVehicleState) {
|
||||
onSyncVehicleStateCallBack(cleanSystemState);
|
||||
@@ -793,11 +805,12 @@ public class SweeperOperatePanelView extends LinearLayout {
|
||||
protected void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
CallerAutopilotVehicleStateListenerManager.INSTANCE.addListener(TAG, mIMoGoAutopilotVehicleStateListener);
|
||||
// TODO 最终调试时需要打开
|
||||
//syncVehicleStateAndRecoverOperatePanelStates();
|
||||
// Mock VehicleState 数据回调
|
||||
// UiThreadHandler.postDelayed(() -> {
|
||||
// onSyncVehicleStateCallBack(SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData());
|
||||
// }, 3000L);
|
||||
// UiThreadHandler.postDelayed(() -> {
|
||||
// onSyncVehicleStateCallBack(SweeperFutianCmdUtil.buildSweeperFuTionCleanSystemStateMockData());
|
||||
// }, 3000L);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user