同步获取响应数据

This commit is contained in:
Guoqs
2024-08-01 16:24:52 +08:00
parent 201137bb9f
commit 901310f061
9 changed files with 61 additions and 307 deletions

View File

@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
import com.jsowell.common.util.BytesUtil;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.YKCUtils;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
@@ -13,6 +14,7 @@ import java.util.List;
* 单数为 桩 -> 平台
* 双数为 平台 -> 桩
*/
@Slf4j
public enum YKCFrameTypeCode {
LOGIN_CODE(0x01, "充电桩登录认证"),
@@ -308,27 +310,13 @@ public enum YKCFrameTypeCode {
this.responseFrameType = responseFrameType;
}
// 根据请求帧类型 获取应答帧类型 int类型
// public static int getResponseFrameTypeByRequestFrameType(int requestFrameType) {
// for (PileAnswersRelation relation : PileAnswersRelation.values()) {
// if (relation.getRequestFrameType() == requestFrameType) {
// return relation.getResponseFrameType();
// }
// }
// return 0;
// }
// 根据请求帧类型 获取应答帧类型 byte[]类型
// public static byte[] getResponseFrameTypeBytes(byte[] requestFrameType) {
// int frameType = BytesUtil.bytesToInt(requestFrameType);
// return BytesUtil.intToBytes(getResponseFrameTypeByRequestFrameType(frameType), 1);
// }
/**
* 根据响应帧类型 查找对应的 请求帧类型
*/
public static String getRequestFrameType(String responseFrameType) {
for (PileAnswersRelation relation : PileAnswersRelation.values()) {
log.info("getRequestFrameType-responseFrameType:{}, 对比:{}",
responseFrameType, YKCUtils.frameType2Str(relation.getResponseFrameBytes()));
if (StringUtils.equals(responseFrameType, YKCUtils.frameType2Str(relation.getResponseFrameBytes()))) {
return YKCUtils.frameType2Str(relation.getRequestFrameBytes());
}
@@ -336,44 +324,6 @@ public enum YKCFrameTypeCode {
return null;
}
// 请求帧类型集合 需要获取应答的帧类型
// public static List<String> getRequestFrameTypeList() {
// List<String> requestList = Lists.newArrayList();
// for (PileAnswersRelation relation : PileAnswersRelation.values()) {
// requestList.add(YKCUtils.frameType2Str(relation.getRequestFrameBytes()));
// }
// return requestList;
// }
// 根据应答帧类型获取请求帧类型 byte[]类型
// public static byte[] getRequestFrameTypeBytes(byte[] responseFrameType) {
// int frameType = BytesUtil.bytesToInt(responseFrameType);
// return BytesUtil.intToBytes(getRequestFrameTypeByResponseFrameType(frameType), 1);
// }
public static void main(String[] args) {
System.out.println(BytesUtil.intToBytes(0));
}
// 根据应答帧类型获取请求帧类型 int类型
// public static int getRequestFrameTypeByResponseFrameType(int requestFrameType) {
// for (PileAnswersRelation relation : PileAnswersRelation.values()) {
// if (relation.getRequestFrameType() == requestFrameType) {
// return relation.getResponseFrameType();
// }
// }
// return 0;
// }
// 应答帧类型集合
// public static List<String> getResponseFrameTypeList() {
// List<String> responseList = Lists.newArrayList();
// for (PileAnswersRelation relation : PileAnswersRelation.values()) {
// responseList.add(YKCUtils.frameType2Str(relation.getResponseFrameBytes()));
// }
// return responseList;
// }
}
}