[change] 添加数据订阅、取消订阅请求
This commit is contained in:
@@ -3,7 +3,7 @@ package mogo.telematics.pad;
|
||||
|
||||
enum ProtocolVersion{
|
||||
Defaultver = 0;
|
||||
CurrentVersion = 4; //每次修改proto文件增加1
|
||||
CurrentVersion = 6; //每次修改proto文件增加1
|
||||
}
|
||||
|
||||
enum MessageType
|
||||
@@ -44,6 +44,8 @@ enum MessageType
|
||||
MsgTypeSetRainModeReq = 0x10113; //设置雨天模式
|
||||
MsgTypeRecordDataConfigReq = 0x10114; //数据采集配置查询请求
|
||||
MsgTypeRecordDataConfigResp = 0x10115; //数据采集配置查询应答
|
||||
MsgTypeOperatorCmdReq = 0x10116; //操控指令
|
||||
MsgTypeSubscribeDataReq = 0x10117; //数据订阅、取消订阅请求
|
||||
}
|
||||
|
||||
message Header
|
||||
@@ -156,6 +158,7 @@ message PlanningObjects
|
||||
// message definition for MessageType: MsgTypeOBU
|
||||
// refer to obu.proto
|
||||
|
||||
|
||||
// message definition for MsgTypeTrajectoryDownloadReq
|
||||
message Line
|
||||
{
|
||||
@@ -376,3 +379,29 @@ message RecordDataConfig
|
||||
repeated RecordDataType recordTypes = 1;
|
||||
}
|
||||
|
||||
// message definition for MsgTypeSubscribeDataReq
|
||||
message SubscribeDataReq
|
||||
{
|
||||
uint32 role = 1; //客户端角色:0: 司机屏,1: 乘客屏,2: 调试屏
|
||||
uint32 reqType = 2; //1:订阅, 2:取消订阅
|
||||
repeated uint32 dataTypes = 3; //订阅/取消订阅的消息类型列表, 透传的消息类型参考配置列表,其他消息类型见MsgType
|
||||
}
|
||||
|
||||
// message definition for MsgTypeOperatorCmdReq
|
||||
enum OperatorCmdType {
|
||||
OPERATOR_CMD_NONE = 0;
|
||||
OPERATOR_CMD_CHANGE_LANE = 1;
|
||||
OPERATOR_CMD_SET_ACCELERATED_SPEED = 2;
|
||||
OPERATOR_CMD_SET_HORN = 3;
|
||||
}
|
||||
|
||||
message OperatorCmdReq
|
||||
{
|
||||
OperatorCmdType cmdType = 1;
|
||||
double value = 2; //OPERATOR_CMD_CHANGE_LANE: 1: left 2: right
|
||||
//OPERATOR_CMD_SET_ACCELERATED_SPEED: accelerated speed
|
||||
//OPERATOR_CMD_SET_HORN: 1: honk 2: stop honking
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ package rule_segement;
|
||||
import "header.proto";
|
||||
|
||||
message MogoPointCloud
|
||||
{
|
||||
optional common.Header header = 1;
|
||||
{
|
||||
optional common.Header header = 1;
|
||||
optional double self_longitude = 2;
|
||||
optional double self_latitude = 3;
|
||||
optional double self_altitude = 4;
|
||||
@@ -13,4 +13,5 @@ message MogoPointCloud
|
||||
optional double self_pitch = 6;
|
||||
optional double self_yaw = 7;
|
||||
repeated int32 add_data = 8 [packed=true];
|
||||
optional double newgpstimestamp = 9;
|
||||
}
|
||||
@@ -36,11 +36,13 @@ import com.zhidao.support.adas.high.protocol.RawUnpack;
|
||||
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.subscribe.SubscribeInterface;
|
||||
import com.zhidao.support.adas.high.thread.DispatchHandler;
|
||||
import com.zhjt.service.chain.ChainLog;
|
||||
import com.zhjt.service.chain.TracingConstants;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@@ -60,7 +62,7 @@ import okio.ByteString;
|
||||
* @UpdateRemark: 更新说明:
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnectListener, IPCFixationIPHelper.IIPCFixationIPListener, DispatchHandler.OnDispatchHandlerListener {
|
||||
public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnectListener, IPCFixationIPHelper.IIPCFixationIPListener, DispatchHandler.OnDispatchHandlerListener, SubscribeInterface.OnSubscribeInterfaceListener {
|
||||
private static final String TAG = AdasChannel.class.getSimpleName();
|
||||
private static final String THREAD_NAME_DISPATCH_EVENT = "IPCEventDispatchHandler";//除点云单独拆分线程以外都是用此名称
|
||||
private static final String THREAD_NAME_DISPATCH_POINT_CLOUD = "IPCPointCloudDispatchHandler";
|
||||
@@ -104,6 +106,11 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
* IPC固定IP查询工具类
|
||||
*/
|
||||
private IPCFixationIPHelper ipcFixationIPHelper;
|
||||
/**
|
||||
* 工控机接口注册 连接成功后可以进行操作 乘客屏未null
|
||||
* 乘客屏无法进行注册或取消注册,因为乘客屏无法感知司机屏与工控机连接状态。无法重置已注册或未注册接口列表
|
||||
*/
|
||||
private SubscribeInterface subscribeInterface;
|
||||
|
||||
public void setOnMultiDeviceListener(OnMultiDeviceListener onMultiDeviceListener) {
|
||||
this.onMultiDeviceListener = onMultiDeviceListener;
|
||||
@@ -393,6 +400,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
sendCarConfigReq();
|
||||
ipcConnectedIp = ipAddress;
|
||||
ipcConnectedPort = port;
|
||||
subscribeInterface = new SubscribeInterface(this);
|
||||
updateConnectStatus(Constants.IPC_CONNECTION_STATUS.CONNECTED, "已连接");
|
||||
}
|
||||
|
||||
@@ -400,6 +408,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
public void onWebSocketConnectFailed(String t) {
|
||||
ipcConnectedIp = null;
|
||||
ipcConnectedPort = Constants.DEFAULT_PORT;
|
||||
subscribeInterface = null;
|
||||
updateConnectStatus(Constants.IPC_CONNECTION_STATUS.DISCONNECTED, t);
|
||||
}
|
||||
|
||||
@@ -483,9 +492,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
clientPkFileName = "sn")
|
||||
private void updateConnectStatus(@Define.IPCConnectionStatus int status, @Nullable String reason) {
|
||||
ipcConnectionStatus.set(status);
|
||||
if (adasConnectStatusListener != null) {
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus.get(), reason);
|
||||
}
|
||||
if (status == Constants.IPC_CONNECTION_STATUS.CONNECTED) {
|
||||
startDispatchHandler();
|
||||
startCheckCompatibility();
|
||||
@@ -496,6 +502,9 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
AdasManager.getInstance().setCarConfig(null);
|
||||
stopDispatchHandler();
|
||||
}
|
||||
if (adasConnectStatusListener != null) {
|
||||
adasConnectStatusListener.onConnectionIPCStatus(ipcConnectionStatus.get(), reason);
|
||||
}
|
||||
CupidLogUtils.i(TAG, "工控机连接状态 status=" + status + " reason=" + reason);
|
||||
}
|
||||
|
||||
@@ -945,5 +954,75 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
.build();
|
||||
return sendPBMessage(MessageType.TYPE_SEND_RECORD_DATA_CONFIG_REQ.typeCode, req.toByteArray());
|
||||
}
|
||||
|
||||
/**************************************注册接口相关*******************************************/
|
||||
@Override
|
||||
public boolean onSendSubscribe(byte[] bytes) {
|
||||
return sendPBMessage(MessageType.TYPE_SEND_SUBSCRIBE_DATA_REQ.typeCode, bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已注册接口
|
||||
*/
|
||||
@Override
|
||||
public Set<MessageType> getSubscribedInterface() {
|
||||
return subscribeInterface == null ? null : subscribeInterface.getSubscribedInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未注册接口
|
||||
*/
|
||||
@Override
|
||||
public Set<MessageType> getUnsubscribedInterface() {
|
||||
return subscribeInterface == null ? null : subscribeInterface.getUnsubscribedInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数查询是否已订阅
|
||||
*
|
||||
* @param messageType messageType
|
||||
* @return 是否已订阅
|
||||
*/
|
||||
@Override
|
||||
public boolean isSubscribedInterface(@NonNull MessageType messageType) {
|
||||
return subscribeInterface != null && subscribeInterface.isSubscribed(messageType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数查询是否未订阅
|
||||
*
|
||||
* @param messageType messageType
|
||||
* @return 是否未订阅
|
||||
*/
|
||||
@Override
|
||||
public boolean iUnsubscribedInterface(@NonNull MessageType messageType) {
|
||||
return subscribeInterface != null && subscribeInterface.isUnsubscribed(messageType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageTypes 要操作的接口
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull Set<MessageType> messageTypes) {
|
||||
return subscribeInterface != null && subscribeInterface.subscribeInterface(role, type, messageTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageType 要操作的接口
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType) {
|
||||
return subscribeInterface != null && subscribeInterface.subscribeInterface(role, type, messageType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,12 @@ import androidx.annotation.NonNull;
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.AppPreferenceHelper;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.Define;
|
||||
import com.zhidao.support.adas.high.common.MessageType;
|
||||
import com.zhidao.support.adas.high.common.ReceiveTimeoutManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
@@ -479,6 +482,70 @@ public class AdasManager implements IAdasNetCommApi {
|
||||
return mChannel != null && mChannel.sendRecordDataConfigReq();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已注册接口
|
||||
*/
|
||||
@Override
|
||||
public Set<MessageType> getSubscribedInterface() {
|
||||
return mChannel == null ? null : mChannel.getSubscribedInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未注册接口
|
||||
*/
|
||||
@Override
|
||||
public Set<MessageType> getUnsubscribedInterface() {
|
||||
return mChannel == null ? null : mChannel.getUnsubscribedInterface();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数查询是否已订阅
|
||||
*
|
||||
* @param messageType messageType
|
||||
* @return 是否已订阅
|
||||
*/
|
||||
@Override
|
||||
public boolean isSubscribedInterface(@NonNull MessageType messageType) {
|
||||
return mChannel != null && mChannel.isSubscribedInterface(messageType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数查询是否未订阅
|
||||
*
|
||||
* @param messageType messageType
|
||||
* @return 是否未订阅
|
||||
*/
|
||||
@Override
|
||||
public boolean iUnsubscribedInterface(@NonNull MessageType messageType) {
|
||||
return mChannel != null && mChannel.iUnsubscribedInterface(messageType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageTypes 要操作的接口
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull Set<MessageType> messageTypes) {
|
||||
return mChannel != null && mChannel.subscribeInterface(role, type, messageTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageType 要操作的接口
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType) {
|
||||
return mChannel != null && mChannel.subscribeInterface(role, type, messageType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取工控机固定IP列表
|
||||
*
|
||||
|
||||
@@ -4,6 +4,10 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.zhidao.support.adas.high.bean.VersionCompatibility;
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.Define;
|
||||
import com.zhidao.support.adas.high.common.MessageType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
@@ -69,7 +73,7 @@ public interface IAdasNetCommApi {
|
||||
* @param mode 1: enter autopilot mode, 0: quit autopilot mode
|
||||
* @param source 命令来源: 0: pad模拟(模拟时routeInfo传null), 1: AICloud业务
|
||||
* @param routeInfo 自动驾驶路径信息
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendAutoPilotModeReq(int mode, int source, MessagePad.RouteInfo routeInfo);
|
||||
|
||||
@@ -77,14 +81,14 @@ public interface IAdasNetCommApi {
|
||||
* 设置演示模式
|
||||
*
|
||||
* @param enable 1: enable, 0: disable
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendDemoModeReq(int enable);
|
||||
|
||||
/**
|
||||
* 车机基础信息请求
|
||||
*
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendCarConfigReq();
|
||||
|
||||
@@ -95,7 +99,7 @@ public interface IAdasNetCommApi {
|
||||
* @param filename 文件路径
|
||||
* @param reasonID 接管原因id
|
||||
* @param reason 接管原因
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendRecordCause(long key, @NonNull String filename, @NonNull String reasonID, @NonNull String reason);
|
||||
|
||||
@@ -104,7 +108,7 @@ public interface IAdasNetCommApi {
|
||||
*
|
||||
* @param id
|
||||
* @param type
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean startRecordPackage(int id, int type);
|
||||
|
||||
@@ -113,7 +117,7 @@ public interface IAdasNetCommApi {
|
||||
*
|
||||
* @param id
|
||||
* @param type
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean startRecordPackage(int id, int duration, int type);
|
||||
|
||||
@@ -124,7 +128,7 @@ public interface IAdasNetCommApi {
|
||||
* @param duration
|
||||
* @param type
|
||||
* @param bduration
|
||||
* @return
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean startRecordPackage(int id, int duration, int type, int bduration);
|
||||
|
||||
@@ -133,7 +137,7 @@ public interface IAdasNetCommApi {
|
||||
*
|
||||
* @param id
|
||||
* @param type
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean stopRecordPackage(int id, int type);
|
||||
|
||||
@@ -145,7 +149,7 @@ public interface IAdasNetCommApi {
|
||||
* @param type 采集类型, 1:badcase, 2: map; 3: rests
|
||||
* @param isRecord 采集指令, true: 采集, false: 停止采集
|
||||
* @param bduration 前溯时长
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendRecordData(int id, int duration, int type, boolean isRecord, int bduration);
|
||||
|
||||
@@ -153,7 +157,7 @@ public interface IAdasNetCommApi {
|
||||
* 设置自动驾驶最大速度
|
||||
*
|
||||
* @param speedLimit 最大车辆速度 m/s
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendAutopilotSpeedReq(double speedLimit);
|
||||
|
||||
@@ -171,7 +175,7 @@ public interface IAdasNetCommApi {
|
||||
* @param flashYellow 黄灯总时间
|
||||
* @param laneDetail 灯态具体信息
|
||||
* @param timestamp 当前卫星时间, 单位: ms
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendTrafficLightData(@NonNull String crossID, double latitude, double longitude,
|
||||
@NonNull String heading, @NonNull String direction, int lightId, int laneNo,
|
||||
@@ -180,7 +184,7 @@ public interface IAdasNetCommApi {
|
||||
/**
|
||||
* 自动驾驶路径请求
|
||||
*
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendGlobalPathReq();
|
||||
|
||||
@@ -190,7 +194,7 @@ public interface IAdasNetCommApi {
|
||||
* @param type SystemCmdType。SYSTEMCMD_REBOOT 重启所有节点
|
||||
* SystemCmdType。SYSTEMCMD_EMPLOY_NEW_IMAGE 使用新镜像(推镜像)
|
||||
* SystemCmdType。SYSTEMCMD_SHUT_DOWN 关机
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendSystemCmdReq(@NonNull MessagePad.SystemCmdType type);
|
||||
|
||||
@@ -198,14 +202,14 @@ public interface IAdasNetCommApi {
|
||||
* 发送 轨迹下载请求
|
||||
*
|
||||
* @param line 线路相关参数详情见PB message_pad.proto -> Line
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendTrajectoryDownloadReq(MessagePad.Line line);
|
||||
|
||||
/**
|
||||
* 发送 状态查询请求
|
||||
*
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendStatusQueryReq();
|
||||
|
||||
@@ -213,7 +217,7 @@ public interface IAdasNetCommApi {
|
||||
* 设置雨天模式
|
||||
*
|
||||
* @param enable 1: enable, 0: disable
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendRainModeReq(int enable);
|
||||
|
||||
@@ -221,10 +225,56 @@ public interface IAdasNetCommApi {
|
||||
* 数据采集配置查询
|
||||
* 0: all, 其他保留
|
||||
*
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendRecordDataConfigReq();
|
||||
|
||||
/**
|
||||
* 获取已注册接口
|
||||
*/
|
||||
Set<MessageType> getSubscribedInterface();
|
||||
|
||||
/**
|
||||
* 获取未注册接口
|
||||
*/
|
||||
Set<MessageType> getUnsubscribedInterface();
|
||||
|
||||
/**
|
||||
* 根据参数查询是否已订阅
|
||||
*
|
||||
* @param messageType messageType
|
||||
* @return 是否已订阅
|
||||
*/
|
||||
boolean isSubscribedInterface(@NonNull MessageType messageType);
|
||||
|
||||
/**
|
||||
* 根据参数查询是否未订阅
|
||||
*
|
||||
* @param messageType messageType
|
||||
* @return 是否未订阅
|
||||
*/
|
||||
boolean iUnsubscribedInterface(@NonNull MessageType messageType);
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageTypes 要操作的接口
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull Set<MessageType> messageTypes);
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageType 要操作的接口
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType);
|
||||
|
||||
// TODO 需求暂停 待讨论
|
||||
// boolean getRoutes();
|
||||
|
||||
@@ -232,7 +282,7 @@ public interface IAdasNetCommApi {
|
||||
* 向工控机发送数据
|
||||
*
|
||||
* @param bytes 数据
|
||||
* @return boolean
|
||||
* @return 加入WS发送消息队列是否成功
|
||||
*/
|
||||
boolean sendWsMessage(byte[] bytes);
|
||||
|
||||
|
||||
@@ -54,4 +54,60 @@ public class Constants {
|
||||
*/
|
||||
int NOT_FOUND_ADDRESS = 0x04;
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端角色类型
|
||||
*/
|
||||
public interface TERMINAL_ROLE {
|
||||
/**
|
||||
* 司机端
|
||||
*/
|
||||
int DRIVER = 0;
|
||||
/**
|
||||
* 乘客端
|
||||
*/
|
||||
int PASSENGER = 1;
|
||||
/**
|
||||
* 调试端
|
||||
*/
|
||||
int DEBUG = 2;
|
||||
}
|
||||
|
||||
/**
|
||||
* 环境
|
||||
*/
|
||||
public interface ENVIRONMENT {
|
||||
/**
|
||||
* 研发
|
||||
*/
|
||||
int DEVELOP = 1;
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
int TEST = 2;
|
||||
/**
|
||||
* 生产
|
||||
*/
|
||||
int PRODUCTION = 3;
|
||||
/**
|
||||
* 演示
|
||||
*/
|
||||
int DEMO = 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口订阅类型
|
||||
*/
|
||||
public interface SUBSCRIBE_TYPE {
|
||||
/**
|
||||
* 订阅
|
||||
*/
|
||||
int SUBSCRIBE = 1;
|
||||
/**
|
||||
* 取消订阅
|
||||
*/
|
||||
int UNSUBSCRIBE = 2;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,4 +25,25 @@ public final class Define {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface VersionCompatibilityDegree {
|
||||
}
|
||||
|
||||
@IntDef(flag = true, value = {Constants.TERMINAL_ROLE.DRIVER,
|
||||
Constants.TERMINAL_ROLE.PASSENGER,
|
||||
Constants.TERMINAL_ROLE.DEBUG})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TerminalRole {
|
||||
}
|
||||
|
||||
@IntDef(flag = true, value = {Constants.ENVIRONMENT.DEVELOP,
|
||||
Constants.ENVIRONMENT.TEST,
|
||||
Constants.ENVIRONMENT.PRODUCTION,
|
||||
Constants.ENVIRONMENT.DEMO})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Environment {
|
||||
}
|
||||
|
||||
@IntDef(flag = true, value = {Constants.SUBSCRIBE_TYPE.SUBSCRIBE,
|
||||
Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface SubscribeType {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* 工控机发送或接收的类型
|
||||
* 工控机接收接口必须包含TYPE_RECEIVE
|
||||
*
|
||||
* @author nie yunlong
|
||||
* @description 请求值
|
||||
@@ -45,7 +46,8 @@ public enum MessageType {
|
||||
TYPE_RECEIVE_STATUS_QUERY_RESP(MessagePad.MessageType.MsgTypeStatusQueryResp, "状态查询应答"),
|
||||
TYPE_SEND_SET_RAIN_MODE_REQ(MessagePad.MessageType.MsgTypeSetRainModeReq, "设置雨天模式"),
|
||||
TYPE_SEND_RECORD_DATA_CONFIG_REQ(MessagePad.MessageType.MsgTypeRecordDataConfigReq, "数据采集配置查询"),
|
||||
TYPE_RECEIVE_RECORD_DATA_CONFIG_RESP(MessagePad.MessageType.MsgTypeRecordDataConfigResp, "数据采集配置");
|
||||
TYPE_RECEIVE_RECORD_DATA_CONFIG_RESP(MessagePad.MessageType.MsgTypeRecordDataConfigResp, "数据采集配置"),
|
||||
TYPE_SEND_SUBSCRIBE_DATA_REQ(MessagePad.MessageType.MsgTypeSubscribeDataReq, "数据订阅、取消订阅请求");
|
||||
|
||||
/**
|
||||
* 消息action code
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
package com.zhidao.support.adas.high.subscribe;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.zhidao.support.adas.high.common.Constants;
|
||||
import com.zhidao.support.adas.high.common.Define;
|
||||
import com.zhidao.support.adas.high.common.MessageType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* 工控机注册接口
|
||||
* Taxi(红旗、东风) MAP260上线
|
||||
* Bus 预计MAP260上线
|
||||
*/
|
||||
public class SubscribeInterface {
|
||||
|
||||
/**
|
||||
* 已注册接口
|
||||
*/
|
||||
private final Map<MessageType, Integer> subscribedInterface = new HashMap<>();
|
||||
/**
|
||||
* 未注册接口
|
||||
*/
|
||||
private final Map<MessageType, Integer> unsubscribedInterface = new HashMap<>();
|
||||
|
||||
private final OnSubscribeInterfaceListener listener;
|
||||
|
||||
public interface OnSubscribeInterfaceListener {
|
||||
boolean onSendSubscribe(byte[] bytes);
|
||||
}
|
||||
|
||||
public SubscribeInterface(@NonNull OnSubscribeInterfaceListener listener) {
|
||||
this.listener = listener;
|
||||
if (listener == null) throw new RuntimeException();
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取已注册接口
|
||||
*/
|
||||
public Set<MessageType> getSubscribedInterface() {
|
||||
return subscribedInterface.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未注册接口
|
||||
*/
|
||||
public Set<MessageType> getUnsubscribedInterface() {
|
||||
return unsubscribedInterface.keySet();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageTypes 要操作的接口
|
||||
* @return
|
||||
*/
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull Set<MessageType> messageTypes) {
|
||||
if (messageTypes == null) return false;
|
||||
MessagePad.SubscribeDataReq.Builder builder = MessagePad.SubscribeDataReq.newBuilder();
|
||||
builder.setRole(role).setReqType(type);
|
||||
Map<MessageType, Integer> temp = new HashMap<>();
|
||||
for (MessageType messageType : messageTypes) {
|
||||
temp.put(messageType, messageType.typeCode.getNumber());
|
||||
}
|
||||
builder.addAllDataTypes(temp.values());
|
||||
boolean isSendSucceed = listener.onSendSubscribe(builder.build().toByteArray());
|
||||
if (isSendSucceed) {
|
||||
for (MessageType messageType : messageTypes) {
|
||||
if (type == Constants.SUBSCRIBE_TYPE.SUBSCRIBE) {
|
||||
if (!subscribedInterface.containsKey(messageType)) {
|
||||
subscribedInterface.put(messageType, messageType.typeCode.getNumber());
|
||||
}
|
||||
unsubscribedInterface.remove(messageType);
|
||||
} else if (type == Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE) {
|
||||
if (!unsubscribedInterface.containsKey(messageType)) {
|
||||
unsubscribedInterface.put(messageType, messageType.typeCode.getNumber());
|
||||
}
|
||||
subscribedInterface.remove(messageType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册或取消注册
|
||||
*
|
||||
* @param role 角色 详情参见{@link Constants.TERMINAL_ROLE}
|
||||
* @param type 注册类型 详情参见{@link Constants.SUBSCRIBE_TYPE}
|
||||
* @param messageType 要操作的接口
|
||||
* @return 是否加入ws发送队列
|
||||
*/
|
||||
public boolean subscribeInterface(@Define.TerminalRole int role, @Define.SubscribeType int type, @NonNull MessageType messageType) {
|
||||
if (messageType == null) return false;
|
||||
MessagePad.SubscribeDataReq.Builder builder = MessagePad.SubscribeDataReq.newBuilder();
|
||||
builder.setRole(role).setReqType(type).addDataTypes(messageType.typeCode.getNumber());
|
||||
boolean isSendSucceed = listener.onSendSubscribe(builder.build().toByteArray());
|
||||
if (isSendSucceed) {
|
||||
if (type == Constants.SUBSCRIBE_TYPE.SUBSCRIBE) {
|
||||
if (!subscribedInterface.containsKey(messageType)) {
|
||||
subscribedInterface.put(messageType, messageType.typeCode.getNumber());
|
||||
}
|
||||
unsubscribedInterface.remove(messageType);
|
||||
} else if (type == Constants.SUBSCRIBE_TYPE.UNSUBSCRIBE) {
|
||||
if (!unsubscribedInterface.containsKey(messageType)) {
|
||||
unsubscribedInterface.put(messageType, messageType.typeCode.getNumber());
|
||||
}
|
||||
subscribedInterface.remove(messageType);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//根据参数查询是否已订阅
|
||||
public boolean isSubscribed(@NonNull MessageType messageType) {
|
||||
return subscribedInterface.containsKey(messageType);
|
||||
}
|
||||
|
||||
//根据参数查询是否未订阅
|
||||
public boolean isUnsubscribed(@NonNull MessageType messageType) {
|
||||
return unsubscribedInterface.containsKey(messageType);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
//默认RECEIVE的全部注册
|
||||
MessageType[] types = MessageType.values();
|
||||
if (types.length > 0) {
|
||||
for (MessageType messageType : types) {
|
||||
if (messageType.name().toLowerCase().contains("type_receive")) {
|
||||
subscribedInterface.put(messageType, messageType.typeCode.getNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_TRAJECTORY, MessageType.TYPE_RECEIVE_TRAJECTORY.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_TRACKED_OBJECTS, MessageType.TYPE_RECEIVE_TRACKED_OBJECTS.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_GNSS_INFO, MessageType.TYPE_RECEIVE_GNSS_INFO.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_VEHICLE_STATE, MessageType.TYPE_RECEIVE_VEHICLE_STATE.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_AUTOPILOT_STATE, MessageType.TYPE_RECEIVE_AUTOPILOT_STATE.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_REPORT_MESSAGE, MessageType.TYPE_RECEIVE_REPORT_MESSAGE.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_PERCEPTION_TRAFFIC_LIGHT, MessageType.TYPE_RECEIVE_PERCEPTION_TRAFFIC_LIGHT.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_PREDICTION_OBSTACLE_TRAJECTORY, MessageType.TYPE_RECEIVE_PREDICTION_OBSTACLE_TRAJECTORY.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_POINT_CLOUD, MessageType.TYPE_RECEIVE_POINT_CLOUD.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_PLANNING_OBJECTS, MessageType.TYPE_RECEIVE_PLANNING_OBJECTS.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_BASIC_INFO_REQ, MessageType.TYPE_RECEIVE_BASIC_INFO_REQ.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_CAR_CONFIG_RESP, MessageType.TYPE_RECEIVE_CAR_CONFIG_RESP.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_RECORD_RESULT, MessageType.TYPE_RECEIVE_RECORD_RESULT.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_GLOBAL_PATH_RESP, MessageType.TYPE_RECEIVE_GLOBAL_PATH_RESP.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_WARN, MessageType.TYPE_RECEIVE_WARN.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_ARRIVAL_NOTIFICATION, MessageType.TYPE_RECEIVE_ARRIVAL_NOTIFICATION.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_STATUS_QUERY_RESP, MessageType.TYPE_RECEIVE_STATUS_QUERY_RESP.typeCode.getNumber());
|
||||
// subscribedInterface.put(MessageType.TYPE_RECEIVE_RECORD_DATA_CONFIG_RESP, MessageType.TYPE_RECEIVE_RECORD_DATA_CONFIG_RESP.typeCode.getNumber());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user