Skip to content

Commit

Permalink
fixed rated capacity and rated mV on Daly binding and error messages on
Browse files Browse the repository at this point in the history
Solis binding
  • Loading branch information
ai-republic committed Dec 28, 2024
1 parent 70c6b53 commit 06910d2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ private void getBatteryTypeInfo(final DalyMessage msg, final BMS bms) {
private void getRatedCapacityAndCellVoltage(final DalyMessage msg, final BMS bms) {
final BatteryPack battery = bms.getBatteryPack(BATTERY_ID);

battery.ratedCellmV = msg.data.getInt(); // in mV
battery.ratedCapacitymAh = msg.data.getInt(); // in mAh
battery.ratedCellmV = msg.data.getInt(); // in mV

LOG.debug("ratedCellmV={}, ratedCapacitymAh={}", battery.ratedCellmV, battery.ratedCapacitymAh);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private List<ByteBuffer> sendEquipmentInformation(final BatteryPack pack) throws
// 0x7310
sendFrames.add(sendHardwareSoftwareVersion(pack));
// 0x7320
sendFrames.add(sendBatterModuleInfo(pack));
sendFrames.add(sendBatteryModuleInfo(pack));
// 0x7340
sendFrames.addAll(sendManufacturer(pack));

Expand Down Expand Up @@ -243,11 +243,11 @@ private ByteBuffer sendAlarms(final BatteryPack pack) throws IOException {

// Error
byte error = 0x00;
error = BitUtil.setBit(error, 0, pack.getAlarmLevel(Alarm.FAILURE_SENSOR_PACK_VOLTAGE) != AlarmLevel.NONE);
error = BitUtil.setBit(error, 1, pack.getAlarmLevel(Alarm.FAILURE_SENSOR_PACK_TEMPERATURE) != AlarmLevel.NONE);
error = BitUtil.setBit(error, 2, pack.getAlarmLevel(Alarm.FAILURE_COMMUNICATION_INTERNAL) != AlarmLevel.NONE);
error = BitUtil.setBit(error, 3, pack.getAlarmLevel(Alarm.FAILURE_CHARGE_BREAKER) != AlarmLevel.NONE);
error = BitUtil.setBit(error, 7, pack.getAlarmLevel(Alarm.FAILURE_OTHER) != AlarmLevel.NONE);
error = BitUtil.setBit(error, 0, pack.getAlarmLevel(Alarm.FAILURE_SENSOR_PACK_VOLTAGE) == AlarmLevel.ALARM);
error = BitUtil.setBit(error, 1, pack.getAlarmLevel(Alarm.FAILURE_SENSOR_PACK_TEMPERATURE) == AlarmLevel.ALARM);
error = BitUtil.setBit(error, 2, pack.getAlarmLevel(Alarm.FAILURE_COMMUNICATION_INTERNAL) == AlarmLevel.ALARM);
error = BitUtil.setBit(error, 3, pack.getAlarmLevel(Alarm.FAILURE_CHARGE_BREAKER) == AlarmLevel.ALARM);
error = BitUtil.setBit(error, 7, pack.getAlarmLevel(Alarm.FAILURE_OTHER) == AlarmLevel.ALARM);

frame.put(error);

Expand Down Expand Up @@ -397,19 +397,28 @@ private ByteBuffer sendHardwareSoftwareVersion(final BatteryPack pack) throws IO


// 0x7320
private ByteBuffer sendBatterModuleInfo(final BatteryPack pack) throws IOException {
private ByteBuffer sendBatteryModuleInfo(final BatteryPack pack) throws IOException {
final ByteBuffer frame = prepareSendFrame(0x00007320);

// battery module quantity
frame.putShort((short) pack.numberOfCells);
frame.putChar((char) pack.numberOfCells);
// battery modules in series
frame.put((byte) pack.modulesInSeries);
// cell quantity in battery module
frame.put(pack.moduleNumberOfCells);
// battery cabinet voltage level (1V)
frame.putShort((short) pack.moduleVoltage);
frame.putChar((char) pack.moduleVoltage);
// battery cabinet AH (1AH)
frame.putShort((short) pack.moduleRatedCapacityAh);
int totalCapacityAH = pack.moduleRatedCapacityAh;

if (totalCapacityAH == 0) {
// collect all the rated mAH capacity of each pack
totalCapacityAH = getEnergyStorage().getBatteryPacks().stream().map(battery -> battery.ratedCapacitymAh).reduce((result, ratedmAH) -> result += ratedmAH).orElse(0);
// convert from mAH to AH
totalCapacityAH = totalCapacityAH / 1000;
}

frame.putChar((char) totalCapacityAH);

LOG.debug("Sending battery module info: {}", Port.printBuffer(frame));
return frame;
Expand Down

0 comments on commit 06910d2

Please sign in to comment.