Skip to content

Commit

Permalink
Merge branch 'release/2024.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Feb 1, 2024
2 parents 29e0231 + a139e55 commit 3e1cc29
Show file tree
Hide file tree
Showing 310 changed files with 4,075 additions and 1,576 deletions.
35 changes: 14 additions & 21 deletions cnf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.5.1</version>
<version>2.9.3</version>
</dependency>
<dependency>
<groupId>com.ghgande</groupId>
<artifactId>j2mod</artifactId>
<version>2.5.5</version>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.github.rzymek</groupId>
Expand Down Expand Up @@ -98,19 +98,6 @@
<artifactId>HikariCP</artifactId>
<version>5.1.0</version>
</dependency>
<!-- commons -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<!-- Apache Commons IO is a library of utilities to assist with developing IO functionality. -->
<!-- Changelog: https://commons.apache.org/proper/commons-io/changes-report.html -->
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.15.1</version>
</dependency>
<!-- de -->
<dependency>
<!-- PgBulkInsert is a Java library for Bulk Inserts to PostgreSQL using the Binary COPY Protocol. -->
Expand Down Expand Up @@ -142,7 +129,7 @@
<dependency>
<groupId>fr.turri</groupId>
<artifactId>aXMLRPC</artifactId>
<version>1.13.0</version>
<version>1.14.0</version>
</dependency>
<!-- info -->
<dependency>
Expand Down Expand Up @@ -215,7 +202,7 @@
<!-- Changelog: https://github.com/apache/felix-dev/commits/master/http -->
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.jetty</artifactId>
<version>5.1.6</version>
<version>5.1.8</version>
</dependency>
<dependency>
<!-- Apache Felix Servlet API -->
Expand All @@ -242,14 +229,14 @@
<!-- Changelog: https://github.com/apache/felix-dev/blob/master/scr/changelog.txt -->
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr</artifactId>
<version>2.2.6</version>
<version>2.2.10</version>
</dependency>
<dependency>
<!-- Apache Felix Web Management Console -->
<!-- Changelog: https://github.com/apache/felix-dev/blob/master/webconsole/README.md#releases -->
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.webconsole</artifactId>
<version>4.9.6</version>
<version>5.0.0</version>
</dependency>
<dependency>
<!-- Apache Felix Web Console Service Component Runtime/Declarative Services Plugin -->
Expand All @@ -263,10 +250,16 @@
<artifactId>org.apache.servicemix.bundles.junit</artifactId>
<version>4.13.2_1</version>
</dependency>
<dependency>
<!-- Bouncycastle for Eclipse Paho MQTTv5 Client -->
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.70</version>
</dependency>
<dependency>
<groupId>org.dhatim</groupId>
<artifactId>fastexcel</artifactId>
<version>0.16.5</version>
<version>0.16.6</version>
</dependency>
<dependency>
<!-- Eclipse Paho MQTTv5 Client -->
Expand Down Expand Up @@ -313,7 +306,7 @@
<!-- HTML processing -->
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.17.1</version>
<version>1.17.2</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
Expand Down
6 changes: 4 additions & 2 deletions doc/modules/ROOT/pages/backend/backend-to-backend.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NOTE: Properties `id` and `jsonrpc` can be omitted for JSON/REST, as they are no

=== GetEdgesStatus

Lists the current status of all accessible Edges.
Lists the current status of Edges.

==== Request
[source,json]
Expand All @@ -49,7 +49,9 @@ Lists the current status of all accessible Edges.
"jsonrpc":"2.0",
"id":"UUID",
"method":"getEdgesStatus",
"params":{}
"params":{
"edgeIds: ["edge0", "edge1"]
}
}
----

Expand Down
4 changes: 2 additions & 2 deletions doc/modules/ROOT/pages/edge/implement.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ NOTE: Most Modbus function codes are available by their respective _FC*_ impleme
- For more advanced channel-to-element mapping functionalities the internal *cm()* method can be used - e.g. to map one Modbus element to multiple Channels.
+
Using this principle a complete Modbus table consisting of multiple register blocks that need to be read or written with different Modbus function codes can be defined. For details have a look at the existing implementation classes inside the Modbus Bridge source code.
====
<17> The ElectricityMeter Nature requires us to provide a *MeterType* via a `MeterType getMeterType()` method. The MeterType is provided by the Config.
<18> Finally it is always a good idea to define a *debugLog()* method. This method is called in each cycle by the *Controller.Debug.Log* and very helpful for continuous debugging.
====

=== JUnit tests

Expand Down Expand Up @@ -508,7 +508,7 @@ Select the `io.openems.edge.meter.simulated` bundle in the left *Repositories* l

