mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 01:49:58 +08:00
!15 增加0x92远程重启和0x91远程重启应答
* Merge remote-tracking branch 'refs/remotes/upstream/master' into maste… * 0x92远程重启和0x91远程重启应答 * 0x92远程重启和0x91远程重启应答测试 * 0x92远程重启和0x91远程重启应答
This commit is contained in:
@@ -33,6 +33,14 @@ public class TestController {
|
||||
return ResponseEntity.ok("success");
|
||||
}
|
||||
|
||||
@GetMapping("/api/reStartCharge")
|
||||
public ResponseEntity<String> reStartCharge() {
|
||||
|
||||
pileProtocolService.restartPile("20231212000010", 1);
|
||||
|
||||
return ResponseEntity.ok("success");
|
||||
}
|
||||
|
||||
@GetMapping("/api/setPricing")
|
||||
public ResponseEntity<String> setPricing() {
|
||||
|
||||
|
||||
@@ -74,6 +74,12 @@ public interface PileProtocolService {
|
||||
*/
|
||||
void startCharge(String pileCode, String gunCode, BigDecimal limitYuan, String orderNo);
|
||||
|
||||
|
||||
/**
|
||||
* 重启充电
|
||||
*/
|
||||
void restartPile(String pileCode, Integer type);
|
||||
|
||||
/**
|
||||
* 下发计费
|
||||
*/
|
||||
@@ -94,6 +100,12 @@ public interface PileProtocolService {
|
||||
*/
|
||||
void onBmsCharingInfo(UplinkQueueMessage uplinkQueueMessage, Callback callback);
|
||||
|
||||
/**
|
||||
* 远程重启反馈
|
||||
*/
|
||||
void onRestartPileResponse(UplinkQueueMessage uplinkQueueMessage, Callback callback);
|
||||
|
||||
|
||||
/**
|
||||
* 充电阶段BMS中止
|
||||
*/
|
||||
|
||||
@@ -297,6 +297,28 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
downlinkCallService.sendDownlinkMessage(downlinkRequestMessageBuilder, pileCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartPile(String pileCode, Integer type) {
|
||||
|
||||
UUID messageId = UUID.randomUUID();
|
||||
UUID requestId = UUID.randomUUID();
|
||||
|
||||
|
||||
DownlinkRequestMessage.Builder downlinkRequestMessageBuilder = DownlinkRequestMessage.newBuilder()
|
||||
.setMessageIdMSB(messageId.getMostSignificantBits())
|
||||
.setMessageIdLSB(messageId.getLeastSignificantBits())
|
||||
.setPileCode(pileCode)
|
||||
.setRequestIdMSB(requestId.getMostSignificantBits())
|
||||
.setRequestIdLSB(requestId.getLeastSignificantBits())
|
||||
.setDownlinkCmd(DownlinkCmdEnum.REMOTE_RE_START_CHARGING.name())
|
||||
.setRestartPileRequest(RestartPileRequest.newBuilder()
|
||||
.setPileCode(pileCode)
|
||||
.setType(type)
|
||||
.build());
|
||||
|
||||
downlinkCallService.sendDownlinkMessage(downlinkRequestMessageBuilder, pileCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPricing(String pileCode, SetPricingRequest setPricingRequest) {
|
||||
UUID messageId = UUID.randomUUID();
|
||||
@@ -347,6 +369,15 @@ public class DefaultPileProtocolService implements PileProtocolService {
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRestartPileResponse(UplinkQueueMessage uplinkQueueMessage, Callback callback) {
|
||||
log.info("接收到充电桩重启结果反馈 {}", uplinkQueueMessage);
|
||||
|
||||
// TODO 处理相关业务逻辑
|
||||
|
||||
callback.onSuccess();
|
||||
}
|
||||
|
||||
private static Period createPeriod(int sn, LocalTime beginTime, LocalTime endTime, PricingModelFlag flag) {
|
||||
Period period = new Period();
|
||||
period.setSn(sn);
|
||||
|
||||
@@ -208,6 +208,10 @@ public class ProtocolUplinkConsumerService extends AbstractConsumerService imple
|
||||
|
||||
pileProtocolService.onBmsAbort(uplinkQueueMsg, callback);
|
||||
|
||||
} else if (uplinkQueueMsg.hasRestartPileResponse()) {
|
||||
|
||||
pileProtocolService.onRestartPileResponse(uplinkQueueMsg, callback);
|
||||
|
||||
} else {
|
||||
|
||||
callback.onSuccess();
|
||||
|
||||
@@ -70,6 +70,8 @@ message UplinkQueueMessage {
|
||||
BmsParamConfigReport bmsParamConfigReport = 33;
|
||||
BmsChargingInfoProto bmsChargingInfoProto = 34;
|
||||
BmsAbortProto bmsAbortProto = 35;
|
||||
RestartPileResponse restartPileResponse = 36;
|
||||
|
||||
}
|
||||
|
||||
message DownlinkRequestMessage {
|
||||
@@ -90,6 +92,7 @@ message DownlinkRequestMessage {
|
||||
RemoteStartChargingRequest remoteStartChargingRequest = 25;
|
||||
RemoteStopChargingRequest remoteStopChargingRequest = 26;
|
||||
TransactionRecordAck transactionRecordAck = 27;
|
||||
RestartPileRequest restartPileRequest = 28;
|
||||
}
|
||||
|
||||
message DownlinkResponseMessage {
|
||||
@@ -242,6 +245,12 @@ message RemoteStartChargingRequest {
|
||||
optional string additionalInfo = 20;
|
||||
}
|
||||
|
||||
message RestartPileRequest {
|
||||
string pileCode = 4;
|
||||
int32 type = 7;
|
||||
|
||||
}
|
||||
|
||||
message RemoteStartChargingResponse {
|
||||
int64 ts = 1;
|
||||
string pileCode = 4;
|
||||
@@ -251,6 +260,11 @@ message RemoteStartChargingResponse {
|
||||
string failReason = 8;
|
||||
optional string additionalInfo = 20;
|
||||
}
|
||||
message RestartPileResponse {
|
||||
int64 ts = 1;
|
||||
string pileCode = 4;
|
||||
bool success = 7;
|
||||
}
|
||||
|
||||
message RemoteStopChargingRequest {
|
||||
string pileCode = 4;
|
||||
|
||||
@@ -26,4 +26,6 @@ public enum DownlinkCmdEnum {
|
||||
TRANSACTION_RECORD_ACK,
|
||||
|
||||
REMOTE_PARALLEL_START_CHARGING,
|
||||
|
||||
REMOTE_RE_START_CHARGING,
|
||||
}
|
||||
@@ -75,3 +75,11 @@
|
||||
---
|
||||
#### 0x1D 充电阶段BMS中止
|
||||
`68 20 00 18 00 1D 20 23 12 12 00 00 01 01 11 51 11 61 55 53 50 26 20 23 12 12 00 00 10 01 00 00 00 00 5a 23`
|
||||
|
||||
|
||||
#### 0x91 远程重启应答
|
||||
`68 0C 00 11 00 91 20 23 12 12 00 00 10 01 03 F2`
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +34,9 @@ public enum YunKuaiChongDownlinkCmdEnum {
|
||||
|
||||
TRANSACTION_RECORD(0x40),
|
||||
|
||||
REMOTE_PARALLEL_START_CHARGING(0xA4);
|
||||
REMOTE_PARALLEL_START_CHARGING(0xA4),
|
||||
|
||||
REMOTE_RE_START_CHARGING(0x92);
|
||||
|
||||
private final Integer cmd;
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 开源代码,仅供学习和交流研究使用,商用请联系三丙
|
||||
* 微信:mohan_88888
|
||||
* 抖音:程序员三丙
|
||||
* 付费课程知识星球:https://t.zsxq.com/aKtXo
|
||||
*/
|
||||
package sanbing.jcpp.protocol.yunkuaichong.v150.cmd;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.RestartPileRequest;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDownlinkCmdExe;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongDwonlinkMessage;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.annotation.YunKuaiChongCmd;
|
||||
|
||||
import static sanbing.jcpp.protocol.yunkuaichong.enums.YunKuaiChongDownlinkCmdEnum.REMOTE_RE_START_CHARGING;
|
||||
|
||||
/**
|
||||
* 云快充1.5.0 运营平台远程重启充电桩
|
||||
*/
|
||||
@Slf4j
|
||||
@YunKuaiChongCmd(0x92)
|
||||
public class YunKuaiChongV150RestartPileDLCmd extends YunKuaiChongDownlinkCmdExe {
|
||||
|
||||
@Override
|
||||
public void execute(TcpSession tcpSession, YunKuaiChongDwonlinkMessage yunKuaiChongDwonlinkMessage, ProtocolContext ctx) {
|
||||
log.info("{} 云快充1.5.0运营平台远程重启充电桩", tcpSession);
|
||||
|
||||
if (!yunKuaiChongDwonlinkMessage.getMsg().hasRestartPileRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
RestartPileRequest restartPileRequest = yunKuaiChongDwonlinkMessage.getMsg().getRestartPileRequest();
|
||||
String pileCode = restartPileRequest.getPileCode();
|
||||
int type = restartPileRequest.getType();
|
||||
ByteBuf msgBody = Unpooled.buffer(8);
|
||||
// 桩编码
|
||||
msgBody.writeBytes(encodePileCode(pileCode));
|
||||
// 0x01:立即执行 0x02:空闲执行
|
||||
msgBody.writeInt(type);
|
||||
encodeAndWriteFlush(REMOTE_RE_START_CHARGING,
|
||||
msgBody,
|
||||
tcpSession);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 开源代码,仅供学习和交流研究使用,商用请联系三丙
|
||||
* 微信:mohan_88888
|
||||
* 抖音:程序员三丙
|
||||
* 付费课程知识星球:https://t.zsxq.com/aKtXo
|
||||
*/
|
||||
package sanbing.jcpp.protocol.yunkuaichong.v150.cmd;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import sanbing.jcpp.infrastructure.util.codec.BCDUtil;
|
||||
import sanbing.jcpp.infrastructure.util.trace.TracerContextUtil;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.RestartPileResponse;
|
||||
import sanbing.jcpp.proto.gen.ProtocolProto.UplinkQueueMessage;
|
||||
import sanbing.jcpp.protocol.ProtocolContext;
|
||||
import sanbing.jcpp.protocol.listener.tcp.TcpSession;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkCmdExe;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.YunKuaiChongUplinkMessage;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.annotation.YunKuaiChongCmd;
|
||||
|
||||
/**
|
||||
* 云快充1.5.0 远程重启充电命令回复
|
||||
*/
|
||||
@Slf4j
|
||||
@YunKuaiChongCmd(0x91)
|
||||
public class YunKuaiChongV150RestartPileResultULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
|
||||
@Override
|
||||
public void execute(TcpSession tcpSession, YunKuaiChongUplinkMessage yunKuaiChongUplinkMessage, ProtocolContext ctx) {
|
||||
log.info("{} 云快充1.5.0远程重启动充电命令回复", tcpSession);
|
||||
ByteBuf byteBuf = Unpooled.wrappedBuffer(yunKuaiChongUplinkMessage.getMsgBody());
|
||||
|
||||
// 从Tracer总获取当前时间
|
||||
long ts = TracerContextUtil.getCurrentTracer().getTracerTs();
|
||||
|
||||
// 1.桩编号
|
||||
byte[] pileCodeBytes = new byte[7];
|
||||
byteBuf.readBytes(pileCodeBytes);
|
||||
String pileCode = BCDUtil.toString(pileCodeBytes);
|
||||
|
||||
// 2.命令执行结果 0x00失败 0x01成功
|
||||
boolean isSuccess = (byteBuf.readByte() == 0x01);
|
||||
|
||||
RestartPileResponse restartPileResponse = RestartPileResponse.newBuilder()
|
||||
.setTs(ts)
|
||||
.setPileCode(pileCode)
|
||||
.setSuccess(isSuccess)
|
||||
.build();
|
||||
|
||||
// 转发到后端
|
||||
UplinkQueueMessage uplinkQueueMessage = uplinkMessageBuilder(pileCode, tcpSession, yunKuaiChongUplinkMessage)
|
||||
.setRestartPileResponse(restartPileResponse)
|
||||
.build();
|
||||
|
||||
tcpSession.getForwarder().sendMessage(uplinkQueueMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user