将ADAS LIB工程代码全部移动到鹰眼项目中
This commit is contained in:
@@ -35,7 +35,7 @@ buildscript {
|
||||
classpath 'com.volcengine:apm_insight_plugin:1.4.1'
|
||||
classpath 'com.mogo.cloud:thread_opt:1.0.0'
|
||||
classpath 'com.mogo.cloud:systrace:1.0.1'
|
||||
|
||||
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
|
||||
// classpath "com.bytedance.android.byteX:base-plugin:0.3.0"
|
||||
// classpath "com.mogo.cloud:hook:${HOOK_LOG_VERSION}"
|
||||
|
||||
|
||||
@@ -113,6 +113,7 @@ MAP_AMAP_VERSION=2.1.16.6
|
||||
MAP_AUTONAVI_VERSION=2.1.16.6
|
||||
MOGO_MAP_VERSION=2.1.16.6
|
||||
MOGO_MAP_API_VERSION=2.1.16.6
|
||||
MOGO_ADAS_VERSION=2.1.16.6
|
||||
MOGO_SERVICE_VERSION=2.1.16.6
|
||||
MOGO_SERVICE_API_VERSION=2.1.16.6
|
||||
MOGO_CONNECTION_VERSION=2.1.16.6
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-android-extensions'
|
||||
id 'kotlin-kapt'
|
||||
id 'com.alibaba.arouter'
|
||||
id 'com.google.protobuf'
|
||||
// id 'maven'
|
||||
}
|
||||
ext {
|
||||
//自动驾驶产品版本号
|
||||
AP_VERSION = "2.2.1"
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
// buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode Integer.valueOf(VERSION_CODE)
|
||||
versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
def name = getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
|
||||
versionName name
|
||||
// buildConfigField "String", "VERSION_NAME", "\"${name}\""
|
||||
buildConfigField "String", "AP_VERSION", "\"${AP_VERSION}\""
|
||||
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
|
||||
//ARouter apt 参数
|
||||
kapt {
|
||||
useBuildCache = false
|
||||
arguments {
|
||||
arg("AROUTER_MODULE_NAME", project.getName())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -33,31 +32,75 @@ android {
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir 'src/main/java'
|
||||
}
|
||||
|
||||
proto {
|
||||
srcDir 'src/main/proto'
|
||||
include '**/*.proto'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protobuf {
|
||||
protoc {
|
||||
artifact = 'com.google.protobuf:protoc:3.6.1'
|
||||
}
|
||||
|
||||
generateProtoTasks {
|
||||
all().each { task ->
|
||||
task.builtins {
|
||||
remove java
|
||||
}
|
||||
task.builtins {
|
||||
java {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation rootProject.ext.dependencies.androidxappcompat
|
||||
|
||||
implementation rootProject.ext.dependencies.arouter
|
||||
kapt rootProject.ext.dependencies.aroutercompiler
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogomapapi
|
||||
api rootProject.ext.dependencies.mapautomap
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
|
||||
} else {
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':libraries:mogo-map-api')
|
||||
api project(':libraries:map-autonavi')
|
||||
implementation project(':foudations:mogo-commons')
|
||||
|
||||
implementation project(':core:mogo-core-data')
|
||||
}
|
||||
//okhttp3的依赖
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.3'
|
||||
// parser
|
||||
implementation rootProject.ext.dependencies.gson
|
||||
// logger
|
||||
//implementation 'com.orhanobut:logger:2.2.0'
|
||||
//ProtoBuf
|
||||
implementation 'com.google.protobuf:protobuf-java:3.6.1'
|
||||
implementation 'com.google.protobuf:protoc:3.6.1'
|
||||
implementation 'com.google.protobuf:protobuf-java-util:3.6.1'
|
||||
implementation 'com.jcraft:jsch:0.1.55'
|
||||
// api project(path: ':lib_recorder')
|
||||
api "com.zhidao.support.recorder:recorder:1.0.0.3"
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
//task androidSourcesJar(type: Jar) {
|
||||
// classifier = 'sources'
|
||||
// from android.sourceSets.main.java.srcDirs
|
||||
//}
|
||||
////配置需要上传到maven仓库的文件
|
||||
//artifacts {
|
||||
// archives androidSourcesJar
|
||||
//}
|
||||
//
|
||||
//uploadArchives {
|
||||
// repositories.mavenDeployer {
|
||||
// repository(url: RELEASE_REPO_URL) {
|
||||
// authentication(userName: NAME, password: PASSWORD)
|
||||
// }
|
||||
// snapshotRepository(url: SNAPSHOT_REPOSITORY_URL) {
|
||||
// authentication(userName: NAME, password: PASSWORD)
|
||||
// }
|
||||
// pom.groupId = GROUP
|
||||
// pom.artifactId = POM_ARTIFACT_ID
|
||||
// pom.version = VERSION
|
||||
// }
|
||||
//}
|
||||
@@ -1,5 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.mogo.adas">
|
||||
|
||||
|
||||
package="com.zhidao.support.adas.high" >
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
|
||||
</manifest>
|
||||
|
||||
@@ -0,0 +1,693 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import static com.zhidao.support.adas.high.common.ActionTypeReceive.ACTION_WS_AUTOPILOT_CONTROL;
|
||||
import static com.zhidao.support.adas.high.udp.CupidUdpConstract.VIDEO_RENDER_IMAGE_UDP;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.zhidao.support.adas.high.bean.AdasConfig;
|
||||
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.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.Constants;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.MgContextUtils;
|
||||
import com.zhidao.support.adas.high.common.SSH;
|
||||
import com.zhidao.support.adas.high.common.ThreadPoolManager;
|
||||
import com.zhidao.support.adas.high.msg.MyMessageFactory;
|
||||
import com.zhidao.support.adas.high.queue.UdpQueueManager;
|
||||
import com.zhidao.support.adas.high.queue.WSByteQueueManager;
|
||||
import com.zhidao.support.adas.high.queue.WebSocketQueueManager;
|
||||
import com.zhidao.support.adas.high.socket.FpgaSocket;
|
||||
import com.zhidao.support.adas.high.socket.read.OriginReadData;
|
||||
import com.zhidao.support.adas.high.socket.read.SocketReader;
|
||||
import com.zhidao.support.adas.high.udp.CupidUdpConstract;
|
||||
import com.zhidao.support.adas.high.udp.IConnectRtpListener;
|
||||
import com.zhidao.support.adas.high.udp.IGetH264Data;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.webproto.WebsocketHeader;
|
||||
import okhttp3.WebSocket;
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: AdasChannel
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/7 13:32
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/7 13:32
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnectListener, IConnectRtpListener, IGetH264Data {
|
||||
private static final String TAG = AdasChannel.class.getSimpleName();
|
||||
|
||||
private FpgaSocket mSocket;
|
||||
private SocketReader socketReader;
|
||||
private JSONObject jsonObject;
|
||||
/**
|
||||
* udp server
|
||||
*/
|
||||
private CupidUdpConstract udpConstract;
|
||||
|
||||
/**
|
||||
* ============是否运行
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 序列化rect
|
||||
*/
|
||||
private Gson gson;
|
||||
/**
|
||||
* 消息工厂
|
||||
*/
|
||||
private MyMessageFactory myMessageFactory;
|
||||
private AutopilotSpeedParam speedParam;
|
||||
private String ipAddr;//工控机IP
|
||||
private RecordCauseParam recordCauseParam;
|
||||
private SSH ssh;
|
||||
|
||||
@Override
|
||||
public void setIPCIp(String ipAddr) {
|
||||
this.ipAddr = ipAddr;
|
||||
}
|
||||
|
||||
AdasChannel(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
AdasChannel(Context context, String ipAddr) {
|
||||
initData(context);
|
||||
this.ipAddr = ipAddr;
|
||||
initSocket();
|
||||
if (TextUtils.isEmpty(ipAddr))
|
||||
initUdpServer();
|
||||
|
||||
}
|
||||
|
||||
private void initData(Context context) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化udp
|
||||
*/
|
||||
private void initUdpServer() {
|
||||
if (isUseQueue) {
|
||||
UdpQueueManager.getInstance().registerAdasChannel(this);
|
||||
UdpQueueManager.getInstance().initDector();
|
||||
}
|
||||
udpConstract = new CupidUdpConstract(VIDEO_RENDER_IMAGE_UDP);
|
||||
udpConstract.setOnReceiverH264Data(this);
|
||||
udpConstract.setOnConnectListener(this);
|
||||
isRunning = true;
|
||||
if (gson == null) {
|
||||
gson = new Gson();
|
||||
}
|
||||
}
|
||||
|
||||
private void initSocket() {
|
||||
mSocket = new FpgaSocket();
|
||||
socketReader = new SocketReader();
|
||||
mSocket.setWebSocketListener(this);
|
||||
if (isUseQueue) {
|
||||
WebSocketQueueManager.getInstance().registerWebSocketListener(this);
|
||||
WebSocketQueueManager.getInstance().initDector();
|
||||
WSByteQueueManager.getInstance().registerWebSocketListener(this);
|
||||
WSByteQueueManager.getInstance().initDector();
|
||||
}
|
||||
//TODO 写死IP
|
||||
if (!TextUtils.isEmpty(ipAddr)) {
|
||||
isRunning = true;
|
||||
getOnConnectionAddress(ipAddr);
|
||||
}
|
||||
}
|
||||
|
||||
private void connectSocket(String address) {
|
||||
mSocket.connectWebSocket(address);
|
||||
}
|
||||
|
||||
public void closeSocket() {
|
||||
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);
|
||||
|
||||
mSocket.sendDataWebSocket(jsonObject.toString());
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 基础信息
|
||||
*
|
||||
* @param basicInfo
|
||||
*/
|
||||
public void sendWsBasicInfo(BasicInfo basicInfo) {
|
||||
if (basicInfo == null) {
|
||||
return;
|
||||
}
|
||||
String msg = gson.toJson(basicInfo);
|
||||
mSocket.sendDataWebSocket(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 向工控机发送数据
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
@Override
|
||||
public void sendBaseInfo(BaseInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
String msg = gson.toJson(info);
|
||||
Log.i("SendBaseInfo=", msg);
|
||||
mSocket.sendDataWebSocket(msg);
|
||||
}
|
||||
|
||||
private void sendIPCCmd(final String cmd) {
|
||||
if (ssh == null) {
|
||||
// String ip = ipAddr;
|
||||
if (TextUtils.isEmpty(ipAddr)) {
|
||||
//尝试从缓存中获取工控机IP
|
||||
// String ip = AppPreferenceHelper.getInstance(MgContextUtils.getContext()).getUdpClientAddress();
|
||||
// if (TextUtils.isEmpty(ip)) {
|
||||
if (mAdasListener != null) {
|
||||
mAdasListener.onSSHResult(new SSHResult(SSHResult.RESULT_CODE.IP_UNKNOWN, cmd, "IPC IP未知"));
|
||||
}
|
||||
return;
|
||||
// }
|
||||
}
|
||||
ThreadPoolManager.getsInstance().execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ssh = new SSH();
|
||||
try {
|
||||
ssh.connect(ipAddr, 22, "titan", "mogo@ZHIDAO10");
|
||||
SSHResult result = ssh.exec(cmd, "mogo@ZHIDAO10");
|
||||
if (mAdasListener != null)
|
||||
mAdasListener.onSSHResult(result);
|
||||
} catch (JSchException | IOException e) {
|
||||
if (mAdasListener != null)
|
||||
mAdasListener.onSSHResult(new SSHResult(SSHResult.RESULT_CODE.ERROR, cmd, e.getMessage()));
|
||||
e.printStackTrace();
|
||||
}
|
||||
ssh.disConnect();
|
||||
ssh = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownIPC() {
|
||||
sendIPCCmd("sudo -S shutdown -h now");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootIPC() {
|
||||
sendIPCCmd("sudo -S reboot");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootAPDocker() {
|
||||
sendIPCCmd("docker restart autocar_default_1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*
|
||||
* @param configInfo
|
||||
*/
|
||||
public void sendWsConfigMessage(ConfigInfo configInfo) {
|
||||
if (configInfo == null) {
|
||||
return;
|
||||
}
|
||||
String msg = gson.toJson(configInfo);
|
||||
mSocket.sendDataWebSocket(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送ws消息
|
||||
*
|
||||
* @param msg 消息
|
||||
*/
|
||||
public boolean sendWsMessage(String msg) {
|
||||
boolean isSend = mSocket.sendDataWebSocket(msg);
|
||||
CupidLogUtils.w("sendWsMessage===>" + msg + " ; " + isSend);
|
||||
return isSend;
|
||||
}
|
||||
|
||||
/**
|
||||
* 线程标志
|
||||
*/
|
||||
public void onResume() {
|
||||
CupidLogUtils.e(TAG, "===>onResume isRunning===>" + isRunning);
|
||||
if (!isRunning) {
|
||||
isRunning = true;
|
||||
if (TextUtils.isEmpty(ipAddr)) {
|
||||
initUdpServer();
|
||||
} else {
|
||||
getOnConnectionAddress(ipAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 暂停
|
||||
*/
|
||||
public void onPause() {
|
||||
isRunning = false;
|
||||
if (udpConstract != null)
|
||||
udpConstract.release();
|
||||
if (isUseQueue) {
|
||||
UdpQueueManager.getInstance().release();
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestory() {
|
||||
onPause();
|
||||
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
|
||||
*/
|
||||
public void setUdpIsFirstInit() {
|
||||
if (udpConstract != null)
|
||||
udpConstract.setUdpIsFirstInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理webSocket text数据
|
||||
*
|
||||
* @param text
|
||||
*/
|
||||
public void handlerWSMsg(String text) {
|
||||
try {
|
||||
JSONObject jsonObjectWs = new JSONObject(text);
|
||||
String action = jsonObjectWs.optString("action");
|
||||
if (TextUtils.isEmpty(action)) {
|
||||
CupidLogUtils.w("--->action is null");
|
||||
return;
|
||||
}
|
||||
myMessageFactory.createMessage(action).handlerMsg(gson, mAdasListener, text);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void handlerWSMsg(ByteString bytes) {
|
||||
try {
|
||||
if (socketReader != null) {
|
||||
OriginReadData read = socketReader.read(bytes);
|
||||
if (read == null) {
|
||||
//read 解析为空 默认解析view
|
||||
CupidLogUtils.w("--->websocket byte read null, analysis view");
|
||||
myMessageFactory.createMessage(0x101).handlerMsg(gson, mAdasListener, bytes.toByteArray());
|
||||
return;
|
||||
}
|
||||
WebsocketHeader.Header_websock header = WebsocketHeader.Header_websock.parseFrom(read.getHeader());
|
||||
int headerType = header.getMsgType();
|
||||
CupidLogUtils.w("--->websocket byte read header = " + headerType);
|
||||
myMessageFactory.createMessage(headerType).handlerMsg(gson, mAdasListener, read.getPayload());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectSuccess(WebSocket webSocket) {
|
||||
isConnected = true;
|
||||
CupidLogUtils.e("--->onWebSocketConnectSuccess");
|
||||
if (mAdasMsgConnectStatusListener != null) {
|
||||
mAdasMsgConnectStatusListener.onWebSocketConnectSuccess();
|
||||
queryCarConfig();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWebSocketConnectFailed(WebSocket webSocket, String t) {
|
||||
isConnected = false;
|
||||
CupidLogUtils.e("--->onWebSocketConnectFailed");
|
||||
setUdpIsFirstInit();
|
||||
if (mAdasMsgConnectStatusListener != null) {
|
||||
mAdasMsgConnectStatusListener.onWebSocketConnectFailed(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String message) {
|
||||
handlerWSMsg(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(ByteString bytes) throws InvalidProtocolBufferException {
|
||||
handlerWSMsg(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionSuccessRtp() {
|
||||
CupidLogUtils.e(TAG, "--->onConnectionSuccessRtp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailedRtp(String reason) {
|
||||
CupidLogUtils.e(TAG, "--->onConnectionFailedRtp:" + reason);
|
||||
// TODO 暂时注释 测试完成添加
|
||||
// closeSocket();
|
||||
setUdpIsFirstInit();
|
||||
/*if (mRenderImageListener != null) {
|
||||
mRenderImageListener.onConnectionFailedRtp(reason);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getOnConnectionAddress(String address) {
|
||||
ipAddr = address;
|
||||
CupidLogUtils.e(TAG, "--->getOnConnectionAddress" + address);
|
||||
AppPreferenceHelper.getInstance(MgContextUtils.getContext()).saveUdpClientAddress(address);
|
||||
connectSocket(address);
|
||||
if (flag) {
|
||||
flag = false;
|
||||
if (configInfo != null && configInfo.size() > 0) {
|
||||
if (isConnected) {
|
||||
mSocket.doConfigChanged(configInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnectRtp() {
|
||||
CupidLogUtils.e(TAG, "--->onDisconnectRtp");
|
||||
setUdpIsFirstInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getH264Data(byte[] data, long receiverDataTimeUdp) {
|
||||
//处理数据
|
||||
String content = new String(data).trim();
|
||||
CupidLogUtils.e("--->udp数据回调:" + content);
|
||||
if (isUseQueue) {
|
||||
UdpQueueManager.getInstance().addQueueData(content);
|
||||
} else {
|
||||
udpDataManage(content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理udp数据
|
||||
*
|
||||
* @param content
|
||||
*/
|
||||
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");
|
||||
if (!TextUtils.isEmpty(udpRenderAction)) {
|
||||
//udp消息处理
|
||||
myMessageFactory.createMessage(udpRenderAction).handlerMsg(gson, mAdasListener, content);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CupidLogUtils.e("--->json数据解析异常-换用protoBuf:" + e.toString());
|
||||
myMessageFactory.createMessage("view").handlerMsg(gson, mAdasListener, content);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private OnAdasListener mAdasListener;
|
||||
//连接状态listener
|
||||
private OnAdasMsgConnectStatusListener mAdasMsgConnectStatusListener;
|
||||
|
||||
void setOnAdasListener(OnAdasListener adasListener) {
|
||||
mAdasListener = adasListener;
|
||||
}
|
||||
|
||||
void setOnAdasMsgConnectStatusListener(OnAdasMsgConnectStatusListener adasMsgConnectStatusListener) {
|
||||
mAdasMsgConnectStatusListener = adasMsgConnectStatusListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean controlAutopilotCarAuto() {
|
||||
AutopilotControl autopilotControl = new AutopilotControl();
|
||||
autopilotControl.setAction(ACTION_WS_AUTOPILOT_CONTROL.getmActionType());
|
||||
AutopilotControl.ValuesBean autopilotControlValues = new AutopilotControl.ValuesBean();
|
||||
autopilotControlValues.setMode(1);
|
||||
autopilotControl.setValues(autopilotControlValues);
|
||||
return sendWsMessage(gson.toJson(autopilotControl));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean controlAutopilotCarHead() {
|
||||
AutopilotControl autopilotControl = new AutopilotControl();
|
||||
autopilotControl.setAction(ACTION_WS_AUTOPILOT_CONTROL.getmActionType());
|
||||
AutopilotControl.ValuesBean autopilotControlValues = new AutopilotControl.ValuesBean();
|
||||
autopilotControlValues.setMode(0);
|
||||
autopilotControl.setValues(autopilotControlValues);
|
||||
return sendWsMessage(gson.toJson(autopilotControl));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSocketConnect() {
|
||||
return mSocket.getWebSocket() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdasConfig getAdasConfig() {
|
||||
String address = AppPreferenceHelper.getInstance(MgContextUtils.getContext()).getUdpClientAddress();
|
||||
String dockConfig = AppPreferenceHelper.getInstance(MgContextUtils.getContext()).getDockConfig();
|
||||
if (TextUtils.isEmpty(dockConfig)) {
|
||||
queryCarConfig();
|
||||
}
|
||||
AdasConfig adasConfig = new AdasConfig();
|
||||
adasConfig.setAddress(address);
|
||||
adasConfig.setDockVersion(dockConfig);
|
||||
return adasConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询config信息
|
||||
*/
|
||||
private void queryCarConfig() {
|
||||
sendWsMessage(Constants.QUERY_CAR_CONFIG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean aiCloudToAdasData(String msg) {
|
||||
//位置信息 action是aiCloudToStartAutopilot
|
||||
if (!TextUtils.isEmpty(msg)) {
|
||||
return sendWsMessage(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAutopilotRoute() {
|
||||
//查询自动驾驶路径
|
||||
return sendWsMessage(Constants.QUERY_GLOBAL_PATH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAutopilotGuardian() {
|
||||
//查询节点信息
|
||||
return sendWsMessage(Constants.QUERY_GUARDIAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recordPackage(int type, int id) {
|
||||
return recordBag(true, type, id, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recordPackage(int type, int id, int duration) {
|
||||
return recordBag(true, type, id, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopRecord(int type, int id) {
|
||||
return recordBag(false, type, id, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recordCause(String key, String name, String reason) {
|
||||
if (recordCauseParam == null) {
|
||||
recordCauseParam = new RecordCauseParam();
|
||||
}
|
||||
RecordCauseParam.Result result = new RecordCauseParam.Result();
|
||||
result.setKey(key);
|
||||
result.setFilename(name);
|
||||
result.setReason(reason);
|
||||
recordCauseParam.setResult(result);
|
||||
return sendWsMessage(gson.toJson(recordCauseParam));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSpeed(int speed) {
|
||||
if (speedParam == null) {
|
||||
speedParam = new AutopilotSpeedParam();
|
||||
}
|
||||
speedParam.setSpeed(speed);
|
||||
String speedJson = gson.toJson(speedParam);
|
||||
return sendWsMessage(speedJson);
|
||||
}
|
||||
// TODO 需求暂停 待讨论
|
||||
// @Override
|
||||
// public boolean getRoutes() {
|
||||
// return sendWsMessage(Constants.QUERY_ROUTES);
|
||||
// }
|
||||
|
||||
private boolean recordBag(boolean isRecord, int type, int id, int duration) {
|
||||
if (recordDataParam == null) {
|
||||
recordDataParam = new RecordDataParam();
|
||||
}
|
||||
RecordDataParam.Result result = new RecordDataParam.Result();
|
||||
result.setIsRecord(isRecord);
|
||||
result.setType(type);
|
||||
result.setId(id);
|
||||
if (isRecord == true) {
|
||||
if (duration > 0) {
|
||||
result.setSustain(false);
|
||||
result.setDuration(duration);
|
||||
} else {
|
||||
result.setSustain(true);
|
||||
}
|
||||
}
|
||||
recordDataParam.setResult(result);
|
||||
String param = gson.toJson(recordDataParam);
|
||||
return sendWsMessage(param);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 接管原因
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* log是否显示
|
||||
*
|
||||
* @param isEnableLog
|
||||
*/
|
||||
public void setEnableLog(boolean isEnableLog) {
|
||||
CupidLogUtils.setEnableLog(isEnableLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* log是否写入本地
|
||||
*
|
||||
* @param isWriteLog
|
||||
*/
|
||||
public void setIsWriteLog(boolean isWriteLog) {
|
||||
CupidLogUtils.setIsWriteLog(isWriteLog);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,324 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: AdasManager
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/7 13:13
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/7 13:13
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class AdasManager implements IAdasNetCommApi {
|
||||
private static volatile AdasManager ourInstance;
|
||||
|
||||
public void init(Context context) {
|
||||
//登录信息,空默认配置
|
||||
|
||||
}
|
||||
|
||||
public static AdasManager getInstance() {
|
||||
if (ourInstance == null) {
|
||||
synchronized (AdasManager.class) {
|
||||
if (ourInstance == null) {
|
||||
ourInstance = new AdasManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
private AdasChannel mChannel;
|
||||
|
||||
private AdasManager() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setOnAdasListener(OnAdasListener l) {
|
||||
if (mChannel != null) {
|
||||
mChannel.setOnAdasListener(l);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 adas 连接状态
|
||||
*
|
||||
* @param onAdasConnectStatusListener
|
||||
*/
|
||||
public void setOnAdasConnectStatusListener(OnAdasMsgConnectStatusListener onAdasConnectStatusListener) {
|
||||
if (mChannel != null) {
|
||||
mChannel.setOnAdasMsgConnectStatusListener(onAdasConnectStatusListener);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void create(Context context) {
|
||||
if (mChannel == null) {
|
||||
mChannel = new AdasChannel(context);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void create(Context context, String ipcIp) {
|
||||
if (mChannel == null) {
|
||||
mChannel = new AdasChannel(context, ipcIp);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送信息
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void sendMessage(String msg) {
|
||||
if (mChannel != null) {
|
||||
mChannel.sendWsMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送基础信息
|
||||
*
|
||||
* @param basicInfo
|
||||
*/
|
||||
public void setBasicInfo(BasicInfo basicInfo) {
|
||||
if (mChannel != null) {
|
||||
mChannel.sendWsBasicInfo(basicInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送配置信息
|
||||
*
|
||||
* @param configMsg
|
||||
*/
|
||||
public void setConfigMsg(ConfigInfo configMsg) {
|
||||
if (mChannel != null) {
|
||||
mChannel.sendWsConfigMessage(configMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭socket连接
|
||||
*/
|
||||
public void closeSocket() {
|
||||
if (mChannel != null) {
|
||||
mChannel.closeSocket();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭所有通信
|
||||
*/
|
||||
public void closeAllMsg() {
|
||||
if (mChannel != null) {
|
||||
mChannel.closeSocket();
|
||||
}
|
||||
pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动所有的通信
|
||||
*/
|
||||
public void startAllMsg() {
|
||||
resume();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean controlAutopilotCarAuto() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.controlAutopilotCarAuto();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean controlAutopilotCarHead() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.controlAutopilotCarHead();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSocketConnect() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.isSocketConnect();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdasConfig getAdasConfig() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.getAdasConfig();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean aiCloudToAdasData(String msg) {
|
||||
if (mChannel != null) {
|
||||
return mChannel.aiCloudToAdasData(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAutopilotRoute() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.queryAutopilotRoute();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean queryAutopilotGuardian() {
|
||||
if (mChannel != null) {
|
||||
return mChannel.queryAutopilotGuardian();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recordPackage(int type, int id) {
|
||||
if (mChannel != null) {
|
||||
return mChannel.recordPackage(type, id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recordPackage(int type, int id, int duration) {
|
||||
if (mChannel != null) {
|
||||
return mChannel.recordPackage(type, id, duration);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stopRecord(int type, int id) {
|
||||
if (mChannel != null) {
|
||||
return mChannel.stopRecord(type, id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean recordCause(String key, String name, String reason) {
|
||||
return mChannel.recordCause(key, name, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setSpeed(int speed) {
|
||||
if (mChannel != null) {
|
||||
return mChannel.setSpeed(speed);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// TODO 需求暂停 待讨论 获取车辆轨迹文件
|
||||
// @Override
|
||||
// public boolean getRoutes() {
|
||||
// if (mChannel!=null){
|
||||
// return mChannel.getRoutes();
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setEnableLog(boolean isEnableLog) {
|
||||
if (mChannel != null) {
|
||||
mChannel.setEnableLog(isEnableLog);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsWriteLog(boolean isWriteLog) {
|
||||
if (mChannel != null) {
|
||||
mChannel.setIsWriteLog(isWriteLog);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIPCIp(String ipAddr) {
|
||||
if (mChannel != null) {
|
||||
mChannel.setIPCIp(ipAddr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向工控机发送数据
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
@Override
|
||||
public void sendBaseInfo(BaseInfo info) {
|
||||
if (mChannel != null) {
|
||||
mChannel.sendBaseInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownIPC() {
|
||||
if (mChannel != null) {
|
||||
mChannel.shutdownIPC();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootIPC() {
|
||||
if (mChannel != null) {
|
||||
mChannel.rebootIPC();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootAPDocker() {
|
||||
if (mChannel != null) {
|
||||
mChannel.rebootAPDocker();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import com.zhidao.support.adas.high.bean.AdasConfig;
|
||||
import com.zhidao.support.adas.high.bean.BaseInfo;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des adas 网络通信api
|
||||
* @date 2020/7/14
|
||||
*/
|
||||
public interface IAdasNetCommApi {
|
||||
/**
|
||||
* 控制自动驾驶车辆 自动模式 自动驾驶
|
||||
*/
|
||||
boolean controlAutopilotCarAuto();
|
||||
|
||||
/**
|
||||
* 控制自动驾驶车辆 手动模式
|
||||
*/
|
||||
boolean controlAutopilotCarHead();
|
||||
|
||||
/**
|
||||
* socket 是否连接状态
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isSocketConnect();
|
||||
|
||||
/**
|
||||
* 基础信息
|
||||
*/
|
||||
AdasConfig getAdasConfig();
|
||||
|
||||
/**
|
||||
* ai云
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
boolean aiCloudToAdasData(String msg);
|
||||
|
||||
/**
|
||||
* 查询自动驾驶路径
|
||||
*/
|
||||
boolean queryAutopilotRoute();
|
||||
|
||||
/**
|
||||
* 查询节点监控信息
|
||||
*/
|
||||
boolean queryAutopilotGuardian();
|
||||
|
||||
/**
|
||||
* 数据采集
|
||||
*/
|
||||
boolean recordPackage(int type, int id);
|
||||
|
||||
boolean recordPackage(int type, int id, int duration);
|
||||
|
||||
boolean stopRecord(int type, int id);
|
||||
|
||||
boolean recordCause(String key, String name, String reason);
|
||||
|
||||
/**
|
||||
* 设置车速
|
||||
* speed km/h
|
||||
*/
|
||||
boolean setSpeed(int speed);
|
||||
|
||||
/**
|
||||
* 查询轨迹文件
|
||||
*
|
||||
*/
|
||||
// TODO 需求暂停 待讨论
|
||||
// boolean getRoutes();
|
||||
|
||||
/**
|
||||
* log是否显示
|
||||
*/
|
||||
void setEnableLog(boolean isEnableLog);
|
||||
|
||||
/**
|
||||
* log是否写入
|
||||
*/
|
||||
void setIsWriteLog(boolean isWriteLog);
|
||||
|
||||
/**
|
||||
* 设置工控机IP 如设置IP将不会执行自动搜索方式链接
|
||||
*
|
||||
* @param ipAddr
|
||||
*/
|
||||
void setIPCIp(String ipAddr);
|
||||
|
||||
/**
|
||||
* 向工控机发送数据
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void sendBaseInfo(BaseInfo info);
|
||||
|
||||
/**
|
||||
* 向工控机发送关机命令
|
||||
*/
|
||||
void shutdownIPC();
|
||||
|
||||
/**
|
||||
* 向工控机发送重启命令
|
||||
*/
|
||||
void rebootIPC();
|
||||
|
||||
/**
|
||||
* 向工控机发送重启自动驾驶Docker命令
|
||||
*/
|
||||
void rebootAPDocker();
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.zhidao.support.adas.high;
|
||||
|
||||
import com.zhidao.support.adas.high.bean.AutopilotRoute;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotStatus;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
|
||||
import com.zhidao.support.adas.high.bean.CarLaneInfo;
|
||||
import com.zhidao.support.adas.high.bean.CarStateInfo;
|
||||
import com.zhidao.support.adas.high.bean.SSHResult;
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradePatchDownloadStatusInfo;
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeStateInfo;
|
||||
import com.zhidao.support.adas.high.bean.LightStatueInfo;
|
||||
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.bean.TrajectoryInfo;
|
||||
import com.zhidao.support.adas.high.bean.WarnMessageInfo;
|
||||
import com.zhidao.support.adas.high.bean.guardian.AutopilotGuardianInfo;
|
||||
import com.zhidao.support.adas.high.bean.record.AutopilotRecordResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: OnAdasListener
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/9 20:28
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/9 20:28
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface OnAdasListener {
|
||||
/**
|
||||
* 报警信息
|
||||
*
|
||||
* @param warnMessageInfo
|
||||
*/
|
||||
void onWarnMessage(WarnMessageInfo warnMessageInfo);
|
||||
|
||||
/**
|
||||
* 视频宽高
|
||||
*
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
void onVideoSize(int width, int height);
|
||||
|
||||
/**
|
||||
* 车框
|
||||
*
|
||||
* @param rectInfo
|
||||
*/
|
||||
void onRectData(RectInfo rectInfo);
|
||||
|
||||
/**
|
||||
* 车辆状态数据
|
||||
*
|
||||
* @param carStateInfo
|
||||
*/
|
||||
void onCarStateData(CarStateInfo carStateInfo);
|
||||
|
||||
/**
|
||||
* 红绿灯状态
|
||||
*
|
||||
* @param lightStatueInfo
|
||||
*/
|
||||
void onLightStateData(LightStatueInfo lightStatueInfo);
|
||||
|
||||
/**
|
||||
* 周边渲染
|
||||
*
|
||||
* @param obstaclesInfo
|
||||
*/
|
||||
void onObstaclesInfo(ObstaclesInfo obstaclesInfo);
|
||||
|
||||
/**
|
||||
* 车道线渲染
|
||||
*
|
||||
* @param carLaneInfo
|
||||
*/
|
||||
void onCarLaneInfo(CarLaneInfo carLaneInfo);
|
||||
|
||||
/**
|
||||
* 自动驾驶状态
|
||||
*
|
||||
* @param autopilotStatus
|
||||
*/
|
||||
void autopilotStatus(AutopilotStatus autopilotStatus);
|
||||
|
||||
/**
|
||||
* 自动驾驶到站
|
||||
*
|
||||
* @param autopilotWayArrive
|
||||
*/
|
||||
void autopilotArrive(AutopilotWayArrive autopilotWayArrive);
|
||||
/**
|
||||
* 接收到FPGA端发来的数据
|
||||
*
|
||||
* @param msg json格式
|
||||
*/
|
||||
//void onMessage(String msg);
|
||||
|
||||
/**
|
||||
* 自动驾驶路径
|
||||
*
|
||||
* @param route
|
||||
*/
|
||||
void onAutopilotRoute(AutopilotRoute route);
|
||||
|
||||
/**
|
||||
* 自动驾驶局部轨迹
|
||||
*
|
||||
* @param trajectoryList
|
||||
*/
|
||||
void onAutopilotTrajectory(List<TrajectoryInfo> trajectoryList);
|
||||
|
||||
/**
|
||||
* 工控机获取SN
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
void onAutopilotSNRequest();
|
||||
|
||||
/**
|
||||
* 工控机监控节点
|
||||
*/
|
||||
void onAutopilotGuardian(AutopilotGuardianInfo guardianInfo);
|
||||
|
||||
/**
|
||||
* 数据采集结果
|
||||
*/
|
||||
void onAutopilotRecord(AutopilotRecordResult result);
|
||||
|
||||
/**
|
||||
* 向IPC发送命令返回结果
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void onSSHResult(SSHResult info);
|
||||
|
||||
/**
|
||||
* 升级状态
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void onUpgradeStateInfo(IPCUpgradeStateInfo info);
|
||||
|
||||
/**
|
||||
* 升级包下载进度 0%~100%
|
||||
*
|
||||
* @param info
|
||||
*/
|
||||
void onUpgradePatchDownloadStatus(IPCUpgradePatchDownloadStatusInfo info);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import com.zhidao.support.adas.high.BuildConfig;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/10/13
|
||||
*/
|
||||
public class AdasConfig {
|
||||
private static final String VERSION = BuildConfig.VERSION_NAME;
|
||||
private static final String AP_VERSION = BuildConfig.AP_VERSION;
|
||||
private String address;
|
||||
private String dockVersion;
|
||||
|
||||
/**
|
||||
* MoGo-AP 版本
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAPVersion() {
|
||||
return AP_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* SDK版本
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getVersion() {
|
||||
return VERSION;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getDockVersion() {
|
||||
return dockVersion;
|
||||
}
|
||||
|
||||
public void setDockVersion(String dockVersion) {
|
||||
this.dockVersion = dockVersion;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des
|
||||
* @date 2020/7/14
|
||||
*/
|
||||
|
||||
public class AutopilotConfig implements Serializable {
|
||||
|
||||
private String action;
|
||||
private ResultBean result;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public ResultBean getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotWayArrive{" +
|
||||
"action='" + action + '\'' +
|
||||
", result=" + result +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ResultBean {
|
||||
private String dock_version;
|
||||
|
||||
public String getDock_version() {
|
||||
return dock_version;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResultBean{" +
|
||||
"dock_version='" + dock_version + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des mode 0是手动 1是自动
|
||||
* @date 2020/7/14
|
||||
*/
|
||||
|
||||
public class AutopilotControl implements Serializable {
|
||||
|
||||
/**
|
||||
* action : autopilotmode
|
||||
* values : {"mode":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;
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
/**
|
||||
* mode : 0
|
||||
*/
|
||||
|
||||
private int mode;
|
||||
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public void setMode(int mode) {
|
||||
this.mode = mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/6/21
|
||||
*/
|
||||
|
||||
public class AutopilotRoute {
|
||||
|
||||
@SerializedName("action")
|
||||
private String action;
|
||||
@SerializedName("models")
|
||||
private List<RouteModels> models;
|
||||
|
||||
public static class RouteModels {
|
||||
@SerializedName("lat")
|
||||
private Double lat;
|
||||
@SerializedName("lon")
|
||||
private Double lon;
|
||||
|
||||
public Double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(Double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public Double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(Double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RouteModels{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public List<RouteModels> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
public void setModels(List<RouteModels> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotRoute{" +
|
||||
"action='" + action + '\'' +
|
||||
", models=" + models +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/7/2
|
||||
*/
|
||||
public class AutopilotSnRequest {
|
||||
private String action;
|
||||
private String models;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
public void setModels(String models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/12/6
|
||||
*/
|
||||
public class AutopilotSpeedParam {
|
||||
private final String action = "autospeed";
|
||||
private SpeedParam result;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed){
|
||||
if (result==null){
|
||||
result = new SpeedParam();
|
||||
}
|
||||
result.setSpeed(speed);
|
||||
}
|
||||
|
||||
public static class SpeedParam {
|
||||
//车辆速度 m/s
|
||||
private double speed;
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) {
|
||||
// speed km/h
|
||||
// this.speed m/s
|
||||
this.speed = speed/3.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des
|
||||
* @date 2020/7/14
|
||||
*/
|
||||
public class AutopilotStatus implements Serializable {
|
||||
|
||||
/**
|
||||
* action : autopilotstate
|
||||
* values : {"state":0,"reason":""}
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
/**
|
||||
* 0是不可用 1是ready 2是自动驾驶start
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int state;
|
||||
/**
|
||||
* 车速 m/s
|
||||
*/
|
||||
private float speed;
|
||||
/**
|
||||
* 不可用原因
|
||||
*/
|
||||
private String reason;
|
||||
/**
|
||||
* 摄像头状态 1代表开启,0代表关闭
|
||||
*/
|
||||
private int camera;
|
||||
/**
|
||||
* 雷达状态 1代表开启,0代表关闭
|
||||
*/
|
||||
private int radar;
|
||||
/**
|
||||
* RTK状态 1代表开启,0代表关闭
|
||||
*/
|
||||
private int rtk;
|
||||
/**
|
||||
* 自动驾驶状态 0非自动驾驶,1自动驾驶
|
||||
*/
|
||||
private int pilotmode;
|
||||
|
||||
/**
|
||||
* 自动驾驶车控状态
|
||||
*/
|
||||
private int control_pilotmode;
|
||||
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public float getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(float speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
public int getCamera() {
|
||||
return camera;
|
||||
}
|
||||
|
||||
public int getRadar() {
|
||||
return radar;
|
||||
}
|
||||
|
||||
public int getRtk() {
|
||||
return rtk;
|
||||
}
|
||||
|
||||
public int getPilotmode() {
|
||||
return pilotmode;
|
||||
}
|
||||
|
||||
public int getControl_pilotmode() {
|
||||
return control_pilotmode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValuesBean{" +
|
||||
"state=" + state +
|
||||
", speed=" + speed +
|
||||
", reason='" + reason + '\'' +
|
||||
", camera=" + camera +
|
||||
", radar=" + radar +
|
||||
", rtk=" + rtk +
|
||||
", pilotmode=" + pilotmode +
|
||||
", control_pilotmode=" + control_pilotmode +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotStatus{" +
|
||||
"action='" + action + '\'' +
|
||||
", values=" + values +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/10/19
|
||||
*/
|
||||
public class AutopilotTrajectory {
|
||||
|
||||
@SerializedName("action")
|
||||
private String action;
|
||||
@SerializedName("models")
|
||||
private List<TrajectoryInfo> models;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public List<TrajectoryInfo> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotTrajectory{" +
|
||||
"action='" + action + '\'' +
|
||||
", models=" + models +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des
|
||||
* @date 2020/7/14
|
||||
*/
|
||||
|
||||
public class AutopilotWayArrive implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* action : autopilotArrive
|
||||
* result : {"carType":0,"endLatLon":{"lat":116.7559675438664,"lon":116.7559675438664}}
|
||||
*/
|
||||
|
||||
private String action;
|
||||
private ResultBean result;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ResultBean getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ResultBean result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotWayArrive{" +
|
||||
"action='" + action + '\'' +
|
||||
", result=" + result +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ResultBean {
|
||||
/**
|
||||
* carType : 0
|
||||
* endLatLon : {"lat":116.7559675438664,"lon":116.7559675438664}
|
||||
*/
|
||||
|
||||
private int carType;
|
||||
private EndLatLonBean endLatLon;
|
||||
|
||||
|
||||
public int getCarType() {
|
||||
return carType;
|
||||
}
|
||||
|
||||
public void setCarType(int carType) {
|
||||
this.carType = carType;
|
||||
}
|
||||
|
||||
public EndLatLonBean getEndLatLon() {
|
||||
return endLatLon;
|
||||
}
|
||||
|
||||
public void setEndLatLon(EndLatLonBean endLatLon) {
|
||||
this.endLatLon = endLatLon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ResultBean{" +
|
||||
"carType=" + carType +
|
||||
", endLatLon=" + endLatLon +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class EndLatLonBean {
|
||||
/**
|
||||
* lat : 116.7559675438664
|
||||
* lon : 116.7559675438664
|
||||
*/
|
||||
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EndLatLonBean{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
public abstract class BaseInfo<T> {
|
||||
protected String action;
|
||||
protected T values;
|
||||
|
||||
|
||||
public BaseInfo(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public T getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(T values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* 7.5. 自动驾驶设备基础信息
|
||||
*/
|
||||
public class BasicInfo {
|
||||
private String action = "basicinfo";
|
||||
private Values values;
|
||||
|
||||
public void setSn(String sn) {
|
||||
if (values == null) {
|
||||
values = new Values();
|
||||
}
|
||||
values.setSn(sn);
|
||||
}
|
||||
|
||||
public void setTileid(String tileid) {
|
||||
if (values == null) {
|
||||
values = new Values();
|
||||
}
|
||||
values.setTileid(tileid);
|
||||
}
|
||||
|
||||
public void setNetEnvironment(int environment) {
|
||||
if (values == null) {
|
||||
values = new Values();
|
||||
}
|
||||
values.setNetEnvironment(environment);
|
||||
}
|
||||
|
||||
private static class Values {
|
||||
private String sn;
|
||||
private String tileid;
|
||||
//研发环境 1;测试环境 2;生产环境 3;演示环境 4;
|
||||
private int netEnvironment;
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public String getTileid() {
|
||||
return tileid;
|
||||
}
|
||||
|
||||
public void setTileid(String tileid) {
|
||||
this.tileid = tileid;
|
||||
}
|
||||
|
||||
public int getNetEnvironment() {
|
||||
return netEnvironment;
|
||||
}
|
||||
|
||||
public void setNetEnvironment(int environment) {
|
||||
this.netEnvironment = environment;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 车道线
|
||||
* @date 2020/4/24
|
||||
*/
|
||||
public class CarLaneInfo {
|
||||
|
||||
private String action;
|
||||
|
||||
private List<CarLaneDetailInfo> models;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public List<CarLaneDetailInfo> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
public void setModels(List<CarLaneDetailInfo> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
public static class CarLaneDetailInfo {
|
||||
private String id; //50~55, 50左黄,51左红,(52左白),53右黄,54右红,(55右白)
|
||||
private String type;
|
||||
private int color; //0白色,1黄色
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 车辆状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class CarStateInfo implements Serializable {
|
||||
|
||||
|
||||
/**
|
||||
* action : “state”
|
||||
* values : {"lon":116.8,"lat":39.4,"alt":22.3,"heading":87.5,"acceleration":0.5,"yaw_rate":0.3}
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
/**
|
||||
* lon : 116.8
|
||||
* lat : 39.4
|
||||
* alt : 22.3
|
||||
* heading : 87.5
|
||||
* acceleration : 0.5
|
||||
* yaw_rate : 0.3
|
||||
*/
|
||||
|
||||
private double lon;
|
||||
private double lat;
|
||||
private double alt;
|
||||
private double heading;
|
||||
private double acceleration;
|
||||
private double yaw_rate;
|
||||
//惯导车速 m/s
|
||||
private float gnss_speed;
|
||||
//车辆车速 m/s
|
||||
private float vehicle_speed;
|
||||
//gps时间
|
||||
private String satelliteTime;
|
||||
//UTC时间差
|
||||
private long utcTimeDiffer;
|
||||
//系统时间
|
||||
private String systemTime;
|
||||
//接收到数据的时间
|
||||
private String receiverDataTime;
|
||||
//接收到gps时间
|
||||
private String adasSatelliteTime;
|
||||
//开始接收数据时间
|
||||
private String startReceiverDataTime;
|
||||
//时间延迟
|
||||
private long timeDiff=0;
|
||||
private int turn_light; //转向灯状态 0是正常 1是左转 2是右转
|
||||
private int flash_light; //双闪灯状态
|
||||
private int brake_light; //刹车灯状态
|
||||
private int frame_num;//统计发包个数
|
||||
|
||||
public int getFrame_num() {
|
||||
return frame_num;
|
||||
}
|
||||
|
||||
public void setFrame_num(int frame_num) {
|
||||
this.frame_num = frame_num;
|
||||
}
|
||||
|
||||
public long getTimeDiff() {
|
||||
return timeDiff;
|
||||
}
|
||||
|
||||
public void setTimeDiff(long timeDiff) {
|
||||
this.timeDiff = timeDiff;
|
||||
}
|
||||
|
||||
public String getReceiverDataTime() {
|
||||
return receiverDataTime;
|
||||
}
|
||||
|
||||
public void setReceiverDataTime(String receiverDataTime) {
|
||||
this.receiverDataTime = receiverDataTime;
|
||||
}
|
||||
|
||||
public String getAdasSatelliteTime() {
|
||||
return adasSatelliteTime;
|
||||
}
|
||||
|
||||
public void setAdasSatelliteTime(String adasSatelliteTime) {
|
||||
this.adasSatelliteTime = adasSatelliteTime;
|
||||
}
|
||||
|
||||
public String getSystemTime() {
|
||||
return systemTime;
|
||||
}
|
||||
|
||||
public void setSystemTime(String systemTime) {
|
||||
this.systemTime = systemTime;
|
||||
}
|
||||
|
||||
public float getGnss_speed() {
|
||||
return gnss_speed;
|
||||
}
|
||||
|
||||
public void setGnss_speed(float gnss_speed) {
|
||||
this.gnss_speed = gnss_speed;
|
||||
}
|
||||
|
||||
public float getVehicle_speed() {
|
||||
return vehicle_speed;
|
||||
}
|
||||
|
||||
public void setVehicle_speed(float vehicle_speed) {
|
||||
this.vehicle_speed = vehicle_speed;
|
||||
}
|
||||
|
||||
public int getTurn_light() {
|
||||
return turn_light;
|
||||
}
|
||||
|
||||
public void setTurn_light(int turn_light) {
|
||||
this.turn_light = turn_light;
|
||||
}
|
||||
|
||||
public int getFlash_light() {
|
||||
return flash_light;
|
||||
}
|
||||
|
||||
public void setFlash_light(int flash_light) {
|
||||
this.flash_light = flash_light;
|
||||
}
|
||||
|
||||
public int getBrake_light() {
|
||||
return brake_light;
|
||||
}
|
||||
|
||||
public void setBrake_light(int brake_light) {
|
||||
this.brake_light = brake_light;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt(double alt) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public double getAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
public void setAcceleration(double acceleration) {
|
||||
this.acceleration = acceleration;
|
||||
}
|
||||
|
||||
public double getYaw_rate() {
|
||||
return yaw_rate;
|
||||
}
|
||||
|
||||
public void setYaw_rate(double yaw_rate) {
|
||||
this.yaw_rate = yaw_rate;
|
||||
}
|
||||
|
||||
public String getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
public void setSatelliteTime(String satelliteTime) {
|
||||
this.satelliteTime = satelliteTime;
|
||||
}
|
||||
|
||||
public long getUtcTimeDiffer() {
|
||||
return utcTimeDiffer;
|
||||
}
|
||||
|
||||
public void setUtcTimeDiffer(long utcTimeDiffer) {
|
||||
this.utcTimeDiffer = utcTimeDiffer;
|
||||
}
|
||||
|
||||
public String getStartReceiverDataTime() {
|
||||
return startReceiverDataTime;
|
||||
}
|
||||
|
||||
public void setStartReceiverDataTime(String startReceiverDataTime) {
|
||||
this.startReceiverDataTime = startReceiverDataTime;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValuesBean{" +
|
||||
"lon=" + lon +
|
||||
", lat=" + lat +
|
||||
", alt=" + alt +
|
||||
", heading=" + heading +
|
||||
", acceleration=" + acceleration +
|
||||
", yaw_rate=" + yaw_rate +
|
||||
", gnss_speed=" + gnss_speed +
|
||||
", vehicle_speed=" + vehicle_speed +
|
||||
", satelliteTime='" + satelliteTime + '\'' +
|
||||
", utcTimeDiffer='" + utcTimeDiffer + '\'' +
|
||||
", systemTime='" + systemTime + '\'' +
|
||||
", receiverDataTime='" + receiverDataTime + '\'' +
|
||||
", startReceiverDataTime='" + startReceiverDataTime + '\'' +
|
||||
", timeDiff=" + timeDiff +
|
||||
", turn_light=" + turn_light +
|
||||
", flash_light=" + flash_light +
|
||||
", brake_light=" + brake_light +
|
||||
", frame_num=" + frame_num +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CarStateInfo{" +
|
||||
"action='" + action + '\'' +
|
||||
", values=" + values +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
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
@@ -0,0 +1,62 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* 工控机升级
|
||||
*/
|
||||
public class IPCUpgradeInfo extends BaseInfo<IPCUpgradeInfo.Values> {
|
||||
public IPCUpgradeInfo() {
|
||||
super("ipc_upgrade");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户不同意升级
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static IPCUpgradeInfo cancel() {
|
||||
IPCUpgradeInfo info = new IPCUpgradeInfo();
|
||||
info.values = new IPCUpgradeInfo.Values();
|
||||
info.values.state = 0;
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户同意升级
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static IPCUpgradeInfo affirm() {
|
||||
IPCUpgradeInfo info = new IPCUpgradeInfo();
|
||||
info.values = new IPCUpgradeInfo.Values();
|
||||
info.values.state = 1;
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级流程完成确认
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static IPCUpgradeInfo upgradeFinishAffirm() {
|
||||
IPCUpgradeInfo info = new IPCUpgradeInfo();
|
||||
info.values = new IPCUpgradeInfo.Values();
|
||||
info.values.state = 3;
|
||||
return info;
|
||||
}
|
||||
|
||||
public static class Values {
|
||||
/**
|
||||
* 0 不同意升级
|
||||
* 1 同意升级
|
||||
*/
|
||||
private int state;
|
||||
|
||||
public int getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* 工控机升级包下载
|
||||
*/
|
||||
public class IPCUpgradePatchDownloadStatusInfo extends BaseInfo<IPCUpgradePatchDownloadStatusInfo.Values> {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
public enum Status {
|
||||
/**
|
||||
* 下载完成
|
||||
*/
|
||||
FINISHED(0, "完成"),
|
||||
/**
|
||||
* 正在下载
|
||||
*/
|
||||
DOWNLOADING(1, "正在下载"),
|
||||
/**
|
||||
* 下载失败
|
||||
*/
|
||||
FAILED(2, "下载失败");
|
||||
public final int code;
|
||||
public final String describe;
|
||||
|
||||
private Status(int code, String describe) {
|
||||
this.code = code;
|
||||
this.describe = describe;
|
||||
}
|
||||
|
||||
public static Status getStatus(int code) {
|
||||
switch (code) {
|
||||
default:
|
||||
case 0:
|
||||
return FINISHED;
|
||||
case 1:
|
||||
return DOWNLOADING;
|
||||
case 2:
|
||||
return FAILED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IPCUpgradePatchDownloadStatusInfo(String action) {
|
||||
super(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载进度
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getDownloadProgress() {
|
||||
if (values == null) {
|
||||
//数据解析出错
|
||||
return -1;
|
||||
} else {
|
||||
return values.downloadProgress;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载状态
|
||||
*
|
||||
* @return {@link Status}
|
||||
*/
|
||||
public int getDownloadStatus() {
|
||||
if (values == null) {
|
||||
//数据解析出错
|
||||
return -1;
|
||||
} else {
|
||||
return values.downloadStatus;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载版本
|
||||
*/
|
||||
public String getDownloadVersion() {
|
||||
if (values == null) {
|
||||
//数据解析出错
|
||||
return null;
|
||||
} else {
|
||||
return values.downloadVersion;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Values {
|
||||
/**
|
||||
* 下载进度
|
||||
*/
|
||||
@SerializedName("progress")
|
||||
private int downloadProgress;
|
||||
/**
|
||||
* 是否下载完成 0:完成 1:正在下载 2:下载失败
|
||||
*/
|
||||
@SerializedName("status")
|
||||
private int downloadStatus;
|
||||
/**
|
||||
* 下载版本
|
||||
*/
|
||||
@SerializedName("version")
|
||||
private String downloadVersion;
|
||||
|
||||
|
||||
public void setDownloadProgress(int downloadProgress) {
|
||||
this.downloadProgress = downloadProgress;
|
||||
}
|
||||
|
||||
public void setDownloadStatus(int downloadStatus) {
|
||||
this.downloadStatus = downloadStatus;
|
||||
}
|
||||
|
||||
public void setDownloadVersion(String downloadVersion) {
|
||||
this.downloadVersion = downloadVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* 工控机升级状态
|
||||
*/
|
||||
public class IPCUpgradeStateInfo extends BaseInfo<IPCUpgradeStateInfo.Values> {
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
public enum Status {
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESSFUL(0, "升级成功"),
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAILED(1, "升级失败");
|
||||
public final int code;
|
||||
public final String describe;
|
||||
|
||||
private Status(int code, String describe) {
|
||||
this.code = code;
|
||||
this.describe = describe;
|
||||
}
|
||||
|
||||
public static Status getStatus(int code) {
|
||||
switch (code) {
|
||||
default:
|
||||
case 0:
|
||||
return FAILED;
|
||||
case 1:
|
||||
return SUCCESSFUL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IPCUpgradeStateInfo(String action) {
|
||||
super(action);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取升级状态
|
||||
*
|
||||
* @return @ {@link Status}
|
||||
*/
|
||||
public int getUpgradeStatus() {
|
||||
if (values == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return values.status;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Values {
|
||||
/**
|
||||
* 0 升级不成功
|
||||
* 1 升级成功
|
||||
*/
|
||||
private int status;
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 红绿灯状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class LightStatueInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* action : light
|
||||
* values : {"left":1,"right ":0,"straight":3,"u_turn":0,"left_time_remains":3,"right_time_remains":3,"straight_time_remains":3,"u_turn_time_remains":3}
|
||||
*/
|
||||
|
||||
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 "LightStatueInfo{" +
|
||||
"action='" + action + '\'' +
|
||||
", values=" + values +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
/**
|
||||
* left : 1
|
||||
* right : 0
|
||||
* straight : 3
|
||||
* u_turn : 0
|
||||
* left_time_remains : 3
|
||||
* right_time_remains : 3
|
||||
* straight_time_remains : 3
|
||||
* u_turn_time_remains : 3
|
||||
*/
|
||||
|
||||
private int left;
|
||||
private int right;
|
||||
private int straight;
|
||||
private int u_turn;
|
||||
private int left_time_remains;
|
||||
private int right_time_remains;
|
||||
private int straight_time_remains;
|
||||
private int u_turn_time_remains;
|
||||
|
||||
public int getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(int left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public int getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(int right) {
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
public int getStraight() {
|
||||
return straight;
|
||||
}
|
||||
|
||||
public void setStraight(int straight) {
|
||||
this.straight = straight;
|
||||
}
|
||||
|
||||
public int getU_turn() {
|
||||
return u_turn;
|
||||
}
|
||||
|
||||
public void setU_turn(int u_turn) {
|
||||
this.u_turn = u_turn;
|
||||
}
|
||||
|
||||
public int getLeft_time_remains() {
|
||||
return left_time_remains;
|
||||
}
|
||||
|
||||
public void setLeft_time_remains(int left_time_remains) {
|
||||
this.left_time_remains = left_time_remains;
|
||||
}
|
||||
|
||||
public int getRight_time_remains() {
|
||||
return right_time_remains;
|
||||
}
|
||||
|
||||
public void setRight_time_remains(int right_time_remains) {
|
||||
this.right_time_remains = right_time_remains;
|
||||
}
|
||||
|
||||
public int getStraight_time_remains() {
|
||||
return straight_time_remains;
|
||||
}
|
||||
|
||||
public void setStraight_time_remains(int straight_time_remains) {
|
||||
this.straight_time_remains = straight_time_remains;
|
||||
}
|
||||
|
||||
public int getU_turn_time_remains() {
|
||||
return u_turn_time_remains;
|
||||
}
|
||||
|
||||
public void setU_turn_time_remains(int u_turn_time_remains) {
|
||||
this.u_turn_time_remains = u_turn_time_remains;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValuesBean{" +
|
||||
"left=" + left +
|
||||
", right=" + right +
|
||||
", straight=" + straight +
|
||||
", u_turn=" + u_turn +
|
||||
", left_time_remains=" + left_time_remains +
|
||||
", right_time_remains=" + right_time_remains +
|
||||
", straight_time_remains=" + straight_time_remains +
|
||||
", u_turn_time_remains=" + u_turn_time_remains +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
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 +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 周边物体渲染
|
||||
* @date 2020/4/24
|
||||
*/
|
||||
public class ObstaclesInfo {
|
||||
|
||||
private String action;
|
||||
|
||||
private List<ObstaclesModelInfo> models;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public List<ObstaclesModelInfo> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
public void setModels(List<ObstaclesModelInfo> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
public static class ObstaclesModelInfo {
|
||||
|
||||
private String id; //50~55, 50左黄,51左红,(52左白),53右黄,54右红,(55右白)
|
||||
private String type;
|
||||
private double distance; //距离/米
|
||||
private double direction; //正前为0,左为90,后为180,右为270
|
||||
private double heading; //物体的朝向角,90~270属于逆向车辆
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public double getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public void setDirection(double direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high.bean
|
||||
* @ClassName: RectInfo
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/9 20:22
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/9 20:22
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class RectInfo {
|
||||
private String type;
|
||||
private String action;
|
||||
private List<RectBean> models;
|
||||
private float fps;
|
||||
|
||||
public float getFps() {
|
||||
return fps;
|
||||
}
|
||||
|
||||
public void setFps(float fps) {
|
||||
this.fps = fps;
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<RectBean> getModels() {
|
||||
return models;
|
||||
}
|
||||
|
||||
public void setModels(List<RectBean> models) {
|
||||
this.models = models;
|
||||
}
|
||||
|
||||
public static class RectBean {
|
||||
private int id;
|
||||
private double xl;
|
||||
private double xr;
|
||||
private double yb;
|
||||
private double yt;
|
||||
//距离x轴值
|
||||
private double distance_x;
|
||||
//距离y轴值
|
||||
private double distance_y;
|
||||
//type="car" 是车辆
|
||||
private String type;
|
||||
//纬度
|
||||
private double lat;
|
||||
//经度
|
||||
private double lon;
|
||||
//朝向
|
||||
private double heading;
|
||||
//系统时间
|
||||
private String systemTime;
|
||||
//gps 时间
|
||||
private String satelliteTime;
|
||||
//海拔高度
|
||||
private double alt;
|
||||
//车牌id
|
||||
private String carId;
|
||||
//uuid
|
||||
private String uuid;
|
||||
//color
|
||||
private String color;
|
||||
//speed
|
||||
private double speed;
|
||||
//危险等级 1 绿,2 黄,3 红
|
||||
private int drawlevel;
|
||||
//长
|
||||
private float length;
|
||||
//宽
|
||||
private float width;
|
||||
//高
|
||||
private float height;
|
||||
//驱动时间
|
||||
private String driverTime;
|
||||
/**
|
||||
* 数据来源精度 0 - 普通定位、1 - 高精定位
|
||||
*/
|
||||
public int dataAccuracy = 1;
|
||||
|
||||
/**
|
||||
* 实际距离,使用 distanceX 和 distanceY 计算
|
||||
*/
|
||||
public double distance;
|
||||
|
||||
public int getDataAccuracy() {
|
||||
return dataAccuracy;
|
||||
}
|
||||
|
||||
public void setDataAccuracy(int dataAccuracy) {
|
||||
this.dataAccuracy = dataAccuracy;
|
||||
}
|
||||
|
||||
public double getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public String getSystemTime() {
|
||||
return systemTime;
|
||||
}
|
||||
|
||||
public void setSystemTime(String systemTime) {
|
||||
this.systemTime = systemTime;
|
||||
}
|
||||
|
||||
public String getSatelliteTime() {
|
||||
return satelliteTime;
|
||||
}
|
||||
|
||||
public void setSatelliteTime(String satelliteTime) {
|
||||
this.satelliteTime = satelliteTime;
|
||||
}
|
||||
|
||||
public double getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public void setAlt(double alt) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public String getCarId() {
|
||||
return carId;
|
||||
}
|
||||
|
||||
public void setCarId(String carId) {
|
||||
this.carId = carId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public void setColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public float getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public void setLength(float length) {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public float getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(float width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public float getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(float height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public int getDrawlevel() {
|
||||
return drawlevel;
|
||||
}
|
||||
|
||||
public void setDrawlevel(int drawlevel) {
|
||||
this.drawlevel = drawlevel;
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return speed;
|
||||
}
|
||||
|
||||
public void setSpeed(double speed) {
|
||||
this.speed = speed;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getDistance_x() {
|
||||
return distance_x;
|
||||
}
|
||||
|
||||
public void setDistance_x(double distance_x) {
|
||||
this.distance_x = distance_x;
|
||||
}
|
||||
|
||||
public double getDistance_y() {
|
||||
return distance_y;
|
||||
}
|
||||
|
||||
public void setDistance_y(double distance_y) {
|
||||
this.distance_y = distance_y;
|
||||
}
|
||||
|
||||
public double getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public void setHeading(double heading) {
|
||||
this.heading = heading;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public double getXl() {
|
||||
return xl;
|
||||
}
|
||||
|
||||
public void setXl(double xl) {
|
||||
this.xl = xl;
|
||||
}
|
||||
|
||||
public double getXr() {
|
||||
return xr;
|
||||
}
|
||||
|
||||
public void setXr(double xr) {
|
||||
this.xr = xr;
|
||||
}
|
||||
|
||||
public double getYb() {
|
||||
return yb;
|
||||
}
|
||||
|
||||
public void setYb(double yb) {
|
||||
this.yb = yb;
|
||||
}
|
||||
|
||||
public double getYt() {
|
||||
return yt;
|
||||
}
|
||||
|
||||
public void setYt(double yt) {
|
||||
this.yt = yt;
|
||||
}
|
||||
|
||||
public String getDriverTime() {
|
||||
return driverTime;
|
||||
}
|
||||
|
||||
public void setDriverTime(String driverTime) {
|
||||
this.driverTime = driverTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RectBean{" +
|
||||
"id=" + id +
|
||||
", xl=" + xl +
|
||||
", xr=" + xr +
|
||||
", yb=" + yb +
|
||||
", yt=" + yt +
|
||||
", distance_x=" + distance_x +
|
||||
", distance_y=" + distance_y +
|
||||
", type='" + type + '\'' +
|
||||
", lat=" + lat +
|
||||
", lon=" + lon +
|
||||
", heading=" + heading +
|
||||
", systemTime='" + systemTime + '\'' +
|
||||
", satelliteTime='" + satelliteTime + '\'' +
|
||||
", alt=" + alt +
|
||||
", carId='" + carId + '\'' +
|
||||
", uuid='" + uuid + '\'' +
|
||||
", color='" + color + '\'' +
|
||||
", speed=" + speed +
|
||||
", drawlevel=" + drawlevel +
|
||||
", length=" + length +
|
||||
", width=" + width +
|
||||
", height=" + height +
|
||||
", driverTime=" + driverTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RectInfo{" +
|
||||
", action='" + action + '\'' +
|
||||
", models=" + models +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/16
|
||||
*
|
||||
* 自动驾驶参数
|
||||
*/
|
||||
class RemoteControlAutoPilotParameters {
|
||||
|
||||
private String action;
|
||||
|
||||
private RemoteControlAutoPilotParameters.ValuesBean result;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public ValuesBean getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(ValuesBean result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RemoteControlAutoPilotParameters{" +
|
||||
"action='" + action + '\'' +
|
||||
", result=" + result +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class ValuesBean {
|
||||
public AutoPilotLonLat startLatLon;
|
||||
public List< AutoPilotLonLat > wayLatLons;
|
||||
public AutoPilotLonLat endLatLon;
|
||||
public float speedLimit;
|
||||
public int vehicleType;// 运营类型
|
||||
|
||||
public static class AutoPilotLonLat {
|
||||
public double lat;
|
||||
public double lon;
|
||||
|
||||
public AutoPilotLonLat() {
|
||||
}
|
||||
|
||||
public AutoPilotLonLat( double lat, double lon ) {
|
||||
this.lat = lat;
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public void setLon(double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutoPilotLonLat{" +
|
||||
"lat=" + lat +
|
||||
", lon=" + lon +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AutoPilotLonLat getStartLatLon() {
|
||||
return startLatLon;
|
||||
}
|
||||
|
||||
public void setStartLatLon(AutoPilotLonLat startLatLon) {
|
||||
this.startLatLon = startLatLon;
|
||||
}
|
||||
|
||||
public List<AutoPilotLonLat> getWayLatLons() {
|
||||
return wayLatLons;
|
||||
}
|
||||
|
||||
public void setWayLatLons(List<AutoPilotLonLat> wayLatLons) {
|
||||
this.wayLatLons = wayLatLons;
|
||||
}
|
||||
|
||||
public AutoPilotLonLat getEndLatLon() {
|
||||
return endLatLon;
|
||||
}
|
||||
|
||||
public void setEndLatLon(AutoPilotLonLat endLatLon) {
|
||||
this.endLatLon = endLatLon;
|
||||
}
|
||||
|
||||
public float getSpeedLimit() {
|
||||
return speedLimit;
|
||||
}
|
||||
|
||||
public void setSpeedLimit(float speedLimit) {
|
||||
this.speedLimit = speedLimit;
|
||||
}
|
||||
|
||||
public int getVehicleType() {
|
||||
return vehicleType;
|
||||
}
|
||||
|
||||
public void setVehicleType(int vehicleType) {
|
||||
this.vehicleType = vehicleType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RemoteControlAutoPilotParameters{" +
|
||||
"startLatLon=" + startLatLon +
|
||||
", wayLatLons=" + wayLatLons +
|
||||
", endLatLon=" + endLatLon +
|
||||
", speedLimit=" + speedLimit +
|
||||
", vehicleType=" + vehicleType +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/12/7
|
||||
*/
|
||||
public class RouteInfo {
|
||||
|
||||
private String id;
|
||||
|
||||
private double startLat;
|
||||
|
||||
private double startLon;
|
||||
|
||||
private double endLat;
|
||||
|
||||
private double endLon;
|
||||
|
||||
private String path;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* SSH返回结果
|
||||
*/
|
||||
public class SSHResult {
|
||||
|
||||
public interface RESULT_CODE {
|
||||
/**
|
||||
* 工控机IP未知
|
||||
*/
|
||||
int IP_UNKNOWN = -2;
|
||||
/**
|
||||
* 网络异常或连接异常或IO异常
|
||||
*/
|
||||
int ERROR = -1;
|
||||
/**
|
||||
* 命令下发成功
|
||||
*/
|
||||
int SEND_SUCCEED = 0;
|
||||
/**
|
||||
* 其他值根据Shell返回结果而定 >0
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
public final int code;
|
||||
public final String cmd;
|
||||
public final String msg;
|
||||
|
||||
public SSHResult(int code, String cmd, String msg) {
|
||||
this.code = code;
|
||||
this.cmd = cmd;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/10/21
|
||||
*/
|
||||
public class TrajectoryInfo {
|
||||
//经度
|
||||
@SerializedName("lon")
|
||||
private Double lon;
|
||||
//纬度
|
||||
@SerializedName("lat")
|
||||
private Double lat;
|
||||
//高度
|
||||
@SerializedName("alt")
|
||||
private Double alt;
|
||||
//时间 秒s
|
||||
@SerializedName("time")
|
||||
private Double time;
|
||||
//速度 m/s
|
||||
@SerializedName("velocity")
|
||||
private Double velocity;
|
||||
//加速度
|
||||
@SerializedName("acceleration")
|
||||
private Double acceleration;
|
||||
//速度方向
|
||||
@SerializedName("theta")
|
||||
private Double theta;
|
||||
//曲率
|
||||
@SerializedName("kappa")
|
||||
private Double kappa;
|
||||
//从起点到目前的总距离
|
||||
@SerializedName("accumulated_dis")
|
||||
private Double accumulatedDis;
|
||||
|
||||
public void setLon(Double lon) {
|
||||
this.lon = lon;
|
||||
}
|
||||
|
||||
public void setLat(Double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public void setAlt(Double alt) {
|
||||
this.alt = alt;
|
||||
}
|
||||
|
||||
public void setTime(Double time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setVelocity(Double velocity) {
|
||||
this.velocity = velocity;
|
||||
}
|
||||
|
||||
public void setAcceleration(Double acceleration) {
|
||||
this.acceleration = acceleration;
|
||||
}
|
||||
|
||||
public void setTheta(Double theta) {
|
||||
this.theta = theta;
|
||||
}
|
||||
|
||||
public void setKappa(Double kappa) {
|
||||
this.kappa = kappa;
|
||||
}
|
||||
|
||||
public void setAccumulatedDis(Double accumulatedDis) {
|
||||
this.accumulatedDis = accumulatedDis;
|
||||
}
|
||||
|
||||
public Double getLon() {
|
||||
return lon;
|
||||
}
|
||||
|
||||
public Double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public Double getAlt() {
|
||||
return alt;
|
||||
}
|
||||
|
||||
public Double getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public Double getVelocity() {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
public Double getAcceleration() {
|
||||
return acceleration;
|
||||
}
|
||||
|
||||
public Double getTheta() {
|
||||
return theta;
|
||||
}
|
||||
|
||||
public Double getKappa() {
|
||||
return kappa;
|
||||
}
|
||||
|
||||
public Double getAccumulatedDis() {
|
||||
return accumulatedDis;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TrajectoryModels{" +
|
||||
"lon=" + lon +
|
||||
", lat=" + lat +
|
||||
", alt=" + alt +
|
||||
", time='" + time + '\'' +
|
||||
", velocity=" + velocity +
|
||||
", acceleration=" + acceleration +
|
||||
", theta=" + theta +
|
||||
", kappa=" + kappa +
|
||||
", accumulatedDis=" + accumulatedDis +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high.bean
|
||||
* @ClassName: WarnMessageInfo
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/9 20:40
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/9 20:40
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class WarnMessageInfo {
|
||||
/**
|
||||
* content : 小心前车
|
||||
* level : 2
|
||||
* type : 20
|
||||
* value :
|
||||
*/
|
||||
|
||||
private String content;
|
||||
private String level;
|
||||
private String type;
|
||||
private String value;
|
||||
|
||||
public WarnMessageInfo() {
|
||||
}
|
||||
|
||||
public WarnMessageInfo(String type, String content, String value, String level) {
|
||||
this.type = type;
|
||||
this.content = content;
|
||||
this.value = value;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(String level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WarnMessageInfo{" +
|
||||
"content='" + content + '\'' +
|
||||
", level='" + level + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.zhidao.support.adas.high.bean.guardian;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author songkenan
|
||||
* @des 节点监控
|
||||
* @date 2021/7/7
|
||||
*/
|
||||
public class AutopilotGuardianInfo implements Serializable {
|
||||
//接口名称
|
||||
@SerializedName("action")
|
||||
private String action;
|
||||
//监控项名称
|
||||
@SerializedName("agentName")
|
||||
private String agentName;
|
||||
//车牌号
|
||||
@SerializedName("carNum")
|
||||
private String carNum;
|
||||
//车型
|
||||
@SerializedName("carType")
|
||||
private String carType;
|
||||
//monitorType
|
||||
@SerializedName("monitorType")
|
||||
private String monitorType;
|
||||
//sn
|
||||
@SerializedName("sn")
|
||||
private String sn;
|
||||
//时间
|
||||
@SerializedName("time")
|
||||
private long time;
|
||||
@SerializedName("modules")
|
||||
private GuardianModule modules;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public String getAgentName() {
|
||||
return agentName;
|
||||
}
|
||||
|
||||
public void setAgentName(String agentName) {
|
||||
this.agentName = agentName;
|
||||
}
|
||||
|
||||
public String getCarNum() {
|
||||
return carNum;
|
||||
}
|
||||
|
||||
public void setCarNum(String carNum) {
|
||||
this.carNum = carNum;
|
||||
}
|
||||
|
||||
public String getCarType() {
|
||||
return carType;
|
||||
}
|
||||
|
||||
public void setCarType(String carType) {
|
||||
this.carType = carType;
|
||||
}
|
||||
|
||||
public String getMonitorType() {
|
||||
return monitorType;
|
||||
}
|
||||
|
||||
public void setMonitorType(String monitorType) {
|
||||
this.monitorType = monitorType;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public void setSn(String sn) {
|
||||
this.sn = sn;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public GuardianModule getModules() {
|
||||
return modules;
|
||||
}
|
||||
|
||||
public void setModules(GuardianModule modules) {
|
||||
this.modules = modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotGuardianInfo{" +
|
||||
"action='" + action + '\'' +
|
||||
", agentName='" + agentName + '\'' +
|
||||
", carNum='" + carNum + '\'' +
|
||||
", carType='" + carType + '\'' +
|
||||
", monitorType='" + monitorType + '\'' +
|
||||
", modules=" + modules +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.zhidao.support.adas.high.bean.guardian;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/12/10
|
||||
*/
|
||||
public class GuardianItem {
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("value")
|
||||
private String value;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GuardianItem{" +
|
||||
"name='" + name + '\'' +
|
||||
", value='" + value + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.zhidao.support.adas.high.bean.guardian;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/12/10
|
||||
*/
|
||||
public class GuardianItemsName {
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("items")
|
||||
private List<GuardianItem> items;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public List<GuardianItem> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public void setItems(List<GuardianItem> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GuardianItemsName{" +
|
||||
"name='" + name + '\'' +
|
||||
", items=" + items +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.zhidao.support.adas.high.bean.guardian;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/12/10
|
||||
*/
|
||||
public class GuardianModule {
|
||||
@SerializedName("itemsname")
|
||||
private List<GuardianItemsName> itemsname;
|
||||
@SerializedName("submodules")
|
||||
private List<GuardianSubmodule> submodules;
|
||||
|
||||
public List<GuardianItemsName> getItemsname() {
|
||||
return itemsname;
|
||||
}
|
||||
|
||||
public void setItemsname(List<GuardianItemsName> itemsname) {
|
||||
this.itemsname = itemsname;
|
||||
}
|
||||
|
||||
public List<GuardianSubmodule> getSubmodules() {
|
||||
return submodules;
|
||||
}
|
||||
|
||||
public void setSubmodules(List<GuardianSubmodule> submodules) {
|
||||
this.submodules = submodules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GuardianModule{" +
|
||||
"itemsname=" + itemsname +
|
||||
", submodules=" + submodules +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.zhidao.support.adas.high.bean.guardian;
|
||||
|
||||
import androidx.core.internal.view.SupportSubMenu;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/12/10
|
||||
*/
|
||||
public class GuardianSubmodule {
|
||||
@SerializedName("modulename")
|
||||
private String modulename;
|
||||
@SerializedName("subnodes")
|
||||
private List<Subnode> subnodes;
|
||||
|
||||
public String getModulename() {
|
||||
return modulename;
|
||||
}
|
||||
|
||||
public void setModulename(String modulename) {
|
||||
this.modulename = modulename;
|
||||
}
|
||||
|
||||
public List<Subnode> getSubnodes() {
|
||||
return subnodes;
|
||||
}
|
||||
|
||||
public void setSubnodes(List<Subnode> subnodes) {
|
||||
this.subnodes = subnodes;
|
||||
}
|
||||
|
||||
public static class Subnode {
|
||||
@SerializedName("nodename")
|
||||
private String nodename;
|
||||
@SerializedName("nodeitems")
|
||||
private List<GuardianItemsName> nodeitems;
|
||||
@SerializedName("topicitems")
|
||||
private List<GuardianItemsName> topicitems;
|
||||
|
||||
public String getNodename() {
|
||||
return nodename;
|
||||
}
|
||||
|
||||
public void setNodename(String nodename) {
|
||||
this.nodename = nodename;
|
||||
}
|
||||
|
||||
public List getNodeitems() {
|
||||
return nodeitems;
|
||||
}
|
||||
|
||||
public void setNodeitems(List nodeitems) {
|
||||
this.nodeitems = nodeitems;
|
||||
}
|
||||
|
||||
public List<GuardianItemsName> getTopicitems() {
|
||||
return topicitems;
|
||||
}
|
||||
|
||||
public void setTopicitems(List<GuardianItemsName> topicitems) {
|
||||
this.topicitems = topicitems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Subnode{" +
|
||||
"nodename='" + nodename + '\'' +
|
||||
", nodeitems=" + nodeitems +
|
||||
", topicitems=" + topicitems +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GuardianSubmodule{" +
|
||||
"modulename='" + modulename + '\'' +
|
||||
", subnodes=" + subnodes +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.zhidao.support.adas.high.bean.record;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/8/26
|
||||
*/
|
||||
public class AutopilotIdentifyInfo {
|
||||
|
||||
@SerializedName("action")
|
||||
private String action;
|
||||
@SerializedName("result")
|
||||
private Result result;
|
||||
|
||||
public static class Result {
|
||||
@SerializedName("panel")
|
||||
private AutopilotRecordResult panel;
|
||||
@SerializedName("passwd")
|
||||
private String passwd;
|
||||
@SerializedName("user")
|
||||
private String user;
|
||||
|
||||
public AutopilotRecordResult getPanel() {
|
||||
return panel;
|
||||
}
|
||||
|
||||
public void setPanel(AutopilotRecordResult panel) {
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
public String getPasswd() {
|
||||
return passwd;
|
||||
}
|
||||
|
||||
public void setPasswd(String passwd) {
|
||||
this.passwd = passwd;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(String action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotIdentifyInfo{" +
|
||||
"action='" + action + '\'' +
|
||||
", result=" + result +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.zhidao.support.adas.high.bean.record;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @ 自动驾驶数据采集结果
|
||||
* @date 2021/11/8
|
||||
*/
|
||||
public class AutopilotRecordResult {
|
||||
//磁盘可用空间(M)
|
||||
@SerializedName("disk_free")
|
||||
private Integer diskFree;
|
||||
//采集时长(秒)
|
||||
@SerializedName("duration")
|
||||
private double duration;
|
||||
//保存的文件名
|
||||
@SerializedName("filename")
|
||||
private String filename;
|
||||
//其他信息,包含错误信息等
|
||||
@SerializedName("note")
|
||||
private String note;
|
||||
//域控制器定义的bag key
|
||||
@SerializedName("key")
|
||||
private String key;
|
||||
//采集状态:100 - 采集成功,自动结束
|
||||
//101 - 采集成功,收到结束指令
|
||||
//102 -- 达到最大采集时长
|
||||
//103 --达到最大采集空间
|
||||
//200 - 采集失败
|
||||
//201 - 采集中
|
||||
//300 - 开始采集
|
||||
@SerializedName("stat")
|
||||
private int stat;
|
||||
//任务类型:1-badcase采集任务,2-地图数据采集任务
|
||||
@SerializedName("type")
|
||||
private int type;
|
||||
//任务id
|
||||
@SerializedName("id")
|
||||
private int id;
|
||||
//时间戳,格式:YYYY-MM-DD-hh-mm-ss
|
||||
@SerializedName("timestamp")
|
||||
private String timestamp;
|
||||
//此次数据总大小(M)
|
||||
@SerializedName("total_size")
|
||||
private Integer totalSize;
|
||||
//触发指令
|
||||
@SerializedName("triggerinfo")
|
||||
private Triggerinfo triggerinfo;
|
||||
//各topic数据量
|
||||
@SerializedName("records")
|
||||
private List<Records> records;
|
||||
|
||||
public static class Triggerinfo {
|
||||
//是否为人工接管时自动采集:true - 自动采集 false - 手动触发
|
||||
@SerializedName("auto_trig")
|
||||
private Boolean autoTrig;
|
||||
//触发采集附带的信息,如任务ID,时间戳等。若为自动采集则此项忽略
|
||||
@SerializedName("trig_msg")
|
||||
private String trigMsg;
|
||||
|
||||
public Boolean getAutoTrig() {
|
||||
return autoTrig;
|
||||
}
|
||||
|
||||
public String getTrigMsg() {
|
||||
return trigMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Triggerinfo{" +
|
||||
"autoTrig=" + autoTrig +
|
||||
", trigMsg='" + trigMsg + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
public static class Records {
|
||||
//数据记录数
|
||||
@SerializedName("nums")
|
||||
private Integer nums;
|
||||
//数据来源的topic名
|
||||
@SerializedName("topic")
|
||||
private String topic;
|
||||
|
||||
public Integer getNums() {
|
||||
return nums;
|
||||
}
|
||||
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Records{" +
|
||||
"nums=" + nums +
|
||||
", topic='" + topic + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getDiskFree() {
|
||||
return diskFree;
|
||||
}
|
||||
|
||||
public double getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public List<Records> getRecords() {
|
||||
return records;
|
||||
}
|
||||
|
||||
public int getStat() {
|
||||
return stat;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public Integer getTotalSize() {
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
public Triggerinfo getTriggerinfo() {
|
||||
return triggerinfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AutopilotRecordResult{" +
|
||||
"diskFree=" + diskFree +
|
||||
", duration=" + duration +
|
||||
", filename='" + filename + '\'' +
|
||||
", note='" + note + '\'' +
|
||||
", key='" + key + '\'' +
|
||||
", stat=" + stat +
|
||||
", type=" + type +
|
||||
", id=" + id +
|
||||
", timestamp='" + timestamp + '\'' +
|
||||
", totalSize=" + totalSize +
|
||||
", triggerinfo=" + triggerinfo +
|
||||
", records=" + records +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.zhidao.support.adas.high.bean.record;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/8/25
|
||||
*/
|
||||
|
||||
public class RecordCauseParam {
|
||||
private final String action = "record_cause";
|
||||
private Result result;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public static class Result{
|
||||
//bag key 唯一标识
|
||||
private String key;
|
||||
//文件路径
|
||||
private String filename;
|
||||
//接管原因
|
||||
private String reason;
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
public void setFilename(String filename) {
|
||||
this.filename = filename;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RecordDataParam{" +
|
||||
"action='" + action + '\'' +
|
||||
", result='" + result + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.zhidao.support.adas.high.bean.record;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/8/25
|
||||
*/
|
||||
|
||||
public class RecordDataParam {
|
||||
private final String action = "record_data";
|
||||
private Result result;
|
||||
|
||||
public String getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(Result result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public static class Result{
|
||||
//采集时间
|
||||
private String time;
|
||||
//采集指令 true 采集 , false 停止采集
|
||||
private boolean isRecord;
|
||||
//采集类型 1 badcase; 2 map; 3 rests
|
||||
private int type;
|
||||
//采集id
|
||||
private int id;
|
||||
//是否持续采集
|
||||
private boolean sustain;
|
||||
//采集时间长
|
||||
private int duration;
|
||||
//余留字段
|
||||
private String note;
|
||||
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(String time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public boolean getIsRecord() {
|
||||
return isRecord;
|
||||
}
|
||||
|
||||
public void setIsRecord(boolean isRecord) {
|
||||
this.isRecord = isRecord;
|
||||
}
|
||||
|
||||
public boolean isRecord() {
|
||||
return isRecord;
|
||||
}
|
||||
|
||||
public void setRecord(boolean record) {
|
||||
isRecord = record;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public boolean isSustain() {
|
||||
return sustain;
|
||||
}
|
||||
|
||||
public void setSustain(boolean sustain) {
|
||||
this.sustain = sustain;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
public void setDuration(int duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RecordDataParam{" +
|
||||
"action='" + action + '\'' +
|
||||
", result='" + result + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
/**
|
||||
* 接收的Action
|
||||
*
|
||||
* @author nie yunlong
|
||||
* @description 请求值
|
||||
* @date 2018/7/3
|
||||
*/
|
||||
public enum ActionTypeReceive {
|
||||
|
||||
/**
|
||||
* udp 消息渲染 action
|
||||
*/
|
||||
ACTION_WS_MSG_RENDER_TYPE("view", 0x101, "渲染流 渲染图像"),
|
||||
/**
|
||||
* 周边物体的状态
|
||||
*/
|
||||
ACTION_WS_OBSTACLES_MESSAGE_TYPE("obstacles", -1, "周边物体的状态"),
|
||||
/**
|
||||
* 车道线渲染
|
||||
*/
|
||||
ACTION_WS_LANES_MESSAGE_TYPE("lanes", -1, "车道线渲染"),
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
ACTION_WS_CAR_STATE_TYPE("state", 0x102, "车辆状态"),
|
||||
/**
|
||||
* ws 报警消息 action
|
||||
*/
|
||||
ACTION_WS_MSG_WARNING_TYPE("warn", -1, "ws 报警消息"),
|
||||
/**
|
||||
* 红绿灯状态
|
||||
*/
|
||||
ACTION_UDP_LIGHT_STATE_TYPE("light", -1, "udp 红绿灯状态"),
|
||||
/**
|
||||
* gps数据
|
||||
*/
|
||||
ACTION_WS_GPS_TYPE("gdgps", -1, "gps 数据"),
|
||||
/**
|
||||
* 自动驾驶状态
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_STATUE("autopilotstate", -1, "自动驾驶状态"),
|
||||
/**
|
||||
* 自动驾驶控制
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_CONTROL("autopilotmode", -1, "自动驾驶控制"),
|
||||
/**
|
||||
* obu红绿灯数据
|
||||
*/
|
||||
ACTION_WS_AI_CLOUD_OBU_RED_GREEN_LIGHT_TYPE("obuTrafficLight", -1, "obu红绿灯数据"),
|
||||
/**
|
||||
* ai云
|
||||
*/
|
||||
ACTION_WS_AI_CLOUD_TYPE("aiCloudToStartAutopilot", -1, "云端控制自动驾驶"),
|
||||
/**
|
||||
* 图片大小
|
||||
*/
|
||||
ACTION_WS_MSG_IMAGE_SIZE_TYPE("imagesize", -1, "ws 图片大小"),
|
||||
/**
|
||||
* ai云推送 在线车辆
|
||||
*/
|
||||
ACTION_WS_AI_CLOUD_ONLINE_CAR_TYPE("aiCloudToOnLineCar", -1, "云端推送在线车辆"),
|
||||
/**
|
||||
* 自动驾驶站点通信
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_WAY_ARRIVE("autopilotArrive", -1, "自动驾驶站点"),
|
||||
/**
|
||||
* 获取自动驾驶路径
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_ROUTE("global_path", -1, "自动驾驶路径"),
|
||||
/**
|
||||
* 查询自动驾驶路径
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_QUERY_ROUTE("query_global_path", -1, "查询自动驾驶路径"),
|
||||
/**
|
||||
* 工控机请求SN
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_SN_REQUEST("autopilotSN", -1, "工控机请求SN"),
|
||||
/**
|
||||
* 监控车辆节点
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_GUARDIAN("guardian", 0x105, "监控车辆节点"),
|
||||
/**
|
||||
* 采集信息
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_IDENTIFY("identify", -1, "FTP消息"),
|
||||
/**
|
||||
* 局部轨迹
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_TRAJECTORY("trajectory", 0x100, "局部轨迹"),
|
||||
/**
|
||||
* car dock 基础信息
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_CAR_CONFIG("car_config", -1, "car_config"),
|
||||
/**
|
||||
* 轨迹列表 routes
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_ROUTES("route_list", 0x104, "轨迹列表"),
|
||||
/**
|
||||
* 工控机升级包下载状态
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_UPGRADE_PATCH_DOWNLOAD_STATUS("ipc_upgrade_patch_download_status", -1, "IPC升级包下载状态"),
|
||||
/**
|
||||
* 工控机升级进度
|
||||
*/
|
||||
ACTION_WS_AUTOPILOT_UPGRADE_STATUS("ipc_upgrade_status", -1, "IPC升级状态");
|
||||
|
||||
/**
|
||||
* 消息action 类型
|
||||
*/
|
||||
String mActionType;
|
||||
|
||||
/**
|
||||
* 消息action code
|
||||
*/
|
||||
int mActionCode;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
String mMsgDesc;
|
||||
|
||||
ActionTypeReceive(String actionType, int actionCode, String msgDesc) {
|
||||
this.mActionType = actionType;
|
||||
this.mActionCode = actionCode;
|
||||
this.mMsgDesc = msgDesc;
|
||||
}
|
||||
|
||||
public String getmActionType() {
|
||||
return mActionType;
|
||||
}
|
||||
|
||||
public void setmActionType(String mActionType) {
|
||||
this.mActionType = mActionType;
|
||||
}
|
||||
|
||||
public int getmActionCode() {
|
||||
return mActionCode;
|
||||
}
|
||||
|
||||
public void setmActionCode(int mActionCode) {
|
||||
this.mActionCode = mActionCode;
|
||||
}
|
||||
|
||||
public String getmMsgDesc() {
|
||||
return mMsgDesc;
|
||||
}
|
||||
|
||||
public void setmMsgDesc(String mMsgDesc) {
|
||||
this.mMsgDesc = mMsgDesc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
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 java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Created by nie yunlong on 2018/4/13.
|
||||
* sharePreference 操作
|
||||
* 根据 具体情况来写
|
||||
*/
|
||||
|
||||
public class AppPreferenceHelper implements IPreferencesHelper {
|
||||
|
||||
public static AppPreferenceHelper appPreferenceHelper;
|
||||
/**
|
||||
* 保存deviceId 文件名称
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* 默认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}]}";
|
||||
|
||||
public static AppPreferenceHelper getInstance(Context context) {
|
||||
if (appPreferenceHelper == null) {
|
||||
appPreferenceHelper = new AppPreferenceHelper(context.getApplicationContext());
|
||||
}
|
||||
return appPreferenceHelper;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveUdpClientAddress(String address) {
|
||||
mDevicePre.edit().putString("upd_client_address", address).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUdpClientAddress() {
|
||||
return mDevicePre.getString("upd_client_address", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDockConfig(String dockConfig) {
|
||||
mDevicePre.edit().putString("dock_version", dockConfig).apply();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDockConfig() {
|
||||
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 FaceLoginResponse.DataBean getUserInfo() {
|
||||
return getUser(mUserLoginInfoPre, "userInfo");
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Created by nie yunlong on 2018/4/9.
|
||||
* IO 操作
|
||||
*/
|
||||
|
||||
public class BaseIoUtils {
|
||||
|
||||
public static final int DEFAULT_IMAGE_TOTAL_SIZE = 500 * 1024; // 500 Kb
|
||||
|
||||
/**
|
||||
* 从输入流中获取数据
|
||||
*
|
||||
* @param inStream 输入流
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static byte[] readInputStreamToByte(InputStream inStream) throws Exception {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, len);
|
||||
}
|
||||
inStream.close();
|
||||
return outStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从输入流中获取数据
|
||||
*
|
||||
* @param inStream 输入流
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String readInputStreamToString(InputStream inStream) throws Exception {
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[1024];
|
||||
int len = 0;
|
||||
while ((len = inStream.read(buffer)) != -1) {
|
||||
outStream.write(buffer, 0, len);
|
||||
}
|
||||
inStream.close();
|
||||
return outStream.toString("utf-8");
|
||||
}
|
||||
|
||||
public static void closeSilently(Closeable closeable) {
|
||||
|
||||
try {
|
||||
if (closeable != null) {
|
||||
closeable.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean copyStream(InputStream is, OutputStream os, int bufferSize)
|
||||
throws IOException {
|
||||
int current = 0;
|
||||
int total = is.available();
|
||||
if (total <= 0) {
|
||||
total = DEFAULT_IMAGE_TOTAL_SIZE;
|
||||
}
|
||||
|
||||
final byte[] bytes = new byte[bufferSize];
|
||||
int count;
|
||||
while ((count = is.read(bytes, 0, bufferSize)) != -1) {
|
||||
os.write(bytes, 0, count);
|
||||
current += count;
|
||||
}
|
||||
os.flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.os.StatFs;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BaseSDCardHelper {
|
||||
|
||||
// 判断SD卡是否被挂载
|
||||
public static boolean isSDCardMounted() {
|
||||
// return Environment.getExternalStorageState().equals("mounted");
|
||||
return Environment.getExternalStorageState().equals(
|
||||
Environment.MEDIA_MOUNTED);
|
||||
}
|
||||
|
||||
// 获取SD卡的根目录
|
||||
public static String getSDCardBaseDir() {
|
||||
if (isSDCardMounted()) {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// 获取SD卡的完整空间大小,返回MB
|
||||
public static long getSDCardSize() {
|
||||
if (isSDCardMounted()) {
|
||||
StatFs fs = new StatFs(getSDCardBaseDir());
|
||||
int count = fs.getBlockCount();
|
||||
int size = fs.getBlockSize();
|
||||
return count * size / 1024 / 1024;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 获取SD卡的剩余空间大小
|
||||
public static long getSDCardFreeSize() {
|
||||
if (isSDCardMounted()) {
|
||||
StatFs fs = new StatFs(getSDCardBaseDir());
|
||||
int count = fs.getFreeBlocks();
|
||||
int size = fs.getBlockSize();
|
||||
return count * size / 1024 / 1024;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 获取SD卡的可用空间大小
|
||||
public static long getSDCardAvailableSize() {
|
||||
if (isSDCardMounted()) {
|
||||
StatFs fs = new StatFs(getSDCardBaseDir());
|
||||
int count = fs.getAvailableBlocks();
|
||||
int size = fs.getBlockSize();
|
||||
return count * size / 1024 / 1024;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 往SD卡的公有目录下保存文件
|
||||
public static boolean saveFileToSDCardPublicDir(byte[] data, String type,
|
||||
String fileName) {
|
||||
BufferedOutputStream bos = null;
|
||||
if (isSDCardMounted()) {
|
||||
File file = Environment.getExternalStoragePublicDirectory(type);
|
||||
try {
|
||||
bos = new BufferedOutputStream(new FileOutputStream(new File(
|
||||
file, fileName)));
|
||||
bos.write(data);
|
||||
bos.flush();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 往SD卡的自定义目录下保存文件
|
||||
public static boolean saveFileToSDCardCustomDir(byte[] data, String dir,
|
||||
String fileName) {
|
||||
BufferedOutputStream bos = null;
|
||||
if (isSDCardMounted()) {
|
||||
File file = new File(getSDCardBaseDir() + File.separator + dir);
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();// 递归创建自定义目录
|
||||
}
|
||||
try {
|
||||
bos = new BufferedOutputStream(new FileOutputStream(new File(
|
||||
file, fileName)));
|
||||
bos.write(data);
|
||||
bos.flush();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 往SD卡的私有Files目录下保存文件
|
||||
public static boolean saveFileToSDCardPrivateFilesDir(byte[] data,
|
||||
String type, String fileName, Context context) {
|
||||
BufferedOutputStream bos = null;
|
||||
if (isSDCardMounted()) {
|
||||
File file = context.getExternalFilesDir(type);
|
||||
try {
|
||||
bos = new BufferedOutputStream(new FileOutputStream(new File(
|
||||
file, fileName)));
|
||||
bos.write(data);
|
||||
bos.flush();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 往SD卡的私有Cache目录下保存文件
|
||||
public static boolean saveFileToSDCardPrivateCacheDir(byte[] data,
|
||||
String fileName, Context context) {
|
||||
BufferedOutputStream bos = null;
|
||||
if (isSDCardMounted()) {
|
||||
File file = context.getExternalCacheDir();
|
||||
try {
|
||||
bos = new BufferedOutputStream(new FileOutputStream(new File(
|
||||
file, fileName)));
|
||||
bos.write(data);
|
||||
bos.flush();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 从SD卡获取文件
|
||||
public static byte[] loadFileFromSDCard(String fileDir) {
|
||||
BufferedInputStream bis = null;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
bis = new BufferedInputStream(
|
||||
new FileInputStream(new File(fileDir)));
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
int c = 0;
|
||||
while ((c = bis.read(buffer)) != -1) {
|
||||
baos.write(buffer, 0, c);
|
||||
baos.flush();
|
||||
}
|
||||
return baos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
baos.close();
|
||||
if (bis != null) {
|
||||
bis.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 获取SD卡公有目录的路径
|
||||
public static String getSDCardPublicDir(String type) {
|
||||
return Environment.getExternalStoragePublicDirectory(type).toString();
|
||||
}
|
||||
|
||||
// 获取SD卡私有Cache目录的路径
|
||||
public static String getSDCardPrivateCacheDir(Context context) {
|
||||
return context.getExternalCacheDir().getAbsolutePath();
|
||||
}
|
||||
|
||||
// 获取SD卡私有Files目录的路径
|
||||
public static String getSDCardPrivateFilesDir(Context context, String type) {
|
||||
return context.getExternalFilesDir(type).getAbsolutePath();
|
||||
}
|
||||
|
||||
// 获取SD卡文件目录的路径
|
||||
public static String getSDCardPrivateFilesDirOne(Context context,
|
||||
String type) {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath()
|
||||
+ File.separator + type;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取sdcard绝对物理路径
|
||||
*/
|
||||
public static String getSDCardPath() {
|
||||
if (isSDCardMounted()) {
|
||||
return Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
* @param path
|
||||
*/
|
||||
public static boolean deleteAllFilesOfDir(File path) {
|
||||
if (!path.exists()){
|
||||
return false;
|
||||
}
|
||||
if (path.isFile()) {
|
||||
path.delete();
|
||||
return true;
|
||||
}
|
||||
File[] files = path.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
deleteAllFilesOfDir(files[i]);
|
||||
}
|
||||
path.delete();
|
||||
System.out.println("删除文件夹成功");
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* 删除文件夹2
|
||||
* @param path
|
||||
*/
|
||||
public static void deleteAllFilesOfDir2(File path) {
|
||||
if (!path.exists()){
|
||||
return ;
|
||||
}
|
||||
if (path.isFile()) {
|
||||
path.delete();
|
||||
return ;
|
||||
}
|
||||
File[] files = path.listFiles();
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
deleteAllFilesOfDir(files[i]);
|
||||
}
|
||||
path.delete();
|
||||
System.out.println("删除文件夹成功");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @description
|
||||
* @date 2018/7/25
|
||||
*/
|
||||
public class BaseTimeUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 格式化日期
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String[] formatTimeDate() {
|
||||
Date d = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd-HH:mm");
|
||||
String time = sdf.format(d);
|
||||
if (!TextUtils.isEmpty(time) && time.contains("-")) {
|
||||
String[] timeSplit = time.split("-");
|
||||
return timeSplit;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public static String formatTimeDate1(long time) {
|
||||
Date date = new Date();
|
||||
date.setTime(time);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间
|
||||
*
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
public static String formatTimeDate(long time, String format) {
|
||||
Date date = new Date();
|
||||
date.setTime(time);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(format);
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static String formatTimeDate2() {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
public static String formatTimeDate3() {
|
||||
Date date = new Date();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss");
|
||||
return sdf.format(date);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Description: 本地时间转化为UTC时间</p>
|
||||
* @param localTime
|
||||
* @return
|
||||
* @author wgs
|
||||
* @date 2018年10月19日 下午2:23:43
|
||||
*
|
||||
*/
|
||||
public static Date localToUTC(String localTime) {
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
// Date localDate= null;
|
||||
// try {
|
||||
// localDate = sdf.parse(localTime);
|
||||
// } catch (ParseException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
long localTimeInMillis=Long.parseLong(localTime);
|
||||
/** long时间转换成Calendar */
|
||||
Calendar calendar= Calendar.getInstance();
|
||||
calendar.setTimeInMillis(localTimeInMillis);
|
||||
/** 取得时间偏移量 */
|
||||
int zoneOffset = calendar.get(java.util.Calendar.ZONE_OFFSET);
|
||||
/** 取得夏令时差 */
|
||||
int dstOffset = calendar.get(java.util.Calendar.DST_OFFSET);
|
||||
/** 从本地时间里扣除这些差量,即可以取得UTC时间*/
|
||||
calendar.add(java.util.Calendar.MILLISECOND, -(zoneOffset + dstOffset));
|
||||
/** 取得的时间就是UTC标准时间 */
|
||||
Date utcDate=new Date(calendar.getTimeInMillis());
|
||||
return utcDate;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* <p>Description:UTC时间转化为本地时间 </p>
|
||||
* @param utcTime
|
||||
* @return
|
||||
* @author wgs
|
||||
* @date 2018年10月19日 下午2:23:24
|
||||
*
|
||||
*/
|
||||
public static Date utcToLocal(String utcTime){
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
Date utcDate = null;
|
||||
try {
|
||||
utcDate = sdf.parse(utcTime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sdf.setTimeZone(TimeZone.getDefault());
|
||||
Date locatlDate = null;
|
||||
String localTime = sdf.format(utcDate.getTime());
|
||||
try {
|
||||
locatlDate = sdf.parse(localTime);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return locatlDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: PACKAGE_NAME
|
||||
* @ClassName: com.zhidao.lib.adas.high.common.Constants
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/7 15:53
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/7 15:53
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class Constants {
|
||||
/**
|
||||
* ws 主机地址 需要从udp里面获取
|
||||
*/
|
||||
public static final String WS_IP_HOST_HEAD = "ws:";
|
||||
/**
|
||||
* ws 端口以及资源名称
|
||||
*/
|
||||
public static final String WS_PORT = ":4110/xvideo-detector";
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
public static final String WS_PORT_=":4110";
|
||||
|
||||
/**
|
||||
* 发送位置信息 action
|
||||
*/
|
||||
public static final int WS_SEND_LOCATION = 2;
|
||||
|
||||
/**
|
||||
* 查询自动驾驶轨迹
|
||||
*/
|
||||
public static final String QUERY_GLOBAL_PATH = "{\"action\":\"query_global_path\",\"result\":null}";
|
||||
/**
|
||||
* 查询节点信息
|
||||
*/
|
||||
public static final String QUERY_GUARDIAN = "{\"action\":\"query_guardian\",\"result\":null}";
|
||||
|
||||
/**
|
||||
* 查询docker版本
|
||||
*/
|
||||
public static final String QUERY_CAR_CONFIG = "{\"action\":\"car_config\",\"result\":null}";
|
||||
|
||||
/**
|
||||
* 查询轨迹
|
||||
*/
|
||||
public static final String QUERY_ROUTES = "{\"action\":\"query_routes\",\"result\":null}";
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.zhidao.support.adas.high.BuildConfig;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @description video-lib
|
||||
* @date 2018/6/15
|
||||
*/
|
||||
public class CupidLogUtils {
|
||||
/**
|
||||
* 默认是打开日志
|
||||
*/
|
||||
// private static boolean mIsEnableLog = BuildConfig.DEBUG;
|
||||
private static boolean mIsEnableLog = true;
|
||||
/**
|
||||
* 是否写日志
|
||||
*/
|
||||
private static boolean isWriteLog = true;
|
||||
|
||||
/**
|
||||
* @param isEnableLog true开启 false关闭
|
||||
*/
|
||||
public static void setEnableLog(boolean isEnableLog) {
|
||||
mIsEnableLog = isEnableLog;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isIsWriteLog() {
|
||||
return isWriteLog;
|
||||
}
|
||||
|
||||
public static void setIsWriteLog(boolean isWriteLog) {
|
||||
CupidLogUtils.isWriteLog = isWriteLog;
|
||||
}
|
||||
|
||||
public static void i(String tag, String msg) {
|
||||
if (!mIsEnableLog) {
|
||||
return;
|
||||
}
|
||||
Log.i(tag, msg);
|
||||
}
|
||||
|
||||
public static void w(String tag, String msg) {
|
||||
if (!mIsEnableLog) {
|
||||
return;
|
||||
}
|
||||
Log.w(tag, msg);
|
||||
}
|
||||
|
||||
public static void e(String tag, String msg) {
|
||||
if (!mIsEnableLog) {
|
||||
return;
|
||||
}
|
||||
Log.e(tag, msg);
|
||||
}
|
||||
|
||||
public static void e(String msg) {
|
||||
if (!mIsEnableLog) {
|
||||
return;
|
||||
}
|
||||
Log.e("elita_lib", msg);
|
||||
}
|
||||
|
||||
public static void w(String msg) {
|
||||
if (!mIsEnableLog) {
|
||||
return;
|
||||
}
|
||||
Log.e("elita_lib", msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写文件
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public static void writeOwnerCarStateLog(String msg) {
|
||||
if (!isWriteLog) {
|
||||
return;
|
||||
}
|
||||
LogSaveManage.getInstance().saveWrite(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,516 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
public class DigitalTrans {
|
||||
|
||||
/**
|
||||
* 数字字符串转ASCII码字符串
|
||||
*
|
||||
* @param content 字符串
|
||||
* @return ASCII字符串
|
||||
*/
|
||||
public static String StringToAsciiString(String content) {
|
||||
String result = "";
|
||||
int max = content.length();
|
||||
for (int i = 0; i < max; i++) {
|
||||
char c = content.charAt(i);
|
||||
String b = Integer.toHexString(c);
|
||||
result = result + b;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制转字符串
|
||||
*
|
||||
* @param hexString 十六进制字符串
|
||||
* @param encodeType 编码类型4:Unicode,2:普通编码
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String hexStringToString(String hexString, int encodeType) {
|
||||
String result = "";
|
||||
int max = hexString.length() / encodeType;
|
||||
for (int i = 0; i < max; i++) {
|
||||
char c = (char) DigitalTrans.hexStringToAlgorism(hexString
|
||||
.substring(i * encodeType, (i + 1) * encodeType));
|
||||
result += c;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制字符串装十进制
|
||||
*
|
||||
* @param hex 十六进制字符串
|
||||
* @return 十进制数值
|
||||
*/
|
||||
public static int hexStringToAlgorism(String hex) {
|
||||
hex = hex.toUpperCase();
|
||||
int max = hex.length();
|
||||
int result = 0;
|
||||
for (int i = max; i > 0; i--) {
|
||||
char c = hex.charAt(i - 1);
|
||||
int algorism = 0;
|
||||
if (c >= '0' && c <= '9') {
|
||||
algorism = c - '0';
|
||||
} else {
|
||||
algorism = c - 55;
|
||||
}
|
||||
result += Math.pow(16, max - i) * algorism;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六转二进制
|
||||
*
|
||||
* @param hex 十六进制字符串
|
||||
* @return 二进制字符串
|
||||
*/
|
||||
public static String hexStringToBinary(String hex) {
|
||||
hex = hex.toUpperCase();
|
||||
String result = "";
|
||||
int max = hex.length();
|
||||
for (int i = 0; i < max; i++) {
|
||||
char c = hex.charAt(i);
|
||||
switch (c) {
|
||||
case '0':
|
||||
result += "0000";
|
||||
break;
|
||||
case '1':
|
||||
result += "0001";
|
||||
break;
|
||||
case '2':
|
||||
result += "0010";
|
||||
break;
|
||||
case '3':
|
||||
result += "0011";
|
||||
break;
|
||||
case '4':
|
||||
result += "0100";
|
||||
break;
|
||||
case '5':
|
||||
result += "0101";
|
||||
break;
|
||||
case '6':
|
||||
result += "0110";
|
||||
break;
|
||||
case '7':
|
||||
result += "0111";
|
||||
break;
|
||||
case '8':
|
||||
result += "1000";
|
||||
break;
|
||||
case '9':
|
||||
result += "1001";
|
||||
break;
|
||||
case 'A':
|
||||
result += "1010";
|
||||
break;
|
||||
case 'B':
|
||||
result += "1011";
|
||||
break;
|
||||
case 'C':
|
||||
result += "1100";
|
||||
break;
|
||||
case 'D':
|
||||
result += "1101";
|
||||
break;
|
||||
case 'E':
|
||||
result += "1110";
|
||||
break;
|
||||
case 'F':
|
||||
result += "1111";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* ASCII码字符串转数字字符串
|
||||
*
|
||||
* @param content ASCII字符串
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String AsciiStringToString(String content) {
|
||||
String result = "";
|
||||
int length = content.length() / 2;
|
||||
for (int i = 0; i < length; i++) {
|
||||
String c = content.substring(i * 2, i * 2 + 2);
|
||||
int a = hexStringToAlgorism(c);
|
||||
char b = (char) a;
|
||||
String d = String.valueOf(b);
|
||||
result += d;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将十进制转换为指定长度的十六进制字符串
|
||||
*
|
||||
* @param algorism int 十进制数字
|
||||
* @param maxLength int 转换后的十六进制字符串长度
|
||||
* @return String 转换后的十六进制字符串
|
||||
*/
|
||||
public static String algorismToHEXString(int algorism, int maxLength) {
|
||||
String result = "";
|
||||
result = Integer.toHexString(algorism);
|
||||
|
||||
if (result.length() % 2 == 1) {
|
||||
result = "0" + result;
|
||||
}
|
||||
return patchHexString(result.toUpperCase(), maxLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节数组转为普通字符串(ASCII对应的字符)
|
||||
*
|
||||
* @param bytearray byte[]
|
||||
* @return String
|
||||
*/
|
||||
public static String bytetoString(byte[] bytearray) {
|
||||
String result = "";
|
||||
char temp;
|
||||
|
||||
int length = bytearray.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
temp = (char) bytearray[i];
|
||||
result += temp;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 二进制字符串转十进制
|
||||
*
|
||||
* @param binary 二进制字符串
|
||||
* @return 十进制数值
|
||||
*/
|
||||
public static int binaryToAlgorism(String binary) {
|
||||
int max = binary.length();
|
||||
int result = 0;
|
||||
for (int i = max; i > 0; i--) {
|
||||
char c = binary.charAt(i - 1);
|
||||
int algorism = c - '0';
|
||||
result += Math.pow(2, max - i) * algorism;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十进制转换为十六进制字符串
|
||||
*
|
||||
* @param algorism int 十进制的数字
|
||||
* @return String 对应的十六进制字符串
|
||||
*/
|
||||
public static String algorismToHEXString(int algorism) {
|
||||
String result = "";
|
||||
result = Integer.toHexString(algorism);
|
||||
|
||||
if (result.length() % 2 == 1) {
|
||||
result = "0" + result;
|
||||
|
||||
}
|
||||
result = result.toUpperCase();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* HEX字符串前补0,主要用于长度位数不足。
|
||||
*
|
||||
* @param str String 需要补充长度的十六进制字符串
|
||||
* @param maxLength int 补充后十六进制字符串的长度
|
||||
* @return 补充结果
|
||||
*/
|
||||
static public String patchHexString(String str, int maxLength) {
|
||||
String temp = "";
|
||||
for (int i = 0; i < maxLength - str.length(); i++) {
|
||||
temp = "0" + temp;
|
||||
}
|
||||
str = (temp + str).substring(0, maxLength);
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个字符串转换为int
|
||||
*
|
||||
* @param s String 要转换的字符串
|
||||
* @param defaultInt int 如果出现异常,默认返回的数字
|
||||
* @param radix int 要转换的字符串是什么进制的,如16 8 10.
|
||||
* @return int 转换后的数字
|
||||
*/
|
||||
public static int parseToInt(String s, int defaultInt, int radix) {
|
||||
int i = 0;
|
||||
try {
|
||||
i = Integer.parseInt(s, radix);
|
||||
} catch (NumberFormatException ex) {
|
||||
i = defaultInt;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个十进制形式的数字字符串转换为int
|
||||
*
|
||||
* @param s String 要转换的字符串
|
||||
* @param defaultInt int 如果出现异常,默认返回的数字
|
||||
* @return int 转换后的数字
|
||||
*/
|
||||
public static int parseToInt(String s, int defaultInt) {
|
||||
int i = 0;
|
||||
try {
|
||||
i = Integer.parseInt(s);
|
||||
} catch (NumberFormatException ex) {
|
||||
i = defaultInt;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制字符串转为Byte数组,每两个十六进制字符转为一个Byte
|
||||
*
|
||||
* @param hex 十六进制字符串
|
||||
* @return byte 转换结果
|
||||
*/
|
||||
public static byte[] hexStringToByte(String hex) {
|
||||
int max = hex.length() / 2;
|
||||
byte[] bytes = new byte[max];
|
||||
String binarys = DigitalTrans.hexStringToBinary(hex);
|
||||
for (int i = 0; i < max; i++) {
|
||||
bytes[i] = (byte) DigitalTrans.binaryToAlgorism(binarys.substring(
|
||||
i * 8 + 1, (i + 1) * 8));
|
||||
if (binarys.charAt(8 * i) == '1') {
|
||||
bytes[i] = (byte) (0 - bytes[i]);
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制串转化为byte数组
|
||||
*
|
||||
* @return the array of byte
|
||||
*/
|
||||
public static final byte[] hex2byte(String hex)
|
||||
throws IllegalArgumentException {
|
||||
if (hex.length() % 2 != 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
char[] arr = hex.toCharArray();
|
||||
byte[] b = new byte[hex.length() / 2];
|
||||
for (int i = 0, j = 0, l = hex.length(); i < l; i++, j++) {
|
||||
String swap = "" + arr[i++] + arr[i];
|
||||
int byteint = Integer.parseInt(swap, 16) & 0xFF;
|
||||
b[j] = new Integer(byteint).byteValue();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节数组转换为十六进制字符串
|
||||
*
|
||||
* @param b byte[] 需要转换的字节数组
|
||||
* @return String 十六进制字符串
|
||||
*/
|
||||
public static final String byte2hex(byte b[]) {
|
||||
if (b == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Argument b ( byte array ) is null! ");
|
||||
}
|
||||
String hs = "";
|
||||
String stmp = "";
|
||||
for (int n = 0; n < b.length; n++) {
|
||||
stmp = Integer.toHexString(b[n] & 0xff);
|
||||
if (stmp.length() == 1) {
|
||||
hs = hs + "0" + stmp;
|
||||
} else {
|
||||
hs = hs + stmp;
|
||||
}
|
||||
}
|
||||
return hs.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串转换成十六进制字符串
|
||||
*
|
||||
* @param String str 待转换的ASCII字符串
|
||||
* @return String 每个Byte之间空格分隔,如: [61 6C 6B]
|
||||
*/
|
||||
public static String str2HexStr(String str) {
|
||||
|
||||
char[] chars = "0123456789ABCDEF".toCharArray();
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
byte[] bs = str.getBytes();
|
||||
int bit;
|
||||
|
||||
for (int i = 0; i < bs.length; i++) {
|
||||
bit = (bs[i] & 0x0f0) >> 4;
|
||||
sb.append(chars[bit]);
|
||||
bit = bs[i] & 0x0f;
|
||||
sb.append(chars[bit]);
|
||||
sb.append(' ');
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 十六进制转换字符串
|
||||
*
|
||||
* @param String str Byte字符串(Byte之间无分隔符 如:[616C6B])
|
||||
* @return String 对应的字符串
|
||||
*/
|
||||
public static String hexStr2Str(String hexStr) {
|
||||
String str = "0123456789ABCDEF";
|
||||
char[] hexs = hexStr.toCharArray();
|
||||
byte[] bytes = new byte[hexStr.length() / 2];
|
||||
int n;
|
||||
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
n = str.indexOf(hexs[2 * i]) * 16;
|
||||
n += str.indexOf(hexs[2 * i + 1]);
|
||||
bytes[i] = (byte) (n & 0xff);
|
||||
}
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* bytes转换成十六进制字符串
|
||||
*
|
||||
* @param byte[] b byte数组
|
||||
* @return String 每个Byte值之间空格分隔
|
||||
*/
|
||||
public static String byte2HexStr(byte[] b) {
|
||||
String stmp = "";
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (int n = 0; n < b.length; n++) {
|
||||
stmp = Integer.toHexString(b[n] & 0xFF);
|
||||
sb.append((stmp.length() == 1) ? "0" + stmp : stmp);
|
||||
sb.append(" ");
|
||||
}
|
||||
return sb.toString().toUpperCase().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* bytes字符串转换为Byte值
|
||||
*
|
||||
* @param String src Byte字符串,每个Byte之间没有分隔符
|
||||
* @return byte[]
|
||||
*/
|
||||
public static byte[] hexStr2Bytes(String src) {
|
||||
int m = 0, n = 0;
|
||||
int l = src.length() / 2;
|
||||
System.out.println(l);
|
||||
byte[] ret = new byte[l];
|
||||
for (int i = 0; i < l; i++) {
|
||||
m = i * 2 + 1;
|
||||
n = m + 1;
|
||||
ret[i] = Byte.decode("0x" + src.substring(i * 2, m) + src.substring(m, n));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* String的字符串转换成unicode的String
|
||||
*
|
||||
* @param String strText 全角字符串
|
||||
* @return String 每个unicode之间无分隔符
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String strToUnicode(String strText)
|
||||
throws Exception {
|
||||
char c;
|
||||
StringBuilder str = new StringBuilder();
|
||||
int intAsc;
|
||||
String strHex;
|
||||
for (int i = 0; i < strText.length(); i++) {
|
||||
c = strText.charAt(i);
|
||||
intAsc = (int) c;
|
||||
strHex = Integer.toHexString(intAsc);
|
||||
if (intAsc > 128)
|
||||
str.append("\\u" + strHex);
|
||||
else // 低位在前面补00
|
||||
str.append("\\u00" + strHex);
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* unicode的String转换成String的字符串
|
||||
*
|
||||
* @param String hex 16进制值字符串 (一个unicode为2byte)
|
||||
* @return String 全角字符串
|
||||
*/
|
||||
public static String unicodeToString(String hex) {
|
||||
int t = hex.length() / 6;
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (int i = 0; i < t; i++) {
|
||||
String s = hex.substring(i * 6, (i + 1) * 6);
|
||||
// 高位需要补上00再转
|
||||
String s1 = s.substring(2, 4) + "00";
|
||||
// 低位直接转
|
||||
String s2 = s.substring(4);
|
||||
// 将16进制的string转为int
|
||||
int n = Integer.valueOf(s1, 16) + Integer.valueOf(s2, 16);
|
||||
// 将int转换为字符
|
||||
char[] chars = Character.toChars(n);
|
||||
str.append(new String(chars));
|
||||
}
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 整型数据拆分为长度为2的字节数组,低8位存放在序号小的元素,高8位存放在序号大的元素中(大端存储)
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static byte[] intTo2Byte(int data) {
|
||||
byte[] byteArray = new byte[2];
|
||||
byteArray[0] = (byte) (data >> 8);
|
||||
byteArray[1] = (byte) data;
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将两个字节拼接还原成无符号的整型数据
|
||||
* 数据域中的数据都按小端存储,示例:数据0x1234,则Byte0为0x34,Byte1为0x12
|
||||
*
|
||||
* @param byte1
|
||||
* @param byte2
|
||||
* @return
|
||||
*/
|
||||
public static int joint2ByteToInt(byte byte1, byte byte2) {
|
||||
int result = byte1 & 0xFF;
|
||||
result = (result << 8) | (0x00FF & byte2);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接两个byte[]
|
||||
*
|
||||
* @param
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public static byte[] concatBytes(byte[] bt1, byte[] bt2) {
|
||||
if (bt1 == null) {
|
||||
return bt2;
|
||||
}
|
||||
if (bt2 == null) {
|
||||
return bt1;
|
||||
}
|
||||
byte[] bt3 = new byte[bt1.length + bt2.length];
|
||||
System.arraycopy(bt1, 0, bt3, 0, bt1.length);
|
||||
System.arraycopy(bt2, 0, bt3, bt1.length, bt2.length);
|
||||
return bt3;
|
||||
}
|
||||
|
||||
//获得本机cpu大小端
|
||||
public static boolean isBigendian() {
|
||||
short i = 0x1;
|
||||
boolean bRet = ((i >> 8) == 0x1);
|
||||
return bRet;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,63 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class HandlerThreadManager {
|
||||
private volatile static HandlerThread sBackgroundHandlerThread;
|
||||
private volatile static HandlerThread sIOHandlerThread;
|
||||
private volatile static Handler sBackgroundHandler;
|
||||
private volatile static Handler sMainHandler;
|
||||
|
||||
public static Handler getBackgroundHandler() {
|
||||
if (sBackgroundHandler == null) {
|
||||
sBackgroundHandler = new Handler(getBackgroundHandlerThread().getLooper());
|
||||
}
|
||||
return sBackgroundHandler;
|
||||
}
|
||||
|
||||
public static HandlerThread getBackgroundHandlerThread() {
|
||||
synchronized (HandlerThreadManager.class) {
|
||||
if (sBackgroundHandlerThread == null) {
|
||||
sBackgroundHandlerThread = new HandlerThread("autopilot_bgd_thread");
|
||||
sBackgroundHandlerThread.start();
|
||||
}
|
||||
}
|
||||
return sBackgroundHandlerThread;
|
||||
}
|
||||
|
||||
private static HandlerThread getVideoHandlerThread() {
|
||||
synchronized (HandlerThreadManager.class) {
|
||||
if (sIOHandlerThread == null) {
|
||||
sIOHandlerThread = new HandlerThread("autopilot_video_thread");
|
||||
sIOHandlerThread.start();
|
||||
}
|
||||
}
|
||||
return sIOHandlerThread;
|
||||
}
|
||||
|
||||
|
||||
public static Handler getMainHandler() {
|
||||
if (sMainHandler == null) {
|
||||
sMainHandler = new Handler(Looper.getMainLooper());
|
||||
}
|
||||
return sMainHandler;
|
||||
}
|
||||
|
||||
public static final Executor EXECUTOR = new ThreadPoolExecutor(2, 5, 60L, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(30),
|
||||
new ThreadFactory() {
|
||||
private final AtomicInteger mCount = new AtomicInteger(1);
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
return new Thread(r, "autopilot-thread-pool" + mCount.getAndIncrement());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
|
||||
import com.zhidao.support.adas.high.bean.FaceLoginResponse;
|
||||
import com.zhidao.support.adas.high.bean.UserInfo;
|
||||
|
||||
/**
|
||||
* Created by nie yunlong on 2018/4/13.
|
||||
*/
|
||||
|
||||
public interface IPreferencesHelper {
|
||||
/**
|
||||
* 保存udp client address
|
||||
*
|
||||
* @param address
|
||||
*/
|
||||
void saveUdpClientAddress(String address);
|
||||
|
||||
/**
|
||||
* 获取client address
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getUdpClientAddress();
|
||||
|
||||
/**
|
||||
* 保存dock config
|
||||
*
|
||||
* @param dockConfig
|
||||
*/
|
||||
void saveDockConfig(String dockConfig);
|
||||
|
||||
/**
|
||||
* 获取dock config
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getDockConfig();
|
||||
|
||||
/**
|
||||
* 设置用户信息
|
||||
*
|
||||
* @param loginResponse
|
||||
*/
|
||||
void setUserInfo(FaceLoginResponse.DataBean loginResponse);
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
FaceLoginResponse.DataBean getUserInfo();
|
||||
|
||||
/**
|
||||
* 假的 以后干掉
|
||||
*
|
||||
* @param selectIndex
|
||||
*/
|
||||
void setConfigNaviMapVis(int selectIndex);
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
int getConfigNaviMapVis();
|
||||
|
||||
/**
|
||||
* @param userInfo
|
||||
*/
|
||||
void saveUserUnInfo(UserInfo userInfo);
|
||||
|
||||
/**
|
||||
* 用户ID userInfo 用于扩展
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
UserInfo getUserUnInfo();
|
||||
|
||||
|
||||
/**
|
||||
* 初始化标志位
|
||||
*
|
||||
* @param flag
|
||||
*/
|
||||
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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.zhidao.support.adas.high.thread.QueuedWork;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des
|
||||
* @date 2021/3/4
|
||||
*/
|
||||
class LogSaveManage {
|
||||
private static final LogSaveManage ourInstance = new LogSaveManage();
|
||||
//当前保存的文件路径
|
||||
private String currentSaveFilePath;
|
||||
//6M
|
||||
private final long FILE_LIMIT_SIZE = 6 * 1024 * 1024;
|
||||
|
||||
static LogSaveManage getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
private LogSaveManage() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存文件
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public synchronized void saveWrite(final String msg) {
|
||||
QueuedWork.runInBack(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String logFilePath = createFileReturnPath();
|
||||
FileUtils.writeFile(logFilePath, msg, true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建文件
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private synchronized String createFileReturnPath() throws Exception {
|
||||
if (!TextUtils.isEmpty(currentSaveFilePath)) {
|
||||
long fileSize = FileUtils.getFileSizeLong(new File(currentSaveFilePath));
|
||||
if (fileSize <= FILE_LIMIT_SIZE) {
|
||||
return currentSaveFilePath;
|
||||
}
|
||||
}
|
||||
//大于6M
|
||||
String filePath = BaseSDCardHelper.getSDCardPrivateFilesDir(MgContextUtils.getContext(), "adas-log") + File.separator + BaseTimeUtils.formatTimeDate3() + "-log.txt";
|
||||
//把日志保存到文件
|
||||
boolean isCreateFileSuccess = FileUtils.createOrExistsFile(filePath);
|
||||
if (isCreateFileSuccess) {
|
||||
currentSaveFilePath = filePath;
|
||||
}
|
||||
return currentSaveFilePath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 上下文管理
|
||||
* @date 2019/5/13
|
||||
*/
|
||||
public class MgContextUtils {
|
||||
/**
|
||||
* 上下文
|
||||
*/
|
||||
private static Context mContext;
|
||||
|
||||
/**
|
||||
* 设置上下文
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
public static void setContext(Context context) {
|
||||
mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上下文
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Context getContext() {
|
||||
return mContext;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @description 请求值
|
||||
* @date 2018/7/3
|
||||
*/
|
||||
public enum RequestWsMsgType {
|
||||
|
||||
/**
|
||||
* 获取视频信息
|
||||
*/
|
||||
MSG_GET_VIDEO_INFO(1, "get video info"),
|
||||
/**
|
||||
* 视频分辨率
|
||||
*/
|
||||
MSG_SEND_LOCATION(2, "视频分辨率"),
|
||||
/**
|
||||
* 上传配置
|
||||
*/
|
||||
MSG_SEND_UPLOAD_CONFIG(3, "上传配置"),
|
||||
|
||||
MSG_SEND_CLOSE(5, "关闭socket");
|
||||
int mMsgType;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
String mMsgDesc;
|
||||
|
||||
RequestWsMsgType(int msgType, String msgDesc) {
|
||||
this.mMsgType = msgType;
|
||||
this.mMsgDesc = msgDesc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取msgType
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getMsgType() {
|
||||
return mMsgType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取描述
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getmMsgDesc() {
|
||||
return mMsgDesc;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
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;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.zhidao.support.adas.high.bean.SSHResult;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class SSH {
|
||||
private static final String TAG = SSH.class.getSimpleName();
|
||||
|
||||
private Session session = null;
|
||||
private ChannelExec channelExec = null;
|
||||
ByteArrayOutputStream err = null;
|
||||
StringBuffer outBuf = null;
|
||||
|
||||
public ByteArrayOutputStream getErr() {
|
||||
return err;
|
||||
}
|
||||
|
||||
public StringBuffer getOutBuf() {
|
||||
return outBuf;
|
||||
}
|
||||
|
||||
public Session getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public ChannelExec getChannelExec() {
|
||||
return channelExec;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用用户名、密码连接
|
||||
*
|
||||
* @param host 主机ip
|
||||
* @param port 主机端口
|
||||
* @param username 主机用户名
|
||||
* @param password 主机密码
|
||||
* @throws JSchException
|
||||
*/
|
||||
public void connect(String host, int port, String username, String password) throws JSchException {
|
||||
JSch jsch = new JSch();
|
||||
session = jsch.getSession(username, host, port);
|
||||
session.setPassword(password);
|
||||
Properties config = new Properties();
|
||||
config.put("StrictHostKeyChecking", "no");
|
||||
session.setConfig(config);
|
||||
session.setTimeout(30000);
|
||||
session.connect();
|
||||
Log.i(TAG, "Connected to " + host + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用授信连接
|
||||
*
|
||||
* @param host 主机ip
|
||||
* @param username 主机用户名
|
||||
* @param privateKey 私钥路径
|
||||
* @throws JSchException
|
||||
*/
|
||||
public void connect(String host, String username, String privateKey) throws JSchException {
|
||||
JSch jsch = new JSch();
|
||||
jsch.addIdentity(privateKey);
|
||||
session = jsch.getSession(username, host);
|
||||
|
||||
Properties config = new Properties();
|
||||
config.put("StrictHostKeyChecking", "no");
|
||||
session.setConfig(config);
|
||||
session.setTimeout(30000);
|
||||
session.connect();
|
||||
Log.i(TAG, "Connected to " + host + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行
|
||||
*
|
||||
* @param cmd 命令
|
||||
* @return 状态
|
||||
* @throws JSchException
|
||||
* @throws IOException
|
||||
*/
|
||||
public SSHResult exec(String cmd) throws JSchException, IOException {
|
||||
return exec(cmd, null);
|
||||
}
|
||||
|
||||
public SSHResult exec(String cmd, String suPwd) throws JSchException, IOException {
|
||||
int exitStatus = 0;
|
||||
channelExec = (ChannelExec) session.openChannel("exec");
|
||||
channelExec.setInputStream(null);
|
||||
err = new ByteArrayOutputStream();
|
||||
channelExec.setErrStream(err);
|
||||
channelExec.setCommand(cmd);
|
||||
InputStream in = channelExec.getInputStream();
|
||||
OutputStream out = channelExec.getOutputStream();
|
||||
channelExec.connect();
|
||||
if (!TextUtils.isEmpty(suPwd) && (cmd.contains("sudo") || cmd.contains("su"))) {
|
||||
out.write((suPwd + "\n").getBytes()); //这里是密码后跟了一个换行符
|
||||
out.flush();
|
||||
}
|
||||
outBuf = new StringBuffer();
|
||||
byte[] tmp = new byte[1024];
|
||||
while (true) {
|
||||
while (in.available() > 0) {
|
||||
int i = in.read(tmp, 0, 1024);
|
||||
if (i < 0) break;
|
||||
outBuf.append(new String(tmp, 0, i));
|
||||
}
|
||||
if (channelExec.isClosed()) {
|
||||
if (in.available() > 0) continue;
|
||||
exitStatus = channelExec.getExitStatus();
|
||||
break;
|
||||
}
|
||||
try {
|
||||
Thread.sleep(1000L);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
channelExec.disconnect();
|
||||
if (exitStatus == 0) {
|
||||
String outInfo = this.getOutBuf().toString();
|
||||
return new SSHResult(exitStatus, cmd, outInfo);
|
||||
} else {
|
||||
String errInfo = this.getErr().toString();
|
||||
return new SSHResult(exitStatus, cmd, errInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开连接
|
||||
*/
|
||||
public void disConnect() {
|
||||
if (channelExec != null) {
|
||||
channelExec.disconnect();
|
||||
}
|
||||
if (session != null) {
|
||||
session.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 线程池
|
||||
* Created by xfk on 2018/9/30.
|
||||
*/
|
||||
|
||||
public class ThreadPoolManager<T> {
|
||||
|
||||
/**
|
||||
* 根据cpu的数量动态的配置核心线程数和最大线程数
|
||||
*/
|
||||
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
|
||||
/**
|
||||
* 核心线程数 = CPU核心数 + 1
|
||||
*/
|
||||
private static final int CORE_POOL_SIZE = CPU_COUNT + 1;
|
||||
/**
|
||||
* 线程池最大线程数 = CPU核心数 * 2 + 1
|
||||
*/
|
||||
private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1;
|
||||
/**
|
||||
* 非核心线程闲置时超时1s
|
||||
*/
|
||||
private static final int KEEP_ALIVE = 1;
|
||||
/**
|
||||
* 线程池的对象
|
||||
*/
|
||||
private ThreadPoolExecutor executor;
|
||||
|
||||
/**
|
||||
* 要确保该类只有一个实例对象,避免产生过多对象消费资源,所以采用单例模式
|
||||
*/
|
||||
private ThreadPoolManager() {
|
||||
}
|
||||
|
||||
private volatile static ThreadPoolManager INSTANCE;
|
||||
|
||||
public static ThreadPoolManager getsInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (ThreadPoolManager.class) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new ThreadPoolManager();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个无返回结果的线程
|
||||
*
|
||||
* @param r
|
||||
*/
|
||||
public void execute(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());
|
||||
}
|
||||
// 把一个任务丢到了线程池中
|
||||
try {
|
||||
executor.execute(r);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 开启一个有返回结果的线程
|
||||
*
|
||||
* @param r
|
||||
* @return
|
||||
*/
|
||||
public Future<T> submit(Callable<T> 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>(20),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
}
|
||||
// 把一个任务丢到了线程池中
|
||||
return executor.submit(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把任务移除等待队列
|
||||
*
|
||||
* @param r
|
||||
*/
|
||||
public void cancel(Runnable r) {
|
||||
if (r != null) {
|
||||
executor.getQueue().remove(r);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
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.queue.UdpMsgModel;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public interface IMsg {
|
||||
/**
|
||||
* 处理消息
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
void handlerMsg(Gson gson, OnAdasListener adasListener, String msg);
|
||||
|
||||
void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zhidao.support.adas.high.msg;
|
||||
|
||||
/**
|
||||
* 生产产品的工厂
|
||||
*/
|
||||
public interface IMyMessageFactory {
|
||||
/**
|
||||
*
|
||||
* @param messageType 消息类型
|
||||
* @return
|
||||
*/
|
||||
public IMsg createMessage(String messageType);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param messageCode 消息类型
|
||||
* @return
|
||||
*/
|
||||
public IMsg createMessage(int messageCode);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 消息处理中心
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public abstract class MyAbstractMessageHandler implements IMsg {
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.zhidao.support.adas.high.common.ActionTypeReceive;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 简易工厂
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class MyMessageFactory implements IMyMessageFactory {
|
||||
/**
|
||||
* udp 渲染 image
|
||||
*/
|
||||
private IMsg udpRenderImageMsg;
|
||||
/**
|
||||
* ws 报警 消息
|
||||
*/
|
||||
private IMsg wsWarnMessage;
|
||||
/**
|
||||
* ws 图像size
|
||||
*/
|
||||
private IMsg wsImageSizeMessage;
|
||||
/**
|
||||
* 空实现
|
||||
*/
|
||||
private IMsg nuImplMessage;
|
||||
/**
|
||||
* udp 车辆状态消息
|
||||
*/
|
||||
private IMsg udpCarStateMessage;
|
||||
/**
|
||||
* 红绿灯状态
|
||||
*/
|
||||
private IMsg udpLightStateMessage;
|
||||
/**
|
||||
* 周边物体的状态
|
||||
*/
|
||||
private IMsg udpObstaclesMessage;
|
||||
|
||||
/**
|
||||
* 局部轨迹消息
|
||||
*/
|
||||
private IMsg trajectoryMessage;
|
||||
|
||||
/**
|
||||
* 监控信息
|
||||
*/
|
||||
private IMsg guardianMessage;
|
||||
/**
|
||||
* 车道线渲染
|
||||
*/
|
||||
private IMsg lanesMessage;
|
||||
/**
|
||||
* 自动驾驶状态
|
||||
*/
|
||||
private IMsg autopilotStatusMessage;
|
||||
/**
|
||||
* 自动驾驶到站
|
||||
*/
|
||||
private IMsg autopilotArriveMessage;
|
||||
/**
|
||||
* 自动驾驶路径
|
||||
*/
|
||||
private IMsg autopilotRouteMessage;
|
||||
/**
|
||||
* 工控机获取SN
|
||||
*/
|
||||
private IMsg autopilotSNMessage;
|
||||
/**
|
||||
* 数据采集信息
|
||||
*/
|
||||
private IMsg autopilotIdentify;
|
||||
/**
|
||||
* 工控机升级状态
|
||||
*/
|
||||
private IMsg autopilotUpgradeStatusMessage;
|
||||
/**
|
||||
* car dock 基础信息
|
||||
*/
|
||||
private IMsg autopilotConfig;
|
||||
/**
|
||||
* 工控机升级进度
|
||||
*/
|
||||
private IMsg autopilotUpgradePatchDownloadStatusMessage;
|
||||
|
||||
|
||||
@Override
|
||||
public IMsg createMessage(String messageType) {
|
||||
if (TextUtils.isEmpty(messageType)) {
|
||||
if (nuImplMessage == null) {
|
||||
nuImplMessage = new NuImplMessage();
|
||||
}
|
||||
return nuImplMessage;
|
||||
}
|
||||
if (messageType.equals(ActionTypeReceive.ACTION_WS_MSG_RENDER_TYPE.getmActionType())) {
|
||||
//udp render
|
||||
if (udpRenderImageMsg == null) {
|
||||
udpRenderImageMsg = new UdpRenderImageMessage();
|
||||
}
|
||||
return udpRenderImageMsg;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_MSG_WARNING_TYPE.getmActionType())) {
|
||||
//ws 报警消息
|
||||
if (wsWarnMessage == null) {
|
||||
wsWarnMessage = new WsWarnMessage();
|
||||
}
|
||||
return wsWarnMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_MSG_IMAGE_SIZE_TYPE.getmActionType())) {
|
||||
//ws 报警消息
|
||||
if (wsImageSizeMessage == null) {
|
||||
wsImageSizeMessage = new WsImageSizeMessage();
|
||||
}
|
||||
return wsImageSizeMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_CAR_STATE_TYPE.getmActionType())) {
|
||||
//udp 车辆消息
|
||||
if (udpCarStateMessage == null) {
|
||||
udpCarStateMessage = new UdpCarStateMessage();
|
||||
}
|
||||
return udpCarStateMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_UDP_LIGHT_STATE_TYPE.getmActionType())) {
|
||||
//udp 红绿灯状态
|
||||
if (udpLightStateMessage == null) {
|
||||
udpLightStateMessage = new UdpLightStateMessage();
|
||||
}
|
||||
return udpLightStateMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_OBSTACLES_MESSAGE_TYPE.getmActionType())) {
|
||||
//udp 周边物体的状态
|
||||
if (udpObstaclesMessage == null) {
|
||||
udpObstaclesMessage = new UdpObstaclesMessage();
|
||||
}
|
||||
return udpObstaclesMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_LANES_MESSAGE_TYPE.getmActionType())) {
|
||||
// 车道线渲染
|
||||
if (lanesMessage == null) {
|
||||
lanesMessage = new UdpLanesMessage();
|
||||
}
|
||||
return lanesMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_STATUE.getmActionType())) {
|
||||
//ws 自动驾驶状态
|
||||
if (autopilotStatusMessage == null) {
|
||||
autopilotStatusMessage = new WsAutopilotStatusMessage();
|
||||
}
|
||||
return autopilotStatusMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_WAY_ARRIVE.getmActionType())) {
|
||||
//自送驾驶到站
|
||||
if (autopilotArriveMessage == null) {
|
||||
autopilotArriveMessage = new WsAutopilotArriveMessage();
|
||||
}
|
||||
return autopilotArriveMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_ROUTE.getmActionType())) {
|
||||
//自动驾驶路径
|
||||
if (autopilotRouteMessage == null) {
|
||||
autopilotRouteMessage = new WsAutopilotRouteMessage();
|
||||
}
|
||||
return autopilotRouteMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_SN_REQUEST.getmActionType())) {
|
||||
//工控机获取sn
|
||||
if (autopilotSNMessage == null) {
|
||||
autopilotSNMessage = new WsAutopilotSNMessage();
|
||||
}
|
||||
return autopilotSNMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_IDENTIFY.getmActionType())) {
|
||||
//数据采集信息
|
||||
if (autopilotIdentify == null) {
|
||||
autopilotIdentify = new WsAutopilotIdentify();
|
||||
}
|
||||
return autopilotIdentify;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_TRAJECTORY.getmActionType())) {
|
||||
//局部轨迹
|
||||
if (trajectoryMessage == null) {
|
||||
trajectoryMessage = new WsAutopilotTrajectoryMessage();
|
||||
}
|
||||
return trajectoryMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_CAR_CONFIG.getmActionType())) {
|
||||
//dock config
|
||||
if (autopilotConfig == null) {
|
||||
autopilotConfig = new WsAutopilotConfig();
|
||||
}
|
||||
return autopilotConfig;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_UPGRADE_STATUS.getmActionType())) {
|
||||
//ws 工控机升级状态
|
||||
if (autopilotUpgradeStatusMessage == null) {
|
||||
autopilotUpgradeStatusMessage = new WsAutopilotUpgradeStatusMessage();
|
||||
}
|
||||
return autopilotUpgradeStatusMessage;
|
||||
} else if (messageType.equals(ActionTypeReceive.ACTION_WS_AUTOPILOT_UPGRADE_PATCH_DOWNLOAD_STATUS.getmActionType())) {
|
||||
//ws 工控机升级进度
|
||||
if (autopilotUpgradePatchDownloadStatusMessage == null) {
|
||||
autopilotUpgradePatchDownloadStatusMessage = new WsAutopilotUpgradePatchDownloadStatusMessage();
|
||||
}
|
||||
return autopilotUpgradePatchDownloadStatusMessage;
|
||||
}
|
||||
|
||||
if (nuImplMessage == null) {
|
||||
nuImplMessage = new NuImplMessage();
|
||||
}
|
||||
return nuImplMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMsg createMessage(int messageCode) {
|
||||
if (messageCode == 0) {
|
||||
if (nuImplMessage == null) {
|
||||
nuImplMessage = new NuImplMessage();
|
||||
}
|
||||
return nuImplMessage;
|
||||
}
|
||||
if (messageCode == ActionTypeReceive.ACTION_WS_MSG_RENDER_TYPE.getmActionCode()) {
|
||||
//感知数据
|
||||
if (udpRenderImageMsg == null) {
|
||||
udpRenderImageMsg = new UdpRenderImageMessage();
|
||||
}
|
||||
return udpRenderImageMsg;
|
||||
} else if (messageCode == ActionTypeReceive.ACTION_WS_CAR_STATE_TYPE.getmActionCode()) {
|
||||
//定位数据
|
||||
if (udpCarStateMessage == null) {
|
||||
udpCarStateMessage = new UdpCarStateMessage();
|
||||
}
|
||||
return udpCarStateMessage;
|
||||
} else if (messageCode == (ActionTypeReceive.ACTION_WS_AUTOPILOT_TRAJECTORY.getmActionCode())) {
|
||||
//局部轨迹
|
||||
if (trajectoryMessage == null) {
|
||||
trajectoryMessage = new WsAutopilotTrajectoryMessage();
|
||||
}
|
||||
return trajectoryMessage;
|
||||
} else if (messageCode == (ActionTypeReceive.ACTION_WS_AUTOPILOT_ROUTES.getmActionCode())) {
|
||||
//轨迹列表
|
||||
|
||||
} else if (messageCode == (ActionTypeReceive.ACTION_WS_AUTOPILOT_GUARDIAN.getmActionCode())) {
|
||||
//监控信息
|
||||
if (guardianMessage == null) {
|
||||
guardianMessage = new WsAutopilotGuardian();
|
||||
}
|
||||
return guardianMessage;
|
||||
}
|
||||
if (nuImplMessage == null) {
|
||||
nuImplMessage = new NuImplMessage();
|
||||
}
|
||||
return nuImplMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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.queue.UdpMsgModel;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 空实现防止空指针
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class NuImplMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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.CarStateInfo;
|
||||
import com.zhidao.support.adas.high.common.BaseTimeUtils;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import mogo.status.CarStatus;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des udp 车辆状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class UdpCarStateMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
CupidLogUtils.w("CarStateData", "===>carStateInfo" + adasListener);
|
||||
CarStateInfo carStateInfo = gson.fromJson(msg, CarStateInfo.class);
|
||||
// String satelliteTime = carStateInfo.getValues().getSatelliteTime();
|
||||
// long systemTime = System.currentTimeMillis();
|
||||
// Date date = BaseTimeUtils.localToUTC(String.valueOf(System.currentTimeMillis()));
|
||||
// long time = date.getTime();
|
||||
// long l = Long.parseLong(satelliteTime)-time;
|
||||
// CupidLogUtils.w("CarStateData", "carStateInfo2 pad system time="+systemTime);
|
||||
// CupidLogUtils.w("CarStateData", "carStateInfo2 pad utc time=" + time);
|
||||
// CupidLogUtils.w("CarStateData", "carStateInfo2 gkj utc time=" + satelliteTime);
|
||||
// CupidLogUtils.w("CarStateData", "carStateInfo2 time difference=" + l);
|
||||
if (adasListener != null) {
|
||||
adasListener.onCarStateData(carStateInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
try {
|
||||
CarStatus.Status status = CarStatus.Status.parseFrom(msg);
|
||||
if (status != null) {
|
||||
CarStateInfo carStateInfo = new CarStateInfo();
|
||||
carStateInfo.setAction("state");
|
||||
CarStateInfo.ValuesBean values = new CarStateInfo.ValuesBean();
|
||||
values.setLon(status.getLon());
|
||||
values.setLat(status.getLat());
|
||||
values.setAlt(status.getAlt());
|
||||
values.setHeading(status.getHeading());
|
||||
values.setAcceleration(status.getAcceleration());
|
||||
values.setYaw_rate(status.getYawRate());
|
||||
values.setGnss_speed(status.getGnssSpeed());
|
||||
values.setVehicle_speed(status.getVehicleSpeed());
|
||||
values.setSatelliteTime(status.getSatelliteTime());
|
||||
values.setSystemTime(status.getSystemTime());
|
||||
values.setTurn_light(status.getTurnLight());
|
||||
values.setFlash_light(status.getFlashLight());
|
||||
values.setBrake_light(status.getBrakeLight());
|
||||
values.setFrame_num(status.getFrameNum());
|
||||
carStateInfo.setValues(values);
|
||||
if (adasListener != null) {
|
||||
adasListener.onCarStateData(carStateInfo);
|
||||
CupidLogUtils.w("UdpCarStateMessage", "" + carStateInfo.toString());
|
||||
}
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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.CarLaneInfo;
|
||||
import com.zhidao.support.adas.high.queue.UdpMsgModel;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des udp 车道线渲染
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class UdpLanesMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
//udp 车道线渲染
|
||||
CarLaneInfo carLaneInfo = gson.fromJson(msg, CarLaneInfo.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onCarLaneInfo(carLaneInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.CarStateInfo;
|
||||
import com.zhidao.support.adas.high.bean.LightStatueInfo;
|
||||
import com.zhidao.support.adas.high.queue.UdpMsgModel;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des udp 红绿灯状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class UdpLightStateMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
//udp 红绿灯状态
|
||||
LightStatueInfo lightStatueInfo = gson.fromJson(msg, LightStatueInfo.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onLightStateData(lightStatueInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.LightStatueInfo;
|
||||
import com.zhidao.support.adas.high.bean.ObstaclesInfo;
|
||||
import com.zhidao.support.adas.high.queue.UdpMsgModel;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des udp 周边物体渲染
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class UdpObstaclesMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
//udp 周边物体渲染
|
||||
ObstaclesInfo obstaclesInfo = gson.fromJson(msg, ObstaclesInfo.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onObstaclesInfo(obstaclesInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.RectInfo;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import adas.Adas;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des udp渲染
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class UdpRenderImageMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
//渲染图像流
|
||||
RectInfo rectInfo = gson.fromJson(msg, RectInfo.class);
|
||||
CupidLogUtils.e("UdpRenderImageMessage--->json:num = " + rectInfo.getModels().size());
|
||||
if (adasListener != null) {
|
||||
adasListener.onRectData(rectInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
Adas.ViwesMsg viewMsg = null;
|
||||
try {
|
||||
viewMsg = Adas.ViwesMsg.parseFrom(msg);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
CupidLogUtils.e("UdpRenderImageMessage--->protoBuf Exception:" + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (viewMsg != null) {
|
||||
if (TextUtils.equals(viewMsg.getAction(), "view")) {
|
||||
RectInfo rectInfo = new RectInfo();
|
||||
rectInfo.setAction(viewMsg.getAction());
|
||||
ArrayList<RectInfo.RectBean> rectBeans = new ArrayList<>();
|
||||
for (int i = 0; i < viewMsg.getModelsList().size(); i++) {
|
||||
RectInfo.RectBean rectBean = new RectInfo.RectBean();
|
||||
rectBean.setYt(viewMsg.getModels(i).getYt());
|
||||
rectBean.setYb(viewMsg.getModels(i).getYb());
|
||||
rectBean.setXr(viewMsg.getModels(i).getXr());
|
||||
rectBean.setXl(viewMsg.getModels(i).getXl());
|
||||
rectBean.setDistance_x(viewMsg.getModels(i).getDistanceX());
|
||||
rectBean.setDistance_y(viewMsg.getModels(i).getDistanceY());
|
||||
rectBean.setType(viewMsg.getModels(i).getType());
|
||||
rectBean.setLat(viewMsg.getModels(i).getLat());
|
||||
rectBean.setLon(viewMsg.getModels(i).getLon());
|
||||
rectBean.setHeading(viewMsg.getModels(i).getHeading());
|
||||
rectBean.setSystemTime(viewMsg.getModels(i).getSystemTime());
|
||||
rectBean.setSatelliteTime(viewMsg.getModels(i).getSatelliteTime());
|
||||
rectBean.setAlt(viewMsg.getModels(i).getAlt());
|
||||
rectBean.setCarId(viewMsg.getModels(i).getCarId());
|
||||
rectBean.setUuid(viewMsg.getModels(i).getUuid());
|
||||
rectBean.setColor(viewMsg.getModels(i).getColor());
|
||||
rectBean.setSpeed(viewMsg.getModels(i).getSpeed());
|
||||
rectBean.setDrawlevel(viewMsg.getModels(i).getDrawlevel());
|
||||
rectBean.setLength(viewMsg.getModels(i).getLength());
|
||||
rectBean.setWidth(viewMsg.getModels(i).getWidth());
|
||||
rectBean.setHeight(viewMsg.getModels(i).getHeight());
|
||||
rectBean.setDriverTime(viewMsg.getModels(i).getDriverTime());
|
||||
// if (viewMsg.getModels(i).getDriverTime()!=null){
|
||||
// String s16 = conversionTime(viewMsg.getModels(i).getDriverTime());
|
||||
// if (s16!=null){
|
||||
// CupidLogUtils.e("UdpRenderImageMessage--->time===>s16=" + s16);
|
||||
// String s13 = s16.substring(0, 13);
|
||||
// CupidLogUtils.e("UdpRenderImageMessage--->time===>s13=" + s13);
|
||||
// rectBean.setDriverTime(s13);
|
||||
// }else {
|
||||
// rectBean.setDriverTime(viewMsg.getModels(i).getDriverTime());
|
||||
// }
|
||||
// }
|
||||
rectBeans.add(rectBean);
|
||||
}
|
||||
rectInfo.setModels(rectBeans);
|
||||
if (adasListener != null) {
|
||||
adasListener.onRectData(rectInfo);
|
||||
CupidLogUtils.e("UdpRenderImageMessage--->protoBuf===>:rectInfo = " + rectInfo.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String conversionTime(String str) {
|
||||
StringBuffer stringBuffer = new StringBuffer("");
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (str.charAt(i) != '.') {
|
||||
stringBuffer.append(str.charAt(i));
|
||||
}
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.AutopilotStatus;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotWayArrive;
|
||||
import com.zhidao.support.adas.high.queue.UdpMsgModel;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des ws自动驾驶到站
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class WsAutopilotArriveMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
//ws 自动驾驶状态
|
||||
AutopilotWayArrive autopilotWayArrive = gson.fromJson(msg, AutopilotWayArrive.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.autopilotArrive(autopilotWayArrive);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
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.AdasConfig;
|
||||
import com.zhidao.support.adas.high.bean.AutopilotConfig;
|
||||
import com.zhidao.support.adas.high.bean.guardian.AutopilotGuardianInfo;
|
||||
import com.zhidao.support.adas.high.common.AppPreferenceHelper;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.MgContextUtils;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/11/17
|
||||
*/
|
||||
public class WsAutopilotConfig extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
AutopilotConfig autopilotConfig = gson.fromJson(msg, AutopilotConfig.class);
|
||||
AutopilotConfig.ResultBean result = autopilotConfig.getResult();
|
||||
if (result!=null){
|
||||
String dockVersion = result.getDock_version();
|
||||
AppPreferenceHelper.getInstance(MgContextUtils.getContext()).saveDockConfig(dockVersion);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.util.JsonFormat;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.guardian.AutopilotGuardianInfo;
|
||||
import com.zhidao.support.adas.high.bean.guardian.GuardianItemsName;
|
||||
import com.zhidao.support.adas.high.bean.guardian.GuardianModule;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import mogo.guardian.MogoGuardian;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/7/7
|
||||
*/
|
||||
public class WsAutopilotGuardian extends MyAbstractMessageHandler{
|
||||
private final JsonFormat.Printer printer = JsonFormat.printer();
|
||||
private AutopilotGuardianInfo info;
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
// CupidLogUtils.w("WsAutopilotGuardian===>"+msg);
|
||||
AutopilotGuardianInfo autopilotGuardian = gson.fromJson(msg, AutopilotGuardianInfo.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onAutopilotGuardian(autopilotGuardian);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
try {
|
||||
MogoGuardian.GuardianProto proto = MogoGuardian.GuardianProto.parseFrom(msg);
|
||||
String print = printer.print(proto);
|
||||
info = gson.fromJson(print, AutopilotGuardianInfo.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onAutopilotGuardian(info);
|
||||
CupidLogUtils.w("WsAutopilotGuardian===>"+ info.toString());
|
||||
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.zhidao.support.adas.high.msg;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.zhidao.support.adas.high.OnAdasListener;
|
||||
import com.zhidao.support.adas.high.bean.record.AutopilotIdentifyInfo;
|
||||
import com.zhidao.support.adas.high.bean.record.AutopilotRecordResult;
|
||||
import com.zhidao.support.adas.high.common.AppPreferenceHelper;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.HandlerThreadManager;
|
||||
import com.zhidao.support.adas.high.common.MgContextUtils;
|
||||
import com.zhidao.support.recorder.RecordDataManager;
|
||||
import com.zhidao.support.recorder.activity.LoginSftpActivity;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/7/7
|
||||
*/
|
||||
public class WsAutopilotIdentify extends MyAbstractMessageHandler {
|
||||
private static final int SHOW_RECORDER = 0x01;
|
||||
private boolean isConnect = false;
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
CupidLogUtils.w("WsAutopilotIdentify===>" + msg);
|
||||
AutopilotIdentifyInfo info = gson.fromJson(msg, AutopilotIdentifyInfo.class);
|
||||
AutopilotIdentifyInfo.Result result = info.getResult();
|
||||
AutopilotRecordResult panel = result.getPanel();
|
||||
if (adasListener!=null){
|
||||
adasListener.onAutopilotRecord(panel);
|
||||
}
|
||||
// if (panel!=null){
|
||||
// int stat = panel.getStat();
|
||||
// if (stat==1){
|
||||
// final String user = result.getUser();
|
||||
// final String passwd = result.getPasswd();
|
||||
// String timestamp = panel.getTimestamp();
|
||||
// final String udpClientAddress = AppPreferenceHelper.getInstance(MgContextUtils.getContext()).getUdpClientAddress();
|
||||
// if (TextUtils.isEmpty(user) || TextUtils.isEmpty(passwd) || TextUtils.isEmpty(udpClientAddress)) {
|
||||
// CupidLogUtils.w("ftp message error");
|
||||
// return;
|
||||
// }
|
||||
// RecordDataManager.getInstance().init(MgContextUtils.getContext(),timestamp , udpClientAddress, 22, user, passwd);
|
||||
// isConnect = RecordDataManager.getInstance().connectSftp();
|
||||
// handler.removeMessages(SHOW_RECORDER);
|
||||
// handler.sendEmptyMessage(SHOW_RECORDER);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
|
||||
private Handler handler = new Handler(HandlerThreadManager.getMainHandler().getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (isConnect) {
|
||||
RecordDataManager.getInstance().record();
|
||||
} else {
|
||||
Intent intent = new Intent(MgContextUtils.getContext(), LoginSftpActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MgContextUtils.getContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
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.common.CupidLogUtils;
|
||||
|
||||
/**
|
||||
* 自动驾驶路径
|
||||
*/
|
||||
public class WsAutopilotRouteMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
// CupidLogUtils.w("WsAutopilotRouteMessage===>"+msg);
|
||||
AutopilotRoute autopilotRoute = gson.fromJson(msg, AutopilotRoute.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onAutopilotRoute(autopilotRoute);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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.AutopilotTrajectory;
|
||||
import com.zhidao.support.adas.high.bean.TrajectoryInfo;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.trajectory.TrajectoryOuterClass;
|
||||
|
||||
/**
|
||||
* 自动驾驶路径
|
||||
*/
|
||||
public class WsAutopilotRoutesMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* 自动驾驶路径
|
||||
*/
|
||||
public class WsAutopilotSNMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
// CupidLogUtils.w("WsAutopilotSNMessage===>"+msg);
|
||||
AutopilotSnRequest autopilotSn = gson.fromJson(msg, AutopilotSnRequest.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onAutopilotSNRequest();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
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.AutopilotStatus;
|
||||
import com.zhidao.support.adas.high.queue.UdpMsgModel;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des ws自动驾驶状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class WsAutopilotStatusMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
//ws 自动驾驶状态
|
||||
AutopilotStatus autopilotStatus = gson.fromJson(msg, AutopilotStatus.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.autopilotStatus(autopilotStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mogo.trajectory.TrajectoryOuterClass;
|
||||
|
||||
/**
|
||||
* 自动驾驶路径
|
||||
*/
|
||||
public class WsAutopilotTrajectoryMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
CupidLogUtils.w("WsAutopilotTrajectoryMessage===>"+msg);
|
||||
AutopilotTrajectory trajectory = gson.fromJson(msg, AutopilotTrajectory.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onAutopilotTrajectory(trajectory.getModels());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
try {
|
||||
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++){
|
||||
TrajectoryOuterClass.TrajectoryPoint point = pointsList.get(i);
|
||||
TrajectoryInfo trajectoryInfo = new TrajectoryInfo();
|
||||
trajectoryInfo.setLon(point.getX());
|
||||
trajectoryInfo.setLat(point.getY());
|
||||
trajectoryInfo.setAlt(point.getZ());
|
||||
trajectoryInfo.setTime(point.getT());
|
||||
trajectoryInfo.setVelocity(point.getV());
|
||||
trajectoryInfo.setAcceleration(point.getA());
|
||||
trajectoryInfo.setTheta(point.getTheta());
|
||||
trajectoryInfo.setKappa(point.getKappa());
|
||||
trajectoryInfo.setAccumulatedDis(point.getS());
|
||||
trajectoryInfos.add(trajectoryInfo);
|
||||
}
|
||||
if (adasListener != null) {
|
||||
adasListener.onAutopilotTrajectory(trajectoryInfos);
|
||||
CupidLogUtils.e("WsAutopilotTrajectoryMessage--->" + trajectoryInfos.toString());
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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.IPCUpgradePatchDownloadStatusInfo;
|
||||
|
||||
/**
|
||||
* @des 工控机升级包下载状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class WsAutopilotUpgradePatchDownloadStatusMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
IPCUpgradePatchDownloadStatusInfo autopilotStatus = gson.fromJson(msg, IPCUpgradePatchDownloadStatusInfo.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onUpgradePatchDownloadStatus(autopilotStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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.IPCUpgradeStateInfo;
|
||||
|
||||
/**
|
||||
* @des 工控机升级状态
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class WsAutopilotUpgradeStatusMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
IPCUpgradeStateInfo autopilotStatus = gson.fromJson(msg, IPCUpgradeStateInfo.class);
|
||||
if (adasListener != null) {
|
||||
adasListener.onUpgradeStateInfo(autopilotStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.queue.UdpMsgModel;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 图像大小
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class WsImageSizeMessage extends MyAbstractMessageHandler {
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = new JSONObject(msg);
|
||||
JSONObject videoInfo = jsonObject.optJSONObject("values");
|
||||
if (videoInfo != null) {
|
||||
int width = videoInfo.optInt("width");
|
||||
int height = videoInfo.optInt("height");
|
||||
CupidLogUtils.e("--->width" + width + ",height" + height);
|
||||
if (adasListener != null) {
|
||||
adasListener.onVideoSize(width, height);
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
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.WarnMessageInfo;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.queue.UdpMsgModel;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @des 报警消息
|
||||
* @date 2020/3/12
|
||||
*/
|
||||
public class WsWarnMessage extends MyAbstractMessageHandler {
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) {
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(msg);
|
||||
JSONObject warning = jsonObject.optJSONObject("values");
|
||||
if (warning != null) {
|
||||
String type = warning.optString("type");
|
||||
String content = warning.optString("content");
|
||||
String value = warning.optString("value");
|
||||
String level = warning.optString("level");
|
||||
CupidLogUtils.e(String.format("--->type:%s, content:%s, value:%s, level:%s", type, content, value, level));
|
||||
if (adasListener != null) {
|
||||
adasListener.onWarnMessage(new WarnMessageInfo(type, content, value, level));
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package com.zhidao.support.adas.high.queue;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.BlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
|
||||
/**
|
||||
* 公共缓存队列
|
||||
* 只做两件事:(1)生产;(2)消费
|
||||
*/
|
||||
public class PublicQueue<T> {
|
||||
|
||||
private BlockingDeque<T> blockingDeque = new LinkedBlockingDeque<>();//缓冲区
|
||||
|
||||
public static PublicQueue publicQueue;
|
||||
|
||||
public static synchronized <T> PublicQueue<T> getInstance() {
|
||||
if (publicQueue == null) {
|
||||
publicQueue = new PublicQueue<T>();
|
||||
}
|
||||
return publicQueue;
|
||||
}
|
||||
|
||||
public void add(T msg) {
|
||||
|
||||
try {
|
||||
blockingDeque.put(msg);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 先移除最新的然后添加最新的
|
||||
*
|
||||
* @param msg
|
||||
*/
|
||||
public void removeLastPutLast(T msg) {
|
||||
|
||||
try {
|
||||
//移除最新的 然后把最新的添加到队尾
|
||||
blockingDeque.takeFirst();
|
||||
blockingDeque.put(msg);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public T remove() {
|
||||
|
||||
T t = null;
|
||||
try {
|
||||
t = blockingDeque.take();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空所有数据
|
||||
*/
|
||||
public void clear(){
|
||||
if (blockingDeque!=null){
|
||||
blockingDeque.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取个数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getSize() {
|
||||
return blockingDeque.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除最后一个
|
||||
*/
|
||||
public void removeLast() {
|
||||
blockingDeque.removeLast();
|
||||
}
|
||||
|
||||
|
||||
public String iteratorData(){
|
||||
StringBuilder stringBuilder=new StringBuilder();
|
||||
Iterator<T> iterater = blockingDeque.iterator();
|
||||
while (iterater.hasNext()){
|
||||
T data = iterater.next();
|
||||
stringBuilder.append(","+data);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.zhidao.support.adas.high.queue;
|
||||
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* author nieyunlong
|
||||
*
|
||||
* @des
|
||||
* @date 2021/3/10
|
||||
*/
|
||||
public class UdpMsgModel {
|
||||
|
||||
/**
|
||||
* 发送数据类型
|
||||
* 1 json,2 pb
|
||||
*/
|
||||
private int type;
|
||||
|
||||
/**
|
||||
* 当前接收到的时间
|
||||
*/
|
||||
private long receiverDataTimeUdp;
|
||||
|
||||
/**
|
||||
* udp 数据
|
||||
*/
|
||||
private String content;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public long getReceiverDataTimeUdp() {
|
||||
return receiverDataTimeUdp;
|
||||
}
|
||||
|
||||
public void setReceiverDataTimeUdp(long receiverDataTimeUdp) {
|
||||
this.receiverDataTimeUdp = receiverDataTimeUdp;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "UdpMsgModel{" +
|
||||
"receiverDataTimeUdp=" + receiverDataTimeUdp +
|
||||
", content='" + content + '\'' +
|
||||
", type='" + type + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.zhidao.support.adas.high.queue;
|
||||
|
||||
import com.zhidao.support.adas.high.AdasChannel;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.thread.QueuedWork;
|
||||
import com.zhidao.support.adas.high.thread.callback.NormalCallback;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* author : peng hongqiu
|
||||
* e-mail : penghongqiu@163.com
|
||||
* date : 2020/12/22 11:46
|
||||
* desc :
|
||||
* version:
|
||||
*/
|
||||
public class UdpQueueManager {
|
||||
|
||||
private static UdpQueueManager sInstance = new UdpQueueManager();
|
||||
//存储dup发送的数据
|
||||
PublicQueue<String> publicQueue = new PublicQueue<>();
|
||||
//实时消费
|
||||
private boolean runConsumerFlag = true;
|
||||
private AdasChannel adasChannel;
|
||||
private RealTimeConsumerFrameMission realTimeConsumerFrameMission;
|
||||
private Future<String> mFutureTask;
|
||||
|
||||
public static UdpQueueManager getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private UdpQueueManager() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addQueueData(String data) {
|
||||
publicQueue.add(data);
|
||||
}
|
||||
|
||||
public void registerAdasChannel(AdasChannel adasChannel) {
|
||||
this.adasChannel = adasChannel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实时消费帧 消费完一帧 立马取最新一帧
|
||||
*/
|
||||
private class RealTimeConsumerFrameMission extends NormalCallback<String> {
|
||||
//消费者
|
||||
private PublicQueue<String> mPublicQueue;
|
||||
|
||||
public RealTimeConsumerFrameMission(PublicQueue<String> publicQueue) {
|
||||
mPublicQueue = publicQueue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String doInBackground() {
|
||||
try {
|
||||
while (runConsumerFlag) {
|
||||
String data = mPublicQueue.remove();
|
||||
if (adasChannel != null) {
|
||||
adasChannel.udpDataManage(data);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return super.doInBackground();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
runConsumerFlag = false;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void initDector() {
|
||||
CupidLogUtils.w("===>UdpQueueManager initDector");
|
||||
release();
|
||||
runConsumerFlag = true;
|
||||
if (realTimeConsumerFrameMission == null){
|
||||
realTimeConsumerFrameMission = new RealTimeConsumerFrameMission(publicQueue);
|
||||
}
|
||||
mFutureTask = QueuedWork.submit(null, realTimeConsumerFrameMission);
|
||||
}
|
||||
|
||||
public void release() {
|
||||
publicQueue.clear();
|
||||
stopCallBack();
|
||||
}
|
||||
|
||||
private void stopCallBack() {
|
||||
if (realTimeConsumerFrameMission != null) {
|
||||
realTimeConsumerFrameMission.stop();
|
||||
realTimeConsumerFrameMission = null;
|
||||
}
|
||||
if (mFutureTask != null) {
|
||||
mFutureTask.cancel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.zhidao.support.adas.high.queue;
|
||||
|
||||
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.socket.FpgaSocket;
|
||||
import com.zhidao.support.adas.high.thread.QueuedWork;
|
||||
import com.zhidao.support.adas.high.thread.callback.NormalCallback;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* author : peng hongqiu
|
||||
* e-mail : penghongqiu@163.com
|
||||
* date : 2020/12/22 11:46
|
||||
* desc :
|
||||
* version:
|
||||
*/
|
||||
public class WSByteQueueManager {
|
||||
|
||||
private static WSByteQueueManager sInstance = new WSByteQueueManager();
|
||||
//存储dup/websocket发送的数据
|
||||
PublicQueue<ByteString> publicQueue = new PublicQueue<>();
|
||||
private RealTimeConsumerFrameMission realTimeConsumerFrameMission;
|
||||
|
||||
private Future<ByteString> mFutureTask;
|
||||
|
||||
private FpgaSocket.IWebSocketConnectListener webSocketConnectListener;
|
||||
|
||||
public static WSByteQueueManager getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private WSByteQueueManager() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addQueueData(ByteString data) {
|
||||
// CupidLogUtils.w("====>生产者几个数据" + publicQueue.getSize() + ",list" + publicQueue.iteratorData());
|
||||
publicQueue.add(data);
|
||||
}
|
||||
|
||||
public void registerWebSocketListener(FpgaSocket.IWebSocketConnectListener webSocketConnectListener) {
|
||||
this.webSocketConnectListener = webSocketConnectListener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实时消费帧 消费完一帧 立马取最新一帧
|
||||
*/
|
||||
private class RealTimeConsumerFrameMission extends NormalCallback<ByteString>{
|
||||
//消费者
|
||||
private PublicQueue<ByteString> mPublicQueue;
|
||||
//实时消费
|
||||
private boolean runConsumerFlag = true;
|
||||
public RealTimeConsumerFrameMission(PublicQueue<ByteString> publicQueue) {
|
||||
mPublicQueue = publicQueue;
|
||||
}
|
||||
public ByteString doInBackground() {
|
||||
try {
|
||||
while (runConsumerFlag) {
|
||||
// CupidLogUtils.w("===>消费者==>ConsumerDataMission");
|
||||
ByteString data = mPublicQueue.remove();
|
||||
// CupidLogUtils.w("===>socket消费者" + data + ",内容个数" + mPublicQueue.getSize() + "\n所有数据" + mPublicQueue.iteratorData());
|
||||
if (webSocketConnectListener != null) {
|
||||
webSocketConnectListener.onMessage(data);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return super.doInBackground();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
runConsumerFlag = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public synchronized void initDector() {
|
||||
release();
|
||||
realTimeConsumerFrameMission = new RealTimeConsumerFrameMission(publicQueue);
|
||||
mFutureTask = QueuedWork.submit(null,realTimeConsumerFrameMission);
|
||||
|
||||
}
|
||||
|
||||
public void release() {
|
||||
publicQueue.clear();
|
||||
stopCallBack();
|
||||
}
|
||||
|
||||
private void stopCallBack() {
|
||||
if (realTimeConsumerFrameMission != null) {
|
||||
realTimeConsumerFrameMission.stop();
|
||||
realTimeConsumerFrameMission = null;
|
||||
}
|
||||
if (mFutureTask != null) {
|
||||
mFutureTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.zhidao.support.adas.high.queue;
|
||||
|
||||
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.socket.FpgaSocket;
|
||||
import com.zhidao.support.adas.high.thread.QueuedWork;
|
||||
import com.zhidao.support.adas.high.thread.callback.NormalCallback;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
* author : peng hongqiu
|
||||
* e-mail : penghongqiu@163.com
|
||||
* date : 2020/12/22 11:46
|
||||
* desc :
|
||||
* version:
|
||||
*/
|
||||
public class WebSocketQueueManager {
|
||||
|
||||
private static WebSocketQueueManager sInstance = new WebSocketQueueManager();
|
||||
//存储dup/websocket发送的数据
|
||||
PublicQueue<String> publicQueue = new PublicQueue<>();
|
||||
private RealTimeConsumerFrameMission realTimeConsumerFrameMission;
|
||||
|
||||
private Future<String> mFutureTask;
|
||||
|
||||
private FpgaSocket.IWebSocketConnectListener webSocketConnectListener;
|
||||
|
||||
public static WebSocketQueueManager getInstance() {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private WebSocketQueueManager() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void addQueueData(String data) {
|
||||
// CupidLogUtils.w("====>生产者几个数据" + publicQueue.getSize() + ",list" + publicQueue.iteratorData());
|
||||
publicQueue.add(data);
|
||||
}
|
||||
|
||||
public void registerWebSocketListener(FpgaSocket.IWebSocketConnectListener webSocketConnectListener) {
|
||||
this.webSocketConnectListener = webSocketConnectListener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实时消费帧 消费完一帧 立马取最新一帧
|
||||
*/
|
||||
private class RealTimeConsumerFrameMission extends NormalCallback<String>{
|
||||
//消费者
|
||||
private PublicQueue<String> mPublicQueue;
|
||||
//实时消费
|
||||
private boolean runConsumerFlag = true;
|
||||
public RealTimeConsumerFrameMission(PublicQueue<String> publicQueue) {
|
||||
mPublicQueue = publicQueue;
|
||||
}
|
||||
public String doInBackground() {
|
||||
try {
|
||||
while (runConsumerFlag) {
|
||||
// CupidLogUtils.w("===>消费者==>ConsumerDataMission");
|
||||
String data = mPublicQueue.remove();
|
||||
// CupidLogUtils.w("===>socket消费者" + data + ",内容个数" + mPublicQueue.getSize() + "\n所有数据" + mPublicQueue.iteratorData());
|
||||
if (webSocketConnectListener != null) {
|
||||
webSocketConnectListener.onMessage(data);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return super.doInBackground();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
runConsumerFlag = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public synchronized void initDector() {
|
||||
release();
|
||||
realTimeConsumerFrameMission = new RealTimeConsumerFrameMission(publicQueue);
|
||||
mFutureTask = QueuedWork.submit(null,realTimeConsumerFrameMission);
|
||||
|
||||
}
|
||||
|
||||
public void release() {
|
||||
publicQueue.clear();
|
||||
stopCallBack();
|
||||
}
|
||||
|
||||
private void stopCallBack() {
|
||||
if (realTimeConsumerFrameMission != null) {
|
||||
realTimeConsumerFrameMission.stop();
|
||||
realTimeConsumerFrameMission = null;
|
||||
}
|
||||
if (mFutureTask != null) {
|
||||
mFutureTask.cancel(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,325 @@
|
||||
package com.zhidao.support.adas.high.socket;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.zhidao.support.adas.high.AdasChannel;
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.bean.FaceLoginResponse;
|
||||
import com.zhidao.support.adas.high.common.DigitalTrans;
|
||||
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 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 adas.Adas;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.WebSocket;
|
||||
import okhttp3.WebSocketListener;
|
||||
import okio.ByteString;
|
||||
|
||||
import static com.zhidao.support.adas.high.common.Constants.WS_IP_HOST_HEAD;
|
||||
import static com.zhidao.support.adas.high.common.Constants.WS_PORT;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: FpgaSocket
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/7 13:36
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/7 13:36
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class FpgaSocket implements IWebSocket {
|
||||
private OkHttpClient client;
|
||||
|
||||
private WebSocket mWebSocket;
|
||||
|
||||
private EchoWebSocketListener listener;
|
||||
|
||||
private Request request;
|
||||
|
||||
private OkHttpClient.Builder okBuilder;
|
||||
|
||||
private JSONObject jsonObject;
|
||||
/**
|
||||
* 是否是用户主动关闭socket
|
||||
*/
|
||||
private boolean isUserCloseWebSocket = false;
|
||||
|
||||
public FpgaSocket() {
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
if (listener == null) {
|
||||
listener = new EchoWebSocketListener();
|
||||
}
|
||||
if (okBuilder == null) {
|
||||
okBuilder = new OkHttpClient.Builder();
|
||||
okBuilder.readTimeout(20, TimeUnit.SECONDS);
|
||||
okBuilder.connectTimeout(20, TimeUnit.SECONDS);
|
||||
}
|
||||
if (client == null) {
|
||||
client = okBuilder.build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectWebSocket(String address) {
|
||||
String wsHost = WS_IP_HOST_HEAD + address + WS_PORT;
|
||||
CupidLogUtils.e("--->connectWebSocket" + wsHost);
|
||||
init();
|
||||
if (client != null) {
|
||||
request = new Request.Builder()
|
||||
.url(wsHost)
|
||||
.build();
|
||||
client.newWebSocket(request, listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeWebSocket() {
|
||||
CupidLogUtils.e("===>closeWebSocket");
|
||||
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.e("===>webSocket关闭了吗" + isClose);
|
||||
|
||||
mWebSocket.cancel();
|
||||
mWebSocket = null;
|
||||
}
|
||||
client = null;
|
||||
request = null;
|
||||
listener = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendDataWebSocket(String data) {
|
||||
if (mWebSocket != null) {
|
||||
boolean result = mWebSocket.send(data);
|
||||
CupidLogUtils.e("FpgaSocket--->sendDataWebSocket--->String: " + data + ", result= " + result);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendDataWebSocket(ByteString data) {
|
||||
if (mWebSocket != null) {
|
||||
boolean result = mWebSocket.send(data);
|
||||
CupidLogUtils.e("FpgaSocket--->sendDataWebSocket--->ByteString: " + data + ", result= " + result);
|
||||
return result;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getConfigData(String appId, String userId) {
|
||||
CupidLogUtils.e("FpgaSocket--->getConfigData appId: " + appId + ", userId:" + userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doConfigChanged(int type, String ip, List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos) {
|
||||
CupidLogUtils.e("FpgaSocket--->doConfigChanged, type: " + type + " ip: " + ip + " configInfos:" + configInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doConfigChanged(List<FaceLoginResponse.DataBean.ConfigInfoHistoryBean> configInfos) {
|
||||
CupidLogUtils.e("FpgaSocket--->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.e("FpgaSocket--->saveShotPic");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTouchImage(String url, double x, double y) {
|
||||
CupidLogUtils.e("FpgaSocket--->getTouchImage, url: " + url + " ,x: " + x + " ,y: " + y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doRecognizeImage(File file, String deviceId, String tag) {
|
||||
CupidLogUtils.e("FpgaSocket--->doRecognizeImage");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getUserAchieveInfo(String userId) {
|
||||
CupidLogUtils.e("FpgaSocket--->getUserAchieveInfo, userId:" + userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getNaviInfo(int type) {
|
||||
CupidLogUtils.e("FpgaSocket--->getNaviInfo, type:" + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncMedalDetailInfo(String userId, int action, String medalType) {
|
||||
CupidLogUtils.e("FpgaSocket--->syncMedalDetailInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCarModelInfo(String s, int id) {
|
||||
CupidLogUtils.e("FpgaSocket--->getCarModelInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doUpdateCarInfo(String userId, String brandId, String brandName, String modelId, String modelName, String styleId, String styleName) {
|
||||
CupidLogUtils.e("FpgaSocket--->doUpdateCarInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getApkAndFireWareInfo(String deviceId, String userId, int apkVersionCode, int xvideoCppVersionCode, int appId) {
|
||||
CupidLogUtils.e("FpgaSocket--->getApkAndFireWareInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getFireWareBaseInfo(String baseUrl) {
|
||||
CupidLogUtils.e("FpgaSocket--->getFireWareBaseInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFirmWareUpdateInfo(String baseUrl, String json) {
|
||||
CupidLogUtils.e("FpgaSocket--->sendFirmWareUpdateInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startNavigate(String userId, String naviStartName, String naviEndName) {
|
||||
CupidLogUtils.e("FpgaSocket--->startNavigate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncUserNavigateInfo(String navigateId, String longtitude, String latitude, String poId, String currentSpeed) {
|
||||
CupidLogUtils.e("FpgaSocket--->syncUserNavigateInfo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doVerticalLineConfigCompleted() {
|
||||
CupidLogUtils.e("FpgaSocket--->doVerticalLineConfigCompleted");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSyncCarSpaceInfo(String carLength, String carWidth, String carHeight) {
|
||||
CupidLogUtils.e("FpgaSocket--->doSyncCarSpaceInfo");
|
||||
}
|
||||
|
||||
private IWebSocketConnectListener mWebSocketConnectListener;
|
||||
|
||||
public interface IWebSocketConnectListener {
|
||||
void onWebSocketConnectSuccess(WebSocket webSocket);
|
||||
|
||||
void onWebSocketConnectFailed(WebSocket webSocket,String t);
|
||||
|
||||
void onMessage(String message);
|
||||
|
||||
void onMessage(ByteString bytes) throws InvalidProtocolBufferException;
|
||||
}
|
||||
|
||||
public void setWebSocketListener(IWebSocketConnectListener listener) {
|
||||
mWebSocketConnectListener = listener;
|
||||
}
|
||||
|
||||
public class EchoWebSocketListener extends WebSocketListener {
|
||||
@Override
|
||||
public void onOpen(WebSocket webSocket, Response response) {
|
||||
super.onOpen(webSocket, response);
|
||||
mWebSocket = webSocket;
|
||||
CupidLogUtils.e("--->websocket response connect success");
|
||||
mWebSocketConnectListener.onWebSocketConnectSuccess(webSocket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, String text) {
|
||||
super.onMessage(webSocket, text);
|
||||
CupidLogUtils.e("--->websocket response connect text" + text);
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
return;
|
||||
}
|
||||
if (AdasChannel.isUseQueue) {
|
||||
WebSocketQueueManager.getInstance().addQueueData(text);
|
||||
} else {
|
||||
mWebSocketConnectListener.onMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMessage(WebSocket webSocket, ByteString bytes) {
|
||||
super.onMessage(webSocket, bytes);
|
||||
CupidLogUtils.e("--->websocket response connect byte" + bytes.hex());
|
||||
if (bytes==null){
|
||||
return;
|
||||
}
|
||||
if (AdasChannel.isUseQueue) {
|
||||
WSByteQueueManager.getInstance().addQueueData(bytes);
|
||||
} else {
|
||||
try {
|
||||
mWebSocketConnectListener.onMessage(bytes);
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosing(WebSocket webSocket, int code, String reason) {
|
||||
super.onClosing(webSocket, code, reason);
|
||||
mWebSocket = null;
|
||||
CupidLogUtils.e("--->websocket onClosing==> onClosing" + reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(WebSocket webSocket, int code, String reason) {
|
||||
super.onClosed(webSocket, code, reason);
|
||||
mWebSocket = null;
|
||||
CupidLogUtils.e("--->websocket onClosed ==> " + reason);
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(webSocket,reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
|
||||
super.onFailure(webSocket, t, response);
|
||||
mWebSocket = null;
|
||||
CupidLogUtils.e("--->websocket onFailure ===>" + t.getMessage());
|
||||
mWebSocketConnectListener.onWebSocketConnectFailed(webSocket,t.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public WebSocket getWebSocket() {
|
||||
return mWebSocket;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: IWebSocket
|
||||
* @Description: java类作用描述
|
||||
* @Author: fenghl
|
||||
* @CreateDate: 2020/2/7 13:28
|
||||
* @UpdateUser: 更新者:
|
||||
* @UpdateDate: 2020/2/7 13:28
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public interface IWebSocket {
|
||||
/**
|
||||
* 连接socket
|
||||
*/
|
||||
void connectWebSocket(String address);
|
||||
|
||||
/**
|
||||
* 关闭webSocket
|
||||
*/
|
||||
void closeWebSocket();
|
||||
|
||||
/**
|
||||
* websocket send data
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
boolean sendDataWebSocket(String data);
|
||||
boolean sendDataWebSocket(ByteString data);
|
||||
|
||||
/**
|
||||
* 云端拉取配置信息
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
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);
|
||||
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.zhidao.support.adas.high.socket;
|
||||
|
||||
/**
|
||||
* @author nie yunlong
|
||||
* @description 接收消息type
|
||||
* @date 2018/7/3
|
||||
*/
|
||||
public enum SocketMsgType {
|
||||
|
||||
/**
|
||||
* 警告
|
||||
*/
|
||||
MSG_WARNING_TYPE(1, "警告"),
|
||||
/**
|
||||
* 视频分辨率
|
||||
*/
|
||||
MSG_VIDEO_INFO_TYPE(2, "视频分辨率"),
|
||||
|
||||
/**
|
||||
* 控制台开
|
||||
*/
|
||||
MSG_CONSOLE_OPEN_TYPE(3, "控制台开"),
|
||||
/**
|
||||
* 控制台关
|
||||
*/
|
||||
MSG_CONSOLE_CLOSE_TYPE(4, "控制台关"),
|
||||
/**
|
||||
* 车道线曲率
|
||||
*/
|
||||
MSG_CONSOLE_ROAD_TYPE(11, "车道线曲率"),
|
||||
/**
|
||||
* 是否是最左侧车道
|
||||
*/
|
||||
MSG_IS_ROAD_LEFT(10, "获取位置"),
|
||||
|
||||
/**
|
||||
* 获取通知进度
|
||||
*/
|
||||
MSG_UPGRADE_NOTIFY(12,"通知进度");
|
||||
|
||||
|
||||
int mMsgType;
|
||||
String mMsgContent;
|
||||
|
||||
SocketMsgType(int msgType, String msgContent) {
|
||||
this.mMsgType = msgType;
|
||||
this.mMsgContent = msgContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取msgType
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getMsgType() {
|
||||
return mMsgType;
|
||||
}
|
||||
|
||||
public String getmMsgContent() {
|
||||
return mMsgContent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.zhidao.support.adas.high.socket.read;
|
||||
|
||||
import com.zhidao.support.adas.high.common.DigitalTrans;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/10/20
|
||||
*/
|
||||
public class DefaultMessageProtocol implements IMessageProtocol{
|
||||
@Override
|
||||
public int getMagicCodeLength() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPackageLength() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffsetLength() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int getOutHeader(){
|
||||
return getMagicCodeLength()+getPackageLength()+getOffsetLength();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeaderLength(byte[] offset) {
|
||||
if (offset == null) {
|
||||
return 0;
|
||||
}
|
||||
String lengthStr = DigitalTrans.byte2hex(offset);
|
||||
int length = DigitalTrans.hexStringToAlgorism(lengthStr);
|
||||
return length - 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPayloadLength(byte[] readData,byte[] offset) {
|
||||
if (readData == null){
|
||||
return 0;
|
||||
}
|
||||
if (offset == null){
|
||||
return DigitalTrans.hexStringToAlgorism(DigitalTrans.byte2hex(readData));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.zhidao.support.adas.high.socket.read;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/10/20
|
||||
*/
|
||||
public interface IMessageProtocol {
|
||||
/**
|
||||
* 获取magicCode的长度
|
||||
*/
|
||||
int getMagicCodeLength();
|
||||
|
||||
/**
|
||||
* 包长度
|
||||
*/
|
||||
int getPackageLength();
|
||||
|
||||
/**
|
||||
* 数据偏移量的长度
|
||||
*/
|
||||
int getOffsetLength();
|
||||
|
||||
/**
|
||||
* 获取header数据长度
|
||||
*/
|
||||
int getHeaderLength(byte[] offset);
|
||||
|
||||
/**
|
||||
* 消息体长度
|
||||
*/
|
||||
int getPayloadLength(byte[] readData,byte[] offset);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.zhidao.support.adas.high.socket.read;
|
||||
|
||||
import com.zhidao.support.adas.high.common.DigitalTrans;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/10/20
|
||||
*/
|
||||
public class OriginReadData implements Serializable {
|
||||
/**
|
||||
* 用于检查数据是否为正确数据
|
||||
* mg=0x6d67
|
||||
*/
|
||||
private byte[] magicCode;
|
||||
|
||||
/**
|
||||
* 包长度
|
||||
*/
|
||||
private byte[] packageLength;
|
||||
|
||||
/**
|
||||
* 偏移量,用于计算header长度
|
||||
*/
|
||||
private byte[] offset;
|
||||
|
||||
/**
|
||||
* 头部消息,装载消息类型等
|
||||
* 长度=offset-out_header.length
|
||||
*/
|
||||
private byte[] header;
|
||||
|
||||
/**
|
||||
* 负载数据:真实上报的数据
|
||||
*/
|
||||
private byte[] payload;
|
||||
|
||||
|
||||
/**
|
||||
* 获取out_header 由魔数、包大小、payload偏移量组成;
|
||||
* 用于识别连接数据和数据报解码使用。
|
||||
* 固定8个字节,否则出错。
|
||||
*/
|
||||
public byte[] getOutHeaderBytes() {
|
||||
byte[] bytes = DigitalTrans.concatBytes(getMagicCode(), getPackageLength());
|
||||
byte[] outHeader = DigitalTrans.concatBytes(bytes, getOffset());
|
||||
return outHeader;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取完整的数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public byte[] getOriginDataBytes() {
|
||||
byte[] bytes = DigitalTrans.concatBytes(getOutHeaderBytes(), getHeader());
|
||||
byte[] originData = DigitalTrans.concatBytes(bytes, getPayload());
|
||||
return originData;
|
||||
}
|
||||
|
||||
|
||||
public byte[] getMagicCode() {
|
||||
return magicCode;
|
||||
}
|
||||
|
||||
public void setMagicCode(byte[] magicCode) {
|
||||
this.magicCode = magicCode;
|
||||
}
|
||||
|
||||
public byte[] getPackageLength() {
|
||||
return packageLength;
|
||||
}
|
||||
|
||||
public void setPackageLength(byte[] packageLength) {
|
||||
this.packageLength = packageLength;
|
||||
}
|
||||
|
||||
public byte[] getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void setOffset(byte[] offset) {
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public byte[] getHeader() {
|
||||
return header;
|
||||
}
|
||||
|
||||
public void setHeader(byte[] header) {
|
||||
this.header = header;
|
||||
}
|
||||
|
||||
public byte[] getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(byte[] payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.zhidao.support.adas.high.socket.read;
|
||||
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils;
|
||||
import com.zhidao.support.adas.high.common.DigitalTrans;
|
||||
import com.zhidao.support.adas.high.udp.CupidUdpConstract;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.IntBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* @author song kenan
|
||||
* @des
|
||||
* @date 2021/10/20
|
||||
*/
|
||||
public class SocketReader {
|
||||
private DefaultMessageProtocol messageProtocol;
|
||||
private static final byte[] mg = new byte[]{(byte) 0x6d, 0x67};
|
||||
|
||||
public SocketReader() {
|
||||
messageProtocol = new DefaultMessageProtocol();
|
||||
}
|
||||
|
||||
public OriginReadData read(ByteString bytes) {
|
||||
OriginReadData originalData = new OriginReadData();
|
||||
OriginReadData originReadData = readData(bytes, originalData);
|
||||
//分发
|
||||
return originReadData;
|
||||
|
||||
}
|
||||
|
||||
private synchronized OriginReadData readData(ByteString bytes, OriginReadData originalData) {
|
||||
// CupidLogUtils.w("--->websocket byte read bytes :"+bytes.hex());
|
||||
//读取magicCode
|
||||
ByteString magicCode = bytes.substring(0, messageProtocol.getMagicCodeLength());
|
||||
originalData.setMagicCode(magicCode.toByteArray());
|
||||
// CupidLogUtils.w("--->websocket byte read magic :"+magicCode.hex());
|
||||
if (Arrays.equals(magicCode.toByteArray(), mg)) {
|
||||
//读取offset
|
||||
ByteString offset = bytes.substring(messageProtocol.getMagicCodeLength(), messageProtocol.getMagicCodeLength() + messageProtocol.getOffsetLength());
|
||||
originalData.setOffset(offset.toByteArray());
|
||||
// CupidLogUtils.w("--->websocket byte read offset :"+offset.hex()+";offset length="+ DigitalTrans.hexStringToAlgorism(offset.hex()));
|
||||
//读取packageLength
|
||||
ByteString packageLength = bytes.substring(messageProtocol.getMagicCodeLength() + messageProtocol.getOffsetLength(), messageProtocol.getOutHeader());
|
||||
originalData.setPackageLength(packageLength.toByteArray());
|
||||
// CupidLogUtils.w("--->websocket byte read packageLength :"+packageLength.hex()+";pl="+ DigitalTrans.hexStringToAlgorism(packageLength.hex()));
|
||||
//读取header
|
||||
ByteString header = bytes.substring(messageProtocol.getOutHeader(), messageProtocol.getOutHeader() + messageProtocol.getHeaderLength(offset.toByteArray()));
|
||||
originalData.setHeader(header.toByteArray());
|
||||
// CupidLogUtils.w("--->websocket byte read header :"+header.hex());
|
||||
//读取payload
|
||||
ByteString payload = bytes.substring(messageProtocol.getOutHeader() + messageProtocol.getHeaderLength(offset.toByteArray()));
|
||||
originalData.setPayload(payload.toByteArray());
|
||||
// CupidLogUtils.w("--->websocket byte read payload :"+payload.hex());
|
||||
return originalData;
|
||||
} else {
|
||||
CupidLogUtils.w("--->websocket byte read magicCode error 丢弃");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
Copyright 2017 yangchong211(github.com/yangchong211)
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package com.zhidao.support.adas.high.thread;
|
||||
|
||||
|
||||
|
||||
import com.zhidao.support.adas.high.thread.callback.NormalCallback;
|
||||
import com.zhidao.support.adas.high.thread.callback.ThreadCallback;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
*/
|
||||
public final class CallableWrapper<T> implements Callable<T> {
|
||||
|
||||
private ThreadCallback<T> callback;
|
||||
|
||||
private Callable<T> proxy;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param proxy 线程优先级
|
||||
*/
|
||||
public CallableWrapper(Callable<T> proxy, NormalCallback<T> normalCallback) {
|
||||
this.proxy = proxy;
|
||||
this.callback = normalCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* 详细可以看我的GitHub:https://github.com/yangchong211
|
||||
* 自定义Callable继承Callable<T>类,Callable 是在 JDK1.5 增加的。
|
||||
* Callable 的 call() 方法可以返回值和抛出异常
|
||||
*
|
||||
* @return 泛型
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Override
|
||||
public T call() {
|
||||
if (callback != null) {
|
||||
//开始
|
||||
callback.onStart();
|
||||
}
|
||||
T t = null;
|
||||
try {
|
||||
t = proxy == null ? null : proxy.call();
|
||||
if (callback != null) {
|
||||
T callInBackground = callback.doInBackground();
|
||||
if (callInBackground != null) {
|
||||
t = callInBackground;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//异常错误
|
||||
if (callback != null) {
|
||||
callback.onError(e);
|
||||
}
|
||||
} finally {
|
||||
//完成
|
||||
if (callback != null) {
|
||||
callback.onCompleted();
|
||||
}
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.zhidao.support.adas.high.thread;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
|
||||
import com.zhidao.support.adas.high.thread.callback.NormalCallback;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Created by nieyunlong on 17/8/8.
|
||||
* 队列
|
||||
*/
|
||||
|
||||
public class QueuedWork {
|
||||
|
||||
private static Handler uiHandler;
|
||||
|
||||
/*sdk请求量不是很大*/
|
||||
private static final int MAX_MISSION_COUNT = 1; //设置线程池最大线程个数
|
||||
private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
|
||||
// We want at least 2 threads and at most 4 threads in the core pool,
|
||||
// preferring to have 1 less than the CPU count to avoid saturating
|
||||
// the CPU with background work
|
||||
// private static final int CORE_POOL_SIZE = Math.max(2, Math.min(CPU_COUNT - 1, 4));
|
||||
private static final int CORE_POOL_SIZE = 3;
|
||||
private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1;
|
||||
|
||||
public static final ThreadPoolExecutor THREAD_POOL_EXECUTOR;
|
||||
|
||||
static {
|
||||
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, 30, TimeUnit.SECONDS,
|
||||
new LinkedBlockingDeque<Runnable>(128));
|
||||
threadPoolExecutor.allowCoreThreadTimeOut(true);
|
||||
THREAD_POOL_EXECUTOR = threadPoolExecutor;
|
||||
}
|
||||
|
||||
|
||||
public static void runInMain(Runnable paramRunnable) {
|
||||
if (uiHandler == null)
|
||||
uiHandler = new Handler(Looper.getMainLooper());
|
||||
uiHandler.post(paramRunnable);
|
||||
}
|
||||
|
||||
public static void runInBack(Runnable task) {
|
||||
THREAD_POOL_EXECUTOR.execute(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 建议停止正在执行的任务
|
||||
*/
|
||||
public static void shutDownNow() {
|
||||
THREAD_POOL_EXECUTOR.shutdownNow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 建议停止正在执行的任务
|
||||
*/
|
||||
public static void shutDown() {
|
||||
THREAD_POOL_EXECUTOR.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 发射任务
|
||||
* 提交任务有返回值
|
||||
* 当我们使用submit来提交任务时,它会返回一个future,我们就可以通过这个future来判断任务是否执行成功,
|
||||
* 还可以通过future的get方法来获取返回值。如果子线程任务没有完成,get方法会阻塞住直到任务完成,
|
||||
* 而使用get(long timeout, TimeUnit unit)方法则会阻塞一段时间后立即返回,这时候有可能任务并没有执行完。
|
||||
*
|
||||
* @param callable callable
|
||||
* @param <T> type
|
||||
* @return {@link Future}
|
||||
*/
|
||||
public static <T> Future<T> submit(Callable<T> callable, NormalCallback<T> normalCallback) {
|
||||
callable = new CallableWrapper<>(callable, normalCallback);
|
||||
Future<T> result = THREAD_POOL_EXECUTOR.submit(callable);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除队列里面的任务
|
||||
*/
|
||||
public static int getQueueSize() {
|
||||
if (null != THREAD_POOL_EXECUTOR) {
|
||||
BlockingQueue<Runnable> queue = THREAD_POOL_EXECUTOR.getQueue();
|
||||
return queue.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static abstract class ZSAsyncTask<Result> {
|
||||
|
||||
protected Runnable thread;
|
||||
|
||||
protected void onPreExecute() {
|
||||
}
|
||||
|
||||
protected abstract Result doInBackground();
|
||||
|
||||
protected void onPostExecute(Result paramResult) {
|
||||
}
|
||||
|
||||
public final ZSAsyncTask<Result> execute() {
|
||||
this.thread = new Runnable() {
|
||||
public void run() {
|
||||
final Result var1 = ZSAsyncTask.this.doInBackground();
|
||||
QueuedWork.runInMain(new Runnable() {
|
||||
public void run() {
|
||||
ZSAsyncTask.this.onPostExecute(var1);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
QueuedWork.runInMain(new Runnable() {
|
||||
public void run() {
|
||||
//pre execute
|
||||
ZSAsyncTask.this.onPreExecute();
|
||||
runInBack(ZSAsyncTask.this.thread);
|
||||
}
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private static final ThreadFactory sThreadFactory = new ThreadFactory() {
|
||||
private final AtomicInteger mCount = new AtomicInteger(1);
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
return new Thread(r, "ZSAsyncTask #" + mCount.getAndIncrement());
|
||||
}
|
||||
};
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user