Commit 38eee007 by chenxi

实现功能:读取实时检测数据

1 parent cc8203c8
...@@ -2,6 +2,7 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base; ...@@ -2,6 +2,7 @@ package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base;
import java.util.Map; import java.util.Map;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.realtime.data.UploadRealTimeDataHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingReqHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingRspHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.param.ParamSettingRspHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.time.TimeSettingReqHandler; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.time.TimeSettingReqHandler;
...@@ -55,6 +56,8 @@ public final class TcpMapper { ...@@ -55,6 +56,8 @@ public final class TcpMapper {
public static TcpMapper CMD_RSP_MODEL_CHARGING = regist(0x0A, "计费模型请求应答", null); public static TcpMapper CMD_RSP_MODEL_CHARGING = regist(0x0A, "计费模型请求应答", null);
public static TcpMapper CMD_REQ_UPLOAD_REAL_TIME_DATA = regist(0x13, "读取实时检测数据", UploadRealTimeDataHandler.class);
// public static TcpMapper CMD_NOTIFY_TIME = regist(0x56, "对时设置", TimeNotifyHandler.class); // public static TcpMapper CMD_NOTIFY_TIME = regist(0x56, "对时设置", TimeNotifyHandler.class);
// 运营交互帧类型码数据定义 0x31~0x47 // 运营交互帧类型码数据定义 0x31~0x47
......
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.base;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpData;
import lombok.Getter;
import lombok.Setter;
/**
* 包含字段抓昂编号、枪号、状态
*
* @author chenxi
* @date 2023年12月1日 下午6:00:39
*/
@Getter
@Setter
public class BaseReq extends TcpData {
/**
* 交易流水号
* 数据类型:byte[] (BCD码)
* 长度(Byte):16
* 备注:
*/
private byte[] transactionSerialNumber = new byte[16];
/**
* 桩编号
* 数据类型:byte[] (BCD码)
* 长度(Byte):7
* 备注:不足7位补0
*/
private byte[] pileNumber = new byte[7];
/**
* 枪号
* 数据类型:byte[] (BCD码)
* 长度(Byte):1
* 备注:
*/
private byte gunNumber;
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.realtime;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.base.BaseReq;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* 上传实时监测数据
* 68 (起始标志) 40 (数据长度) 1A03 (序列号域) 00 (加密标志) 13 (类型)
* 00000000000000000000000000000000(交易流水号)55031412782305(桩编码)01(枪号:1
* 号枪)00(状态:离线)01(是否归位:已归位)01(是否插枪:是)0200(输出电压:0)0000
* (输出电流:0)00(枪线温度:10)0000000000000000(枪线编码)00(soc:0)00(电池组
* 最高温度:0)00 00(累计充电时间:0)00 00(剩余时间:0)00 00 00 00(充电度数:0)
* 00 00 00 00(计损充电度数:0)00 00 00 00(已充金额:0)0000(硬件故障:无)9DAC(帧
* 校验域)
*
* @author chenxi
* @date 2023年12月1日 下午6:00:39
*/
@Getter
@Setter
@ToString
public class RealTimeData extends BaseReq {
/**
* 状态 BIN 码
* 0x00:离线
* 0x01:故障
* 0x02:空闲
* 0x03:充电
*/
private byte status;
/**
* 枪是否归位
* 0x00 否
* 0x01 是
* 0x02 未知
* 无法检测到枪是否插回枪座即未知
*/
private byte ifReturn;
/**
* 是否插枪 BIN 码
* 0x00 否
* 0x01 是
* 需做到变位上送
*/
private byte ifCharging;
/**
* 输出电压 BIN 码
* 精确到小数点后一位;待机置零
*/
private byte[] outputVoltage = new byte[2];
/**
* 输出电流 BIN 码
* 精确到小数点后一位;待机置零
*/
private byte[] outputCurrent = new byte[2];
/**
* 枪线温度 BIN 码
* 整形,偏移量-50;待机置零
*/
private byte gunWireTemperature;
/**
* 枪线编码 BIN 码
* 没有置零
*/
private byte[] gunWireNumber = new byte[8];
/**
* SOC BIN 码
* 待机置零;交流桩置零
*/
private byte soc;
/**
* 电池组最高温度 BIN 码
* 整形,偏移量-50 ºC;待机置零;
* 交流桩置零
*/
private byte batteryHighestTemperature;
/**
* 累计充电时间 BIN 码
* 单位:min;待机置零
*/
private byte[] accumulatedChargingTime = new byte[2];
/**
* 剩余时间 BIN 码
* 单位:min;待机置零、交流桩置
* 零
*/
private byte[] timeLeft = new byte[2];
/**
* 充电度数 BIN 码
* 精确到小数点后四位;待机置零
*
*/
private byte[] chargingDegree = new byte[4];
/**
* 计损度数 BIN 码
* 精确到小数点后四位;待机置零,未设置计损比例时等于充电度数
*
*/
private byte[] lossChargingDegree = new byte[4];
/**
* 已充金额 BIN 码
* 精确到小数点后四位;待机置零(电费+服务费)*计损充电度数
*
*/
private byte[] chargingMoney = new byte[4];
/**
* 硬件故障 BIN 码
* Bit 位表示(0 否 1 是),低位到高位顺序
* Bit1:急停按钮动作故障;
* Bit2:无可用整流模块;
* Bit3:出风口温度过高;
* Bit4:交流防雷故障;
* Bit5:交直流模块 DC20 通信中
* 断;
* Bit6:绝缘检测模块 FC08 通信中
* 断;
* Bit7:电度表通信中断;
* Bit8:读卡器通信中断;
* Bit9:RC10 通信中断;
* Bit10:风扇调速板故障;
* Bit11:直流熔断器故障;
* Bit12:高压接触器故障;
* Bit13:门打开;
*
*/
private byte[] hardwareMalfunction = new byte[2];
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.handler.realtime.data;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpHandler;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.UploadRealtimeDataReq;
import io.netty.channel.Channel;
/**
* 充电桩上传实时检测数据handler
*
* @author chenxi
* @date 2023年11月7日 上午10:19:34
*/
public class UploadRealTimeDataHandler implements TcpHandler<UploadRealtimeDataReq, UploadRealtimeDataReq> {
@Override
public UploadRealtimeDataReq handle(Channel channel, UploadRealtimeDataReq notify) {
log.info("实时检测数据:{}", notify.getData());
return null;
}
}
package cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpMapper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.realtime.RealTimeData;
/**
* @author 读取实时检测数据
* @date 2023年11月7日 下午2:48:32
*/
public class UploadRealtimeDataReq extends TcpReq<RealTimeData> {
public UploadRealtimeDataReq() {
super(TcpMapper.CMD_REQ_UPLOAD_REAL_TIME_DATA.getType());
}
}
package cn.com.glsx.charging.gbt.ocpp16;
import cn.com.glsx.charging.modules.gbt.ocpp16.ClientMain;
import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.client.TcpClient;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.login.ModelValReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.realtime.RealTimeData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.ModelValReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.login.UploadRealtimeDataReq;
/**
* 读取实时检测数据
*/
public class UploadRealTimeDataTest {
public static void main(String[] args) throws Exception {
Ocpp16Helper.scan();
String host = "localhost";
int port = 8888;
TcpClient client = ClientMain.getInstance(host, port);
Thread.sleep(3000);
UploadRealtimeDataReq req = new UploadRealtimeDataReq();
RealTimeData data = new RealTimeData();
data.setTransactionSerialNumber(Ocpp16Helper.strToBcd("00000000000000000000000000000000", data.getTransactionSerialNumber()));
data.setPileNumber(Ocpp16Helper.strToBcd("55031412782305",data.getPileNumber()));
data.setGunNumber((byte)1);
data.setStatus((byte)0);
data.setIfReturn((byte)1);
data.setIfCharging((byte)1);
byte[] outputVoltage = new byte[]{(byte) 0x02, 0x00};
data.setOutputVoltage(outputVoltage);
byte[] outputCurrent = new byte[]{(byte) 0x00, 0x00};
data.setOutputCurrent(outputCurrent);
data.setGunWireTemperature((byte)0);
byte[] gunWireNumber = new byte[]{(byte) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
data.setGunWireNumber(gunWireNumber);
data.setSoc((byte)0);
data.setBatteryHighestTemperature((byte)0);
data.setAccumulatedChargingTime(outputCurrent);
data.setTimeLeft(outputCurrent);
byte[] chargingDegree = new byte[]{(byte) 0x00, 0x00, 0x00, 0x00};
data.setChargingDegree(chargingDegree);
data.setLossChargingDegree(chargingDegree);
data.setChargingMoney(chargingDegree);
data.setHardwareMalfunction(outputCurrent);
req.setData(data);
client.sendSync(req);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!