Press btn:[Ctrl] + btn:[s] to save the `EdgeApp.bndrun` file.

Click on btn:[Resolve] to update the list of bundles that are required to run OpenEMS Edge. After a few seconds the *Resolution Results* window should appear; acknowledge by pressing btn:[Finish].
Click on btn:[Resolve] to update the list of bundles that are required to run OpenEMS Edge. After a few seconds the *Resolution Results* window should appear; acknowledge by pressing btn:[Update].

.Eclipse IDE Resolve EdgeApp.bndrun
image::eclipse-edgeapp-resolve.png[Eclipse IDE Resolve EdgeApp.bndrun]
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/gettingstarted.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ image::eclipse-io.openems.edge.application.png[io.openems.edge.application proje
+
NOTE: Instead of navigating through the projects tree, you can simply use the keyboard shortcut btn:[Ctrl] + btn:[Shift] + btn:[R] to start the "Open Resource" dialog. Enter "EdgeApp.bndrun" there and press btn:[Enter] to open the file.
+
The `EdgeApp.bndrun` file declares all the bundles and runtime properties. For now it should not be necessary to edit it, but it hides some useful settings unter the btn:[Source] tab:
The `EdgeApp.bndrun` file declares all the bundles and runtime properties. For now it should not be necessary to edit it, but it hides some useful settings under the btn:[Source] tab:
+
- `org.osgi.service.http.port=8080`: start the Apache Felix Web Console on port `8080`
- `felix.cm.dir=c:/openems/config`: persist configurations in the folder `c:/openems/config`. Adjust this if you are working on Linux to keep your configurations after restart
Expand Down
8 changes: 3 additions & 5 deletions io.openems.backend.application/BackendApp.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,15 @@
io.openems.wrapper.retrofit2;version=snapshot,\
io.reactivex.rxjava3.rxjava;version='[3.1.8,3.1.9)',\
org.apache.commons.commons-csv;version='[1.10.0,1.10.1)',\
org.apache.commons.commons-fileupload;version='[1.5.0,1.5.1)',\
org.apache.commons.commons-io;version='[2.15.1,2.15.2)',\
org.apache.felix.configadmin;version='[1.9.26,1.9.27)',\
org.apache.felix.eventadmin;version='[1.6.4,1.6.5)',\
org.apache.felix.fileinstall;version='[3.7.4,3.7.5)',\
org.apache.felix.http.jetty;version='[5.1.6,5.1.7)',\
org.apache.felix.http.jetty;version='[5.1.8,5.1.9)',\
org.apache.felix.http.servlet-api;version='[3.0.0,3.0.1)',\
org.apache.felix.inventory;version='[2.0.0,2.0.1)',\
org.apache.felix.metatype;version='[1.2.4,1.2.5)',\
org.apache.felix.scr;version='[2.2.6,2.2.7)',\
org.apache.felix.webconsole;version='[4.9.6,4.9.7)',\
org.apache.felix.scr;version='[2.2.10,2.2.11)',\
org.apache.felix.webconsole;version='[5.0.0,5.0.1)',\
org.apache.felix.webconsole.plugins.ds;version='[2.3.0,2.3.1)',\
org.jetbrains.kotlin.osgi-bundle;version='[1.9.22,1.9.23)',\
org.jsr-305;version='[3.0.2,3.0.3)',\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.openems.backend.b2bwebsocket;

import java.util.HashMap;
import static java.util.stream.Collectors.toUnmodifiableMap;

import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
Expand Down Expand Up @@ -132,18 +133,24 @@ public String getId() {

@Override
public String debugLog() {
return "[" + this.getName() + "] " + this.server.debugLog();
return new StringBuilder() //
.append("[").append(this.getName()).append("] ") //
.append(this.server != null //
? this.server.debugLog() //
: "NOT STARTED") //
.toString();
}

@Override
public Map<String, JsonElement> debugMetrics() {
final var metrics = new HashMap<String, JsonElement>();

this.server.debugMetrics().forEach((key, value) -> {
metrics.put(this.getId() + "/" + key, new JsonPrimitive(value));
});
if (this.server == null) {
return null;
}

return metrics;
return this.server.debugMetrics().entrySet().stream() //
.collect(toUnmodifiableMap(//
e -> this.getId() + "/" + e.getKey(), //
e -> new JsonPrimitive(e.getValue())));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public CompletableFuture<? extends JsonrpcResponseSuccess> run(WebSocket ws, Jso
*/
private CompletableFuture<GenericJsonrpcResponseSuccess> handleSubscribeEdgesChannelsRequest(WsData wsData,
User user, UUID messageId, SubscribeEdgesChannelsRequest request) throws OpenemsNamedException {
for (String edgeId : request.getEdgeIds()) {
for (var edgeId : request.getEdgeIds()) {
if (user.getRole(edgeId).isEmpty()) {
this.parent.metadata.getEdgeMetadataForUser(user, edgeId);
}

// assure read permissions of this User for this Edge.
user.assertEdgeRoleIsAtLeast(SubscribeEdgesChannelsRequest.METHOD, edgeId, Role.GUEST);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,38 @@
import io.openems.backend.common.jsonrpc.request.GetEdgesChannelsValuesRequest;
import io.openems.backend.common.jsonrpc.request.GetEdgesStatusRequest;
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.common.jsonrpc.request.EdgeRpcRequest;
import io.openems.common.jsonrpc.request.GetEdgeConfigRequest;
import io.openems.common.jsonrpc.request.SetGridConnScheduleRequest;
import io.openems.common.jsonrpc.request.SetGridConnScheduleRequest.GridConnSchedule;
import io.openems.common.types.ChannelAddress;

/**
* This Test demonstrates the usage of the OpenEMS Backend-to-Backend API
* interface. To start the tests make sure to start OpenEMS Backend and activate
* the B2bWebsocket component via Apache Felix. Afterwards uncomment the "@Test"
* annotations below and execute the Tests.
* the B2bWebsocket component via Apache Felix. Afterwards run this App via
* main().
*/
public class B2bWebsocketTest {

private static final String URI = "ws://localhost:8076";
private static final String USERNAME = "user";
private static final String PASSWORD = "password";

/**
* Main.
*
* @param args the args
* @throws Exception on error
*/
public static void main(String[] args) throws Exception {
getEdgesStatusRequest();
getEdgeConfigRequest();
getEdgesChannelsValuesRequest();
subscribeEdgesChannelsRequest();
setGridConnSchedule();
}

private static TestClient prepareTestClient() throws URISyntaxException, InterruptedException {
Map<String, String> httpHeaders = new HashMap<>();
var auth = new String(
Expand All @@ -39,12 +55,23 @@ private static TestClient prepareTestClient() throws URISyntaxException, Interru
return client;
}

// @Test
protected void testGetEdgesStatusRequest()
throws URISyntaxException, InterruptedException, ExecutionException, OpenemsNamedException {
private static void getEdgesStatusRequest() throws Exception {
var client = B2bWebsocketTest.prepareTestClient();

var request = new GetEdgesStatusRequest("edge0");
try {
var responseFuture = client.sendRequest(request);
System.out.println(responseFuture.get().toString());
} catch (InterruptedException | ExecutionException | OpenemsNamedException e) {
System.out.println(e.getMessage());
}
client.stop();
}

private static void getEdgeConfigRequest() throws Exception {
var client = B2bWebsocketTest.prepareTestClient();

var request = new GetEdgesStatusRequest();
var request = new EdgeRpcRequest("edge0", new GetEdgeConfigRequest());
try {
var responseFuture = client.sendRequest(request);
System.out.println(responseFuture.get().toString());
Expand All @@ -54,8 +81,7 @@ protected void testGetEdgesStatusRequest()
client.stop();
}

// @Test
protected void testGetEdgesChannelsValuesRequest() throws URISyntaxException, InterruptedException {
private static void getEdgesChannelsValuesRequest() throws Exception {
var client = B2bWebsocketTest.prepareTestClient();

var request = new GetEdgesChannelsValuesRequest();
Expand All @@ -71,9 +97,7 @@ protected void testGetEdgesChannelsValuesRequest() throws URISyntaxException, In
client.stop();
}

// @Test
protected void testSubscribeEdgesChannelsRequest()
throws URISyntaxException, InterruptedException, ExecutionException, OpenemsNamedException {
private static void subscribeEdgesChannelsRequest() throws Exception {
var client = B2bWebsocketTest.prepareTestClient();
client.setOnNotification((ws, notification) -> {
System.out.println(notification.toString());
Expand All @@ -94,8 +118,7 @@ protected void testSubscribeEdgesChannelsRequest()
client.stop();
}

// @Test
protected void testSetGridConnSchedule() throws URISyntaxException, InterruptedException {
private static void setGridConnSchedule() throws Exception {
var client = B2bWebsocketTest.prepareTestClient();

var request = new SetGridConnScheduleRequest("edge0");
Expand All @@ -108,5 +131,6 @@ protected void testSetGridConnSchedule() throws URISyntaxException, InterruptedE
} catch (InterruptedException | ExecutionException | OpenemsNamedException e) {
System.out.println(e.getMessage());
}
client.stop();
}
}
Loading

0 comments on commit 3e1cc29

Please sign in to comment.