Skip to content

Commit 7ca7b30

Browse files
committed
added JDK8 support and MPPSolar binding to configurator
1 parent 50ae3e7 commit 7ca7b30

File tree

51 files changed

+937
-461
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+937
-461
lines changed

bms-daly-can/src/main/java/com/airepublic/bmstoinverter/bms/daly/can/DalyBmsCANProcessor.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.nio.ByteBuffer;
1515
import java.nio.ByteOrder;
1616
import java.util.ArrayList;
17-
import java.util.HexFormat;
1817
import java.util.List;
1918

2019
import org.slf4j.Logger;
@@ -26,6 +25,7 @@
2625
import com.airepublic.bmstoinverter.core.NoDataAvailableException;
2726
import com.airepublic.bmstoinverter.core.Port;
2827
import com.airepublic.bmstoinverter.core.protocol.can.CANPort;
28+
import com.airepublic.bmstoinverter.core.util.HexUtil;
2929

3030
/**
3131
* The class to handle CAN messages from a Daly BMS.
@@ -99,7 +99,7 @@ protected List<ByteBuffer> sendMessage(final Port port, final DalyCommand cmd, f
9999
}
100100
} while (framesToBeReceived > 0 & skip > 0);
101101

102-
LOG.debug("Command 0x{} to BMS {} successfully sent and received!", HexFormat.of().toHexDigits(cmd.id), getBmsId());
102+
LOG.debug("Command 0x{} to BMS {} successfully sent and received!", HexUtil.toHexDigits(cmd.id), getBmsId());
103103
return readBuffers;
104104
}
105105

@@ -144,14 +144,15 @@ public DalyMessage convertReceiveFrameToDalyMessage(final ByteBuffer buffer) {
144144
}
145145

146146
final byte[] dataBytes = new byte[buffer.get(4)];
147-
buffer.get(8, dataBytes);
147+
buffer.position(8);
148+
buffer.get(dataBytes);
148149
msg.data = ByteBuffer.wrap(dataBytes);
149150

150151
if (LOG.isDebugEnabled()) {
151152
LOG.info("DALY Message: frameId= " + Integer.toHexString(frameId)
152-
+ ", address=" + HexFormat.of().toHexDigits(msg.bmsId)
153-
+ ", dataId=" + HexFormat.of().toHexDigits(msg.cmd.id)
154-
+ ", data=" + HexFormat.of().formatHex(dataBytes));
153+
+ ", address=" + HexUtil.toHexDigits(msg.bmsId)
154+
+ ", dataId=" + HexUtil.toHexDigits(msg.cmd.id)
155+
+ ", data=" + HexUtil.formatHex(dataBytes));
155156
}
156157

157158
return msg;

bms-daly-common/src/main/java/com/airepublic/bmstoinverter/bms/daly/common/AbstractDalyBmsProcessor.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.io.IOException;
1414
import java.nio.ByteBuffer;
1515
import java.time.LocalDateTime;
16-
import java.util.HexFormat;
1716
import java.util.List;
1817
import java.util.concurrent.ExecutorService;
1918
import java.util.concurrent.Executors;
@@ -28,6 +27,7 @@
2827
import com.airepublic.bmstoinverter.core.Port;
2928
import com.airepublic.bmstoinverter.core.TooManyInvalidFramesException;
3029
import com.airepublic.bmstoinverter.core.bms.data.BatteryPack;
30+
import com.airepublic.bmstoinverter.core.util.HexUtil;
3131

3232
import jakarta.inject.Inject;
3333

@@ -111,7 +111,7 @@ protected void autoCalibrateSOC(final Port port) {
111111
try {
112112
final Future<List<ByteBuffer>> future = executor.submit(() -> {
113113

114-
LOG.info("calibrate request (SOC " + calculatedSOC + "): " + HexFormat.of().withUpperCase().withDelimiter(", 0x").formatHex(data));
114+
LOG.info("calibrate request (SOC " + calculatedSOC + "): " + HexUtil.formatHex(data));
115115
final List<ByteBuffer> result = sendMessage(port, DalyCommand.WRITE_RTC_AND_SOC, data);
116116
LOG.info("calibrate result: " + Port.printBuffer(result.get(0)));
117117
return result;

bms-daly-rs485/src/main/java/com/airepublic/bmstoinverter/bms/daly/rs485/DalyBmsRS485Processor.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.io.IOException;
1414
import java.nio.ByteBuffer;
1515
import java.util.ArrayList;
16-
import java.util.HexFormat;
1716
import java.util.List;
1817
import java.util.function.Predicate;
1918

@@ -26,6 +25,7 @@
2625
import com.airepublic.bmstoinverter.core.NoDataAvailableException;
2726
import com.airepublic.bmstoinverter.core.Port;
2827
import com.airepublic.bmstoinverter.core.TooManyInvalidFramesException;
28+
import com.airepublic.bmstoinverter.core.util.HexUtil;
2929

3030
/**
3131
* The class to handle RS485 messages from a Daly BMS.
@@ -147,7 +147,7 @@ protected List<ByteBuffer> sendMessage(final Port port, final DalyCommand cmd, f
147147
}
148148
} while (framesToBeReceived > 0);
149149

150-
LOG.warn("Command {} to BMS {} successfully sent and received!", HexFormat.of().withPrefix("0x").formatHex(new byte[] { (byte) cmd.id }), address - 0x3F);
150+
LOG.warn("Command {} to BMS {} successfully sent and received!", HexUtil.formatHex(new byte[] { (byte) cmd.id }), address - 0x3F);
151151

152152
return readBuffers;
153153
}
@@ -192,7 +192,8 @@ protected DalyMessage convertReceiveFrameToDalyMessage(final ByteBuffer buffer)
192192
}
193193

194194
final byte[] dataBytes = new byte[8];
195-
buffer.get(4, dataBytes);
195+
buffer.position(4);
196+
buffer.get(dataBytes);
196197
msg.data = ByteBuffer.wrap(dataBytes);
197198
msg.data.rewind();
198199

bms-discover-can/pom.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>com.ai-republic.bms-to-inverter</groupId>
8+
<artifactId>bms-to-inverter-parent</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>bms-discover-can</artifactId>
13+
14+
<name>${project.artifactId}-${project.version}</name>
15+
<description>Module for the Discover BMS CAN support</description>
16+
17+
<properties>
18+
<encoding>UTF-8</encoding>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>com.ai-republic.bms-to-inverter</groupId>
25+
<artifactId>protocol-can</artifactId>
26+
<version>${project.version}</version>
27+
</dependency>
28+
</dependencies>
29+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* This software is free to use and to distribute in its unchanged form for private use.
3+
* Commercial use is prohibited without an explicit license agreement of the copyright holder.
4+
* Any changes to this software must be made solely in the project repository at https://github.com/ai-republic/bms-to-inverter.
5+
* The copyright holder is not liable for any damages in whatever form that may occur by using this software.
6+
*
7+
* (c) Copyright 2022 and onwards - Torsten Oltmanns
8+
*
9+
* @author Torsten Oltmanns - bms-to-inverter''AT''gmail.com
10+
*/
11+
package com.airepublic.bmstoinverter.bms.discover.can;
12+
13+
import com.airepublic.bmstoinverter.core.BMS;
14+
import com.airepublic.bmstoinverter.core.BMSConfig;
15+
import com.airepublic.bmstoinverter.core.BMSDescriptor;
16+
import com.airepublic.bmstoinverter.protocol.can.JavaCANPort;
17+
18+
/**
19+
* The {@link BMSDescriptor} for the Pylon LV BMS using the CAN protocol.
20+
*/
21+
public class DiscoverBmsCANDescriptor implements BMSDescriptor {
22+
@Override
23+
public String getName() {
24+
return "DISCOVER_CAN";
25+
}
26+
27+
28+
@Override
29+
public int getDefaultBaudRate() {
30+
return 500000;
31+
}
32+
33+
34+
@Override
35+
public Class<? extends BMS> getBMSClass() {
36+
return DiscoverBmsCANProcessor.class;
37+
}
38+
39+
40+
@Override
41+
public JavaCANPort createPort(final BMSConfig config) {
42+
final JavaCANPort port = new JavaCANPort(config.getPortLocator(), config.getBaudRate());
43+
return port;
44+
}
45+
46+
}

0 commit comments

Comments
 (0)