优化工控机监控代码
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.MainActivity"
|
||||
android:resizeableActivity="false"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
@@ -51,6 +52,7 @@
|
||||
|
||||
<activity
|
||||
android:name=".ui.AutopilotConfigActivity"
|
||||
android:resizeableActivity="false"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
|
||||
</activity>
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
package com.zhidao.adas.client;
|
||||
|
||||
import com.zhidao.adas.client.bean.ArrivalNotification;
|
||||
import com.zhidao.adas.client.bean.AutopilotState;
|
||||
import com.zhidao.adas.client.bean.BaseInfo;
|
||||
import com.zhidao.adas.client.bean.BasicInfoReq;
|
||||
import com.zhidao.adas.client.bean.CarConfigResp;
|
||||
import com.zhidao.adas.client.bean.ErrorData;
|
||||
import com.zhidao.adas.client.bean.GlobalPathResp;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.bean.MogoReportMessage;
|
||||
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
|
||||
import com.zhidao.adas.client.bean.RecordPanel;
|
||||
import com.zhidao.adas.client.bean.TrackedObjects;
|
||||
import com.zhidao.adas.client.bean.Trajectory;
|
||||
import com.zhidao.adas.client.bean.VehicleState;
|
||||
import com.zhidao.adas.client.bean.Warn;
|
||||
import com.zhidao.adas.client.log.LogSave;
|
||||
import com.zhidao.support.adas.high.common.ThreadPoolManager;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
/**
|
||||
* 数据分发
|
||||
*/
|
||||
public class DataDistribution {
|
||||
private static final String TAG = DataDistribution.class.getSimpleName();
|
||||
private volatile static DataDistribution INSTANCE;
|
||||
private final LinkedBlockingQueue<BaseInfo> queue;
|
||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS ", Locale.getDefault());
|
||||
private Future future;
|
||||
private final List<OnAdasClientListener> listeners = new ArrayList<>();
|
||||
|
||||
private DataDistribution() {
|
||||
queue = new LinkedBlockingQueue<>();
|
||||
start();
|
||||
}
|
||||
|
||||
public static DataDistribution getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (DataDistribution.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new DataDistribution();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void registerOnAdasClientListener(OnAdasClientListener listener) {
|
||||
if (!listeners.contains(listener)) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterOnAdasClientListener(OnAdasClientListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
|
||||
public void addData(BaseInfo info) {
|
||||
queue.add(info);
|
||||
}
|
||||
|
||||
|
||||
public void start() {
|
||||
if (future == null) {
|
||||
future = ThreadPoolManager.getsInstance().submit(new WriteThread());
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
queue.clear();
|
||||
if (future != null && !future.isCancelled()) {
|
||||
future.cancel(true);
|
||||
}
|
||||
future = null;
|
||||
}
|
||||
|
||||
|
||||
private static final int LIST_SIZE = 5;//默认list最大数据量5个
|
||||
public final List<String> listTrajectory = new ArrayList<>();
|
||||
public final List<String> listTrackedObjects = new ArrayList<>();
|
||||
public final List<String> listGnssInfo = new ArrayList<>();
|
||||
public final List<String> listVehicleState = new ArrayList<>();
|
||||
public final List<String> listAutopilotState = new ArrayList<>();
|
||||
public final List<String> listMogoReportMessage = new ArrayList<>();
|
||||
public final List<String> listPerceptionTrafficLight = new ArrayList<>();
|
||||
public final List<String> listBasicInfoReq = new ArrayList<>();
|
||||
public final List<String> listRecordPanel = new ArrayList<>();
|
||||
public final List<String> listGlobalPathResp = new ArrayList<>();
|
||||
public final List<String> listWarn = new ArrayList<>();
|
||||
public final List<String> listArrivalNotification = new ArrayList<>();
|
||||
public final List<String> listErrorData = new ArrayList<>();
|
||||
public final List<String> listUpdate = new ArrayList<>();
|
||||
|
||||
private String onTransmit(String time, BaseInfo data) {
|
||||
String str = data.toString();
|
||||
if (data instanceof Trajectory) {
|
||||
String temp = time + str;
|
||||
if (temp.length() > 588) {
|
||||
temp = temp.substring(0, 588) + "\n(已缩短。如需查看完整数据,请勾选日志存储复选框)";
|
||||
}
|
||||
listTrajectory.add(temp);
|
||||
if (listTrajectory.size() > LIST_SIZE) {
|
||||
listTrajectory.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof TrackedObjects) {
|
||||
String temp = time + str;
|
||||
if (temp.length() > 588) {
|
||||
temp = temp.substring(0, 588) + "\n(已缩短。如需查看完整数据,请勾选日志存储复选框)";
|
||||
}
|
||||
listTrackedObjects.add(temp);
|
||||
if (listTrackedObjects.size() > LIST_SIZE) {
|
||||
listTrackedObjects.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof GnssInfo) {
|
||||
listGnssInfo.add(time + str);
|
||||
if (listGnssInfo.size() > LIST_SIZE) {
|
||||
listGnssInfo.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof VehicleState) {
|
||||
listVehicleState.add(time + str);
|
||||
if (listVehicleState.size() > LIST_SIZE) {
|
||||
listVehicleState.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof AutopilotState) {
|
||||
listAutopilotState.add(time + str);
|
||||
if (listAutopilotState.size() > LIST_SIZE) {
|
||||
listAutopilotState.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof MogoReportMessage) {
|
||||
listMogoReportMessage.add(time + str);
|
||||
if (listMogoReportMessage.size() > LIST_SIZE) {
|
||||
listMogoReportMessage.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof PerceptionTrafficLight) {
|
||||
listPerceptionTrafficLight.add(time + str);
|
||||
if (listPerceptionTrafficLight.size() > LIST_SIZE) {
|
||||
listPerceptionTrafficLight.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof BasicInfoReq) {
|
||||
listBasicInfoReq.add(time + str);
|
||||
if (listBasicInfoReq.size() > LIST_SIZE) {
|
||||
listBasicInfoReq.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof CarConfigResp) {
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof RecordPanel) {
|
||||
listRecordPanel.add(time + str);
|
||||
if (listRecordPanel.size() > LIST_SIZE) {
|
||||
listRecordPanel.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof GlobalPathResp) {
|
||||
listGlobalPathResp.add(time + str);
|
||||
if (listGlobalPathResp.size() > LIST_SIZE) {
|
||||
listGlobalPathResp.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof Warn) {
|
||||
listWarn.add(time + str);
|
||||
if (listWarn.size() > LIST_SIZE) {
|
||||
listWarn.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof ArrivalNotification) {
|
||||
listArrivalNotification.add(time + str);
|
||||
if (listArrivalNotification.size() > LIST_SIZE) {
|
||||
listArrivalNotification.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
} else if (data instanceof ErrorData) {
|
||||
listErrorData.add(time + str);
|
||||
if (listErrorData.size() > 50) {
|
||||
listErrorData.remove(0);
|
||||
}
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
listener.onRefresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
private class WriteThread implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (this) {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
try {
|
||||
BaseInfo data = queue.take();
|
||||
String time = sdf.format(new Date(data.nowTime));
|
||||
String temp = onTransmit(time, data);
|
||||
String builder = time + "[action]:" + data.action + " [data]:" + temp;
|
||||
LogSave.getInstance().saveLog(builder);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,154 +1,140 @@
|
||||
package com.zhidao.adas.client;
|
||||
|
||||
import com.zhidao.adas.client.bean.ArrivalNotification;
|
||||
import com.zhidao.adas.client.bean.AutopilotState;
|
||||
import com.zhidao.adas.client.bean.BasicInfoReq;
|
||||
import com.zhidao.adas.client.bean.CarConfigResp;
|
||||
import com.zhidao.adas.client.bean.GlobalPathResp;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.bean.MogoReportMessage;
|
||||
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
|
||||
import com.zhidao.adas.client.bean.RecordPanel;
|
||||
import com.zhidao.adas.client.bean.TrackedObjects;
|
||||
import com.zhidao.adas.client.bean.Trajectory;
|
||||
import com.zhidao.adas.client.bean.VehicleState;
|
||||
import com.zhidao.adas.client.bean.Warn;
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeStateInfo;
|
||||
import com.zhidao.support.adas.high.bean.SSHResult;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
|
||||
public abstract class OnAdasClientListener {
|
||||
/**
|
||||
* 自动驾驶局部轨迹 车前引导线
|
||||
*
|
||||
* @param trajectory 数据
|
||||
*/
|
||||
public void onTrajectory(Trajectory trajectory) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 障碍物 他车数据
|
||||
*
|
||||
* @param trackedObjects 数据
|
||||
*/
|
||||
public void onTrackedObjects(TrackedObjects trackedObjects) {
|
||||
}
|
||||
public abstract void onRefresh();
|
||||
|
||||
/**
|
||||
* 惯导信息
|
||||
*
|
||||
* @param gnssInfo 数据
|
||||
*/
|
||||
public void onGnssInfo(GnssInfo gnssInfo) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 底盘信息, 透传底盘状态,pb参考底盘
|
||||
*
|
||||
* @param vehicleState 数据
|
||||
*/
|
||||
public void onVehicleState(VehicleState vehicleState) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶状态
|
||||
*
|
||||
* @param autopilotState 数据
|
||||
*/
|
||||
public void onAutopilotState(AutopilotState autopilotState) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控事件报告
|
||||
*
|
||||
* @param mogoReportMessage 数据
|
||||
*/
|
||||
public void onReportMessage(MogoReportMessage mogoReportMessage) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 感知红绿灯
|
||||
*
|
||||
* @param trafficLights 感知红绿灯
|
||||
*/
|
||||
public void onPerceptionTrafficLight(PerceptionTrafficLight trafficLights) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶设备基础信息请求
|
||||
*
|
||||
* @param basicInfoReq 数据 目前没有任何参数
|
||||
*/
|
||||
public void onBasicInfoReq(BasicInfoReq basicInfoReq) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 车机基础信息应答
|
||||
*
|
||||
* @param carConfigResp 数据
|
||||
*/
|
||||
public void onCarConfigResp(CarConfigResp carConfigResp) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据采集结果
|
||||
*
|
||||
* @param recordPanel 数据
|
||||
*/
|
||||
public void onRecordResult(RecordPanel recordPanel) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动驾驶路径应答
|
||||
*
|
||||
* @param globalPathResp 数据
|
||||
*/
|
||||
public void onGlobalPathResp(GlobalPathResp globalPathResp) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 报警信息
|
||||
* 暂时保留,目前没有使用
|
||||
*
|
||||
* @param warn 数据
|
||||
*/
|
||||
@Deprecated
|
||||
public void onWarn(Warn warn) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 到站提醒 自动驾驶站点
|
||||
*
|
||||
* @param arrivalNotification 数据
|
||||
*/
|
||||
public void onArrivalNotification(ArrivalNotification arrivalNotification) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级状态
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
@Deprecated
|
||||
public void onUpgradeStateInfo(IPCUpgradeStateInfo info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 向IPC发送命令返回结果
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
public void onSSHResult(SSHResult info) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据错误
|
||||
*
|
||||
* @param status 错误原因
|
||||
* @param bytes 原始数据
|
||||
*/
|
||||
public void onError(ProtocolStatus status, byte[] bytes) {
|
||||
|
||||
}
|
||||
// /**
|
||||
// * 自动驾驶局部轨迹 车前引导线
|
||||
// *
|
||||
// * @param isAdd 是否是添加数据回调
|
||||
// */
|
||||
// public void onTrajectory() {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 障碍物 他车数据
|
||||
// *
|
||||
// * @param trackedObjects 数据
|
||||
// */
|
||||
// public void onTrackedObjects(TrackedObjects trackedObjects) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 惯导信息
|
||||
// *
|
||||
// * @param isAdd 是否是添加数据回调
|
||||
// */
|
||||
// public void onGnssInfo() {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 底盘信息, 透传底盘状态,pb参考底盘
|
||||
// *
|
||||
// * @param vehicleState 数据
|
||||
// */
|
||||
// public void onVehicleState(VehicleState vehicleState) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 自动驾驶状态
|
||||
// *
|
||||
// * @param autopilotState 数据
|
||||
// */
|
||||
// public void onAutopilotState(AutopilotState autopilotState) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 监控事件报告
|
||||
// *
|
||||
// * @param mogoReportMessage 数据
|
||||
// */
|
||||
// public void onReportMessage(MogoReportMessage mogoReportMessage) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 感知红绿灯
|
||||
// *
|
||||
// * @param trafficLights 感知红绿灯
|
||||
// */
|
||||
// public void onPerceptionTrafficLight(PerceptionTrafficLight trafficLights) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 自动驾驶设备基础信息请求
|
||||
// *
|
||||
// * @param basicInfoReq 数据 目前没有任何参数
|
||||
// */
|
||||
// public void onBasicInfoReq(BasicInfoReq basicInfoReq) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 车机基础信息应答
|
||||
// *
|
||||
// * @param carConfigResp 数据
|
||||
// */
|
||||
// public void onCarConfigResp(CarConfigResp carConfigResp) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 数据采集结果
|
||||
// *
|
||||
// * @param recordPanel 数据
|
||||
// */
|
||||
// public void onRecordResult(RecordPanel recordPanel) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 自动驾驶路径应答
|
||||
// *
|
||||
// * @param globalPathResp 数据
|
||||
// */
|
||||
// public void onGlobalPathResp(GlobalPathResp globalPathResp) {
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * 报警信息
|
||||
// * 暂时保留,目前没有使用
|
||||
// *
|
||||
// * @param warn 数据
|
||||
// */
|
||||
// @Deprecated
|
||||
// public void onWarn(Warn warn) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 到站提醒 自动驾驶站点
|
||||
// *
|
||||
// * @param arrivalNotification 数据
|
||||
// */
|
||||
// public void onArrivalNotification(ArrivalNotification arrivalNotification) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 升级状态
|
||||
// *
|
||||
// * @param info
|
||||
// */
|
||||
// @Deprecated
|
||||
// public void onUpgradeStateInfo(IPCUpgradeStateInfo info) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 向IPC发送命令返回结果
|
||||
// *
|
||||
// * @param info
|
||||
// */
|
||||
// public void onSSHResult(SSHResult info) {
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 数据错误
|
||||
// *
|
||||
// * @param status 错误原因
|
||||
// * @param bytes 原始数据
|
||||
// */
|
||||
// public void onError(ProtocolStatus status, byte[] bytes) {
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -12,37 +12,26 @@ import com.zhidao.adas.client.R;
|
||||
import com.zhidao.adas.client.base.BaseAdapter;
|
||||
import com.zhidao.adas.client.base.BaseViewHolder;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
//log所用
|
||||
public class DataShowAdapter extends BaseAdapter<String, DataShowAdapter.ViewHolder> {
|
||||
private final int[] colors = {Color.parseColor("#FA8072"), Color.parseColor("#FF00FF"), Color.parseColor("#228B22"), Color.parseColor("#871f78")};
|
||||
private final Random random = new Random();
|
||||
|
||||
public void refreshView(int position) {
|
||||
if (position == -1) {
|
||||
notifyDataSetChanged();
|
||||
} else {
|
||||
notifyItemInserted(position);
|
||||
}
|
||||
// notifyDataSetChanged();
|
||||
// L.i(TAG, "position=" + position);
|
||||
|
||||
public void refreshView() {
|
||||
// notifyItemChanged(mDatas.size()-1,0);
|
||||
notifyItemRangeChanged(0, getItemCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
protected void onBindDataToItem(ViewHolder viewHolder, String data, int position) {
|
||||
if (data.contains("##")) {
|
||||
String[] temp = data.split("##");
|
||||
viewHolder.id.setText("[" + temp[0] + "]" + (position + 1) + ". ");
|
||||
viewHolder.editText.setTextColor(colors[random.nextInt(4)]);
|
||||
viewHolder.editText.setText(temp[1]);
|
||||
} else {
|
||||
viewHolder.id.setText((position + 1) + ". ");
|
||||
viewHolder.editText.setTextColor(colors[random.nextInt(4)]);
|
||||
viewHolder.editText.setText(data);
|
||||
}
|
||||
viewHolder.id.setText((position + 1) + ". ");
|
||||
viewHolder.editText.setText(data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ public abstract class BaseAdapter<D, VH extends BaseViewHolder> extends Recycler
|
||||
|
||||
public void setData(List<D> mDatas) {
|
||||
this.mDatas = mDatas;
|
||||
notifyDataSetChanged();
|
||||
if (!mDatas.isEmpty())
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<D> listener) {
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
package com.zhidao.adas.client.base;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.zhidao.adas.client.DataDistribution;
|
||||
import com.zhidao.adas.client.OnAdasClientListener;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/8/16
|
||||
*/
|
||||
public abstract class BaseFragment extends Fragment {
|
||||
private static final int WHAT_REFRESH = 0x01;
|
||||
protected String title;
|
||||
|
||||
|
||||
public BaseFragment(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initHandler();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
DataDistribution.getInstance().registerOnAdasClientListener(adasClientListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
DataDistribution.getInstance().unregisterOnAdasClientListener(adasClientListener);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
if (getHandler() != null)
|
||||
getHandler().removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
protected abstract void onRefreshView();
|
||||
|
||||
|
||||
private final OnAdasClientListener adasClientListener = new OnAdasClientListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
getHandler().sendEmptyMessage(WHAT_REFRESH);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private BaseHandler mBaseHandler;
|
||||
|
||||
|
||||
/**
|
||||
* 初始化一个Handler,如果需要使用Handler,先调用此方法,
|
||||
* 然后可以使用postRunnable(Runnable runnable),
|
||||
* sendMessage在handleMessage(Message msg)中接收msg
|
||||
*/
|
||||
public void initHandler() {
|
||||
mBaseHandler = new BaseHandler(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回Handler,在此之前确定已经调用initHandler()
|
||||
*
|
||||
* @return Handler
|
||||
*/
|
||||
public Handler getHandler() {
|
||||
return mBaseHandler;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 同Handler 的 handleMessage,
|
||||
* getHandler.sendMessage,发送的Message在此接收
|
||||
* 在此之前确定已经调用initHandler()
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
protected void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case WHAT_REFRESH:
|
||||
onRefreshView();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同Handler的postRunnable
|
||||
* 在此之前确定已经调用initHandler()
|
||||
*/
|
||||
protected void postRunnable(Runnable runnable) {
|
||||
postRunnableDelayed(runnable, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同Handler的postRunnableDelayed
|
||||
* 在此之前确定已经调用initHandler()
|
||||
*/
|
||||
protected void postRunnableDelayed(Runnable runnable, long delayMillis) {
|
||||
if (mBaseHandler == null) initHandler();
|
||||
mBaseHandler.postDelayed(runnable, delayMillis);
|
||||
}
|
||||
|
||||
|
||||
protected static class BaseHandler extends Handler {
|
||||
private final WeakReference<BaseFragment> mObjects;
|
||||
|
||||
public BaseHandler(BaseFragment mPresenter) {
|
||||
mObjects = new WeakReference<BaseFragment>(mPresenter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
BaseFragment mPresenter = mObjects.get();
|
||||
if (mPresenter != null)
|
||||
mPresenter.handleMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,6 @@ public abstract class BaseInfo {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return len + "##Header:[" + TextFormat.printer().escapingNonAscii(false).shortDebugString(header) + "]\n";
|
||||
return "原始数据长度:"+len + "\nHeader:[" + TextFormat.printer().escapingNonAscii(false).shortDebugString(header) + "]\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,21 +4,7 @@ import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.zhidao.adas.client.OnAdasClientListener;
|
||||
import com.zhidao.adas.client.bean.ArrivalNotification;
|
||||
import com.zhidao.adas.client.bean.AutopilotState;
|
||||
import com.zhidao.adas.client.bean.BaseInfo;
|
||||
import com.zhidao.adas.client.bean.BasicInfoReq;
|
||||
import com.zhidao.adas.client.bean.CarConfigResp;
|
||||
import com.zhidao.adas.client.bean.GlobalPathResp;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.bean.MogoReportMessage;
|
||||
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
|
||||
import com.zhidao.adas.client.bean.RecordPanel;
|
||||
import com.zhidao.adas.client.bean.TrackedObjects;
|
||||
import com.zhidao.adas.client.bean.Trajectory;
|
||||
import com.zhidao.adas.client.bean.VehicleState;
|
||||
import com.zhidao.adas.client.bean.Warn;
|
||||
import com.zhidao.support.adas.high.common.ThreadPoolManager;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
@@ -26,9 +12,7 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
@@ -42,13 +26,12 @@ public class LogSave {
|
||||
private static final String LOG_FILE_NAME = "%s.log";//文件名称
|
||||
private volatile static LogSave INSTANCE;
|
||||
private static final long MAX_CAPACITY = 20 * 1024 * 1024L;//单文件最大存储容量 kb
|
||||
private final LinkedBlockingQueue<BaseInfo> queue;
|
||||
private final LinkedBlockingQueue<String> queue;
|
||||
private BufferedWriter buff = null;
|
||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault());
|
||||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-SSS", Locale.getDefault());
|
||||
private File file;
|
||||
private volatile long capacity = MAX_CAPACITY;
|
||||
private Future future;
|
||||
private List<OnAdasClientListener> listeners = new ArrayList<>();
|
||||
|
||||
private LogSave() {
|
||||
queue = new LinkedBlockingQueue<>();
|
||||
@@ -65,15 +48,6 @@ public class LogSave {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void registerOnAdasClientListener(OnAdasClientListener listener) {
|
||||
if (!listeners.contains(listener)) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterOnAdasClientListener(OnAdasClientListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public boolean isSdcardUse() {
|
||||
boolean bl = false;
|
||||
@@ -86,7 +60,6 @@ public class LogSave {
|
||||
private void getFile() throws IOException {
|
||||
if (isSdcardUse()) {
|
||||
String time = sdf.format(new Date());
|
||||
time = time.replace(" ", "_").replace(":", "-").replace(".", "-");
|
||||
String childPath = time.split("_")[0] + File.separator;
|
||||
file = new File(ROOT_PATH + childPath + String.format(LOG_FILE_NAME, time));
|
||||
if (!file.exists()) {
|
||||
@@ -101,12 +74,12 @@ public class LogSave {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void saveLog(BaseInfo info) {
|
||||
public void saveLog(String info) {
|
||||
if (isStart()) {
|
||||
queue.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isStart() {
|
||||
return future != null;
|
||||
}
|
||||
@@ -154,43 +127,9 @@ public class LogSave {
|
||||
closeBufferedWriter();
|
||||
getFile();
|
||||
}
|
||||
BaseInfo data = queue.take();
|
||||
if (!listeners.isEmpty()) {
|
||||
for (OnAdasClientListener listener : listeners) {
|
||||
if (data instanceof Trajectory) {
|
||||
listener.onTrajectory((Trajectory) data);
|
||||
} else if (data instanceof TrackedObjects) {
|
||||
listener.onTrackedObjects((TrackedObjects) data);
|
||||
}else if (data instanceof GnssInfo) {
|
||||
listener.onGnssInfo((GnssInfo) data);
|
||||
}else if (data instanceof VehicleState) {
|
||||
listener.onVehicleState((VehicleState) data);
|
||||
}else if (data instanceof AutopilotState) {
|
||||
listener.onAutopilotState((AutopilotState) data);
|
||||
}else if (data instanceof MogoReportMessage) {
|
||||
listener.onReportMessage((MogoReportMessage) data);
|
||||
}else if (data instanceof PerceptionTrafficLight) {
|
||||
listener.onPerceptionTrafficLight((PerceptionTrafficLight) data);
|
||||
}else if (data instanceof BasicInfoReq) {
|
||||
listener.onBasicInfoReq((BasicInfoReq) data);
|
||||
}else if (data instanceof CarConfigResp) {
|
||||
listener.onCarConfigResp((CarConfigResp) data);
|
||||
}else if (data instanceof RecordPanel) {
|
||||
listener.onRecordResult((RecordPanel) data);
|
||||
}else if (data instanceof GlobalPathResp) {
|
||||
listener.onGlobalPathResp((GlobalPathResp) data);
|
||||
}else if (data instanceof Warn) {
|
||||
listener.onWarn((Warn) data);
|
||||
}else if (data instanceof ArrivalNotification) {
|
||||
listener.onArrivalNotification((ArrivalNotification) data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String time = sdf.format(new Date(data.nowTime));
|
||||
String builder = time + " [action]:" + data.action + " [data]:" + data.toString();
|
||||
if (!TextUtils.isEmpty(builder)) {
|
||||
buff.write(builder);
|
||||
String data = queue.take();
|
||||
if (buff != null && !TextUtils.isEmpty(data)) {
|
||||
buff.write(data);
|
||||
buff.newLine();
|
||||
buff.flush();
|
||||
}
|
||||
@@ -198,9 +137,8 @@ public class LogSave {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
Log.i(TAG, "退出线程");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,18 +20,18 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.zhidao.adas.client.OnAdasClientListener;
|
||||
import com.zhidao.adas.client.R;
|
||||
import com.zhidao.adas.client.adapter.AutopilotConfigAdapter;
|
||||
import com.zhidao.adas.client.base.BaseActivity;
|
||||
import com.zhidao.adas.client.bean.UpdateDataEvent;
|
||||
import com.zhidao.adas.client.bean.AutoPilotMode;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.DataDistribution;
|
||||
import com.zhidao.adas.client.utils.Constants;
|
||||
import com.zhidao.support.adas.high.common.ThreadPoolManager;
|
||||
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -43,7 +43,8 @@ public class AutopilotConfigActivity extends BaseActivity {
|
||||
private AutopilotConfigAdapter autopilotConfigAdapter;
|
||||
private GridLayoutManager linearLayoutManager;
|
||||
|
||||
private static final int WHAT_START = 0;
|
||||
private static final int WHAT_START = 0x01;
|
||||
private static final int WHAT_UPDATE_SHOW = 0x02;
|
||||
TextView no_date;
|
||||
private TextView lonText;
|
||||
private TextView latText;
|
||||
@@ -64,7 +65,6 @@ public class AutopilotConfigActivity extends BaseActivity {
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);//左侧添加一个默认的返回图标
|
||||
getSupportActionBar().setHomeButtonEnabled(true); //设置返回键可用
|
||||
initHandler();
|
||||
EventBus.getDefault().register(this);
|
||||
initRecyclerView();
|
||||
toolbar_title.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
@@ -148,20 +148,30 @@ public class AutopilotConfigActivity extends BaseActivity {
|
||||
ThreadPoolManager.getsInstance().execute(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
DataDistribution.getInstance().registerOnAdasClientListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
DataDistribution.getInstance().unregisterOnAdasClientListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().post(new UpdateDataEvent());
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
switch (msg.what) {
|
||||
case WHAT_START:
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
if ((Boolean) msg.obj) {
|
||||
builder.setTitle("保存成功")
|
||||
.setMessage("配置保存成功啦")
|
||||
@@ -186,12 +196,19 @@ public class AutopilotConfigActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
}
|
||||
AlertDialog dialog = builder.show();
|
||||
// dialog.setCancelable(false);
|
||||
// dialog.setCanceledOnTouchOutside(false);
|
||||
break;
|
||||
case WHAT_UPDATE_SHOW:
|
||||
if (lonText != null)
|
||||
lonText.setText("Lon:" + lon);
|
||||
if (latText != null)
|
||||
latText.setText("Lat:" + lat);
|
||||
break;
|
||||
|
||||
}
|
||||
AlertDialog dialog = builder.show();
|
||||
// dialog.setCancelable(false);
|
||||
// dialog.setCanceledOnTouchOutside(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -243,17 +260,30 @@ public class AutopilotConfigActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onLocationEvent(GnssInfo info) {
|
||||
if (info != null && info.bean != null) {
|
||||
lon = info.bean.getLongitude();
|
||||
lat = info.bean.getLatitude();
|
||||
if (lonText != null)
|
||||
lonText.setText("Lon:" + lon);
|
||||
if (latText != null)
|
||||
latText.setText("Lat:" + lat);
|
||||
private OnAdasClientListener listener = new OnAdasClientListener() {
|
||||
@Override
|
||||
public void onRefresh() {
|
||||
List<String> listGnssInfo = DataDistribution.getInstance().listGnssInfo;
|
||||
if (!listGnssInfo.isEmpty()) {
|
||||
String info = listGnssInfo.get(listGnssInfo.size() - 1);
|
||||
lon = Double.parseDouble(info.split("longitude: ")[1].split("\n")[0]);
|
||||
lat = Double.parseDouble(info.split("latitude: ")[1].split("\n")[0]);
|
||||
getHandler().sendEmptyMessage(WHAT_UPDATE_SHOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onLocationEvent(GnssInfo info) {
|
||||
// if (info != null && info.bean != null) {
|
||||
// lon = info.bean.getLongitude();
|
||||
// lat = info.bean.getLatitude();
|
||||
// if (lonText != null)
|
||||
// lonText.setText("Lon:" + lon);
|
||||
// if (latText != null)
|
||||
// latText.setText("Lat:" + lat);
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
|
||||
@@ -1,69 +1,40 @@
|
||||
package com.zhidao.adas.client.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import com.zhidao.adas.client.DataDistribution;
|
||||
import com.zhidao.adas.client.R;
|
||||
import com.zhidao.adas.client.adapter.DataShowAdapter;
|
||||
import com.zhidao.adas.client.bean.ArrivalNotification;
|
||||
import com.zhidao.adas.client.bean.AutopilotState;
|
||||
import com.zhidao.adas.client.bean.ErrorData;
|
||||
import com.zhidao.adas.client.bean.GlobalPathResp;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.bean.MogoReportMessage;
|
||||
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
|
||||
import com.zhidao.adas.client.bean.RecordPanel;
|
||||
import com.zhidao.adas.client.bean.TrackedObjects;
|
||||
import com.zhidao.adas.client.bean.Trajectory;
|
||||
import com.zhidao.adas.client.bean.VehicleState;
|
||||
import com.zhidao.adas.client.bean.Warn;
|
||||
import com.zhidao.adas.client.base.BaseFragment;
|
||||
import com.zhidao.adas.client.utils.Constants;
|
||||
import com.zhidao.adas.client.utils.MyLinearLayoutManager;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeInfo;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/8/16
|
||||
*/
|
||||
public class InfoFragment extends Fragment {
|
||||
public class InfoFragment extends BaseFragment {
|
||||
|
||||
private String title;
|
||||
private final List<String> data = new ArrayList<>();
|
||||
private DataShowAdapter adapter;
|
||||
|
||||
public InfoFragment() {
|
||||
}
|
||||
|
||||
public InfoFragment(String title) {
|
||||
this.title = title;
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -74,226 +45,300 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
setData();
|
||||
}
|
||||
|
||||
private TextView tvTitle;
|
||||
private RecyclerView rvInfo;
|
||||
private View layout_update;
|
||||
|
||||
private void initView(View view) {
|
||||
tvTitle = view.findViewById(R.id.tv_title);
|
||||
rvInfo = view.findViewById(R.id.rv_info);
|
||||
|
||||
CupidLogUtils.w("InfoFragment===>" + title);
|
||||
TextView tvTitle = view.findViewById(R.id.tv_title);
|
||||
RecyclerView rvInfo = view.findViewById(R.id.rv_info);
|
||||
layout_update = view.findViewById(R.id.layout_update);
|
||||
tvTitle.setText(title);
|
||||
tvTitle.setGravity(Gravity.CENTER);
|
||||
//创建默认的线性LayoutManager 横向的GridLayoutManager
|
||||
MyLinearLayoutManager linearLayoutManager = new MyLinearLayoutManager(this.getContext());
|
||||
linearLayoutManager.setStackFromEnd(true);//列表再底部开始展示,反转后由上面开始展示
|
||||
// linearLayoutManager.setStackFromEnd(true);//列表再底部开始展示,反转后由上面开始展示
|
||||
// linearLayoutManager.setReverseLayout(true);//列表翻转
|
||||
rvInfo.setLayoutManager(linearLayoutManager);
|
||||
//如果可以确定每个item的高度是固定的,设置这个选项可以提高性能
|
||||
rvInfo.setHasFixedSize(false);
|
||||
rvInfo.setNestedScrollingEnabled(false);
|
||||
//升级按钮
|
||||
Button btn1 = view.findViewById(R.id.btn1);
|
||||
//升级按钮
|
||||
Button btn2 = view.findViewById(R.id.btn2);
|
||||
btn1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.affirm());
|
||||
}
|
||||
});
|
||||
btn2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.cancel());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
RecyclerView.ItemAnimator itemAnimator = rvInfo.getItemAnimator();
|
||||
if (itemAnimator != null) {
|
||||
itemAnimator.setAddDuration(0);
|
||||
itemAnimator.setChangeDuration(0);
|
||||
itemAnimator.setMoveDuration(0);
|
||||
itemAnimator.setRemoveDuration(0);
|
||||
((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
|
||||
}
|
||||
adapter = new DataShowAdapter();
|
||||
adapter.setData(data);
|
||||
adapter.setHasStableIds(true);
|
||||
rvInfo.setAdapter(adapter);
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onWarnEvent(Warn info) {
|
||||
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_WARN)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRectEvent(TrackedObjects info) {
|
||||
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_TRACKED_OBJECTS)) {
|
||||
if (data.size() > 4) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onErrorEvent(ErrorData info) {
|
||||
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_ERROR)) {
|
||||
if (data.size() > 19) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void onTurnLightState(int turnLight, boolean brake_light) {
|
||||
StringBuilder builder = new StringBuilder(MainActivity.TITLE.RECEIVE_VEHICLE_STATE + "\t");
|
||||
if (turnLight == 0) {
|
||||
builder.append("左转:关");
|
||||
builder.append("右转:关");
|
||||
} else if (turnLight == 1) {
|
||||
builder.append("左转:开");
|
||||
builder.append("右转:关");
|
||||
} else if (turnLight == 2) {
|
||||
builder.append("左转:关");
|
||||
builder.append("右转:开");
|
||||
}
|
||||
|
||||
builder.append(brake_light ? " 刹车:开" : " 刹车:关");
|
||||
tvTitle.setText(builder.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析转向灯
|
||||
*/
|
||||
private int turnLightTimes = 0;
|
||||
private boolean isOnTurnLight = false;
|
||||
private int turnLight = 0;
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onVehicleStateEvent(VehicleState info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_VEHICLE_STATE)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
int light = info.bean.getLight().getNumber();//转向灯状态 0是正常 1是左转 2是右转
|
||||
onTurnLightState(setTurnLightState(light), info.bean.getBrakeLightStatus());
|
||||
private void setData() {
|
||||
switch (title) {
|
||||
case Constants.TITLE.RECEIVE_GNSS_INFO:
|
||||
adapter.setData(DataDistribution.getInstance().listGnssInfo);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_VEHICLE_STATE:
|
||||
adapter.setData(DataDistribution.getInstance().listVehicleState);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_TRACKED_OBJECTS:
|
||||
adapter.setData(DataDistribution.getInstance().listTrackedObjects);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_AUTOPILOT_STATE:
|
||||
adapter.setData(DataDistribution.getInstance().listAutopilotState);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_WARN:
|
||||
adapter.setData(DataDistribution.getInstance().listWarn);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_TRAJECTORY:
|
||||
adapter.setData(DataDistribution.getInstance().listTrajectory);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_ARRIVAL_NOTIFICATION:
|
||||
adapter.setData(DataDistribution.getInstance().listArrivalNotification);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_GLOBAL_PATH_RESP:
|
||||
adapter.setData(DataDistribution.getInstance().listGlobalPathResp);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_IPC_UPGRADE_STATUS:
|
||||
layout_update.setVisibility(View.VISIBLE);
|
||||
// text2.setText("IPC升级 \nUpgradeStatus:" + IPCUpgradeStateInfo.UpgradeStatus.getStatus(info.getUpgradeStatus()) +
|
||||
// "\nDownloadStatus:" + IPCUpgradeStateInfo.DownloadStatus.getStatus(info.getDownloadStatus()) +
|
||||
// "\nUpgradeMode:" + IPCUpgradeStateInfo.UpgradeMode.getStatus(info.getUpgradeMode()) +
|
||||
// "\nProgress:" + info.getProgress() +
|
||||
// "\nImages:" + info.getImages());
|
||||
adapter.setData(DataDistribution.getInstance().listUpdate);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_RECORD_RESULT:
|
||||
adapter.setData(DataDistribution.getInstance().listRecordPanel);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_REPORT_MESSAGE:
|
||||
adapter.setData(DataDistribution.getInstance().listMogoReportMessage);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT:
|
||||
adapter.setData(DataDistribution.getInstance().listPerceptionTrafficLight);
|
||||
break;
|
||||
case Constants.TITLE.RECEIVE_ERROR:
|
||||
adapter.setData(DataDistribution.getInstance().listErrorData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGnssInfoEvent(GnssInfo info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_GNSS_INFO)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onAutopilotStateEvent(AutopilotState info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_AUTOPILOT_STATE)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onTrajectoryEvent(Trajectory info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_TRAJECTORY)) {
|
||||
if (data.size() > 4) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onArrivalNotificationEvent(ArrivalNotification info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_ARRIVAL_NOTIFICATION)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGlobalPathEvent(GlobalPathResp info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_GLOBAL_PATH_RESP)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRecordPanelEvent(RecordPanel info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_RECORD_RESULT)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMogoReportMessageEvent(MogoReportMessage info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_REPORT_MESSAGE)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onPerceptionTrafficLightEvent(PerceptionTrafficLight info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onWarnEvent(Warn info) {
|
||||
//
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_WARN)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onRectEvent(TrackedObjects info) {
|
||||
//
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_TRACKED_OBJECTS)) {
|
||||
// if (data.size() > 4) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onErrorEvent(ErrorData info) {
|
||||
//
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_ERROR)) {
|
||||
// if (data.size() > 19) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void onTurnLightState(int turnLight, boolean brake_light) {
|
||||
// StringBuilder builder = new StringBuilder(MainActivity.TITLE.RECEIVE_VEHICLE_STATE + "\t");
|
||||
// if (turnLight == 0) {
|
||||
// builder.append("左转:关");
|
||||
// builder.append("右转:关");
|
||||
// } else if (turnLight == 1) {
|
||||
// builder.append("左转:开");
|
||||
// builder.append("右转:关");
|
||||
// } else if (turnLight == 2) {
|
||||
// builder.append("左转:关");
|
||||
// builder.append("右转:开");
|
||||
// }
|
||||
//
|
||||
// builder.append(brake_light ? " 刹车:开" : " 刹车:关");
|
||||
// tvTitle.setText(builder.toString());
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 解析转向灯
|
||||
// */
|
||||
// private int turnLightTimes = 0;
|
||||
// private boolean isOnTurnLight = false;
|
||||
// private int turnLight = 0;
|
||||
//
|
||||
// public 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;
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onVehicleStateEvent(VehicleState info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_VEHICLE_STATE)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// int light = info.bean.getLight().getNumber();//转向灯状态 0是正常 1是左转 2是右转
|
||||
// onTurnLightState(setTurnLightState(light), info.bean.getBrakeLightStatus());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onGnssInfoEvent(GnssInfo info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_GNSS_INFO)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onAutopilotStateEvent(AutopilotState info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_AUTOPILOT_STATE)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onTrajectoryEvent(Trajectory info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_TRAJECTORY)) {
|
||||
// if (data.size() > 4) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onArrivalNotificationEvent(ArrivalNotification info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_ARRIVAL_NOTIFICATION)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onGlobalPathEvent(GlobalPathResp info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_GLOBAL_PATH_RESP)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onRecordPanelEvent(RecordPanel info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_RECORD_RESULT)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onMogoReportMessageEvent(MogoReportMessage info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_REPORT_MESSAGE)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
// public void onPerceptionTrafficLightEvent(PerceptionTrafficLight info) {
|
||||
// if (title.equals(MainActivity.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT)) {
|
||||
// if (data.size() > 9) {
|
||||
// data.remove(0);
|
||||
// }
|
||||
// data.add(info.toString());
|
||||
// adapter.notifyDataSetChanged();
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
protected void onRefreshView() {
|
||||
if (adapter != null) {
|
||||
// adapter.notifyDataSetChanged();
|
||||
adapter.refreshView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.zhidao.adas.client.bean.TrackedObjects;
|
||||
import com.zhidao.adas.client.bean.Trajectory;
|
||||
import com.zhidao.adas.client.bean.VehicleState;
|
||||
import com.zhidao.adas.client.bean.Warn;
|
||||
import com.zhidao.adas.client.DataDistribution;
|
||||
import com.zhidao.adas.client.log.LogSave;
|
||||
import com.zhidao.adas.client.utils.Constants;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
@@ -73,10 +74,9 @@ import com.zhidao.support.adas.high.bean.SSHResult;
|
||||
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.ProtocolStatus;
|
||||
import com.zhidao.support.adas.high.common.ReceiveTimeoutManager;
|
||||
import com.zhidao.support.recorder.RecordDataManager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
@@ -112,6 +112,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
private RadioButton assign;
|
||||
private CheckBox cb_print;
|
||||
private CheckBox cb_save;
|
||||
private CheckBox cb_timeout;
|
||||
private RecyclerView infoBtn;
|
||||
private RecyclerView infoFragment;
|
||||
private TextView tvConnectState;
|
||||
@@ -132,7 +133,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
private InfoFragment trajectoryFragment;
|
||||
private InfoFragment autopilotWayArriveFragment;
|
||||
private InfoFragment autopilotRouteFragment;
|
||||
private UpgradeFragment upgradeFragment;
|
||||
private InfoFragment upgradeFragment;
|
||||
private InfoFragment badcseFragment;
|
||||
private InfoFragment errorFragment;
|
||||
private InfoFragment reportMessageFragment;
|
||||
@@ -148,36 +149,19 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
private AutoPilotModeDialog autoPilotModeDialog;
|
||||
private ListPopupWindow listPopupWindow;
|
||||
|
||||
public interface TITLE {
|
||||
String RECEIVE_TRAJECTORY = "车前引导线";
|
||||
String RECEIVE_TRACKED_OBJECTS = "障碍物信息";
|
||||
String RECEIVE_GNSS_INFO = "惯导信息";
|
||||
String RECEIVE_VEHICLE_STATE = "底盘信息";
|
||||
String RECEIVE_AUTOPILOT_STATE = "自动驾驶状态";
|
||||
String RECEIVE_REPORT_MESSAGE = "监控事件";
|
||||
String RECEIVE_PERCEPTION_TRAFFIC_LIGHT = "感知红绿灯";
|
||||
// @Override
|
||||
// protected void onStart() {
|
||||
// super.onStart();
|
||||
// LogSave.getInstance().start();
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// protected void onStop() {
|
||||
// super.onStop();
|
||||
// //需要将数据换发到别的页面
|
||||
// LogSave.getInstance().stop();
|
||||
// }
|
||||
|
||||
// String RECEIVE_BASIC_INFO_REQ = "自动驾驶设备基础信息请求";
|
||||
String RECEIVE_CAR_CONFIG_RESP = "信息与配置";
|
||||
String RECEIVE_RECORD_RESULT = "数据采集结果";
|
||||
String RECEIVE_GLOBAL_PATH_RESP = "自动驾驶路径";
|
||||
String RECEIVE_WARN = "预警数据";
|
||||
String RECEIVE_ARRIVAL_NOTIFICATION = "到站提醒";
|
||||
String RECEIVE_IPC_UPGRADE_STATUS = "升级状态";
|
||||
String RECEIVE_ERROR = "错误数据";
|
||||
|
||||
|
||||
String SEND_BASIC_INFO_RESP = "自动驾驶设备基础信息应答";
|
||||
String SEND_SET_AUTOPILOT_MODE_REQ = "设置自动驾驶模式 启动自动驾驶";
|
||||
String SEND_SET_DEMO_MODE_REQ = "设置演示模式";
|
||||
String SEND_CAR_CONFIG_REQ = "车机基础信息请求";
|
||||
String SEND_RECORD_CAUSE = "记录人工接管原因";
|
||||
String SEND_RECORD_DATA = "数据采集请求";
|
||||
String SEND_SET_AUTOPILOT_SPEED_REQ = "设置自动驾驶最大速度";
|
||||
String SEND_GLOBAL_PATH_REQ = "自动驾驶路径请求";
|
||||
String SEND_TRAFFIC_LIGHT_DATA = "发送红绿灯数据到工控机";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -231,6 +215,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
assign = findViewById(R.id.assign);
|
||||
cb_print = findViewById(R.id.cb_print);
|
||||
cb_save = findViewById(R.id.cb_save);
|
||||
cb_timeout = findViewById(R.id.cb_timeout);
|
||||
title = findViewById(R.id.title);
|
||||
infoBtn = findViewById(R.id.info_btn);
|
||||
infoFragment = findViewById(R.id.info_fragment);
|
||||
@@ -301,9 +286,27 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
}
|
||||
}
|
||||
});
|
||||
boolean isEnable = Constants.getTimeoutEnable(this);
|
||||
ReceiveTimeoutManager.getInstance().setEnable(isEnable, AdasManager.getInstance().getIpcConnectionStatus());
|
||||
cb_timeout.setChecked(ReceiveTimeoutManager.getInstance().isEnable());
|
||||
cb_timeout.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
Constants.setTimeoutEnable(MainActivity.this, isChecked);
|
||||
ReceiveTimeoutManager.getInstance().setEnable(isChecked, AdasManager.getInstance().getIpcConnectionStatus());
|
||||
}
|
||||
});
|
||||
cb_timeout.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
showToastCenter("由于没有心跳机制,如果服务器端断网或其他非正常断开,客户端无法感知,所以需要进行数据接收超时检测", Toast.LENGTH_LONG);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
connectionType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
AdasManager.getInstance().disconnect();
|
||||
int type;
|
||||
switch (checkedId) {
|
||||
default:
|
||||
@@ -391,20 +394,20 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
}
|
||||
|
||||
private void initListData() {
|
||||
titleFragmentData.add(TITLE.RECEIVE_GNSS_INFO);
|
||||
titleFragmentData.add(TITLE.RECEIVE_TRAJECTORY);
|
||||
titleFragmentData.add(TITLE.RECEIVE_TRACKED_OBJECTS);
|
||||
titleFragmentData.add(TITLE.RECEIVE_VEHICLE_STATE);
|
||||
titleFragmentData.add(TITLE.RECEIVE_AUTOPILOT_STATE);
|
||||
titleFragmentData.add(TITLE.RECEIVE_REPORT_MESSAGE);
|
||||
titleFragmentData.add(TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT);
|
||||
titleFragmentData.add(TITLE.RECEIVE_CAR_CONFIG_RESP);
|
||||
titleFragmentData.add(TITLE.RECEIVE_RECORD_RESULT);
|
||||
titleFragmentData.add(TITLE.RECEIVE_GLOBAL_PATH_RESP);
|
||||
titleFragmentData.add(TITLE.RECEIVE_WARN);
|
||||
titleFragmentData.add(TITLE.RECEIVE_ARRIVAL_NOTIFICATION);
|
||||
titleFragmentData.add(TITLE.RECEIVE_IPC_UPGRADE_STATUS);
|
||||
titleFragmentData.add(TITLE.RECEIVE_ERROR);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_GNSS_INFO);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_TRAJECTORY);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_TRACKED_OBJECTS);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_VEHICLE_STATE);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_AUTOPILOT_STATE);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_REPORT_MESSAGE);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_CAR_CONFIG_RESP);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_RECORD_RESULT);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_GLOBAL_PATH_RESP);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_WARN);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_ARRIVAL_NOTIFICATION);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_IPC_UPGRADE_STATUS);
|
||||
titleFragmentData.add(Constants.TITLE.RECEIVE_ERROR);
|
||||
|
||||
|
||||
titleBtnData.add("启动自动驾驶");
|
||||
@@ -462,12 +465,11 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
fragmentAdapter.setSelectedPosition(position);
|
||||
manager = getSupportFragmentManager();
|
||||
transaction = manager.beginTransaction();
|
||||
CupidLogUtils.w(TAG, "TitleAdapter===>name:" + data);
|
||||
switch (data) {
|
||||
case TITLE.RECEIVE_GNSS_INFO:
|
||||
case Constants.TITLE.RECEIVE_GNSS_INFO:
|
||||
firstFragment();
|
||||
break;
|
||||
case TITLE.RECEIVE_VEHICLE_STATE:
|
||||
case Constants.TITLE.RECEIVE_VEHICLE_STATE:
|
||||
if (canFragment == null)
|
||||
canFragment = new InfoFragment(data);
|
||||
if (!canFragment.isVisible()) {
|
||||
@@ -475,7 +477,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_TRACKED_OBJECTS:
|
||||
case Constants.TITLE.RECEIVE_TRACKED_OBJECTS:
|
||||
if (viewFragment == null)
|
||||
viewFragment = new InfoFragment(data);
|
||||
if (!viewFragment.isVisible()) {
|
||||
@@ -483,7 +485,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_AUTOPILOT_STATE:
|
||||
case Constants.TITLE.RECEIVE_AUTOPILOT_STATE:
|
||||
if (autoFragment == null)
|
||||
autoFragment = new InfoFragment(data);
|
||||
if (!autoFragment.isVisible()) {
|
||||
@@ -491,7 +493,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_WARN:
|
||||
case Constants.TITLE.RECEIVE_WARN:
|
||||
if (warnFragment == null)
|
||||
warnFragment = new InfoFragment(data);
|
||||
if (!warnFragment.isVisible()) {
|
||||
@@ -499,7 +501,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_TRAJECTORY:
|
||||
case Constants.TITLE.RECEIVE_TRAJECTORY:
|
||||
if (trajectoryFragment == null)
|
||||
trajectoryFragment = new InfoFragment(data);
|
||||
if (!trajectoryFragment.isVisible()) {
|
||||
@@ -507,7 +509,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_ARRIVAL_NOTIFICATION:
|
||||
case Constants.TITLE.RECEIVE_ARRIVAL_NOTIFICATION:
|
||||
if (autopilotWayArriveFragment == null)
|
||||
autopilotWayArriveFragment = new InfoFragment(data);
|
||||
if (!autopilotWayArriveFragment.isVisible()) {
|
||||
@@ -515,7 +517,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_GLOBAL_PATH_RESP:
|
||||
case Constants.TITLE.RECEIVE_GLOBAL_PATH_RESP:
|
||||
if (autopilotRouteFragment == null)
|
||||
autopilotRouteFragment = new InfoFragment(data);
|
||||
if (!autopilotRouteFragment.isVisible()) {
|
||||
@@ -523,15 +525,16 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_IPC_UPGRADE_STATUS:
|
||||
case Constants.TITLE.RECEIVE_IPC_UPGRADE_STATUS:
|
||||
showToastCenter("“" + data + "”功能暂时未开发");
|
||||
if (upgradeFragment == null)
|
||||
upgradeFragment = new UpgradeFragment(data);
|
||||
upgradeFragment = new InfoFragment(data);
|
||||
if (!upgradeFragment.isVisible()) {
|
||||
transaction.replace(R.id.fl_info, upgradeFragment);
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_RECORD_RESULT:
|
||||
case Constants.TITLE.RECEIVE_RECORD_RESULT:
|
||||
if (badcseFragment == null)
|
||||
badcseFragment = new InfoFragment(data);
|
||||
if (!badcseFragment.isVisible()) {
|
||||
@@ -539,7 +542,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_REPORT_MESSAGE:
|
||||
case Constants.TITLE.RECEIVE_REPORT_MESSAGE:
|
||||
if (reportMessageFragment == null)
|
||||
reportMessageFragment = new InfoFragment(data);
|
||||
if (!reportMessageFragment.isVisible()) {
|
||||
@@ -547,7 +550,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT:
|
||||
case Constants.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT:
|
||||
if (perceptionTrafficLightFragment == null)
|
||||
perceptionTrafficLightFragment = new InfoFragment(data);
|
||||
if (!perceptionTrafficLightFragment.isVisible()) {
|
||||
@@ -555,7 +558,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
transaction.commit();
|
||||
}
|
||||
break;
|
||||
case TITLE.RECEIVE_CAR_CONFIG_RESP:
|
||||
case Constants.TITLE.RECEIVE_CAR_CONFIG_RESP:
|
||||
AdasManager.getInstance().sendCarConfigReq();
|
||||
if (versionFragment == null)
|
||||
versionFragment = new VersionFragment("工控机版本\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t固定IP配置");
|
||||
@@ -565,7 +568,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
}
|
||||
break;
|
||||
|
||||
case TITLE.RECEIVE_ERROR:
|
||||
case Constants.TITLE.RECEIVE_ERROR:
|
||||
if (errorFragment == null)
|
||||
errorFragment = new InfoFragment(data);
|
||||
if (!errorFragment.isVisible()) {
|
||||
@@ -634,7 +637,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
@Override
|
||||
public void onSSHResult(final SSHResult info) {
|
||||
MySSHResult result = new MySSHResult(info.toString(), 0);
|
||||
LogSave.getInstance().saveLog(result);
|
||||
DataDistribution.getInstance().addData(result);
|
||||
showToastCenter("IPC命令下发结果:" + info.code + " 命令:" + info.cmd + " 信息:" + info.msg);
|
||||
CupidLogUtils.w(TAG, "IPC命令下发结果:" + info.code + " 命令:" + info.cmd + " 信息:" + info.msg);
|
||||
}
|
||||
@@ -642,115 +645,104 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
@Override
|
||||
public void onError(ProtocolStatus status, byte[] bytes) {
|
||||
ErrorData base = new ErrorData(status, bytes);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrajectory(MessagePad.Header header, MessagePad.Trajectory trajectory) {
|
||||
Trajectory base = new Trajectory(header, trajectory);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrackedObjects(MessagePad.Header header, MessagePad.TrackedObjects trackedObjects) {
|
||||
TrackedObjects base = new TrackedObjects(header, trackedObjects);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGnssInfo(MessagePad.Header header, MessagePad.GnssInfo gnssInfo) {
|
||||
GnssInfo base = new GnssInfo(header, gnssInfo);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVehicleState(MessagePad.Header header, VehicleStateOuterClass.VehicleState vehicleState) {
|
||||
VehicleState base = new VehicleState(header, vehicleState);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotState(MessagePad.Header header, MessagePad.AutopilotState autopilotState) {
|
||||
AutopilotState base = new AutopilotState(header, autopilotState);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReportMessage(MessagePad.Header header, MogoReportMsg.MogoReportMessage mogoReportMessage) {
|
||||
MogoReportMessage base = new MogoReportMessage(header, mogoReportMessage);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPerceptionTrafficLight(MessagePad.Header header, TrafficLightOuterClass.TrafficLights trafficLights) {
|
||||
PerceptionTrafficLight base = new PerceptionTrafficLight(header, trafficLights);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBasicInfoReq(MessagePad.Header header, MessagePad.BasicInfoReq basicInfoReq) {
|
||||
BasicInfoReq info = new BasicInfoReq(header, basicInfoReq);
|
||||
LogSave.getInstance().saveLog(info);
|
||||
DataDistribution.getInstance().addData(info);
|
||||
AdasManager.getInstance().sendBasicInfoResp("X202021111192N41VY", 1);
|
||||
showToastCenter("收到车机基础信息请求:" + info.toString());
|
||||
// EventBus.getDefault().post(new BasicInfoReq(header, basicInfoReq));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarConfigResp(MessagePad.Header header, MessagePad.CarConfigResp carConfigResp) {
|
||||
CarConfigResp base = new CarConfigResp(header, carConfigResp);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().postSticky(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecordResult(MessagePad.Header header, RecordPanelOuterClass.RecordPanel recordPanel) {
|
||||
RecordPanel base = new RecordPanel(header, recordPanel);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
recordKey = recordPanel.getKey();
|
||||
recordFileName = recordPanel.getFilename();
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGlobalPathResp(MessagePad.Header header, MessagePad.GlobalPathResp globalPathResp) {
|
||||
GlobalPathResp base = new GlobalPathResp(header, globalPathResp);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarn(MessagePad.Header header, MessagePad.Warn warn) {
|
||||
Warn base = new Warn(header, warn);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArrivalNotification(MessagePad.Header header, MessagePad.ArrivalNotification arrivalNotification) {
|
||||
ArrivalNotification base = new ArrivalNotification(header, arrivalNotification);
|
||||
LogSave.getInstance().saveLog(base);
|
||||
EventBus.getDefault().post(base);
|
||||
DataDistribution.getInstance().addData(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgradeStateInfo(final IPCUpgradeStateInfo info) {
|
||||
// LogSave.getInstance().saveLog("接收", info.toString());
|
||||
EventBus.getDefault().post(info);
|
||||
}
|
||||
|
||||
|
||||
private Toast toast;
|
||||
|
||||
public void showToastCenter(String msg) {
|
||||
showToastCenter(msg, Toast.LENGTH_SHORT);
|
||||
}
|
||||
|
||||
public void showToastCenter(String msg, int duration) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -758,7 +750,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
toast.cancel();
|
||||
toast = null;
|
||||
}
|
||||
toast = Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT); //如果有居中显示需求
|
||||
toast = Toast.makeText(MainActivity.this, "", duration); //如果有居中显示需求
|
||||
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
@@ -879,6 +871,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
if (mExecutorServiceConfigTimer != null) {
|
||||
mExecutorServiceConfigTimer.shutdownNow();
|
||||
}
|
||||
DataDistribution.getInstance().stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -942,7 +935,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
|
||||
private void firstFragment() {
|
||||
if (carFragment == null)
|
||||
carFragment = new InfoFragment(TITLE.RECEIVE_GNSS_INFO);
|
||||
carFragment = new InfoFragment(Constants.TITLE.RECEIVE_GNSS_INFO);
|
||||
if (!carFragment.isVisible()) {
|
||||
transaction.replace(R.id.fl_info, carFragment);
|
||||
transaction.commit();
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
package com.zhidao.adas.client.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.zhidao.adas.client.R;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeInfo;
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeStateInfo;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @des 升级页面
|
||||
*/
|
||||
public class UpgradeFragment extends Fragment {
|
||||
private final int[] colors = {Color.parseColor("#FA8072"), Color.parseColor("#FF00FF"), Color.parseColor("#228B22"), Color.parseColor("#871f78")};
|
||||
private final Random random = new Random();
|
||||
|
||||
private String title;
|
||||
|
||||
public UpgradeFragment() {
|
||||
}
|
||||
|
||||
public UpgradeFragment(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_upgrade, container, false);
|
||||
initView(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
private TextView tvTitle;
|
||||
private TextView text2;
|
||||
private Button btn1;
|
||||
private Button btn2;
|
||||
|
||||
private void initView(View view) {
|
||||
tvTitle = view.findViewById(R.id.tv_title);
|
||||
text2 = view.findViewById(R.id.text2);
|
||||
btn1 = view.findViewById(R.id.btn1);
|
||||
btn2 = view.findViewById(R.id.btn2);
|
||||
CupidLogUtils.w("InfoFragment===>" + title);
|
||||
tvTitle.setText(title);
|
||||
tvTitle.setGravity(Gravity.CENTER);
|
||||
|
||||
btn1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.affirm());
|
||||
}
|
||||
});
|
||||
|
||||
btn2.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AdasManager.getInstance().sendBaseInfo(IPCUpgradeInfo.cancel());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onIPCUpgradeStateInfo(IPCUpgradeStateInfo info) {
|
||||
text2.setTextColor(colors[random.nextInt(4)]);
|
||||
text2.setText("IPC升级 \nUpgradeStatus:" + IPCUpgradeStateInfo.UpgradeStatus.getStatus(info.getUpgradeStatus()) +
|
||||
"\nDownloadStatus:" + IPCUpgradeStateInfo.DownloadStatus.getStatus(info.getDownloadStatus()) +
|
||||
"\nUpgradeMode:" + IPCUpgradeStateInfo.UpgradeMode.getStatus(info.getUpgradeMode()) +
|
||||
"\nProgress:" + info.getProgress() +
|
||||
"\nImages:" + info.getImages());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
@@ -22,34 +21,30 @@ import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
import com.zhidao.adas.client.BuildConfig;
|
||||
import com.zhidao.adas.client.R;
|
||||
import com.zhidao.adas.client.adapter.ConfigAdapter;
|
||||
import com.zhidao.adas.client.base.BaseFragment;
|
||||
import com.zhidao.adas.client.bean.CarConfigResp;
|
||||
import com.zhidao.adas.client.bean.Config;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* @des 升级页面
|
||||
*/
|
||||
public class VersionFragment extends Fragment {
|
||||
public class VersionFragment extends BaseFragment {
|
||||
|
||||
|
||||
private String title;
|
||||
private ConfigAdapter adapter;
|
||||
|
||||
public VersionFragment() {
|
||||
public VersionFragment(String title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
public VersionFragment(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
@@ -72,8 +67,8 @@ public class VersionFragment extends Fragment {
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
EventBus.getDefault().register(this);
|
||||
showIps();
|
||||
showVersion();
|
||||
}
|
||||
|
||||
|
||||
@@ -96,19 +91,15 @@ public class VersionFragment extends Fragment {
|
||||
|
||||
}
|
||||
|
||||
private TextView tvTitle;
|
||||
|
||||
private TextView ipsView;
|
||||
private Button btn1;
|
||||
private Button btn2;
|
||||
private EditText ipView;
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
private void initView(View view) {
|
||||
tvTitle = view.findViewById(R.id.tv_title);
|
||||
btn1 = view.findViewById(R.id.btn1);
|
||||
TextView tvTitle = view.findViewById(R.id.tv_title);
|
||||
Button btn1 = view.findViewById(R.id.btn1);
|
||||
ipView = view.findViewById(R.id.ip);
|
||||
btn2 = view.findViewById(R.id.btn2);
|
||||
Button btn2 = view.findViewById(R.id.btn2);
|
||||
ipsView = view.findViewById(R.id.ips_view);
|
||||
recyclerView = view.findViewById(R.id.config_list);
|
||||
initFragmentRecyclerView();
|
||||
@@ -153,14 +144,11 @@ public class VersionFragment extends Fragment {
|
||||
view.findViewById(R.id.line1).setVisibility(View.GONE);
|
||||
tvTitle.setText("版本");
|
||||
}
|
||||
// if (AdasManager.getInstance().getIpcConnectionStatus() != Constants.IPC_CONNECTION_STATUS.CONNECTED)
|
||||
showVersion(null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void showVersion(CarConfigResp adasConfig) {
|
||||
public void showVersion() {
|
||||
List<Config> list = new ArrayList<>();
|
||||
if (!BuildConfig.IS_CLIENT) {
|
||||
String ip = AdasManager.getInstance().getIpcConnectedIp();
|
||||
@@ -168,25 +156,26 @@ public class VersionFragment extends Fragment {
|
||||
if (!TextUtils.isEmpty(ip)) {
|
||||
temp = ip + ":" + AdasManager.getInstance().getIpcConnectedPort();
|
||||
}
|
||||
MessagePad.CarConfigResp adasConfig = AdasManager.getInstance().getCarConfig();
|
||||
list.add(new Config("工控机IP:", temp));
|
||||
list.add(new Config("工控机版本:", adasConfig == null ? null : adasConfig.bean.getDockVersion()));
|
||||
list.add(new Config("车牌号:", adasConfig == null ? null : adasConfig.bean.getPlateNumber()));
|
||||
list.add(new Config("MAC地址:", adasConfig == null ? null : adasConfig.bean.getMacAddress()));
|
||||
list.add(new Config("自动驾驶限速:", adasConfig == null ? null : adasConfig.bean.getSpeedLimit() + "m/s"));
|
||||
list.add(new Config("最大自动驾驶限速:", adasConfig == null ? null : adasConfig.bean.getMaxSpeedLimit() + "m/s"));
|
||||
list.add(new Config("最小加速度:", adasConfig == null ? null : adasConfig.bean.getMinAcceleration() + "m/s²"));
|
||||
list.add(new Config("最大加速度:", adasConfig == null ? null : adasConfig.bean.getMaxAcceleration() + "m/s²"));
|
||||
list.add(new Config("IPC通信协议版本:", adasConfig == null ? null : String.valueOf(adasConfig.bean.getProtocolVersion().getNumber())));
|
||||
list.add(new Config("工控机版本:", adasConfig == null ? null : adasConfig.getDockVersion()));
|
||||
list.add(new Config("车牌号:", adasConfig == null ? null : adasConfig.getPlateNumber()));
|
||||
list.add(new Config("MAC地址:", adasConfig == null ? null : adasConfig.getMacAddress()));
|
||||
list.add(new Config("自动驾驶限速:", adasConfig == null ? null : adasConfig.getSpeedLimit() + "m/s"));
|
||||
list.add(new Config("最大自动驾驶限速:", adasConfig == null ? null : adasConfig.getMaxSpeedLimit() + "m/s"));
|
||||
list.add(new Config("最小加速度:", adasConfig == null ? null : adasConfig.getMinAcceleration() + "m/s²"));
|
||||
list.add(new Config("最大加速度:", adasConfig == null ? null : adasConfig.getMaxAcceleration() + "m/s²"));
|
||||
list.add(new Config("IPC通信协议版本:", adasConfig == null ? null : String.valueOf(adasConfig.getProtocolVersion().getNumber())));
|
||||
list.add(new Config("APP通信协议版本:", String.valueOf(AdasManager.getInstance().getProtocolVersion())));
|
||||
}
|
||||
list.add(new Config("ADAS LIB版本:", AdasManager.getInstance().getAdasVersion()));
|
||||
adapter.setData(list);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
EventBus.getDefault().unregister(this);
|
||||
protected void onRefreshView() {
|
||||
showVersion();
|
||||
}
|
||||
|
||||
private void initFragmentRecyclerView() {
|
||||
@@ -204,9 +193,4 @@ public class VersionFragment extends Fragment {
|
||||
adapter = new ConfigAdapter();
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,5 +124,52 @@ public class Constants {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*********************存储超时检测按钮开关状态******************/
|
||||
private static final String TIMEOUT_ENABLE = "timeout_enable";
|
||||
|
||||
public static void setTimeoutEnable(Context context, boolean isEnable) {
|
||||
PreferencesUtils.putBoolean(context, TIMEOUT_ENABLE, isEnable);
|
||||
}
|
||||
|
||||
public static boolean getTimeoutEnable(Context context) {
|
||||
return PreferencesUtils.putBoolean(context, TIMEOUT_ENABLE, true);
|
||||
}
|
||||
|
||||
public static boolean delTimeoutEnable(Context context) {
|
||||
return PreferencesUtils.delete(context, TIMEOUT_ENABLE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public interface TITLE {
|
||||
String RECEIVE_TRAJECTORY = "车前引导线";
|
||||
String RECEIVE_TRACKED_OBJECTS = "障碍物信息";
|
||||
String RECEIVE_GNSS_INFO = "惯导信息";
|
||||
String RECEIVE_VEHICLE_STATE = "底盘信息";
|
||||
String RECEIVE_AUTOPILOT_STATE = "自动驾驶状态";
|
||||
String RECEIVE_REPORT_MESSAGE = "监控事件";
|
||||
String RECEIVE_PERCEPTION_TRAFFIC_LIGHT = "感知红绿灯";
|
||||
|
||||
// String RECEIVE_BASIC_INFO_REQ = "自动驾驶设备基础信息请求";
|
||||
String RECEIVE_CAR_CONFIG_RESP = "信息与配置";
|
||||
String RECEIVE_RECORD_RESULT = "数据采集结果";
|
||||
String RECEIVE_GLOBAL_PATH_RESP = "自动驾驶路径";
|
||||
String RECEIVE_WARN = "预警数据";
|
||||
String RECEIVE_ARRIVAL_NOTIFICATION = "到站提醒";
|
||||
String RECEIVE_IPC_UPGRADE_STATUS = "升级状态";
|
||||
String RECEIVE_ERROR = "错误数据";
|
||||
|
||||
|
||||
String SEND_BASIC_INFO_RESP = "自动驾驶设备基础信息应答";
|
||||
String SEND_SET_AUTOPILOT_MODE_REQ = "设置自动驾驶模式 启动自动驾驶";
|
||||
String SEND_SET_DEMO_MODE_REQ = "设置演示模式";
|
||||
String SEND_CAR_CONFIG_REQ = "车机基础信息请求";
|
||||
String SEND_RECORD_CAUSE = "记录人工接管原因";
|
||||
String SEND_RECORD_DATA = "数据采集请求";
|
||||
String SEND_SET_AUTOPILOT_SPEED_REQ = "设置自动驾驶最大速度";
|
||||
String SEND_GLOBAL_PATH_REQ = "自动驾驶路径请求";
|
||||
String SEND_TRAFFIC_LIGHT_DATA = "发送红绿灯数据到工控机";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,43 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_update"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:visibility="gone">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/btn_bg"
|
||||
android:text="确定升级"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/btn_bg"
|
||||
android:text="取消升级"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/btn_bg"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="延迟升级(最长50分钟)"
|
||||
android:textColor="#ffffff" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_info"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/colorWhile"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="25dp"
|
||||
android:background="#DCDCDC">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_gravity="center"
|
||||
android:text="INFO TITLE"
|
||||
android:textColor="#40E0D0"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center">
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/btn_bg"
|
||||
android:text="确定升级"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/btn_bg"
|
||||
android:text="取消升级"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/btn_bg"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="延迟升级(最长50分钟)"
|
||||
android:textColor="#ffffff" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textColor="#000"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
@@ -14,7 +14,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingTop="4dp"
|
||||
@@ -34,6 +33,7 @@
|
||||
android:background="@android:color/transparent"
|
||||
android:cursorVisible="false"
|
||||
android:focusable="false"
|
||||
android:textColor="#ff0000"
|
||||
android:textSize="14dp" />
|
||||
|
||||
|
||||
|
||||
@@ -69,17 +69,34 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_connect_state"
|
||||
android:layout_width="60dp"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="10dp"
|
||||
android:gravity="right|center_vertical"
|
||||
android:text="未连接"
|
||||
android:textColor="@color/colorWhile"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold" />
|
||||
android:layout_marginRight="5dp"
|
||||
android:layoutDirection="ltr"
|
||||
android:orientation="vertical">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cb_timeout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:checked="true"
|
||||
android:text="超时检测"
|
||||
android:textColor="#ffffff" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_connect_state"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="未连接"
|
||||
android:textColor="@color/colorWhile"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/line2"
|
||||
|
||||
Reference in New Issue
Block a user