[V2X]添加新的长链类型
[V2X]添加新的长链类型
This commit is contained in:
@@ -4,6 +4,7 @@ apply from: "config.gradle"
|
||||
buildscript {
|
||||
ext.kotlin_version = "1.4.31"
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
}
|
||||
@@ -14,10 +15,10 @@ buildscript {
|
||||
url 'http://nexus.zhidaoauto.com/repository/maven-public/'
|
||||
}
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:3.5.3"
|
||||
classpath 'gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.18'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
|
||||
// 对kotlin生成doc
|
||||
@@ -29,6 +30,7 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven {
|
||||
url 'http://maven.aliyun.com/nexus/content/groups/public/'
|
||||
}
|
||||
@@ -39,7 +41,6 @@ allprojects {
|
||||
url 'http://nexus.zhidaoauto.com/repository/maven-public/'
|
||||
}
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,12 @@ ext {
|
||||
googlezxing : "com.google.zxing:core:3.3.3",
|
||||
litezxing : "com.google.zxing:litezxing:1.0.29.8",
|
||||
cossdk : "com.zhidao.cosupload:cosuploadsdk:1.1.6",
|
||||
spi : 'com.elegant.spi:api:1.0.9.1' //运行时spi库
|
||||
spi : 'com.elegant.spi:api:1.0.9.1' ,//运行时spi库
|
||||
|
||||
//========================== ProtoBuf =======================
|
||||
protoc : "com.google.protobuf:protoc:3.12.4",
|
||||
protobuf_java : "com.google.protobuf:protobuf-java:3.12.4",
|
||||
protobuf_java_util : "com.google.protobuf:protobuf-java-util:3.12.4",
|
||||
|
||||
]
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.mogo.cloud.socket;
|
||||
import static com.mogo.cloud.socket.SocketServicesConstants.getTag;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
@@ -11,6 +12,8 @@ import com.elegant.log.simplelog.Logger;
|
||||
import com.elegant.network.utils.GsonUtil;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import com.google.protobuf.Message;
|
||||
import com.google.protobuf.MessageOrBuilder;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.cloud.socket.entity.MsgBody;
|
||||
@@ -20,6 +23,7 @@ import com.mogo.cloud.socket.third.ThirdSocketManager;
|
||||
import com.zhidao.ptech.connsvr.protocol.MogoConnsvr;
|
||||
import com.zhidao.socket.ConnectionLifecycleListener;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@@ -35,6 +39,8 @@ public class SocketManager implements IMogoCloudSocketManager {
|
||||
private static volatile SocketManager mInstance;
|
||||
private MoGoAiCloudClientConfig cloudClientConfig;
|
||||
|
||||
private static final String TAG = "SocketManager";
|
||||
|
||||
private SocketManager() {
|
||||
cloudClientConfig = MoGoAiCloudClient.getInstance().getAiCloudClientConfig();
|
||||
}
|
||||
@@ -160,15 +166,25 @@ public class SocketManager implements IMogoCloudSocketManager {
|
||||
IMogoCloudSocketOnMessageListener listener = iterator.next();
|
||||
if (payload.getPayload() != null) {
|
||||
Class clz = listener.target(msgType);
|
||||
if ("SocketDownDataProto".equals(clz.getSimpleName())) {
|
||||
obj = SocketDownData.SocketDownDataProto.parseFrom(payload.getPayload());
|
||||
if (MessageOrBuilder.class.isAssignableFrom(clz)) {
|
||||
try {
|
||||
Constructor c = clz.getDeclaredConstructor(Void.class);
|
||||
if (c != null) {
|
||||
c.setAccessible(true);
|
||||
MessageOrBuilder o = (MessageOrBuilder)c.newInstance();
|
||||
o.getDefaultInstanceForType().getParserForType().parseFrom(payload.getPayload());
|
||||
obj = o;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
Log.e(TAG, Log.getStackTraceString(t));
|
||||
}
|
||||
} else {
|
||||
obj = GsonUtil.objectFromJson(payload.getPayload().toStringUtf8(), listener.target(msgType));
|
||||
}
|
||||
}
|
||||
if (listener != null) {
|
||||
if (listener != null && obj != null) {
|
||||
if (SocketBuildConfig.isPrintLog) {
|
||||
Logger.d(getTag(), "received msgId = %s, content = %s", msgId, payload.getPayload().toStringUtf8());
|
||||
Logger.d(getTag(), "received msgId = %s, msgType = %d, content = %s", msgId, msgType, obj);
|
||||
}
|
||||
listener.onMsgReceived(msgType, obj);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'org.jetbrains.dokka'
|
||||
apply plugin: 'com.google.protobuf'
|
||||
|
||||
android {
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
@@ -10,7 +11,6 @@ android {
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode 1
|
||||
versionName "${MOGO_SOCKET_VERSION}"
|
||||
|
||||
consumerProguardFiles "consumer-rules.pro"
|
||||
}
|
||||
|
||||
@@ -24,10 +24,25 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
protobuf {
|
||||
protoc {
|
||||
artifact = rootProject.ext.dependencies.protoc
|
||||
}
|
||||
generateProtoTasks {
|
||||
all().each { task ->
|
||||
task.builtins {
|
||||
java {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation rootProject.ext.dependencies.rxandroid
|
||||
implementation rootProject.ext.dependencies.protobuf_java
|
||||
implementation rootProject.ext.dependencies.protobuf_java_util
|
||||
if (Boolean.valueOf(RELEASE)) {
|
||||
implementation "com.mogo.cloud:location:${MOGO_LOCATION_VERSION}"
|
||||
implementation "com.mogo.cloud:network:${MOGO_NETWORK_VERSION}"
|
||||
|
||||
@@ -11,11 +11,13 @@ import com.mogo.v2x.data.V2XMarkerResponse
|
||||
import com.mogo.v2x.event.V2XEvent
|
||||
import com.mogo.v2x.http.V2XRefreshModel
|
||||
import com.mogo.v2x.http.callback.IV2XRefreshCallback
|
||||
import com.mogo.v2x.logger.Logger
|
||||
import com.mogo.v2x.socket.*
|
||||
import com.mogo.v2x.socket.V2XMessageListener_401012
|
||||
import com.mogo.v2x.socket.V2XMessageListener_401018
|
||||
import com.mogo.v2x.socket.V2XMessageListener_402000
|
||||
import com.mogo.v2x.socket.V2XMessageListener_404000
|
||||
import com.mogo.v2x.logger.Logger
|
||||
import com.mogo.v2x.socket.V2XMessageListener_503000
|
||||
import com.mogo.v2x.utils.DistanceUtils
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -131,7 +133,7 @@ object V2XManager {
|
||||
SocketManager.getInstance().registerOnMessageListener(401018, V2XMessageListener_401018(cbs))
|
||||
SocketManager.getInstance().registerOnMessageListener(402000, V2XMessageListener_402000(cbs))
|
||||
SocketManager.getInstance().registerOnMessageListener(404000, V2XMessageListener_404000(cbs))
|
||||
|
||||
SocketManager.getInstance().registerOnMessageListener(503000, V2XMessageListener_503000(cbs))
|
||||
|
||||
LocationManager.getInstance().init(config.context)
|
||||
LocationManager.getInstance().start()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.v2x.event
|
||||
|
||||
import com.mogo.v2x.data.*
|
||||
import roadwork.Road.RW_PB
|
||||
|
||||
sealed class V2XEvent {
|
||||
|
||||
@@ -40,6 +41,17 @@ sealed class V2XEvent {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 长链-道路事件云识别
|
||||
*/
|
||||
class RoadAI(val type: Int = 503000, val data: RW_PB): V2XEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "RoadAI(type=$type, data=$data)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 短链-道路标记事件
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.mogo.v2x.socket
|
||||
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener
|
||||
import com.mogo.v2x.V2XManager
|
||||
import com.mogo.v2x.callback.IV2XCallback
|
||||
import com.mogo.v2x.data.V2XAdvanceWarning
|
||||
import com.mogo.v2x.event.V2XEvent
|
||||
import com.mogo.v2x.event.V2XEvent.RoadAI
|
||||
import com.mogo.v2x.logger.Logger
|
||||
import roadwork.Road.RW_PB
|
||||
|
||||
internal class V2XMessageListener_503000(val cbs: Iterable<IV2XCallback>?): IMogoCloudSocketOnMessageListener<RW_PB> {
|
||||
|
||||
override fun target(msgType: Int): Class<RW_PB> = RW_PB::class.java
|
||||
|
||||
override fun onMsgReceived(msgType: Int, data: RW_PB?) {
|
||||
if (msgType != 503000) {
|
||||
return
|
||||
}
|
||||
if (data == null) {
|
||||
Logger.i(V2XManager.TAG, "V2XMessageListener_503000:message is null!")
|
||||
return
|
||||
}
|
||||
Logger.i(V2XManager.TAG, "V2XMessageListener_503000:$data")
|
||||
cbs?.forEach {
|
||||
it.onAck(RoadAI(data = data))
|
||||
}
|
||||
}
|
||||
}
|
||||
59
foudations/mogo-v2x/src/main/proto/road.proto
Normal file
59
foudations/mogo-v2x/src/main/proto/road.proto
Normal file
@@ -0,0 +1,59 @@
|
||||
syntax = "proto2";
|
||||
|
||||
package roadwork;
|
||||
|
||||
message RW_PB {
|
||||
required Roadwork_PB roadwork =1;
|
||||
optional Header header = 2;
|
||||
}
|
||||
|
||||
message Roadwork_PB{
|
||||
optional string id = 1; // 对应id
|
||||
required int32 score = 2; // 置信度
|
||||
required int64 detect_time = 3; // 发送时间
|
||||
required int32 poi_type = 4; // poi 类型
|
||||
optional int32 type = 5; // 事件类型
|
||||
required Center_PB center = 6; // 中心点坐标
|
||||
repeated GPSPoint_PB polygon = 7; // 多边形范围
|
||||
repeated Road_PB road = 8; // 车道集合信息
|
||||
}
|
||||
|
||||
message GPSPoint_PB {
|
||||
required double lat = 1; // 纬度
|
||||
required double lon = 2; // 经度
|
||||
optional double hgt = 3; // 高程
|
||||
}
|
||||
|
||||
message Road_PB{
|
||||
required string road_id = 1; // 路段id
|
||||
required string lane_no = 2; // 车道号
|
||||
required string tile_id = 3; // 瓦片id
|
||||
required int32 bearing = 4; // 方向角,正北是0度 顺时针
|
||||
}
|
||||
|
||||
message Center_PB{
|
||||
required Road_PB road = 1; // 道路信息
|
||||
required GPSPoint_PB point = 2; // 坐标
|
||||
}
|
||||
|
||||
// header
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -36,26 +36,26 @@ PASSWORD=xintai2018
|
||||
RELEASE=true
|
||||
# AI CLOUD 云平台
|
||||
# 工具类
|
||||
MOGO_UTILS_VERSION=1.3.59
|
||||
MOGO_UTILS_VERSION=1.4.1
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.3.59
|
||||
MOGO_NETWORK_VERSION=1.4.1
|
||||
# 网络DNS
|
||||
MOGO_HTTPDNS_VERSION=1.3.59
|
||||
MOGO_HTTPDNS_VERSION=1.4.1
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.3.59
|
||||
MOGO_PASSPORT_VERSION=1.4.1
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.3.59
|
||||
MOGO_SOCKET_VERSION=1.4.1
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.3.59
|
||||
MOGO_REALTIME_VERSION=1.4.1
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.3.59
|
||||
MOGO_TANLU_VERSION=1.4.1
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.3.59
|
||||
MOGO_LIVE_VERSION=1.4.1
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.3.59
|
||||
MOGO_TRAFFICLIVE_VERSION=1.4.1
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.3.59
|
||||
MOGO_LOCATION_VERSION=1.4.1
|
||||
# 远程通讯模块
|
||||
MOGO_TELEMATIC_VERSION=1.3.59
|
||||
MOGO_TELEMATIC_VERSION=1.4.1
|
||||
# v2x
|
||||
MOGO_V2X_VERSION=1.3.59
|
||||
MOGO_V2X_VERSION=1.4.1
|
||||
|
||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
||||
#Mon Jan 18 20:48:23 CST 2021
|
||||
#Wed Dec 18 10:03:53 CST 2019
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
|
||||
|
||||
Reference in New Issue
Block a user