30 changed files with 771 additions and 36 deletions
@ -0,0 +1,64 @@ |
|||||
|
package com.galaxis.rcs.communication; |
||||
|
|
||||
|
import com.fasterxml.jackson.core.type.TypeReference; |
||||
|
import com.fasterxml.jackson.databind.JavaType; |
||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
|
||||
|
import java.lang.reflect.Type; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.concurrent.ConcurrentHashMap; |
||||
|
|
||||
|
@Slf4j |
||||
|
public class JacksonGenericUtils { |
||||
|
private static final ObjectMapper mapper = new ObjectMapper(); |
||||
|
private static final Map<String, JavaType> typeCache = new ConcurrentHashMap<>(); |
||||
|
|
||||
|
// 解析泛型对象(TypeReference方式)
|
||||
|
public static <T> T parse(String json, TypeReference<T> typeRef) { |
||||
|
try { |
||||
|
return mapper.readValue(json, typeRef); |
||||
|
} catch (Exception e) { |
||||
|
log.error("JSON解析失败{}", json, e); |
||||
|
throw new RuntimeException("JSON解析失败", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 动态构建JavaType(支持嵌套泛型)
|
||||
|
public static JavaType buildType(Class<?> rawType, Class<?>... parameterClasses) { |
||||
|
String cacheKey = buildCacheKey(rawType, parameterClasses); |
||||
|
return typeCache.computeIfAbsent(cacheKey, k -> |
||||
|
mapper.getTypeFactory().constructParametricType(rawType, parameterClasses) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// 解析List泛型(高频场景优化)
|
||||
|
public static <T> List<T> parseList(String json, Class<T> elementClass) { |
||||
|
try { |
||||
|
JavaType type = buildType(List.class, elementClass); |
||||
|
return mapper.readValue(json, type); |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException("List解析失败", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 解析Map泛型(Key为String)
|
||||
|
public static <V> Map<String, V> parseMap(String json, Class<V> valueClass) { |
||||
|
try { |
||||
|
JavaType type = mapper.getTypeFactory() |
||||
|
.constructMapType(Map.class, String.class, valueClass); |
||||
|
return mapper.readValue(json, type); |
||||
|
} catch (Exception e) { |
||||
|
throw new RuntimeException("Map解析失败", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static String buildCacheKey(Class<?> rawType, Class<?>... parameterClasses) { |
||||
|
StringBuilder key = new StringBuilder(rawType.getName()); |
||||
|
for (Class<?> clazz : parameterClasses) { |
||||
|
key.append("#").append(clazz.getName()); |
||||
|
} |
||||
|
return key.toString(); |
||||
|
} |
||||
|
} |
||||
@ -1,13 +1,136 @@ |
|||||
package com.galaxis.rcs.communication.amrCommunication; |
package com.galaxis.rcs.communication.amrCommunication; |
||||
|
|
||||
import org.eclipse.paho.mqttv5.client.IMqttMessageListener; |
|
||||
|
import com.fasterxml.jackson.core.type.TypeReference; |
||||
|
import com.galaxis.rcs.communication.JacksonGenericUtils; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.*; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.TaskCompletedData; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.TaskModeChangeData; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.TaskStatusChangeData; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.TaskTypeChangeData; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.clever.core.json.JsonWrapper; |
||||
import org.eclipse.paho.mqttv5.common.MqttMessage; |
import org.eclipse.paho.mqttv5.common.MqttMessage; |
||||
import org.springframework.stereotype.Service; |
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.nio.charset.StandardCharsets; |
||||
|
|
||||
|
@Slf4j |
||||
@Service |
@Service |
||||
public class AmrMessageHandler implements IMqttMessageListener { |
public class AmrMessageHandler { |
||||
@Override |
|
||||
public void messageArrived(String topic, MqttMessage message) throws Exception { |
private static final TypeReference<AmrMessage<AmrTaskCompletedMessage>> typeRef20010Message = new TypeReference<AmrMessage<AmrTaskCompletedMessage>>() {}; |
||||
System.out.println("Received message: " + message.toString()); |
private static final TypeReference<AmrMessage<AmrTaskStatusMessage<TaskStatusChangeData>>> typeRef20011_defaultMessage = new TypeReference<AmrMessage<AmrTaskStatusMessage<TaskStatusChangeData>>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrTaskStatusMessage<TaskModeChangeData>>> typeRef20011_1Message = new TypeReference<AmrMessage<AmrTaskStatusMessage<TaskModeChangeData>>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrTaskStatusMessage<TaskCompletedData>>> typeRef20011_4Message = new TypeReference<AmrMessage<AmrTaskStatusMessage<TaskCompletedData>>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrTaskStatusMessage<TaskTypeChangeData>>> typeRef20011_8Message = new TypeReference<AmrMessage<AmrTaskStatusMessage<TaskTypeChangeData>>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrModuleTaskStatusMessage>> typeRef20012Message = new TypeReference<AmrMessage<AmrModuleTaskStatusMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrLandmarkMessage>> typeRef20020Message = new TypeReference<AmrMessage<AmrLandmarkMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrAckMessage>> typeRef20050Message = new TypeReference<AmrMessage<AmrAckMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrStatusMessage>> typeRef20060Message = new TypeReference<AmrMessage<AmrStatusMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrHeartbeatMessage>> typeRef20100Message = new TypeReference<AmrMessage<AmrHeartbeatMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrBootMessage>> typeRef20147Message = new TypeReference<AmrMessage<AmrBootMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrShutdownMessage>> typeRef20148Message = new TypeReference<AmrMessage<AmrShutdownMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrAppStartMessage>> typeRef20149Message = new TypeReference<AmrMessage<AmrAppStartMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrOnlineMessage>> typeRef20150Message = new TypeReference<AmrMessage<AmrOnlineMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrOfflineMessage>> typeRef20200Message = new TypeReference<AmrMessage<AmrOfflineMessage>>() {}; |
||||
|
private static final TypeReference<AmrMessage<AmrExceptionMessage>> typeRef20250Message = new TypeReference<AmrMessage<AmrExceptionMessage>>() {}; |
||||
|
public static void handleAgvRobotStatusMessage(MqttMessage message) { |
||||
|
byte[] messageData = message.getPayload(); |
||||
|
String json = new String(messageData, StandardCharsets.UTF_8); |
||||
|
JsonWrapper jw = new JsonWrapper(json); |
||||
|
int id = jw.asInt("id"); |
||||
|
|
||||
|
/* |
||||
|
* 消息标识 |
||||
|
* 小车作业完成 20010 AmrTaskCompletedMessage |
||||
|
* 任务状态上报 20011 AmrTaskStatusMessage |
||||
|
* 小车子模块任务状态 20012 AmrModuleTaskStatusMessage |
||||
|
* 地标报告 20020 AmrLandmarkMessage |
||||
|
* 消息应答 20050 AmrAckMessage |
||||
|
* 状态上报 20060 AmrStatusMessage |
||||
|
* 心跳 20100 AmrHeartbeatMessage |
||||
|
* 开机上报 20147 AmrBootMessage |
||||
|
* 关机上报 20148 AmrShutdownMessage |
||||
|
* 小车主程序启动 20149 AmrAppStartMessage |
||||
|
* 小车上线 20150 AmrOnlineMessage |
||||
|
* 小车离线 20200 AmrOfflineMessage |
||||
|
* 异常上报 20250 AmrExceptionMessage |
||||
|
*/ |
||||
|
|
||||
|
AmrMessage<?> amrMessage = null; |
||||
|
switch (id) { |
||||
|
case 20010: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20010Message); |
||||
|
break; |
||||
|
case 20011: { |
||||
|
int EventId = jw.asInt("content", "EventId"); |
||||
|
switch (EventId) { |
||||
|
case 0: |
||||
|
case 2: |
||||
|
case 3: |
||||
|
case 5: |
||||
|
case 6: |
||||
|
case 7: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20011_defaultMessage); |
||||
|
break; |
||||
|
case 1: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20011_1Message); |
||||
|
break; |
||||
|
case 4: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20011_4Message); |
||||
|
break; |
||||
|
case 8: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20011_8Message); |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
break; |
||||
|
} |
||||
|
case 20012: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20012Message); |
||||
|
break; |
||||
|
case 20020: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20020Message); |
||||
|
break; |
||||
|
case 20050: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20050Message); |
||||
|
break; |
||||
|
case 20060: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20060Message); |
||||
|
break; |
||||
|
case 20100: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20100Message); |
||||
|
// if (amrMessage.content instanceof AmrHeartbeatMessage) {
|
||||
|
// AmrHeartbeatMessage msg = (AmrHeartbeatMessage) amrMessage.content;
|
||||
|
// if (msg.VehicleId == 102) {
|
||||
|
// log.info("Received message: " + json);
|
||||
|
// }
|
||||
|
// }
|
||||
|
break; |
||||
|
case 20147: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20147Message); |
||||
|
break; |
||||
|
case 20148: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20148Message); |
||||
|
break; |
||||
|
case 20149: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20149Message); |
||||
|
break; |
||||
|
case 20150: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20150Message); |
||||
|
break; |
||||
|
case 20200: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20200Message); |
||||
|
break; |
||||
|
case 20250: |
||||
|
amrMessage = JacksonGenericUtils.parse(json, typeRef20250Message); |
||||
|
break; |
||||
|
default: |
||||
|
log.error("未知消息:{}", json); |
||||
|
break; |
||||
|
} |
||||
} |
} |
||||
|
|
||||
|
|
||||
} |
} |
||||
|
|||||
@ -0,0 +1,34 @@ |
|||||
|
package com.galaxis.rcs.communication.amrCommunication; |
||||
|
|
||||
|
public class AmrStatusAndInfo { |
||||
|
// agvId 车唯一标识
|
||||
|
public String agvId; |
||||
|
// agv名称
|
||||
|
public String agvName; |
||||
|
// agv类型
|
||||
|
public String agvType; |
||||
|
// agv型号
|
||||
|
public String agvModel; |
||||
|
// AMR功能型号
|
||||
|
public String agvFnModel; |
||||
|
// agv电量
|
||||
|
public double agvSOC; |
||||
|
// agv电池电压
|
||||
|
public double agvBatteryVoltage; |
||||
|
// agv充电状态
|
||||
|
public boolean agvChargingStatus; |
||||
|
// agv充电电流
|
||||
|
public double agvChargingCurrent; |
||||
|
// agv放电电流
|
||||
|
public double agvDischargingCurrent; |
||||
|
// agv电池温度
|
||||
|
public double agvBatteryTemperature; |
||||
|
// agv当前x坐标
|
||||
|
public double x; |
||||
|
// agv当前y坐标
|
||||
|
public double y; |
||||
|
// agv当前z坐标
|
||||
|
public double z; |
||||
|
// agv当前方向
|
||||
|
public double orientation; |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 消息应答 20050
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrAckMessage extends AmrCommonMessage { |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 小车主程序启动 20149
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrAppStartMessage extends AmrCommonMessage { |
||||
|
// 电量百分比 Uint8
|
||||
|
public short Battery; |
||||
|
// AMR底盘型号 String 对于底盘和功能一体的版本,由底盘型号便知道功能;对于通用底盘,底盘型号指定了底盘的版本
|
||||
|
public String AGVModel; |
||||
|
// AMR功能型号 String 底盘之上的工装的型号
|
||||
|
public String AGVFnModel; |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 开机上报 20147 在开机后上报一次,此后AMR程序重启不会重新上报(与ID#20149的差异),除非人为清除内部记录已上报的标志。
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrBootMessage extends AmrCommonMessage { |
||||
|
// 电量百分比 Uint8
|
||||
|
public short Battery; |
||||
|
// AMR底盘型号 String 对于底盘和功能一体的版本,由底盘型号便知道功能;对于通用底盘,底盘型号指定了底盘的版本
|
||||
|
public String AGVModel; |
||||
|
// AMR功能型号 String 底盘之上的工装的型号
|
||||
|
public String AGVFnModel; |
||||
|
// 上电至今的毫秒数 Uint64
|
||||
|
public long Uptime; |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
// 异常上报 20250
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrExceptionMessage extends AmrCommonMessage { |
||||
|
// 异常代码 UInt8 1. 货架编号不匹配 2. 地标异常 3. 电量低
|
||||
|
public short ErrCode; |
||||
|
// 异常机构代码 UInt8 对于哪吒飞梭类的机型,增加MechNo用于指示异常具体是哪一层发生的。 MechNo: 1- 机构1^[1]^异常 2- 机构2异常 3- 机构3异常
|
||||
|
public short MechNo; |
||||
|
// 异常详情 Struct 根据不同的异常,字段不一样,比如针对ErrCode为2电量低的情况,ErrMsg中使用CurBattery标识当前电量;
|
||||
|
public Map<String, Object> ErrMsg; |
||||
|
// 异常事件类型 UInt8 0:无 1:开始 2:更新 3:结束 4:开始并结束
|
||||
|
public short ErrEvtType; |
||||
|
// 异常等级 UInt8 0:Undetermined 12:Info 13:Warning 14:Critical 15:Fatal
|
||||
|
public short ErrLevel; |
||||
|
// 异常生命周期 UInt8 0:易变的 1:一次性 2:持续性 3:任务期间
|
||||
|
public short ErrLifecycle; |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
//心跳 20100
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrHeartbeatMessage extends AmrCommonMessage { |
||||
|
// 电量百分比 Uint8
|
||||
|
public short Battery; |
||||
|
// 上电至今的毫秒数 Uint64
|
||||
|
public long Uptime; |
||||
|
// static
|
||||
|
public TemperatureData Temperature; |
||||
|
public static class TemperatureData { |
||||
|
// 电池温度 Double 单位:摄氏度 备注:一个电池可能有多个(不同型号的)温度传感器,目前只上报最高的温度
|
||||
|
public Double Battery; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 地标报告 20020
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrLandmarkMessage extends AmrCommonMessage { |
||||
|
// 当前X坐标 Double 当前实际位置在地图坐标系中的X坐标
|
||||
|
public double CurX; |
||||
|
// 当前Y坐标 Double 当前实际位置在地图坐标系中的Y坐标
|
||||
|
public double CurY; |
||||
|
// 当前方向 UInt8 0: X轴正向 1: Y轴正向 2: X轴负向 3: Y轴负向 15: 未知方向
|
||||
|
public short CurDirection; |
||||
|
// 当前所在站点的逻辑X坐标 Int32
|
||||
|
public int CurLogicX; |
||||
|
// 当前所在站点的逻辑Y坐标 Int32
|
||||
|
public int CurLogicY; |
||||
|
// 当前标准X坐标 double
|
||||
|
public double X; |
||||
|
// 当前标准Y坐标 double
|
||||
|
public double Y; |
||||
|
// 当前方向 Double 角度
|
||||
|
public double CurOrientation; |
||||
|
// 未知
|
||||
|
public int MarkerType; |
||||
|
} |
||||
@ -1,16 +1,27 @@ |
|||||
package com.galaxis.rcs.connector.cl2.receiveEntity; |
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
// RCS 接收 AMR的消息
|
// RCS 接收 AMR的消息
|
||||
|
@Data |
||||
public class AmrMessage<T> { |
public class AmrMessage<T> { |
||||
// 作业序号 UInt32 从1开始,0作为超级序号使用,不参与序号规则判断
|
/** |
||||
public long SeqNo; |
* 消息标识 |
||||
// AMR编号 UInt16
|
* 小车作业完成 20010 AmrTaskCompletedMessage |
||||
public int VehicleId; |
* 任务状态上报 20011 AmrTaskStatusMessage |
||||
// 消息创建时间 UInt64 毫秒级时间戳
|
* 小车子模块任务状态 20012 AmrModuleTaskStatusMessage |
||||
public long CreateTime; |
* 地标报告 20020 AmrLandmarkMessage |
||||
// 消息创建时主机的开机时长 UInt64 毫秒级时间戳
|
* 消息应答 20050 AmrAckMessage |
||||
public long CreateMonoTime; |
* 状态上报 20060 AmrStatusMessage |
||||
// 发送消息的时间 UInt64 毫秒级时间戳
|
* 心跳 20100 AmrHeartbeatMessage |
||||
public long SendTime; |
* 小车主程序启动 20149 AmrAppStartMessage |
||||
|
* 小车上线 20150 AmrOnlineMessage |
||||
|
* 小车离线 20200 AmrOfflineMessage |
||||
|
* 异常上报 20250 AmrExceptionMessage |
||||
|
* 开机上报 20147 AmrBootMessage |
||||
|
* 关机上报 20148 AmrShutdownMessage |
||||
|
*/ |
||||
|
public int id; |
||||
|
// 消息内容
|
||||
|
public T content; |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,17 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 小车子模块任务状态 20012
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrModuleTaskStatusMessage extends AmrCommonMessage { |
||||
|
// 多机构^[1]^的拣货模式 UInt8[3] 数组形式,意义同"PickMode"
|
||||
|
public short[] MPickMode; |
||||
|
// 子模块任务状态 UInt8[3] 数组形式,数组下标^\[1\]^分别对应各子模块。 0:无任务 2:任务中 3:任务准备中(已有任务,但还没有执行任务的条件) 5:任务异常 7:任务完成 其它:保留
|
||||
|
public short[] MechStatus; |
||||
|
// 多载货机构上每个机构上面货物的ID String[] 数组形式,分别对应各子模块上货箱的ID码的值,如果无货为"",如果解不出来为"unknown"
|
||||
|
public String[] MStorageRacksNo; |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 小车离线 20200 注意:目前未实现此报文
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrOfflineMessage extends AmrCommonMessage { |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 小车上线 20150 代表车已经完成初始化,可以接收任务了。
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrOnlineMessage extends AmrCommonMessage { |
||||
|
// 电量百分比 Uint8
|
||||
|
public short Battery; |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 关机上报 20148 在收到关机信号后上报此消息。
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrShutdownMessage extends AmrCommonMessage { |
||||
|
// 电量百分比 Uint8
|
||||
|
public short Battery; |
||||
|
// 上电至今的毫秒数 Uint64
|
||||
|
public long Uptime; |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.CurBatteryData; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.LocationData; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 状态上报 20060
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrStatusMessage extends AmrCommonMessage { |
||||
|
|
||||
|
// 电池状态
|
||||
|
public CurBatteryData CurBattery; |
||||
|
// 当前方向 Double 角度
|
||||
|
public double CurOrientation; |
||||
|
// 当前所在站点的逻辑X坐标 Int32
|
||||
|
public int CurLogicX; |
||||
|
// 当前所在站点的逻辑Y坐标 Int32
|
||||
|
public int CurLogicY; |
||||
|
// 当前X坐标 Double 当前实际位置在地图坐标系中的X坐标
|
||||
|
public double CurX; |
||||
|
// 当前Y坐标 Double 当前实际位置在地图坐标系中的Y坐标
|
||||
|
public double CurY; |
||||
|
// 货架当前方向 Double
|
||||
|
public double RackCurOrientation; |
||||
|
// 货架当前位置 Double
|
||||
|
public double RackCurPosition; |
||||
|
// 货架号 String
|
||||
|
public String StorageRacksNo; |
||||
|
// 多载货机构上每个机构上面货物的ID String[]
|
||||
|
public String[] MStorageRacksNo; |
||||
|
// 任务模式 Byte
|
||||
|
public short TaskMode; |
||||
|
// 当前标准X坐标 double
|
||||
|
public double X; |
||||
|
// 当前标准Y坐标 double
|
||||
|
public double Y; |
||||
|
// 当前货物数量。数组形式。 对于单滚筒等单个托盘的机型,只需关注数据0; 对于双滚筒,滚筒1的数量放到数据0中,滚筒2的货物数量放到数据1中。 其它机型以此类推。UInt16 [4]
|
||||
|
public int[] GoodsQuantity; |
||||
|
// 异常数组,存放异常的所有异常ID UInt16 [4]
|
||||
|
public int[] Exceptions; |
||||
|
// 是否已进行精准停靠(是否能在原地直接执行对接任务) bool
|
||||
|
public boolean InDock; |
||||
|
// 初始化状态 bool
|
||||
|
public boolean Initialized; |
||||
|
// 车载货位信息
|
||||
|
public LocationData[] GoodsSlots; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,37 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.LocationData; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.SummaryData; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 小车作业完成 20010
|
||||
|
//@Data
|
||||
|
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrTaskCompletedMessage extends AmrCommonMessage { |
||||
|
|
||||
|
// 当前X坐标 Double 当前实际位置在地图坐标系中的X坐标
|
||||
|
public double CurX; |
||||
|
// 当前Y坐标 Double 当前实际位置在地图坐标系中的Y坐标
|
||||
|
public double CurY; |
||||
|
// 当前方向 UInt8 0: X轴正向 1: Y轴正向 2: X轴负向 3: Y轴负向 15: 未知方向
|
||||
|
public short CurDirection; |
||||
|
// 当前方向 Double 角度
|
||||
|
public double CurOrientation; |
||||
|
// 作业类型 UInt8 0:运输 1:接货 2:卸货 3:充电 4:提升移栽取货或卸货 5:滚筒取货或卸货(双向作业) 135:旋转货架 136:旋转车身
|
||||
|
public short OperationType; |
||||
|
// 作业结果 Int32 参考linux errno
|
||||
|
public long OperationResult; |
||||
|
// 货物ID String 在肥波类车型中是货架二维码值;在飞梭车中是箱码(目前未传,未来可能会有);在皮带飞梭中是货物上贴的二维码的码值(如果检测到多个码,则以"
|
||||
|
public String StorageRacksNo; |
||||
|
// 电量百分比 Uint8
|
||||
|
public short Battery; |
||||
|
// 任务描述 Object 目前仅在飞梭和侧叉车型的报文中有这个字段,字段详情见下文
|
||||
|
public SummaryData Summary; |
||||
|
// 车载货位信息
|
||||
|
public LocationData[] GoodsSlots; |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.base.AmrCommonMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
//@Data
|
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class AmrTaskStatusMessage<T> extends AmrCommonMessage { |
||||
|
// 事件ID UInt8 0:无变化 1:任务模式改变 2:任务接收成功 3:任务开始 4:任务完成 5:任务已取消 6:任务已停止 7:任务已恢复 8:任务已更变
|
||||
|
public short EventId; |
||||
|
// 任务模式 Byte
|
||||
|
public short TaskMode; |
||||
|
// 任务信息 由事件ID决定 Object 默认消息(0,2,3,5,6,7):任务状态改变消息 1:任务模式消息 4:任务完成消息 8:任务类型改变消息
|
||||
|
public T Info; |
||||
|
} |
||||
@ -0,0 +1,17 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 共同信息字段
|
||||
|
public class AmrCommonMessage { |
||||
|
// 作业序号 UInt32 从1开始,0作为超级序号使用,不参与序号规则判断
|
||||
|
public long SeqNo; |
||||
|
// AMR编号 UInt16
|
||||
|
public int VehicleId; |
||||
|
// 消息创建时间 UInt64 毫秒级时间戳
|
||||
|
public long CreateTime; |
||||
|
// 消息创建时主机的开机时长 UInt64 毫秒级时间戳
|
||||
|
public long CreateMonoTime; |
||||
|
// 发送消息的时间 UInt64 毫秒级时间戳
|
||||
|
public long SendTime; |
||||
|
} |
||||
@ -0,0 +1,20 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 电池状态
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class CurBatteryData { |
||||
|
// 充电电流
|
||||
|
public double ChargingCurrent; |
||||
|
// 放电电流
|
||||
|
public double DischargingCurrent; |
||||
|
// 电量
|
||||
|
public double SOC; |
||||
|
// 电压
|
||||
|
public double Voltage; |
||||
|
// 温度
|
||||
|
public double Temperature; |
||||
|
} |
||||
@ -0,0 +1,32 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.galaxis.rcs.connector.cl2.receiveEntity.AmrStatusMessage; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 货物信息
|
||||
|
@Data |
||||
|
public class GoodsData { |
||||
|
// 货物类型 UInt 对于一类设备可能取放不同货物时有用;如果只有一类货物,则可以不(在地图或者RCS下发的任务报文中)指定,此种情况下报文中不包含此字段
|
||||
|
public int Category; |
||||
|
// 传感器检测到的货物ID String 比如飞梭通过摄像头检测到的箱码、FM系列通过对上摄像头检测到的货架底部二维码等;如果车型没配备可以检测货物ID的传感器,则报文中不包含此字段
|
||||
|
public String DetectedId; |
||||
|
// 上位系统传过来的货物ID String 通常上位传过来的ID应该跟检测到的ID一致,否则会报错;对于没有检测ID功能的车型,不做校验而只是回传该值;有些项目可能会希望两个ID分开,对应此类需求可以特别设置不校验两类ID;也许有些项目会同时传入两种ID,当前暂不支持;如果上位没传入ID,则报文中不包含此字段
|
||||
|
public String UpperSystemDefinedId; |
||||
|
// 高度等级 UInt8 部分车型能检测货物高度,等级从0(最矮,默认值)开始,每一级递增1,各个等级的具体含义与车型有关,需要另行约定;如果有传感器但是由于传感器异常等原因无法获取到检测结果,则设置该值为0xff,代表状态未知。
|
||||
|
public short HeightLevel; |
||||
|
// 长度等级
|
||||
|
public short LengthLevel; |
||||
|
// 宽度等级
|
||||
|
public short WidthLevel; |
||||
|
// 重量等级
|
||||
|
public short WeightLevel; |
||||
|
// 测算的重量,不一定准 Double 单位是千克
|
||||
|
public double ApproximateWeight; |
||||
|
// 货物在地图上的朝向 Double 角度(Degree)值
|
||||
|
public double Orientation; |
||||
|
// 货物相对机器人的位置 包含以下成员: OffsetX:Int32类型 OffsetY:Int32类型 Orientation:Double类型,用角度(Degree)表示
|
||||
|
public OffsetPosition RelativePosition; |
||||
|
// 检测到的货物状态冲突 [UInt8] 1:货物ID不匹配 2:货物高度不匹配 3:货物宽度不匹配 4:货物长度不匹配 5:应该有货但没检测到有货 6:应该没货但检测到有货
|
||||
|
public short[] DetectedStatusConflicts; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 货位信息
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class LocationData { |
||||
|
// 货位ID UInt8 从0开始,每款车自己定义的车载货位的ID
|
||||
|
public short ID; |
||||
|
// 货位名称 String 每款车自己定义的货位的名称
|
||||
|
public String Name; |
||||
|
// 逻辑上是否应该有货 bool 有些车型有传感器来检测货物状态,这时实际的货物状态跟逻辑状态就可能不同
|
||||
|
public boolean ShouldHaveGoods; |
||||
|
// 检测到的货位状态 UInt8 0: 正常 1: 冲突,即传感器检测到的状态跟逻辑状态有冲突。逻辑上有货,实际无货,是一种冲突;逻辑上货的属性(比如高度)跟实际检测到的属性不同,也会产生冲突;对于一个货位有多个货物的情况,需要查看货物信息来查找具体是哪个货物出现了什么冲突
|
||||
|
public short DetectedStatus; |
||||
|
// 货位放货平面离地高度 Double
|
||||
|
public double Height; |
||||
|
// 货位相对原点(初始化后货位所在位置)的相对位置 Object 包含以下成员: OffsetX:Double类型 OffsetY:Double类型 OffsetZ:Double类型,代表在高度上的位移 Orientation:Double类型,用角度(Degree)表示
|
||||
|
public OffsetPosition Position; |
||||
|
// 货物信息 Object
|
||||
|
public GoodsData[] Goods; |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 相对原点偏移
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class OffsetPosition { |
||||
|
// OffsetX:Double类型 OffsetY:Double类型 OffsetZ:Double类型,代表在高度上的位移 Orientation:Double类型,用角度(Degree)表示
|
||||
|
public double OffsetX; |
||||
|
public double OffsetY; |
||||
|
public double OffsetZ; |
||||
|
public double Orientation; |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 任务描述
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class SummaryData { |
||||
|
// 执行器(比如飞梭的载货台)任务概览列表 Array 车载多少个执行器,数组就有多少个成员
|
||||
|
public ActuatorsData[] Actuators; |
||||
|
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public static class ActuatorsData { |
||||
|
// 执行器编号 Uint8 从1开始
|
||||
|
public short MechNo; |
||||
|
// 执行器名称 String
|
||||
|
public String Name; |
||||
|
// 任务类型 UInt8 同下发任务中PickMode的定义
|
||||
|
public short PickMode; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,36 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 任务状态上报 20011 中 EventId = 4:任务完成 任务完成消息
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class TaskCompletedData { |
||||
|
// 作业类型 UInt8 0:运输 1:接货 2:卸货 3:充电 4:提升移栽取货或卸货 5:滚筒取货或卸货(双向作业) 135:旋转货架 136:旋转车身
|
||||
|
public short OperationType; |
||||
|
// 作业结果 Int32 参考linux errno
|
||||
|
public long OperationResult; |
||||
|
// 当前所在站点的逻辑X坐标 Int32
|
||||
|
public int CurLogicX; |
||||
|
// 当前所在站点的逻辑Y坐标 Int32
|
||||
|
public int CurLogicY; |
||||
|
// 当前X坐标 Double 当前实际位置在地图坐标系中的X坐标
|
||||
|
public double CurX; |
||||
|
// 当前Y坐标 Double 当前实际位置在地图坐标系中的Y坐标
|
||||
|
public double CurY; |
||||
|
// 当前方向 UInt8 0: X轴正向 1: Y轴正向 2: X轴负向 3: Y轴负向 15: 未知方向
|
||||
|
public short CurDirection; |
||||
|
// 当前方向 Double 角度
|
||||
|
public double CurOrientation; |
||||
|
// 货架号 String 在肥波类车型中是货架二维码值;在飞梭车中是箱码(目前未传,未来可能会有);在皮带飞梭中是货物上贴的二维码的码值(如果检测到多个码,则以"
|
||||
|
public String StorageRacksNo; |
||||
|
// 货架朝向 UInt8 0: X轴正向 1: Y轴正向 2: X轴负向 3: Y轴负向 15: 未知方向
|
||||
|
public short StorageDirection; |
||||
|
// 任务描述 Object 目前仅在飞梭和侧叉车型的报文中有这个字段,字段详情见下文
|
||||
|
public SummaryData Summary; |
||||
|
// 电量百分比 Uint8
|
||||
|
public short Battery; |
||||
|
// 车载货位信息
|
||||
|
public LocationData[] GoodsSlots; |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
//1: 任务模式改变消息
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class TaskModeChangeData { |
||||
|
// 上一个任务模式 Uint8 0: 空闲模式 1: 初始化模式 2: 任务模式 3: 单动作模式 4: 手动模式 5: 遥控器模式 6: 充电模式 7: 任务被中断模式 有任务,但未收到终点坐标 8: 自定义模式
|
||||
|
public short PrevTaskMode; |
||||
|
// 当前任务模式 Uint8 0: 空闲模式 1: 初始化模式 2: 任务模式 3: 单动作模式 4: 手动模式 5: 遥控器模式 6: 充电模式 7: 任务被中断模式 有任务,但未收到终点坐标 8: 自定义模式
|
||||
|
public short TaskMode; |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 0,2,3,5,6,7:任务状态改变消息
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class TaskStatusChangeData { |
||||
|
// 当前任务类型 0: 运输 1: 接货 2: 卸货 3: 充电 4: 提升移栽取货或卸货 5: 滚筒取货或卸货(双向作业) 135: 旋转货架 136: 旋转车身 143: 卷帘门控制 224: 等待就绪
|
||||
|
public short OperationType; |
||||
|
} |
||||
@ -0,0 +1,14 @@ |
|||||
|
package com.galaxis.rcs.connector.cl2.receiveEntity.base; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
// 8: 任务类型改变消息
|
||||
|
@Data |
||||
|
@JsonIgnoreProperties(ignoreUnknown = true) |
||||
|
public class TaskTypeChangeData { |
||||
|
// 上一个任务类型 0: 运输 1: 接货 2: 卸货 3: 充电 4: 提升移栽取货或卸货 5: 滚筒取货或卸货(双向作业) 135: 旋转货架 136: 旋转车身 143: 卷帘门控制 224: 等待就绪
|
||||
|
public short PrevOperationType; |
||||
|
// 当前任务类型 0: 运输 1: 接货 2: 卸货 3: 充电 4: 提升移栽取货或卸货 5: 滚筒取货或卸货(双向作业) 135: 旋转货架 136: 旋转车身 143: 卷帘门控制 224: 等待就绪
|
||||
|
public short OperationType; |
||||
|
} |
||||
Loading…
Reference in new issue