From 877f35b6150532704fb2440ec8d272f111ffe138 Mon Sep 17 00:00:00 2001 From: xinfengkun Date: Wed, 19 Jan 2022 17:19:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86ADAS=20LIB=E5=B7=A5=E7=A8=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=85=A8=E9=83=A8=E7=A7=BB=E5=8A=A8=E5=88=B0=E9=B9=B0?= =?UTF-8?q?=E7=9C=BC=E9=A1=B9=E7=9B=AE=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- gradle.properties | 1 + libraries/mogo-adas/build.gradle | 115 +- .../mogo-adas/src/main/AndroidManifest.xml | 7 +- .../src/main/java/com/mogo/adas/占位 | 0 .../zhidao/support/adas/high/AdasChannel.java | 693 ++++++++ .../zhidao/support/adas/high/AdasManager.java | 324 ++++ .../support/adas/high/IAdasNetCommApi.java | 113 ++ .../support/adas/high/OnAdasListener.java | 156 ++ .../high/OnAdasMsgConnectStatusListener.java | 18 + .../support/adas/high/bean/AdasConfig.java | 49 + .../adas/high/bean/AutopilotConfig.java | 46 + .../adas/high/bean/AutopilotControl.java | 53 + .../adas/high/bean/AutopilotRoute.java | 75 + .../adas/high/bean/AutopilotSnRequest.java | 29 + .../adas/high/bean/AutopilotSpeedParam.java | 39 + .../adas/high/bean/AutopilotStatus.java | 139 ++ .../adas/high/bean/AutopilotTrajectory.java | 34 + .../adas/high/bean/AutopilotWayArrive.java | 115 ++ .../support/adas/high/bean/BaseInfo.java | 23 + .../support/adas/high/bean/BasicInfo.java | 61 + .../support/adas/high/bean/CarLaneInfo.java | 63 + .../support/adas/high/bean/CarStateInfo.java | 261 +++ .../support/adas/high/bean/ConfigInfo.java | 129 ++ .../adas/high/bean/FaceLoginResponse.java | 417 +++++ .../adas/high/bean/IPCUpgradeInfo.java | 62 + .../IPCUpgradePatchDownloadStatusInfo.java | 120 ++ .../adas/high/bean/IPCUpgradeStateInfo.java | 70 + .../adas/high/bean/LightStatueInfo.java | 143 ++ .../adas/high/bean/MapLocationInfo.java | 110 ++ .../support/adas/high/bean/ObstaclesInfo.java | 82 + .../support/adas/high/bean/RectInfo.java | 344 ++++ .../RemoteControlAutoPilotParameters.java | 139 ++ .../support/adas/high/bean/RouteInfo.java | 23 + .../support/adas/high/bean/SSHResult.java | 36 + .../adas/high/bean/TrajectoryInfo.java | 125 ++ .../support/adas/high/bean/UserInfo.java | 28 + .../adas/high/bean/WarnMessageInfo.java | 80 + .../bean/guardian/AutopilotGuardianInfo.java | 113 ++ .../adas/high/bean/guardian/GuardianItem.java | 39 + .../high/bean/guardian/GuardianItemsName.java | 41 + .../high/bean/guardian/GuardianModule.java | 41 + .../high/bean/guardian/GuardianSubmodule.java | 85 + .../bean/record/AutopilotIdentifyInfo.java | 75 + .../bean/record/AutopilotRecordResult.java | 171 ++ .../high/bean/record/RecordCauseParam.java | 66 + .../high/bean/record/RecordDataParam.java | 113 ++ .../adas/high/common/ActionTypeReceive.java | 152 ++ .../adas/high/common/AppPreferenceHelper.java | 280 +++ .../support/adas/high/common/BaseIoUtils.java | 84 + .../adas/high/common/BaseSDCardHelper.java | 276 +++ .../adas/high/common/BaseTimeUtils.java | 139 ++ .../support/adas/high/common/Constants.java | 52 + .../adas/high/common/CupidLogUtils.java | 85 + .../adas/high/common/DigitalTrans.java | 516 ++++++ .../support/adas/high/common/FileUtils.java | 1543 +++++++++++++++++ .../high/common/HandlerThreadManager.java | 63 + .../adas/high/common/IPreferencesHelper.java | 135 ++ .../adas/high/common/LogSaveManage.java | 70 + .../adas/high/common/MgContextUtils.java | 33 + .../adas/high/common/RequestWsMsgType.java | 52 + .../zhidao/support/adas/high/common/SSH.java | 150 ++ .../adas/high/common/ThreadPoolManager.java | 127 ++ .../zhidao/support/adas/high/msg/IMsg.java | 22 + .../adas/high/msg/IMyMessageFactory.java | 20 + .../high/msg/MyAbstractMessageHandler.java | 11 + .../adas/high/msg/MyMessageFactory.java | 242 +++ .../support/adas/high/msg/NuImplMessage.java | 23 + .../adas/high/msg/UdpCarStateMessage.java | 72 + .../adas/high/msg/UdpLanesMessage.java | 28 + .../adas/high/msg/UdpLightStateMessage.java | 29 + .../adas/high/msg/UdpObstaclesMessage.java | 29 + .../adas/high/msg/UdpRenderImageMessage.java | 101 ++ .../high/msg/WsAutopilotArriveMessage.java | 29 + .../adas/high/msg/WsAutopilotConfig.java | 34 + .../adas/high/msg/WsAutopilotGuardian.java | 51 + .../adas/high/msg/WsAutopilotIdentify.java | 75 + .../high/msg/WsAutopilotRouteMessage.java | 26 + .../high/msg/WsAutopilotRoutesMessage.java | 29 + .../adas/high/msg/WsAutopilotSNMessage.java | 27 + .../high/msg/WsAutopilotStatusMessage.java | 28 + .../msg/WsAutopilotTrajectoryMessage.java | 60 + ...ilotUpgradePatchDownloadStatusMessage.java | 25 + .../msg/WsAutopilotUpgradeStatusMessage.java | 25 + .../adas/high/msg/WsImageSizeMessage.java | 40 + .../support/adas/high/msg/WsWarnMessage.java | 43 + .../support/adas/high/queue/PublicQueue.java | 96 + .../support/adas/high/queue/UdpMsgModel.java | 62 + .../adas/high/queue/UdpQueueManager.java | 101 ++ .../adas/high/queue/WSByteQueueManager.java | 107 ++ .../high/queue/WebSocketQueueManager.java | 105 ++ .../support/adas/high/socket/FpgaSocket.java | 325 ++++ .../support/adas/high/socket/IWebSocket.java | 154 ++ .../adas/high/socket/SocketMsgType.java | 62 + .../socket/read/DefaultMessageProtocol.java | 50 + .../high/socket/read/IMessageProtocol.java | 35 + .../adas/high/socket/read/OriginReadData.java | 103 ++ .../adas/high/socket/read/SocketReader.java | 69 + .../adas/high/thread/CallableWrapper.java | 84 + .../support/adas/high/thread/QueuedWork.java | 141 ++ .../high/thread/callback/NormalCallback.java | 44 + .../high/thread/callback/ThreadCallback.java | 47 + .../adas/high/udp/CupidBufStreamImpl.java | 88 + .../adas/high/udp/CupidBufStreamImpl2.java | 54 + .../adas/high/udp/CupidUdpConstract.java | 132 ++ .../support/adas/high/udp/CupidUdpServer.java | 275 +++ .../support/adas/high/udp/IBuffStream.java | 20 + .../adas/high/udp/IConnectRtpListener.java | 25 + .../support/adas/high/udp/IGetH264Data.java | 16 + .../adas/high/udp/IRenderImageListener.java | 81 + .../support/adas/high/udp/RTPUtils.java | 392 +++++ .../high/udp/factory/AbstractUdpImpl.java | 217 +++ .../udp/factory/CupidRenderImageServer.java | 55 + .../high/udp/factory/CupidUdpFactory.java | 37 + .../high/udp/factory/CupidVideoUdpServer.java | 243 +++ .../udp/factory/CupidVideoUdpServer2.java | 247 +++ .../adas/high/udp/factory/IUdpAction.java | 88 + libraries/mogo-adas/src/main/proto/adas.proto | 87 + .../mogo-adas/src/main/proto/car_status.proto | 42 + .../mogo-adas/src/main/proto/geometry.proto | 84 + .../mogo-adas/src/main/proto/header.proto | 23 + .../src/main/proto/mogo_guardian.proto | 76 + .../mogo-adas/src/main/proto/route_list.proto | 27 + .../mogo-adas/src/main/proto/trajectory.proto | 18 + .../src/main/proto/websocket_header.proto | 25 + .../mogo-adas/src/main/res/values/strings.xml | 2 +- 126 files changed, 13792 insertions(+), 41 deletions(-) delete mode 100644 libraries/mogo-adas/src/main/java/com/mogo/adas/占位 create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasMsgConnectStatusListener.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AdasConfig.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotConfig.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotControl.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotRoute.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSnRequest.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSpeedParam.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatus.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotTrajectory.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotWayArrive.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BaseInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BasicInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarLaneInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarStateInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ConfigInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/FaceLoginResponse.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradePatchDownloadStatusInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeStateInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/LightStatueInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/MapLocationInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ObstaclesInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RectInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RemoteControlAutoPilotParameters.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RouteInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/SSHResult.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/TrajectoryInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/UserInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/WarnMessageInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/AutopilotGuardianInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItem.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItemsName.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianModule.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianSubmodule.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotIdentifyInfo.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotRecordResult.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordCauseParam.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordDataParam.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ActionTypeReceive.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AppPreferenceHelper.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseIoUtils.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseSDCardHelper.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseTimeUtils.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/FileUtils.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/HandlerThreadManager.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/IPreferencesHelper.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/LogSaveManage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MgContextUtils.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/RequestWsMsgType.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/SSH.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ThreadPoolManager.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMsg.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMyMessageFactory.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyAbstractMessageHandler.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/NuImplMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpCarStateMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLanesMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLightStateMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpObstaclesMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpRenderImageMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotArriveMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotConfig.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotGuardian.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotIdentify.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRouteMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRoutesMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotSNMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotStatusMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotTrajectoryMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradePatchDownloadStatusMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradeStatusMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsImageSizeMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsWarnMessage.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/PublicQueue.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpMsgModel.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpQueueManager.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WSByteQueueManager.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WebSocketQueueManager.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/FpgaSocket.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/IWebSocket.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/SocketMsgType.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/DefaultMessageProtocol.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/IMessageProtocol.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/OriginReadData.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/SocketReader.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/CallableWrapper.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/QueuedWork.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/NormalCallback.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/ThreadCallback.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl2.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpConstract.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpServer.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IBuffStream.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IConnectRtpListener.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IGetH264Data.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IRenderImageListener.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/RTPUtils.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/AbstractUdpImpl.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidRenderImageServer.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidUdpFactory.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer2.java create mode 100644 libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/IUdpAction.java create mode 100644 libraries/mogo-adas/src/main/proto/adas.proto create mode 100644 libraries/mogo-adas/src/main/proto/car_status.proto create mode 100644 libraries/mogo-adas/src/main/proto/geometry.proto create mode 100644 libraries/mogo-adas/src/main/proto/header.proto create mode 100644 libraries/mogo-adas/src/main/proto/mogo_guardian.proto create mode 100644 libraries/mogo-adas/src/main/proto/route_list.proto create mode 100644 libraries/mogo-adas/src/main/proto/trajectory.proto create mode 100644 libraries/mogo-adas/src/main/proto/websocket_header.proto diff --git a/build.gradle b/build.gradle index 95ee9b6c7f..c6d6a9c787 100644 --- a/build.gradle +++ b/build.gradle @@ -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}" diff --git a/gradle.properties b/gradle.properties index 8c721eea63..2160ee300d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/libraries/mogo-adas/build.gradle b/libraries/mogo-adas/build.gradle index 5d155f536e..e24df46820 100644 --- a/libraries/mogo-adas/build.gradle +++ b/libraries/mogo-adas/build.gradle @@ -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 +// } +//} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/AndroidManifest.xml b/libraries/mogo-adas/src/main/AndroidManifest.xml index e296a58d02..d0a6ae62d1 100644 --- a/libraries/mogo-adas/src/main/AndroidManifest.xml +++ b/libraries/mogo-adas/src/main/AndroidManifest.xml @@ -1,5 +1,6 @@ - - + package="com.zhidao.support.adas.high" > + + + diff --git a/libraries/mogo-adas/src/main/java/com/mogo/adas/占位 b/libraries/mogo-adas/src/main/java/com/mogo/adas/占位 deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java new file mode 100644 index 0000000000..ad481f529f --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasChannel.java @@ -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 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); + } + +} + diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java new file mode 100644 index 0000000000..14eb8a4165 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasManager.java @@ -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(); + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java new file mode 100644 index 0000000000..20f3a04474 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/IAdasNetCommApi.java @@ -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(); +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java new file mode 100644 index 0000000000..cfcf09ba60 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasListener.java @@ -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 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); + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasMsgConnectStatusListener.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasMsgConnectStatusListener.java new file mode 100644 index 0000000000..0ecb9a2b6c --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasMsgConnectStatusListener.java @@ -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); +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AdasConfig.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AdasConfig.java new file mode 100644 index 0000000000..7184cd7732 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AdasConfig.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotConfig.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotConfig.java new file mode 100644 index 0000000000..e8a2e76925 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotConfig.java @@ -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 + '\'' + + '}'; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotControl.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotControl.java new file mode 100644 index 0000000000..f7e6ec1136 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotControl.java @@ -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; + } + } +} + diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotRoute.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotRoute.java new file mode 100644 index 0000000000..1de9990c8b --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotRoute.java @@ -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 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 getModels() { + return models; + } + + public void setModels(List models) { + this.models = models; + } + + @Override + public String toString() { + return "AutopilotRoute{" + + "action='" + action + '\'' + + ", models=" + models + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSnRequest.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSnRequest.java new file mode 100644 index 0000000000..1ad4199bd5 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSnRequest.java @@ -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; + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSpeedParam.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSpeedParam.java new file mode 100644 index 0000000000..ec4e8c0c16 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSpeedParam.java @@ -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; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatus.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatus.java new file mode 100644 index 0000000000..6339c25f09 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatus.java @@ -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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotTrajectory.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotTrajectory.java new file mode 100644 index 0000000000..079db7b0bc --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotTrajectory.java @@ -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 models; + + public String getAction() { + return action; + } + + public List getModels() { + return models; + } + + @Override + public String toString() { + return "AutopilotTrajectory{" + + "action='" + action + '\'' + + ", models=" + models + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotWayArrive.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotWayArrive.java new file mode 100644 index 0000000000..a81c22ddf5 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotWayArrive.java @@ -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 + + '}'; + } + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BaseInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BaseInfo.java new file mode 100644 index 0000000000..4e660e1f69 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BaseInfo.java @@ -0,0 +1,23 @@ +package com.zhidao.support.adas.high.bean; + +public abstract class BaseInfo { + 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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BasicInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BasicInfo.java new file mode 100644 index 0000000000..f9d08ced0c --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BasicInfo.java @@ -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; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarLaneInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarLaneInfo.java new file mode 100644 index 0000000000..0a4aa775db --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarLaneInfo.java @@ -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 models; + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public List getModels() { + return models; + } + + public void setModels(List 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; + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarStateInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarStateInfo.java new file mode 100644 index 0000000000..e6e24fe9de --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarStateInfo.java @@ -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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ConfigInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ConfigInfo.java new file mode 100644 index 0000000000..7f1793f875 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ConfigInfo.java @@ -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 + + '}'; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/FaceLoginResponse.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/FaceLoginResponse.java new file mode 100644 index 0000000000..9f1d1c24f4 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/FaceLoginResponse.java @@ -0,0 +1,417 @@ +package com.zhidao.support.adas.high.bean; + +import java.io.Serializable; +import java.util.List; + +/** + * Created by wanglirong on 2018/2/4. + */ + +public class FaceLoginResponse implements Serializable { + + + /** + * data : {"configInfoHistory":[{"kCode":"d_fcw_touch","kName":"前车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"3.7","userId":1068446492234686466},{"kCode":"d_fcw_start","kName":"前车启动提醒","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_driver","kName":"驾驶员疲劳/危险预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_person","kName":"行人碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_sliding","kName":"溜车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_ldw_out","kName":"车道线偏离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5.9","userId":1068446492234686466},{"kCode":"d_hmw_follow","kName":"跟车距离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"2.8","userId":1068446492234686466},{"kCode":"d_volume_size","kName":"音量大小","kOrder":1,"kType":"aided_driving_dic","kVal":"40.6","userId":1068446492234686466},{"kCode":"is_use_ar_navBar","kName":"是否使用AR导航","kOrder":0,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_touch","kName":"前车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_start","kName":"前车启动提醒","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_driver","kName":"驾驶员疲劳/危险预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_person","kName":"行人碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_sliding","kName":"溜车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_ldw_out","kName":"车道线偏离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hmw_follow","kName":"跟车距离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_volume_size","kName":"音量大小","kOrder":1,"kType":"aided_driving_dic","kVal":"60","userId":1068446492234686466},{"kCode":"is_use_ar_navBar","kName":"是否使用AR导航","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_touch","kName":"前车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_start","kName":"前车启动提醒","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_driver","kName":"驾驶员疲劳/危险预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_person","kName":"行人碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_sliding","kName":"溜车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_ldw_out","kName":"车道线偏离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hmw_follow","kName":"跟车距离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_volume_size","kName":"音量大小","kOrder":1,"kType":"aided_driving_dic","kVal":"60","userId":1068446492234686466},{"kCode":"is_use_ar_navBar","kName":"是否使用AR导航","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466}],"currentHeadImageUrl":"http://d2.yiche.com/xvideo-rest/longRunnerDriver.png","medalType":"","navPreferenceConfigHistory":[{"kCode":"avoid_block","kName":"躲避拥堵","kOrder":1,"kType":"aided_navigate_dic","kVal":"1","userId":1068446492234686466},{"kCode":"avoid_pay","kName":"躲避收费","kOrder":1,"kType":"aided_navigate_dic","kVal":"0","userId":1068446492234686466},{"kCode":"avoid_freeway","kName":"不走高速","kOrder":1,"kType":"aided_navigate_dic","kVal":"0","userId":1068446492234686466},{"kCode":"first_freeway","kName":"高速优先","kOrder":1,"kType":"aided_navigate_dic","kVal":"0","userId":1068446492234686466}],"upgrade":false,"userHaunts":[{"latitude":"40.0708","longtitude":"116.336116","otherName":"address","poId":"BV10013514","realName":"回龙观(地铁站)","serialNum":1068449529778237441,"userId":1068446492234686466}],"userMedalDetails":[{"headImageUrl":"http://d2.yiche.com/xvideo-rest/longRunnerDriver.png","medalDescribe":"使用AR导航的次数","medalName":"驰骋⻋主","score":26,"stage":2,"type":"longRunnerDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/caringDriver.png","medalDescribe":"右转道礼让行人","medalName":"爱心⻋主","score":0,"stage":0,"type":"caringDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/curiosityDriver.png","medalDescribe":"使用抓拍功能的次数","medalName":"好奇⻋主","score":2,"stage":0,"type":"curiosityDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/attentionDriver.png","medalDescribe":"连续X天驾驶出行但 未触发X预警","medalName":"安全⻋主","score":1,"stage":0,"type":"attentionDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/carFansDriver.png","medalDescribe":"拍照⻋型照片次数","medalName":"⻋迷⻋主","score":0,"stage":0,"type":"carFansDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/lookForward.png","medalDescribe":"待开发","medalName":"敬请期待","score":0,"stage":0,"type":"lookForward","upgrade":false,"userId":1068446492234686466}]} + * errorCode : 10000 + * errorMsg : OK + */ + + private DataBean data; + private int errorCode; + private String errorMsg; + + public DataBean getData() { + return data; + } + + public void setData(DataBean data) { + this.data = data; + } + + public int getErrorCode() { + return errorCode; + } + + public void setErrorCode(int errorCode) { + this.errorCode = errorCode; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public static class DataBean implements Serializable { + /** + * configInfoHistory : [{"kCode":"d_fcw_touch","kName":"前车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"3.7","userId":1068446492234686466},{"kCode":"d_fcw_start","kName":"前车启动提醒","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_driver","kName":"驾驶员疲劳/危险预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_person","kName":"行人碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_sliding","kName":"溜车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_ldw_out","kName":"车道线偏离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5.9","userId":1068446492234686466},{"kCode":"d_hmw_follow","kName":"跟车距离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"2.8","userId":1068446492234686466},{"kCode":"d_volume_size","kName":"音量大小","kOrder":1,"kType":"aided_driving_dic","kVal":"40.6","userId":1068446492234686466},{"kCode":"is_use_ar_navBar","kName":"是否使用AR导航","kOrder":0,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_touch","kName":"前车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_start","kName":"前车启动提醒","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_driver","kName":"驾驶员疲劳/危险预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_person","kName":"行人碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_sliding","kName":"溜车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_ldw_out","kName":"车道线偏离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hmw_follow","kName":"跟车距离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_volume_size","kName":"音量大小","kOrder":1,"kType":"aided_driving_dic","kVal":"60","userId":1068446492234686466},{"kCode":"is_use_ar_navBar","kName":"是否使用AR导航","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_touch","kName":"前车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_start","kName":"前车启动提醒","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_driver","kName":"驾驶员疲劳/危险预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_fcw_person","kName":"行人碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hdw_sliding","kName":"溜车碰撞预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_ldw_out","kName":"车道线偏离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_hmw_follow","kName":"跟车距离预警","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466},{"kCode":"d_volume_size","kName":"音量大小","kOrder":1,"kType":"aided_driving_dic","kVal":"60","userId":1068446492234686466},{"kCode":"is_use_ar_navBar","kName":"是否使用AR导航","kOrder":1,"kType":"aided_driving_dic","kVal":"5","userId":1068446492234686466}] + * currentHeadImageUrl : http://d2.yiche.com/xvideo-rest/longRunnerDriver.png + * medalType : + * navPreferenceConfigHistory : [{"kCode":"avoid_block","kName":"躲避拥堵","kOrder":1,"kType":"aided_navigate_dic","kVal":"1","userId":1068446492234686466},{"kCode":"avoid_pay","kName":"躲避收费","kOrder":1,"kType":"aided_navigate_dic","kVal":"0","userId":1068446492234686466},{"kCode":"avoid_freeway","kName":"不走高速","kOrder":1,"kType":"aided_navigate_dic","kVal":"0","userId":1068446492234686466},{"kCode":"first_freeway","kName":"高速优先","kOrder":1,"kType":"aided_navigate_dic","kVal":"0","userId":1068446492234686466}] + * upgrade : false + * userHaunts : [{"latitude":"40.0708","longtitude":"116.336116","otherName":"address","poId":"BV10013514","realName":"回龙观(地铁站)","serialNum":1068449529778237441,"userId":1068446492234686466}] + * userMedalDetails : [{"headImageUrl":"http://d2.yiche.com/xvideo-rest/longRunnerDriver.png","medalDescribe":"使用AR导航的次数","medalName":"驰骋⻋主","score":26,"stage":2,"type":"longRunnerDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/caringDriver.png","medalDescribe":"右转道礼让行人","medalName":"爱心⻋主","score":0,"stage":0,"type":"caringDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/curiosityDriver.png","medalDescribe":"使用抓拍功能的次数","medalName":"好奇⻋主","score":2,"stage":0,"type":"curiosityDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/attentionDriver.png","medalDescribe":"连续X天驾驶出行但 未触发X预警","medalName":"安全⻋主","score":1,"stage":0,"type":"attentionDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/carFansDriver.png","medalDescribe":"拍照⻋型照片次数","medalName":"⻋迷⻋主","score":0,"stage":0,"type":"carFansDriver","upgrade":false,"userId":1068446492234686466},{"headImageUrl":"http://d2.yiche.com/xvideo-rest/lookForward.png","medalDescribe":"待开发","medalName":"敬请期待","score":0,"stage":0,"type":"lookForward","upgrade":false,"userId":1068446492234686466}] + */ + + private String currentHeadImageUrl; + private String medalType; + private String name; + private boolean upgrade; + private List configInfoHistory; + private List userHaunts; + private List userMedalDetails; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCurrentHeadImageUrl() { + return currentHeadImageUrl; + } + + public void setCurrentHeadImageUrl(String currentHeadImageUrl) { + this.currentHeadImageUrl = currentHeadImageUrl; + } + + public String getMedalType() { + return medalType; + } + + public void setMedalType(String medalType) { + this.medalType = medalType; + } + + public boolean isUpgrade() { + return upgrade; + } + + public void setUpgrade(boolean upgrade) { + this.upgrade = upgrade; + } + + public List getConfigInfoHistory() { + return configInfoHistory; + } + + public void setConfigInfoHistory(List configInfoHistory) { + this.configInfoHistory = configInfoHistory; + } + + public List getUserHaunts() { + return userHaunts; + } + + public void setUserHaunts(List userHaunts) { + this.userHaunts = userHaunts; + } + + public List getUserMedalDetails() { + return userMedalDetails; + } + + public void setUserMedalDetails(List userMedalDetails) { + this.userMedalDetails = userMedalDetails; + } + + @Override + public String toString() { + return "DataBean{" + + "currentHeadImageUrl='" + currentHeadImageUrl + '\'' + + ", medalType='" + medalType + '\'' + + ", name='" + name + '\'' + + ", upgrade=" + upgrade + + ", configInfoHistory=" + configInfoHistory + + ", userHaunts=" + userHaunts + + ", userMedalDetails=" + userMedalDetails + + '}'; + } + + public static class ConfigInfoHistoryBean implements Serializable { + /** + * kCode : d_fcw_touch + * kName : 前车碰撞预警 + * kOrder : 1 + * kType : aided_driving_dic + * kVal : 3.7 + * userId : 1068446492234686466 + */ + + private String kCode; + private String kName; + private int kOrder; + private String kType; + private String kVal; + private String userId; + + public String getKCode() { + return kCode; + } + + public void setKCode(String kCode) { + this.kCode = kCode; + } + + public String getKName() { + return kName; + } + + public void setKName(String kName) { + this.kName = kName; + } + + public int getKOrder() { + return kOrder; + } + + public void setKOrder(int kOrder) { + this.kOrder = kOrder; + } + + public String getKType() { + return kType; + } + + public void setKType(String kType) { + this.kType = kType; + } + + public String getKVal() { + return kVal; + } + + public void setKVal(String kVal) { + this.kVal = kVal; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + + public String getkCode() { + return kCode; + } + + public void setkCode(String kCode) { + this.kCode = kCode; + } + + public String getkName() { + return kName; + } + + public void setkName(String kName) { + this.kName = kName; + } + + public int getkOrder() { + return kOrder; + } + + public void setkOrder(int kOrder) { + this.kOrder = kOrder; + } + + public String getkType() { + return kType; + } + + public void setkType(String kType) { + this.kType = kType; + } + + public String getkVal() { + return kVal; + } + + public void setkVal(String kVal) { + this.kVal = kVal; + } + + @Override + public String toString() { + return "ConfigInfoHistoryBean{" + + "kCode='" + kCode + '\'' + + ", kName='" + kName + '\'' + + ", kOrder=" + kOrder + + ", kType='" + kType + '\'' + + ", kVal='" + kVal + '\'' + + ", userId='" + userId + '\'' + + '}'; + } + } + + + + public static class UserHauntsBean implements Serializable { + /** + * latitude : 40.0708 + * longtitude : 116.336116 + * otherName : address + * poId : BV10013514 + * realName : 回龙观(地铁站) + * serialNum : 1068449529778237441 + * userId : 1068446492234686466 + */ + + private String latitude; + private String longtitude; + private String otherName; + private String poId; + private String realName; + private String serialNum; + private String userId; + + public String getLatitude() { + return latitude; + } + + public void setLatitude(String latitude) { + this.latitude = latitude; + } + + public String getLongtitude() { + return longtitude; + } + + public void setLongtitude(String longtitude) { + this.longtitude = longtitude; + } + + public String getOtherName() { + return otherName; + } + + public void setOtherName(String otherName) { + this.otherName = otherName; + } + + public String getPoId() { + return poId; + } + + public void setPoId(String poId) { + this.poId = poId; + } + + public String getRealName() { + return realName; + } + + public void setRealName(String realName) { + this.realName = realName; + } + + public String getSerialNum() { + return serialNum; + } + + public void setSerialNum(String serialNum) { + this.serialNum = serialNum; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + } + + public static class UserMedalDetailsBean implements Serializable { + /** + * headImageUrl : http://d2.yiche.com/xvideo-rest/longRunnerDriver.png + * medalDescribe : 使用AR导航的次数 + * medalName : 驰骋⻋主 + * score : 26 + * stage : 2 + * type : longRunnerDriver + * upgrade : false + * userId : 1068446492234686466 + */ + + private String headImageUrl; + private String medalDescribe; + private String medalName; + private int score; + private int stage; + private String type; + private boolean upgrade; + private String userId; + + public String getHeadImageUrl() { + return headImageUrl; + } + + public void setHeadImageUrl(String headImageUrl) { + this.headImageUrl = headImageUrl; + } + + public String getMedalDescribe() { + return medalDescribe; + } + + public void setMedalDescribe(String medalDescribe) { + this.medalDescribe = medalDescribe; + } + + public String getMedalName() { + return medalName; + } + + public void setMedalName(String medalName) { + this.medalName = medalName; + } + + public int getScore() { + return score; + } + + public void setScore(int score) { + this.score = score; + } + + public int getStage() { + return stage; + } + + public void setStage(int stage) { + this.stage = stage; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public boolean isUpgrade() { + return upgrade; + } + + public void setUpgrade(boolean upgrade) { + this.upgrade = upgrade; + } + + public String getUserId() { + return userId; + } + + public void setUserId(String userId) { + this.userId = userId; + } + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeInfo.java new file mode 100644 index 0000000000..274b760698 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeInfo.java @@ -0,0 +1,62 @@ +package com.zhidao.support.adas.high.bean; + +/** + * 工控机升级 + */ +public class IPCUpgradeInfo extends BaseInfo { + 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; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradePatchDownloadStatusInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradePatchDownloadStatusInfo.java new file mode 100644 index 0000000000..6ed102e26c --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradePatchDownloadStatusInfo.java @@ -0,0 +1,120 @@ +package com.zhidao.support.adas.high.bean; + +import com.google.gson.annotations.SerializedName; + +/** + * 工控机升级包下载 + */ +public class IPCUpgradePatchDownloadStatusInfo extends BaseInfo { + /** + * 状态 + */ + 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; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeStateInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeStateInfo.java new file mode 100644 index 0000000000..a06206384a --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/IPCUpgradeStateInfo.java @@ -0,0 +1,70 @@ +package com.zhidao.support.adas.high.bean; + +/** + * 工控机升级状态 + */ +public class IPCUpgradeStateInfo extends BaseInfo { + /** + * 状态 + */ + 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; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/LightStatueInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/LightStatueInfo.java new file mode 100644 index 0000000000..4d8df164d3 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/LightStatueInfo.java @@ -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 + + '}'; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/MapLocationInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/MapLocationInfo.java new file mode 100644 index 0000000000..18ca402b11 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/MapLocationInfo.java @@ -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 CREATOR = new Parcelable.Creator() { + @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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ObstaclesInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ObstaclesInfo.java new file mode 100644 index 0000000000..2af375c32b --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ObstaclesInfo.java @@ -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 models; + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public List getModels() { + return models; + } + + public void setModels(List 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; + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RectInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RectInfo.java new file mode 100644 index 0000000000..ab710e82a6 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RectInfo.java @@ -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 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 getModels() { + return models; + } + + public void setModels(List 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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RemoteControlAutoPilotParameters.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RemoteControlAutoPilotParameters.java new file mode 100644 index 0000000000..4208c9d617 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RemoteControlAutoPilotParameters.java @@ -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 getWayLatLons() { + return wayLatLons; + } + + public void setWayLatLons(List 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 + + '}'; + } + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RouteInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RouteInfo.java new file mode 100644 index 0000000000..5229eca2f5 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RouteInfo.java @@ -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; + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/SSHResult.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/SSHResult.java new file mode 100644 index 0000000000..2c18901d23 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/SSHResult.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/TrajectoryInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/TrajectoryInfo.java new file mode 100644 index 0000000000..027a1e2cb0 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/TrajectoryInfo.java @@ -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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/UserInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/UserInfo.java new file mode 100644 index 0000000000..a039058cbf --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/UserInfo.java @@ -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 + '\'' + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/WarnMessageInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/WarnMessageInfo.java new file mode 100644 index 0000000000..d79071f189 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/WarnMessageInfo.java @@ -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 + '\'' + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/AutopilotGuardianInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/AutopilotGuardianInfo.java new file mode 100644 index 0000000000..88a05c38dd --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/AutopilotGuardianInfo.java @@ -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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItem.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItem.java new file mode 100644 index 0000000000..4b2a04b761 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItem.java @@ -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 + '\'' + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItemsName.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItemsName.java new file mode 100644 index 0000000000..1dfe098a6e --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItemsName.java @@ -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 items; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + @Override + public String toString() { + return "GuardianItemsName{" + + "name='" + name + '\'' + + ", items=" + items + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianModule.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianModule.java new file mode 100644 index 0000000000..4815e7b367 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianModule.java @@ -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 itemsname; + @SerializedName("submodules") + private List submodules; + + public List getItemsname() { + return itemsname; + } + + public void setItemsname(List itemsname) { + this.itemsname = itemsname; + } + + public List getSubmodules() { + return submodules; + } + + public void setSubmodules(List submodules) { + this.submodules = submodules; + } + + @Override + public String toString() { + return "GuardianModule{" + + "itemsname=" + itemsname + + ", submodules=" + submodules + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianSubmodule.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianSubmodule.java new file mode 100644 index 0000000000..c06e0f3275 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianSubmodule.java @@ -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 subnodes; + + public String getModulename() { + return modulename; + } + + public void setModulename(String modulename) { + this.modulename = modulename; + } + + public List getSubnodes() { + return subnodes; + } + + public void setSubnodes(List subnodes) { + this.subnodes = subnodes; + } + + public static class Subnode { + @SerializedName("nodename") + private String nodename; + @SerializedName("nodeitems") + private List nodeitems; + @SerializedName("topicitems") + private List 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 getTopicitems() { + return topicitems; + } + + public void setTopicitems(List 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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotIdentifyInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotIdentifyInfo.java new file mode 100644 index 0000000000..4091d0ceb3 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotIdentifyInfo.java @@ -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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotRecordResult.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotRecordResult.java new file mode 100644 index 0000000000..07462482f3 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotRecordResult.java @@ -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; + + 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 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 + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordCauseParam.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordCauseParam.java new file mode 100644 index 0000000000..750b884e43 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordCauseParam.java @@ -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 + '\'' + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordDataParam.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordDataParam.java new file mode 100644 index 0000000000..f3ff1966a9 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordDataParam.java @@ -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 + '\'' + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ActionTypeReceive.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ActionTypeReceive.java new file mode 100644 index 0000000000..276de17756 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ActionTypeReceive.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AppPreferenceHelper.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AppPreferenceHelper.java new file mode 100644 index 0000000000..bab5488aaf --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/AppPreferenceHelper.java @@ -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); + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseIoUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseIoUtils.java new file mode 100644 index 0000000000..c5cbd962b6 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseIoUtils.java @@ -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; + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseSDCardHelper.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseSDCardHelper.java new file mode 100644 index 0000000000..1fdceec991 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseSDCardHelper.java @@ -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("删除文件夹成功"); + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseTimeUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseTimeUtils.java new file mode 100644 index 0000000000..19d015f249 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/BaseTimeUtils.java @@ -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); + } + + + /** + * + *

Description: 本地时间转化为UTC时间

+ * @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; + } + + /** + * + *

Description:UTC时间转化为本地时间

+ * @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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java new file mode 100644 index 0000000000..8c24926f9f --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/Constants.java @@ -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}"; +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java new file mode 100644 index 0000000000..1b3c9d2217 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/CupidLogUtils.java @@ -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); + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java new file mode 100644 index 0000000000..fe344bee47 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/DigitalTrans.java @@ -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; + } + +} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/FileUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/FileUtils.java new file mode 100644 index 0000000000..4376c74e9a --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/FileUtils.java @@ -0,0 +1,1543 @@ +package com.zhidao.support.adas.high.common; + +import android.content.Context; +import android.content.Intent; +import android.net.Uri; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileFilter; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.RandomAccessFile; +import java.net.URL; +import java.nio.MappedByteBuffer; +import java.nio.channels.FileChannel; +import java.security.DigestInputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Locale; + +import javax.net.ssl.HttpsURLConnection; + +/** + *
+ *     author: Blankj
+ *     blog  : http://blankj.com
+ *     time  : 2016/05/03
+ *     desc  : utils about file
+ * 
+ */ +public final class FileUtils { + + private static final String LINE_SEP = System.getProperty("line.separator"); + + private FileUtils() { + throw new UnsupportedOperationException("u can't instantiate me..."); + } + + /** + * Return the file by path. + * + * @param filePath The path of file. + * @return the file + */ + public static File getFileByPath(final String filePath) { + return isSpace(filePath) ? null : new File(filePath); + } + + /** + * Return whether the file exists. + * + * @param filePath The path of file. + * @return {@code true}: yes
{@code false}: no + */ + public static boolean isFileExists(final String filePath) { + return isFileExists(getFileByPath(filePath)); + } + + /** + * Return whether the file exists. + * + * @param file The file. + * @return {@code true}: yes
{@code false}: no + */ + public static boolean isFileExists(final File file) { + return file != null && file.exists(); + } + + /** + * Rename the file. + * + * @param filePath The path of file. + * @param newName The new name of file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean rename(final String filePath, final String newName) { + return rename(getFileByPath(filePath), newName); + } + + /** + * Rename the file. + * + * @param file The file. + * @param newName The new name of file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean rename(final File file, final String newName) { + // file is null then return false + if (file == null) return false; + // file doesn't exist then return false + if (!file.exists()) return false; + // the new name is space then return false + if (isSpace(newName)) return false; + // the new name equals old name then return true + if (newName.equals(file.getName())) return true; + File newFile = new File(file.getParent() + File.separator + newName); + // the new name of file exists then return false + return !newFile.exists() + && file.renameTo(newFile); + } + + /** + * Return whether it is a directory. + * + * @param dirPath The path of directory. + * @return {@code true}: yes
{@code false}: no + */ + public static boolean isDir(final String dirPath) { + return isDir(getFileByPath(dirPath)); + } + + /** + * Return whether it is a directory. + * + * @param file The file. + * @return {@code true}: yes
{@code false}: no + */ + public static boolean isDir(final File file) { + return file != null && file.exists() && file.isDirectory(); + } + + /** + * Return whether it is a file. + * + * @param filePath The path of file. + * @return {@code true}: yes
{@code false}: no + */ + public static boolean isFile(final String filePath) { + return isFile(getFileByPath(filePath)); + } + + /** + * Return whether it is a file. + * + * @param file The file. + * @return {@code true}: yes
{@code false}: no + */ + public static boolean isFile(final File file) { + return file != null && file.exists() && file.isFile(); + } + + /** + * Create a directory if it doesn't exist, otherwise do nothing. + * + * @param dirPath The path of directory. + * @return {@code true}: exists or creates successfully
{@code false}: otherwise + */ + public static boolean createOrExistsDir(final String dirPath) { + return createOrExistsDir(getFileByPath(dirPath)); + } + + /** + * Create a directory if it doesn't exist, otherwise do nothing. + * + * @param file The file. + * @return {@code true}: exists or creates successfully
{@code false}: otherwise + */ + public static boolean createOrExistsDir(final File file) { + return file != null && (file.exists() ? file.isDirectory() : file.mkdirs()); + } + + /** + * Create a file if it doesn't exist, otherwise do nothing. + * + * @param filePath The path of file. + * @return {@code true}: exists or creates successfully
{@code false}: otherwise + */ + public static boolean createOrExistsFile(final String filePath) { + return createOrExistsFile(getFileByPath(filePath)); + } + + /** + * Create a file if it doesn't exist, otherwise do nothing. + * + * @param file The file. + * @return {@code true}: exists or creates successfully
{@code false}: otherwise + */ + public static boolean createOrExistsFile(final File file) { + if (file == null) return false; + if (file.exists()) return file.isFile(); + if (!createOrExistsDir(file.getParentFile())) return false; + try { + return file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + + /** + * Create a file if it doesn't exist, otherwise delete old file before creating. + * + * @param filePath The path of file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean createFileByDeleteOldFile(final String filePath) { + return createFileByDeleteOldFile(getFileByPath(filePath)); + } + + /** + * Create a file if it doesn't exist, otherwise delete old file before creating. + * + * @param file The file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean createFileByDeleteOldFile(final File file) { + if (file == null) return false; + // file exists and unsuccessfully delete then return false + if (file.exists() && !file.delete()) return false; + if (!createOrExistsDir(file.getParentFile())) return false; + try { + return file.createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + + /** + * Copy the directory. + * + * @param srcDirPath The path of source directory. + * @param destDirPath The path of destination directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyDir(final String srcDirPath, + final String destDirPath) { + return copyDir(getFileByPath(srcDirPath), getFileByPath(destDirPath)); + } + + /** + * Copy the directory. + * + * @param srcDirPath The path of source directory. + * @param destDirPath The path of destination directory. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyDir(final String srcDirPath, + final String destDirPath, + final OnReplaceListener listener) { + return copyDir(getFileByPath(srcDirPath), getFileByPath(destDirPath), listener); + } + + /** + * Copy the directory. + * + * @param srcDir The source directory. + * @param destDir The destination directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyDir(final File srcDir, + final File destDir) { + return copyOrMoveDir(srcDir, destDir, false); + } + + /** + * Copy the directory. + * + * @param srcDir The source directory. + * @param destDir The destination directory. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyDir(final File srcDir, + final File destDir, + final OnReplaceListener listener) { + return copyOrMoveDir(srcDir, destDir, listener, false); + } + + /** + * Copy the file. + * + * @param srcFilePath The path of source file. + * @param destFilePath The path of destination file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyFile(final String srcFilePath, + final String destFilePath) { + return copyFile(getFileByPath(srcFilePath), getFileByPath(destFilePath)); + } + + /** + * Copy the file. + * + * @param srcFilePath The path of source file. + * @param destFilePath The path of destination file. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyFile(final String srcFilePath, + final String destFilePath, + final OnReplaceListener listener) { + return copyFile(getFileByPath(srcFilePath), getFileByPath(destFilePath), listener); + } + + /** + * Copy the file. + * + * @param srcFile The source file. + * @param destFile The destination file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyFile(final File srcFile, + final File destFile) { + return copyOrMoveFile(srcFile, destFile, false); + } + + /** + * Copy the file. + * + * @param srcFile The source file. + * @param destFile The destination file. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean copyFile(final File srcFile, + final File destFile, + final OnReplaceListener listener) { + return copyOrMoveFile(srcFile, destFile, listener, false); + } + + /** + * Move the directory. + * + * @param srcDirPath The path of source directory. + * @param destDirPath The path of destination directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveDir(final String srcDirPath, + final String destDirPath) { + return moveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath)); + } + + /** + * Move the directory. + * + * @param srcDirPath The path of source directory. + * @param destDirPath The path of destination directory. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveDir(final String srcDirPath, + final String destDirPath, + final OnReplaceListener listener) { + return moveDir(getFileByPath(srcDirPath), getFileByPath(destDirPath), listener); + } + + /** + * Move the directory. + * + * @param srcDir The source directory. + * @param destDir The destination directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveDir(final File srcDir, + final File destDir) { + return copyOrMoveDir(srcDir, destDir, true); + } + + /** + * Move the directory. + * + * @param srcDir The source directory. + * @param destDir The destination directory. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveDir(final File srcDir, + final File destDir, + final OnReplaceListener listener) { + return copyOrMoveDir(srcDir, destDir, listener, true); + } + + /** + * Move the file. + * + * @param srcFilePath The path of source file. + * @param destFilePath The path of destination file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveFile(final String srcFilePath, + final String destFilePath) { + return moveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath)); + } + + /** + * Move the file. + * + * @param srcFilePath The path of source file. + * @param destFilePath The path of destination file. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveFile(final String srcFilePath, + final String destFilePath, + final OnReplaceListener listener) { + return moveFile(getFileByPath(srcFilePath), getFileByPath(destFilePath), listener); + } + + /** + * Move the file. + * + * @param srcFile The source file. + * @param destFile The destination file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveFile(final File srcFile, + final File destFile) { + return copyOrMoveFile(srcFile, destFile, true); + } + + /** + * Move the file. + * + * @param srcFile The source file. + * @param destFile The destination file. + * @param listener The replace listener. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean moveFile(final File srcFile, + final File destFile, + final OnReplaceListener listener) { + return copyOrMoveFile(srcFile, destFile, listener, true); + } + + private static boolean copyOrMoveDir(final File srcDir, + final File destDir, + final boolean isMove) { + return copyOrMoveDir(srcDir, destDir, new OnReplaceListener() { + @Override + public boolean onReplace() { + return true; + } + }, isMove); + } + + private static boolean copyOrMoveDir(final File srcDir, + final File destDir, + final OnReplaceListener listener, + final boolean isMove) { + if (srcDir == null || destDir == null) return false; + // destDir's path locate in srcDir's path then return false + String srcPath = srcDir.getPath() + File.separator; + String destPath = destDir.getPath() + File.separator; + if (destPath.contains(srcPath)) return false; + if (!srcDir.exists() || !srcDir.isDirectory()) return false; + if (destDir.exists()) { + if (listener == null || listener.onReplace()) {// require delete the old directory + if (!deleteAllInDir(destDir)) {// unsuccessfully delete then return false + return false; + } + } else { + return true; + } + } + if (!createOrExistsDir(destDir)) return false; + File[] files = srcDir.listFiles(); + for (File file : files) { + File oneDestFile = new File(destPath + file.getName()); + if (file.isFile()) { + if (!copyOrMoveFile(file, oneDestFile, listener, isMove)) return false; + } else if (file.isDirectory()) { + if (!copyOrMoveDir(file, oneDestFile, listener, isMove)) return false; + } + } + return !isMove || deleteDir(srcDir); + } + + private static boolean copyOrMoveFile(final File srcFile, + final File destFile, + final boolean isMove) { + return copyOrMoveFile(srcFile, destFile, new OnReplaceListener() { + @Override + public boolean onReplace() { + return true; + } + }, isMove); + } + + private static boolean copyOrMoveFile(final File srcFile, + final File destFile, + final OnReplaceListener listener, + final boolean isMove) { + if (srcFile == null || destFile == null) return false; + // srcFile equals destFile then return false + if (srcFile.equals(destFile)) return false; + // srcFile doesn't exist or isn't a file then return false + if (!srcFile.exists() || !srcFile.isFile()) return false; + if (destFile.exists()) { + if (listener == null || listener.onReplace()) {// require delete the old file + if (!destFile.delete()) {// unsuccessfully delete then return false + return false; + } + } else { + return true; + } + } + if (!createOrExistsDir(destFile.getParentFile())) return false; + try { + return writeFileFromIS(destFile, new FileInputStream(srcFile)) + && !(isMove && !deleteFile(srcFile)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + return false; + } + } + + /** + * Delete the directory. + * + * @param filePath The path of file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean delete(final String filePath) { + return delete(getFileByPath(filePath)); + } + + /** + * Delete the directory. + * + * @param file The file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean delete(final File file) { + if (file == null) return false; + if (file.isDirectory()) { + return deleteDir(file); + } + return deleteFile(file); + } + + /** + * Delete the directory. + * + * @param dirPath The path of directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteDir(final String dirPath) { + return deleteDir(getFileByPath(dirPath)); + } + + /** + * Delete the directory. + * + * @param dir The directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteDir(final File dir) { + if (dir == null) return false; + // dir doesn't exist then return true + if (!dir.exists()) return true; + // dir isn't a directory then return false + if (!dir.isDirectory()) return false; + File[] files = dir.listFiles(); + if (files != null && files.length != 0) { + for (File file : files) { + if (file.isFile()) { + if (!file.delete()) return false; + } else if (file.isDirectory()) { + if (!deleteDir(file)) return false; + } + } + } + return dir.delete(); + } + + /** + * Delete the file. + * + * @param srcFilePath The path of source file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteFile(final String srcFilePath) { + return deleteFile(getFileByPath(srcFilePath)); + } + + /** + * Delete the file. + * + * @param file The file. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteFile(final File file) { + return file != null && (!file.exists() || file.isFile() && file.delete()); + } + + /** + * Delete the all in directory. + * + * @param dirPath The path of directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteAllInDir(final String dirPath) { + return deleteAllInDir(getFileByPath(dirPath)); + } + + /** + * Delete the all in directory. + * + * @param dir The directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteAllInDir(final File dir) { + return deleteFilesInDirWithFilter(dir, new FileFilter() { + @Override + public boolean accept(File pathname) { + return true; + } + }); + } + + /** + * Delete all files in directory. + * + * @param dirPath The path of directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteFilesInDir(final String dirPath) { + return deleteFilesInDir(getFileByPath(dirPath)); + } + + /** + * Delete all files in directory. + * + * @param dir The directory. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteFilesInDir(final File dir) { + return deleteFilesInDirWithFilter(dir, new FileFilter() { + @Override + public boolean accept(File pathname) { + return pathname.isFile(); + } + }); + } + + /** + * Delete all files that satisfy the filter in directory. + * + * @param dirPath The path of directory. + * @param filter The filter. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteFilesInDirWithFilter(final String dirPath, + final FileFilter filter) { + return deleteFilesInDirWithFilter(getFileByPath(dirPath), filter); + } + + /** + * Delete all files that satisfy the filter in directory. + * + * @param dir The directory. + * @param filter The filter. + * @return {@code true}: success
{@code false}: fail + */ + public static boolean deleteFilesInDirWithFilter(final File dir, final FileFilter filter) { + if (dir == null) return false; + // dir doesn't exist then return true + if (!dir.exists()) return true; + // dir isn't a directory then return false + if (!dir.isDirectory()) return false; + File[] files = dir.listFiles(); + if (files != null && files.length != 0) { + for (File file : files) { + if (filter.accept(file)) { + if (file.isFile()) { + if (!file.delete()) return false; + } else if (file.isDirectory()) { + if (!deleteDir(file)) return false; + } + } + } + } + return true; + } + + /** + * Return the files in directory. + *

Doesn't traverse subdirectories

+ * + * @param dirPath The path of directory. + * @return the files in directory + */ + public static List listFilesInDir(final String dirPath) { + return listFilesInDir(dirPath, false); + } + + /** + * Return the files in directory. + *

Doesn't traverse subdirectories

+ * + * @param dir The directory. + * @return the files in directory + */ + public static List listFilesInDir(final File dir) { + return listFilesInDir(dir, false); + } + + /** + * Return the files in directory. + * + * @param dirPath The path of directory. + * @param isRecursive True to traverse subdirectories, false otherwise. + * @return the files in directory + */ + public static List listFilesInDir(final String dirPath, final boolean isRecursive) { + return listFilesInDir(getFileByPath(dirPath), isRecursive); + } + + /** + * Return the files in directory. + * + * @param dir The directory. + * @param isRecursive True to traverse subdirectories, false otherwise. + * @return the files in directory + */ + public static List listFilesInDir(final File dir, final boolean isRecursive) { + return listFilesInDirWithFilter(dir, new FileFilter() { + @Override + public boolean accept(File pathname) { + return true; + } + }, isRecursive); + } + + /** + * Return the files that satisfy the filter in directory. + *

Doesn't traverse subdirectories

+ * + * @param dirPath The path of directory. + * @param filter The filter. + * @return the files that satisfy the filter in directory + */ + public static List listFilesInDirWithFilter(final String dirPath, + final FileFilter filter) { + return listFilesInDirWithFilter(getFileByPath(dirPath), filter, false); + } + + /** + * Return the files that satisfy the filter in directory. + *

Doesn't traverse subdirectories

+ * + * @param dir The directory. + * @param filter The filter. + * @return the files that satisfy the filter in directory + */ + public static List listFilesInDirWithFilter(final File dir, + final FileFilter filter) { + return listFilesInDirWithFilter(dir, filter, false); + } + + /** + * Return the files that satisfy the filter in directory. + * + * @param dirPath The path of directory. + * @param filter The filter. + * @param isRecursive True to traverse subdirectories, false otherwise. + * @return the files that satisfy the filter in directory + */ + public static List listFilesInDirWithFilter(final String dirPath, + final FileFilter filter, + final boolean isRecursive) { + return listFilesInDirWithFilter(getFileByPath(dirPath), filter, isRecursive); + } + + /** + * Return the files that satisfy the filter in directory. + * + * @param dir The directory. + * @param filter The filter. + * @param isRecursive True to traverse subdirectories, false otherwise. + * @return the files that satisfy the filter in directory + */ + public static List listFilesInDirWithFilter(final File dir, + final FileFilter filter, + final boolean isRecursive) { + if (!isDir(dir)) return null; + List list = new ArrayList<>(); + File[] files = dir.listFiles(); + if (files != null && files.length != 0) { + for (File file : files) { + if (filter.accept(file)) { + list.add(file); + } + if (isRecursive && file.isDirectory()) { + //noinspection ConstantConditions + list.addAll(listFilesInDirWithFilter(file, filter, true)); + } + } + } + return list; + } + + /** + * Return the time that the file was last modified. + * + * @param filePath The path of file. + * @return the time that the file was last modified + */ + + public static long getFileLastModified(final String filePath) { + return getFileLastModified(getFileByPath(filePath)); + } + + /** + * Return the time that the file was last modified. + * + * @param file The file. + * @return the time that the file was last modified + */ + public static long getFileLastModified(final File file) { + if (file == null) return -1; + return file.lastModified(); + } + + /** + * Return the charset of file simply. + * + * @param filePath The path of file. + * @return the charset of file simply + */ + public static String getFileCharsetSimple(final String filePath) { + return getFileCharsetSimple(getFileByPath(filePath)); + } + + /** + * Return the charset of file simply. + * + * @param file The file. + * @return the charset of file simply + */ + public static String getFileCharsetSimple(final File file) { + int p = 0; + InputStream is = null; + try { + is = new BufferedInputStream(new FileInputStream(file)); + p = (is.read() << 8) + is.read(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (is != null) { + is.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + switch (p) { + case 0xefbb: + return "UTF-8"; + case 0xfffe: + return "Unicode"; + case 0xfeff: + return "UTF-16BE"; + default: + return "GBK"; + } + } + + /** + * Return the number of lines of file. + * + * @param filePath The path of file. + * @return the number of lines of file + */ + public static int getFileLines(final String filePath) { + return getFileLines(getFileByPath(filePath)); + } + + /** + * Return the number of lines of file. + * + * @param file The file. + * @return the number of lines of file + */ + public static int getFileLines(final File file) { + int count = 1; + InputStream is = null; + try { + is = new BufferedInputStream(new FileInputStream(file)); + byte[] buffer = new byte[1024]; + int readChars; + if (LINE_SEP.endsWith("\n")) { + while ((readChars = is.read(buffer, 0, 1024)) != -1) { + for (int i = 0; i < readChars; ++i) { + if (buffer[i] == '\n') ++count; + } + } + } else { + while ((readChars = is.read(buffer, 0, 1024)) != -1) { + for (int i = 0; i < readChars; ++i) { + if (buffer[i] == '\r') ++count; + } + } + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (is != null) { + is.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return count; + } + + /** + * Return the size of directory. + * + * @param dirPath The path of directory. + * @return the size of directory + */ + public static String getDirSize(final String dirPath) { + return getDirSize(getFileByPath(dirPath)); + } + + /** + * Return the size of directory. + * + * @param dir The directory. + * @return the size of directory + */ + public static String getDirSize(final File dir) { + long len = getDirLength(dir); + return len == -1 ? "" : byte2FitMemorySize(len); + } + + /** + * Return the length of file. + * + * @param filePath The path of file. + * @return the length of file + */ + public static String getFileSize(final String filePath) { + long len = getFileLength(filePath); + return len == -1 ? "" : byte2FitMemorySize(len); + } + + /** + * Return the length of file. + * + * @param file The file. + * @return the length of file + */ + public static String getFileSize(final File file) { + long len = getFileLength(file); + return len == -1 ? "" : byte2FitMemorySize(len); + } + + /** + * Return the length of directory. + * + * @param dirPath The path of directory. + * @return the length of directory + */ + public static long getDirLength(final String dirPath) { + return getDirLength(getFileByPath(dirPath)); + } + + /** + * Return the length of directory. + * + * @param dir The directory. + * @return the length of directory + */ + public static long getDirLength(final File dir) { + if (!isDir(dir)) return -1; + long len = 0; + File[] files = dir.listFiles(); + if (files != null && files.length != 0) { + for (File file : files) { + if (file.isDirectory()) { + len += getDirLength(file); + } else { + len += file.length(); + } + } + } + return len; + } + + /** + * Return the length of file. + * + * @param filePath The path of file. + * @return the length of file + */ + public static long getFileLength(final String filePath) { + boolean isURL = filePath.matches("[a-zA-z]+://[^\\s]*"); + if (isURL) { + try { + HttpsURLConnection conn = (HttpsURLConnection) new URL(filePath).openConnection(); + conn.setRequestProperty("Accept-Encoding", "identity"); + conn.connect(); + if (conn.getResponseCode() == 200) { + return conn.getContentLength(); + } + return -1; + } catch (IOException e) { + e.printStackTrace(); + } + } + return getFileLength(getFileByPath(filePath)); + } + + /** + * Return the length of file. + * + * @param file The file. + * @return the length of file + */ + public static long getFileLength(final File file) { + if (!isFile(file)) return -1; + return file.length(); + } + + /** + * 获取指定文件大小 + * @return + * @throws Exception + */ + public static long getFileSizeLong(File file) throws Exception + { + long size = 0; + if (file.exists()){ + FileInputStream fis = null; + fis = new FileInputStream(file); + size = fis.available(); + } + else{ + CupidLogUtils.e("获取文件大小","文件不存在!"); + } + return size; + } + + /** + * Return the MD5 of file. + * + * @param filePath The path of file. + * @return the md5 of file + */ + public static String getFileMD5ToString(final String filePath) { + File file = isSpace(filePath) ? null : new File(filePath); + return getFileMD5ToString(file); + } + + /** + * Return the MD5 of file. + * + * @param file The file. + * @return the md5 of file + */ + public static String getFileMD5ToString(final File file) { + return bytes2HexString(getFileMD5(file)); + } + + /** + * Return the MD5 of file. + * + * @param filePath The path of file. + * @return the md5 of file + */ + public static byte[] getFileMD5(final String filePath) { + return getFileMD5(getFileByPath(filePath)); + } + + /** + * Return the MD5 of file. + * + * @param file The file. + * @return the md5 of file + */ + public static byte[] getFileMD5(final File file) { + if (file == null) return null; + DigestInputStream dis = null; + try { + FileInputStream fis = new FileInputStream(file); + MessageDigest md = MessageDigest.getInstance("MD5"); + dis = new DigestInputStream(fis, md); + byte[] buffer = new byte[1024 * 256]; + while (true) { + if (!(dis.read(buffer) > 0)) break; + } + md = dis.getMessageDigest(); + return md.digest(); + } catch (NoSuchAlgorithmException | IOException e) { + e.printStackTrace(); + } finally { + try { + if (dis != null) { + dis.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * Return the file's path of directory. + * + * @param file The file. + * @return the file's path of directory + */ + public static String getDirName(final File file) { + if (file == null) return ""; + return getDirName(file.getAbsolutePath()); + } + + /** + * Return the file's path of directory. + * + * @param filePath The path of file. + * @return the file's path of directory + */ + public static String getDirName(final String filePath) { + if (isSpace(filePath)) return ""; + int lastSep = filePath.lastIndexOf(File.separator); + return lastSep == -1 ? "" : filePath.substring(0, lastSep + 1); + } + + /** + * Return the name of file. + * + * @param file The file. + * @return the name of file + */ + public static String getFileName(final File file) { + if (file == null) return ""; + return getFileName(file.getAbsolutePath()); + } + + /** + * Return the name of file. + * + * @param filePath The path of file. + * @return the name of file + */ + public static String getFileName(final String filePath) { + if (isSpace(filePath)) return ""; + int lastSep = filePath.lastIndexOf(File.separator); + return lastSep == -1 ? filePath : filePath.substring(lastSep + 1); + } + + /** + * Return the name of file without extension. + * + * @param file The file. + * @return the name of file without extension + */ + public static String getFileNameNoExtension(final File file) { + if (file == null) return ""; + return getFileNameNoExtension(file.getPath()); + } + + /** + * Return the name of file without extension. + * + * @param filePath The path of file. + * @return the name of file without extension + */ + public static String getFileNameNoExtension(final String filePath) { + if (isSpace(filePath)) return ""; + int lastPoi = filePath.lastIndexOf('.'); + int lastSep = filePath.lastIndexOf(File.separator); + if (lastSep == -1) { + return (lastPoi == -1 ? filePath : filePath.substring(0, lastPoi)); + } + if (lastPoi == -1 || lastSep > lastPoi) { + return filePath.substring(lastSep + 1); + } + return filePath.substring(lastSep + 1, lastPoi); + } + + /** + * Return the extension of file. + * + * @param file The file. + * @return the extension of file + */ + public static String getFileExtension(final File file) { + if (file == null) return ""; + return getFileExtension(file.getPath()); + } + + /** + * Return the extension of file. + * + * @param filePath The path of file. + * @return the extension of file + */ + public static String getFileExtension(final String filePath) { + if (isSpace(filePath)) return ""; + int lastPoi = filePath.lastIndexOf('.'); + int lastSep = filePath.lastIndexOf(File.separator); + if (lastPoi == -1 || lastSep >= lastPoi) return ""; + return filePath.substring(lastPoi + 1); + } + + /** + * Notify system to scan the file. + * + * @param file The file. + */ + public static void notifySystemToScan(Context context, final File file) { + if (file == null || !file.exists()) return; + Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); + Uri uri = Uri.fromFile(file); + intent.setData(uri); + context.sendBroadcast(intent); + } + + /** + * Notify system to scan the file. + * + * @param filePath The path of file. + */ + public static void notifySystemToScan(final Context context, final String filePath) { + notifySystemToScan(context, getFileByPath(filePath)); + } + + /////////////////////////////////////////////////////////////////////////// + // interface + /////////////////////////////////////////////////////////////////////////// + + public interface OnReplaceListener { + boolean onReplace(); + } + + /////////////////////////////////////////////////////////////////////////// + // other utils methods + /////////////////////////////////////////////////////////////////////////// + + private static final char[] HEX_DIGITS = + {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + + private static String bytes2HexString(final byte[] bytes) { + if (bytes == null) return ""; + int len = bytes.length; + if (len <= 0) return ""; + char[] ret = new char[len << 1]; + for (int i = 0, j = 0; i < len; i++) { + ret[j++] = HEX_DIGITS[bytes[i] >> 4 & 0x0f]; + ret[j++] = HEX_DIGITS[bytes[i] & 0x0f]; + } + return new String(ret); + } + + private static String byte2FitMemorySize(final long byteNum) { + if (byteNum < 0) { + return "shouldn't be less than zero!"; + } else if (byteNum < 1024) { + return String.format(Locale.getDefault(), "%.3fB", (double) byteNum); + } else if (byteNum < 1048576) { + return String.format(Locale.getDefault(), "%.3fKB", (double) byteNum / 1024); + } else if (byteNum < 1073741824) { + return String.format(Locale.getDefault(), "%.3fMB", (double) byteNum / 1048576); + } else { + return String.format(Locale.getDefault(), "%.3fGB", (double) byteNum / 1073741824); + } + } + + private static boolean isSpace(final String s) { + if (s == null) return true; + for (int i = 0, len = s.length(); i < len; ++i) { + if (!Character.isWhitespace(s.charAt(i))) { + return false; + } + } + return true; + } + + private static boolean writeFileFromIS(final File file, + final InputStream is) { + OutputStream os = null; + try { + os = new BufferedOutputStream(new FileOutputStream(file)); + byte data[] = new byte[8192]; + int len; + while ((len = is.read(data, 0, 8192)) != -1) { + os.write(data, 0, len); + } + return true; + } catch (IOException e) { + e.printStackTrace(); + return false; + } finally { + try { + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + try { + if (os != null) { + os.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + /** + * 写文件 string + * + * @param fullFileName + * @param logContent + * @param isAppend + */ + public static void writeFile(String fullFileName, String logContent, boolean isAppend) { + FileWriter fileWriter = null; + try { + fileWriter = new FileWriter(new File(fullFileName), isAppend); + fileWriter.write(logContent); + fileWriter.write("\n"); + fileWriter.flush(); + fileWriter.close(); + } catch (Exception e) { + } finally { + BaseIoUtils.closeSilently(fileWriter); + } + } + + /** + * 获取文件路径 + * + * @param baseDir + * @param fileName + * @return + */ + public static String getFilePath(Context context, String baseDir, String fileName) { + String basePath = saveVideoBasePathDir(context, baseDir); + File file = new File(basePath + File.separator + fileName); + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + + if (!file.exists()) { + try { + file.createNewFile(); + return file.getAbsolutePath(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return file.getAbsolutePath(); + } + + /** + * 保存图片的路径 + * + * @return + */ + public static String saveVideoBasePathDir(Context context, String dirName) { + String basePath = null; + //有SD卡 + if (BaseSDCardHelper.isSDCardMounted()) { + basePath = BaseSDCardHelper.getSDCardBaseDir(); + } else { + basePath = context.getCacheDir().getAbsolutePath(); + } + + return basePath + File.separator + dirName; + + } + + /** + * 删除文件夹 + * + * @param context + * @param baseDir + */ + public static void removeAllFileDir(Context context, String baseDir) { + String basePath = saveVideoBasePathDir(context, baseDir); + File file = new File(basePath); + if (file.exists()) { + delAllFile(file.getAbsolutePath()); + } + } + + + public static boolean delAllFile(String path) { + boolean flag = false; + try { + File file = new File(path); + if (!file.exists()) { + return flag; + } + if (!file.isDirectory()) { + return flag; + } + String[] tempList = file.list(); + File temp = null; + for (int i = 0; i < tempList.length; i++) { + if (path.endsWith(File.separator)) { + temp = new File(path + tempList[i]); + } else { + temp = new File(path + File.separator + tempList[i]); + } + if (temp.isFile()) { + temp.delete(); + } + if (temp.isDirectory()) { + delAllFile(path + "/" + tempList[i]);// 先删除文件夹里面的文件 + delFolder(path + "/" + tempList[i]);// 再删除空文件夹 + flag = true; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return flag; + } + + private static void delFolder(String folderPath) { + try { + delAllFile(folderPath); // 删除完里面所有内容 + String filePath = folderPath; + filePath = filePath.toString(); + File myFilePath = new File(filePath); + myFilePath.delete(); // 删除空文件夹 + } catch (Exception e) { + e.printStackTrace(); + } + } + + + /** + * 根据byte数组生成文件 + * + * @param bytes 生成文件用到的byte数组 + */ + public static void createFileWithByte(byte[] bytes, String filePath) { + /** + * 创建File对象,其中包含文件所在的目录以及文件的命名 + */ + File file = new File(filePath); + // 创建FileOutputStream对象 + FileOutputStream outputStream = null; + // 创建BufferedOutputStream对象 + BufferedOutputStream bufferedOutputStream = null; + try { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + if (!file.exists()) { + // 在文件系统中根据路径创建一个新的空文件 + file.createNewFile(); + } + // 获取FileOutputStream对象 + outputStream = new FileOutputStream(file); + // 获取BufferedOutputStream对象 + bufferedOutputStream = new BufferedOutputStream(outputStream); + // 往文件所在的缓冲输出流中写byte数据 + bufferedOutputStream.write(bytes); + // 刷出缓冲输出流,该步很关键,要是不执行flush()方法,那么文件的内容是空的。 + bufferedOutputStream.flush(); + } catch (Exception e) { + // 打印异常信息 + e.printStackTrace(); + } finally { + // 关闭创建的流对象 + if (outputStream != null) { + try { + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + if (bufferedOutputStream != null) { + try { + bufferedOutputStream.close(); + } catch (Exception e2) { + e2.printStackTrace(); + } + } + } + } + + /** + * Mapped File way MappedByteBuffer 可以在处理大文件时,提升性能 + * + * @param filename + * @return + * @throws IOException + */ + public static byte[] file2ByteArray(String filename) throws IOException { + + FileChannel fc = null; + try { + fc = new RandomAccessFile(filename, "r").getChannel(); + MappedByteBuffer byteBuffer = fc.map(FileChannel.MapMode.READ_ONLY, 0, + fc.size()).load(); + System.out.println(byteBuffer.isLoaded()); + byte[] result = new byte[(int) fc.size()]; + if (byteBuffer.remaining() > 0) { + // System.out.println("remain"); + byteBuffer.get(result, 0, byteBuffer.remaining()); + } + return result; + } catch (IOException e) { + e.printStackTrace(); + throw e; + } finally { + try { + fc.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static String getNowString(final java.text.DateFormat format) { + return millis2String(System.currentTimeMillis(), format); + } + + /** + * Milliseconds to the formatted time string. + * + * @param millis The milliseconds. + * @param format The format. + * @return the formatted time string + */ + public static String millis2String(final long millis, final java.text.DateFormat format) { + return format.format(new Date(millis)); + } + +} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/HandlerThreadManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/HandlerThreadManager.java new file mode 100644 index 0000000000..94cfee8328 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/HandlerThreadManager.java @@ -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(30), + new ThreadFactory() { + private final AtomicInteger mCount = new AtomicInteger(1); + + public Thread newThread(Runnable r) { + return new Thread(r, "autopilot-thread-pool" + mCount.getAndIncrement()); + } + }); +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/IPreferencesHelper.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/IPreferencesHelper.java new file mode 100644 index 0000000000..1c843a1066 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/IPreferencesHelper.java @@ -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(); + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/LogSaveManage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/LogSaveManage.java new file mode 100644 index 0000000000..48e2df1031 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/LogSaveManage.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MgContextUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MgContextUtils.java new file mode 100644 index 0000000000..fcc310a381 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MgContextUtils.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/RequestWsMsgType.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/RequestWsMsgType.java new file mode 100644 index 0000000000..6eb1ffa5b2 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/RequestWsMsgType.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/SSH.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/SSH.java new file mode 100644 index 0000000000..561a360952 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/SSH.java @@ -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(); + } + } + +} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ThreadPoolManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ThreadPoolManager.java new file mode 100644 index 0000000000..4ae835c3ef --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ThreadPoolManager.java @@ -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 { + + /** + * 根据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(200), + Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy()); + } + // 把一个任务丢到了线程池中 + try { + executor.execute(r); + } catch (Exception e) { + e.printStackTrace(); + } + + } + + /** + * 开启一个有返回结果的线程 + * + * @param r + * @return + */ + public Future submit(Callable 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(20), + Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy()); + } + // 把一个任务丢到了线程池中 + return executor.submit(r); + } + + /** + * 把任务移除等待队列 + * + * @param r + */ + public void cancel(Runnable r) { + if (r != null) { + executor.getQueue().remove(r); + } + } + +} + diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMsg.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMsg.java new file mode 100644 index 0000000000..acdc45de7d --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMsg.java @@ -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); + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMyMessageFactory.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMyMessageFactory.java new file mode 100644 index 0000000000..d85aeee531 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/IMyMessageFactory.java @@ -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); +} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyAbstractMessageHandler.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyAbstractMessageHandler.java new file mode 100644 index 0000000000..59dcf3d8c3 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyAbstractMessageHandler.java @@ -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 { +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java new file mode 100644 index 0000000000..4991e7b859 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/MyMessageFactory.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/NuImplMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/NuImplMessage.java new file mode 100644 index 0000000000..31e816b59c --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/NuImplMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpCarStateMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpCarStateMessage.java new file mode 100644 index 0000000000..cc9c6b661b --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpCarStateMessage.java @@ -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(); + } + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLanesMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLanesMessage.java new file mode 100644 index 0000000000..16cea5dc1d --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLanesMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLightStateMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLightStateMessage.java new file mode 100644 index 0000000000..d77597908e --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLightStateMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpObstaclesMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpObstaclesMessage.java new file mode 100644 index 0000000000..5bf41edbcc --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpObstaclesMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpRenderImageMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpRenderImageMessage.java new file mode 100644 index 0000000000..84be2140d4 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpRenderImageMessage.java @@ -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 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(); + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotArriveMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotArriveMessage.java new file mode 100644 index 0000000000..bb45a115a6 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotArriveMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotConfig.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotConfig.java new file mode 100644 index 0000000000..1046cebaf1 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotConfig.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotGuardian.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotGuardian.java new file mode 100644 index 0000000000..2dc502c8bc --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotGuardian.java @@ -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(); + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotIdentify.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotIdentify.java new file mode 100644 index 0000000000..4fb08036e6 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotIdentify.java @@ -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); + } + } + }; + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRouteMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRouteMessage.java new file mode 100644 index 0000000000..fa6398c9a0 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRouteMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRoutesMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRoutesMessage.java new file mode 100644 index 0000000000..c816039bb7 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRoutesMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotSNMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotSNMessage.java new file mode 100644 index 0000000000..dbb4e7b0fa --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotSNMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotStatusMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotStatusMessage.java new file mode 100644 index 0000000000..5f384202d6 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotStatusMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotTrajectoryMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotTrajectoryMessage.java new file mode 100644 index 0000000000..cc20edd9eb --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotTrajectoryMessage.java @@ -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 pointsList = trajectory.getPointsList(); + ArrayList trajectoryInfos = new ArrayList<>(); + for (int i = 0;i" + trajectoryInfos.toString()); + } + } catch (InvalidProtocolBufferException e) { + e.printStackTrace(); + } + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradePatchDownloadStatusMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradePatchDownloadStatusMessage.java new file mode 100644 index 0000000000..5070d77b91 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradePatchDownloadStatusMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradeStatusMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradeStatusMessage.java new file mode 100644 index 0000000000..c4dc8565eb --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotUpgradeStatusMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsImageSizeMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsImageSizeMessage.java new file mode 100644 index 0000000000..994c4384fe --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsImageSizeMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsWarnMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsWarnMessage.java new file mode 100644 index 0000000000..373c5b9ac1 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsWarnMessage.java @@ -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) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/PublicQueue.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/PublicQueue.java new file mode 100644 index 0000000000..60476a7d42 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/PublicQueue.java @@ -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 { + + private BlockingDeque blockingDeque = new LinkedBlockingDeque<>();//缓冲区 + + public static PublicQueue publicQueue; + + public static synchronized PublicQueue getInstance() { + if (publicQueue == null) { + publicQueue = new PublicQueue(); + } + 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 iterater = blockingDeque.iterator(); + while (iterater.hasNext()){ + T data = iterater.next(); + stringBuilder.append(","+data); + } + return stringBuilder.toString(); + } +} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpMsgModel.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpMsgModel.java new file mode 100644 index 0000000000..9763e0dbb6 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpMsgModel.java @@ -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 + '\'' + + '}'; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpQueueManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpQueueManager.java new file mode 100644 index 0000000000..c4ca870879 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpQueueManager.java @@ -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 publicQueue = new PublicQueue<>(); + //实时消费 + private boolean runConsumerFlag = true; + private AdasChannel adasChannel; + private RealTimeConsumerFrameMission realTimeConsumerFrameMission; + private Future 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 { + //消费者 + private PublicQueue mPublicQueue; + + public RealTimeConsumerFrameMission(PublicQueue 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); + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WSByteQueueManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WSByteQueueManager.java new file mode 100644 index 0000000000..b218efb98b --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WSByteQueueManager.java @@ -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 publicQueue = new PublicQueue<>(); + private RealTimeConsumerFrameMission realTimeConsumerFrameMission; + + private Future 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{ + //消费者 + private PublicQueue mPublicQueue; + //实时消费 + private boolean runConsumerFlag = true; + public RealTimeConsumerFrameMission(PublicQueue 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); + } + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WebSocketQueueManager.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WebSocketQueueManager.java new file mode 100644 index 0000000000..b7d8c864f4 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/WebSocketQueueManager.java @@ -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 publicQueue = new PublicQueue<>(); + private RealTimeConsumerFrameMission realTimeConsumerFrameMission; + + private Future 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{ + //消费者 + private PublicQueue mPublicQueue; + //实时消费 + private boolean runConsumerFlag = true; + public RealTimeConsumerFrameMission(PublicQueue 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); + } + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/FpgaSocket.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/FpgaSocket.java new file mode 100644 index 0000000000..34052cb95e --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/FpgaSocket.java @@ -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 configInfos) { + CupidLogUtils.e("FpgaSocket--->doConfigChanged, type: " + type + " ip: " + ip + " configInfos:" + configInfos); + } + + @Override + public void doConfigChanged(List 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; + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/IWebSocket.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/IWebSocket.java new file mode 100644 index 0000000000..4c38b96e6a --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/IWebSocket.java @@ -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 configInfos); + + /** + * 上传配置 + * @param configInfos + */ + void doConfigChanged( List 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); +} + diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/SocketMsgType.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/SocketMsgType.java new file mode 100644 index 0000000000..aa4d402a78 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/SocketMsgType.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/DefaultMessageProtocol.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/DefaultMessageProtocol.java new file mode 100644 index 0000000000..2095861dbc --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/DefaultMessageProtocol.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/IMessageProtocol.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/IMessageProtocol.java new file mode 100644 index 0000000000..e68846c9f9 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/IMessageProtocol.java @@ -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); +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/OriginReadData.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/OriginReadData.java new file mode 100644 index 0000000000..b078e4e7c7 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/OriginReadData.java @@ -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; + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/SocketReader.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/SocketReader.java new file mode 100644 index 0000000000..007a41f4d2 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/SocketReader.java @@ -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; + } + + + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/CallableWrapper.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/CallableWrapper.java new file mode 100644 index 0000000000..1d0508a537 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/CallableWrapper.java @@ -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 + */ +public final class CallableWrapper implements Callable { + + private ThreadCallback callback; + + private Callable proxy; + + /** + * 构造方法 + * + * @param proxy 线程优先级 + */ + public CallableWrapper(Callable proxy, NormalCallback normalCallback) { + this.proxy = proxy; + this.callback = normalCallback; + } + + /** + * 详细可以看我的GitHub:https://github.com/yangchong211 + * 自定义Callable继承Callable类,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; + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/QueuedWork.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/QueuedWork.java new file mode 100644 index 0000000000..595736858d --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/QueuedWork.java @@ -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(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 type + * @return {@link Future} + */ + public static Future submit(Callable callable, NormalCallback normalCallback) { + callable = new CallableWrapper<>(callable, normalCallback); + Future result = THREAD_POOL_EXECUTOR.submit(callable); + return result; + } + + /** + * 移除队列里面的任务 + */ + public static int getQueueSize() { + if (null != THREAD_POOL_EXECUTOR) { + BlockingQueue queue = THREAD_POOL_EXECUTOR.getQueue(); + return queue.size(); + } + return 0; + } + + + public static abstract class ZSAsyncTask { + + protected Runnable thread; + + protected void onPreExecute() { + } + + protected abstract Result doInBackground(); + + protected void onPostExecute(Result paramResult) { + } + + public final ZSAsyncTask 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()); + } + }; +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/NormalCallback.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/NormalCallback.java new file mode 100644 index 0000000000..15ba267b0a --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/NormalCallback.java @@ -0,0 +1,44 @@ +/* +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.callback; + +/** + * + * @param + */ +public class NormalCallback implements ThreadCallback { + + + @Override + public void onError(Throwable t) { + + } + + @Override + public Result doInBackground() { + return null; + } + + @Override + public void onCompleted() { + + } + + @Override + public void onStart() { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/ThreadCallback.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/ThreadCallback.java new file mode 100644 index 0000000000..9e9d0965b9 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/thread/callback/ThreadCallback.java @@ -0,0 +1,47 @@ +/* +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.callback; + +/** + * + * @param + */ +public interface ThreadCallback { + + /** + * 当线程发生错误时,将调用此方法。 + * @param t 异常 + */ + void onError(Throwable t); + + /** + * 做后台操作 + * 如果没有Callable 代理 直接走这个后台操作 如果有代理会直接走代理 + */ + Result doInBackground(); + + /** + * 通知用户知道它已经完成 + */ + void onCompleted(); + + /** + * 通知用户任务开始运行 + */ + void onStart(); + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl.java new file mode 100644 index 0000000000..b9e0497aec --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl.java @@ -0,0 +1,88 @@ +package com.zhidao.support.adas.high.udp; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; + +/** + * Created by wangyaofu on 2018/6/14. + */ +public class CupidBufStreamImpl implements IBuffStream { + + // 5M +// public static final int BUF_SIZE = 5242880; + public static final int BUF_SIZE = 2097152; + //3M + public static final int BUF_SIZE_LIMIT = 3145728; + + ByteArrayOutputStream ostream0_; + ByteArrayOutputStream ostream1_; + + volatile Boolean isSwitch; + + @Override + public void init() { + ostream0_ = new ByteArrayOutputStream(BUF_SIZE); + ostream1_ = new ByteArrayOutputStream(BUF_SIZE); + isSwitch = false; + } + + @Override + public OutputStream getOutputStream() { + synchronized (isSwitch) { + if (isSwitch) { + return ostream1_; + } else { + return ostream0_; + } + } + + } + + @Override + public byte[] getData() { + byte[] b = null; + synchronized (isSwitch) { + if (isSwitch) { + b = ostream0_.toByteArray(); + } else { + b = ostream1_.toByteArray(); + } + } + return b; + } + + @Override + public int getLength() { + int size; + synchronized (isSwitch) { + if (isSwitch) { + size = ostream0_.size(); + } else { + size = ostream1_.size(); + } + } + return size; + } + + @Override + public void close() { + if (ostream0_ != null) { + ostream0_.reset(); + } + if (ostream1_ != null) { + ostream1_.reset(); + } + } + + @Override + public void doSwitch() { + synchronized (isSwitch) { + if (isSwitch) { + ostream0_.reset(); + } else { + ostream1_.reset(); + } + isSwitch = !isSwitch; + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl2.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl2.java new file mode 100644 index 0000000000..df33ac8ade --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl2.java @@ -0,0 +1,54 @@ +package com.zhidao.support.adas.high.udp; + +import java.io.ByteArrayOutputStream; +import java.io.OutputStream; + +/** + * Created by wangyaofu on 2018/6/14. + */ +public class CupidBufStreamImpl2 implements IBuffStream { + + // 5M +// public static final int BUF_SIZE = 5242880; + public static final int BUF_SIZE = 2097152; + //3M + public static final int BUF_SIZE_LIMIT = 3145728; + + ByteArrayOutputStream ostream0_; + + @Override + public void init() { + if (ostream0_ != null) { + ostream0_.reset(); + ostream0_ = null; + } + ostream0_ = new ByteArrayOutputStream(BUF_SIZE); + } + + @Override + public OutputStream getOutputStream() { + return ostream0_; + } + + @Override + public byte[] getData() { + byte[] b = ostream0_.toByteArray(); + return b; + } + + @Override + public int getLength() { + int size = ostream0_.size(); + return size; + } + + @Override + public void close() { + init(); + } + + @Override + public void doSwitch() { + ostream0_.reset(); + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpConstract.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpConstract.java new file mode 100644 index 0000000000..77022ac8df --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpConstract.java @@ -0,0 +1,132 @@ +package com.zhidao.support.adas.high.udp; + + +import com.zhidao.support.adas.high.common.CupidLogUtils; +import com.zhidao.support.adas.high.udp.factory.AbstractUdpImpl; +import com.zhidao.support.adas.high.udp.factory.CupidUdpFactory; + +/** + * @author nie yunlong + * @description udp 与 stream + * @date 2018/6/15 + */ +public class CupidUdpConstract { + + + private CupidBufStreamImpl2 buffStreamImpl; + /** + * udp 接收数据线程 + */ + private Thread udpReceiverDataThread; + /** + * 默认的udp端口 + */ + private int defaultVideoUdpPort = 6665; + + /** + * 默认的udp端口 + */ + private int defaultRenderImageUdpPort = 6661; + + private AbstractUdpImpl udpImpl; + /** + * 默认是0 创建h264解析流 + */ + public static final int VIDEO_STREAM_UDP = 0; + /** + * 上层绘制 待开发 + */ + public static final int VIDEO_RENDER_IMAGE_UDP = 1; + + public CupidUdpConstract(int udpType) { + init(udpType); + } + + /** + * 初始化UDPserver 接收数据 + */ + private void init(int udpType) { + if (udpType == VIDEO_STREAM_UDP) { + udpImpl = CupidUdpFactory.createVideoStreamUdp(); + udpImpl.setUdpPort(defaultVideoUdpPort); + // buffStreamImpl = new CupidBufStreamImpl(); + buffStreamImpl = new CupidBufStreamImpl2(); + buffStreamImpl.init(); + udpImpl.setBuffStream(buffStreamImpl); + } else if (udpType == VIDEO_RENDER_IMAGE_UDP) { + udpImpl = CupidUdpFactory.createRenderImageUdp(); + udpImpl.setUdpPort(defaultRenderImageUdpPort); + } + udpImpl.setStop(false); + startReceiverDataThread(); + } + + /** + * 开启线程 在surface准备好之后再进行接收数据 + */ + public void startReceiverDataThread() { + if (udpReceiverDataThread != null) { + udpReceiverDataThread.interrupt(); + udpReceiverDataThread = null; + } + udpReceiverDataThread = new Thread(udpImpl); + udpReceiverDataThread.start(); + } + + public void setOnReceiverH264Data(IGetH264Data getH264Data) { + udpImpl.getVideoInputStreamData(getH264Data); + } + + /** + * 连接listener + * + * @param connectListener + */ + public void setOnConnectListener(IConnectRtpListener connectListener) { + udpImpl.setOnConnectListener(connectListener); + } + + public void onPause() { + udpImpl.onPause(); + } + + public void onResume() { + udpImpl.onResume(); + } + + /** + * 初始化webSocket + */ + public void setUdpIsFirstInit() { + if (udpImpl != null) { + udpImpl.setFirstReceiverAddress(false); + } + } + + /** + * 服务端关闭 初始化buffer + */ + public void resetBuffer() { + if (udpImpl != null) { + udpImpl.initBuffer(); + } + } + + + public void release() { + try { + CupidLogUtils.e("---->关闭socket"); + if (udpImpl != null) { + udpImpl.close(); + udpImpl = null; + } + if (udpReceiverDataThread != null && !udpReceiverDataThread.isInterrupted()) { + udpReceiverDataThread.interrupt(); + udpReceiverDataThread = null; + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpServer.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpServer.java new file mode 100644 index 0000000000..bc4f6c1a0f --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpServer.java @@ -0,0 +1,275 @@ +package com.zhidao.support.adas.high.udp; + + + +import com.zhidao.support.adas.high.common.CupidLogUtils; + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.MulticastSocket; + +/** + * Created by wangyaofu on 18/6/14. + */ +public class CupidUdpServer implements Runnable { + + static final String TAG = CupidUdpServer.class.getSimpleName(); + + private int udpPort; + private boolean isMultiCast; + private String multiCastIp; + private volatile boolean isStop; + + private IBuffStream buffStream; + /** + * 接口 回调一帧 + */ + private IGetH264Data mGetH264Data; + + private IConnectRtpListener mConnectRtpListener; + /** + * 接收的ip地址 + */ + private volatile String mReceiveAddress; + + + public int getUdpPort() { + return udpPort; + } + + public void setUdpPort(int udpPort) { + this.udpPort = udpPort; + } + + public boolean isMultiCast() { + return isMultiCast; + } + + public void setMultiCast(boolean multiCast) { + isMultiCast = multiCast; + } + + public String getMultiCastIp() { + return multiCastIp; + } + + public void setMultiCastIp(String multiCastIp) { + this.multiCastIp = multiCastIp; + } + + public boolean isStop() { + return isStop; + } + + public synchronized void setStop(boolean stop) { + isStop = stop; + } + + public IBuffStream getBuffStream() { + return buffStream; + } + + public void setBuffStream(IBuffStream buffStream) { + this.buffStream = buffStream; + } + + + /** + * + * @param connectRtpListener + */ + public void setOnConnectListener(IConnectRtpListener connectRtpListener) { + this.mConnectRtpListener = connectRtpListener; + } + + /** + * + * @param getH264Data + */ + public void setOnReceiverListener(IGetH264Data getH264Data) { + this.mGetH264Data = getH264Data; + } + + private static final int DATA_LEN = 4096; + byte[] inBuff = new byte[DATA_LEN]; + /** + * 接收的包 + */ + private DatagramPacket inPacket = new DatagramPacket(inBuff, inBuff.length); + /** + * udp + */ + private DatagramSocket socket = null; + /** + * 带广播的udp + */ + private MulticastSocket mMulticastSocket = null; + /** + * 第一次获取到接收端的ip + */ + private volatile boolean isFirstReceiverAddress; + + boolean parseRTP() { + int naluType = 0; + int nalunri = 0; + int naluf = 0; + + boolean isEnd = false; + if ((int) (inBuff[1] >> 7 & 0x01) == 1) { + isEnd = true; + } + + byte naluHeader = inBuff[12]; + naluType = naluHeader & 0x1f; + nalunri = naluHeader >> 5 & 0x03; + naluf = naluHeader >> 7 & 0x01; + int len = inPacket.getLength(); + CupidLogUtils.i(TAG, "packet-len:" + len); + + byte[] fu_h_byte = new byte[5]; + fu_h_byte[0] = 0; + fu_h_byte[1] = 0; + fu_h_byte[2] = 0; + fu_h_byte[3] = 1; + + if (28 == naluType) { + // H264 Begin + int fu_type = 0; + int fu_r = 0; + int fu_e = 0; + int fu_s = 0; + + byte fu_header = inBuff[13]; + fu_type = fu_header & 0x1f; + fu_r = fu_header >> 5 & 0x01; + fu_e = fu_header >> 6 & 0x01; + fu_s = fu_header >> 7 & 0x01; + + if (fu_s == 1) { + //buffStream.doSwitch(); + // start of fu-a + fu_h_byte[4] = (byte) ((fu_type & 0x1f) | (nalunri << 5 & 0x60) | (naluf << 7 & 0x80)); + try { + //buffStream.getOutputStream().write(fu_h_byte, 0, 5); + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } else { + // end of fu-a + try { + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + + } else { + fu_h_byte[4] = (byte) ((naluType & 0x1f) | (nalunri << 5 & 0x60) | (naluf << 7 & 0x80)); + try { + //buffStream.getOutputStream().write(fu_h_byte, 0, 5); + buffStream.getOutputStream().write(inBuff, 13, len - 13); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + if (isEnd) { + buffStream.doSwitch(); + if (mGetH264Data != null) { + mGetH264Data.getH264Data(buffStream.getData(),System.currentTimeMillis()); + } + } + return true; + } + + @Override + public void run() { + CupidLogUtils.e(TAG, "---->开始接收数据"); + try { + if (isMultiCast) { + mMulticastSocket = new MulticastSocket(udpPort); + InetAddress bcAddr = InetAddress.getByName(multiCastIp); + mMulticastSocket.setReuseAddress(true); + mMulticastSocket.joinGroup(bcAddr); + mMulticastSocket.setLoopbackMode(false); + } else { + CupidLogUtils.e(TAG, "---->开始连接端口" + udpPort); + socket = new DatagramSocket(udpPort); + socket.setReuseAddress(true); + CupidLogUtils.e(TAG, "---->连接成功" + udpPort); + } + } catch (Exception e) { + e.printStackTrace(); + if (mConnectRtpListener != null) { + mConnectRtpListener.onConnectionFailedRtp(e.getMessage()); + } + return; + } + + while (!isStop) { + try { + if (isMultiCast && mMulticastSocket != null) { + mMulticastSocket.receive(inPacket); + } else { + if (socket != null) { + socket.receive(inPacket); + } + } + if (!isFirstReceiverAddress) { + mReceiveAddress = inPacket.getAddress().getHostAddress(); + CupidLogUtils.e("mReceiveAddress--->mReceiveAddress" + mReceiveAddress); + isFirstReceiverAddress = true; + if (mConnectRtpListener != null) { + mConnectRtpListener.getOnConnectionAddress(mReceiveAddress); + } + } + + + if (inPacket.getLength() > 12) { + parseRTP(); + } + } catch (Exception e) { + e.printStackTrace(); + if (mConnectRtpListener != null) { + mConnectRtpListener.onConnectionFailedRtp(e.getMessage()); + } + } + } + } + + /** + * 获取到连接ip地址 + * + * @return + */ + public String getmReceiveAddress() { + return mReceiveAddress; + } + + + /** + * 关闭流 + */ + public synchronized void close() { + setStop(true); + if (mMulticastSocket != null) { + mMulticastSocket.close(); + } + if (socket != null) { + socket.close(); + } + } + + public boolean isFirstReceiverAddress() { + return isFirstReceiverAddress; + } + + public void setFirstReceiverAddress(boolean firstReceiverAddress) { + isFirstReceiverAddress = firstReceiverAddress; + } +} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IBuffStream.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IBuffStream.java new file mode 100644 index 0000000000..07b065ab5b --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IBuffStream.java @@ -0,0 +1,20 @@ +package com.zhidao.support.adas.high.udp; + +import java.io.OutputStream; + +/** + * Created by wangyaofu on 2018/6/14. + */ +public interface IBuffStream { + void init(); + + OutputStream getOutputStream(); + + void doSwitch(); + + byte[] getData(); + + int getLength(); + + void close(); +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IConnectRtpListener.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IConnectRtpListener.java new file mode 100644 index 0000000000..ecccba0bb9 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IConnectRtpListener.java @@ -0,0 +1,25 @@ +package com.zhidao.support.adas.high.udp; + +/** + * @author nie yunlong + * @description + * @date 2018/6/15 + */ +public interface IConnectRtpListener { + + /** + * 连接成功 指的是 client发送数据包 + */ + void onConnectionSuccessRtp(); + + void onConnectionFailedRtp(String reason); + + /** + * 获取到client的ip地址 + * @param address + */ + void getOnConnectionAddress(String address); + + void onDisconnectRtp(); + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IGetH264Data.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IGetH264Data.java new file mode 100644 index 0000000000..d32a9f0351 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IGetH264Data.java @@ -0,0 +1,16 @@ +package com.zhidao.support.adas.high.udp; + +/** + * @author nie yunlong + * @description h264数据 + * @date 2018/6/15 + */ +public interface IGetH264Data { + + /** + * 获取h264数据 + * @param data h264 + */ + void getH264Data(byte[] data,long receiverDataUdpTime); + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IRenderImageListener.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IRenderImageListener.java new file mode 100644 index 0000000000..88b4495452 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IRenderImageListener.java @@ -0,0 +1,81 @@ +package com.zhidao.support.adas.high.udp; + +import android.view.SurfaceHolder; + +/** + * @author nie yunlong + * @description 回调获取数据时候 ui变化 + * @date 2018/6/26 + */ +public interface IRenderImageListener { + /** + * 获取udp包的数据 用来告知展示什么ui + * + * @param data + */ + void getUdpData(String data); + + /** + * surface create + * + * @param holder + */ + void surfaceCreated(SurfaceHolder holder); + + /** + * 改变尺寸 + * + * @param holder + * @param format + * @param width + * @param height + */ + void surfaceChanged(SurfaceHolder holder, int format, int width, int height); + + /** + * 销毁 + * + * @param holder + */ + void surfaceDestroyed(SurfaceHolder holder); + + /** + * udp 连接失败 + */ + void onConnectionFailedRtp(String reason); + + /** + * 连接udpok + * @param address + */ + void getOnConnectionAddress(String address); + + + /** + * 所有的都是模拟 贴图模式 + * + * @param canvas + * @param width + * @param height + * @param scaleWidth + * @param scaleHeight + * @param isChange 是否改变元数据坐标 + */ + //boolean draw(Canvas canvas, int width, int height, float scaleWidth, float scaleHeight, List drawUiInfoList, boolean isChange); + + /** + * 绘制 与帧绑定 + * + * @param canvas + * @param width 展示UI层 宽度 + */ + // void draw(Canvas canvas, int width, int height, float scaleWidth, float scaleHeight, DrawUiInfo drawUiInfo); + + /** + * @param canvas + * @param picWidth 图片的宽度 + * @param picHeight 图片的高度 + * @param drawAlarmAnimationList 报警位置的集合 + */ +// void drawAlarm(Canvas canvas, float picWidth, float picHeight, List drawAlarmAnimationList); +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/RTPUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/RTPUtils.java new file mode 100644 index 0000000000..34bfaf260d --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/RTPUtils.java @@ -0,0 +1,392 @@ +package com.zhidao.support.adas.high.udp; + +import java.util.Comparator; + +/** + * RTP-related static utility methods. + * + * @deprecated + * + * @author Boris Grozev + */ +public class RTPUtils +{ + /** + * Hex characters for converting bytes to readable hex strings + */ + private final static char[] HEXES = new char[] + { + '0', '1', '2', '3', '4', '5', '6', '7', '8', + '9', 'A', 'B', 'C', 'D', 'E', 'F' + }; + /** + * Returns the delta between two RTP sequence numbers, taking into account + * rollover. This will return the 'shortest' delta between the two + * sequence numbers in the form of the number you'd add to b to get a. e.g.: + * getSequenceNumberDelta(1, 10) -> -9 (10 + -9 = 1) + * getSequenceNumberDelta(1, 65530) -> 7 (65530 + 7 = 1) + * @return the delta between two RTP sequence numbers (modulo 2^16). + */ + public static int getSequenceNumberDelta(int a, int b) + { + int diff = a - b; + + if (diff < -(1<<15)) + { + diff += 1 << 16; + } + else if (diff > 1<<15) + { + diff -= 1 << 16; + } + + return diff; + } + + /** + * Returns whether or not seqNumOne is 'older' than seqNumTwo, taking + * rollover into account + * @param seqNumOne + * @param seqNumTwo + * @return true if seqNumOne is 'older' than seqNumTwo + */ + public static boolean isOlderSequenceNumberThan(int seqNumOne, int seqNumTwo) + { + return getSequenceNumberDelta(seqNumOne, seqNumTwo) < 0; + } + + /** + * Returns result of the subtraction of one RTP sequence number from another + * (modulo 2^16). + * @return result of the subtraction of one RTP sequence number from another + * (modulo 2^16). + */ + public static int subtractNumber(int a, int b) + { + return as16Bits(a - b); + } + + + /** + * Apply a delta to a given sequence number and return the result (taking + * rollover into account) + * @param startingSequenceNumber the starting sequence number + * @param delta the delta to be applied + * @return the sequence number result from doing + * startingSequenceNumber + delta + */ + public static int applySequenceNumberDelta( + int startingSequenceNumber, int delta) + { + return (startingSequenceNumber + delta) & 0xFFFF; + } + + /** + * Set an integer at specified offset in network order. + * + * @param off Offset into the buffer + * @param data The integer to store in the packet + */ + public static int writeInt(byte[] buf, int off, int data) + { + if (buf == null || buf.length < off + 4) + { + return -1; + } + + buf[off++] = (byte)(data>>24); + buf[off++] = (byte)(data>>16); + buf[off++] = (byte)(data>>8); + buf[off] = (byte)data; + return 4; + } + + /** + * Writes the least significant 24 bits from the given integer into the + * given byte array at the given offset. + * @param buf the buffer into which to write. + * @param off the offset at which to write. + * @param data the integer to write. + * @return 3 + */ + public static int writeUint24(byte[] buf, int off, int data) + { + if (buf == null || buf.length < off + 3) + { + return -1; + } + + buf[off++] = (byte)(data>>16); + buf[off++] = (byte)(data>>8); + buf[off] = (byte)data; + return 3; + } + + /** + * Set an integer at specified offset in network order. + * + * @param off Offset into the buffer + * @param data The integer to store in the packet + */ + public static int writeShort(byte[] buf, int off, short data) + { + buf[off++] = (byte)(data>>8); + buf[off] = (byte)data; + return 2; + } + + /** + * Read an integer from a buffer at a specified offset. + * + * @param buf the buffer. + * @param off start offset of the integer to be read. + */ + public static int readInt(byte[] buf, int off) + { + return + ((buf[off++] & 0xFF) << 24) + | ((buf[off++] & 0xFF) << 16) + | ((buf[off++] & 0xFF) << 8) + | (buf[off] & 0xFF); + } + + /** + * Reads a 32-bit unsigned integer from the given buffer at the given + * offset and returns its {@link long} representation. + * @param buf the buffer. + * @param off start offset of the integer to be read. + */ + public static long readUint32AsLong(byte[] buf, int off) + { + return readInt(buf, off) & 0xFFFF_FFFFL; + } + + /** + * Read an unsigned short at a specified offset as an int. + * + * @param buf the buffer from which to read. + * @param off start offset of the unsigned short + * @return the int value of the unsigned short at offset + */ + public static int readUint16AsInt(byte[] buf, int off) + { + int b1 = (0xFF & (buf[off + 0])); + int b2 = (0xFF & (buf[off + 1])); + int val = b1 << 8 | b2; + return val; + } + + /** + * Read a signed short at a specified offset as an int. + * + * @param buf the buffer from which to read. + * @param off start offset of the unsigned short + * @return the int value of the unsigned short at offset + */ + public static int readInt16AsInt(byte[] buf, int off) + { + int ret = ((0xFF & (buf[off])) << 8) + | (0xFF & (buf[off + 1])); + if ((ret & 0x8000) != 0) + { + ret = ret | 0xFFFF_0000; + } + + return ret; + } + + /** + * Read an unsigned short at specified offset as a int + * + * @param buf + * @param off start offset of the unsigned short + * @return the int value of the unsigned short at offset + */ + public static int readUint24AsInt(byte[] buf, int off) + { + int b1 = (0xFF & (buf[off + 0])); + int b2 = (0xFF & (buf[off + 1])); + int b3 = (0xFF & (buf[off + 2])); + return b1 << 16 | b2 << 8 | b3; + } + + /** + * Returns the given integer masked to 16 bits + * @param value the integer to mask + * @return the value, masked to only keep the lower + * 16 bits + */ + public static int as16Bits(int value) + { + return value & 0xFFFF; + } + + /** + * Returns the given integer masked to 32 bits + * @param value the integer to mask + * @return the value, masked to only keep the lower + * 32 bits + */ + public static long as32Bits(long value) + { + return value & 0xFFFF_FFFFL; + } + + /** + * A {@link Comparator} implementation for unsigned 16-bit {@link Integer}s. + * Compares {@code a} and {@code b} inside the [0, 2^16] ring; + * {@code a} is considered smaller than {@code b} if it takes a smaller + * number to reach from {@code a} to {@code b} than the other way round. + * + * IMPORTANT: This is a valid {@link Comparator} implementation only when + * used for subsets of [0, 2^16) which don't span more than 2^15 elements. + * + * E.g. it works for: [0, 2^15-1] and ([50000, 2^16) u [0, 10000]) + * Doesn't work for: [0, 2^15] and ([0, 2^15-1] u {2^16-1}) and [0, 2^16) + */ + public static final Comparator sequenceNumberComparator + = new Comparator() { + @Override + public int compare(Integer a, Integer b) + { + if (a.equals(b)) + { + return 0; + } + else if (a > b) + { + if (a - b < 0x10000) + { + return 1; + } + else + { + return -1; + } + } + else //a < b + { + if (b - a < 0x10000) + { + return -1; + } + else + { + return 1; + } + } + } + }; + + /** + * Returns the difference between two RTP timestamps. + * @return the difference between two RTP timestamps. + */ + public static long rtpTimestampDiff(long a, long b) + { + long diff = a - b; + if (diff < -(1L<<31)) + { + diff += 1L << 32; + } + else if (diff > 1L<<31) + { + diff -= 1L << 32; + } + + return diff; + } + + /** + * Returns whether or not the first given timestamp is newer than the second + * @param a + * @param b + * @return true if a is newer than b, false otherwise + */ + public static boolean isNewerTimestampThan(long a, long b) + { + return rtpTimestampDiff(a, b) > 0; + } + + /** + * Return a string containing the hex string version of the given byte + * @param b + * @return + */ + private static String toHexString(byte b) + { + + StringBuilder hexStringBuilder = new StringBuilder(2); + + hexStringBuilder.append(HEXES[(b & 0xF0) >> 4]); + hexStringBuilder.append(HEXES[b & 0x0F]); + + return hexStringBuilder.toString(); + } + + /** + * Return a string containing the hex string version of the given bytes + * @param buf + * @return + */ + public static String toHexString(byte[] buf) + { + return toHexString(buf, 0, buf.length, true); + } + + /** + * Return a string containing the hex string version of the given byte + * @param buf + * @param off + * @param len + * @return + */ + public static String toHexString(byte[] buf, int off, int len) + { + return toHexString(buf, off, len, true); + } + + /** + * Return a string containing the hex string version of the given byte + * @param buf + * @param off + * @param len + * @param format a boolean that indicates whether or not to format the hex + * string. + * @return + */ + public static String toHexString(byte[] buf, int off, int len, boolean format) + { + if (buf == null) + { + return null; + } + else + { + StringBuilder hexStringBuilder + = new StringBuilder(2 * buf.length); + + for (int i = 0; i < len; i++) + { + if (format) + { + if (i % 16 == 0) + { + hexStringBuilder.append("\n") + .append(toHexString((byte) i)) + .append(" "); + } + else if (i % 8 == 0) + { + hexStringBuilder.append(" "); + } + } + byte b = buf[off + i]; + + hexStringBuilder.append(toHexString(b)); + hexStringBuilder.append(" "); + } + return hexStringBuilder.toString(); + } + } +} \ No newline at end of file diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/AbstractUdpImpl.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/AbstractUdpImpl.java new file mode 100644 index 0000000000..69401db025 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/AbstractUdpImpl.java @@ -0,0 +1,217 @@ +package com.zhidao.support.adas.high.udp.factory; + + +import com.zhidao.support.adas.high.common.CupidLogUtils; +import com.zhidao.support.adas.high.udp.IConnectRtpListener; +import com.zhidao.support.adas.high.udp.IGetH264Data; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.MulticastSocket; + +/** + * @author nie yunlong + * @description + * @date 2018/7/11 + */ +public abstract class AbstractUdpImpl implements IUdpAction, Runnable { + + + static final String TAG = AbstractUdpImpl.class.getSimpleName(); + /** + * udp端口 + */ + private int udpPort; + /** + * 是否组播 + */ + private boolean isMultiCast; + /** + * 组播IP + */ + private String multiCastIp; + + public static final int DATA_LEN = 8 * 1024; + byte[] inBuff; + /** + * 接收的包 + */ + private DatagramPacket inPacket; + /** + * udp + */ + private DatagramSocket socket = null; + /** + * 带广播的udp + */ + private MulticastSocket mMulticastSocket = null; + /** + * 第一次获取到接收端的ip + */ + private volatile boolean isFirstReceiverAddress; + + /** + * 接口 回调一帧 + */ + protected IGetH264Data mGetH264Data; + + private IConnectRtpListener mConnectRtpListener; + /** + * stop + */ + private volatile boolean isStop; + + /** + * 接收的ip地址 + */ + private volatile String mReceiveAddress; + /** + * 暂停状态 + */ + protected volatile boolean isPause = false; + + public AbstractUdpImpl(int byteSize) { + inBuff = new byte[byteSize]; + inPacket = new DatagramPacket(inBuff, inBuff.length); + + + } + + @Override + public void onPause() { + isPause = true; + } + + @Override + public void onResume() { + isPause = false; + } + + @Override + public void close() { + try { + setStop(true); + if (mMulticastSocket != null) { + mMulticastSocket.close(); + mMulticastSocket = null; + } + if (socket != null) { + socket.close(); + socket = null; + } + + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (mConnectRtpListener != null) { + mConnectRtpListener = null; + } + if (mGetH264Data != null) { + mGetH264Data = null; + } + inPacket = null; + inBuff = null; + } + } + + @Override + public void setUdpPort(int udpPort) { + this.udpPort = udpPort; + } + + @Override + public void setMultiCast(boolean multiCast) { + isMultiCast = multiCast; + } + + @Override + public synchronized void setStop(boolean stop) { + isStop = stop; + } + + @Override + public void setOnConnectListener(IConnectRtpListener connectRtpListener) { + this.mConnectRtpListener = connectRtpListener; + } + + @Override + public void getVideoInputStreamData(IGetH264Data getH264Data) { + this.mGetH264Data = getH264Data; + } + + public void setFirstReceiverAddress(boolean firstReceiverAddress) { + isFirstReceiverAddress = firstReceiverAddress; + } + + @Override + public void initBuffer() { + + } + + @Override + public void run() { + // CupidLogUtils.e(TAG, "---->开始接收数据"); + try { + if (isMultiCast) { + mMulticastSocket = new MulticastSocket(udpPort); + InetAddress bcAddr = InetAddress.getByName(multiCastIp); + mMulticastSocket.setReuseAddress(true); + mMulticastSocket.joinGroup(bcAddr); + mMulticastSocket.setLoopbackMode(false); + } else { + CupidLogUtils.e(TAG, "---->开始连接端口" + udpPort + ",stop" + isStop); + if (socket == null) { + socket = new DatagramSocket(udpPort); + socket.setReuseAddress(true); + socket.setReceiveBufferSize(32 * 1024); + CupidLogUtils.e("--->setReceiveBufferSize:" + socket.getReceiveBufferSize()); + CupidLogUtils.e(TAG, "---->连接成功" + udpPort); + } + } + } catch (Exception e) { + e.printStackTrace(); + CupidLogUtils.e(TAG, "---->udp" + e.getMessage()); + if (mConnectRtpListener != null) { + mConnectRtpListener.onConnectionFailedRtp(e.getMessage()); + } + } + + while (!isStop) { + try { + if (isMultiCast && mMulticastSocket != null) { + mMulticastSocket.receive(inPacket); + } else { + if (socket != null) { + //inPacket.setLength(0); + socket.receive(inPacket); + } + } + long receiverDataTimeUdp = System.currentTimeMillis(); + if (!isFirstReceiverAddress) { + if (inPacket.getAddress() != null) { + mReceiveAddress = inPacket.getAddress().getHostAddress(); + CupidLogUtils.e("mReceiveAddress--->mReceiveAddress" + mReceiveAddress); + isFirstReceiverAddress = true; + if (mConnectRtpListener != null) { + mConnectRtpListener.getOnConnectionAddress(mReceiveAddress); + } + } + + } + if (inPacket.getAddress() != null) { + parseData(inPacket, receiverDataTimeUdp); + } + } catch (Exception e) { + e.printStackTrace(); + CupidLogUtils.e("UdpException" + e.getMessage()); + if (mConnectRtpListener != null) { + mConnectRtpListener.onConnectionFailedRtp(e.getMessage()); + } + } + } + + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidRenderImageServer.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidRenderImageServer.java new file mode 100644 index 0000000000..f35b10635c --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidRenderImageServer.java @@ -0,0 +1,55 @@ +package com.zhidao.support.adas.high.udp.factory; + +import com.zhidao.support.adas.high.udp.IBuffStream; + +import java.net.DatagramPacket; + +/** + * @author nie yunlong + * @description 绘制上层数据 + * @date 2018/7/11 + */ +public class CupidRenderImageServer extends AbstractUdpImpl { + + +// StringBuilder stringBuilder = new StringBuilder(); +// +// StringBuilder normalDataBuilder = new StringBuilder(); + /** + * 内容 + */ + private String content; + + public CupidRenderImageServer() { + super(8*1024); + } + + + /** + * 回调真实数据 + * + * @param realData + */ + public void callBackRealData(String realData) { + if (realData.contains("<")) { + realData.replace("<", ""); + } + if (realData.contains(">")) { + realData.replace(">", ""); + } + mGetH264Data.getH264Data(realData.getBytes(),System.currentTimeMillis()); + } + + @Override + public void parseData(DatagramPacket inPacket, long receiverDataTimeUdp) { + if (mGetH264Data != null && !isPause) { + content = new String(inPacket.getData(), 0, inPacket.getLength()); + mGetH264Data.getH264Data(content.getBytes(),receiverDataTimeUdp); + } + } + + @Override + public void setBuffStream(IBuffStream buffStream) { + + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidUdpFactory.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidUdpFactory.java new file mode 100644 index 0000000000..a5c8c22ca8 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidUdpFactory.java @@ -0,0 +1,37 @@ +package com.zhidao.support.adas.high.udp.factory; + +/** + * @author nie yunlong + * @description 生产udp对象 + * @date 2018/7/11 + */ +public class CupidUdpFactory { + + /** + * 创建视频流解析对象 + * + * @return + */ + public static AbstractUdpImpl createVideoStreamUdp() { + return new CupidVideoUdpServer(); + } + + /** + * 优化后的接收udp buffer + * + * @return + */ + public static AbstractUdpImpl createVideoStreamUdp2() { + return new CupidVideoUdpServer2(); + } + + /** + * 上层绘制 接收udp 给的数据 解析展示数据 + * + * @return + */ + public static AbstractUdpImpl createRenderImageUdp() { + return new CupidRenderImageServer(); + } + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer.java new file mode 100644 index 0000000000..a579e76b5f --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer.java @@ -0,0 +1,243 @@ +package com.zhidao.support.adas.high.udp.factory; + + + +import com.zhidao.support.adas.high.common.CupidLogUtils; +import com.zhidao.support.adas.high.udp.IBuffStream; + +import java.io.IOException; +import java.net.DatagramPacket; + +import static com.zhidao.support.adas.high.udp.CupidBufStreamImpl.BUF_SIZE_LIMIT; + + +/** + * @author nie yunlong + * @description 视频流 + * @date 2018/7/11 + */ +public class CupidVideoUdpServer extends AbstractUdpImpl { + + private IBuffStream buffStream; + + private byte[] fu_h_byte; + + /** + * 是否是开始第一帧 + */ + boolean isBegin = false; + /** + * 对照h264帧 + */ + private int mIndexSeqNo = 0; + + /** + * 容错次数 + */ + private int mConcernedNumber = 0; + /** + * 容错常量 2次 + */ + private final int CONCERNED_NUMBER_RTP = 5; + + public CupidVideoUdpServer() { + super(DATA_LEN); + } + + + @Override + public void setBuffStream(IBuffStream buffStream) { + this.buffStream = buffStream; + } + + /** + * 替换rtp头 暴露h264 + * + * @param inPacket + * @return + */ + boolean parseRTP(DatagramPacket inPacket) { + int naluType = 0; + int nalunri = 0; + int naluf = 0; + + boolean isEnd = false; + //最高位是否是F 1111 **** + if ((int) (inBuff[1] >> 7 & 0x01) == 1) { + isEnd = true; + } + //inBuff[3] 是啥数据 就是啥 0xFF 都是1 1111 1111 + int seq_no = inBuff[3] & 0xFF; + //左移 补0 结果是把inBuffer[3]inBuffer[2] 得到数据 获取到的长度 + seq_no |= (((int) inBuff[2] << 8) & 0xFF00); + +// CupidLogUtils.e("seq_no" + seq_no + ",begin=>" + isBegin + ",isEnd=>" + isEnd); + + if (seq_no == 1) { //0001 开始位置 + isBegin = true; + mIndexSeqNo = 1; + } else if (seq_no == 65530) { //FFFF 结束一帧 + isEnd = true; + isBegin = false; + mIndexSeqNo = 0; + } + +// boolean isSkip = isCheckConcernedNumer(isEnd); +//// if (isSkip) { +//// return false; +//// } + + if (buffStream.getLength() > BUF_SIZE_LIMIT) { + buffStream.close(); + return false; + } + byte naluHeader = inBuff[12]; + naluType = naluHeader & 0x1f; // + nalunri = naluHeader >> 5 & 0x03; + naluf = naluHeader >> 7 & 0x01; + int len = inPacket.getLength(); +// CupidLogUtils.i(TAG, "packet-len:" + len); + + fu_h_byte = new byte[5]; + fu_h_byte[0] = 0; + fu_h_byte[1] = 0; + fu_h_byte[2] = 0; + fu_h_byte[3] = 1; + + if (28 == naluType) { //0x1C ‭0001 1100‬ + // H264 Begin + int fu_type = 0; + int fu_r = 0; + int fu_e = 0; + int fu_s = 0; + + byte fu_header = inBuff[13]; + fu_type = fu_header & 0x1f; + fu_r = fu_header >> 5 & 0x01; + fu_e = fu_header >> 6 & 0x01; + fu_s = fu_header >> 7 & 0x01; + + if (fu_s == 1) { + //buffStream.doSwitch(); + // start of fu-a + fu_h_byte[4] = (byte) ((fu_type & 0x1f) | (nalunri << 5 & 0x60) | (naluf << 7 & 0x80)); + try { + //buffStream.getOutputStream().write(fu_h_byte, 0, 5); + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + } else if (1 == fu_e) { + // end of fu-a + try { + if (isBegin || isEnd) { + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + } else { + // middle of fu-a + try { + if (isBegin) { + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + } + + } else { + //TODO 没用上 + fu_h_byte[4] = (byte) ((naluType & 0x1f) | (nalunri << 5 & 0x60) | (naluf << 7 & 0x80)); + try { + //buffStream.getOutputStream().write(fu_h_byte, 0, 5); + buffStream.getOutputStream().write(inBuff, 13, len - 13); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + if (isEnd) { + if (mGetH264Data != null) { + try { + mGetH264Data.getH264Data(buffStream.getData(),System.currentTimeMillis()); + } catch (OutOfMemoryError outOfMemoryError) { + CupidLogUtils.e("===>内存溢出"); + buffStream.close(); + System.gc(); + } + } + buffStream.doSwitch(); + } + return true; + } + + /** + * 是否跳过 后边代码 + * + * @param isEnd + * @return + */ + private boolean isCheckConcernedNumer(boolean isEnd) { + int seq_no = inBuff[3] & 0xFF; + seq_no |= (((int) inBuff[2] << 8) & 0xFF00); + + CupidLogUtils.e("seq_no" + seq_no + ",begin=>" + isBegin + ",isEnd=>" + isEnd); + + if (seq_no == 1) { + isBegin = true; + mIndexSeqNo = 1; + } else if (seq_no == 65530) { + isEnd = true; + isBegin = false; + mIndexSeqNo = 0; + } else { + mIndexSeqNo++; + if (mIndexSeqNo != seq_no && mConcernedNumber <= CONCERNED_NUMBER_RTP) { + mConcernedNumber++; + } + if (mConcernedNumber > CONCERNED_NUMBER_RTP) { + CupidLogUtils.e("===>超过次数==>mConcernedNumber" + mConcernedNumber); + mConcernedNumber = 0; + buffStream.doSwitch(); + return true; + } + } + return false; + } + + @Override + public void close() { + super.close(); + if (buffStream != null) { + buffStream.close(); + buffStream = null; + } + } + + @Override + public void parseData(DatagramPacket inPacket, long receiverDataTimeUdp) { + if (isPause) { + buffStream.close(); + } + if (inPacket.getLength() > 0 && !isPause) { + CupidLogUtils.w("===》数据包" + inPacket.getLength() + ",string" + new String(inPacket.getData())); + parseRTP(inPacket); + } + } + + @Override + public void initBuffer() { + super.initBuffer(); + if (buffStream != null) { + buffStream.close(); + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer2.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer2.java new file mode 100644 index 0000000000..9d2c434049 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer2.java @@ -0,0 +1,247 @@ +package com.zhidao.support.adas.high.udp.factory; + + + +import com.zhidao.support.adas.high.common.CupidLogUtils; +import com.zhidao.support.adas.high.udp.IBuffStream; + +import java.io.IOException; +import java.net.DatagramPacket; + +import static com.zhidao.support.adas.high.udp.CupidBufStreamImpl2.BUF_SIZE_LIMIT; + + +/** + * @author nie yunlong + * @description 视频流 + * @date 2018/7/11 + */ +public class CupidVideoUdpServer2 extends AbstractUdpImpl { + + private IBuffStream buffStream; + + private byte[] fu_h_byte; + + /** + * 是否是开始第一帧 + */ + boolean isBegin = false; + /** + * 对照h264帧 + */ + private int mIndexSeqNo = 0; + + /** + * 容错次数 + */ + private int mConcernedNumber = 0; + /** + * 容错常量 2次 + */ + private final int CONCERNED_NUMBER_RTP = 5; + + public CupidVideoUdpServer2() { + super(DATA_LEN); + } + + + @Override + public void setBuffStream(IBuffStream buffStream) { + this.buffStream = buffStream; + } + + /** + * 替换rtp头 暴露h264 + * + * @param inPacket + * @return + */ + boolean parseRTP(DatagramPacket inPacket) { + int naluType = 0; + int nalunri = 0; + int naluf = 0; + + boolean isEnd = false; + //最高位是否是F 1111 **** + if ((int) (inBuff[1] >> 7 & 0x01) == 1) { + isEnd = true; + } + //inBuff[3] 是啥数据 就是啥 0xFF 都是1 1111 1111 + int seq_no = inBuff[3] & 0xFF; + //左移 补0 结果是把inBuffer[3]inBuffer[2] 得到数据 获取到的长度 + seq_no |= (((int) inBuff[2] << 8) & 0xFF00); + +// CupidLogUtils.e("seq_no" + seq_no + ",begin=>" + isBegin + ",isEnd=>" + isEnd); + + if (seq_no == 1) { //0001 开始位置 + //如果在开始有问题 reset + if (buffStream.getLength() > 0) { + buffStream.doSwitch(); + } + isBegin = true; + mIndexSeqNo = 1; + } else if (seq_no == 65530) { //FFFF 结束一帧 + isEnd = true; + isBegin = false; + mIndexSeqNo = 0; + } + +// boolean isSkip = isCheckConcernedNumer(isEnd); +//// if (isSkip) { +//// return false; +//// } + + if (buffStream.getLength() > BUF_SIZE_LIMIT) { + buffStream.close(); + return false; + } + byte naluHeader = inBuff[12]; + naluType = naluHeader & 0x1f; // + nalunri = naluHeader >> 5 & 0x03; + naluf = naluHeader >> 7 & 0x01; + int len = inPacket.getLength(); +// CupidLogUtils.i(TAG, "packet-len:" + len); + + fu_h_byte = new byte[5]; + fu_h_byte[0] = 0; + fu_h_byte[1] = 0; + fu_h_byte[2] = 0; + fu_h_byte[3] = 1; + + if (28 == naluType) { //0x1C ‭0001 1100‬ + // H264 Begin + int fu_type = 0; + int fu_r = 0; + int fu_e = 0; + int fu_s = 0; + + byte fu_header = inBuff[13]; + fu_type = fu_header & 0x1f; + fu_r = fu_header >> 5 & 0x01; + fu_e = fu_header >> 6 & 0x01; + fu_s = fu_header >> 7 & 0x01; + + if (fu_s == 1) { + //buffStream.doSwitch(); + // start of fu-a + fu_h_byte[4] = (byte) ((fu_type & 0x1f) | (nalunri << 5 & 0x60) | (naluf << 7 & 0x80)); + try { + //buffStream.getOutputStream().write(fu_h_byte, 0, 5); + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + } else if (1 == fu_e) { + // end of fu-a + try { + if (isBegin || isEnd) { + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + } else { + // middle of fu-a + try { + if (isBegin) { + buffStream.getOutputStream().write(inBuff, 14, len - 14); + } + } catch (IOException e) { + e.printStackTrace(); + return false; + } + + } + + } else { + //TODO 没用上 + fu_h_byte[4] = (byte) ((naluType & 0x1f) | (nalunri << 5 & 0x60) | (naluf << 7 & 0x80)); + try { + //buffStream.getOutputStream().write(fu_h_byte, 0, 5); + buffStream.getOutputStream().write(inBuff, 13, len - 13); + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + if (isEnd) { + if (mGetH264Data != null) { + try { + mGetH264Data.getH264Data(buffStream.getData(),System.currentTimeMillis()); + } catch (OutOfMemoryError outOfMemoryError) { + CupidLogUtils.e("===>内存溢出"); + buffStream.close(); + System.gc(); + } + } + buffStream.doSwitch(); + } + return true; + } + + /** + * 是否跳过 后边代码 + * + * @param isEnd + * @return + */ + private boolean isCheckConcernedNumer(boolean isEnd) { + int seq_no = inBuff[3] & 0xFF; + seq_no |= (((int) inBuff[2] << 8) & 0xFF00); + + CupidLogUtils.e("seq_no" + seq_no + ",begin=>" + isBegin + ",isEnd=>" + isEnd); + + if (seq_no == 1) { + isBegin = true; + mIndexSeqNo = 1; + } else if (seq_no == 65530) { + isEnd = true; + isBegin = false; + mIndexSeqNo = 0; + } else { + mIndexSeqNo++; + if (mIndexSeqNo != seq_no && mConcernedNumber <= CONCERNED_NUMBER_RTP) { + mConcernedNumber++; + } + if (mConcernedNumber > CONCERNED_NUMBER_RTP) { + CupidLogUtils.e("===>超过次数==>mConcernedNumber" + mConcernedNumber); + mConcernedNumber = 0; + buffStream.doSwitch(); + return true; + } + } + return false; + } + + @Override + public void close() { + super.close(); + if (buffStream != null) { + buffStream.close(); + buffStream = null; + } + } + + @Override + public void parseData(DatagramPacket inPacket, long receiverDataTimeUdp) { + if (isPause) { + buffStream.close(); + } + if (inPacket.getLength() > 12 && !isPause) { + CupidLogUtils.w("===》数据包" + inPacket.getLength() + ",string" + new String(inPacket.getData())); + parseRTP(inPacket); + } + } + + @Override + public void initBuffer() { + super.initBuffer(); + if (buffStream != null) { + buffStream.close(); + } + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/IUdpAction.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/IUdpAction.java new file mode 100644 index 0000000000..bfff270c14 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/IUdpAction.java @@ -0,0 +1,88 @@ +package com.zhidao.support.adas.high.udp.factory; + + + +import com.zhidao.support.adas.high.udp.IBuffStream; +import com.zhidao.support.adas.high.udp.IConnectRtpListener; +import com.zhidao.support.adas.high.udp.IGetH264Data; + +import java.net.DatagramPacket; + +/** + * @author nie yunlong + * @description udp 抽象方法 + * @date 2018/7/11 + */ +public interface IUdpAction { + + /** + * udp 关闭释放资源 + */ + void close(); + + /** + * set udp port + * + * @param udpPort + */ + void setUdpPort(int udpPort); + + /** + * 设置广播模式 + * + * @param multiCast + */ + void setMultiCast(boolean multiCast); + + /** + * 停止udp 线程 + * + * @param stop + */ + void setStop(boolean stop); + + /** + * 设置socket 连接状态监听 + * + * @param connectRtpListener + */ + void setOnConnectListener(IConnectRtpListener connectRtpListener); + + /** + * 获取udp数据 + * + * @param getH264Data + */ + void getVideoInputStreamData(IGetH264Data getH264Data); + + /** + * 解析接收到数据包 + * + * @param inPacket + */ + void parseData(DatagramPacket inPacket,long receiverDataTimeUdp); + + + /** + * 设置buffer + * + * @param buffStream + */ + void setBuffStream(IBuffStream buffStream); + + /** + * onPause + */ + void onPause(); + + /** + * onResume + */ + void onResume(); + + /** + * init buffer 服务器关闭 初始化数据 + */ + void initBuffer(); + +} diff --git a/libraries/mogo-adas/src/main/proto/adas.proto b/libraries/mogo-adas/src/main/proto/adas.proto new file mode 100644 index 0000000000..f8b5478853 --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/adas.proto @@ -0,0 +1,87 @@ +syntax = "proto2"; +package adas; + +enum CarLocation +{ + Same_LINE = 0; + Left_LINE = 1; + Right_LINE = 2; + left2_LINE = 3; + Right2_LINE = 4; +} + +enum ActionType +{ + action_type_view = 1; + action_type_obstacles = 2; + action_type_lanes = 3; + action_type_state = 4; + action_type_warn = 5; + action_type_light = 6; + action_type_config = 7; + action_type_gdgps = 8; + action_type_auto_pilot_state = 9; + action_type_auto_pilot_mode = 10; + action_type_obu_traffic_light = 11; + action_type_ai_cloud_to_start_autopilot = 12; +} + +message View +{ + optional int32 xl = 1; + optional int32 yt = 2; + optional int32 xr = 3; + optional int32 yb = 4; + //物体类型 + optional string type = 5; + optional CarLocation showImageLocation = 6; + //距离x轴值 + optional double distance_x = 7; + //距离y轴值 + optional double distance_y = 8; + //经度 + optional double lon = 9; + //纬度 + optional double lat = 10; + //海拔 + optional double alt = 11; + //系统时间 + optional string systemTime = 12; + //gps时间 + optional string satelliteTime = 13; + //车辆id + optional string uuid = 14; + //车牌id + optional string carId = 15; + //车辆颜色 + optional string color = 16; + //车辆朝向 + optional double heading = 17; + //车辆速度 + optional double speed = 18; + //长 + optional float length = 19; + //宽 + optional float width = 20; + //高 + optional float height = 21; + //危险等级 1 绿,2 黄,3 红 + optional int32 drawlevel = 22; + //驱动感知时间 + optional string driverTime = 23; +} + + +// 渲染流消息 +message ViwesMsg +{ + optional string action = 1; + repeated View models = 2; +} + + + + + + + diff --git a/libraries/mogo-adas/src/main/proto/car_status.proto b/libraries/mogo-adas/src/main/proto/car_status.proto new file mode 100644 index 0000000000..6f4f477051 --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/car_status.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; +package mogo.status; + + +message Status +{ + //经度 + double lon = 1; + //纬度 + double lat = 2; + //海拔 + double alt = 3; + //航向角 + double heading = 4; + //加速度 + double acceleration = 5; + //曲率 + double yaw_rate = 6; + //惯导车速 m/s + float gnss_speed = 7; + //车辆车速 m/s + float vehicle_speed = 8; + //gps时间 + string satelliteTime = 9; + //系统时间 + string systemTime = 10; + //转向灯状态 + int32 turn_light = 11; + //双闪灯状态 + int32 flash_light = 12; + //刹车灯状态 + int32 brake_light = 13; + //统计包个数 + int32 frame_num = 14; +} + + + + + + + diff --git a/libraries/mogo-adas/src/main/proto/geometry.proto b/libraries/mogo-adas/src/main/proto/geometry.proto new file mode 100644 index 0000000000..9910b32a10 --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/geometry.proto @@ -0,0 +1,84 @@ +syntax = "proto2"; +package geometry; + +message Vector3 { + optional double x = 1; + optional double y = 2; + optional double z = 3; +} + +message Vector3f { + optional float x = 1; + optional float y = 2; + optional float z = 3; +} + +message Point2D { + optional double x = 1 [default = nan]; + optional double y = 2 [default = nan]; +} + +message Point3D { + optional double x = 1 [default = nan]; + optional double y = 2 [default = nan]; + optional double z = 3 [default = nan]; +} + +message Trace { + optional double timestamp = 1; + optional Point3D position = 2; + optional Point3D velocity = 3; + optional Point3D acceleration = 4; + optional Point3D heading = 5; +} + +message PointLLH { + // Longitude in degrees, ranging from -180 to 180. + optional double lon = 1 [default = nan]; + // Latitude in degrees, ranging from -90 to 90. + optional double lat = 2 [default = nan]; + // WGS-84 ellipsoid height in meters. + optional double height = 3 [default = 0.0]; +} + +message Point { + optional double x = 1; + optional double y = 2; + optional double z = 3; +} + +message Quaternion { + optional double x = 1 [default = nan]; + optional double y = 2 [default = nan]; + optional double z = 3 [default = nan];; + optional double w = 4 [default = nan]; +} + +message Polygon { + repeated Point points = 1; +} + +message Transform { + optional Vector3 translation = 1; + optional Quaternion rotation = 2; +} + +//pose in free space, composed of position and orientation +message Pose { + optional Point position = 1; + optional Quaternion orientation = 2; +} + +//acceleration in free space broken into its linear and angular parts +message Accel { + optional Vector3 linear = 1; + optional Vector3 angular = 2; +} + +//velocity in free space broken into its linear and angular parts +message Twist { + optional Vector3 linear = 1; + optional Vector3 angular = 2; +} + + diff --git a/libraries/mogo-adas/src/main/proto/header.proto b/libraries/mogo-adas/src/main/proto/header.proto new file mode 100644 index 0000000000..2a50a1702d --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/header.proto @@ -0,0 +1,23 @@ +syntax = "proto2"; + +package common; + +message Time { + optional uint32 sec = 1; + optional uint32 nsec = 2; +} + +message Header { + // Sequence number for each message. Each module maintains its own counter for + // sequence_num, always starting from 1 on boot. + optional uint32 seq = 1; + + // Message publishing time in seconds. + optional Time stamp = 2; + + // frame id + optional string frame_id = 3; + + // Module name. + optional string module_name = 4; +} diff --git a/libraries/mogo-adas/src/main/proto/mogo_guardian.proto b/libraries/mogo-adas/src/main/proto/mogo_guardian.proto new file mode 100644 index 0000000000..27e5946a47 --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/mogo_guardian.proto @@ -0,0 +1,76 @@ +syntax = "proto3"; +package mogo.guardian; +/* +message xxx { + // 字段规则:required -> 字段只能也必须出现 1 次. proto3中移除了required + // 字段规则:optional -> 字段可出现 0 次或1次 + // 字段规则:repeated -> 字段可出现任意多次(包括 0) + // 类型:int32、int64、sint32、sint64、string、32-bit .... + // 字段编号:0 ~ 536870911(除去 19000 到 19999 之间的数字) + 字段规则 类型 名称 = 字段编号; +} +*/ +/* 监控实体 */ +message GuardianProto { +/* i接口名成*/ + string action = 1; +/* 监控项名称*/ + string agentName = 2; +/* 车牌号*/ + string carNum = 3; +/* 工控机mac地址*/ + string macAddr = 4; +/* 车型*/ + string carType = 5; +/* 监控类型*/ + string monitorType = 6; +/* sn*/ + string sn = 7; +/* 时间*/ + uint64 time = 8; +/* 模块*/ + Modules modules = 9; +} + +/* 模块*/ +message Modules { +/* 子项*/ + repeated ItemsName itemsname = 1; +/* 子模块*/ + repeated SubModules submodules = 2; +} + +/* 子项*/ +message ItemsName { +/* 子项名称*/ + string name = 1; +/* 子项键值属性*/ + repeated Items items = 2; +} +/* 键值对*/ +message Items { +/* key*/ + string name = 1; +/* value*/ + string value = 2; + +} +/* 子模块*/ +message SubModules { +/* 子模块名称*/ + string modulename = 1; +/* 子节点*/ + repeated SubNode subnodes = 2; + +} + +/* 模块中的节点*/ +message SubNode{ +/* 节点名称*/ + string nodename = 1; +/* 节点项*/ + repeated Items nodeitems = 2; +/* *topic项*/ + repeated ItemsName topicitems = 3; +} + diff --git a/libraries/mogo-adas/src/main/proto/route_list.proto b/libraries/mogo-adas/src/main/proto/route_list.proto new file mode 100644 index 0000000000..407ca0563c --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/route_list.proto @@ -0,0 +1,27 @@ +syntax = "proto2"; + +package hadmap; + +import "geometry.proto"; +import "header.proto"; + +message RouteInfo { + optional string id = 1; + optional geometry.Point start = 2;//经纬度坐标 + optional string start_eng = 3; //起点拼音大写 + optional string start_chn = 4; //起点中文名 + optional geometry.Point end = 5;//经纬度坐标 + optional string end_eng = 6; //终点拼音大写 + optional string end_chn = 7; //终点中文名 + optional string traj_file_path = 8; // file path+file name + optional int32 vehicle_type = 9; + optional string time = 10; + optional string comment = 11; +} + +message RouteList { + optional common.Header header = 1; + optional uint32 routes_count = 2; + repeated RouteInfo routes_info = 3; +} + diff --git a/libraries/mogo-adas/src/main/proto/trajectory.proto b/libraries/mogo-adas/src/main/proto/trajectory.proto new file mode 100644 index 0000000000..afd61c757c --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/trajectory.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package mogo.trajectory; + +message TrajectoryPoint { + double x = 1; + double y = 2; + double z = 3; + double t = 4; //time in seconds + double v = 5; //velocity in m/s + double a = 6; //acceleration in m/s^26766 + double theta = 7; //direction of v + double kappa = 8; //curvature + double s = 9; //accumulated distance in meters from beginning +} + +message Trajectory { + repeated TrajectoryPoint points = 1; +} diff --git a/libraries/mogo-adas/src/main/proto/websocket_header.proto b/libraries/mogo-adas/src/main/proto/websocket_header.proto new file mode 100644 index 0000000000..909787d1d3 --- /dev/null +++ b/libraries/mogo-adas/src/main/proto/websocket_header.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package mogo.webproto; + +enum Constants { + DEFAULT = 0x0000; //0 + Magic = 0x6d67; //"mg" +} + +/************************Head Def***********************/ +/*******************************************************/ + +message Header_websock { + uint32 msgType = 1; //payload type, enum @PacketType +} + + +enum MsgType_websock { + mogo_DEFAULT = 0x000; // 0 + mogoTrajectory = 0x100; // 轨迹规划 + mogoAdas = 0x101; //adas数据 + mogoCar = 0x102; //自车数据 + mogoDataCollect = 0x103; //数据采集文件 + mogoRoutList = 0x104; //maplist + mogoGuardian = 0x105; //监控 +} diff --git a/libraries/mogo-adas/src/main/res/values/strings.xml b/libraries/mogo-adas/src/main/res/values/strings.xml index f02e39594e..9e8787cc20 100644 --- a/libraries/mogo-adas/src/main/res/values/strings.xml +++ b/libraries/mogo-adas/src/main/res/values/strings.xml @@ -1,3 +1,3 @@ - mogo-adas + adas-high