diff --git a/config.gradle b/config.gradle index 22df70a5de..6a3e76a787 100644 --- a/config.gradle +++ b/config.gradle @@ -214,7 +214,7 @@ ext { mogo_core_network : "com.mogo.eagle.core:network:${MOGO_CORE_NETWORK_VERSION}", //========================= V2X SDK ========================= - mogo_v2x : "com.mogo.v2x:v2x:${MOGO_V2X_SDK_VERSION}", + mogo_v2x : "com.mogo.v2x:v2x:${MOGO_V2X_SDK_VERSION}", life_cycle_scope : "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0", view_model_scope : "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0", @@ -228,7 +228,12 @@ ext { androidx_unit_ext : "androidx.test.ext:junit:1.1.2", androidx_unit_ext_ktx : "androidx.test.ext:junit-ktx:1.1.2", androidx_runner : "androidx.test:runner:1.3.0", - androidx_espresso_core : "androidx.test.espresso:espresso-core:3.3.0" + androidx_espresso_core : "androidx.test.espresso:espresso-core:3.3.0", + + //========================== 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" ] diff --git a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt index bfe1427450..e556a18d3a 100644 --- a/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt +++ b/core/function-impl/mogo-core-function-autopilot/src/main/java/com/mogo/eagle/core/function/autopilot/MoGoAutopilotProvider.kt @@ -71,7 +71,7 @@ class MoGoAutopilotProvider : .setClient(false) .build() - AdasManager.getInstance().create(context, options) + AdasManager.getInstance().create(options, MoGoAdasMsgConnectStatusListenerImpl()) NSDNettyManager.getInstance().startNSDNettyServerWithSN(context, object : NettyServerListener { override fun onMessageResponseServer(msg: MogoProtocolMsg?, channel: Channel?) { @@ -107,7 +107,7 @@ class MoGoAutopilotProvider : .setIpcAssignIP(FunctionBuildConfig.adasConnectIP) .setClient(true) .build() - AdasManager.getInstance().create(context, options) + AdasManager.getInstance().create(options, MoGoAdasMsgConnectStatusListenerImpl()) NSDNettyManager.getInstance() .searchAndConnectServer(context, MoGoAiCloudClientConfig.getInstance().sn, object : NettyClientListener { @@ -134,9 +134,7 @@ class MoGoAutopilotProvider : }) } //////////////////////////////////注意先后顺序,AdasManager.getInstance().create后才可以设置监听///////////////////////////////////////////// - // 监听 adas 连接状态 - AdasManager.getInstance() - .setOnAdasConnectStatusListener(MoGoAdasMsgConnectStatusListenerImpl()) + // 监听ADAS-SDK获取到的工控机数据(乘客也需注册) AdasManager.getInstance().setOnAdasListener(MoGoAdasListenerImpl()) // 司机端监听 diff --git a/core/mogo-core-data/build.gradle b/core/mogo-core-data/build.gradle index 618b44468c..8636b97258 100644 --- a/core/mogo-core-data/build.gradle +++ b/core/mogo-core-data/build.gradle @@ -4,6 +4,7 @@ plugins { id 'kotlin-android-extensions' id 'kotlin-kapt' id 'com.alibaba.arouter' + id 'com.google.protobuf' } android { compileSdkVersion rootProject.ext.android.compileSdkVersion @@ -33,7 +34,35 @@ 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 = rootProject.ext.dependencies.protoc + } + + generateProtoTasks { + all().each { task -> + task.builtins { + remove java + } + task.builtins { + java {} + } + } + } + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 @@ -53,6 +82,8 @@ dependencies { implementation rootProject.ext.dependencies.androidxroomruntime implementation rootProject.ext.dependencies.androidxroomktx kapt rootProject.ext.dependencies.androidxroomcompiler + api rootProject.ext.dependencies.protobuf_java + api rootProject.ext.dependencies.protobuf_java_util if (Boolean.valueOf(USE_MAVEN_PACKAGE)) { implementation rootProject.ext.dependencies.mogo_core_res } else { diff --git a/core/mogo-core-data/src/main/proto/chassis.proto b/core/mogo-core-data/src/main/proto/chassis.proto new file mode 100644 index 0000000000..52e3dfe9eb --- /dev/null +++ b/core/mogo-core-data/src/main/proto/chassis.proto @@ -0,0 +1,41 @@ +syntax = "proto2"; +package chassis; + +enum GearPosition { + GEAR_NONE = 0; + GEAR_N = 1; + GEAR_R = 2; + GEAR_P = 3; + GEAR_D = 4; +} + +enum LightSwitch { + LIGHT_NONE = 0; + LIGHT_LEFT = 1; + LIGHT_RIGHT = 2; + LIGHT_FLASH = 3; + LIGHT_MANUAL = 4; + LIGHT_AUTO = 5; +} + +enum PilotMode { + MODE_MANUAL = 0; + MODE_AUTO_DRIVE = 1; + MODE_STEER_ONLY = 2; + MODE_SPEED_ONLY = 3; +} + +enum LongitudeDrivingMode { + ManualMode = 0; + AutomaticStandby = 1; + AutomaticAcceleration = 2; + AutomaticDeceleration = 3; +} + +enum EPSSteeringMode { + Manual = 0; + Automatic = 1; + ManualFromInterference = 2; + ManualFromEPSFailure = 3; + TemporaryInhibited = 4; +} diff --git a/libraries/mogo-adas/src/main/proto/header.proto b/core/mogo-core-data/src/main/proto/header.proto similarity index 100% rename from libraries/mogo-adas/src/main/proto/header.proto rename to core/mogo-core-data/src/main/proto/header.proto diff --git a/core/mogo-core-data/src/main/proto/message_pad.proto b/core/mogo-core-data/src/main/proto/message_pad.proto new file mode 100644 index 0000000000..163047566e --- /dev/null +++ b/core/mogo-core-data/src/main/proto/message_pad.proto @@ -0,0 +1,274 @@ +syntax = "proto3"; +package mogo.telematics.pad; + +enum ProtocolVersion{ + Defaultver = 0; + CurrentVersion = 1; //每次修改proto文件增加1 +} + +enum MessageType +{ + MsgTypeDefault = 0; + + MsgTypeTrajectory = 0x10000; //局部轨迹,车前引导线 + MsgTypeTrackedObjects = 0x10001; //障碍物信息 + MsgTypeGnssInfo = 0x10002; //惯导信息 + MsgTypeVehicleState = 0x10003; //底盘信息, 透传底盘状态,pb参考底盘 + MsgTypeAutopilotState = 0x10004; //自动驾驶状态 + MsgTypeReportMessage = 0x10005; //监控事件报告 + + MsgTypeBasicInfoReq = 0x10100; //自动驾驶设备基础信息请求 + MsgTypeBasicInfoResp = 0x10101; //自动驾驶设备基础信息应答 + MsgTypeSetAutopilotModeReq = 0x10102; //设置自动驾驶模式 + MsgTypeSetDemoModeReq = 0x10103; //设置演示模式 + MsgTypeCarConfigReq = 0x10104; //车机基础信息请求 + MsgTypeCarConfigResp = 0x10105; //车机基础信息应答 + MsgTypeRecordCause = 0x10106; //记录人工接管原因 + MsgTypeRecordData = 0x10107; //数据采集请求 + MsgTypeRecordResult = 0x10108; //数据采集结果 + MsgTypeSetAutopilotSpeedReq = 0x10109; //设置自动驾驶最大速度 + MsgTypeGlobalPathReq = 0x1010a; //自动驾驶路径请求 + MsgTypeGlobalPathResp = 0x1010b; //自动驾驶路径应答 + MsgTypeTrafficLightData = 0x1010c; //发送红绿灯数据到工控机 + MsgTypeWarn = 0x1010d; //预警数据 + MsgTypeArrivalNotification = 0x1010e; //到站提醒 +} + +message Header +{ + uint64 msgID = 1; //消息唯一id,自增 + MessageType msgType = 2; //消息类型 + double timestamp = 3; //telematics消息发送时间, 单位:秒 + double sourceTimestamp = 4; //数据源消息发送时间, 单位:秒 +} + +// message definition for MsgTypeTrajectory +message TrajectoryPoint +{ + double longitude = 1; + double latitude = 2; + double altitude = 3; + double time = 4; //时间, 单位:秒 + double velocity = 5; //速度, m/s + double acceleration = 6; //加速度, m/s^2 + double theta = 7; //速度方向 + double kappa = 8; //曲率 + double accumulatedDis = 9; //从起点到目前的总距离 + double reversedAccumulatedDis = 10; //从当前到终点的距离 +} + +message Trajectory +{ + repeated TrajectoryPoint points = 1; +} + +// message definition for MsgTypeTrackedObjects +message TrackedObject +{ + uint32 type = 1; //物体类型, 0:Background, 1:Person, 2:Bicycle, 3:Car, 4:MotorCycle, + //5:TrafficSign, 6:Bus, 7:CellPhone, 8:Truck, 9:Bottle, 10:TrafficLight, + //11:Rider, 12:TriangleRoadblock, 13:WarningTriangle, 100:Unknown + double longitude = 2; //经度 + double latitude = 3; //纬度 + double altitude = 4; //海拔 + double systemTime = 5; //系统时间 单位:秒s + double satelliteTime = 6; //gps时间 单位:秒s + uint32 uuid = 7; //车辆id + string carID = 8; //车牌id + string color = 9; //车辆颜色 + double heading = 10; //车辆朝向 + double speed = 11; //车辆速度 + uint32 drawLevel = 12; //危险等级 1 绿,2 黄,3 红 + double driverTime = 13; //驱动感知时间 +} + +message TrackedObjects +{ + repeated TrackedObject objs = 1; +} + +// message definition for MsgTypeGnssInfo +message GnssInfo +{ + double longitude = 1; //经度 + double latitude = 2; //纬度 + double altitude = 3; //海拔 + double heading = 4; //航向角 + double acceleration = 5; //加速度 + double yawRate = 6; //曲率 + double gnssSpeed = 7; //惯导车速 m/s + double vehicleSpeed = 8; //车辆车速 m/s + double satelliteTime = 9; //gps时间 单位:秒s + double systemTime = 10; //系统时间 单位:秒s +} + +// message definition for MessageType: MsgTypeVehicleState +// refer to VehicleState in vehicle_state.proto + +// message definition for MessageType: MsgTypeAutopilotState +message AutopilotState +{ + uint32 state = 1; //0: 不可用, 1:ready, 2:自动驾驶中 + uint32 camera = 2; //camera节点状态 1:开启,0:关闭 + uint32 radar = 3; //雷达节点状态 1:开启,0:关闭 + uint32 rtk = 4; //RTK节点状态 1:开启,0:关闭 + uint32 autopilotMode = 5; //自动驾驶状态 0: 非自动驾驶,1: 自动驾驶 + double speed = 6; //惯导车速 m/s + string reason = 7; //不可用原因 +} + +// message definition for MessageType: MsgTypeReportMessage +// refer to mogo_report_msg.proto + +// message definition for MessageType: MsgTypeBasicInfoReq +message BasicInfoReq +{ +} + +// message definition for MessageType: MsgTypeBasicInfoRsp +message BasicInfoResp +{ + string sn = 1; + uint32 environment = 2; //1: 研发环境, 2:测试环境, 3:生产环境 4:演示环境 +} + +// message definition for MsgTypeSetAutopilotModeReq +message Location +{ + double longitude = 1; + double latitude = 2; + double altitude = 3; + double heading = 4; +} + +message RouteInfo{ + Location startLocation = 1; + string startName = 2; + Location endLocation = 3; + string endName = 4; + repeated Location wayPoints = 5; + double speedLimit = 6; + uint32 vehicleType = 7; + bool isSpeakVoice = 8; +} + +message SetAutopilotModeReq +{ + uint32 mode = 1; //1: enter autopilot mode, 0: quit autopilot mode + uint32 source = 2; //命令来源: 0: pad模拟, 1: aicloud业务 + RouteInfo routeInfo = 3; //自动驾驶路径信息 +} + +// message definition for MsgTypeSetDemoModeReq +message SetDemoModeReq +{ + uint32 enable = 1; //1: enable, 0: disable +} + +// message definition for MsgTypeCarConfigReq +message CarConfigReq +{ +} + +// message definition for MsgTypeCarConfigResp +message CarConfigResp +{ + string dockVersion = 1; + string plateNumber = 2; + string macAddress = 3; + ProtocolVersion protocolVersion = 4; //通信协议版本 + double speedLimit = 5; //自动驾驶限速 +} + +// message definition for MsgTypeRecordCause +message RecordCause +{ + string key = 1; //bag key 唯一标识 + string filename = 2; //文件路径 + string reason = 3; //接管原因 + string reasonID = 4; //接管原因id +} + +// message definition for MsgTypeRecordData +message RecordData +{ + uint32 id = 1; //采集id + uint32 duration = 2; //采集时间长 + uint32 type = 3; //采集类型, 1:badcase, 2: map; 3: rests + bool isRecord = 4; //采集指令, true: 采集, false: 停止采集 + bool sustain = 5; //是否持续采集 +} + +// message definition for MsgTypeRecordResult +// refer to RecordPanel in record_panel.proto + +// message definition for MsgTypeSetAutopilotSpeedReq +message SetAutopilotSpeedReq +{ + double speedLimit = 1; //最大车辆速度 m/s +} + +// message definition for MsgTypeGlobalPathReq +message GlobalPathReq +{ +} + +// message definition for MsgTypeGlobalPathResp +message GlobalPathResp +{ + repeated Location wayPoints = 1; +} + +// message definition for MsgTypeTrafficLightData +message TrafficLightStatus +{ + string phaseNo = 1; //相位编号 + string color = 2; //灯态: 红灯-R,绿灯-G,绿闪-FG,黄-Y,B-黑 + int32 remain = 3; //倒计时-秒 +} + +message TrafficLightDetail +{ + TrafficLightStatus left = 1; //左灯 + TrafficLightStatus mid = 2; //中间灯 + TrafficLightStatus right = 3; //右灯 +} + +message TrafficLightData +{ + string crossID = 1; //roadID + double latitude = 2; + double longitude = 3; + string heading = 4; //红绿灯方向 + string direction = 5; //路的航向角 + int32 lightId = 6; //红绿灯ID + int32 laneNo = 7; //车道号 + int32 arrowNo = 8; //当前车道对应地面要素转向 + int32 flashYellow = 9; //黄灯总时间 + TrafficLightDetail laneDetail = 10; //灯态具体信息 +} + +// message definition for MsgTypeWarn +message Warn +{ + uint32 type = 1; //16: 小心行人, 17: 前车起步, 18: 左车道偏离, 19: 右车道偏离 + //20: 保持车距/小心前车, 23:摩托车碰撞 + //40: 禁止掉头, 41: 禁止左转, 42: 禁止右转, 43: 禁止鸣喇叭, 44: 禁止通行, 45: 限速%d + string content = 2; //words describe type + uint32 level = 3; //1:low 2:high + string value = 4; //reserved +} + +// message definition for MsgTypeArrivalNotification +message ArrivalNotification +{ + uint32 carType = 1; + Location endLocation = 2; +} + + + + + + + diff --git a/core/mogo-core-data/src/main/proto/mogo_report_msg.proto b/core/mogo-core-data/src/main/proto/mogo_report_msg.proto new file mode 100644 index 0000000000..e916a30383 --- /dev/null +++ b/core/mogo-core-data/src/main/proto/mogo_report_msg.proto @@ -0,0 +1,21 @@ +syntax = "proto2"; +package mogo_msg; + +message MogoMsgTimestamp { + required fixed32 sec = 1; + required fixed32 nsec = 2; +} + +message MogoReportMessage { + required MogoMsgTimestamp timestamp = 1; //来自消息源的时间戳,转发消息时不应修改 + required string src = 2; //消息来源 + required string level = 3; //error info + optional string msg = 4; //研发自己看的信息;对标准日志来说就是日志内容 + optional string code = 5; //error日志中的错误原因,这是一个类似宏的受约束字段,用字符串的目的是便于排查问题时查看 + + repeated string result = 6; //带来的后果;例如pad无法启动驾驶,远程驾驶无法启动等;可供监控后台做错误分类;pad无法理解code时也可参考此字段 + + repeated string actions = 16; //试验性字段。消息发出者希望触发的动作,例如:触发短信报警,自动创建工单,要求pad弹框等 +} + + diff --git a/core/mogo-core-data/src/main/proto/record_panel.proto b/core/mogo-core-data/src/main/proto/record_panel.proto new file mode 100644 index 0000000000..5d556eb7a6 --- /dev/null +++ b/core/mogo-core-data/src/main/proto/record_panel.proto @@ -0,0 +1,35 @@ +syntax = "proto2"; + +package record_cache; + +import "header.proto"; + +message RecordItem { + optional string topic = 1; //topic name of record data + optional int32 nums = 2; //quantity of this topic's data +} + +message TriggerInfo { + required bool auto_trig = 1; //trigger mode: true - auto trig when autopilot mode turn to handle | false - subscribe topic to trig + optional string trig_topic = 2; //name of topic used to trig(mode is 0 available) + optional string trig_msg = 3; //topic message(mode is 0 available) +} + +message RecordPanel { + optional common.Header header = 1; + optional int32 stat = 2; //record stat:100 - record succeed,auto stop | 101 - record succeed,handle stop | 200 - record failed + optional int64 disk_free = 3; //disk space available + optional int64 total_size = 4; //space used by bag + optional string timestamp = 5; //timestamp + optional float duration = 6; //data duration + optional TriggerInfo triggerinfo = 7; //information of trigger + optional string filename = 8; //bag's filename + repeated RecordItem records = 9; //information of each topic's record + optional string note = 10; //other message(warn,error or other message included) + optional int32 type = 11; + optional int32 id = 12; + required uint64 key = 13; + repeated string topics = 14; +} + + diff --git a/core/mogo-core-data/src/main/proto/vehicle_state.proto b/core/mogo-core-data/src/main/proto/vehicle_state.proto new file mode 100644 index 0000000000..8bce80eb61 --- /dev/null +++ b/core/mogo-core-data/src/main/proto/vehicle_state.proto @@ -0,0 +1,41 @@ +syntax = "proto2"; +package chassis; + +import "header.proto"; +import "chassis.proto"; + +message VehicleState { + optional common.Header header = 1; + optional chassis.PilotMode pilot_mode = 2 [default = MODE_MANUAL]; + optional float steering = 3 [default = 0]; // steering angle in degrees + optional float speed = 4 [default = 0]; // speed in m/s + optional float accel = 5 [default = 0]; // target acceleration in m/s^2 + optional float throttle = 6 [default = 0]; // target throttle in percentage [0, 100] + optional float brake = 7 [default = 0]; // target brake in percentage [0, 100] + + optional chassis.GearPosition gear = 8 [default = GEAR_NONE]; + optional chassis.LightSwitch light = 9 [default = LIGHT_NONE]; + + //TODO: move to chassis + optional bool horn = 10 [default = false]; //鸣笛 + optional bool highbeam = 11 [default = false]; //远光灯 + optional bool lowbeam = 12 [default = false]; //近光灯 + optional bool foglight = 13 [default = false]; //雾灯 + optional bool clearance_lamps = 14 [default = false]; //示廓灯 + optional bool warn_light = 15 [default = false]; //报警灯 + optional bool parking_brake = 16 [default = false]; + + optional chassis.LongitudeDrivingMode longitude_driving_mode = 20; + optional chassis.EPSSteeringMode eps_steering_mode = 21; + optional uint32 steering_sign = 22; + + optional bool steer_inference = 23 [default = false]; //方向盘干预 + optional bool brake_inference = 24 [default = false]; //制动踏板干预 + optional bool accel_inference = 25 [default = false]; //加速踏板干预 + optional bool gear_switch_inference = 26 [default = false]; //档位切换干预 + optional bool location_missing = 27 [default = false]; //未收到定位 + optional bool trajectory_missing = 28 [default = false]; //未收到轨迹 + optional bool chassis_status_missing = 29 [default = false]; //未收到车辆底盘反馈信息 + optional bool brake_light_status = 30 [default = false]; //自驾模式下制动灯状态 + optional bool pilot_mode_condition_met = 31 [default = false]; +} diff --git a/libraries/mogo-adas/build.gradle b/libraries/mogo-adas/build.gradle index 1ad426e62a..2347e09978 100644 --- a/libraries/mogo-adas/build.gradle +++ b/libraries/mogo-adas/build.gradle @@ -5,7 +5,7 @@ plugins { } ext { //自动驾驶产品版本号 - AP_VERSION = "2.2.1" + AP_VERSION = "2.6.0" } android { compileSdkVersion rootProject.ext.android.compileSdkVersion @@ -33,35 +33,35 @@ android { } } - 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 {} - } - } - } - } +// 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 {} +// } +// } +// } +// } } @@ -76,9 +76,9 @@ dependencies { // 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.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" 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 index 44b5f7d289..77aecf2f28 100644 --- 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 @@ -3,43 +3,30 @@ package com.zhidao.support.adas.high; import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_UDP_CONNECT_ADDRESS; import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_ADAS; import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS; -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 com.google.gson.Gson; import com.google.protobuf.InvalidProtocolBufferException; -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.DemoModeInfo; 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.AppPreferenceHelper; import com.zhidao.support.adas.high.common.Base64; import com.zhidao.support.adas.high.common.Constants; import com.zhidao.support.adas.high.common.CupidLogUtils; import com.zhidao.support.adas.high.common.Define; import com.zhidao.support.adas.high.common.IPCFixationIPHelper; -import com.zhidao.support.adas.high.common.MgContextUtils; +import com.zhidao.support.adas.high.common.MessageType; import com.zhidao.support.adas.high.common.RSATool; +import com.zhidao.support.adas.high.common.RegexUtils; 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.protocol.RawPack; 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 com.zhidao.support.adas.high.protocol.RawData; +import com.zhidao.support.adas.high.protocol.RawUnpack; import com.zhjt.service.chain.ChainLog; import com.zhjt.service.chain.TracingConstants; @@ -48,7 +35,7 @@ import org.json.JSONObject; import java.nio.charset.StandardCharsets; import java.util.HashSet; -import mogo.webproto.WebsocketHeader; +import mogo.telematics.pad.MessagePad; import okio.ByteString; /** @@ -63,15 +50,12 @@ import okio.ByteString; * @UpdateRemark: 更新说明: * @Version: 1.0 */ -public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnectListener, IConnectRtpListener, IGetH264Data, IPCFixationIPHelper.IIPCFixationIPListener { +public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnectListener, IPCFixationIPHelper.IIPCFixationIPListener { private static final String TAG = AdasChannel.class.getSimpleName(); private FpgaSocket mSocket; - private SocketReader socketReader; - /** - * udp server - */ - private CupidUdpConstract udpConstract; + private RawUnpack rawUnpack;//数据拆包 + private RawPack rawPack;//数据打包 /** * 与工控机链接状态 */ @@ -80,13 +64,10 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec /** - * 是否使用队列处理数据 + * 是否使用队列处理数据 TODO 测试了一下队列有bug */ public static final boolean isUseQueue = false; - /** - * 录包信息 - */ - private RecordDataParam recordDataParam = null; + /** * 序列化rect @@ -96,17 +77,19 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec * 消息工厂 */ private MyMessageFactory myMessageFactory; - private AutopilotSpeedParam speedParam; /** * 工控机连接配置 */ private final AdasOptions adasOptions; - private RecordCauseParam recordCauseParam; private SSH ssh; /** * 已经链接成功的工控机IP 未连接未null */ - private String ipcConnectedIP; + private String ipcConnectedIp; + /** + * 已经链接成功的工控机端口 + */ + private int ipcConnectedPort = Constants.DEFAULT_PORT; private OnMultiDeviceListener onMultiDeviceListener; /** * IPC固定IP查询工具类 @@ -140,11 +123,19 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec */ @Override public void onAvailableIP(String ip) { - getOnConnectionAddress(ip); + onConnectionAddress(ip); } - AdasChannel(Context context, AdasOptions options) { - initData(context); + /** + * 创建对象时会自动连接工控机,如果使用setListener 会出现 listener=null而调用回调的情况,所以将所使用到的接口 + * + * @param context + * @param options + * @param onAdasConnectStatusListener + */ + AdasChannel( AdasOptions options, OnAdasConnectStatusListener onAdasConnectStatusListener) { + this.adasConnectStatusListener = onAdasConnectStatusListener; + initData(); //配置为null默认是乘客屏幕 if (options == null) { this.adasOptions = new AdasOptions.Builder().setClient(true).build(); @@ -156,28 +147,15 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec } } - private void initData(Context context) { + private void initData() { //原始数据解析类 - socketReader = new SocketReader(); - MgContextUtils.setContext(context.getApplicationContext()); + rawUnpack = new RawUnpack(); + rawPack = new RawPack(); //消息工厂 myMessageFactory = new MyMessageFactory(); } - /** - * 初始化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); - } - /** * 根据固定IP查询可用IP */ @@ -205,51 +183,20 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec nodeAliasCode = CHAIN_ALIAS_CODE_UDP_CONNECT_ADDRESS, paramIndexes = {0}, clientPkFileName = "sn") - private void connectSocket(String address) { + private void connectSocket(String address, int port) { if (mSocket != null) { - mSocket.connectWebSocket(address); + mSocket.connectWebSocket(address, port); } } - /** - * 基础信息 - * - * @param basicInfo - */ - public void sendWsBasicInfo(BasicInfo basicInfo) { - if (basicInfo == null) { - return; - } - String msg = gson.toJson(basicInfo); - sendWsMessage(msg); - } - - /** - * 向工控机发送数据 - * - * @param info - */ - @Override - public void sendBaseInfo(BaseInfo info) { - if (info == null) { - return; - } - String msg = gson.toJson(info); - sendWsMessage(msg); - } private void sendIPCCmd(final String cmd) { if (ssh == null) { -// String ip = ipcIp; - if (TextUtils.isEmpty(ipcConnectedIP)) { - //尝试从缓存中获取工控机IP -// String ip = AppPreferenceHelper.getInstance(MgContextUtils.getContext()).getUdpClientAddress(); -// if (TextUtils.isEmpty(ip)) { + if (TextUtils.isEmpty(ipcConnectedIp)) { if (mAdasListener != null) { mAdasListener.onSSHResult(new SSHResult(SSHResult.RESULT_CODE.IP_UNKNOWN, cmd, "IPC IP未知")); } return; -// } } ThreadPoolManager.getsInstance().execute(new Runnable() { @Override @@ -259,7 +206,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec String privateKey = "MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEA127FFvuPolaxYTBg5wkyDIrEbcNKXoIjf0bK7QUQ991Lsbv5Ktv/XM2F6qJFssVF1KTkStVBSQGxJB1eZLwJEwIDAQABAkBM39AgpV/Z1Amz3qmVh+h+JT521ItDMjksf7yF25r0dzGjOfGLQmMAqQXT68B+cQX5HSoFMwk/rE1hnXgifyNBAiEA6uNE2TfPj51mPOZztGy1Q8p4exWohfotiy64g/CyVeMCIQDqy9e7bGeZEi6p1zemEgFVtwgZZvLn/BOP4UO7NjJnEQIhAJBnprUwha/SYb+BIpNC3fHOcWGigBfWJdfSomejO9BnAiEApfojLqKbOWHZCsbQ19yyhN02JH7aB5PyYCtlrdnKF4ECIHR1P2LOQLddXO8PwgoF6gtCTO2sxIqdvu8fUruWyouQ"; try { String pwd = RSATool.decodeByPrivateKey(encodePwd, Base64.decodeBase64(privateKey)); - ssh.connect(ipcConnectedIP, 22, "titan", pwd); + ssh.connect(ipcConnectedIp, 22, "titan", pwd); SSHResult result = ssh.exec(cmd, pwd); if (mAdasListener != null) mAdasListener.onSSHResult(result); @@ -292,18 +239,13 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec @Override - public void enableDemoMode() { - sendBaseInfo(DemoModeInfo.enable()); + public String getIpcConnectedIp() { + return ipcConnectedIp; } @Override - public void disableDemoMode() { - sendBaseInfo(DemoModeInfo.disable()); - } - - @Override - public String getIPCConnectedIP() { - return ipcConnectedIP; + public int getIpcConnectedPort() { + return ipcConnectedPort; } @@ -318,11 +260,20 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec /** - * 初始化webSocket + * 发送PB数据 + * + * @param msgType 数据类型 + * @param data 数据 + * @return */ - public void setUdpIsFirstInit() { - if (udpConstract != null) - udpConstract.setUdpIsFirstInit(); + private boolean sendWsMessage(MessagePad.MessageType msgType, byte[] data) { + if (mSocket != null && rawPack != null) { + ByteString byteString = rawPack.pack(msgType, data); + if (byteString != null) { + return mSocket.sendDataWebSocket(byteString); + } + } + return false; } /** @@ -378,18 +329,17 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec //PB解析 ByteString byteString = ByteString.of(bytes); try { - if (socketReader != null) { - OriginReadData read = socketReader.read(byteString); - if (read == null) { - //read 解析为空 默认解析view - CupidLogUtils.w("--->websocket byte read null, analysis view"); - myMessageFactory.createMessage(0x101).handlerMsg(gson, mAdasListener, bytes); - return; + if (rawUnpack != null) { + RawData raw = rawUnpack.read(byteString); + if (raw.isUnpackSucceed()) { + MessagePad.Header header = MessagePad.Header.parseFrom(raw.getHeader()); + MessagePad.MessageType messageType = header.getMsgType(); + CupidLogUtils.w("--->websocket byte read header = " + messageType.toString()); + myMessageFactory.createMessage(messageType).handlerMsg(header, raw.getPayload(), mAdasListener); + } else { + CupidLogUtils.w("数据解析失败=" + byteString.hex()); } - 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(); @@ -408,29 +358,18 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec public void connect() { //当是司机屏才启用 if (!adasOptions.isClient()) { - if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED) { + if (ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.DISCONNECTED || + ipcConnectionStatus == Constants.IPC_CONNECTION_STATUS.NOT_FOUND_ADDRESS) { ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.SEARCH_ADDRESS; if (adasConnectStatusListener != null) { adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, null); } switch (adasOptions.getIpcConnectionMode()) { case AdasOptions.IPC_CONNECTION_MODE.FIXATION: - if (mSocket != null) { - mSocket.setIsReconnect(true); - } ipcFixationIPHelper(adasOptions.getIpcFixationIP()); break; case AdasOptions.IPC_CONNECTION_MODE.ASSIGN: - if (mSocket != null) { - mSocket.setIsReconnect(true); - } - getOnConnectionAddress(adasOptions.getIpcAssignIP()); - break; - case AdasOptions.IPC_CONNECTION_MODE.UDP: - if (mSocket != null) { - mSocket.setIsReconnect(false); - } - initUdpServer(); + onConnectionAddress(adasOptions.getIpcAssignIP()); break; } } @@ -443,16 +382,15 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec */ @Override public void disconnect() { - if (ipcFixationIPHelper!=null){ + if (ipcFixationIPHelper != null) { ipcFixationIPHelper.stop(); } if (!adasOptions.isClient()) { - if (udpConstract != null) - udpConstract.release(); if (mSocket != null) mSocket.closeWebSocket(); if (isUseQueue) { - UdpQueueManager.getInstance().release(); + WebSocketQueueManager.getInstance().release(); + WSByteQueueManager.getInstance().release(); } } } @@ -479,18 +417,21 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec } @Override - public void onWebSocketConnectSuccess() { + public void onWebSocketConnectSuccess(String ipAddress, int port) { ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.CONNECTED; + ipcConnectedIp = ipAddress; + ipcConnectedPort = port; + sendCarConfigReq(); if (adasConnectStatusListener != null) { adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, null); - queryCarConfig(); } } @Override public void onWebSocketConnectFailed(String t) { ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.DISCONNECTED; - setUdpIsFirstInit(); + ipcConnectedIp = null; + ipcConnectedPort = Constants.DEFAULT_PORT; if (adasConnectStatusListener != null) { adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, t); } @@ -506,232 +447,78 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec 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) { - CupidLogUtils.e(TAG, "要连接的工控机IP=" + address); - if (TextUtils.isEmpty(address)) { - if (mSocket != null) { - mSocket.setIsReconnect(false); - } - if (adasConnectStatusListener != null) { - ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.NOT_FOUND_ADDRESS; - adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, "找不到可用的IP"); - } - return; - } - ipcConnectedIP = address; - AppPreferenceHelper.getInstance(MgContextUtils.getContext()).saveUdpClientAddress(address); - connectSocket(address); - } - - @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); + private void notFoundAddress() { + ipcConnectionStatus = Constants.IPC_CONNECTION_STATUS.NOT_FOUND_ADDRESS; + if (adasConnectStatusListener != null) { + adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus, "地址不可用或不合法"); } } /** - * 处理udp数据 + * 根据IP和端口进行连接 * - * @param content + * @param address */ - public void udpDataManage(String content) { - if (!TextUtils.isEmpty(content)) { - 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 void onConnectionAddress(String address) { + CupidLogUtils.e(TAG, "要连接的工控机地址=" + address); + + if (TextUtils.isEmpty(address)) { + notFoundAddress(); + return; } + String tempIp; + int tempPort; + if (address.contains(":")) { + String[] temp = address.split(":"); + if (temp.length < 2) { + notFoundAddress(); + return; + } + tempIp = temp[0]; + try { + tempPort = Integer.parseInt(temp[1]); + if (tempPort <= 0 || tempPort > 65535) { + notFoundAddress(); + return; + } + } catch (NumberFormatException e) { + e.printStackTrace(); + notFoundAddress(); + return; + } + + } else { + tempIp = address; + tempPort = Constants.DEFAULT_PORT; + } + if (!RegexUtils.isIP(tempIp)) { + notFoundAddress(); + return; + } + connectSocket(tempIp, tempPort); } private OnAdasListener mAdasListener; //连接状态listener - private OnAdasConnectStatusListener adasConnectStatusListener; + private final OnAdasConnectStatusListener adasConnectStatusListener; void setOnAdasListener(OnAdasListener adasListener) { mAdasListener = adasListener; } - void setOnAdasMsgConnectStatusListener(OnAdasConnectStatusListener adasMsgConnectStatusListener) { - adasConnectStatusListener = 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 int getIpcConnectionStatus() { return ipcConnectionStatus; } - @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 id, String reason) { - if (recordCauseParam == null) { - recordCauseParam = new RecordCauseParam(); - } - RecordCauseParam.Result result = new RecordCauseParam.Result(); - result.setKey(key); - result.setFilename(name); - result.setReason(reason); - result.setId(id); - 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); // } - /** - * 主动录制Bag包 - * - * @param isRecord - * @param type - * @param id - * @param duration - * @return - */ - 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); - - } /** * 接管原因 @@ -756,6 +543,213 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec CupidLogUtils.setIsWriteLog(isWriteLog); } + /** + * 向工控机发送数据 + * + * @param info + */ + @Override + public void sendBaseInfo(BaseInfo info) { + if (info == null) { + return; + } + String msg = gson.toJson(info); + sendWsMessage(msg); + } +/**************************************************************************************************************************/ + /** + * 自动驾驶设备基础信息应答 + * + * @param sn SN + * @param environment 1: 研发环境, 2:测试环境, 3:生产环境 4:演示环境 + * @return + */ + @Override + public boolean sendBasicInfoResp(String sn, int environment) { + MessagePad.BasicInfoResp resp = MessagePad.BasicInfoResp + .newBuilder() + .setSn(sn) + .setEnvironment(environment) + .build(); + return sendWsMessage(MessageType.TYPE_SEND_BASIC_INFO_RESP.typeCode, resp.toByteArray()); + } + + /** + * 设置自动驾驶模式 启动自动驾驶 + * + * @param mode 1: enter autopilot mode, 0: quit autopilot mode + * @param source 命令来源: 0: pad模拟(模拟时routeInfo传null), 1: AICloud业务 + * @param routeInfo 自动驾驶路径信息 + * @return + */ + @Override + public boolean sendAutoPilotModeReq(int mode, int source, MessagePad.RouteInfo routeInfo) { + MessagePad.SetAutopilotModeReq.Builder builder = MessagePad.SetAutopilotModeReq.newBuilder(); + builder.setMode(mode); + builder.setSource(source); + if (routeInfo != null) + builder.setRouteInfo(routeInfo); + MessagePad.SetAutopilotModeReq req = builder.build(); + return sendWsMessage(MessageType.TYPE_SEND_SET_AUTOPILOT_MODE_REQ.typeCode, req.toByteArray()); + } + + /** + * 设置演示模式 + * + * @param enable 1: enable, 0: disable + * @return + */ + @Override + public boolean sendDemoModeReq(int enable) { + MessagePad.SetDemoModeReq req = MessagePad.SetDemoModeReq + .newBuilder() + .setEnable(enable) + .build(); + return sendWsMessage(MessageType.TYPE_SEND_SET_DEMO_MODE_REQ.typeCode, req.toByteArray()); + } + + /** + * 车机基础信息请求 + * + * @return + */ + @Override + public boolean sendCarConfigReq() { + MessagePad.CarConfigReq req = MessagePad.CarConfigReq + .newBuilder() + .build(); + return sendWsMessage(MessageType.TYPE_SEND_CAR_CONFIG_REQ.typeCode, req.toByteArray()); + } + + /** + * 记录人工接管原因 + * + * @param key bag key 唯一标识 + * @param filename 文件路径 + * @param reasonID 接管原因id + * @param reason 接管原因 + * @return + */ + @Override + public boolean sendRecordCause(String key, String filename, String reasonID, String reason) { + MessagePad.RecordCause resp = MessagePad.RecordCause + .newBuilder() + .setKey(key) + .setFilename(filename) + .setReason(reason) + .setReasonID(reasonID) + .build(); + return sendWsMessage(MessageType.TYPE_SEND_RECORD_CAUSE.typeCode, resp.toByteArray()); + } + + @Override + public boolean startRecordPackage(int id, int type) { + return sendRecordData(id, 0, type, true); + } + + @Override + public boolean startRecordPackage(int id, int duration, int type) { + return sendRecordData(id, duration, type, true); + } + + @Override + public boolean stopRecordPackage(int id, int type) { + return sendRecordData(id, 0, type, false); + } + + + /** + * 数据采集请求 主动录制Bag包 + * + * @param id 采集id + * @param duration 采集时间长 + * @param type 采集类型, 1:badcase, 2: map; 3: rests + * @param isRecord 采集指令, true: 采集, false: 停止采集 + * @param sustain 是否持续采集 + * @return + */ + @Override + public boolean sendRecordData(int id, int duration, int type, boolean isRecord) { + boolean sustain = false; + if (isRecord) { + if (duration <= 0) { + duration = 0; + sustain = true; + } + } + MessagePad.RecordData req = MessagePad.RecordData + .newBuilder() + .setId(id) + .setDuration(duration) + .setType(type) + .setIsRecord(isRecord) + .setSustain(sustain) + .build(); + return sendWsMessage(MessageType.TYPE_SEND_RECORD_DATA.typeCode, req.toByteArray()); + } + + /** + * 设置自动驾驶最大速度 + * + * @param speedLimit 最大车辆速度 m/s + * @return + */ + @Override + public boolean sendAutopilotSpeedReq(double speedLimit) { + MessagePad.SetAutopilotSpeedReq req = MessagePad.SetAutopilotSpeedReq + .newBuilder() + .setSpeedLimit(speedLimit) + .build(); + return sendWsMessage(MessageType.TYPE_SEND_SET_AUTOPILOT_SPEED_REQ.typeCode, req.toByteArray()); + } + + /** + * 自动驾驶路径请求 + * + * @return + */ + @Override + public boolean sendGlobalPathReq() { + MessagePad.GlobalPathReq req = MessagePad.GlobalPathReq + .newBuilder() + .build(); + return sendWsMessage(MessageType.TYPE_SEND_GLOBAL_PATH_REQ.typeCode, req.toByteArray()); + } + + /** + * 发送红绿灯数据到工控机 + * + * @param crossID roadID + * @param latitude + * @param longitude + * @param heading 红绿灯方向 + * @param direction 路的航向角 + * @param lightId 红绿灯ID + * @param laneNo 车道号 + * @param arrowNo 当前车道对应地面要素转向 + * @param flashYellow 黄灯总时间 + * @param laneDetail 灯态具体信息 + * @return + */ + @Override + public boolean sendTrafficLightData(String crossID, double latitude, double longitude, + String heading, String direction, int lightId, int laneNo, + int arrowNo, int flashYellow, MessagePad.TrafficLightDetail laneDetail) { + MessagePad.TrafficLightData.Builder builder = MessagePad.TrafficLightData.newBuilder(); + builder.setCrossID(crossID); + builder.setLatitude(latitude); + builder.setLongitude(longitude); + builder.setHeading(heading); + builder.setDirection(direction); + builder.setLightId(lightId); + builder.setLaneNo(laneNo); + builder.setArrowNo(arrowNo); + builder.setFlashYellow(flashYellow); + if (laneDetail != null) + builder.setLaneDetail(laneDetail); + MessagePad.TrafficLightData req = builder.build(); + return sendWsMessage(MessageType.TYPE_SEND_TRAFFIC_LIGHT_DATA.typeCode, req.toByteArray()); + } } 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 index 3b1d7604ad..e147069e6d 100644 --- 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 @@ -2,14 +2,14 @@ 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.common.AppPreferenceHelper; import com.zhidao.support.adas.high.common.Constants; import java.util.HashSet; +import mogo.telematics.pad.MessagePad; + /** * @ProjectName: lib-adas-fpga * @Package: com.zhidao.lib.adas.high @@ -24,7 +24,11 @@ import java.util.HashSet; */ public class AdasManager implements IAdasNetCommApi { private static volatile AdasManager ourInstance; - + /** + * 当前协议使用的版本 + */ + private static final int PROTOCOL_VERSION = MessagePad.ProtocolVersion.CurrentVersion.getNumber(); + public static final String AP_VERSION = BuildConfig.AP_VERSION; public static AdasManager getInstance() { if (ourInstance == null) { @@ -56,20 +60,33 @@ public class AdasManager implements IAdasNetCommApi { } /** - * 获取 adas 连接状态 + * 创建一个连接 * - * @param onAdasConnectStatusListener + * @param options 连接参数 + * @param onAdasConnectStatusListener 连接状态监听 */ - public void setOnAdasConnectStatusListener(OnAdasConnectStatusListener onAdasConnectStatusListener) { - if (mChannel != null) { - mChannel.setOnAdasMsgConnectStatusListener(onAdasConnectStatusListener); + public synchronized void create(AdasOptions options, OnAdasConnectStatusListener onAdasConnectStatusListener) { + if (mChannel == null) { + mChannel = new AdasChannel(options, onAdasConnectStatusListener); } } - public synchronized void create(Context context, AdasOptions options) { - if (mChannel == null) { - mChannel = new AdasChannel(context, options); - } + /** + * MoGo-AP 版本 + * + * @return + */ + public String getAPVersion() { + return AP_VERSION; + } + + /** + * 获取协议版本 + * + * @return + */ + public int getProtocolVersion() { + return PROTOCOL_VERSION; } @@ -84,22 +101,9 @@ public class AdasManager implements IAdasNetCommApi { } } - /** - * 发送基础信息 - * - * @param basicInfo - */ - public void setBasicInfo(BasicInfo basicInfo) { - if (mChannel != null) { - mChannel.sendWsBasicInfo(basicInfo); - } - } - - public synchronized void destory() { if (mChannel != null) { - mChannel.onDisconnectRtp(); mChannel.disconnect(); mChannel = null; } @@ -120,21 +124,6 @@ public class AdasManager implements IAdasNetCommApi { } } - @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 int getIpcConnectionStatus() { @@ -144,74 +133,7 @@ public class AdasManager implements IAdasNetCommApi { return Constants.IPC_CONNECTION_STATUS.DISCONNECTED; } - @Override - public AdasConfig getAdasConfig() { - if (mChannel != null) { - return mChannel.getAdasConfig(); - } - return new AdasConfig(); - } - @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 id, String reason) { - return mChannel.recordCause(key, name, id, reason); - } - - @Override - public boolean setSpeed(int speed) { - if (mChannel != null) { - return mChannel.setSpeed(speed); - } - return false; - } // TODO 需求暂停 待讨论 获取车辆轨迹文件 // @Override // public boolean getRoutes() { @@ -236,18 +158,6 @@ public class AdasManager implements IAdasNetCommApi { } - /** - * 向工控机发送数据 - * - * @param info - */ - @Override - public void sendBaseInfo(BaseInfo info) { - if (mChannel != null) { - mChannel.sendBaseInfo(info); - } - } - @Override public void shutdownIPC() { if (mChannel != null) { @@ -278,33 +188,78 @@ public class AdasManager implements IAdasNetCommApi { @Override public AdasOptions getAdasOptions() { - if (mChannel != null) { - return mChannel.getAdasOptions(); - } - return null; + return mChannel == null ? null : mChannel.getAdasOptions(); } @Override - public void enableDemoMode() { - if (mChannel != null) { - mChannel.enableDemoMode(); - } + public String getIpcConnectedIp() { + return mChannel == null ? null : mChannel.getIpcConnectedIp(); } @Override - public void disableDemoMode() { - if (mChannel != null) { - mChannel.disableDemoMode(); - } + public int getIpcConnectedPort() { + return mChannel == null ? Constants.DEFAULT_PORT : mChannel.getIpcConnectedPort(); } @Override - public String getIPCConnectedIP() { - if (mChannel != null) { - return mChannel.getIPCConnectedIP(); - } - return null; + public boolean sendBasicInfoResp(String sn, int environment) { + return mChannel != null && mChannel.sendBasicInfoResp(sn, environment); + } + + @Override + public boolean sendAutoPilotModeReq(int mode, int source, MessagePad.RouteInfo routeInfo) { + return mChannel != null && mChannel.sendAutoPilotModeReq(mode, source, routeInfo); + } + + @Override + public boolean sendDemoModeReq(int enable) { + return mChannel != null && mChannel.sendDemoModeReq(enable); + } + + @Override + public boolean sendCarConfigReq() { + return mChannel != null && mChannel.sendCarConfigReq(); + } + + @Override + public boolean sendRecordCause(String key, String filename, String reasonID, String reason) { + return mChannel != null && mChannel.sendRecordCause(key, filename, reasonID, reason); + } + + @Override + public boolean startRecordPackage(int id, int type) { + return mChannel != null && mChannel.startRecordPackage(id, type); + } + + @Override + public boolean startRecordPackage(int id, int duration, int type) { + return mChannel != null && mChannel.startRecordPackage(id, duration, type); + } + + @Override + public boolean stopRecordPackage(int id, int type) { + return mChannel != null && mChannel.stopRecordPackage(id, type); + } + + @Override + public boolean sendRecordData(int id, int duration, int type, boolean isRecord) { + return mChannel != null && mChannel.sendRecordData(id, duration, type, isRecord); + } + + @Override + public boolean sendAutopilotSpeedReq(double speedLimit) { + return mChannel != null && mChannel.sendAutopilotSpeedReq(speedLimit); + } + + @Override + public boolean sendTrafficLightData(String crossID, double latitude, double longitude, String heading, String direction, int lightId, int laneNo, int arrowNo, int flashYellow, MessagePad.TrafficLightDetail laneDetail) { + return mChannel != null && mChannel.sendTrafficLightData(crossID, latitude, longitude, heading, direction, lightId, laneNo, arrowNo, flashYellow, laneDetail); + } + + @Override + public boolean sendGlobalPathReq() { + return mChannel != null && mChannel.sendGlobalPathReq(); } /** @@ -321,8 +276,8 @@ public class AdasManager implements IAdasNetCommApi { * * @param ipcIP */ - public void addIPCFixationIP(Context context, String ipcIP) { - AppPreferenceHelper.getInstance(context).addIPCFixationIP(ipcIP); + public boolean addIPCFixationIP(Context context, String ipcIP) { + return AppPreferenceHelper.getInstance(context).addIPCFixationIP(ipcIP); } /** @@ -330,8 +285,8 @@ public class AdasManager implements IAdasNetCommApi { * * @param ipcIP */ - public void delIPCFixationIP(Context context, String ipcIP) { - AppPreferenceHelper.getInstance(context).delIPCFixationIP(ipcIP); + public boolean delIPCFixationIP(Context context, String ipcIP) { + return AppPreferenceHelper.getInstance(context).delIPCFixationIP(ipcIP); } /** @@ -341,5 +296,15 @@ public class AdasManager implements IAdasNetCommApi { AppPreferenceHelper.getInstance(context).delIPCFixationIP(); } - + /** + * 向工控机发送数据 + * + * @param info + */ + @Override + public void sendBaseInfo(BaseInfo info) { + if (mChannel != null) { + mChannel.sendBaseInfo(info); + } + } } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java index beca852d0a..77e467446f 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/AdasOptions.java @@ -21,10 +21,6 @@ public class AdasOptions { * 指定IP */ int ASSIGN = 1; - /** - * UDP方式 - */ - int UDP = 2; } /** 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 index 201c6dfcd1..eb256bc4a8 100644 --- 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 @@ -1,7 +1,9 @@ package com.zhidao.support.adas.high; -import com.zhidao.support.adas.high.bean.AdasConfig; import com.zhidao.support.adas.high.bean.BaseInfo; +import com.zhidao.support.adas.high.common.Constants; + +import mogo.telematics.pad.MessagePad; /** * @author nie yunlong @@ -19,94 +21,157 @@ public interface IAdasNetCommApi { */ void disconnect(); - /** - * 控制自动驾驶车辆 自动模式 自动驾驶 - */ - boolean controlAutopilotCarAuto(); - - /** - * 控制自动驾驶车辆 手动模式 - */ - boolean controlAutopilotCarHead(); /** * 获取当前工控机的链接状态 * - * @return + * @return {@link Constants.IPC_CONNECTION_STATUS} */ int getIpcConnectionStatus(); /** - * 基础信息 - */ - AdasConfig getAdasConfig(); - - /** - * ai云 + * 获取工控机链接配置 * - * @param msg + * @return 工控机链接参数 */ - boolean aiCloudToAdasData(String msg); + AdasOptions getAdasOptions(); + /** - * 查询自动驾驶路径 - */ - boolean queryAutopilotRoute(); - - /** - * 查询节点监控信息 - */ - boolean queryAutopilotGuardian(); - - /** - * 数据采集 - */ - boolean recordPackage(int type, int id); - - boolean recordPackage(int type, int id, int duration); - - boolean stopRecord(int type, int id); - - /** - * 采集类型 + * 获取已经链接成功的工控机IP 未连接为null * - * @param key 工控机返回的 - * @param name 文件名称 也是工控机返回 - * @param id 接管原因id - * @param reason 接管原因 + * @return ip null:表示未连接 + */ + String getIpcConnectedIp(); + + /** + * 获取已经链接成功的工控机端口 未连接为默认端口 + * + * @return ip null:表示未连接 + */ + int getIpcConnectedPort(); + + /** + * 自动驾驶设备基础信息应答 + * + * @param sn SN + * @param environment 1: 研发环境, 2:测试环境, 3:生产环境 4:演示环境 * @return */ - boolean recordCause(String key, String name, String id, String reason); + boolean sendBasicInfoResp(String sn, int environment); /** - * 设置车速 - * speed km/h - */ - boolean setSpeed(int speed); - - /** - * 查询轨迹文件 + * 设置自动驾驶模式 启动自动驾驶 * + * @param mode 1: enter autopilot mode, 0: quit autopilot mode + * @param source 命令来源: 0: pad模拟(模拟时routeInfo传null), 1: AICloud业务 + * @param routeInfo 自动驾驶路径信息 + * @return */ -// TODO 需求暂停 待讨论 + boolean sendAutoPilotModeReq(int mode, int source, MessagePad.RouteInfo routeInfo); + + /** + * 设置演示模式 + * + * @param enable 1: enable, 0: disable + * @return + */ + boolean sendDemoModeReq(int enable); + + /** + * 车机基础信息请求 + * + * @return + */ + boolean sendCarConfigReq(); + + /** + * 记录人工接管原因 + * + * @param key bag key 唯一标识 + * @param filename 文件路径 + * @param reasonID 接管原因id + * @param reason 接管原因 + * @return + */ + boolean sendRecordCause(String key, String filename, String reasonID, String reason); + + /** + * 同下 + * + * @param id + * @param type + * @return + */ + boolean startRecordPackage(int id, int type); + + /** + * 同下 + * + * @param id + * @param type + * @return + */ + boolean startRecordPackage(int id, int duration, int type); + + /** + * 同下 + * + * @param id + * @param type + * @return + */ + boolean stopRecordPackage(int id, int type); + + /** + * 数据采集请求 主动录制Bag包 + * + * @param id 采集id + * @param duration 采集时间长 + * @param type 采集类型, 1:badcase, 2: map; 3: rests + * @param isRecord 采集指令, true: 采集, false: 停止采集 + * @param sustain 是否持续采集 + * @return + */ + boolean sendRecordData(int id, int duration, int type, boolean isRecord); + + /** + * 设置自动驾驶最大速度 + * + * @param speedLimit 最大车辆速度 m/s + * @return + */ + boolean sendAutopilotSpeedReq(double speedLimit); + + /** + * 发送红绿灯数据到工控机 + * + * @param crossID roadID + * @param latitude + * @param longitude + * @param heading 红绿灯方向 + * @param direction 路的航向角 + * @param lightId 红绿灯ID + * @param laneNo 车道号 + * @param arrowNo 当前车道对应地面要素转向 + * @param flashYellow 黄灯总时间 + * @param laneDetail 灯态具体信息 + * @return + */ + boolean sendTrafficLightData(String crossID, double latitude, double longitude, + String heading, String direction, int lightId, int laneNo, + int arrowNo, int flashYellow, MessagePad.TrafficLightDetail laneDetail); + + /** + * 自动驾驶路径请求 + * + * @return + */ + boolean sendGlobalPathReq(); + + // TODO 需求暂停 待讨论 // boolean getRoutes(); - - /** - * log是否显示 - */ - void setEnableLog(boolean isEnableLog); - - /** - * log是否写入 - */ - void setIsWriteLog(boolean isWriteLog); - - - /** - * 向工控机发送数据 - * - * @param info - */ + @Deprecated void sendBaseInfo(BaseInfo info); /** @@ -132,26 +197,13 @@ public interface IAdasNetCommApi { void parseIPCData(byte[] bytes); /** - * 获取工控机链接配置 - * - * @return + * log是否显示 */ - AdasOptions getAdasOptions(); + void setEnableLog(boolean isEnableLog); /** - * 打开演示模式 + * log是否写入 */ - void enableDemoMode(); + void setIsWriteLog(boolean isWriteLog); - /** - * 关闭演示模式 - */ - void disableDemoMode(); - - /** - * 获取已经链接成功的工控机IP 未连接未null - * - * @return ip null:表示未连接 - */ - String getIPCConnectedIP(); } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasConnectStatusListener.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasConnectStatusListener.java index 1e0df218d0..6ddb1f5157 100644 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasConnectStatusListener.java +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/OnAdasConnectStatusListener.java @@ -1,7 +1,6 @@ package com.zhidao.support.adas.high; -import android.text.TextUtils; - +import com.zhidao.support.adas.high.common.Constants; import com.zhidao.support.adas.high.common.Define; /** @@ -10,16 +9,12 @@ import com.zhidao.support.adas.high.common.Define; * @date 2020/3/20 */ public interface OnAdasConnectStatusListener { - /** - * 指定IP或固定IP(轮询ping集合中的IP) 找不到可用的IP时会被调用 - * 规则: TextUtils.isEmpty() - */ -// void onAddressDisabled(); /** * 与工控机链接状态变化 * - * @param ipcConnectionStatus + * @param ipcConnectionStatus {@link Constants.IPC_CONNECTION_STATUS} + * @param failedMsg 连接异常信息 */ void onConnectionIPCStatus(@Define.IPCConnectionStatus int ipcConnectionStatus, String failedMsg); 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 index 37529065f5..fd4b3a96ea 100644 --- 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 @@ -1,21 +1,12 @@ 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.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 com.zhidao.support.adas.high.bean.SSHResult; -import java.util.List; +import chassis.VehicleStateOuterClass; +import mogo.telematics.pad.MessagePad; +import mogo_msg.MogoReportMsg; +import record_cache.RecordPanelOuterClass; /** * @ProjectName: lib-adas-fpga @@ -30,106 +21,113 @@ import java.util.List; * @Version: 1.0 */ public interface OnAdasListener { - /** - * 报警信息 - * - * @param warnMessageInfo - */ - void onWarnMessage(WarnMessageInfo warnMessageInfo); /** - * 视频宽高 + * 自动驾驶局部轨迹 前车引导线 * - * @param width - * @param height + * @param header 头 + * @param trajectory 数据 */ - void onVideoSize(int width, int height); + void onTrajectory(MessagePad.Header header, MessagePad.Trajectory trajectory); /** - * 车框 + * 障碍物 他车数据 * - * @param rectInfo + * @param header 头 + * @param trackedObjects 数据 */ - void onRectData(RectInfo rectInfo); + void onTrackedObjects(MessagePad.Header header, MessagePad.TrackedObjects trackedObjects); /** - * 车辆状态数据 + * 惯导信息 * - * @param carStateInfo + * @param header 头 + * @param gnssInfo 数据 */ - void onCarStateData(CarStateInfo carStateInfo); + void onGnssInfo(MessagePad.Header header, MessagePad.GnssInfo gnssInfo); /** - * 红绿灯状态 + * 底盘信息, 透传底盘状态,pb参考底盘 * - * @param lightStatueInfo + * @param header 头 + * @param vehicleState 数据 */ - void onLightStateData(LightStatueInfo lightStatueInfo); - - /** - * 周边渲染 - * - * @param obstaclesInfo - */ - void onObstaclesInfo(ObstaclesInfo obstaclesInfo); - - /** - * 车道线渲染 - * - * @param carLaneInfo - */ - void onCarLaneInfo(CarLaneInfo carLaneInfo); + void onVehicleState(MessagePad.Header header, VehicleStateOuterClass.VehicleState vehicleState); /** * 自动驾驶状态 * - * @param autopilotStatus + * @param header 头 + * @param autopilotState 数据 */ - void autopilotStatus(AutopilotStatus autopilotStatus); + void onAutopilotState(MessagePad.Header header, MessagePad.AutopilotState autopilotState); /** - * 自动驾驶到站 + * 监控事件报告 * - * @param autopilotWayArrive + * @param header 头 + * @param mogoReportMessage 数据 */ - void autopilotArrive(AutopilotWayArrive autopilotWayArrive); - /** - * 接收到FPGA端发来的数据 - * - * @param msg json格式 - */ - //void onMessage(String msg); + void onReportMessage(MessagePad.Header header, MogoReportMsg.MogoReportMessage mogoReportMessage); /** - * 自动驾驶路径 + * 自动驾驶设备基础信息请求 * - * @param route + * @param header 头 + * @param basicInfoReq 数据 目前没有任何参数 */ - void onAutopilotRoute(AutopilotRoute route); + void onBasicInfoReq(MessagePad.Header header, MessagePad.BasicInfoReq basicInfoReq); /** - * 自动驾驶局部轨迹 + * 车机基础信息应答 * - * @param trajectoryList + * @param header 头 + * @param carConfigResp 数据 */ - void onAutopilotTrajectory(List trajectoryList); - - /** - * 工控机获取SN - * - * @param - */ - void onAutopilotSNRequest(); - - /** - * 工控机监控节点 - */ - void onAutopilotGuardian(AutopilotGuardianInfo guardianInfo); + void onCarConfigResp(MessagePad.Header header, MessagePad.CarConfigResp carConfigResp); /** * 数据采集结果 + * + * @param header 头 + * @param recordPanel 数据 */ - void onAutopilotRecord(AutopilotRecordResult result); + void onRecordResult(MessagePad.Header header, RecordPanelOuterClass.RecordPanel recordPanel); + + /** + * 自动驾驶路径应答 + * + * @param header 头 + * @param globalPathResp 数据 + */ + void onGlobalPathResp(MessagePad.Header header, MessagePad.GlobalPathResp globalPathResp); + + + /** + * 报警信息 + * 暂时保留,目前没有使用 + * + * @param header 头 + * @param warn 数据 + */ + @Deprecated + void onWarn(MessagePad.Header header, MessagePad.Warn warn); + + /** + * 到站提醒 自动驾驶站点 + * + * @param header 头 + * @param arrivalNotification 数据 + */ + void onArrivalNotification(MessagePad.Header header, MessagePad.ArrivalNotification arrivalNotification); + + /** + * 升级状态 + * + * @param info + */ + @Deprecated + void onUpgradeStateInfo(IPCUpgradeStateInfo info); /** * 向IPC发送命令返回结果 @@ -138,12 +136,5 @@ public interface OnAdasListener { */ void onSSHResult(SSHResult info); - /** - * 升级状态 - * - * @param info - */ - void onUpgradeStateInfo(IPCUpgradeStateInfo info); - } 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 deleted file mode 100644 index 7184cd7732..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AdasConfig.java +++ /dev/null @@ -1,49 +0,0 @@ -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 deleted file mode 100644 index e8a2e76925..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotConfig.java +++ /dev/null @@ -1,46 +0,0 @@ -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 deleted file mode 100644 index f7e6ec1136..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotControl.java +++ /dev/null @@ -1,53 +0,0 @@ -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 deleted file mode 100644 index 1de9990c8b..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotRoute.java +++ /dev/null @@ -1,75 +0,0 @@ -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 deleted file mode 100644 index 1ad4199bd5..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSnRequest.java +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index ec4e8c0c16..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotSpeedParam.java +++ /dev/null @@ -1,39 +0,0 @@ -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 deleted file mode 100644 index 6339c25f09..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotStatus.java +++ /dev/null @@ -1,139 +0,0 @@ -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 deleted file mode 100644 index 079db7b0bc..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotTrajectory.java +++ /dev/null @@ -1,34 +0,0 @@ -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 deleted file mode 100644 index a81c22ddf5..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/AutopilotWayArrive.java +++ /dev/null @@ -1,115 +0,0 @@ -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 index 4e660e1f69..6422a108c0 100644 --- 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 @@ -1,5 +1,6 @@ package com.zhidao.support.adas.high.bean; +@Deprecated public abstract class BaseInfo { protected String action; protected T 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 deleted file mode 100644 index f9d08ced0c..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/BasicInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -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 deleted file mode 100644 index 0a4aa775db..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarLaneInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -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 deleted file mode 100644 index 928a17aa3a..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/CarStateInfo.java +++ /dev/null @@ -1,279 +0,0 @@ -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 long 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;//统计发包个数 - /** - * 常开 常关 转向灯 - * 0 --关 - * 1 --左转 - * 2 --右转 - */ - private int turnLightOften = 0; - - - public int getFrame_num() { - return frame_num; - } - - public void setFrame_num(int frame_num) { - this.frame_num = frame_num; - } - - public int getTurnLightOften() { - return turnLightOften; - } - - public void setTurnLightOften(int turnLightOften) { - this.turnLightOften = turnLightOften; - } - - public long getTimeDiff() { - return timeDiff; - } - - public void setTimeDiff(long timeDiff) { - this.timeDiff = timeDiff; - } - - public long getReceiverDataTime() { - return receiverDataTime; - } - - public void setReceiverDataTime(long 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 + '\'' + - ", adasSatelliteTime='" + adasSatelliteTime + '\'' + - ", startReceiverDataTime='" + startReceiverDataTime + '\'' + - ", timeDiff=" + timeDiff + - ", turn_light=" + turn_light + - ", flash_light=" + flash_light + - ", brake_light=" + brake_light + - ", frame_num=" + frame_num + - ", turnLightOften=" + turnLightOften + - '}'; - } - } - - @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/DemoModeInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/DemoModeInfo.java deleted file mode 100644 index 04deffb0ee..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/DemoModeInfo.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.zhidao.support.adas.high.bean; - -/** - * 演示模式 - */ -public class DemoModeInfo extends BaseInfo { - public DemoModeInfo(String action) { - super(action); - } - - /** - * 开启演示模式 - * - * @return - */ - public static DemoModeInfo enable() { - return new DemoModeInfo("enable_demo_pilot"); - } - - /** - * 关闭演示模式 - * - * @return - */ - public static DemoModeInfo disable() { - return new DemoModeInfo("disable_demo_pilot"); - } - - -} 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 index 8772a2f105..dbf1e9e04a 100644 --- 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 @@ -3,6 +3,7 @@ package com.zhidao.support.adas.high.bean; /** * 工控机升级 */ +@Deprecated public class IPCUpgradeInfo extends BaseInfo { public IPCUpgradeInfo() { super("ipc_upgrade"); 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 index 4e82b55e0f..7d7b3c96e6 100644 --- 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 @@ -5,6 +5,7 @@ import com.google.gson.annotations.SerializedName; /** * 工控机升级 */ +@Deprecated public class IPCUpgradeStateInfo extends BaseInfo { /** * 升级模式 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 deleted file mode 100644 index 4d8df164d3..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/LightStatueInfo.java +++ /dev/null @@ -1,143 +0,0 @@ -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/ObstaclesInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ObstaclesInfo.java deleted file mode 100644 index 2af375c32b..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/ObstaclesInfo.java +++ /dev/null @@ -1,82 +0,0 @@ -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 deleted file mode 100644 index ab710e82a6..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RectInfo.java +++ /dev/null @@ -1,344 +0,0 @@ -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 deleted file mode 100644 index 4208c9d617..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RemoteControlAutoPilotParameters.java +++ /dev/null @@ -1,139 +0,0 @@ -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 deleted file mode 100644 index 5229eca2f5..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/RouteInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -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/TrajectoryInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/TrajectoryInfo.java deleted file mode 100644 index 027a1e2cb0..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/TrajectoryInfo.java +++ /dev/null @@ -1,125 +0,0 @@ -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/WarnMessageInfo.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/WarnMessageInfo.java deleted file mode 100644 index d79071f189..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/WarnMessageInfo.java +++ /dev/null @@ -1,80 +0,0 @@ -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 deleted file mode 100644 index 88a05c38dd..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/AutopilotGuardianInfo.java +++ /dev/null @@ -1,113 +0,0 @@ -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 deleted file mode 100644 index 4b2a04b761..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItem.java +++ /dev/null @@ -1,39 +0,0 @@ -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 deleted file mode 100644 index 1dfe098a6e..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianItemsName.java +++ /dev/null @@ -1,41 +0,0 @@ -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 deleted file mode 100644 index 4815e7b367..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianModule.java +++ /dev/null @@ -1,41 +0,0 @@ -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 deleted file mode 100644 index 79e4648acc..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/guardian/GuardianSubmodule.java +++ /dev/null @@ -1,84 +0,0 @@ -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 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 deleted file mode 100644 index 4091d0ceb3..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotIdentifyInfo.java +++ /dev/null @@ -1,75 +0,0 @@ -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 deleted file mode 100644 index 144b480fb5..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/AutopilotRecordResult.java +++ /dev/null @@ -1,171 +0,0 @@ -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 Long 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 Long 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 Long 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 Long 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 deleted file mode 100644 index 9190a5fa01..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordCauseParam.java +++ /dev/null @@ -1,75 +0,0 @@ -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; - //接管原因id - private String id; - - 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; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - } - - @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 deleted file mode 100644 index f3ff1966a9..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/bean/record/RecordDataParam.java +++ /dev/null @@ -1,113 +0,0 @@ -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 deleted file mode 100644 index edf9426be7..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/ActionTypeReceive.java +++ /dev/null @@ -1,144 +0,0 @@ -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 红绿灯状态"), - /** - * 自动驾驶状态 - */ - 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, "监控车辆节点"), - /** - * BadCase数据采集 - */ - ACTION_WS_AUTOPILOT_IDENTIFY("identify", -1, "BadCase数据采集"), - /** - * 局部轨迹 车前引导钱 - */ - 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_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 index 7fc5c55a14..209d58a5a6 100644 --- 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 @@ -19,17 +19,13 @@ public class AppPreferenceHelper implements IPreferencesHelper { /** * 保存deviceId 文件名称 */ - private final String UDP_RECEIVER_ADDRESS_FILE_NAME = "upd_receive"; + private final static String SP_NAME = "adas_config"; /** * 手机Id */ - private SharedPreferences mDevicePre; + private SharedPreferences ipcPre; - /** - * 默认data - */ - private String defaultData = "{\"configInfoHistory\":[{\"kCode\":\"d_fcw_touch\",\"kName\":\"前车碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_fcw_start\",\"kName\":\"前车启动提醒\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hdw_driver\",\"kName\":\"驾驶员疲劳/危险预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_fcw_person\",\"kName\":\"行人碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hdw_sliding\",\"kName\":\"溜车碰撞预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_ldw_out\",\"kName\":\"车道线偏离预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_hmw_follow\",\"kName\":\"跟车距离预警\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0},{\"kCode\":\"d_volume_size\",\"kName\":\"音量大小\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"60\",\"userId\":0},{\"kCode\":\"is_use_ar_navBar\",\"kName\":\"是否使用AR导航\",\"kOrder\":1,\"kType\":\"aided_driving_dic\",\"kVal\":\"5\",\"userId\":0}]}"; private HashSet ipcFixationIPSet;//工控机固定IP列表 @@ -41,35 +37,16 @@ public class AppPreferenceHelper implements IPreferencesHelper { } private AppPreferenceHelper(Context context) { - mDevicePre = context.getSharedPreferences(UDP_RECEIVER_ADDRESS_FILE_NAME, Context.MODE_PRIVATE); + ipcPre = context.getSharedPreferences(SP_NAME, Context.MODE_PRIVATE); getIPCFixationIPList(); } - @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 HashSet getIPCFixationIPList() { if (ipcFixationIPSet == null || ipcFixationIPSet.isEmpty()) { - String json = mDevicePre.getString("ipc_fixation_ip", Constants.DEFAULT_IPC_FIXATION_IP); + String json = ipcPre.getString("ipc_fixation_ip", Constants.DEFAULT_IPC_FIXATION_IP); ipcFixationIPSet = JsonUtil.fromJson(json, new TypeToken>() { }.getType()); @@ -78,25 +55,29 @@ public class AppPreferenceHelper implements IPreferencesHelper { } @Override - public void addIPCFixationIP(String ipcIP) { + public boolean addIPCFixationIP(String ipcIP) { if (ipcFixationIPSet == null) ipcFixationIPSet = new HashSet<>(); if (!ipcFixationIPSet.contains(ipcIP)) { ipcFixationIPSet.add(ipcIP); - mDevicePre.edit().putString("ipc_fixation_ip", JsonUtil.toJson(ipcFixationIPSet)).apply(); + ipcPre.edit().putString("ipc_fixation_ip", JsonUtil.toJson(ipcFixationIPSet)).apply(); + return true; } + return false; } @Override - public void delIPCFixationIP(String ipcIP) { + public boolean delIPCFixationIP(String ipcIP) { if (ipcFixationIPSet != null && ipcFixationIPSet.contains(ipcIP)) { ipcFixationIPSet.remove(ipcIP); - mDevicePre.edit().putString("ipc_fixation_ip", JsonUtil.toJson(ipcFixationIPSet)).apply(); + ipcPre.edit().putString("ipc_fixation_ip", JsonUtil.toJson(ipcFixationIPSet)).apply(); + return true; } + return false; } @Override public void delIPCFixationIP() { - mDevicePre.edit().remove("ipc_fixation_ip").apply(); + ipcPre.edit().remove("ipc_fixation_ip").apply(); } } 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 index 50f64645ee..e7a84a14ab 100644 --- 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 @@ -14,38 +14,21 @@ package com.zhidao.support.adas.high.common; */ public class Constants { /** - * ws 主机地址 需要从udp里面获取 + * ws 主机地址 */ public static final String WS_IP_HOST_HEAD = "ws:"; /** * ws 端口以及资源名称 */ - public static final String WS_PORT = ":4110/xvideo-detector"; - + public static final String RESOURCE_PATH = ":%d/xvideo-detector"; /** - * 发送位置信息 action + * 默认端口 */ - public static final int WS_SEND_LOCATION = 2; - + public static final int DEFAULT_PORT = 4110; /** - * 查询自动驾驶轨迹 + * 数据协议头 */ - 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}"; - + public static final byte[] RAW_MG = new byte[]{(byte) 0x6d, 0x67}; public static final String DEFAULT_IPC_FIXATION_IP = "[\"192.168.1.102\", \"192.168.8.102\"]"; 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 index 1b3c9d2217..22acc920fb 100644 --- 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 @@ -2,8 +2,6 @@ package com.zhidao.support.adas.high.common; import android.util.Log; -import com.zhidao.support.adas.high.BuildConfig; - /** * @author nie yunlong * @description video-lib @@ -70,16 +68,4 @@ public class CupidLogUtils { } 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 index fe344bee47..daf476edb1 100644 --- 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 @@ -513,4 +513,95 @@ public class DigitalTrans { return bRet; } + + /** + * 无符号 + * 1 byte + * + * @param data + * @return + */ + + + public static int get8bitUnsignedValue(byte[] data) { + int value = 0; + int index = 0; + if (data.length > index) { + value = data[index] & 0xFF; + } + return value; + } + + /** + * 无符号 + * 合并 2 byte + * + * @param data + * @return + */ + public static int get16bitUnsignedValue(byte[] data) { + int value = 0; + int index = 0; + if (data.length > index + 1) { + value = data[index++] & 0xFF; + value = value << 8; + value = value | (data[index] & 0xFF); + } + return value; + } + + /** + * 无符号 + * 合并 4 byte + * + * @param data + * @return + */ + public static long get32bitUnsignedValue(byte[] data) { + long value = 0L; + int index = 0; + if (data.length > index + 3) { + value = data[index++] & 0xFF; + value = value << 8; + value = value | (data[index++] & 0xFF); + value = value << 8; + value = value | (data[index++] & 0xFF); + value = value << 8; + value = value | (data[index] & 0xFF); + } + return value; + } + public static byte[] set8bitUnsignedValue(int num) { + return new byte[]{(byte) (num)}; + } + + public static byte[] set16bitUnsignedValue(int num) { + byte[] bytes = new byte[2]; + bytes[0] = (byte) (num >> 8); + bytes[1] = (byte) num; + return bytes; + } + + public static byte[] set32bitUnsignedValue(long num) { + byte[] bytes = new byte[4]; + bytes[0] = (byte) (num >> 24); + bytes[1] = (byte) (num >> 16); + bytes[2] = (byte) (num >> 8); + bytes[3] = (byte) num; + return bytes; + } + + public static byte[] set64bitUnsignedValue(long num) { + byte[] bytes = new byte[8]; + bytes[0] = (byte) (num >> 56); + bytes[1] = (byte) (num >> 48); + bytes[2] = (byte) (num >> 40); + bytes[3] = (byte) (num >> 32); + bytes[4] = (byte) (num >> 24); + bytes[5] = (byte) (num >> 16); + bytes[6] = (byte) (num >> 8); + bytes[7] = (byte) num; + return bytes; + } + } \ No newline at end of file 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 index bcaaa74f35..53eacdb744 100644 --- 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 @@ -8,35 +8,6 @@ import java.util.HashSet; */ 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(); - - /** @@ -51,14 +22,14 @@ public interface IPreferencesHelper { * * @param ipcIP */ - void addIPCFixationIP(String ipcIP); + boolean addIPCFixationIP(String ipcIP); /** * 删除指定的工控机固定IP * * @param ipcIP */ - void delIPCFixationIP(String ipcIP); + boolean delIPCFixationIP(String ipcIP); /** * 删除所有工控机固定IP 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 deleted file mode 100644 index 48e2df1031..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/LogSaveManage.java +++ /dev/null @@ -1,70 +0,0 @@ -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/MessageType.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java new file mode 100644 index 0000000000..1ba18b8e1c --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MessageType.java @@ -0,0 +1,62 @@ +package com.zhidao.support.adas.high.common; + +import mogo.telematics.pad.MessagePad; + +/** + * 工控机发送或接收的类型 + * + * @author nie yunlong + * @description 请求值 + * @date 2018/7/3 + */ +public enum MessageType { + + TYPE_DEFAULT("default", MessagePad.MessageType.MsgTypeDefault, "默认"), + TYPE_RECEIVE_TRAJECTORY("trajectory", MessagePad.MessageType.MsgTypeTrajectory, "局部轨迹,车前引导线"), + TYPE_RECEIVE_TRACKED_OBJECTS("tracked_objects", MessagePad.MessageType.MsgTypeTrackedObjects, "障碍物信息"), + TYPE_RECEIVE_GNSS_INFO("gnss_info", MessagePad.MessageType.MsgTypeGnssInfo, "惯导信息"), + TYPE_RECEIVE_VEHICLE_STATE("vehicle_state", MessagePad.MessageType.MsgTypeVehicleState, "底盘信息, 透传底盘状态,pb参考底盘"), + TYPE_RECEIVE_AUTOPILOT_STATE("autopilot_state", MessagePad.MessageType.MsgTypeAutopilotState, "自动驾驶状态"), + TYPE_RECEIVE_REPORT_MESSAGE("report_message", MessagePad.MessageType.MsgTypeReportMessage, "监控事件报告"), + + TYPE_RECEIVE_BASIC_INFO_REQ("basic_info_req", MessagePad.MessageType.MsgTypeBasicInfoReq, "自动驾驶设备基础信息请求"), + TYPE_SEND_BASIC_INFO_RESP("basic_info_resp", MessagePad.MessageType.MsgTypeBasicInfoResp, "自动驾驶设备基础信息应答"), + TYPE_SEND_SET_AUTOPILOT_MODE_REQ("set_autopilot_mode_req", MessagePad.MessageType.MsgTypeSetAutopilotModeReq, "设置自动驾驶模式 启动自动驾驶"), + TYPE_SEND_SET_DEMO_MODE_REQ("set_demo_mode_req", MessagePad.MessageType.MsgTypeSetDemoModeReq, "设置演示模式"), + TYPE_SEND_CAR_CONFIG_REQ("car_config_req", MessagePad.MessageType.MsgTypeCarConfigReq, "车机基础信息请求"), + TYPE_RECEIVE_CAR_CONFIG_RESP("car_config_resp", MessagePad.MessageType.MsgTypeCarConfigResp, "车机基础信息应答"), + TYPE_SEND_RECORD_CAUSE("record_cause", MessagePad.MessageType.MsgTypeRecordCause, "记录人工接管原因"), + TYPE_SEND_RECORD_DATA("record_data", MessagePad.MessageType.MsgTypeRecordData, "数据采集请求"), + TYPE_RECEIVE_RECORD_RESULT("record_result", MessagePad.MessageType.MsgTypeRecordResult, "数据采集结果"), + TYPE_SEND_SET_AUTOPILOT_SPEED_REQ("set_autopilot_speed_req", MessagePad.MessageType.MsgTypeSetAutopilotSpeedReq, "设置自动驾驶最大速度"), + TYPE_SEND_GLOBAL_PATH_REQ("global_path_req", MessagePad.MessageType.MsgTypeGlobalPathReq, "自动驾驶路径请求"), + TYPE_RECEIVE_GLOBAL_PATH_RESP("global_path_resp", MessagePad.MessageType.MsgTypeGlobalPathResp, "自动驾驶路径应答"), + TYPE_SEND_TRAFFIC_LIGHT_DATA("traffic_light_data", MessagePad.MessageType.MsgTypeTrafficLightData, "发送红绿灯数据到工控机"), + @Deprecated + TYPE_RECEIVE_WARN("warn", MessagePad.MessageType.MsgTypeWarn, "预警数据"), + TYPE_RECEIVE_ARRIVAL_NOTIFICATION("arrival_notification", MessagePad.MessageType.MsgTypeArrivalNotification, "到站提醒"), + + /** + * 工控机升级状态 + */ + @Deprecated + TYPE_RECEIVE_IPC_UPGRADE_STATUS("ipc_upgrade_status", null, "IPC升级状态"); + + public final String typeName; + /** + * 消息action code + */ + public final MessagePad.MessageType typeCode; + /** + * 描述 + */ + public final String desc; + + MessageType(String typeName, MessagePad.MessageType typeCode, String desc) { + this.typeName = typeName; + this.typeCode = typeCode; + this.desc = desc; + } + + +} 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 deleted file mode 100644 index fcc310a381..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/MgContextUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -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/RegexUtils.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/RegexUtils.java new file mode 100644 index 0000000000..7ee948d1a5 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/common/RegexUtils.java @@ -0,0 +1,40 @@ +package com.zhidao.support.adas.high.common; + + +import java.util.regex.Pattern; + + +/** + * Created by goldze on 2017/6/19. + * 正则相关工具类 + */ +public final class RegexUtils { + public static final String REGEX_IP = "((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)"; + + private RegexUtils() { + throw new UnsupportedOperationException("u can't instantiate me..."); + } + + /** + * 判断是否匹配正则 + * + * @param regex 正则表达式 + * @param input 要匹配的字符串 + * @return {@code true}: 匹配
{@code false}: 不匹配 + */ + public static boolean isMatch(final String regex, final CharSequence input) { + return input != null && input.length() > 0 && Pattern.matches(regex, input); + } + + /** + * 验证IP地址 + * + * @param input 待验证文本 + * @return {@code true}: 匹配
{@code false}: 不匹配 + */ + public static boolean isIP(final CharSequence input) { + return isMatch(REGEX_IP, input); + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ArrivalNotificationMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ArrivalNotificationMessage.java new file mode 100644 index 0000000000..fe07077a6e --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ArrivalNotificationMessage.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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; + +/** + * 到站提醒 自动驾驶站点 + */ +public class ArrivalNotificationMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.ArrivalNotification arrivalNotification = MessagePad.ArrivalNotification.parseFrom(msg); + if (adasListener != null) { + adasListener.onArrivalNotification(header, arrivalNotification); + CupidLogUtils.e("到站提醒--->" + arrivalNotification.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/AutopilotStateMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/AutopilotStateMessage.java new file mode 100644 index 0000000000..f9eb44e9e8 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/AutopilotStateMessage.java @@ -0,0 +1,30 @@ +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.common.CupidLogUtils; + +import chassis.VehicleStateOuterClass; +import mogo.telematics.pad.MessagePad; + +/** + * 自动驾驶状态 + */ +public class AutopilotStateMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.AutopilotState autopilotState = MessagePad.AutopilotState.parseFrom(msg); + if (adasListener != null) { + adasListener.onAutopilotState(header, autopilotState); + CupidLogUtils.e("自动驾驶状态--->" + autopilotState.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/BasicInfoReqMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/BasicInfoReqMessage.java new file mode 100644 index 0000000000..501b2852cc --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/BasicInfoReqMessage.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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; + +/** + * 自动驾驶设备基础信息请求 + */ +public class BasicInfoReqMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.BasicInfoReq autopilotState = MessagePad.BasicInfoReq.parseFrom(msg); + if (adasListener != null) { + adasListener.onBasicInfoReq(header, autopilotState); + CupidLogUtils.e("自动驾驶设备基础信息请求--->" + autopilotState.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/CarConfigRespMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/CarConfigRespMessage.java new file mode 100644 index 0000000000..18b19b872c --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/CarConfigRespMessage.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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; + +/** + * 车机基础信息应答 + */ +public class CarConfigRespMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.CarConfigResp carConfigResp = MessagePad.CarConfigResp.parseFrom(msg); + if (adasListener != null) { + adasListener.onCarConfigResp(header, carConfigResp); + CupidLogUtils.e("车机基础信息应答--->" + carConfigResp.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/GlobalPathRespMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/GlobalPathRespMessage.java new file mode 100644 index 0000000000..77fc871b46 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/GlobalPathRespMessage.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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; + +/** + * 自动驾驶路径应答 + */ +public class GlobalPathRespMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.GlobalPathResp globalPathResp = MessagePad.GlobalPathResp.parseFrom(msg); + if (adasListener != null) { + adasListener.onGlobalPathResp(header, globalPathResp); + CupidLogUtils.e("自动驾驶路径应答--->" + globalPathResp.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/GnssInfoMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/GnssInfoMessage.java new file mode 100644 index 0000000000..c9cb551b22 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/GnssInfoMessage.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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; + +/** + * 惯导信息 + */ +public class GnssInfoMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.GnssInfo trajectory = MessagePad.GnssInfo.parseFrom(msg); + if (adasListener != null) { + adasListener.onGnssInfo(header, trajectory); + CupidLogUtils.e("惯导信息--->" + trajectory.toString()); + } + } + + +} 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 index acdc45de7d..afe897f90c 100644 --- 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 @@ -1,8 +1,10 @@ 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.queue.UdpMsgModel; + +import mogo.telematics.pad.MessagePad; /** * @author nie yunlong @@ -17,6 +19,6 @@ public interface IMsg { */ void handlerMsg(Gson gson, OnAdasListener adasListener, String msg); - void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg); + void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException; } 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 index d85aeee531..602bdd1b1d 100644 --- 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 @@ -1,20 +1,20 @@ package com.zhidao.support.adas.high.msg; +import mogo.telematics.pad.MessagePad; + /** * 生产产品的工厂 */ public interface IMyMessageFactory { /** - * * @param messageType 消息类型 * @return */ public IMsg createMessage(String messageType); /** - * * @param messageCode 消息类型 * @return */ - public IMsg createMessage(int messageCode); + public IMsg createMessage(MessagePad.MessageType messageCode); } \ No newline at end of file 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 index 055d002223..389c1474d8 100644 --- 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 @@ -1,8 +1,8 @@ package com.zhidao.support.adas.high.msg; -import android.text.TextUtils; +import com.zhidao.support.adas.high.common.MessageType; -import com.zhidao.support.adas.high.common.ActionTypeReceive; +import mogo.telematics.pad.MessagePad; /** * @author nie yunlong @@ -10,224 +10,123 @@ import com.zhidao.support.adas.high.common.ActionTypeReceive; * @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 trajectoryMessage;//局部轨迹消息 + private IMsg trackedObjectsMessage;//障碍物信息 + private IMsg gnssInfoMessage;//惯导信息 + private IMsg vehicleStateMessage;//底盘信息, 透传底盘状态,pb参考底盘 + private IMsg autopilotStateMessage;//自动驾驶状态 + private IMsg reportMessage;//监控事件报告 - /** - * 监控信息 - */ - 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 basicInfoReqMessage;//自动驾驶设备基础信息请求 + private IMsg carConfigRespMessage;//车机基础信息应答 + private IMsg recordResultMessage;//数据采集结果 + private IMsg globalPathRespMessage;//自动驾驶路径应答 + private IMsg warnMessage;//预警数据 + private IMsg arrivalNotificationMessage;//到站提醒 + private IMsg nuImplMessage;//空实现 + private IMsg autopilotUpgradeStatusMessage;//工控机升级状态 + @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())) { + if (MessageType.TYPE_RECEIVE_IPC_UPGRADE_STATUS.typeName.equals(messageType)) { //ws 工控机升级状态 if (autopilotUpgradeStatusMessage == null) { autopilotUpgradeStatusMessage = new WsAutopilotUpgradeStatusMessage(); } return autopilotUpgradeStatusMessage; - } - - if (nuImplMessage == null) { - nuImplMessage = new NuImplMessage(); - } - return nuImplMessage; - } - - @Override - public IMsg createMessage(int messageCode) { - if (messageCode == 0) { + } else { 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())) { + } + + @Override + public IMsg createMessage(MessagePad.MessageType messageType) { + + if (messageType == MessageType.TYPE_RECEIVE_TRAJECTORY.typeCode) { //局部轨迹 if (trajectoryMessage == null) { - trajectoryMessage = new WsAutopilotTrajectoryMessage(); + trajectoryMessage = new TrajectoryMessage(); } 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(); + } else if (messageType == MessageType.TYPE_RECEIVE_TRACKED_OBJECTS.typeCode) { + //感知数据 障碍物信息 他车数据 + if (trackedObjectsMessage == null) { + trackedObjectsMessage = new TrackedObjectsMessage(); } - return guardianMessage; + return trackedObjectsMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_GNSS_INFO.typeCode) { + //惯导信息 + if (gnssInfoMessage == null) { + gnssInfoMessage = new GnssInfoMessage(); + } + return gnssInfoMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_VEHICLE_STATE.typeCode) { + //底盘信息, 透传底盘状态,pb参考底盘 + if (vehicleStateMessage == null) { + vehicleStateMessage = new VehicleStateMessage(); + } + return vehicleStateMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_AUTOPILOT_STATE.typeCode) { + //自动驾驶状态 + if (autopilotStateMessage == null) { + autopilotStateMessage = new AutopilotStateMessage(); + } + return autopilotStateMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_REPORT_MESSAGE.typeCode) { + //监控事件报告 + if (reportMessage == null) { + reportMessage = new ReportMessage(); + } + return reportMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_BASIC_INFO_REQ.typeCode) { + //自动驾驶设备基础信息请求 + if (basicInfoReqMessage == null) { + basicInfoReqMessage = new BasicInfoReqMessage(); + } + return basicInfoReqMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_CAR_CONFIG_RESP.typeCode) { + //车机基础信息应答 + if (carConfigRespMessage == null) { + carConfigRespMessage = new CarConfigRespMessage(); + } + return carConfigRespMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_RECORD_RESULT.typeCode) { + //数据采集结果 + if (recordResultMessage == null) { + recordResultMessage = new RecordResultMessage(); + } + return recordResultMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_GLOBAL_PATH_RESP.typeCode) { + //自动驾驶路径应答 + if (globalPathRespMessage == null) { + globalPathRespMessage = new GlobalPathRespMessage(); + } + return globalPathRespMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_WARN.typeCode) { + //预警数据 + if (warnMessage == null) { + warnMessage = new WarnMessage(); + } + return warnMessage; + } else if (messageType == MessageType.TYPE_RECEIVE_ARRIVAL_NOTIFICATION.typeCode) { + //到站提醒 + if (arrivalNotificationMessage == null) { + arrivalNotificationMessage = new ArrivalNotificationMessage(); + } + return arrivalNotificationMessage; + } else { + //MessageType.TYPE_DEFAULT.typeCode + if (nuImplMessage == null) { + nuImplMessage = new NuImplMessage(); + } + return nuImplMessage; } - 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 index 31e816b59c..3b884dc5d6 100644 --- 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 @@ -1,8 +1,10 @@ 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.queue.UdpMsgModel; + +import mogo.telematics.pad.MessagePad; /** * @author nie yunlong @@ -17,7 +19,9 @@ public class NuImplMessage extends MyAbstractMessageHandler { } @Override - public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) { + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { } + + } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/RecordResultMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/RecordResultMessage.java new file mode 100644 index 0000000000..45eeeeafd4 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/RecordResultMessage.java @@ -0,0 +1,30 @@ +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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; +import record_cache.RecordPanelOuterClass; + +/** + * 数据采集结果 + */ +public class RecordResultMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + RecordPanelOuterClass.RecordPanel recordPanel = RecordPanelOuterClass.RecordPanel.parseFrom(msg); + if (adasListener != null) { + adasListener.onRecordResult(header, recordPanel); + CupidLogUtils.e("数据采集结果--->" + recordPanel.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ReportMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ReportMessage.java new file mode 100644 index 0000000000..7821d756f6 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/ReportMessage.java @@ -0,0 +1,30 @@ +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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; +import mogo_msg.MogoReportMsg; + +/** + * 监控事件报告 + */ +public class ReportMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MogoReportMsg.MogoReportMessage mogoReportMessage = MogoReportMsg.MogoReportMessage.parseFrom(msg); + if (adasListener != null) { + adasListener.onReportMessage(header, mogoReportMessage); + CupidLogUtils.e("到站提醒--->" + mogoReportMessage.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/TrackedObjectsMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/TrackedObjectsMessage.java new file mode 100644 index 0000000000..681b716fbe --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/TrackedObjectsMessage.java @@ -0,0 +1,36 @@ +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.common.CupidLogUtils; + +import java.util.ArrayList; + +import mogo.telematics.pad.MessagePad; + +/** + * @author nie yunlong + * @des 障碍物信息 他车数据 + * @date 2020/3/12 + */ +public class TrackedObjectsMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.TrackedObjects trackedObjects = MessagePad.TrackedObjects.parseFrom(msg); + if (adasListener != null) { + adasListener.onTrackedObjects(header, trackedObjects); + CupidLogUtils.e("障碍物--->" + trackedObjects.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/TrajectoryMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/TrajectoryMessage.java new file mode 100644 index 0000000000..b7649d8b7f --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/TrajectoryMessage.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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; + +/** + * 自动驾驶局部轨迹 前车引导线 + */ +public class TrajectoryMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.Trajectory trajectory = MessagePad.Trajectory.parseFrom(msg); + if (adasListener != null) { + adasListener.onTrajectory(header, trajectory); + CupidLogUtils.e("自动驾驶局部轨迹 前车引导线--->" + trajectory.toString()); + } + } + + +} 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 deleted file mode 100644 index 10a8cb7efe..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpCarStateMessage.java +++ /dev/null @@ -1,100 +0,0 @@ -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.CupidLogUtils; - -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 { - long time = System.currentTimeMillis(); - 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()); - values.setReceiverDataTime(time); - carStateInfo.setValues(values); - setTurnLightState(values); - if (adasListener != null) { - adasListener.onCarStateData(carStateInfo); - CupidLogUtils.w("UdpCarStateMessage", "" + carStateInfo.toString()); - } - } - } catch (InvalidProtocolBufferException e) { - e.printStackTrace(); - } - } - - /** - * 解析转向灯 - */ - private int turnLightTimes = 0; - private boolean isOnTurnLight = false; - private int turnLight = 0; - - public void setTurnLightState(CarStateInfo.ValuesBean values) { - int turn_light = values.getTurn_light(); - if (turn_light == 0) { - if (isOnTurnLight) { - if (turnLightTimes >= 10) { - isOnTurnLight = false; - turnLight = 0; - } - turnLightTimes++; - } - } else if (turn_light == 1) { - turnLightTimes = 0; - isOnTurnLight = true; - turnLight = 1; - } else if (turn_light == 2) { - turnLightTimes = 0; - isOnTurnLight = true; - turnLight = 2; - } - values.setTurnLightOften(turnLight); - } -} 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 deleted file mode 100644 index 16cea5dc1d..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLanesMessage.java +++ /dev/null @@ -1,28 +0,0 @@ -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 deleted file mode 100644 index d77597908e..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpLightStateMessage.java +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 5bf41edbcc..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpObstaclesMessage.java +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 84be2140d4..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/UdpRenderImageMessage.java +++ /dev/null @@ -1,101 +0,0 @@ -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/VehicleStateMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java new file mode 100644 index 0000000000..5b51ecf016 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/VehicleStateMessage.java @@ -0,0 +1,30 @@ +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.common.CupidLogUtils; + +import chassis.VehicleStateOuterClass; +import mogo.telematics.pad.MessagePad; + +/** + * 底盘信息, 透传底盘状态,pb参考底盘 + */ +public class VehicleStateMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + VehicleStateOuterClass.VehicleState vehicleState = VehicleStateOuterClass.VehicleState.parseFrom(msg); + if (adasListener != null) { + adasListener.onVehicleState(header, vehicleState); + CupidLogUtils.e("惯导信息--->" + vehicleState.toString()); + } + } + + +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WarnMessage.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WarnMessage.java new file mode 100644 index 0000000000..a631d26894 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WarnMessage.java @@ -0,0 +1,30 @@ +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.common.CupidLogUtils; + +import mogo.telematics.pad.MessagePad; + +/** + * 预警数据 + */ +@Deprecated +public class WarnMessage extends MyAbstractMessageHandler { + + @Override + public void handlerMsg(Gson gson, OnAdasListener adasListener, String msg) { + } + + @Override + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { + MessagePad.Warn warn = MessagePad.Warn.parseFrom(msg); + if (adasListener != null) { + adasListener.onWarn(header, warn); + CupidLogUtils.e("自动驾驶路径应答--->" + warn.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 deleted file mode 100644 index bb45a115a6..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotArriveMessage.java +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 1046cebaf1..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotConfig.java +++ /dev/null @@ -1,34 +0,0 @@ -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 deleted file mode 100644 index 2dc502c8bc..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotGuardian.java +++ /dev/null @@ -1,51 +0,0 @@ -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 deleted file mode 100644 index 82187a79a3..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotIdentify.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.zhidao.support.adas.high.msg; - -import android.content.Intent; -import android.os.Handler; -import android.os.Message; - -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.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) { - 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 deleted file mode 100644 index fa6398c9a0..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRouteMessage.java +++ /dev/null @@ -1,26 +0,0 @@ -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 deleted file mode 100644 index c816039bb7..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotRoutesMessage.java +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 5b3058101f..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotSNMessage.java +++ /dev/null @@ -1,25 +0,0 @@ -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.AutopilotSnRequest; - -/** - * 自动驾驶路径 - */ -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 deleted file mode 100644 index 5f384202d6..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotStatusMessage.java +++ /dev/null @@ -1,28 +0,0 @@ -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 deleted file mode 100644 index f31d0ee102..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsAutopilotTrajectoryMessage.java +++ /dev/null @@ -1,58 +0,0 @@ -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 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 < pointsList.size(); i++) { - TrajectoryOuterClass.TrajectoryPoint point = pointsList.get(i); - TrajectoryInfo trajectoryInfo = new TrajectoryInfo(); - trajectoryInfo.setLon(point.getX()); - trajectoryInfo.setLat(point.getY()); - trajectoryInfo.setAlt(point.getZ()); - trajectoryInfo.setTime(point.getT()); - trajectoryInfo.setVelocity(point.getV()); - trajectoryInfo.setAcceleration(point.getA()); - trajectoryInfo.setTheta(point.getTheta()); - trajectoryInfo.setKappa(point.getKappa()); - trajectoryInfo.setAccumulatedDis(point.getS()); - trajectoryInfos.add(trajectoryInfo); - } - if (adasListener != null) { - adasListener.onAutopilotTrajectory(trajectoryInfos); - CupidLogUtils.e("WsAutopilotTrajectoryMessage--->" + trajectoryInfos.toString()); - } - } catch (InvalidProtocolBufferException e) { - e.printStackTrace(); - } - - } -} 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 index 501077e959..d4f40be30e 100644 --- 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 @@ -1,14 +1,18 @@ 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.IPCUpgradeStateInfo; import com.zhidao.support.adas.high.common.CupidLogUtils; +import mogo.telematics.pad.MessagePad; + /** - * @des 工控机升级状态 + * @des 工控机升级状态 之后版本会被替换成PB格式 * @date 2020/3/12 */ +@Deprecated public class WsAutopilotUpgradeStatusMessage extends MyAbstractMessageHandler { @Override @@ -21,7 +25,9 @@ public class WsAutopilotUpgradeStatusMessage extends MyAbstractMessageHandler { } @Override - public void handlerMsg(Gson gson, OnAdasListener adasListener, byte[] msg) { + public void handlerMsg(MessagePad.Header header, byte[] msg, OnAdasListener adasListener) throws InvalidProtocolBufferException { } + + } 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 deleted file mode 100644 index 994c4384fe..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsImageSizeMessage.java +++ /dev/null @@ -1,40 +0,0 @@ -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 deleted file mode 100644 index 373c5b9ac1..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/msg/WsWarnMessage.java +++ /dev/null @@ -1,43 +0,0 @@ -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/protocol/DefaultMessageProtocol.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/DefaultMessageProtocol.java new file mode 100644 index 0000000000..cbc4d9f041 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/DefaultMessageProtocol.java @@ -0,0 +1,81 @@ +package com.zhidao.support.adas.high.protocol; + +/** + * @author song kenan + * @des + * @date 2021/10/20 + */ +public class DefaultMessageProtocol implements IMessageProtocol { + /** + * MC 2字节 + * + * @return + */ + @Override + public int getMagicCodeLength() { + return 2; + } + + /** + * 偏移量 2字节 + * + * @return + */ + @Override + public int getOffsetLength() { + return 2; + } + + /** + * 数据包总长度 4字节 + * + * @return + */ + @Override + public int getPackageLength() { + return 4; + } + + /** + * MC+偏移量+数据包总长度 + * + * @return + */ + @Override + public int getOutHeader() { + return getMagicCodeLength() + getPackageLength() + getOffsetLength(); + } + + + /** + * Header 长度 + * + * @param offsetValue + * @return + */ + @Override + public int getHeaderLength(int offsetValue) { + if (offsetValue == 0) { + return offsetValue; + } + return offsetValue - getOutHeader(); + } + + /** + * 数据长度 + * + * @param packageLengthValue 数据包总长度 + * @param offsetValue 偏移量 + * @return + */ + @Override + public long getPayloadLength(long packageLengthValue, int offsetValue) { + if (packageLengthValue == 0) { + return 0; + } + if (offsetValue == 0) { + return 0; + } + return packageLengthValue - offsetValue; + } +} 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/protocol/IMessageProtocol.java similarity index 65% rename from libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/IMessageProtocol.java rename to libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/IMessageProtocol.java index e68846c9f9..0e81ca2ce4 100644 --- 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/protocol/IMessageProtocol.java @@ -1,6 +1,4 @@ -package com.zhidao.support.adas.high.socket.read; - -import java.nio.ByteOrder; +package com.zhidao.support.adas.high.protocol; /** * @author song kenan @@ -13,23 +11,25 @@ public interface IMessageProtocol { */ int getMagicCodeLength(); - /** - * 包长度 - */ - int getPackageLength(); - /** * 数据偏移量的长度 */ int getOffsetLength(); + /** + * 数据包长度 + */ + int getPackageLength(); + + int getOutHeader(); + /** * 获取header数据长度 */ - int getHeaderLength(byte[] offset); + int getHeaderLength(int offsetValue); /** * 消息体长度 */ - int getPayloadLength(byte[] readData,byte[] offset); + long getPayloadLength(long packageLengthValue, int offsetValue); } 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/protocol/RawData.java similarity index 58% rename from libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/OriginReadData.java rename to libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/RawData.java index b078e4e7c7..06f5189ada 100644 --- 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/protocol/RawData.java @@ -1,30 +1,45 @@ -package com.zhidao.support.adas.high.socket.read; +package com.zhidao.support.adas.high.protocol; import com.zhidao.support.adas.high.common.DigitalTrans; import java.io.Serializable; /** + * 原始数据协议 + * * @author song kenan * @des * @date 2021/10/20 + * 原始数据格式:MagicCode(2字节 6d67) 偏移量(2字节 从原始数据头开始一直到Body头) 数据包总长度(4字节) Header Body */ -public class OriginReadData implements Serializable { +public class RawData implements Serializable { + /** + * 数据拆包是否成功 + */ + private boolean isUnpackSucceed = true; + /** * 用于检查数据是否为正确数据 * mg=0x6d67 */ private byte[] magicCode; - /** - * 包长度 - */ - private byte[] packageLength; - /** * 偏移量,用于计算header长度 */ private byte[] offset; + /** + * 偏移量,用于计算header长度 + */ + private int offsetValue; + /** + * 包长度 + */ + private byte[] packageLength; + /** + * 包长度 + */ + private long packageLengthValue; /** * 头部消息,装载消息类型等 @@ -37,6 +52,8 @@ public class OriginReadData implements Serializable { */ private byte[] payload; + public RawData() { + } /** * 获取out_header 由魔数、包大小、payload偏移量组成; @@ -44,22 +61,11 @@ public class OriginReadData implements Serializable { * 固定8个字节,否则出错。 */ public byte[] getOutHeaderBytes() { - byte[] bytes = DigitalTrans.concatBytes(getMagicCode(), getPackageLength()); - byte[] outHeader = DigitalTrans.concatBytes(bytes, getOffset()); + byte[] bytes = DigitalTrans.concatBytes(getMagicCode(), getOffset()); + byte[] outHeader = DigitalTrans.concatBytes(bytes, getPackageLength()); 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; @@ -69,20 +75,23 @@ public class OriginReadData implements Serializable { 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) { + public void setOffset(byte[] offset, int offsetValue) { this.offset = offset; + this.offsetValue = offsetValue; + } + + public byte[] getPackageLength() { + return packageLength; + } + + public void setPackageLength(byte[] packageLength, long packageLengthValue) { + this.packageLength = packageLength; + this.packageLengthValue = packageLengthValue; } public byte[] getHeader() { @@ -100,4 +109,20 @@ public class OriginReadData implements Serializable { public void setPayload(byte[] payload) { this.payload = payload; } + + public boolean isUnpackSucceed() { + return isUnpackSucceed; + } + + public void setUnpackSucceed(boolean unpackSucceed) { + isUnpackSucceed = unpackSucceed; + } + + public int getOffsetValue() { + return offsetValue; + } + + public long getPackageLengthValue() { + return packageLengthValue; + } } diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/RawPack.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/RawPack.java new file mode 100644 index 0000000000..a66992829f --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/RawPack.java @@ -0,0 +1,80 @@ +package com.zhidao.support.adas.high.protocol; + +import com.zhidao.support.adas.high.common.Constants; +import com.zhidao.support.adas.high.common.DigitalTrans; + +import mogo.telematics.pad.MessagePad; +import okio.ByteString; + +/** + * 数据打包 + * + * @author song kenan + * @des + * @date 2021/10/20 + */ +public class RawPack { + private static final String TAG = RawPack.class.getSimpleName(); + private final DefaultMessageProtocol messageProtocol; + private volatile long msgID = 0L; + + public RawPack() { + messageProtocol = new DefaultMessageProtocol(); + } + + + public synchronized ByteString pack(MessagePad.MessageType msgType, byte[] data) { + if (msgType == null) { + return null; + } + msgID++; + double time = System.nanoTime() / 1000000000.0; + //封装Header + MessagePad.Header.Builder headerBuilder = MessagePad.Header.newBuilder(); + headerBuilder.setMsgID(msgID);//消息唯一ID,生成数据累加。从1开始,程序或者就一直累加,断开连接或者更换连接的工控机不做重置 + headerBuilder.setMsgType(msgType); + headerBuilder.setTimestamp(time); + headerBuilder.setSourceTimestamp(time); + MessagePad.Header headerPb = headerBuilder.build(); + int lengthValue = messageProtocol.getOutHeader() + headerPb.getSerializedSize();//数据总长度 + byte[] offset = getOffset(lengthValue); + if (data != null && data.length > 0) { + lengthValue += data.length; + } + byte[] msg = new byte[lengthValue]; + byte[] length = getPackageLength(lengthValue); + byte[] header = headerPb.toByteArray(); + //添加MG + System.arraycopy(Constants.RAW_MG, 0, msg, 0, messageProtocol.getMagicCodeLength()); + //添加偏移量 + System.arraycopy(offset, 0, msg, messageProtocol.getMagicCodeLength(), messageProtocol.getOffsetLength()); + //添加数据包长度 + System.arraycopy(length, 0, msg, messageProtocol.getMagicCodeLength() + messageProtocol.getOffsetLength(), messageProtocol.getPackageLength()); + //添加Header + System.arraycopy(header, 0, msg, messageProtocol.getOutHeader(), header.length); + //添加数据 + if (data != null && data.length > 0) { + System.arraycopy(data, 0, msg, messageProtocol.getOutHeader() + header.length, data.length); + } + return ByteString.of(msg); + + } + + /** + * 偏移量 + * + * @return + */ + private byte[] getOffset(int offsetValue) { + return DigitalTrans.set16bitUnsignedValue(offsetValue); + } + + /** + * 偏移量 + * + * @return + */ + private byte[] getPackageLength(long lengthValue) { + return DigitalTrans.set32bitUnsignedValue(lengthValue); + } +} diff --git a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/RawUnpack.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/RawUnpack.java new file mode 100644 index 0000000000..6cb735ae37 --- /dev/null +++ b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/protocol/RawUnpack.java @@ -0,0 +1,88 @@ +package com.zhidao.support.adas.high.protocol; + +import com.zhidao.support.adas.high.common.Constants; +import com.zhidao.support.adas.high.common.CupidLogUtils; +import com.zhidao.support.adas.high.common.DigitalTrans; + +import java.util.Arrays; + +import okio.ByteString; + +/** + * 数据拆包 + * + * @author song kenan + * @des + * @date 2021/10/20 + */ +public class RawUnpack { + private static final String TAG = RawUnpack.class.getSimpleName(); + private final DefaultMessageProtocol messageProtocol; + + + public RawUnpack() { + messageProtocol = new DefaultMessageProtocol(); + } + + public RawData read(ByteString bytes) { + RawData originalData = new RawData(); + unpack(bytes, originalData); + return originalData; + + } + + private synchronized void unpack(ByteString bytes, RawData raw) { + CupidLogUtils.w(TAG, "WS 原始数据=" + bytes.hex()); + //读取magicCode + ByteString magicCode = bytes.substring(0, messageProtocol.getMagicCodeLength()); + raw.setMagicCode(magicCode.toByteArray()); + CupidLogUtils.w(TAG, "WS MagicCode=" + magicCode.hex()); + if (Arrays.equals(magicCode.toByteArray(), Constants.RAW_MG)) { + //读取offset + ByteString offset = bytes.substring(messageProtocol.getMagicCodeLength(), messageProtocol.getMagicCodeLength() + messageProtocol.getOffsetLength()); + byte[] offsetB = offset.toByteArray(); + raw.setOffset(offsetB, getOffsetValue(offsetB)); + CupidLogUtils.w(TAG, "WS 偏移量 bytes=" + offset.hex() + " 偏移量=" + raw.getOffsetValue()); + //读取packageLength + ByteString packageLength = bytes.substring(messageProtocol.getMagicCodeLength() + messageProtocol.getOffsetLength(), messageProtocol.getOutHeader()); + byte[] packageLengthB = packageLength.toByteArray(); + raw.setPackageLength(packageLengthB, getPackageLengthValue(packageLengthB)); + CupidLogUtils.w(TAG, "WS 数据包从长度 bytes=" + packageLength.hex() + " 数据包从长度=" + raw.getPackageLengthValue()); + //读取header + ByteString header = bytes.substring(messageProtocol.getOutHeader(), raw.getOffsetValue()); + raw.setHeader(header.toByteArray()); + CupidLogUtils.w(TAG, "WS Header=" + header.hex()); + //读取payload + ByteString payload = bytes.substring(raw.getOffsetValue()); + raw.setPayload(payload.toByteArray()); + CupidLogUtils.w(TAG, "WS IPC数据=" + payload.hex() + " IPC数据长度=" + messageProtocol.getPayloadLength(raw.getPackageLengthValue(), raw.getOffsetValue())); + } else { + raw.setUnpackSucceed(false); + } + + } + + /** + * 偏移量 + * + * @return + */ + private int getOffsetValue(byte[] offset) { + if (offset == null || offset.length != 2) { + return 0; + } + return DigitalTrans.get16bitUnsignedValue(offset); + } + + /** + * 偏移量 + * + * @return + */ + private long getPackageLengthValue(byte[] length) { + if (length == null || length.length != 4) { + return 0; + } + return DigitalTrans.get32bitUnsignedValue(length); + } +} 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 deleted file mode 100644 index 9763e0dbb6..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpMsgModel.java +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index c4ca870879..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/queue/UdpQueueManager.java +++ /dev/null @@ -1,101 +0,0 @@ -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/socket/FpgaSocket.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/FpgaSocket.java index eba814ffca..ef456b1157 100644 --- 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 @@ -6,8 +6,8 @@ import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_WEB_ import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_ADAS; import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS; import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_LOG_WEB_SOCKET_DATA; +import static com.zhidao.support.adas.high.common.Constants.RESOURCE_PATH; import static com.zhidao.support.adas.high.common.Constants.WS_IP_HOST_HEAD; -import static com.zhidao.support.adas.high.common.Constants.WS_PORT; import android.text.TextUtils; @@ -21,6 +21,7 @@ import com.zhidao.support.adas.high.queue.WebSocketQueueManager; import com.zhjt.service.chain.ChainLog; import com.zhjt.service.chain.TracingConstants; +import java.util.Locale; import java.util.concurrent.TimeUnit; import okhttp3.OkHttpClient; @@ -55,6 +56,8 @@ public class FpgaSocket implements IWebSocket { private OkHttpClient.Builder okBuilder; private String wsHost; + private String ipAddress; + private int port; /** * 是否是用户主动关闭socket */ @@ -84,9 +87,11 @@ public class FpgaSocket implements IWebSocket { } @Override - public void connectWebSocket(String address) { + public void connectWebSocket(String address, int port) { + this.ipAddress = address; + this.port = port; isUserCloseWebSocket = false; - wsHost = WS_IP_HOST_HEAD + address + WS_PORT; + wsHost = WS_IP_HOST_HEAD + address + String.format(Locale.getDefault(), RESOURCE_PATH, port); CupidLogUtils.i(TAG, "WebSocket 主动连接= " + wsHost); init(); connect(); @@ -174,7 +179,7 @@ public class FpgaSocket implements IWebSocket { */ void onConnecting(); - void onWebSocketConnectSuccess(); + void onWebSocketConnectSuccess(String ipAddress, int port); void onWebSocketConnectFailed(String t); @@ -205,7 +210,7 @@ public class FpgaSocket implements IWebSocket { } else { CupidLogUtils.i(TAG, "WebSocket 连接成功"); if (mWebSocketConnectListener != null) - mWebSocketConnectListener.onWebSocketConnectSuccess(); + mWebSocketConnectListener.onWebSocketConnectSuccess(ipAddress, port); } } 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 index 1c28c5bb2b..04edb0d226 100644 --- 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 @@ -18,7 +18,7 @@ public interface IWebSocket { /** * 连接socket */ - void connectWebSocket(String address); + void connectWebSocket(String address, int port); /** * 关闭webSocket 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 deleted file mode 100644 index aa4d402a78..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/SocketMsgType.java +++ /dev/null @@ -1,62 +0,0 @@ -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 deleted file mode 100644 index 2095861dbc..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/DefaultMessageProtocol.java +++ /dev/null @@ -1,50 +0,0 @@ -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/SocketReader.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/SocketReader.java deleted file mode 100644 index 007a41f4d2..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/socket/read/SocketReader.java +++ /dev/null @@ -1,69 +0,0 @@ -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/udp/CupidBufStreamImpl.java b/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl.java deleted file mode 100644 index b9e0497aec..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl.java +++ /dev/null @@ -1,88 +0,0 @@ -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 deleted file mode 100644 index df33ac8ade..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidBufStreamImpl2.java +++ /dev/null @@ -1,54 +0,0 @@ -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 deleted file mode 100644 index ae386ba84a..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpConstract.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.zhidao.support.adas.high.udp; - - -import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_ALIAS_CODE_UDP_INIT; -import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_ADAS; -import static com.mogo.eagle.core.data.chain.ChainConstant.CHAIN_LINK_LOG_CONNECT_STATUS; - -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; -import com.zhjt.service.chain.ChainLog; -import com.zhjt.service.chain.TracingConstants; - -/** - * @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准备好之后再进行接收数据 - */ - @ChainLog(linkCode = CHAIN_LINK_ADAS, - linkChainLog = CHAIN_LINK_LOG_CONNECT_STATUS, - endpoint = TracingConstants.Endpoint.PAD, - nodeAliasCode = CHAIN_ALIAS_CODE_UDP_INIT, - paramIndexes = {0}, - clientPkFileName = "sn") - public void startReceiverDataThread() { - if (udpReceiverDataThread != null) { - udpReceiverDataThread.interrupt(); - 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 deleted file mode 100644 index bc4f6c1a0f..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/CupidUdpServer.java +++ /dev/null @@ -1,275 +0,0 @@ -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 deleted file mode 100644 index 07b065ab5b..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IBuffStream.java +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index ecccba0bb9..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IConnectRtpListener.java +++ /dev/null @@ -1,25 +0,0 @@ -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 deleted file mode 100644 index d32a9f0351..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IGetH264Data.java +++ /dev/null @@ -1,16 +0,0 @@ -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 deleted file mode 100644 index 88b4495452..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/IRenderImageListener.java +++ /dev/null @@ -1,81 +0,0 @@ -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 deleted file mode 100644 index 34bfaf260d..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/RTPUtils.java +++ /dev/null @@ -1,392 +0,0 @@ -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 deleted file mode 100644 index 69401db025..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/AbstractUdpImpl.java +++ /dev/null @@ -1,217 +0,0 @@ -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 deleted file mode 100644 index f35b10635c..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidRenderImageServer.java +++ /dev/null @@ -1,55 +0,0 @@ -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 deleted file mode 100644 index a5c8c22ca8..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidUdpFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index a579e76b5f..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer.java +++ /dev/null @@ -1,243 +0,0 @@ -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 deleted file mode 100644 index 9d2c434049..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/CupidVideoUdpServer2.java +++ /dev/null @@ -1,247 +0,0 @@ -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 deleted file mode 100644 index bfff270c14..0000000000 --- a/libraries/mogo-adas/src/main/java/com/zhidao/support/adas/high/udp/factory/IUdpAction.java +++ /dev/null @@ -1,88 +0,0 @@ -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 deleted file mode 100644 index f8b5478853..0000000000 --- a/libraries/mogo-adas/src/main/proto/adas.proto +++ /dev/null @@ -1,87 +0,0 @@ -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 deleted file mode 100644 index 6f4f477051..0000000000 --- a/libraries/mogo-adas/src/main/proto/car_status.proto +++ /dev/null @@ -1,42 +0,0 @@ -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 deleted file mode 100644 index 9910b32a10..0000000000 --- a/libraries/mogo-adas/src/main/proto/geometry.proto +++ /dev/null @@ -1,84 +0,0 @@ -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/mogo_guardian.proto b/libraries/mogo-adas/src/main/proto/mogo_guardian.proto deleted file mode 100644 index 27e5946a47..0000000000 --- a/libraries/mogo-adas/src/main/proto/mogo_guardian.proto +++ /dev/null @@ -1,76 +0,0 @@ -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 deleted file mode 100644 index 407ca0563c..0000000000 --- a/libraries/mogo-adas/src/main/proto/route_list.proto +++ /dev/null @@ -1,27 +0,0 @@ -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 deleted file mode 100644 index afd61c757c..0000000000 --- a/libraries/mogo-adas/src/main/proto/trajectory.proto +++ /dev/null @@ -1,18 +0,0 @@ -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 deleted file mode 100644 index 909787d1d3..0000000000 --- a/libraries/mogo-adas/src/main/proto/websocket_header.proto +++ /dev/null @@ -1,25 +0,0 @@ -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; //监控 -}