mirror of
https://gitee.com/san-bing/JChargePointProtocol
synced 2026-05-04 09:59:55 +08:00
!17 根据GBT27930解析中止原因
* Merge branch 'feat_0x1d' into develop * 删除main方法; 添加单元测试 * Merge branch 'feat_0x1d' into develop * 根据GBT27930解析中止原因
This commit is contained in:
@@ -86,10 +86,50 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
* BMS中止充电原因枚举
|
||||
*/
|
||||
public enum AbortReasonEnum {
|
||||
SOC_TARGET("需求SOC目标值"),
|
||||
TOTAL_VOLTAGE("达到总电压设定值"),
|
||||
CELL_VOLTAGE("达到单体电压设定值"),
|
||||
CHARGER_INITIATED("充电机主动中止");
|
||||
SOC_TARGET("需求SOC目标值") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "未达到所需SOC目标值";
|
||||
case 1: return "达到所需SOC目标值";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
TOTAL_VOLTAGE("达到总电压设定值") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "未达到总电压设定值";
|
||||
case 1: return "达到总电压设定值";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
CELL_VOLTAGE("达到单体电压设定值") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "未达到单体电压设定值";
|
||||
case 1: return "达到单体电压设定值";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
CHARGER_INITIATED("充电机主动中止") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "充电机主动中止正常";
|
||||
case 1: return "充电机中止(收到CST帧)";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final String description;
|
||||
|
||||
@@ -100,6 +140,8 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public abstract String getStateDescription(int state);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,26 +161,103 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
int bitPosition = reason.ordinal() * 2;
|
||||
int mask = 0b11 << bitPosition; // 创建该组的位掩码
|
||||
int groupValue = (value & mask) >>> bitPosition; // 提取组值
|
||||
|
||||
if (groupValue != 0) {
|
||||
reasons.add(reason.getDescription());
|
||||
}
|
||||
reasons.add(reason.getStateDescription(groupValue));
|
||||
}
|
||||
return Joiner.on(",").join(reasons);
|
||||
return Joiner.on(", ").join(reasons);
|
||||
}
|
||||
|
||||
/**
|
||||
* BMS中止充电故障原因枚举
|
||||
*/
|
||||
public enum FaultReasonsEnum {
|
||||
INSULATION_FAULT("绝缘故障"),
|
||||
CONNECTOR_OVERHEAT("输出连接器过温故障"),
|
||||
BMS_COMPONENT_OVERHEAT("BMS元件过温故障"),
|
||||
CHARGING_CONNECTOR_FAULT("充电连接器故障"),
|
||||
BATTERY_OVERHEAT("电池组温度过高故障"),
|
||||
HIGH_VOLTAGE_RELAY_FAULT("高压继电器故障"),
|
||||
VOLTAGE_DETECTION_FAULT("检测点2电压检测故障"),
|
||||
OTHER_FAULT("其他故障");
|
||||
INSULATION_FAULT("绝缘故障"){
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "绝缘正常";
|
||||
case 1: return "绝缘故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
CONNECTOR_OVERHEAT("输出连接器过温故障"){
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "输出连接器正常";
|
||||
case 1: return "输出连接器过温故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
BMS_COMPONENT_OVERHEAT("BMS元件过温故障") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "BMS元件正常";
|
||||
case 1: return "BMS元件过温故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
CHARGING_CONNECTOR_FAULT("充电连接器故障") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "充电连接器正常";
|
||||
case 1: return "充电连接器故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
BATTERY_OVERHEAT("电池组温度过高故障") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "电池组温度正常";
|
||||
case 1: return "电池组温度过高故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
HIGH_VOLTAGE_RELAY_FAULT("高压继电器故障") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "高压继电器正常";
|
||||
case 1: return "高压继电器故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
VOLTAGE_DETECTION_FAULT("检测点2电压检测故障") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "检测点2电压检测正常";
|
||||
case 1: return "检测点2电压检测故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
OTHER_FAULT("其他故障") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "其他正常";
|
||||
case 1: return "其他故障";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final String description;
|
||||
|
||||
@@ -149,6 +268,9 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public abstract String getStateDescription(int state);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,12 +293,9 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
int bitPosition = fault.ordinal() * 2;
|
||||
int mask = 0b11 << bitPosition; // 创建该组的位掩码
|
||||
int groupValue = (value & mask) >>> bitPosition; // 提取组值
|
||||
|
||||
if (groupValue != 0) {
|
||||
faults.add(fault.getDescription());
|
||||
}
|
||||
faults.add(fault.getStateDescription(groupValue));
|
||||
}
|
||||
return Joiner.on(",").join(faults);
|
||||
return Joiner.on(", ").join(faults);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,8 +303,28 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
*/
|
||||
@Getter
|
||||
public enum ErrorReasonsEnum {
|
||||
CURRENT_OVERFLOW("电流过大"),
|
||||
VOLTAGE_ABNORMAL("电压异常");
|
||||
CURRENT_OVERFLOW("电流过大") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "电流正常";
|
||||
case 1: return "电流超过需求值";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
},
|
||||
VOLTAGE_ABNORMAL("电压异常") {
|
||||
@Override
|
||||
public String getStateDescription(int state) {
|
||||
switch (state) {
|
||||
case 0: return "电压正常";
|
||||
case 1: return "电压异常";
|
||||
case 2: return "不可信状态";
|
||||
default: return "未知状态";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final String description;
|
||||
|
||||
@@ -193,6 +332,8 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public abstract String getStateDescription(int state);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,11 +349,9 @@ public class YunKuaiChongV150BmsAbortULCmd extends YunKuaiChongUplinkCmdExe {
|
||||
int bitPosition = error.ordinal() * 2;
|
||||
int mask = 0b11 << bitPosition;
|
||||
int groupValue = (value & mask) >>> bitPosition;
|
||||
|
||||
if (groupValue != 0) {
|
||||
errors.add(error.getDescription());
|
||||
}
|
||||
errors.add(error.getStateDescription(groupValue));
|
||||
}
|
||||
return Joiner.on(",").join(errors);
|
||||
return Joiner.on(", ").join(errors);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package sanbing.jcpp.protocol.yunkuaichong.v150;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import sanbing.jcpp.protocol.yunkuaichong.v150.cmd.YunKuaiChongV150BmsAbortULCmd;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
|
||||
public class BmsAbortULCmdTest {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
YunKuaiChongV150BmsAbortULCmd bmsAbortULCmd = new YunKuaiChongV150BmsAbortULCmd();
|
||||
|
||||
/*
|
||||
解析中止原因
|
||||
0x05 -> 00000101
|
||||
*/
|
||||
System.out.println("BMS中止充电原因: " + bmsAbortULCmd.parseAbortReasons((byte) 0x05));
|
||||
|
||||
/*
|
||||
解析故障原因
|
||||
0x0005 -> 00000000 00000101
|
||||
*/
|
||||
System.out.println("BMS中止充电故障原因: " + bmsAbortULCmd.parseFaultReasons(new byte[]{(byte)0x00, (byte)0x05}));
|
||||
|
||||
/*
|
||||
解析错误原因
|
||||
0x01 -> 00000001
|
||||
*/
|
||||
System.out.println("BMS中止充电错误原因: " + bmsAbortULCmd.parseErrorReasons((byte) 0x01));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user