|
|
@ -31,7 +31,7 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
private static final byte[] UPPER_DATA_3_4 = new byte[]{0x02, 0x01};
|
|
|
|
private static final byte[] UPPER_DATA_3_4 = new byte[]{0x02, 0x01};
|
|
|
|
|
|
|
|
|
|
|
|
/**常发数据内容,被填入ByteBuf初始内容,所有飞机共用, 禁止修改*/
|
|
|
|
/**常发数据内容,被填入ByteBuf初始内容,所有飞机共用, 禁止修改*/
|
|
|
|
private static final byte C0 = 0x01; // 空白数据自定义特征字
|
|
|
|
private static final byte C0 = 0x00; // 空白数据自定义特征字
|
|
|
|
private static final byte[] COMMON_DATA_14_29 = new byte[]{
|
|
|
|
private static final byte[] COMMON_DATA_14_29 = new byte[]{
|
|
|
|
0x21, C0, C0, C0, C0, // 14~29
|
|
|
|
0x21, C0, C0, C0, C0, // 14~29
|
|
|
|
C0, C0, C0, C0, C0,
|
|
|
|
C0, C0, C0, C0, C0,
|
|
|
@ -39,7 +39,7 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**控制帧数据内容,被填入ByteBuf初始内容,*/
|
|
|
|
/**控制帧数据内容,被填入ByteBuf初始内容,*/
|
|
|
|
private static final byte C1 = 0x02; // 空白数据自定义特征字
|
|
|
|
private static final byte C1 = 0x00; // 空白数据自定义特征字
|
|
|
|
private static final byte[] CONTROL_DATA_14_29 = new byte[]{
|
|
|
|
private static final byte[] CONTROL_DATA_14_29 = new byte[]{
|
|
|
|
0x21, C1, C1, C1, C1, // 14~29
|
|
|
|
0x21, C1, C1, C1, C1, // 14~29
|
|
|
|
C1, C1, C1, C1, C1,
|
|
|
|
C1, C1, C1, C1, C1,
|
|
|
@ -85,7 +85,7 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
uavId = HaborUavMap.getUavIdByHaborSn(haborSn);
|
|
|
|
uavId = HaborUavMap.getUavIdByHaborSn(haborSn);
|
|
|
|
uavType = UavIdMap.getUavType(uavId);
|
|
|
|
uavType = UavIdMap.getUavType(uavId);
|
|
|
|
fkId = (byte) UavIdMap.getFkId(uavId);
|
|
|
|
fkId = (byte) UavIdMap.getFkId(uavId);
|
|
|
|
super.commonDataFreq = 1; // 发送频率, 每秒发送帧数
|
|
|
|
super.commonDataFreq = 5; // 发送频率, 每秒发送帧数
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -184,26 +184,27 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
dataBufToSend.addSendCount();
|
|
|
|
dataBufToSend.addSendCount();
|
|
|
|
|
|
|
|
|
|
|
|
if (dataBufToSend instanceof CommonDataBuf) {
|
|
|
|
if (dataBufToSend instanceof CommonDataBuf) {
|
|
|
|
log.debug("[cac] {} 发送常发帧: {}", shortInfo(), ByteBufUtil.hexDump(dataBufToSend.buf));
|
|
|
|
// log.debug("[cac] {} 发送常发帧: {}", shortInfo(), ByteUtils.bytes2HexString(ByteBufUtil.getBytes()(dataBufToSend.buf)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dataBufToSend instanceof ControlDataBuf) {
|
|
|
|
if (dataBufToSend instanceof ControlDataBuf) {
|
|
|
|
log.info("[cac] {} 发送控制指令: {}", shortInfo(), ByteBufUtil.hexDump(dataBufToSend.buf));
|
|
|
|
log.debug("[cac] {} 发送控制指令: {}", shortInfo(), ByteUtils.bytes2HexString(ByteBufUtil.getBytes(dataBufToSend.buf)));
|
|
|
|
if (dataBufToSend.getSendCount() >= ((ControlDataBuf) dataBufToSend).needCount) {
|
|
|
|
if (dataBufToSend.getSendCount() >= ((ControlDataBuf) dataBufToSend).needCount) {
|
|
|
|
log.info("[cac] {} 控制指令发送完毕", shortInfo());
|
|
|
|
log.info("[cac] {} 控制指令发送完毕, {}", shortInfo(), ByteUtils.bytes2HexString(ByteBufUtil.getBytes(dataBufToSend.buf)));
|
|
|
|
|
|
|
|
//
|
|
|
|
switchToCommonData();
|
|
|
|
switchToCommonData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dataBufToSend instanceof QueryDataBuf) {
|
|
|
|
if (dataBufToSend instanceof QueryDataBuf) {
|
|
|
|
log.info("[cac] {} 发送查询指令: {}", shortInfo(), ByteBufUtil.hexDump(dataBufToSend.buf));
|
|
|
|
log.debug("[cac] {} 发送查询指令: {}", shortInfo(), ByteUtils.bytes2HexString(ByteBufUtil.getBytes(dataBufToSend.buf)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dataBufToSend instanceof BindDataBuf) {
|
|
|
|
if (dataBufToSend instanceof BindDataBuf) {
|
|
|
|
log.info("[cac] {} 发送参数装订指令: {}", shortInfo(), ByteBufUtil.hexDump(dataBufToSend.buf));
|
|
|
|
log.debug("[cac] {} 发送参数装订指令: {}", shortInfo(), ByteUtils.bytes2HexString(ByteBufUtil.getBytes(dataBufToSend.buf)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dataBufToSend instanceof RouteDataBuf) {
|
|
|
|
if (dataBufToSend instanceof RouteDataBuf) {
|
|
|
|
log.info("[cac] {} 发送航线装订指令: {}", shortInfo(), ByteBufUtil.hexDump(dataBufToSend.buf));
|
|
|
|
log.debug("[cac] {} 发送航线装订指令: {}", shortInfo(), ByteUtils.bytes2HexString(ByteBufUtil.getBytes(dataBufToSend.buf)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -286,31 +287,31 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
writeRouteBindCommand0(commandCode, routeInfoList.get(0), controlUniId); //发送第一个节点
|
|
|
|
writeRouteBindCommand0(commandCode, routeInfoList.get(0), controlUniId); //发送第一个节点
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**注入回报帧处理*/
|
|
|
|
/**注入回报帧处理, 如果正常处理,返回true,否则返回false继续透传*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
protected void processInjectResponse(ByteBuf msg) {
|
|
|
|
protected boolean processInjectResponse(ByteBuf msg) {
|
|
|
|
if (msg.getByte(0) != HEAD[0] && msg.getByte(1) != HEAD[1]) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 只处理注入回报帧A0
|
|
|
|
// 只处理注入回报帧A0
|
|
|
|
if (msg.getByte(2) != (byte) 0xA0) {
|
|
|
|
if (msg.getByte(2) == (byte) 0xA0) {
|
|
|
|
return;
|
|
|
|
if (checkParamBindResponse(msg)) return true; // 检查参数装订回报
|
|
|
|
|
|
|
|
if (checkParamQueryResponse(msg)) return true; // 检查参数查询回报
|
|
|
|
|
|
|
|
if (checkRouteBindResponse(msg)) return true; // 检查航线装订回报
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg.getByte(2) == (byte) 0xA1) {
|
|
|
|
|
|
|
|
if (checkControlResponse(msg)) return true; // 检查控制指令回报
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (checkControlResponse(msg)) return; // 检查控制指令回报
|
|
|
|
return false;
|
|
|
|
if (checkParamBindResponse(msg)) return; // 检查参数装订回报
|
|
|
|
|
|
|
|
if (checkParamQueryResponse(msg)) return; // 检查参数查询回报
|
|
|
|
|
|
|
|
if (checkRouteBindResponse(msg)) return; // 检查航线装订回报
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 检查控制指令回报*/
|
|
|
|
/** 检查控制指令回报*/
|
|
|
|
private boolean checkControlResponse(ByteBuf msg) {
|
|
|
|
private boolean checkControlResponse(ByteBuf msg) {
|
|
|
|
if (CommandRecord.WAITING_RESULT == previousControl.getState()) {
|
|
|
|
if (CommandRecord.WAITING_RESULT == previousControl.getState()) {
|
|
|
|
|
|
|
|
log.debug("当前指令{}, uniId:{}, A1帧指令回报: {}", ByteUtils.byteToHex(previousControl.code), previousControl.commandUniId, ByteUtils.byteToHex(msg.getByte(29)));
|
|
|
|
previousControl.addReceiveFrameCount();
|
|
|
|
previousControl.addReceiveFrameCount();
|
|
|
|
if (previousControl.commandMatch(msg.slice(13,16))) {
|
|
|
|
if (msg.getByte(29) == previousControl.code) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// previousControl.notifyControlCommandResult();
|
|
|
|
previousControl.notifyControlCommandResult(uavId, true);
|
|
|
|
log.info("[cac] {} 控制指令成功结果回报...", shortInfo());
|
|
|
|
log.info("[cac] {} 控制指令成功结果回报...", shortInfo());
|
|
|
|
previousControl.clearCommand();
|
|
|
|
previousControl.clearCommand();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -335,7 +336,7 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
previousParamBind.addReceiveFrameCount();
|
|
|
|
previousParamBind.addReceiveFrameCount();
|
|
|
|
if (previousParamBind.commandMatch(msg.slice(13,16))) {
|
|
|
|
if (previousParamBind.commandMatch(msg.slice(13,16))) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// previousParamBind.notifyParamBindCommandResult(true);
|
|
|
|
previousParamBind.notifyParamBindCommandResult(uavId, uavType,true);
|
|
|
|
log.info("[cac] {} 指令装订成功结果回报...", shortInfo());
|
|
|
|
log.info("[cac] {} 指令装订成功结果回报...", shortInfo());
|
|
|
|
previousParamBind.clearCommand();
|
|
|
|
previousParamBind.clearCommand();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -358,10 +359,20 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
private boolean checkParamQueryResponse(ByteBuf msg) {
|
|
|
|
private boolean checkParamQueryResponse(ByteBuf msg) {
|
|
|
|
if (CommandRecord.WAITING_RESULT == previousParamQuery.getState()) {
|
|
|
|
if (CommandRecord.WAITING_RESULT == previousParamQuery.getState()) {
|
|
|
|
previousParamQuery.addReceiveFrameCount();
|
|
|
|
previousParamQuery.addReceiveFrameCount();
|
|
|
|
if (previousParamQuery.commandMatch(msg.slice(13,16))) {
|
|
|
|
if (msg.getByte(13) == previousParamQuery.code) { // fixme 匹配的不是同样的内容
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
UavTakeOffParamQueryResultParam981A uavTakeOffParamQueryResultParam = new UavTakeOffParamQueryResultParam981A(msg.slice(13,16));
|
|
|
|
UavQueryResultParam uavQueryResultParam = null;
|
|
|
|
// previousParamQuery.notifyParamQueryCommandResult(true, uavTakeOffParamQueryResultParam);
|
|
|
|
switch (msg.getByte(13)) {
|
|
|
|
|
|
|
|
case (byte) 0x41: // 起飞参数查询
|
|
|
|
|
|
|
|
uavQueryResultParam = new UavTakeOffParamQueryResultParam981A(msg.slice(13, 16));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case (byte) 0x33: // 重量查询
|
|
|
|
|
|
|
|
uavQueryResultParam = new UavWeightQueryResultParam981A(msg.slice(13, 16));
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
log.warn("[cac] {} 指令查询结果回报,未知的指令类型:{}", shortInfo(), ByteUtils.byteToHex(msg.getByte(13)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
previousParamQuery.notifyParamQueryCommandResult(uavId, uavType, true, uavQueryResultParam);
|
|
|
|
log.info("[cac] {} 指令查询成功结果回报...", shortInfo());
|
|
|
|
log.info("[cac] {} 指令查询成功结果回报...", shortInfo());
|
|
|
|
previousParamQuery.clearCommand();
|
|
|
|
previousParamQuery.clearCommand();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -388,7 +399,7 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
if (previousRouteBind.commandMatch(msg.slice(13, 16))) {
|
|
|
|
if (previousRouteBind.commandMatch(msg.slice(13, 16))) {
|
|
|
|
if (previousRouteBind.completeOrWaitNext()) { // 如果指令列表均已回报,则判定成功,向中心指控回报, 并恢复常发帧
|
|
|
|
if (previousRouteBind.completeOrWaitNext()) { // 如果指令列表均已回报,则判定成功,向中心指控回报, 并恢复常发帧
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// previousRouteBind.notifyParamBindCommandResult(true);
|
|
|
|
previousRouteBind.notifyParamBindCommandResult(uavId,uavType,true);
|
|
|
|
log.info("[cac] {} 航线装订成功结果成功", shortInfo());
|
|
|
|
log.info("[cac] {} 航线装订成功结果成功", shortInfo());
|
|
|
|
previousRouteBind.clearCommand();
|
|
|
|
previousRouteBind.clearCommand();
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -422,12 +433,12 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
case (byte) 0xE3: // 开伞
|
|
|
|
case (byte) 0xE3: // 开伞
|
|
|
|
return 45;
|
|
|
|
return 45;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return 5;
|
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 查询指令回报结果参数类, 各型号分开定义*/
|
|
|
|
/**Cac起飞参数查询查询回报,具体定义见各型号子类*/
|
|
|
|
@Data
|
|
|
|
@Data
|
|
|
|
private static class UavTakeOffParamQueryResultParam981A extends UavTakeOffParamQueryResultParam {
|
|
|
|
private static class UavTakeOffParamQueryResultParam981A extends UavTakeOffParamQueryResultParam {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -522,4 +533,28 @@ public class HaborClient981A extends HaborClient {
|
|
|
|
return JSONUtils.obj2json(this);
|
|
|
|
return JSONUtils.obj2json(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class UavWeightQueryResultParam981A extends UavWeightQueryResultParam{
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 空机重量,单位kg,精确到整数位; 原数据分辨率 1
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private int uavWeight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 货物重量,单位kg,精确到整数位; 原数据分辨率 1
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private int cargoWeight;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public UavWeightQueryResultParam981A(ByteBuf dataBufSlice) {
|
|
|
|
|
|
|
|
int idx = 1;
|
|
|
|
|
|
|
|
uavWeight = dataBufSlice.getUnsignedShortLE(idx);
|
|
|
|
|
|
|
|
idx += 2;
|
|
|
|
|
|
|
|
cargoWeight = dataBufSlice.getUnsignedShortLE(idx);
|
|
|
|
|
|
|
|
idx += 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toJsonStr() throws IOException {
|
|
|
|
|
|
|
|
return JSONUtils.obj2json(this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|