Merge branch 'dev_MogoAP_eagle-220_211207_8.0.17_merge' into dev_robotaxi-p-app_254_220228_2.5.4
This commit is contained in:
@@ -24,6 +24,7 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.zhidao.support.adas.high.AdasManager
|
||||
import com.zhidao.support.adas.high.AdasOptions
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeInfo
|
||||
import com.zhidao.support.adas.high.common.Constants
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@@ -57,7 +58,8 @@ class MoGoAutopilotProvider :
|
||||
CallerMapDataCollectorManager.registerOnMapCollectTaskListener(this)
|
||||
// "192.168.1.102"
|
||||
val options = AdasOptions.Builder()
|
||||
.setIPCIp(FunctionBuildConfig.adasConnectIP)
|
||||
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
|
||||
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
|
||||
.setClient(false)
|
||||
.build()
|
||||
|
||||
@@ -124,8 +126,9 @@ class MoGoAutopilotProvider :
|
||||
else -> // 默认采用UDP寻址方式
|
||||
{
|
||||
val options = AdasOptions.Builder()
|
||||
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
|
||||
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
|
||||
.setClient(false)
|
||||
.setIPCIp(FunctionBuildConfig.adasConnectIP)
|
||||
.build()
|
||||
AdasManager.getInstance().create(context, options)
|
||||
}
|
||||
@@ -181,7 +184,7 @@ class MoGoAutopilotProvider :
|
||||
*/
|
||||
override fun resetIpAddress(autoPilotIp: String) {
|
||||
// 关闭通信
|
||||
AdasManager.getInstance().closeAllMsg()
|
||||
AdasManager.getInstance().disconnect()
|
||||
// 延时执行连接指定IP地址
|
||||
ThreadUtils.executeBySingleWithDelay(object : ThreadUtils.SimpleTask<String>() {
|
||||
@RequiresPermission(permission.INTERNET)
|
||||
@@ -191,9 +194,10 @@ class MoGoAutopilotProvider :
|
||||
SharedPrefsMgr.getInstance(it).putString(MoGoConfig.AUTOPILOT_IP, autoPilotIp)
|
||||
}
|
||||
// 设置IP地址
|
||||
AdasManager.getInstance().setIPCIp(autoPilotIp)
|
||||
AdasManager.getInstance().adasOptions.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.ASSIGN)
|
||||
AdasManager.getInstance().adasOptions.setIpcAssignIP(autoPilotIp)
|
||||
// 打开通讯连接
|
||||
AdasManager.getInstance().startAllMsg()
|
||||
AdasManager.getInstance().connect()
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -214,7 +218,7 @@ class MoGoAutopilotProvider :
|
||||
}
|
||||
|
||||
override fun startAutoPilot(result: AutopilotControlParameters) {
|
||||
if (AdasManager.getInstance().isSocketConnect) {
|
||||
if (AdasManager.getInstance().ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
val parameter = AutopilotControlCmdParameter("aiCloudToStartAutopilot", result)
|
||||
AdasManager.getInstance().aiCloudToAdasData(GsonUtils.toJson(parameter))
|
||||
} else {
|
||||
@@ -227,7 +231,7 @@ class MoGoAutopilotProvider :
|
||||
}
|
||||
|
||||
override fun cancelAutoPilot() {
|
||||
if (AdasManager.getInstance().isSocketConnect) {
|
||||
if (AdasManager.getInstance().ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
AdasManager.getInstance().controlAutopilotCarHead()
|
||||
} else {
|
||||
Logger.e(TAG, "车机与工控机链接失败,无法断开自动驾驶")
|
||||
|
||||
@@ -2,17 +2,16 @@ package com.mogo.eagle.core.function.autopilot.adapter
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.eagle.core.data.app.AppConfigInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStationInfo
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
|
||||
import com.mogo.eagle.core.data.constants.MoGoConfig
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.autopilot.network.AdasServiceModel
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.zhidao.support.adas.high.AdasManager
|
||||
import com.zhidao.support.adas.high.OnAdasMsgConnectStatusListener
|
||||
import com.zhidao.support.adas.high.OnAdasConnectStatusListener
|
||||
import com.zhidao.support.adas.high.bean.BasicInfo
|
||||
import com.zhidao.support.adas.high.common.Constants
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
@@ -23,7 +22,8 @@ import java.util.concurrent.TimeUnit
|
||||
*
|
||||
* @author donghongyu
|
||||
*/
|
||||
class MoGoAdasMsgConnectStatusListenerImpl : OnAdasMsgConnectStatusListener, IMoGoAutopilotStatusListener {
|
||||
class MoGoAdasMsgConnectStatusListenerImpl : OnAdasConnectStatusListener,
|
||||
IMoGoAutopilotStatusListener {
|
||||
private val TAG = "MoGoAdasMsgConnectStatusListenerImpl"
|
||||
|
||||
//自动驾驶状态
|
||||
@@ -32,26 +32,36 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasMsgConnectStatusListener, IMo
|
||||
//自动驾驶车速度
|
||||
private var mCurrentAutopilotSpeed = 0f
|
||||
|
||||
override fun onWebSocketConnectSuccess() {
|
||||
Logger.d(TAG, "webSocket 连接成功")
|
||||
// 初始化自动驾驶状态信息
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectIP = AdasManager.getInstance().adasConfig.address
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = true
|
||||
CallerAutoPilotStatusListenerManager.invokeAutoPilotStatus()
|
||||
|
||||
// 同步SN给工控机
|
||||
syncBasicInfoToAutopilot()
|
||||
override fun onConnectionIPCStatus(ipcConnectionStatus: Int, reason: String?) {
|
||||
if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
Logger.d(TAG, "webSocket 连接成功")
|
||||
// 初始化自动驾驶状态信息
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectIP =
|
||||
AdasManager.getInstance().adasConfig.address
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = true
|
||||
CallerAutoPilotStatusListenerManager.invokeAutoPilotStatus()
|
||||
|
||||
// 开启轮训上传自动驾驶状态
|
||||
updateDriveStatusTask()
|
||||
// 同步SN给工控机
|
||||
syncBasicInfoToAutopilot()
|
||||
|
||||
// 开启轮训上传自动驾驶状态
|
||||
updateDriveStatusTask()
|
||||
} else if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) {
|
||||
Logger.d(TAG, "webSocket 连接失败 reason:$reason")
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectIP =
|
||||
AdasManager.getInstance().adasConfig.address
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = false
|
||||
CallerAutoPilotStatusListenerManager.invokeAutoPilotStatus()
|
||||
} else if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.CONNECTING) {
|
||||
Logger.d(TAG, "webSocket 正在连接")
|
||||
} else if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.SEARCH_ADDRESS) {
|
||||
Logger.d(TAG, "webSocket 正在搜索工控机IP")
|
||||
} else if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.NOT_FOUND_ADDRESS) {
|
||||
Logger.d(TAG, "webSocket 找不到可用IP 传入的IP不可用或固定IP列表中所有IP不可用")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onWebSocketConnectFailed(reason: String) {
|
||||
Logger.d(TAG, "webSocket 连接失败 reason:$reason")
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectIP = AdasManager.getInstance().adasConfig.address
|
||||
CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo().connectStatus = false
|
||||
CallerAutoPilotStatusListenerManager.invokeAutoPilotStatus()
|
||||
}
|
||||
|
||||
/**
|
||||
* 工控机获取SN
|
||||
@@ -94,12 +104,13 @@ class MoGoAdasMsgConnectStatusListenerImpl : OnAdasMsgConnectStatusListener, IMo
|
||||
private fun updateDriveStatusTask() {
|
||||
Logger.d(TAG, "updateDriveStatusTask")
|
||||
Flowable.interval(0, 5, TimeUnit.SECONDS)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { aLong: Long? ->
|
||||
AdasServiceModel.getInstance().updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.unsubscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe { aLong: Long? ->
|
||||
AdasServiceModel.getInstance()
|
||||
.updateDriveStatus(mCurrentAutopilotStatus, mCurrentAutopilotSpeed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ android {
|
||||
|
||||
protobuf {
|
||||
protoc {
|
||||
artifact = 'com.google.protobuf:protoc:3.6.1:osx-x86_64'
|
||||
artifact = 'com.google.protobuf:protoc:3.6.1'
|
||||
}
|
||||
|
||||
generateProtoTasks {
|
||||
|
||||
@@ -16,18 +16,16 @@ import com.zhidao.support.adas.high.bean.AutopilotControl;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotSpeedParam;
|
||||
import com.zhidao.support.adas.high.bean.BaseInfo;
|
||||
import com.zhidao.support.adas.high.bean.BasicInfo;
|
||||
import com.zhidao.support.adas.high.bean.ConfigInfo;
|
||||
import com.zhidao.support.adas.high.bean.DemoModeInfo;
|
||||
import com.zhidao.support.adas.high.bean.FaceLoginResponse;
|
||||
import com.zhidao.support.adas.high.bean.MapLocationInfo;
|
||||
import com.zhidao.support.adas.high.bean.SSHResult;
|
||||
import com.zhidao.support.adas.high.bean.record.RecordCauseParam;
|
||||
import com.zhidao.support.adas.high.bean.record.RecordDataParam;
|
||||
import com.zhidao.support.adas.high.common.ActionTypeReceive;
|
||||
import com.zhidao.support.adas.high.common.AppPreferenceHelper;
|
||||
import com.zhidao.support.adas.high.common.Base64;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.Define;
|
||||
import com.zhidao.support.adas.high.common.IPCFixationIPHelper;
|
||||
import com.zhidao.support.adas.high.common.MgContextUtils;
|
||||
import com.zhidao.support.adas.high.common.RSATool;
|
||||
import com.zhidao.support.adas.high.common.SSH;
|
||||
@@ -48,10 +46,9 @@ import com.zhjt.service.chain.TracingConstants;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
|
||||
import mogo.webproto.WebsocketHeader;
|
||||
import okhttp3.WebSocket;
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
@@ -66,73 +63,88 @@ import okio.ByteString;
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnectListener, IConnectRtpListener, IGetH264Data {
|
||||
public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnectListener, IConnectRtpListener, IGetH264Data, IPCFixationIPHelper.IIPCFixationIPListener {
|
||||
private static final String TAG = AdasChannel.class.getSimpleName();
|
||||
|
||||
private FpgaSocket mSocket;
|
||||
private SocketReader socketReader;
|
||||
private JSONObject jsonObject;
|
||||
/**
|
||||
* udp server
|
||||
*/
|
||||
private CupidUdpConstract udpConstract;
|
||||
/**
|
||||
* 与工控机链接状态
|
||||
*/
|
||||
@Define.IPCConnectionStatus
|
||||
private int ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.DISCONNECTED;
|
||||
|
||||
|
||||
/**
|
||||
* ============是否运行
|
||||
* 是否使用队列处理数据
|
||||
*/
|
||||
private volatile boolean isRunning;
|
||||
private volatile boolean isConnected;
|
||||
private volatile boolean flag = false;
|
||||
|
||||
private JSONObject location;
|
||||
//是否使用队列处理数据
|
||||
public static final boolean isUseQueue = false;
|
||||
//录包信息
|
||||
private RecordDataParam recordDataParam = null;
|
||||
/**
|
||||
* 配置信息同步接口只调用一次
|
||||
* 录包信息
|
||||
*/
|
||||
private List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfo;
|
||||
private RecordDataParam recordDataParam = null;
|
||||
|
||||
/**
|
||||
* 序列化rect
|
||||
*/
|
||||
private Gson gson;
|
||||
private final Gson gson = new Gson();
|
||||
/**
|
||||
* 消息工厂
|
||||
*/
|
||||
private MyMessageFactory myMessageFactory;
|
||||
private AutopilotSpeedParam speedParam;
|
||||
/**
|
||||
* 工控机IP
|
||||
* 工控机连接配置
|
||||
*/
|
||||
private String ipcIp;
|
||||
private final AdasOptions adasOptions;
|
||||
private RecordCauseParam recordCauseParam;
|
||||
private SSH ssh;
|
||||
/**
|
||||
* 是否是客户端
|
||||
* 已经链接成功的工控机IP 未连接未null
|
||||
*/
|
||||
private boolean isClient = true;
|
||||
private String ipcConnectedIP;
|
||||
private OnMultiDeviceListener onMultiDeviceListener;
|
||||
/**
|
||||
* IPC固定IP查询工具类
|
||||
*/
|
||||
private IPCFixationIPHelper ipcFixationIPHelper;
|
||||
|
||||
public void setOnMultiDeviceListener(OnMultiDeviceListener onMultiDeviceListener) {
|
||||
this.onMultiDeviceListener = onMultiDeviceListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIPCIp(String ipcIp) {
|
||||
this.ipcIp = ipcIp;
|
||||
public void onStartFindIP() {
|
||||
if (adasConnectStatusListener != null) {
|
||||
ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.SEARCH_ADDRESS;
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 可连通的IP
|
||||
*
|
||||
* @param ip 返回可用IP 当为null时表示无可用IP
|
||||
*/
|
||||
@Override
|
||||
public void onAvailableIP(String ip) {
|
||||
getOnConnectionAddress(ip);
|
||||
}
|
||||
|
||||
AdasChannel(Context context, AdasOptions options) {
|
||||
initData(context);
|
||||
if (options != null) {
|
||||
this.isClient = options.isClient();
|
||||
this.ipcIp = options.getIpcIp();
|
||||
//配置为null默认是乘客屏幕
|
||||
if (options == null) {
|
||||
this.adasOptions = new AdasOptions.Builder().setClient(true).build();
|
||||
} else {
|
||||
this.adasOptions = options;
|
||||
}
|
||||
if (!isClient) {
|
||||
if (!adasOptions.isClient()) {
|
||||
initSocket();
|
||||
if (TextUtils.isEmpty(ipcIp))
|
||||
initUdpServer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,15 +154,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
MgContextUtils.setContext(context.getApplicationContext());
|
||||
//消息工厂
|
||||
myMessageFactory = new MyMessageFactory();
|
||||
FaceLoginResponse.DataBean dataBean = AppPreferenceHelper.getInstance(context).getUserInfo();
|
||||
if (dataBean != null) {
|
||||
configInfo = dataBean.getConfigInfoHistory();
|
||||
}
|
||||
jsonObject = new JSONObject();
|
||||
location = new JSONObject();
|
||||
if (gson == null) {
|
||||
gson = new Gson();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,10 +168,15 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
udpConstract = new CupidUdpConstract(VIDEO_RENDER_IMAGE_UDP);
|
||||
udpConstract.setOnReceiverH264Data(this);
|
||||
udpConstract.setOnConnectListener(this);
|
||||
isRunning = true;
|
||||
if (gson == null) {
|
||||
gson = new Gson();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据固定IP查询可用IP
|
||||
*/
|
||||
private void ipcFixationIPHelper(HashSet<String> ips) {
|
||||
if (ipcFixationIPHelper == null)
|
||||
ipcFixationIPHelper = new IPCFixationIPHelper(this);
|
||||
ipcFixationIPHelper.start(ips);
|
||||
}
|
||||
|
||||
private void initSocket() {
|
||||
@@ -179,68 +188,18 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
WSByteQueueManager.getInstance().registerWebSocketListener(this);
|
||||
WSByteQueueManager.getInstance().initDector();
|
||||
}
|
||||
//TODO 写死IP
|
||||
if (!TextUtils.isEmpty(ipcIp)) {
|
||||
isRunning = true;
|
||||
getOnConnectionAddress(ipcIp);
|
||||
}
|
||||
connect();
|
||||
}
|
||||
|
||||
// @ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
// linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
// endpoint = TracingConstants.Endpoint.PAD,
|
||||
// nodeAliasCode = CHAIN_ALIAS_CODE_UDP_CONNECT_ADDRESS,
|
||||
// paramIndexes = {0},
|
||||
// clientPkFileName = "sn")
|
||||
@ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_UDP_CONNECT_ADDRESS,
|
||||
paramIndexes = {0},
|
||||
clientPkFileName = "sn")
|
||||
private void connectSocket(String address) {
|
||||
if (mSocket != null)
|
||||
if (mSocket != null) {
|
||||
mSocket.connectWebSocket(address);
|
||||
}
|
||||
|
||||
public void closeSocket() {
|
||||
if (mSocket != null)
|
||||
mSocket.closeWebSocket();
|
||||
}
|
||||
|
||||
public void sendLocation(MapLocationInfo mapLocationInfo) {
|
||||
if (!isConnected) {
|
||||
return;
|
||||
}
|
||||
CupidLogUtils.e(mapLocationInfo.toString());
|
||||
//locationType
|
||||
/*
|
||||
TODO
|
||||
一次过滤:
|
||||
mAMapLocation.getLocationType(); //通过以上方法获取定位类型,如果对定位类型要求比较高,可以过滤掉基站定位(类型6)结果。
|
||||
二次过滤:
|
||||
mAMapLocation. getAccuracy(); //通过以上方法获取定位精度,例如超过500M精度的定位结果可以考虑不在业务场景里使用。
|
||||
6 基站定位结果 纯粹依赖移动、联通、电信等移动网络定位,定位精度在500米-5000米之间。
|
||||
5 Wifi定位结果 属于网络定位,定位精度相对基站定位会更好,定位精度较高,在5米-200米之间。
|
||||
4 缓存定位结果 返回一段时间前设备在同样的位置缓存下来的网络定位结果
|
||||
1 GPS定位结果 通过设备GPS定位模块返回的定位结果,精度较高,在10米-100米左右
|
||||
*/
|
||||
//纬度
|
||||
double currentLat = mapLocationInfo.getLatitude();
|
||||
//经度
|
||||
double currentLng = mapLocationInfo.getLongitude();
|
||||
//瞬时速度 m/s
|
||||
float speed = mapLocationInfo.getSpeed();
|
||||
/*if (BuildConfig.DEBUG) {
|
||||
speed = 60.0f;
|
||||
}*/
|
||||
try {
|
||||
//位置信息 action是2
|
||||
jsonObject.put("action", ActionTypeReceive.ACTION_WS_GPS_TYPE.getmActionType());
|
||||
location.put("latitude", currentLat + "");
|
||||
location.put("longitude", currentLng + "");
|
||||
location.put("speed", speed + "");
|
||||
location.put("bearing", mapLocationInfo.getBearing() + "");
|
||||
jsonObject.put("location", location);
|
||||
|
||||
sendWsMessage(jsonObject.toString());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +233,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
private void sendIPCCmd(final String cmd) {
|
||||
if (ssh == null) {
|
||||
// String ip = ipcIp;
|
||||
if (TextUtils.isEmpty(ipcIp)) {
|
||||
if (TextUtils.isEmpty(ipcConnectedIP)) {
|
||||
//尝试从缓存中获取工控机IP
|
||||
// String ip = AppPreferenceHelper.getInstance(MgContextUtils.getContext()).getUdpClientAddress();
|
||||
// if (TextUtils.isEmpty(ip)) {
|
||||
@@ -292,7 +251,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
String privateKey = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA127FFvuPolaxYTBg5wkyDIrEbcNKXoIjf0bK7QUQ991Lsbv5Ktv/XM2F6qJFssVF1KTkStVBSQGxJB1eZLwJEwIDAQABAkBM39AgpV/Z1Amz3qmVh+h+JT521ItDMjksf7yF25r0dzGjOfGLQmMAqQXT68B+cQX5HSoFMwk/rE1hnXgifyNBAiEA6uNE2TfPj51mPOZztGy1Q8p4exWohfotiy64g/CyVeMCIQDqy9e7bGeZEi6p1zemEgFVtwgZZvLn/BOP4UO7NjJnEQIhAJBnprUwha/SYb+BIpNC3fHOcWGigBfWJdfSomejO9BnAiEApfojLqKbOWHZCsbQ19yyhN02JH7aB5PyYCtlrdnKF4ECIHR1P2LOQLddXO8PwgoF6gtCTO2sxIqdvu8fUruWyouQ";
|
||||
try {
|
||||
String pwd = RSATool.decodeByPrivateKey(encodePwd, Base64.decodeBase64(privateKey));
|
||||
ssh.connect(ipcIp, 22, "titan", pwd);
|
||||
ssh.connect(ipcConnectedIP, 22, "titan", pwd);
|
||||
SSHResult result = ssh.exec(cmd, pwd);
|
||||
if (mAdasListener != null)
|
||||
mAdasListener.onSSHResult(result);
|
||||
@@ -323,10 +282,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
sendIPCCmd("docker restart autocar_default_1");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClient() {
|
||||
return isClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableDemoMode() {
|
||||
@@ -338,19 +293,12 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
sendBaseInfo(DemoModeInfo.disable());
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*
|
||||
* @param configInfo
|
||||
*/
|
||||
public void sendWsConfigMessage(ConfigInfo configInfo) {
|
||||
if (configInfo == null) {
|
||||
return;
|
||||
}
|
||||
String msg = gson.toJson(configInfo);
|
||||
sendWsMessage(msg);
|
||||
@Override
|
||||
public String getIPCConnectedIP() {
|
||||
return ipcConnectedIP;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发送ws消息
|
||||
*
|
||||
@@ -360,57 +308,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
return mSocket != null && mSocket.sendDataWebSocket(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 线程标志
|
||||
*/
|
||||
public void onResume() {
|
||||
CupidLogUtils.e(TAG, "===>onResume isRunning===>" + isRunning);
|
||||
if (!isRunning) {
|
||||
isRunning = true;
|
||||
if (TextUtils.isEmpty(ipcIp)) {
|
||||
initUdpServer();
|
||||
} else {
|
||||
getOnConnectionAddress(ipcIp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
public void onPause() {
|
||||
isRunning = false;
|
||||
if (udpConstract != null)
|
||||
udpConstract.release();
|
||||
if (isUseQueue) {
|
||||
UdpQueueManager.getInstance().release();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestory() {
|
||||
onPause();
|
||||
if (mSocket != null)
|
||||
mSocket.closeWebSocket();
|
||||
if (configInfo != null) {
|
||||
configInfo.clear();
|
||||
configInfo = null;
|
||||
}
|
||||
if (location != null) {
|
||||
location = null;
|
||||
}
|
||||
if (jsonObject != null) {
|
||||
jsonObject = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置buffer
|
||||
*/
|
||||
public void resetBuffer() {
|
||||
if (udpConstract != null) {
|
||||
udpConstract.resetBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化webSocket
|
||||
@@ -438,7 +335,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
e.printStackTrace();
|
||||
}
|
||||
// TODO 临时接续Json数据传递添加的Header 0x00表示PB数据 0x01表示Json数据
|
||||
if (!isClient && onMultiDeviceListener != null) {
|
||||
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);
|
||||
@@ -459,7 +356,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
return;
|
||||
}
|
||||
//TODO 临时将Json数据转发并解析 0x00表示PB数据 0x01表示Json数据
|
||||
if (isClient) {
|
||||
if (adasOptions.isClient()) {
|
||||
byte header = bytes[0];
|
||||
byte[] temp = new byte[bytes.length - 1];
|
||||
System.arraycopy(bytes, 1, temp, 0, temp.length);
|
||||
@@ -491,10 +388,72 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdasOptions getAdasOptions() {
|
||||
return adasOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接工控机
|
||||
*/
|
||||
@Override
|
||||
public void connect() {
|
||||
//当是司机屏才启用
|
||||
if (!adasOptions.isClient()) {
|
||||
if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) {
|
||||
ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.SEARCH_ADDRESS;
|
||||
if (adasConnectStatusListener != null) {
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, null);
|
||||
}
|
||||
switch (adasOptions.getIpcConnectionMode()) {
|
||||
case AdasOptions.IPC_CONNECTION_MODE.FIXATION:
|
||||
if (mSocket != null) {
|
||||
mSocket.setIsReconnect(true);
|
||||
}
|
||||
ipcFixationIPHelper(adasOptions.getIpcFixationIP());
|
||||
break;
|
||||
case AdasOptions.IPC_CONNECTION_MODE.ASSIGN:
|
||||
if (mSocket != null) {
|
||||
mSocket.setIsReconnect(true);
|
||||
}
|
||||
getOnConnectionAddress(adasOptions.getIpcAssignIP());
|
||||
break;
|
||||
case AdasOptions.IPC_CONNECTION_MODE.UDP:
|
||||
if (mSocket != null) {
|
||||
mSocket.setIsReconnect(false);
|
||||
}
|
||||
initUdpServer();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开与工控机的链接
|
||||
*/
|
||||
@Override
|
||||
public void disconnect() {
|
||||
if (!adasOptions.isClient()) {
|
||||
// ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.DISCONNECTED;
|
||||
// if (adasConnectStatusListener != null) {
|
||||
// adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, null);
|
||||
// }
|
||||
if (udpConstract != null)
|
||||
udpConstract.release();
|
||||
if (mSocket != null)
|
||||
mSocket.closeWebSocket();
|
||||
if (isUseQueue) {
|
||||
UdpQueueManager.getInstance().release();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handlerWSMsg(ByteString bytes) {
|
||||
byte[] bytes1 = bytes.toByteArray();
|
||||
parseIPCData(bytes1);
|
||||
if (!isClient && onMultiDeviceListener != null) {
|
||||
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);
|
||||
@@ -505,22 +464,28 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectSuccess(WebSocket webSocket) {
|
||||
isConnected = true;
|
||||
CupidLogUtils.e("--->onWebSocketConnectSuccess");
|
||||
if (mAdasMsgConnectStatusListener != null) {
|
||||
mAdasMsgConnectStatusListener.onWebSocketConnectSuccess();
|
||||
public void onConnecting() {
|
||||
ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.CONNECTING;
|
||||
if (adasConnectStatusListener != null) {
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectSuccess() {
|
||||
ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.CONNECTED;
|
||||
if (adasConnectStatusListener != null) {
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, null);
|
||||
queryCarConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectFailed(WebSocket webSocket, String t) {
|
||||
isConnected = false;
|
||||
CupidLogUtils.e("--->onWebSocketConnectFailed");
|
||||
public void onWebSocketConnectFailed(String t) {
|
||||
ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.DISCONNECTED;
|
||||
setUdpIsFirstInit();
|
||||
if (mAdasMsgConnectStatusListener != null) {
|
||||
mAdasMsgConnectStatusListener.onWebSocketConnectFailed(t);
|
||||
if (adasConnectStatusListener != null) {
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,20 +517,20 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
|
||||
@Override
|
||||
public void getOnConnectionAddress(String address) {
|
||||
ipcIp = address;
|
||||
CupidLogUtils.e(TAG, "--->getOnConnectionAddress" + address);
|
||||
CupidLogUtils.e(TAG, "要连接的工控机IP=" + address);
|
||||
if (TextUtils.isEmpty(address)) {
|
||||
if (mSocket != null) {
|
||||
mSocket.setIsReconnect(false);
|
||||
}
|
||||
if (adasConnectStatusListener != null) {
|
||||
ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.NOT_FOUND_ADDRESS;
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, "找不到可用的IP");
|
||||
}
|
||||
return;
|
||||
}
|
||||
ipcConnectedIP = address;
|
||||
AppPreferenceHelper.getInstance(MgContextUtils.getContext()).saveUdpClientAddress(address);
|
||||
connectSocket(address);
|
||||
if (flag) {
|
||||
flag = false;
|
||||
if (configInfo != null && configInfo.size() > 0) {
|
||||
if (isConnected) {
|
||||
if (mSocket != null)
|
||||
mSocket.doConfigChanged(configInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -593,9 +558,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
*/
|
||||
public void udpDataManage(String content) {
|
||||
if (!TextUtils.isEmpty(content)) {
|
||||
if (gson == null) {
|
||||
gson = new Gson();
|
||||
}
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(content);
|
||||
String udpRenderAction = jsonObject.getString("action");
|
||||
@@ -613,14 +575,14 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
|
||||
private OnAdasListener mAdasListener;
|
||||
//连接状态listener
|
||||
private OnAdasMsgConnectStatusListener mAdasMsgConnectStatusListener;
|
||||
private OnAdasConnectStatusListener adasConnectStatusListener;
|
||||
|
||||
void setOnAdasListener(OnAdasListener adasListener) {
|
||||
mAdasListener = adasListener;
|
||||
}
|
||||
|
||||
void setOnAdasMsgConnectStatusListener(OnAdasMsgConnectStatusListener adasMsgConnectStatusListener) {
|
||||
mAdasMsgConnectStatusListener = adasMsgConnectStatusListener;
|
||||
void setOnAdasMsgConnectStatusListener(OnAdasConnectStatusListener adasMsgConnectStatusListener) {
|
||||
adasConnectStatusListener = adasMsgConnectStatusListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -644,8 +606,8 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSocketConnect() {
|
||||
return mSocket != null && mSocket.getWebSocket() != null;
|
||||
public int getIpcConnectionStatus() {
|
||||
return ipcConnectionStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -787,5 +749,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
CupidLogUtils.setIsWriteLog(isWriteLog);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,10 @@ import android.content.Context;
|
||||
import com.zhidao.support.adas.high.bean.AdasConfig;
|
||||
import com.zhidao.support.adas.high.bean.BaseInfo;
|
||||
import com.zhidao.support.adas.high.bean.BasicInfo;
|
||||
import com.zhidao.support.adas.high.bean.ConfigInfo;
|
||||
import com.zhidao.support.adas.high.bean.MapLocationInfo;
|
||||
import com.zhidao.support.adas.high.common.AppPreferenceHelper;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
@@ -23,10 +25,6 @@ import com.zhidao.support.adas.high.bean.MapLocationInfo;
|
||||
public class AdasManager implements IAdasNetCommApi {
|
||||
private static volatile AdasManager ourInstance;
|
||||
|
||||
public void init(Context context) {
|
||||
//登录信息,空默认配置
|
||||
|
||||
}
|
||||
|
||||
public static AdasManager getInstance() {
|
||||
if (ourInstance == null) {
|
||||
@@ -62,7 +60,7 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
*
|
||||
* @param onAdasConnectStatusListener
|
||||
*/
|
||||
public void setOnAdasConnectStatusListener(OnAdasMsgConnectStatusListener onAdasConnectStatusListener) {
|
||||
public void setOnAdasConnectStatusListener(OnAdasConnectStatusListener onAdasConnectStatusListener) {
|
||||
if (mChannel != null) {
|
||||
mChannel.setOnAdasMsgConnectStatusListener(onAdasConnectStatusListener);
|
||||
}
|
||||
@@ -75,38 +73,6 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
}
|
||||
|
||||
|
||||
public void pause() {
|
||||
if (mChannel != null) {
|
||||
mChannel.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
public void resume() {
|
||||
if (mChannel != null) {
|
||||
mChannel.onResume();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void destory() {
|
||||
if (mChannel != null) {
|
||||
mChannel.onDisconnectRtp();
|
||||
mChannel.onPause();
|
||||
mChannel.onDestory();
|
||||
mChannel = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送速度信息
|
||||
*
|
||||
* @param mapLocationInfo
|
||||
*/
|
||||
public void sendMapLocation(MapLocationInfo mapLocationInfo) {
|
||||
if (mChannel != null) {
|
||||
mChannel.sendLocation(mapLocationInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送信息
|
||||
*
|
||||
@@ -129,44 +95,31 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送配置信息
|
||||
*
|
||||
* @param configMsg
|
||||
*/
|
||||
public void setConfigMsg(ConfigInfo configMsg) {
|
||||
|
||||
|
||||
public synchronized void destory() {
|
||||
if (mChannel != null) {
|
||||
mChannel.sendWsConfigMessage(configMsg);
|
||||
mChannel.onDisconnectRtp();
|
||||
mChannel.disconnect();
|
||||
mChannel = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭socket连接
|
||||
*/
|
||||
public void closeSocket() {
|
||||
|
||||
@Override
|
||||
public void connect() {
|
||||
if (mChannel != null) {
|
||||
mChannel.closeSocket();
|
||||
mChannel.connect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭所有通信
|
||||
*/
|
||||
public void closeAllMsg() {
|
||||
@Override
|
||||
public void disconnect() {
|
||||
if (mChannel != null) {
|
||||
mChannel.closeSocket();
|
||||
mChannel.disconnect();
|
||||
}
|
||||
pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动所有的通信
|
||||
*/
|
||||
public void startAllMsg() {
|
||||
resume();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean controlAutopilotCarAuto() {
|
||||
if (mChannel != null) {
|
||||
@@ -184,11 +137,11 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSocketConnect() {
|
||||
public int getIpcConnectionStatus() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.isSocketConnect();
|
||||
return mChannel.getIpcConnectionStatus();
|
||||
}
|
||||
return false;
|
||||
return Constants.IPC_CONNECTION_STATUS.DISCONNECTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -196,7 +149,7 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
if (mChannel != null) {
|
||||
return mChannel.getAdasConfig();
|
||||
}
|
||||
return null;
|
||||
return new AdasConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,12 +235,6 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIPCIp(String ipAddr) {
|
||||
if (mChannel != null) {
|
||||
mChannel.setIPCIp(ipAddr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向工控机发送数据
|
||||
@@ -330,10 +277,14 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClient() {
|
||||
return mChannel == null || mChannel.isClient();
|
||||
public AdasOptions getAdasOptions() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.getAdasOptions();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void enableDemoMode() {
|
||||
if (mChannel != null) {
|
||||
@@ -347,4 +298,48 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
mChannel.disableDemoMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIPCConnectedIP() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.getIPCConnectedIP();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工控机固定IP列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public HashSet<String> getIPCFixationIPList(Context context) {
|
||||
return AppPreferenceHelper.getInstance(context).getIPCFixationIPList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加工控机固定IP
|
||||
*
|
||||
* @param ipcIP
|
||||
*/
|
||||
public void addIPCFixationIP(Context context, String ipcIP) {
|
||||
AppPreferenceHelper.getInstance(context).addIPCFixationIP(ipcIP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定的工控机固定IP
|
||||
*
|
||||
* @param ipcIP
|
||||
*/
|
||||
public void delIPCFixationIP(Context context, String ipcIP) {
|
||||
AppPreferenceHelper.getInstance(context).delIPCFixationIP(ipcIP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除所有工控机固定IP
|
||||
*/
|
||||
public void delIPCFixationIP(Context context) {
|
||||
AppPreferenceHelper.getInstance(context).delIPCFixationIP();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,51 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Date:2019/5/31。
|
||||
* Note: Adas相关配置。
|
||||
* 更换链接方式必须先断开与工控机的连接
|
||||
*/
|
||||
public class AdasOptions {
|
||||
/**
|
||||
* 链接方式
|
||||
*/
|
||||
public interface IPC_CONNECTION_MODE {
|
||||
/**
|
||||
* 固定IP 根据存储的IP进行轮询
|
||||
*/
|
||||
int FIXATION = 0;
|
||||
|
||||
/**
|
||||
* 指定IP
|
||||
*/
|
||||
int ASSIGN = 1;
|
||||
/**
|
||||
* UDP方式
|
||||
*/
|
||||
int UDP = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是客户端
|
||||
* 是否是客户端 true:客户度(乘客屏) false:服务端(司机屏)
|
||||
* 当是乘客端的情况下 ipcConnectionMode ipcAssignIP ipcFixationIPSet 均无效
|
||||
*/
|
||||
private boolean isClient;
|
||||
|
||||
/**
|
||||
* 工控机IP
|
||||
* 链接工控机方式
|
||||
* 如果是司机屏默认 固定IP方式
|
||||
*/
|
||||
private String ipcIp;
|
||||
private int ipcConnectionMode = IPC_CONNECTION_MODE.FIXATION;
|
||||
/**
|
||||
* 指定工控机IP
|
||||
*/
|
||||
private String ipcAssignIP;
|
||||
/**
|
||||
* 工控机固定IP集合 通过Ping方式尝试
|
||||
*/
|
||||
private HashSet<String> ipcFixationIP;
|
||||
|
||||
private AdasOptions() {
|
||||
}
|
||||
@@ -48,14 +79,36 @@ public class AdasOptions {
|
||||
/**
|
||||
* 设置IPC主机地址
|
||||
*
|
||||
* @param ipcIp
|
||||
* @param ipcAssignIP
|
||||
* @return
|
||||
*/
|
||||
public Builder setIPCIp(String ipcIp) {
|
||||
options.ipcIp = ipcIp;
|
||||
public Builder setIpcAssignIP(String ipcAssignIP) {
|
||||
options.ipcAssignIP = ipcAssignIP;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置IPC 固定IP
|
||||
* 通过ping方式逐一检查连通性
|
||||
*
|
||||
* @param ipcFixationIP
|
||||
* @return
|
||||
*/
|
||||
public Builder setIpcFixationIP(HashSet<String> ipcFixationIP) {
|
||||
options.ipcFixationIP = ipcFixationIP;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置连接方式
|
||||
*
|
||||
* @param ipcConnectionMode
|
||||
* @return
|
||||
*/
|
||||
public Builder setIpcConnectionMode(int ipcConnectionMode) {
|
||||
options.ipcConnectionMode = ipcConnectionMode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public AdasOptions build() {
|
||||
return options;
|
||||
@@ -64,13 +117,15 @@ public class AdasOptions {
|
||||
|
||||
/**
|
||||
* 获取默认的配置
|
||||
* 默认配置是乘客端
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static AdasOptions getDefaultOptions() {
|
||||
AdasOptions options = new AdasOptions();
|
||||
options.isClient = true;
|
||||
options.ipcIp = null;
|
||||
options.ipcAssignIP = null;
|
||||
options.ipcFixationIP = null;
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -78,7 +133,31 @@ public class AdasOptions {
|
||||
return isClient;
|
||||
}
|
||||
|
||||
public String getIpcIp() {
|
||||
return ipcIp;
|
||||
public String getIpcAssignIP() {
|
||||
return ipcAssignIP;
|
||||
}
|
||||
|
||||
public int getIpcConnectionMode() {
|
||||
return ipcConnectionMode;
|
||||
}
|
||||
|
||||
public HashSet<String> getIpcFixationIP() {
|
||||
return ipcFixationIP;
|
||||
}
|
||||
|
||||
public void setIpcAssignIP(String ipcAssignIP) {
|
||||
this.ipcAssignIP = ipcAssignIP;
|
||||
}
|
||||
|
||||
public void setClient(boolean client) {
|
||||
isClient = client;
|
||||
}
|
||||
|
||||
public void setIpcConnectionMode(int ipcConnectionMode) {
|
||||
this.ipcConnectionMode = ipcConnectionMode;
|
||||
}
|
||||
|
||||
public void setIpcFixationIP(HashSet<String> ipcFixationIP) {
|
||||
this.ipcFixationIP = ipcFixationIP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,16 @@ import com.zhidao.support.adas.high.bean.BaseInfo;
|
||||
* @date 2020/7/14
|
||||
*/
|
||||
public interface IAdasNetCommApi {
|
||||
/**
|
||||
* 链接工控机
|
||||
*/
|
||||
void connect();
|
||||
|
||||
/**
|
||||
* 与工控机断开连接
|
||||
*/
|
||||
void disconnect();
|
||||
|
||||
/**
|
||||
* 控制自动驾驶车辆 自动模式 自动驾驶
|
||||
*/
|
||||
@@ -20,11 +30,11 @@ public interface IAdasNetCommApi {
|
||||
boolean controlAutopilotCarHead();
|
||||
|
||||
/**
|
||||
* socket 是否连接状态
|
||||
* 获取当前工控机的链接状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isSocketConnect();
|
||||
int getIpcConnectionStatus();
|
||||
|
||||
/**
|
||||
* 基础信息
|
||||
@@ -91,12 +101,6 @@ public interface IAdasNetCommApi {
|
||||
*/
|
||||
void setIsWriteLog(boolean isWriteLog);
|
||||
|
||||
/**
|
||||
* 设置工控机IP 如设置IP将不会执行自动搜索方式链接
|
||||
*
|
||||
* @param ipAddr
|
||||
*/
|
||||
void setIPCIp(String ipAddr);
|
||||
|
||||
/**
|
||||
* 向工控机发送数据
|
||||
@@ -128,11 +132,11 @@ public interface IAdasNetCommApi {
|
||||
void parseIPCData(byte[] bytes);
|
||||
|
||||
/**
|
||||
* 是否是客户端
|
||||
* 获取工控机链接配置
|
||||
*
|
||||
* @return true:客户度 false:服务端
|
||||
* @return
|
||||
*/
|
||||
boolean isClient();
|
||||
AdasOptions getAdasOptions();
|
||||
|
||||
/**
|
||||
* 打开演示模式
|
||||
@@ -143,4 +147,11 @@ public interface IAdasNetCommApi {
|
||||
* 关闭演示模式
|
||||
*/
|
||||
void disableDemoMode();
|
||||
|
||||
/**
|
||||
* 获取已经链接成功的工控机IP 未连接未null
|
||||
*
|
||||
* @return ip null:表示未连接
|
||||
*/
|
||||
String getIPCConnectedIP();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.zhidao.support.adas.high.common.Define;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 消息通信连接状态 回掉
|
||||
* @date 2020/3/20
|
||||
*/
|
||||
public interface OnAdasConnectStatusListener {
|
||||
/**
|
||||
* 指定IP或固定IP(轮询ping集合中的IP) 找不到可用的IP时会被调用
|
||||
* 规则: TextUtils.isEmpty()
|
||||
*/
|
||||
// void onAddressDisabled();
|
||||
|
||||
/**
|
||||
* 与工控机链接状态变化
|
||||
*
|
||||
* @param ipcConnectionStatus
|
||||
*/
|
||||
void onConnectionIPCStatus(@Define.IPCConnectionStatus int ipcConnectionStatus, String failedMsg);
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 消息通信连接状态 回掉
|
||||
* @date 2020/3/20
|
||||
*/
|
||||
public interface OnAdasMsgConnectStatusListener {
|
||||
/**
|
||||
* ws 连接成功
|
||||
*/
|
||||
void onWebSocketConnectSuccess();
|
||||
|
||||
/**
|
||||
* ws 连接失败
|
||||
*/
|
||||
void onWebSocketConnectFailed(String t);
|
||||
}
|
||||
@@ -1,129 +0,0 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 配置信息
|
||||
* json 摄像头类型 enum "0=小霸王 1=汇影"
|
||||
* 车型 enum "0=小轿车 1=SUV 2=中巴车 3=大巴车 4=大货车"
|
||||
* 安装高度 float 1.2~1.5米
|
||||
* FCW报警等级 enum "0=关闭 1=近距离报警(不敏感) 2=远距离报警(敏感)"
|
||||
* LDW报警等级 enum "0=关闭 1=打开"
|
||||
* Stop&Go提醒等级 enum "0=关闭 1=打开"
|
||||
* 自动驾驶状态 enum "0=人工驾驶 1=自动驾驶"
|
||||
* 车辆速度 float 0~130km/h
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class ConfigInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* action : config
|
||||
* values : {"camera":0,"vehicle_type":"car","height":1.2,"fcw":1,"ldw":1,"stop_go":0}
|
||||
*/
|
||||
|
||||
private String action;
|
||||
private ValuesBean values;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ValuesBean getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(ValuesBean values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConfigInfo{" +
|
||||
"action='" + action + '\'' +
|
||||
", values=" + values +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
/**
|
||||
* camera : 0
|
||||
* vehicle_type : car
|
||||
* height : 1.2
|
||||
* fcw : 1
|
||||
* ldw : 1
|
||||
* stop_go : 0
|
||||
*/
|
||||
|
||||
private int camera;
|
||||
private String vehicle_type;
|
||||
private double height;
|
||||
private int fcw;
|
||||
private int ldw;
|
||||
private int stop_go;
|
||||
|
||||
public int getCamera() {
|
||||
return camera;
|
||||
}
|
||||
|
||||
public void setCamera(int camera) {
|
||||
this.camera = camera;
|
||||
}
|
||||
|
||||
public String getVehicle_type() {
|
||||
return vehicle_type;
|
||||
}
|
||||
|
||||
public void setVehicle_type(String vehicle_type) {
|
||||
this.vehicle_type = vehicle_type;
|
||||
}
|
||||
|
||||
public double getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(double height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getFcw() {
|
||||
return fcw;
|
||||
}
|
||||
|
||||
public void setFcw(int fcw) {
|
||||
this.fcw = fcw;
|
||||
}
|
||||
|
||||
public int getLdw() {
|
||||
return ldw;
|
||||
}
|
||||
|
||||
public void setLdw(int ldw) {
|
||||
this.ldw = ldw;
|
||||
}
|
||||
|
||||
public int getStop_go() {
|
||||
return stop_go;
|
||||
}
|
||||
|
||||
public void setStop_go(int stop_go) {
|
||||
this.stop_go = stop_go;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValuesBean{" +
|
||||
"camera=" + camera +
|
||||
", vehicle_type='" + vehicle_type + '\'' +
|
||||
", height=" + height +
|
||||
", fcw=" + fcw +
|
||||
", ldw=" + ldw +
|
||||
", stop_go=" + stop_go +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,110 +0,0 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high.bean
|
||||
* @ClassName: MapLocationInfo
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/9 14:32
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/9 14:32
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class MapLocationInfo implements Parcelable {
|
||||
//纬度
|
||||
private double latitude;
|
||||
//经度
|
||||
private double longitude;
|
||||
private float speed;
|
||||
private float bearing;
|
||||
|
||||
public MapLocationInfo() {
|
||||
}
|
||||
|
||||
public MapLocationInfo(double latitude, double longitude, float speed, float bearing) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
this.speed = speed;
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
|
||||
public void setLatitude(double latitude) {
|
||||
this.latitude = latitude;
|
||||
}
|
||||
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
public void setLongitude(double longitude) {
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(float speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public float getBearing() {
|
||||
return bearing;
|
||||
}
|
||||
|
||||
public void setBearing(float bearing) {
|
||||
this.bearing = bearing;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeDouble(this.latitude);
|
||||
dest.writeDouble(this.longitude);
|
||||
dest.writeFloat(this.speed);
|
||||
dest.writeFloat(this.bearing);
|
||||
}
|
||||
|
||||
protected MapLocationInfo(Parcel in) {
|
||||
this.latitude = in.readDouble();
|
||||
this.longitude = in.readDouble();
|
||||
this.speed = in.readFloat();
|
||||
this.bearing = in.readFloat();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<MapLocationInfo> CREATOR = new Parcelable.Creator<MapLocationInfo>() {
|
||||
@Override
|
||||
public MapLocationInfo createFromParcel(Parcel source) {
|
||||
return new MapLocationInfo(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapLocationInfo[] newArray(int size) {
|
||||
return new MapLocationInfo[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MapLocationInfo{" +
|
||||
"latitude=" + latitude +
|
||||
", longitude=" + longitude +
|
||||
", speed=" + speed +
|
||||
", bearing=" + bearing +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @description
|
||||
* @date 2018/9/6
|
||||
*/
|
||||
public class UserInfo implements Serializable {
|
||||
|
||||
private String userId;
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UserInfo{" +
|
||||
"userId='" + userId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -33,10 +33,6 @@ public enum ActionTypeReceive {
|
||||
* 红绿灯状态
|
||||
*/
|
||||
ACTION_UDP_LIGHT_STATE_TYPE("light", -1, "udp 红绿灯状态"),
|
||||
/**
|
||||
* gps数据
|
||||
*/
|
||||
ACTION_WS_GPS_TYPE("gdgps", -1, "gps 数据"),
|
||||
/**
|
||||
* 自动驾驶状态
|
||||
*/
|
||||
|
||||
@@ -2,19 +2,10 @@ package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.zhidao.support.adas.high.bean.FaceLoginResponse;
|
||||
import com.zhidao.support.adas.high.bean.UserInfo;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by nie yunlong on 2018/4/13.
|
||||
@@ -28,49 +19,19 @@ public class AppPreferenceHelper implements IPreferencesHelper {
|
||||
/**
|
||||
* 保存deviceId 文件名称
|
||||
*/
|
||||
private final String UDP_RECEIVER_ADDRESS_FILE_NAME = "upd_receive";
|
||||
private final String UDP_RECEIVER_ADDRESS_FILE_NAME = "upd_receive";
|
||||
|
||||
/**
|
||||
* 假的数据 share
|
||||
*/
|
||||
private final String FAKE_DATA_PRE_FILE_NAME = "data_fake";
|
||||
/**
|
||||
* 用户信息
|
||||
*/
|
||||
private final String USER_INFO_FILE_NAME = "user_info";
|
||||
|
||||
/**
|
||||
* 保存raw
|
||||
*/
|
||||
private final String CONFIG_RAW_FILE_NAME = "raw_config";
|
||||
|
||||
private final String USER_NAME = "user_name";
|
||||
|
||||
|
||||
private final String CONFIG_PRE_FILE_NAME = "config";
|
||||
|
||||
/**
|
||||
* 用户信息pre
|
||||
*/
|
||||
private final SharedPreferences mUserLoginInfoPre;
|
||||
/**
|
||||
* 假的数据share
|
||||
*/
|
||||
private final SharedPreferences mFakeDataPre;
|
||||
|
||||
private final SharedPreferences mRawConfigPre;
|
||||
/**
|
||||
* 手机Id
|
||||
*/
|
||||
private SharedPreferences mDevicePre;
|
||||
/**
|
||||
* 配置标志位
|
||||
*/
|
||||
private SharedPreferences mConfigPre;
|
||||
private SharedPreferences mDevicePre;
|
||||
|
||||
/**
|
||||
* 默认data
|
||||
*/
|
||||
private String defaultData = "{\"configInfoHistory\":[{\"kCode\":\"d_fcw_touch\",\"kName\":\"前车碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_fcw_start\",\"kName\":\"前车启动提醒\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hdw_driver\",\"kName\":\"驾驶员疲劳/危险预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_fcw_person\",\"kName\":\"行人碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hdw_sliding\",\"kName\":\"溜车碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_ldw_out\",\"kName\":\"车道线偏离预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hmw_follow\",\"kName\":\"跟车距离预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_volume_size\",\"kName\":\"音量大小\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"60\",\"userId\":0},{\"kCode\":\"is_use_ar_navBar\",\"kName\":\"是否使用AR导航\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0}]}";
|
||||
private String defaultData = "{\"configInfoHistory\":[{\"kCode\":\"d_fcw_touch\",\"kName\":\"前车碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_fcw_start\",\"kName\":\"前车启动提醒\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hdw_driver\",\"kName\":\"驾驶员疲劳/危险预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_fcw_person\",\"kName\":\"行人碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hdw_sliding\",\"kName\":\"溜车碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_ldw_out\",\"kName\":\"车道线偏离预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hmw_follow\",\"kName\":\"跟车距离预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_volume_size\",\"kName\":\"音量大小\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"60\",\"userId\":0},{\"kCode\":\"is_use_ar_navBar\",\"kName\":\"是否使用AR导航\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0}]}";
|
||||
|
||||
private HashSet<String> ipcFixationIPSet;//工控机固定IP列表
|
||||
|
||||
public static AppPreferenceHelper getInstance(Context context) {
|
||||
if (appPreferenceHelper == null) {
|
||||
@@ -81,10 +42,7 @@ public class AppPreferenceHelper implements IPreferencesHelper {
|
||||
|
||||
private AppPreferenceHelper(Context context) {
|
||||
mDevicePre = context.getSharedPreferences(UDP_RECEIVER_ADDRESS_FILE_NAME, Context.MODE_PRIVATE);
|
||||
mUserLoginInfoPre = context.getSharedPreferences(USER_INFO_FILE_NAME, Context.MODE_PRIVATE);
|
||||
mFakeDataPre = context.getSharedPreferences(FAKE_DATA_PRE_FILE_NAME, Context.MODE_PRIVATE);
|
||||
mRawConfigPre = context.getSharedPreferences(CONFIG_RAW_FILE_NAME, Context.MODE_PRIVATE);
|
||||
mConfigPre = context.getSharedPreferences(CONFIG_PRE_FILE_NAME, Context.MODE_PRIVATE);
|
||||
getIPCFixationIPList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,174 +65,38 @@ public class AppPreferenceHelper implements IPreferencesHelper {
|
||||
return mDevicePre.getString("dock_version", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserInfo(FaceLoginResponse.DataBean loginResponse) {
|
||||
|
||||
try {
|
||||
saveUser(mUserLoginInfoPre, "userInfo", loginResponse);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@Override
|
||||
public HashSet<String> getIPCFixationIPList() {
|
||||
if (ipcFixationIPSet == null || ipcFixationIPSet.isEmpty()) {
|
||||
String json = mDevicePre.getString("ipc_fixation_ip", Constants.DEFAULT_IPC_FIXATION_IP);
|
||||
ipcFixationIPSet = JsonUtil.fromJson(json, new TypeToken<HashSet<String>>() {
|
||||
}.getType());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public FaceLoginResponse.DataBean getUserInfo() {
|
||||
return getUser(mUserLoginInfoPre, "userInfo");
|
||||
return ipcFixationIPSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigNaviMapVis(int selectIndex) {
|
||||
mFakeDataPre.edit().putInt("selectIndex", selectIndex).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getConfigNaviMapVis() {
|
||||
return mFakeDataPre.getInt("selectIndex", 1);
|
||||
}
|
||||
|
||||
|
||||
private void saveUser(SharedPreferences sharedPreferences, String key, FaceLoginResponse.DataBean user) throws Exception {
|
||||
if (user instanceof Serializable) {
|
||||
SharedPreferences.Editor editor = sharedPreferences.edit();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
//把对象写到流里
|
||||
oos.writeObject(user);
|
||||
String temp = new String(Base64.encode(baos.toByteArray(), Base64.DEFAULT));
|
||||
editor.putString(key, temp);
|
||||
editor.commit();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
throw new Exception("User must implements Serializable");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private FaceLoginResponse.DataBean getUser(SharedPreferences sharedPreferences, String key) {
|
||||
String temp = sharedPreferences.getString(key, "");
|
||||
FaceLoginResponse.DataBean user = null;
|
||||
try {
|
||||
if (!TextUtils.isEmpty(temp)) {
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(temp.getBytes(), Base64.DEFAULT));
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
user = (FaceLoginResponse.DataBean) ois.readObject();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (ClassNotFoundException e1) {
|
||||
|
||||
}
|
||||
try {
|
||||
if (user == null) {
|
||||
//是空的 使用默认的配置
|
||||
Gson gson = new Gson();
|
||||
FaceLoginResponse.DataBean dataConfig = gson.fromJson(defaultData, FaceLoginResponse.DataBean.class);
|
||||
|
||||
saveUser(mUserLoginInfoPre, "userInfo", dataConfig);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveUserUnInfo(UserInfo userInfo) {
|
||||
if (userInfo == null) {
|
||||
userInfo = new UserInfo();
|
||||
}
|
||||
if (userInfo instanceof Serializable) {
|
||||
SharedPreferences.Editor editor = mUserLoginInfoPre.edit();
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
try {
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
//把对象写到流里
|
||||
oos.writeObject(userInfo);
|
||||
String temp = new String(Base64.encode(baos.toByteArray(), Base64.DEFAULT));
|
||||
editor.putString("userInfoId", temp);
|
||||
editor.apply();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public void addIPCFixationIP(String ipcIP) {
|
||||
if (ipcFixationIPSet == null)
|
||||
ipcFixationIPSet = new HashSet<>();
|
||||
if (!ipcFixationIPSet.contains(ipcIP)) {
|
||||
ipcFixationIPSet.add(ipcIP);
|
||||
mDevicePre.edit().putString("ipc_fixation_ip", JsonUtil.toJson(ipcFixationIPSet)).apply();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo getUserUnInfo() {
|
||||
String temp = mUserLoginInfoPre.getString("userInfoId", "");
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(Base64.decode(temp.getBytes(), Base64.DEFAULT));
|
||||
UserInfo user = null;
|
||||
try {
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
user = (UserInfo) ois.readObject();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
public void delIPCFixationIP(String ipcIP) {
|
||||
if (ipcFixationIPSet != null && ipcFixationIPSet.contains(ipcIP)) {
|
||||
ipcFixationIPSet.remove(ipcIP);
|
||||
mDevicePre.edit().putString("ipc_fixation_ip", JsonUtil.toJson(ipcFixationIPSet)).apply();
|
||||
}
|
||||
if (user == null) {
|
||||
user = new UserInfo();
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigInitResutl(boolean flag) {
|
||||
mConfigPre.edit().putBoolean("configInit", flag).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getConfigInitResutl() {
|
||||
return mConfigPre.getBoolean("configInit", false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelectCarInfo(String brand, String model, String style) {
|
||||
mConfigPre.edit().putString("brand", brand).putString("model", model).putString("style", style).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelectBrand() {
|
||||
return mConfigPre.getString("brand", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelectModel() {
|
||||
return mConfigPre.getString("model", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSelectStyle() {
|
||||
return mConfigPre.getString("style", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void saveRawPath(int rawName, String rawPath) {
|
||||
|
||||
mRawConfigPre.edit().putString("" + rawName, rawPath).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRawPath(int rawName) {
|
||||
return mRawConfigPre.getString("" + rawName, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearRawConfig(int rawName) {
|
||||
mRawConfigPre.edit().putString("" + rawName, "").apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAppAttachTime(long time) {
|
||||
mRawConfigPre.edit().putLong("appAttachTime", time).commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAppAttachTime() {
|
||||
return mRawConfigPre.getLong("appAttachTime", 3000);
|
||||
public void delIPCFixationIP() {
|
||||
mDevicePre.edit().remove("ipc_fixation_ip").apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,6 @@ public class Constants {
|
||||
* ws 端口以及资源名称
|
||||
*/
|
||||
public static final String WS_PORT = ":4110/xvideo-detector";
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
public static final String WS_PORT_=":4110";
|
||||
|
||||
/**
|
||||
* 发送位置信息 action
|
||||
@@ -49,4 +45,30 @@ public class Constants {
|
||||
* 查询轨迹
|
||||
*/
|
||||
public static final String QUERY_ROUTES = "{\"action\":\"query_routes\",\"result\":null}";
|
||||
|
||||
|
||||
public static final String DEFAULT_IPC_FIXATION_IP = "[\"192.168.1.102\", \"192.168.8.102\"]";
|
||||
|
||||
public interface IPC_CONNECTION_STATUS {
|
||||
/**
|
||||
* 已连接
|
||||
*/
|
||||
int CONNECTED = 0x00;
|
||||
/**
|
||||
* 未连接
|
||||
*/
|
||||
int DISCONNECTED = 0x01;
|
||||
/**
|
||||
* 正在连接
|
||||
*/
|
||||
int CONNECTING = 0x02;
|
||||
/**
|
||||
* 正在搜索IP
|
||||
*/
|
||||
int SEARCH_ADDRESS = 0x03;
|
||||
/**
|
||||
* 找不到可用IP 传入的IP不可用或固定IP列表中所有IP不可用
|
||||
*/
|
||||
int NOT_FOUND_ADDRESS = 0x04;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public final class Define {
|
||||
|
||||
@IntDef(flag = true, value = {Constants.IPC_CONNECTION_STATUS.CONNECTED,
|
||||
Constants.IPC_CONNECTION_STATUS.DISCONNECTED,
|
||||
Constants.IPC_CONNECTION_STATUS.CONNECTING,
|
||||
Constants.IPC_CONNECTION_STATUS.SEARCH_ADDRESS,
|
||||
Constants.IPC_CONNECTION_STATUS.NOT_FOUND_ADDRESS})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface IPCConnectionStatus {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* 工控机固定IP查询
|
||||
*/
|
||||
public class IPCFixationIPHelper {
|
||||
private static final String TAG = IPCFixationIPHelper.class.getSimpleName();
|
||||
private final IIPCFixationIPListener listener;
|
||||
private final List<Future> futures = new ArrayList<>();
|
||||
private volatile boolean isCallListener = false;//是否已经调用了回调
|
||||
private volatile int unavailableCount = 0;//不可用IP个数
|
||||
private volatile int queryCount;//要查询的IP个数
|
||||
private Timer retryTimer;
|
||||
|
||||
public IPCFixationIPHelper(IIPCFixationIPListener listener) {
|
||||
if (listener == null)
|
||||
throw new RuntimeException("工控机固定IP查询回调不能为空");
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public interface IIPCFixationIPListener {
|
||||
/**
|
||||
* 开始查找可用IP
|
||||
*/
|
||||
void onStartFindIP();
|
||||
|
||||
/**
|
||||
* 轮询结果可连通的IP
|
||||
*
|
||||
* @param ip 返回可用IP 当为null时表示无可用IP
|
||||
*/
|
||||
void onAvailableIP(String ip);
|
||||
}
|
||||
|
||||
private void interrupted() {
|
||||
if (!futures.isEmpty()) {
|
||||
for (Future future : futures) {
|
||||
if (!future.isCancelled()) {
|
||||
future.cancel(true);
|
||||
}
|
||||
}
|
||||
futures.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始根据固定IP列表惊醒PING 方式查找可用工控机
|
||||
*/
|
||||
public void start(final HashSet<String> ips) {
|
||||
listener.onStartFindIP();
|
||||
if (retryTimer != null) {
|
||||
retryTimer.cancel();
|
||||
retryTimer = null;
|
||||
}
|
||||
if (ips == null || ips.isEmpty()) {
|
||||
listener.onAvailableIP(null);
|
||||
} else {
|
||||
interrupted();
|
||||
queryCount = ips.size();
|
||||
unavailableCount = 0;
|
||||
isCallListener = false;
|
||||
for (final String temp : ips) {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CupidLogUtils.i(TAG, "ip=" + temp);
|
||||
boolean isAvailable = ping(temp);
|
||||
if (isAvailable) {
|
||||
if (!isCallListener && !Thread.currentThread().isInterrupted()) {
|
||||
isCallListener = true;
|
||||
listener.onAvailableIP(temp);
|
||||
CupidLogUtils.i(TAG, "可用IP=" + temp);
|
||||
interrupted();
|
||||
}
|
||||
} else {
|
||||
allNotAvailable(ips);
|
||||
}
|
||||
}
|
||||
};
|
||||
Future future = ThreadPoolManager.getsInstance().submit(runnable);
|
||||
futures.add(future);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void allNotAvailable(final HashSet<String> ips) {
|
||||
unavailableCount++;
|
||||
CupidLogUtils.i(TAG, "unavailableCount=" + unavailableCount);
|
||||
if (queryCount == unavailableCount) {
|
||||
if (!isCallListener) {
|
||||
isCallListener = true;
|
||||
listener.onAvailableIP(null);
|
||||
CupidLogUtils.i(TAG, "所有IP均不可用");
|
||||
//当配置中的所有IP都ping不通时,需要继续ping
|
||||
if (retryTimer == null) {
|
||||
retryTimer = new Timer();
|
||||
retryTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
start(ips);
|
||||
}
|
||||
}, 5 * 1000L);//延时
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean ping(String str) {
|
||||
String resault;
|
||||
Process p;
|
||||
try {
|
||||
//ping -c 3 -w 100 中 ,-c 是指ping的次数 3是指ping 3次 ,-w 100 以秒为单位指定超时间隔,是指超时时间为100秒
|
||||
p = Runtime.getRuntime().exec("ping -c 2 -w 5 " + str);
|
||||
int status = p.waitFor();
|
||||
InputStream input = p.getInputStream();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(input));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
builder.append(line).append("\n");
|
||||
}
|
||||
if (status == 0) {
|
||||
resault = "是";
|
||||
} else {
|
||||
resault = "否";
|
||||
}
|
||||
builder.append("工控机IP:").append(str).append(" 是否可以连通:").append(resault);
|
||||
CupidLogUtils.i(TAG, builder.toString());
|
||||
return status == 0;
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
|
||||
import com.zhidao.support.adas.high.bean.FaceLoginResponse;
|
||||
import com.zhidao.support.adas.high.bean.UserInfo;
|
||||
import java.util.HashSet;
|
||||
|
||||
/**
|
||||
* Created by nie yunlong on 2018/4/13.
|
||||
@@ -37,99 +36,33 @@ public interface IPreferencesHelper {
|
||||
*/
|
||||
String getDockConfig();
|
||||
|
||||
/**
|
||||
* 设置用户信息
|
||||
*
|
||||
* @param loginResponse
|
||||
*/
|
||||
void setUserInfo(FaceLoginResponse.DataBean loginResponse);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* 获取工控机固定IP列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
FaceLoginResponse.DataBean getUserInfo();
|
||||
HashSet<String> getIPCFixationIPList();
|
||||
|
||||
/**
|
||||
* 假的 以后干掉
|
||||
* 增加工控机固定IP
|
||||
*
|
||||
* @param selectIndex
|
||||
* @param ipcIP
|
||||
*/
|
||||
void setConfigNaviMapVis(int selectIndex);
|
||||
void addIPCFixationIP(String ipcIP);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
int getConfigNaviMapVis();
|
||||
|
||||
/**
|
||||
* @param userInfo
|
||||
*/
|
||||
void saveUserUnInfo(UserInfo userInfo);
|
||||
|
||||
/**
|
||||
* 用户ID userInfo 用于扩展
|
||||
* 删除指定的工控机固定IP
|
||||
*
|
||||
* @return
|
||||
* @param ipcIP
|
||||
*/
|
||||
UserInfo getUserUnInfo();
|
||||
|
||||
void delIPCFixationIP(String ipcIP);
|
||||
|
||||
/**
|
||||
* 初始化标志位
|
||||
*
|
||||
* @param flag
|
||||
* 删除所有工控机固定IP
|
||||
*/
|
||||
void setConfigInitResutl(boolean flag);
|
||||
|
||||
/**
|
||||
* 初始化标志位
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean getConfigInitResutl();
|
||||
|
||||
|
||||
|
||||
void setSelectCarInfo(String brand, String model, String style);
|
||||
|
||||
String getSelectBrand();
|
||||
|
||||
String getSelectModel();
|
||||
|
||||
String getSelectStyle();
|
||||
|
||||
|
||||
/**
|
||||
* raw
|
||||
*
|
||||
* @param rawPath
|
||||
*/
|
||||
void saveRawPath(int rawName, String rawPath);
|
||||
|
||||
/**
|
||||
* @param rawName
|
||||
* @return
|
||||
*/
|
||||
String getRawPath(int rawName);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void clearRawConfig(int rawName);
|
||||
|
||||
/**
|
||||
* app 启动开始时间
|
||||
*
|
||||
* @param time
|
||||
*/
|
||||
void setAppAttachTime(long time);
|
||||
|
||||
/**
|
||||
* 获取
|
||||
* @return
|
||||
*/
|
||||
long getAppAttachTime();
|
||||
void delIPCFixationIP();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Java对象和JSON字符串相互转化工具类
|
||||
* 格式化
|
||||
*
|
||||
* @author xfk
|
||||
*/
|
||||
public final class JsonUtil {
|
||||
|
||||
|
||||
/**
|
||||
* 对象转换成json字符串
|
||||
*
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
public static String toJson(Object obj) {
|
||||
|
||||
return toJson(false, obj);
|
||||
}
|
||||
|
||||
public static String toJson(boolean isSerializeNulls, Object obj) {
|
||||
Gson gson;
|
||||
if (isSerializeNulls) {
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
gsonBuilder.serializeNulls(); //重点
|
||||
gson = gsonBuilder.create();
|
||||
} else {
|
||||
gson = new Gson();
|
||||
}
|
||||
return gson.toJson(obj);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* json字符串转成对象
|
||||
*
|
||||
* @param str
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static <T> T fromJson(String str, Type type) {
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(str, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* json字符串转成对象
|
||||
*
|
||||
* @param str
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public static <T> T fromJson(String str, Class<T> type) {
|
||||
Gson gson = new Gson();
|
||||
return gson.fromJson(str, type);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.jcraft.jsch.ChannelExec;
|
||||
import com.jcraft.jsch.JSch;
|
||||
@@ -55,9 +54,9 @@ public class SSH {
|
||||
Properties config = new Properties();
|
||||
config.put("StrictHostKeyChecking", "no");
|
||||
session.setConfig(config);
|
||||
session.setTimeout(30000);
|
||||
session.setTimeout(10000);
|
||||
session.connect();
|
||||
Log.i(TAG, "Connected to " + host + ".");
|
||||
CupidLogUtils.i(TAG, "Connected to " + host + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,7 +77,7 @@ public class SSH {
|
||||
session.setConfig(config);
|
||||
session.setTimeout(30000);
|
||||
session.connect();
|
||||
Log.i(TAG, "Connected to " + host + ".");
|
||||
CupidLogUtils.i(TAG, "Connected to " + host + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,6 +112,31 @@ public class ThreadPoolManager<T> {
|
||||
return executor.submit(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个无返回结果的线程
|
||||
*
|
||||
* @param r
|
||||
*/
|
||||
public Future submit(Runnable r) {
|
||||
if (executor == null) {
|
||||
/**
|
||||
* corePoolSize:核心线程数
|
||||
* maximumPoolSize:线程池所容纳最大线程数(workQueue队列满了之后才开启)
|
||||
* keepAliveTime:非核心线程闲置时间超时时长
|
||||
* unit:keepAliveTime的单位
|
||||
* workQueue:等待队列,存储还未执行的任务
|
||||
* threadFactory:线程创建的工厂
|
||||
* handler:异常处理机制
|
||||
*
|
||||
*/
|
||||
executor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE,
|
||||
KEEP_ALIVE, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(200),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
return executor.submit(r);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 把任务移除等待队列
|
||||
*
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotSnRequest;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
/**
|
||||
* 自动驾驶路径
|
||||
|
||||
@@ -3,9 +3,7 @@ package com.zhidao.support.adas.high.msg;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotTrajectory;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.TrajectoryInfo;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
@@ -21,7 +19,7 @@ public class WsAutopilotTrajectoryMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
CupidLogUtils.w("WsAutopilotTrajectoryMessage===>"+msg);
|
||||
CupidLogUtils.w("WsAutopilotTrajectoryMessage===>" + msg);
|
||||
AutopilotTrajectory trajectory = gson.fromJson(msg, AutopilotTrajectory.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onAutopilotTrajectory(trajectory.getModels());
|
||||
@@ -34,7 +32,7 @@ public class WsAutopilotTrajectoryMessage extends MyAbstractMessageHandler {
|
||||
TrajectoryOuterClass.Trajectory trajectory = TrajectoryOuterClass.Trajectory.parseFrom(msg);
|
||||
List<TrajectoryOuterClass.TrajectoryPoint> pointsList = trajectory.getPointsList();
|
||||
ArrayList<TrajectoryInfo> trajectoryInfos = new ArrayList<>();
|
||||
for (int i = 0;i<pointsList.size();i++){
|
||||
for (int i = 0; i < pointsList.size(); i++) {
|
||||
TrajectoryOuterClass.TrajectoryPoint point = pointsList.get(i);
|
||||
TrajectoryInfo trajectoryInfo = new TrajectoryInfo();
|
||||
trajectoryInfo.setLon(point.getX());
|
||||
|
||||
@@ -9,26 +9,18 @@ import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_LOG_WEB_SO
|
||||
import static com.zhidao.support.adas.high.common.Constants.WS_IP_HOST_HEAD;
|
||||
import static com.zhidao.support.adas.high.common.Constants.WS_PORT;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.AdasChannel;
|
||||
import com.zhidao.support.adas.high.bean.FaceLoginResponse;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.RequestWsMsgType;
|
||||
import com.zhidao.support.adas.high.queue.WSByteQueueManager;
|
||||
import com.zhidao.support.adas.high.queue.WebSocketQueueManager;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
import com.zhjt.service.chain.TracingConstants;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
@@ -57,16 +49,20 @@ public class FpgaSocket implements IWebSocket {
|
||||
private WebSocket mWebSocket;
|
||||
|
||||
private EchoWebSocketListener listener;
|
||||
|
||||
private IWebSocketConnectListener mWebSocketConnectListener;
|
||||
private Request request;
|
||||
|
||||
private OkHttpClient.Builder okBuilder;
|
||||
|
||||
private JSONObject jsonObject;
|
||||
private String wsHost;
|
||||
/**
|
||||
* 是否是用户主动关闭socket
|
||||
*/
|
||||
private boolean isUserCloseWebSocket = false;
|
||||
private volatile boolean isUserCloseWebSocket = false;
|
||||
/**
|
||||
* 是否启用自动重连
|
||||
*/
|
||||
private volatile boolean isReconnect = true;
|
||||
|
||||
public FpgaSocket() {
|
||||
init();
|
||||
@@ -78,8 +74,9 @@ public class FpgaSocket implements IWebSocket {
|
||||
}
|
||||
if (okBuilder == null) {
|
||||
okBuilder = new OkHttpClient.Builder();
|
||||
okBuilder.readTimeout(20, TimeUnit.SECONDS);
|
||||
okBuilder.connectTimeout(20, TimeUnit.SECONDS);
|
||||
okBuilder.writeTimeout(10, TimeUnit.SECONDS);
|
||||
okBuilder.readTimeout(10, TimeUnit.SECONDS);
|
||||
okBuilder.connectTimeout(10, TimeUnit.SECONDS);
|
||||
}
|
||||
if (client == null) {
|
||||
client = okBuilder.build();
|
||||
@@ -88,44 +85,68 @@ public class FpgaSocket implements IWebSocket {
|
||||
|
||||
@Override
|
||||
public void connectWebSocket(String address) {
|
||||
String wsHost = WS_IP_HOST_HEAD + address + WS_PORT;
|
||||
CupidLogUtils.i(TAG, "--->connectWebSocket" + wsHost);
|
||||
isUserCloseWebSocket = false;
|
||||
wsHost = WS_IP_HOST_HEAD + address + WS_PORT;
|
||||
CupidLogUtils.i(TAG, "WebSocket 主动连接= " + wsHost);
|
||||
init();
|
||||
if (client != null) {
|
||||
request = new Request.Builder()
|
||||
.url(wsHost)
|
||||
.build();
|
||||
connect();
|
||||
}
|
||||
|
||||
private void connect() {
|
||||
if (client != null && mWebSocket == null) {
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onConnecting();
|
||||
if (request == null)
|
||||
request = new Request.Builder()
|
||||
.url(wsHost)
|
||||
.build();
|
||||
client.newWebSocket(request, listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重连
|
||||
*/
|
||||
public void reconnect() {
|
||||
CupidLogUtils.i(TAG, "WebSocket 是否启用自动重连=" + isReconnect);
|
||||
if (isReconnect) {
|
||||
if (!isUserCloseWebSocket) {
|
||||
try {
|
||||
Thread.sleep(5000L);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
connect();
|
||||
} else {
|
||||
isUserCloseWebSocket = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWebSocket() {
|
||||
CupidLogUtils.i(TAG, "===>closeWebSocket");
|
||||
CupidLogUtils.i(TAG, "WebSocket 主动断开连接");
|
||||
if (AdasChannel.isUseQueue) {
|
||||
WebSocketQueueManager.getInstance().release();
|
||||
WSByteQueueManager.getInstance().release();
|
||||
}
|
||||
isUserCloseWebSocket = true;
|
||||
listener = null;
|
||||
jsonObject = null;
|
||||
if (mWebSocket != null) {
|
||||
boolean isClose = mWebSocket.close(1000, null);
|
||||
CupidLogUtils.i(TAG, "===>webSocket关闭了吗" + isClose);
|
||||
|
||||
CupidLogUtils.i(TAG, "WebSocket 主动断开连接,是否成功= " + isClose);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
}
|
||||
listener = null;
|
||||
client = null;
|
||||
request = null;
|
||||
listener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendDataWebSocket(String data) {
|
||||
if (mWebSocket != null) {
|
||||
boolean result = mWebSocket.send(data);
|
||||
CupidLogUtils.i(TAG, "sendDataWebSocket--->String: " + data + ", result= " + result);
|
||||
CupidLogUtils.i(TAG, "WebSocket send String= " + data + ", result= " + result);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
@@ -135,118 +156,27 @@ public class FpgaSocket implements IWebSocket {
|
||||
public boolean sendDataWebSocket(ByteString data) {
|
||||
if (mWebSocket != null) {
|
||||
boolean result = mWebSocket.send(data);
|
||||
CupidLogUtils.i(TAG, "sendDataWebSocket--->ByteString: " + data + ", result= " + result);
|
||||
CupidLogUtils.i(TAG, "WebSocket send ByteString= " + data + ", result= " + result);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getConfigData(String appId, String userId) {
|
||||
CupidLogUtils.i(TAG, "getConfigData appId: " + appId + ", userId:" + userId);
|
||||
public void setIsReconnect(boolean isReconnect) {
|
||||
this.isReconnect = isReconnect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doConfigChanged(int type, String ip, List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos) {
|
||||
CupidLogUtils.i(TAG, "doConfigChanged, type: " + type + " ip: " + ip + " configInfos:" + configInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doConfigChanged(List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos) {
|
||||
CupidLogUtils.i(TAG, "doConfigChanged, configInfos:" + configInfos);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//上传配置信息
|
||||
//位置信息 action是3
|
||||
try {
|
||||
jsonObject.put("action", RequestWsMsgType.MSG_SEND_UPLOAD_CONFIG.getMsgType());
|
||||
jsonObject.put("config", new JSONArray(new Gson().toJson(configInfos)));
|
||||
sendDataWebSocket(jsonObject.toString());
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveShotPic(Bitmap bitmap) {
|
||||
CupidLogUtils.i(TAG, "saveShotPic");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTouchImage(String url, double x, double y) {
|
||||
CupidLogUtils.i(TAG, "getTouchImage, url: " + url + " ,x: " + x + " ,y: " + y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRecognizeImage(File file, String deviceId, String tag) {
|
||||
CupidLogUtils.i(TAG, "doRecognizeImage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getUserAchieveInfo(String userId) {
|
||||
CupidLogUtils.i(TAG, "getUserAchieveInfo, userId:" + userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNaviInfo(int type) {
|
||||
CupidLogUtils.i(TAG, "getNaviInfo, type:" + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncMedalDetailInfo(String userId, int action, String medalType) {
|
||||
CupidLogUtils.i(TAG, "syncMedalDetailInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCarModelInfo(String s, int id) {
|
||||
CupidLogUtils.i(TAG, "getCarModelInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doUpdateCarInfo(String userId, String brandId, String brandName, String modelId, String modelName, String styleId, String styleName) {
|
||||
CupidLogUtils.i(TAG, "doUpdateCarInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getApkAndFireWareInfo(String deviceId, String userId, int apkVersionCode, int xvideoCppVersionCode, int appId) {
|
||||
CupidLogUtils.i(TAG, "getApkAndFireWareInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFireWareBaseInfo(String baseUrl) {
|
||||
CupidLogUtils.i(TAG, "getFireWareBaseInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFirmWareUpdateInfo(String baseUrl, String json) {
|
||||
CupidLogUtils.i(TAG, "sendFirmWareUpdateInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startNavigate(String userId, String naviStartName, String naviEndName) {
|
||||
CupidLogUtils.i(TAG, "startNavigate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncUserNavigateInfo(String navigateId, String longtitude, String latitude, String poId, String currentSpeed) {
|
||||
CupidLogUtils.i(TAG, "syncUserNavigateInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doVerticalLineConfigCompleted() {
|
||||
CupidLogUtils.i(TAG, "doVerticalLineConfigCompleted");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSyncCarSpaceInfo(String carLength, String carWidth, String carHeight) {
|
||||
CupidLogUtils.i(TAG, "doSyncCarSpaceInfo");
|
||||
}
|
||||
|
||||
private IWebSocketConnectListener mWebSocketConnectListener;
|
||||
|
||||
public interface IWebSocketConnectListener {
|
||||
void onWebSocketConnectSuccess(WebSocket webSocket);
|
||||
/**
|
||||
* 正在连接
|
||||
*/
|
||||
void onConnecting();
|
||||
|
||||
void onWebSocketConnectFailed(WebSocket webSocket, String t);
|
||||
void onWebSocketConnectSuccess();
|
||||
|
||||
void onWebSocketConnectFailed(String t);
|
||||
|
||||
void onMessage(String message);
|
||||
|
||||
@@ -259,58 +189,63 @@ public class FpgaSocket implements IWebSocket {
|
||||
|
||||
public class EchoWebSocketListener extends WebSocketListener {
|
||||
|
||||
// @ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
// linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
// endpoint = TracingConstants.Endpoint.PAD,
|
||||
// nodeAliasCode = CHAIN_ALIAS_CODE_WEB_SOCKET_OPEN,
|
||||
// paramIndexes = {1},
|
||||
// clientPkFileName = "sn")
|
||||
@ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_WEB_SOCKET_OPEN,
|
||||
paramIndexes = {1},
|
||||
clientPkFileName = "sn")
|
||||
@Override
|
||||
public void onOpen(WebSocket webSocket, Response response) {
|
||||
public void onOpen(@NonNull WebSocket webSocket, @NonNull Response response) {
|
||||
super.onOpen(webSocket, response);
|
||||
mWebSocket = webSocket;
|
||||
CupidLogUtils.i(TAG, "websocket response connect success");
|
||||
mWebSocketConnectListener.onWebSocketConnectSuccess(webSocket);
|
||||
boolean isConnect = response.code() == 101;
|
||||
if (!isConnect) {
|
||||
reconnect();
|
||||
} else {
|
||||
CupidLogUtils.i(TAG, "WebSocket 连接成功");
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onWebSocketConnectSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
// @ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
// linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_DATA,
|
||||
// endpoint = TracingConstants.Endpoint.PAD,
|
||||
// nodeAliasCode = CHAIN_ALIAS_CODE_WEB_SOCKET_MESSAGE_JSON,
|
||||
// paramIndexes = {1},
|
||||
// clientPkFileName = "sn")
|
||||
@ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_DATA,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_WEB_SOCKET_MESSAGE_JSON,
|
||||
paramIndexes = {1},
|
||||
clientPkFileName = "sn")
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
public void onMessage(@NonNull WebSocket webSocket, @NonNull String text) {
|
||||
super.onMessage(webSocket, text);
|
||||
CupidLogUtils.i(TAG, "websocket response connect text" + text);
|
||||
CupidLogUtils.i(TAG, "WebSocket onMessage text= " + text);
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
return;
|
||||
}
|
||||
if (AdasChannel.isUseQueue) {
|
||||
WebSocketQueueManager.getInstance().addQueueData(text);
|
||||
} else {
|
||||
mWebSocketConnectListener.onMessage(text);
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onMessage(text);
|
||||
}
|
||||
}
|
||||
//
|
||||
// @ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
// linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_DATA,
|
||||
// endpoint = TracingConstants.Endpoint.PAD,
|
||||
// nodeAliasCode = CHAIN_ALIAS_CODE_WEB_SOCKET_MESSAGE_BYTE,
|
||||
// paramIndexes = {-1},
|
||||
// clientPkFileName = "sn")
|
||||
|
||||
@ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
linkChainLog = CHAIN_LINK_LOG_WEB_SOCKET_DATA,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_WEB_SOCKET_MESSAGE_BYTE,
|
||||
paramIndexes = {-1},
|
||||
clientPkFileName = "sn")
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, ByteString bytes) {
|
||||
public void onMessage(@NonNull WebSocket webSocket, @NonNull ByteString bytes) {
|
||||
super.onMessage(webSocket, bytes);
|
||||
CupidLogUtils.i(TAG, "websocket response connect byte" + bytes.hex());
|
||||
if (bytes == null) {
|
||||
return;
|
||||
}
|
||||
CupidLogUtils.i(TAG, "WebSocket onMessage bytes= " + bytes.hex());
|
||||
if (AdasChannel.isUseQueue) {
|
||||
WSByteQueueManager.getInstance().addQueueData(bytes);
|
||||
} else {
|
||||
try {
|
||||
mWebSocketConnectListener.onMessage(bytes);
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onMessage(bytes);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -319,26 +254,47 @@ public class FpgaSocket implements IWebSocket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosing(WebSocket webSocket, int code, String reason) {
|
||||
public void onClosing(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
||||
super.onClosing(webSocket, code, reason);
|
||||
mWebSocket = null;
|
||||
CupidLogUtils.i(TAG, "websocket onClosing==> onClosing" + reason);
|
||||
CupidLogUtils.e(TAG, "WebSocket onClosing= " + reason);
|
||||
if (mWebSocket != null) {
|
||||
mWebSocket.close(1000, null);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
} else {
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(reason);
|
||||
reconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
public void onClosed(@NonNull WebSocket webSocket, int code, @NonNull String reason) {
|
||||
super.onClosed(webSocket, code, reason);
|
||||
mWebSocket = null;
|
||||
CupidLogUtils.i(TAG, "websocket onClosed ==> " + reason);
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(webSocket, reason);
|
||||
CupidLogUtils.e(TAG, "WebSocket onClosed= " + reason);
|
||||
if (mWebSocket != null) {
|
||||
mWebSocket.close(1000, null);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
} else {
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(reason);
|
||||
reconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
public void onFailure(@NonNull WebSocket webSocket, @NonNull Throwable t, Response response) {
|
||||
super.onFailure(webSocket, t, response);
|
||||
mWebSocket = null;
|
||||
CupidLogUtils.i(TAG, "websocket onFailure ===>" + t.getMessage());
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(webSocket, t.toString());
|
||||
CupidLogUtils.e(TAG, "WebSocket onFailure= " + t);
|
||||
if (mWebSocket != null) {
|
||||
mWebSocket.close(1000, null);
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
}
|
||||
if (mWebSocketConnectListener != null)
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(t.toString());
|
||||
reconnect();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
package com.zhidao.support.adas.high.socket;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import com.zhidao.support.adas.high.bean.FaceLoginResponse;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
@@ -38,117 +31,16 @@ public interface IWebSocket {
|
||||
* @param data
|
||||
*/
|
||||
boolean sendDataWebSocket(String data);
|
||||
|
||||
boolean sendDataWebSocket(ByteString data);
|
||||
|
||||
/**
|
||||
* 云端拉取配置信息
|
||||
* 是否启用自动重连
|
||||
*
|
||||
* @param
|
||||
* @param isReconnect
|
||||
*/
|
||||
void getConfigData(String appId, String userId);
|
||||
|
||||
/**
|
||||
* 更改云端配置信息
|
||||
*
|
||||
* @param configInfos
|
||||
*/
|
||||
void doConfigChanged(int type, String ip, List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos);
|
||||
|
||||
/**
|
||||
* 上传配置
|
||||
* @param configInfos
|
||||
*/
|
||||
void doConfigChanged( List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos);
|
||||
|
||||
/**
|
||||
* 保存图片
|
||||
*/
|
||||
void saveShotPic(Bitmap bitmap);
|
||||
void setIsReconnect(boolean isReconnect);
|
||||
|
||||
|
||||
/**
|
||||
* @param x
|
||||
* @param y
|
||||
*/
|
||||
void getTouchImage(String url, double x, double y);
|
||||
|
||||
/**
|
||||
* @param file
|
||||
* @param deviceId
|
||||
* @param tag
|
||||
*/
|
||||
void doRecognizeImage(File file, String deviceId, String tag);
|
||||
|
||||
/**
|
||||
* @param userId
|
||||
*/
|
||||
void getUserAchieveInfo(String userId);
|
||||
|
||||
|
||||
/**
|
||||
* 从板子上获取导航信息
|
||||
*
|
||||
* @param type 10/角度 11/位置
|
||||
*/
|
||||
void getNaviInfo(int type);
|
||||
|
||||
|
||||
/**
|
||||
* 同步成就信息
|
||||
*
|
||||
* @param userId
|
||||
* @param action
|
||||
* @param medalType
|
||||
*/
|
||||
void syncMedalDetailInfo(String userId, int action, String medalType);
|
||||
|
||||
|
||||
/**
|
||||
* 获取品牌车型车款信息
|
||||
*
|
||||
* @param s
|
||||
*/
|
||||
void getCarModelInfo(String s, int id);
|
||||
|
||||
void doUpdateCarInfo(String userId, String brandId, String brandName, String modelId, String modelName, String styleId, String styleName);
|
||||
|
||||
/**
|
||||
* 获取apk 以及 固件升级信息
|
||||
*
|
||||
* @param deviceId
|
||||
* @param userId
|
||||
* @param apkVersionCode
|
||||
* @param xvideoCppVersionCode
|
||||
* @param appId 2是专业版
|
||||
*/
|
||||
void getApkAndFireWareInfo(String deviceId, String userId, int apkVersionCode, int xvideoCppVersionCode,int appId);
|
||||
|
||||
/**
|
||||
* 获取固件基础信息
|
||||
*/
|
||||
void getFireWareBaseInfo(String baseUrl);
|
||||
|
||||
/**
|
||||
* 发送板子 更新升级信息
|
||||
* @param baseUrl
|
||||
* @param json
|
||||
*/
|
||||
void sendFirmWareUpdateInfo(String baseUrl,String json);
|
||||
|
||||
void startNavigate(String userId, String naviStartName, String naviEndName);
|
||||
|
||||
void syncUserNavigateInfo(String navigateId, String longtitude, String latitude, String poId, String currentSpeed);
|
||||
|
||||
|
||||
void doVerticalLineConfigCompleted();
|
||||
|
||||
|
||||
/**
|
||||
* 给板子同步长宽高信息
|
||||
* @param carLength
|
||||
* @param carWidth
|
||||
* @param carHeight
|
||||
*/
|
||||
void doSyncCarSpaceInfo(String carLength, String carWidth, String carHeight);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ public class CupidUdpConstract {
|
||||
/**
|
||||
* 初始化UDPserver 接收数据
|
||||
*/
|
||||
|
||||
private void init(int udpType) {
|
||||
if (udpType == VIDEO_STREAM_UDP) {
|
||||
udpImpl = CupidUdpFactory.createVideoStreamUdp();
|
||||
@@ -71,12 +70,12 @@ public class CupidUdpConstract {
|
||||
/**
|
||||
* 开启线程 在surface准备好之后再进行接收数据
|
||||
*/
|
||||
// @ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
// linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
// endpoint = TracingConstants.Endpoint.PAD,
|
||||
// nodeAliasCode = CHAIN_ALIAS_CODE_UDP_INIT,
|
||||
// paramIndexes = {0},
|
||||
// clientPkFileName = "sn")
|
||||
@ChainLog(linkCode = CHAIN_LINK_ADAS,
|
||||
linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS,
|
||||
endpoint = TracingConstants.Endpoint.PAD,
|
||||
nodeAliasCode = CHAIN_ALIAS_CODE_UDP_INIT,
|
||||
paramIndexes = {0},
|
||||
clientPkFileName = "sn")
|
||||
public void startReceiverDataThread() {
|
||||
if (udpReceiverDataThread != null) {
|
||||
udpReceiverDataThread.interrupt();
|
||||
|
||||
Reference in New Issue
Block a user