Merge branch 'dev_robotaxi-d-app-module_265_220329_2.6.5' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_robotaxi-d-app-module_265_220329_2.6.5
This commit is contained in:
@@ -9,6 +9,14 @@ import java.lang.ref.WeakReference;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
private BaseHandler mBaseHandler;
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (getHandler() != null)
|
||||
getHandler().removeCallbacksAndMessages(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化一个Handler,如果需要使用Handler,先调用此方法,
|
||||
* 然后可以使用postRunnable(Runnable runnable),
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.zhidao.adas.client.bean;
|
||||
|
||||
import androidx.annotation.ColorRes;
|
||||
|
||||
public class IPCConnectState {
|
||||
public final String status;
|
||||
@ColorRes
|
||||
public final int color;
|
||||
|
||||
public IPCConnectState(String status, @ColorRes int color) {
|
||||
this.status = status;
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
@@ -4,25 +4,15 @@ import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.ThreadPoolManager;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
@@ -32,21 +22,18 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
public class LogSave {
|
||||
private static final String TAG = LogSave.class.getSimpleName();
|
||||
private static final String ROOT_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "IPCMonitoring" + File.separator;//程序外部存储跟目录
|
||||
private static final String LOG_FILE_NAME = "data%s.log";//文件名称
|
||||
private static final String LOG_FILE_NAME = "%s.log";//文件名称
|
||||
private volatile static LogSave INSTANCE;
|
||||
private static final long MAX_CAPACITY = 5 * 1024 * 1024L;//单文件最大存储容量 kb
|
||||
private static final long MAX_CAPACITY = 20 * 1024 * 1024L;//单文件最大存储容量 kb
|
||||
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 FILE_SDF = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss-SSS", Locale.getDefault());
|
||||
private File file;
|
||||
private boolean isLogSwitch = false;
|
||||
private long capacity = MAX_CAPACITY;
|
||||
private volatile long capacity = MAX_CAPACITY;
|
||||
private Future future;
|
||||
|
||||
private LogSave() {
|
||||
queue = new LinkedBlockingQueue<>();
|
||||
start();
|
||||
}
|
||||
|
||||
public static LogSave getInstance() {
|
||||
@@ -61,15 +48,6 @@ public class LogSave {
|
||||
}
|
||||
|
||||
|
||||
public void setIsLogSwitch(boolean isLogSwitch) {
|
||||
this.isLogSwitch = isLogSwitch;
|
||||
}
|
||||
|
||||
public boolean isLogSwitch() {
|
||||
return isLogSwitch;
|
||||
}
|
||||
|
||||
|
||||
public boolean isSdcardUse() {
|
||||
boolean bl = false;
|
||||
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
|
||||
@@ -80,7 +58,8 @@ public class LogSave {
|
||||
|
||||
private void getFile() throws IOException {
|
||||
if (isSdcardUse()) {
|
||||
String time = FILE_SDF.format(new Date());
|
||||
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()) {
|
||||
@@ -96,12 +75,14 @@ public class LogSave {
|
||||
|
||||
|
||||
public void saveLog(String action, String data) {
|
||||
if (isLogSwitch) {
|
||||
long nowTime = System.currentTimeMillis();
|
||||
String time = sdf.format(new Date(nowTime));
|
||||
String builder = time + " [action]:" + action + " [data]:" + data;
|
||||
queue.add(builder);
|
||||
}
|
||||
long nowTime = System.currentTimeMillis();
|
||||
String time = sdf.format(new Date(nowTime));
|
||||
String builder = time + " [action]:" + action + " [data]:" + data;
|
||||
queue.add(builder);
|
||||
}
|
||||
|
||||
public boolean isStart() {
|
||||
return future != null;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
|
||||
@@ -153,8 +153,6 @@ public class AutopilotConfigActivity extends BaseActivity {
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
EventBus.getDefault().post(new UpdateDataEvent());
|
||||
if (getHandler() != null)
|
||||
getHandler().removeCallbacksAndMessages(null);
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,9 +103,9 @@ public class InfoFragment extends Fragment {
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onWarnEvent(Warn info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_WARN)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
@@ -115,9 +115,9 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onRectEvent(TrackedObjects info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_TRACKED_OBJECTS)) {
|
||||
if (data.size() > 4) {
|
||||
data.remove(0);
|
||||
@@ -127,9 +127,9 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onErrorEvent(ErrorData info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_ERROR)) {
|
||||
if (data.size() > 19) {
|
||||
data.remove(0);
|
||||
@@ -184,11 +184,10 @@ public class InfoFragment extends Fragment {
|
||||
return turnLight;
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onCarEvent(VehicleState info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onVehicleStateEvent(VehicleState info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_VEHICLE_STATE)) {
|
||||
if (data.size() > 5) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
@@ -199,9 +198,8 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onAutoEvent(GnssInfo info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onGnssInfoEvent(GnssInfo info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_GNSS_INFO)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
@@ -211,9 +209,8 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onAutoEvent(AutopilotState info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onAutopilotStateEvent(AutopilotState info) {
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_AUTOPILOT_STATE)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
@@ -224,10 +221,53 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onTrajectoryEvent(Trajectory info) {
|
||||
EventBus.getDefault().removeStickyEvent(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);
|
||||
}
|
||||
@@ -236,46 +276,12 @@ public class InfoFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onAutopilotWayArriveEvent(ArrivalNotification info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_ARRIVAL_NOTIFICATION)) {
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onAutopilotRouteEvent(GlobalPathResp info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_GLOBAL_PATH_RESP)) {
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onAutopilotRecordResultEvent(RecordPanel info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_RECORD_RESULT)) {
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onAutopilotGuardianInfoEvent(MogoReportMessage info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_REPORT_MESSAGE)) {
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
|
||||
public void onPerceptionTrafficLightEvent(PerceptionTrafficLight info) {
|
||||
EventBus.getDefault().removeStickyEvent(info);
|
||||
if (title.equals(MainActivity.TITLE.RECEIVE_PERCEPTION_TRAFFIC_LIGHT)) {
|
||||
if (data.size() > 9) {
|
||||
data.remove(0);
|
||||
}
|
||||
data.add(info.toString());
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import static com.mogo.telematic.MogoProtocolMsg.NORMAL_DATA;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
@@ -14,17 +14,19 @@ import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ListPopupWindow;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.Switch;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
@@ -33,10 +35,6 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import com.zhidao.adas.client.bean.Base;
|
||||
import com.zhidao.adas.client.log.LogSave;
|
||||
import com.zhidao.support.adas.high.common.Constants.IPC_CONNECTION_STATUS;
|
||||
import com.google.gson.Gson;
|
||||
import com.mogo.telematic.MogoProtocolMsg;
|
||||
import com.mogo.telematic.NSDNettyManager;
|
||||
import com.mogo.telematic.client.listener.NettyClientListener;
|
||||
@@ -48,13 +46,13 @@ import com.zhidao.adas.client.adapter.InfoTitleAdapter;
|
||||
import com.zhidao.adas.client.base.BaseActivity;
|
||||
import com.zhidao.adas.client.base.BaseAdapter;
|
||||
import com.zhidao.adas.client.bean.ArrivalNotification;
|
||||
import com.zhidao.adas.client.bean.AutoPilotMode;
|
||||
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.ErrorData;
|
||||
import com.zhidao.adas.client.bean.GlobalPathResp;
|
||||
import com.zhidao.adas.client.bean.GnssInfo;
|
||||
import com.zhidao.adas.client.bean.IPCConnectState;
|
||||
import com.zhidao.adas.client.bean.MogoReportMessage;
|
||||
import com.zhidao.adas.client.bean.PerceptionTrafficLight;
|
||||
import com.zhidao.adas.client.bean.RecordPanel;
|
||||
@@ -62,16 +60,16 @@ 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.adas.client.utils.Constants;
|
||||
import com.zhidao.support.adas.high.AdasManager;
|
||||
import com.zhidao.support.adas.high.AdasOptions;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.OnAdasConnectStatusListener;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.OnMultiDeviceListener;
|
||||
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeStateInfo;
|
||||
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.recorder.RecordDataManager;
|
||||
@@ -86,7 +84,6 @@ import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import chassis.VehicleStateOuterClass;
|
||||
import io.netty.channel.Channel;
|
||||
@@ -97,6 +94,9 @@ import record_cache.RecordPanelOuterClass;
|
||||
|
||||
public class MainActivity extends BaseActivity implements OnAdasListener, OnAdasConnectStatusListener, BaseAdapter.OnItemClickListener<String> {
|
||||
private final static String TAG = MainActivity.class.getSimpleName();
|
||||
private static final int WHAT_IPC_IP = 0x00;
|
||||
private static final int WHAT_DRIVER_IP = 0x01;
|
||||
private static final int WHATIPC_CONNECT_STATE = 0x02;
|
||||
private EditText etIp;
|
||||
private TextView role;
|
||||
private TextView tvIp;
|
||||
@@ -145,6 +145,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
private String recordFileName;
|
||||
private int connectStatus;
|
||||
private AutoPilotModeDialog autoPilotModeDialog;
|
||||
private ListPopupWindow listPopupWindow;
|
||||
|
||||
public interface TITLE {
|
||||
String RECEIVE_TRAJECTORY = "车前引导线";
|
||||
@@ -181,6 +182,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
initHandler();
|
||||
isPad = isPad(this);
|
||||
if (!isPad)
|
||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
@@ -190,7 +192,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
initAdas();
|
||||
connectStatus = AdasManager.getInstance().getIpcConnectionStatus();
|
||||
onUpdateConnectStateView();
|
||||
showIPCIP(AdasManager.getInstance().getIpcConnectedIp(), AdasManager.getInstance().getIpcConnectedPort());
|
||||
showIPCIP();
|
||||
}
|
||||
|
||||
|
||||
@@ -236,7 +238,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
localIp = findViewById(R.id.local_ip);
|
||||
|
||||
|
||||
role.setText(BuildConfig.IS_CLIENT ? "乘客" : "司机");
|
||||
role.setText(BuildConfig.IS_CLIENT ? "乘客端" : "司机端");
|
||||
if (BuildConfig.IS_CLIENT) {
|
||||
line.setVisibility(View.GONE);
|
||||
connectionType.setVisibility(View.GONE);
|
||||
@@ -271,8 +273,11 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
|
||||
}
|
||||
String ip = Constants.getIPCIp(this);
|
||||
if (!TextUtils.isEmpty(ip))
|
||||
if (!TextUtils.isEmpty(ip)) {
|
||||
etIp.setText(ip);
|
||||
etIp.setSelection(ip.length());
|
||||
}
|
||||
|
||||
// infoTitleList.add("录音测试");
|
||||
//初始化fragment
|
||||
manager = getSupportFragmentManager();
|
||||
@@ -284,7 +289,7 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
AdasManager.getInstance().setEnableLog(isChecked);
|
||||
}
|
||||
});
|
||||
cb_save.setChecked(LogSave.getInstance().isLogSwitch());
|
||||
cb_save.setChecked(LogSave.getInstance().isStart());
|
||||
cb_save.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
@@ -293,7 +298,6 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
} else {
|
||||
LogSave.getInstance().stop();
|
||||
}
|
||||
LogSave.getInstance().setIsLogSwitch(isChecked);
|
||||
}
|
||||
});
|
||||
connectionType.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@@ -322,7 +326,13 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
if (TextUtils.isEmpty(s)) {
|
||||
Constants.delIPCIp(MainActivity.this);
|
||||
} else {
|
||||
Constants.setIPCIp(MainActivity.this, s.toString());
|
||||
String str = s.toString();
|
||||
if (str.contains(":")) {
|
||||
str = str.replace(":", ":");
|
||||
etIp.setText(str);
|
||||
etIp.setSelection(str.length());
|
||||
}
|
||||
Constants.setIPCIp(MainActivity.this, str);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -338,6 +348,45 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
showLocalIP();
|
||||
}
|
||||
});
|
||||
|
||||
findViewById(R.id.tv_ip).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (listPopupWindow == null)
|
||||
showListPopupWindow();
|
||||
else {
|
||||
listPopupWindow.dismiss();
|
||||
listPopupWindow = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showListPopupWindow() {
|
||||
List<String> ips = Constants.getIpcUsedIps(this);
|
||||
if (ips != null && !ips.isEmpty()) {
|
||||
listPopupWindow = new ListPopupWindow(this);
|
||||
listPopupWindow.setAdapter(new ArrayAdapter<String>(this, R.layout.item_pop, ips));
|
||||
listPopupWindow.setAnchorView(etIp);//以哪个控件为基准,在该处以mEditText为基准
|
||||
listPopupWindow.setModal(true);
|
||||
listPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss() {
|
||||
listPopupWindow = null;
|
||||
}
|
||||
});
|
||||
listPopupWindow.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
String text = ips.get(i);
|
||||
etIp.setText(text);
|
||||
etIp.setSelection(text.length());
|
||||
listPopupWindow.dismiss();
|
||||
listPopupWindow = null;
|
||||
}
|
||||
});
|
||||
listPopupWindow.show();
|
||||
}
|
||||
}
|
||||
|
||||
private void initListData() {
|
||||
@@ -528,22 +577,23 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
});
|
||||
}
|
||||
|
||||
public void showIPCIP(final String ip, final int port) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!BuildConfig.IS_CLIENT) {
|
||||
String temp = "";
|
||||
ipcIp.setVisibility(View.VISIBLE);
|
||||
if (!TextUtils.isEmpty(ip)) {
|
||||
temp = "IPC IP:" + ip + ":" + port;
|
||||
}
|
||||
ipcIp.setText(temp);
|
||||
} else {
|
||||
ipcIp.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
private String getIPCIP() {
|
||||
final String ip = AdasManager.getInstance().getIpcConnectedIp();
|
||||
final int port = AdasManager.getInstance().getIpcConnectedPort();
|
||||
String temp = "";
|
||||
if (!TextUtils.isEmpty(ip)) {
|
||||
temp = ip + ":" + port;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
public void showIPCIP() {
|
||||
if (!BuildConfig.IS_CLIENT) {
|
||||
ipcIp.setVisibility(View.VISIBLE);
|
||||
ipcIp.setText("IPC IP:" + getIPCIP());
|
||||
} else {
|
||||
ipcIp.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -573,38 +623,17 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
color = R.color.connect_status_disconnecting;
|
||||
break;
|
||||
}
|
||||
CupidLogUtils.i(TAG, "connectStatus=" + status);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tvConnectState.setText(status);
|
||||
tvConnectState.setTextColor(getResources().getColor(color));
|
||||
}
|
||||
});
|
||||
Message msg = Message.obtain();
|
||||
msg.obj = new IPCConnectState(status, color);
|
||||
msg.what = WHATIPC_CONNECT_STATE;
|
||||
getHandler().sendMessage(msg);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
private void updateText(final TextView tv, final String text) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
tv.setText(text);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onSSHResult(final SSHResult info) {
|
||||
LogSave.getInstance().saveLog("接收", info.toString());
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showToastCenter("IPC命令下发结果:" + info.code + " 命令:" + info.cmd + " 信息:" + info.msg);
|
||||
}
|
||||
});
|
||||
showToastCenter("IPC命令下发结果:" + info.code + " 命令:" + info.cmd + " 信息:" + info.msg);
|
||||
CupidLogUtils.w(TAG, "IPC命令下发结果:" + info.code + " 命令:" + info.cmd + " 信息:" + info.msg);
|
||||
}
|
||||
|
||||
@@ -612,56 +641,56 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
public void onError(ProtocolStatus status, byte[] bytes) {
|
||||
ErrorData base = new ErrorData(status, bytes);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrajectory(MessagePad.Header header, MessagePad.Trajectory trajectory) {
|
||||
Trajectory base = new Trajectory(header, trajectory);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrackedObjects(MessagePad.Header header, MessagePad.TrackedObjects trackedObjects) {
|
||||
TrackedObjects base = new TrackedObjects(header, trackedObjects);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGnssInfo(MessagePad.Header header, MessagePad.GnssInfo gnssInfo) {
|
||||
GnssInfo base = new GnssInfo(header, gnssInfo);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onVehicleState(MessagePad.Header header, VehicleStateOuterClass.VehicleState vehicleState) {
|
||||
VehicleState base = new VehicleState(header, vehicleState);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotState(MessagePad.Header header, MessagePad.AutopilotState autopilotState) {
|
||||
AutopilotState base = new AutopilotState(header, autopilotState);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReportMessage(MessagePad.Header header, MogoReportMsg.MogoReportMessage mogoReportMessage) {
|
||||
MogoReportMessage base = new MogoReportMessage(header, mogoReportMessage);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPerceptionTrafficLight(MessagePad.Header header, TrafficLightOuterClass.TrafficLights trafficLights) {
|
||||
PerceptionTrafficLight base = new PerceptionTrafficLight(header, trafficLights);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -669,13 +698,8 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
BasicInfoReq info = new BasicInfoReq(header, basicInfoReq);
|
||||
LogSave.getInstance().saveLog("接收", info.toString());
|
||||
AdasManager.getInstance().sendBasicInfoResp("X202021111192N41VY", 1);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
toastMsg("收到车机基础信息请求:" + info.toString());
|
||||
}
|
||||
});
|
||||
// EventBus.getDefault().postSticky(new BasicInfoReq(header, basicInfoReq));
|
||||
showToastCenter("收到车机基础信息请求:" + info.toString());
|
||||
// EventBus.getDefault().post(new BasicInfoReq(header, basicInfoReq));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -691,48 +715,53 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
recordKey = recordPanel.getKey();
|
||||
recordFileName = recordPanel.getFilename();
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGlobalPathResp(MessagePad.Header header, MessagePad.GlobalPathResp globalPathResp) {
|
||||
GlobalPathResp base = new GlobalPathResp(header, globalPathResp);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWarn(MessagePad.Header header, MessagePad.Warn warn) {
|
||||
Warn base = new Warn(header, warn);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArrivalNotification(MessagePad.Header header, MessagePad.ArrivalNotification arrivalNotification) {
|
||||
ArrivalNotification base = new ArrivalNotification(header, arrivalNotification);
|
||||
LogSave.getInstance().saveLog("接收", base.toString());
|
||||
EventBus.getDefault().postSticky(base);
|
||||
EventBus.getDefault().post(base);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpgradeStateInfo(final IPCUpgradeStateInfo info) {
|
||||
LogSave.getInstance().saveLog("接收", info.toString());
|
||||
EventBus.getDefault().postSticky(info);
|
||||
EventBus.getDefault().post(info);
|
||||
}
|
||||
|
||||
|
||||
private Toast toast;
|
||||
|
||||
public void showToastCenter(String msg) {
|
||||
if (toast != null) {
|
||||
toast.cancel();
|
||||
toast = null;
|
||||
}
|
||||
toast = Toast.makeText(this, "", Toast.LENGTH_SHORT); //如果有居中显示需求
|
||||
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (toast != null) {
|
||||
toast.cancel();
|
||||
toast = null;
|
||||
}
|
||||
toast = Toast.makeText(MainActivity.this, "", Toast.LENGTH_SHORT); //如果有居中显示需求
|
||||
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
toast.setText(msg);
|
||||
toast.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -744,26 +773,19 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
options = new AdasOptions.Builder().setClient(true).build();
|
||||
NSDNettyManager.getInstance().searchAndConnectServer(this, "1234", new NettyClientListener<MogoProtocolMsg>() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onMessageResponseClient(MogoProtocolMsg msg, String sign) {
|
||||
public void onMessageResponseClient(MogoProtocolMsg msg, String sign, Channel channel) {
|
||||
AdasManager.getInstance().parseIPCData(msg.getBody());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClientStatusConnectChanged(int statusCode, String sign) {
|
||||
public void onClientStatusConnectChanged(int statusCode, String sign, Channel channel) {
|
||||
if (statusCode == ConnectState.STATUS_CONNECT_SUCCESS) {
|
||||
connectStatus = IPC_CONNECTION_STATUS.CONNECTED;
|
||||
} else {
|
||||
connectStatus = IPC_CONNECTION_STATUS.DISCONNECTED;
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ipcIp.setVisibility(View.VISIBLE);
|
||||
ipcIp.setText("司机IP:" + NSDNettyManager.getInstance().getConnServerIp());
|
||||
}
|
||||
});
|
||||
getHandler().sendEmptyMessage(WHAT_DRIVER_IP);
|
||||
onUpdateConnectStateView();
|
||||
}
|
||||
});
|
||||
@@ -862,29 +884,26 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
public void onConnectionIPCStatus(int ipcConnectionStatus, String failedMsg) {
|
||||
connectStatus = ipcConnectionStatus;
|
||||
String status = onUpdateConnectStateView();
|
||||
status += "failedMsg=" + failedMsg;
|
||||
LogSave.getInstance().saveLog("连接状态", status);
|
||||
if (connectStatus == IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
CupidLogUtils.w(TAG, "===>MainActivity onWebSocketConnectSuccess");
|
||||
showIPCIP(AdasManager.getInstance().getIpcConnectedIp(), AdasManager.getInstance().getIpcConnectedPort());
|
||||
} else if (connectStatus == IPC_CONNECTION_STATUS.DISCONNECTED) {
|
||||
toastMsg("连接失败:" + failedMsg);
|
||||
CupidLogUtils.w(TAG, "===>MainActivity onWebSocketConnectFailed");
|
||||
showIPCIP(AdasManager.getInstance().getIpcConnectedIp(), AdasManager.getInstance().getIpcConnectedPort());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void toastMsg(final String msg) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Toast.makeText(MainActivity.this, msg, Toast.LENGTH_LONG).show();
|
||||
getHandler().sendEmptyMessage(WHAT_IPC_IP);
|
||||
String tem = getIPCIP();
|
||||
if (!TextUtils.isEmpty(tem)) {
|
||||
List<String> ips = Constants.getIpcUsedIps(this);
|
||||
Constants.addIpcUsedIps(this, ips, tem);
|
||||
}
|
||||
});
|
||||
} else if (connectStatus == IPC_CONNECTION_STATUS.DISCONNECTED) {
|
||||
if (!TextUtils.isEmpty(failedMsg)) {
|
||||
status += " failedMsg=" + failedMsg;
|
||||
showToastCenter("连接失败:" + failedMsg);
|
||||
}
|
||||
getHandler().sendEmptyMessage(WHAT_IPC_IP);
|
||||
}
|
||||
LogSave.getInstance().saveLog("连接状态", status);
|
||||
CupidLogUtils.i(TAG, "connectStatus=" + status);
|
||||
}
|
||||
|
||||
private void showLocalIP() {
|
||||
showToastCenter("已刷新本机IP");
|
||||
localIp.setText("本机IP:" + getIpAddressString());
|
||||
}
|
||||
|
||||
@@ -930,10 +949,10 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
|
||||
@Override
|
||||
public void onItemClick(int position, String data) {
|
||||
// if (connectStatus != IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
// toastMsg("IPC 未连接");
|
||||
// return;
|
||||
// }
|
||||
if (connectStatus != IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
showToastCenter("IPC 未连接");
|
||||
return;
|
||||
}
|
||||
switch (position) {
|
||||
case 0:
|
||||
if (autoPilotModeDialog == null) {
|
||||
@@ -1050,4 +1069,24 @@ public class MainActivity extends BaseActivity implements OnAdasListener, OnAdas
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
switch (msg.what) {
|
||||
case WHAT_IPC_IP:
|
||||
showIPCIP();
|
||||
break;
|
||||
case WHAT_DRIVER_IP:
|
||||
ipcIp.setVisibility(View.VISIBLE);
|
||||
ipcIp.setText("司机IP:" + NSDNettyManager.getInstance().getConnServerIp());
|
||||
break;
|
||||
case WHATIPC_CONNECT_STATE:
|
||||
IPCConnectState status = (IPCConnectState) msg.obj;
|
||||
tvConnectState.setText(status.status);
|
||||
tvConnectState.setTextColor(getResources().getColor(status.color));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zhidao.adas.client.utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.zhidao.adas.client.bean.AutoPilotMode;
|
||||
@@ -85,4 +86,43 @@ public class Constants {
|
||||
public static boolean delIPCIp(Context context) {
|
||||
return PreferencesUtils.delete(context, IPC_IP);
|
||||
}
|
||||
|
||||
|
||||
/***********************保存使用过的IP列表******************/
|
||||
|
||||
|
||||
private static final String IPC_USED_IP = "ipc_used_ip";
|
||||
|
||||
public static List<String> getIpcUsedIps(Context context) {
|
||||
String json = PreferencesUtils.getString(context, IPC_USED_IP, null);
|
||||
if (TextUtils.isEmpty(json)) return null;
|
||||
List<String> list = JsonUtil.fromJson(json, new TypeToken<List<String>>() {
|
||||
}.getType());
|
||||
return list;
|
||||
}
|
||||
|
||||
public static boolean addIpcUsedIps(Context context, List<String> list, String mode) {
|
||||
if (list == null)
|
||||
list = new ArrayList<>();
|
||||
list.remove(mode);
|
||||
list.add(0, mode);
|
||||
if (list.size() > 10) {
|
||||
list.remove(list.size() - 1);
|
||||
}
|
||||
return PreferencesUtils.putString(context, IPC_USED_IP, JsonUtil.toJson(list));
|
||||
}
|
||||
|
||||
public static boolean delIpcUsedIps(Context context, List<String> list, String mode) {
|
||||
if (list == null) {
|
||||
return PreferencesUtils.delete(context, IPC_USED_IP);
|
||||
} else {
|
||||
if (list.contains(mode)) {
|
||||
list.remove(mode);
|
||||
return PreferencesUtils.putString(context, IPC_USED_IP, JsonUtil.toJson(list));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:text="工控机"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/colorWhile"
|
||||
android:textSize="18dp"
|
||||
android:textStyle="bold" />
|
||||
@@ -207,7 +207,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:digits="0123456789.:"
|
||||
android:digits="0123456789.::"
|
||||
android:gravity="right|center_vertical"
|
||||
android:hint="IP地址"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
@@ -215,9 +215,9 @@
|
||||
android:layoutDirection="ltr"
|
||||
android:maxLength="21"
|
||||
android:maxLines="1"
|
||||
android:minWidth="100dp"
|
||||
android:minWidth="166dp"
|
||||
android:textColor="@color/colorWhile"
|
||||
android:textSize="16dp" />
|
||||
android:textSize="16sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_ip"
|
||||
|
||||
13
app_ipc_monitoring/src/main/res/layout/item_pop.xml
Normal file
13
app_ipc_monitoring/src/main/res/layout/item_pop.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:maxLines="1"
|
||||
android:minWidth="100dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="@color/colorBlock"
|
||||
android:textSize="16sp" />
|
||||
@@ -167,7 +167,7 @@ class MoGoAutopilotProvider :
|
||||
// 监听ADAS-SDK获取到的工控机数据(乘客也需注册)
|
||||
AdasManager.getInstance().setOnAdasListener(MoGoAdasListenerImpl())
|
||||
// 司机端监听
|
||||
if (FunctionBuildConfig.appIdentityMode == 0) {
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
AdasManager.getInstance().setOnMultiDeviceListener { bytes ->
|
||||
// 发送数据给乘客端
|
||||
if (NSDNettyManager.getInstance().isServerStart) {
|
||||
@@ -338,7 +338,7 @@ class MoGoAutopilotProvider :
|
||||
AdasManager.getInstance().sendDemoModeReq(0)
|
||||
}
|
||||
// 同步给乘客端
|
||||
if (FunctionBuildConfig.appIdentityMode == 0) {
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
var byteArray = if (isEnable) byteArrayOf(1) else byteArrayOf(0)
|
||||
if (NSDNettyManager.getInstance().isServerStart) {
|
||||
NSDNettyManager.getInstance()
|
||||
|
||||
@@ -840,7 +840,9 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
override fun showTurnLight(light: Int) {
|
||||
if (HmiBuildConfig.isShowTurnLightView) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
turnLightView.setTurnLight(light)
|
||||
turnLightView?.let {
|
||||
turnLightView.setTurnLight(light)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -851,7 +853,9 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
|
||||
override fun showBrakeLight(light: Int) {
|
||||
if (HmiBuildConfig.isShowBrakeLightView) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
brakeView.setBrakeLight(light)
|
||||
brakeView?.let {
|
||||
brakeView.setBrakeLight(light)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1345,16 +1345,17 @@ class DebugSettingView @JvmOverloads constructor(
|
||||
AppConfigInfo.isConnectNet = NetworkUtils.isConnected(context)
|
||||
AppConfigInfo.isConnectSocket = DebugConfig.isDownloadSnapshot()
|
||||
|
||||
when (FunctionBuildConfig.appIdentityMode) {
|
||||
0x00 -> {// 司机端
|
||||
when {
|
||||
AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode) -> {// 司机端
|
||||
AppConfigInfo.isDriver = true
|
||||
AppConfigInfo.isConnectedNetty = CallerTelematicManager.getServerStarted()
|
||||
}
|
||||
else -> {
|
||||
AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode) -> {
|
||||
AppConfigInfo.isDriver = false
|
||||
AppConfigInfo.isConnectedNetty = CallerTelematicManager.getClientConnStatus()
|
||||
AppConfigInfo.serverIp = CallerTelematicManager.getServerIp()
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,6 +51,11 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
initView()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private var maxAcceleration: Double = 2.0
|
||||
private var speedLimit: Double = 0.0
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun initView() {
|
||||
background = ColorDrawable(Color.parseColor("#F0151D41"))
|
||||
@@ -124,6 +129,12 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
if (AppConfigInfo.isConnectAutopilot) {
|
||||
CallerAutoPilotManager.getCarConfig()
|
||||
}
|
||||
if (maxAcceleration > 0) {
|
||||
tvAcceleration.text = "加速度 $maxAcceleration m/s²"
|
||||
}
|
||||
if (speedLimit > 0) {
|
||||
etInputSpeed.setText((speedLimit * 3.6).toInt().toString())
|
||||
}
|
||||
// // 比如需要设置默认速度
|
||||
// val speed = "30"
|
||||
// etInputSpeed.setText(speed)
|
||||
@@ -204,6 +215,8 @@ class AutoPilotAndCheckView @JvmOverloads constructor(
|
||||
override fun onAutopilotCarConfig(carConfigResp: MessagePad.CarConfigResp) {
|
||||
UiThreadHandler.post {
|
||||
tvAcceleration?.let {
|
||||
maxAcceleration = carConfigResp.maxAcceleration
|
||||
speedLimit = carConfigResp.speedLimit
|
||||
tvAcceleration.text = "加速度 ${carConfigResp.maxAcceleration} m/s²"
|
||||
etInputSpeed.setText((carConfigResp.speedLimit * 3.6).toInt().toString())
|
||||
}
|
||||
|
||||
@@ -185,7 +185,6 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="123px"
|
||||
android:layout_marginTop="12px"
|
||||
android:text="加速度 2 m/s²"
|
||||
android:textColor="#A7B6F0"
|
||||
android:textSize="32px"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvLimitingVelocity"
|
||||
android:layout_width="130px"
|
||||
android:layout_height="130px"
|
||||
android:layout_width="120px"
|
||||
android:layout_height="120px"
|
||||
android:background="@drawable/bg_waring_limiting_velocity"
|
||||
android:elevation="@dimen/dp_10"
|
||||
android:gravity="center"
|
||||
|
||||
@@ -48,11 +48,11 @@ class MogoTrafficLightManager : IMogoCarLocationChangedListener2 {
|
||||
.registerCenterApi.registerCarLocationChangedListener(TAG, this)
|
||||
mThreadHandler =
|
||||
TrafficLightThreadHandler(Looper.getMainLooper(), {
|
||||
//TODO emArrow 查询路口时,如果红绿灯显示,则隐藏掉
|
||||
// if (TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()) {
|
||||
// TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
// CallTrafficLightListenerManager.resetTrafficLightData()
|
||||
// }
|
||||
//查询路口时,如果红绿灯显示,则隐藏掉
|
||||
if (TrafficLightHMIManager.INSTANCE.isWarningTrafficLightShow()) {
|
||||
TrafficLightHMIManager.INSTANCE.hideTrafficLight()
|
||||
CallTrafficLightListenerManager.resetTrafficLightData()
|
||||
}
|
||||
mLocation?.let { it ->
|
||||
val tileId = CallerMapUIServiceManager.getMapUIController()?.getTileId(it.longitude, it.latitude) ?: 0
|
||||
trafficLightNetWorkModel.requestRoadID(
|
||||
|
||||
@@ -3,21 +3,20 @@
|
||||
|
||||
<item>
|
||||
<shape android:shape="oval">
|
||||
<solid android:color="#3F4C7D" />
|
||||
<solid android:color="#E63F4C7D" />
|
||||
|
||||
<size
|
||||
android:width="130px"
|
||||
android:height="130px" />
|
||||
android:width="120px"
|
||||
android:height="120px" />
|
||||
</shape>
|
||||
</item>
|
||||
<item>
|
||||
<shape
|
||||
android:innerRadius="60px"
|
||||
android:innerRadius="52px"
|
||||
android:shape="ring"
|
||||
android:thickness="5px"
|
||||
android:thickness="8px"
|
||||
android:useLevel="false">
|
||||
<solid android:color="#F03232" />
|
||||
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
|
||||
@@ -301,14 +301,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// TODO 临时接续Json数据传递添加的Header 0x00表示PB数据 0x01表示Json数据
|
||||
if (!adasOptions.isClient() && onMultiDeviceListener != null) {
|
||||
byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] temp = new byte[bytes.length + 1];
|
||||
System.arraycopy(bytes, 0, temp, 1, bytes.length);
|
||||
temp[0] = 0x01;
|
||||
onMultiDeviceListener.onForwardingIPCMessage(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,19 +313,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
if (bytes == null || bytes.length == 0) {
|
||||
return;
|
||||
}
|
||||
//TODO 临时将Json数据转发并解析 0x00表示PB数据 0x01表示Json数据
|
||||
if (adasOptions.isClient()) {
|
||||
byte header = bytes[0];
|
||||
byte[] temp = new byte[bytes.length - 1];
|
||||
System.arraycopy(bytes, 1, temp, 0, temp.length);
|
||||
bytes = temp;
|
||||
if (header != 0x00) {
|
||||
//Json 解析
|
||||
handlerWSMsg(new String(bytes, StandardCharsets.UTF_8));
|
||||
return;
|
||||
}
|
||||
}
|
||||
//PB解析
|
||||
ByteString byteString = ByteString.of(bytes);
|
||||
try {
|
||||
if (rawUnpack != null) {
|
||||
@@ -417,11 +396,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
byte[] bytes1 = bytes.toByteArray();
|
||||
parseIPCData(bytes1);
|
||||
if (!adasOptions.isClient() && onMultiDeviceListener != null) {
|
||||
// TODO 临时接续Json数据传递添加的Header 0x00表示PB数据 0x01表示Json数据
|
||||
byte[] temp = new byte[bytes1.length + 1];
|
||||
System.arraycopy(bytes1, 0, temp, 1, bytes1.length);
|
||||
temp[0] = 0x00;
|
||||
onMultiDeviceListener.onForwardingIPCMessage(temp);
|
||||
onMultiDeviceListener.onForwardingIPCMessage(bytes1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.Define;
|
||||
|
||||
@@ -15,7 +17,8 @@ public interface OnAdasConnectStatusListener {
|
||||
*
|
||||
* @param ipcConnectionStatus {@link Constants.IPC_CONNECTION_STATUS}
|
||||
* @param failedMsg 连接异常信息 需要判null
|
||||
* 如果ipcConnectionStatus==Constants.IPC_CONNECTION_STATUS.DISCONNECTED&&failedMsg==null 表示主动断开连接
|
||||
*/
|
||||
void onConnectionIPCStatus(@Define.IPCConnectionStatus int ipcConnectionStatus, String failedMsg);
|
||||
void onConnectionIPCStatus(@Define.IPCConnectionStatus int ipcConnectionStatus, @Nullable String failedMsg);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* 与工控机链接成功后,工控机断开连接超时监测管理器
|
||||
*/
|
||||
public class TimeoutManager {
|
||||
private static volatile TimeoutManager INSTANCE;
|
||||
private volatile long lastReceiveTime;
|
||||
private volatile Future future;
|
||||
private OnTimeoutListener listener;
|
||||
|
||||
public interface OnTimeoutListener {
|
||||
void onTimeout();
|
||||
}
|
||||
|
||||
public void setListener(OnTimeoutListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
private TimeoutManager() {
|
||||
}
|
||||
|
||||
public static TimeoutManager getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (TimeoutManager.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new TimeoutManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新最后一次接收时间
|
||||
*/
|
||||
public void refreshLase() {
|
||||
lastReceiveTime = System.currentTimeMillis();
|
||||
Log.i("Fpga", "lastReceiveTime=" + lastReceiveTime);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
if (future == null) {
|
||||
future = ThreadPoolManager.getsInstance().submit(new DetectionThread());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stop() {
|
||||
if (future != null && !future.isCancelled()) {
|
||||
future.cancel(true);
|
||||
}
|
||||
future = null;
|
||||
}
|
||||
|
||||
private class DetectionThread implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (this) {
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
if (System.currentTimeMillis() - lastReceiveTime > 5 * 1000L) {
|
||||
if (listener != null) {
|
||||
listener.onTimeout();
|
||||
}
|
||||
stop();
|
||||
}
|
||||
try {
|
||||
Thread.sleep(5 * 1000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class FpgaSocket implements IWebSocket {
|
||||
private String wsHost;
|
||||
private String ipAddress;
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* 是否是用户主动关闭socket
|
||||
*/
|
||||
@@ -76,9 +77,9 @@ public class FpgaSocket implements IWebSocket {
|
||||
}
|
||||
if (okBuilder == null) {
|
||||
okBuilder = new OkHttpClient.Builder();
|
||||
okBuilder.writeTimeout(5, TimeUnit.SECONDS);
|
||||
okBuilder.readTimeout(5, TimeUnit.SECONDS);
|
||||
okBuilder.connectTimeout(5, TimeUnit.SECONDS);
|
||||
okBuilder.writeTimeout(5, TimeUnit.SECONDS)
|
||||
.readTimeout(5, TimeUnit.SECONDS)
|
||||
.connectTimeout(5, TimeUnit.SECONDS);
|
||||
}
|
||||
if (client == null) {
|
||||
client = okBuilder.build();
|
||||
@@ -136,10 +137,9 @@ public class FpgaSocket implements IWebSocket {
|
||||
}
|
||||
isUserCloseWebSocket = true;
|
||||
if (mWebSocket != null) {
|
||||
boolean isClose = mWebSocket.close(1000, null);
|
||||
CupidLogUtils.i(TAG, "WebSocket 主动断开连接,是否成功= " + isClose);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
close(true, 1000);
|
||||
} else {
|
||||
onConnectFailed(null);
|
||||
}
|
||||
listener = null;
|
||||
client = null;
|
||||
@@ -259,6 +259,8 @@ public class FpgaSocket implements IWebSocket {
|
||||
public void onClosing(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
||||
super.onClosing(webSocket, code, reason);
|
||||
CupidLogUtils.e(TAG, "WebSocket onClosing= " + reason);
|
||||
if (TextUtils.isEmpty(reason))
|
||||
reason = "onClosing";
|
||||
onClose(reason);
|
||||
}
|
||||
|
||||
@@ -266,6 +268,8 @@ public class FpgaSocket implements IWebSocket {
|
||||
public void onClosed(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
||||
super.onClosed(webSocket, code, reason);
|
||||
CupidLogUtils.e(TAG, "WebSocket onClosed= " + reason);
|
||||
if (TextUtils.isEmpty(reason))
|
||||
reason = "onClosed";
|
||||
onClose(reason);
|
||||
}
|
||||
|
||||
@@ -273,30 +277,45 @@ public class FpgaSocket implements IWebSocket {
|
||||
public void onFailure(@NonNull WebSocket webSocket, @NonNull Throwable t, Response response) {
|
||||
super.onFailure(webSocket, t, response);
|
||||
CupidLogUtils.e(TAG, "WebSocket onFailure= " + t);
|
||||
t.printStackTrace();
|
||||
String reason = t.toString();
|
||||
if (TextUtils.isEmpty(reason))
|
||||
reason = "onFailure";
|
||||
if (mWebSocket != null) {
|
||||
mWebSocket.close(1000, null);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
close(false, 1001);
|
||||
}
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(t.toString());
|
||||
reconnect();
|
||||
|
||||
onConnectFailed(reason);
|
||||
}
|
||||
}
|
||||
|
||||
private void onConnectFailed(String reason) {
|
||||
if (mWebSocketConnectListener != null) {
|
||||
if (isUserCloseWebSocket)
|
||||
reason = null;
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(reason);
|
||||
}
|
||||
reconnect();
|
||||
}
|
||||
|
||||
private void onClose(String reason) {
|
||||
if (mWebSocket != null) {
|
||||
mWebSocket.close(1000, null);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
close(false, 1001);
|
||||
} else {
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(reason);
|
||||
reconnect();
|
||||
onConnectFailed(reason);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isInitiative 是否是主动断开
|
||||
* @param code code
|
||||
*/
|
||||
private void close(boolean isInitiative, int code) {
|
||||
boolean isClose = mWebSocket.close(code, null);
|
||||
CupidLogUtils.i(TAG, "WebSocket " + (isInitiative ? "主动" : "被动") + "断开连接是否成功= " + isClose);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
}
|
||||
|
||||
public WebSocket getWebSocket() {
|
||||
return mWebSocket;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user