Skip to content

Commit

Permalink
Merge branch 'release/2020.21.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Oct 8, 2020
2 parents b759493 + b28b2c7 commit 1abc495
Show file tree
Hide file tree
Showing 190 changed files with 6,920 additions and 5,001 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ matrix:
jdk:
- openjdk8
script:
- ./gradlew build -x test
- ./gradlew build
- ./gradlew buildAggregatedJavadocs --continue
- ./gradlew buildAntoraDocs --continue
deploy:
Expand Down
4 changes: 2 additions & 2 deletions cnf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
<!-- Changelog: https://github.com/apache/felix-dev/commits/master/http -->
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.http.jetty</artifactId>
<version>4.0.20</version>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
Expand Down Expand Up @@ -197,7 +197,7 @@
<dependency>
<groupId>org.msgpack</groupId>
<artifactId>msgpack-core</artifactId>
<version>0.8.20</version>
<version>0.8.21</version>
</dependency>
<dependency>
<groupId>org.openmuc</groupId>
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/pages/single_document.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
= OpenEMS - Open Energy Management System
ifndef::toc[]
(c) 2020 OpenEMS Association e.V.
Version 2020.20.0
Version 2020.21.0
:sectnums:
:sectnumlevels: 4
:toc:
Expand Down
2 changes: 1 addition & 1 deletion io.openems.backend.application/BackendApp.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
org.apache.commons.commons-fileupload;version='[1.4.0,1.4.1)',\
org.apache.commons.io;version='[2.6.0,2.6.1)',\
org.apache.felix.configadmin;version='[1.9.18,1.9.19)',\
org.apache.felix.http.jetty;version='[4.0.20,4.0.21)',\
org.apache.felix.http.jetty;version='[4.1.0,4.1.1)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.inventory;version='[1.0.6,1.0.7)',\
org.apache.felix.metatype;version='[1.2.2,1.2.3)',\
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
eclipse.preferences.version=1
encoding//test/io/openems/backend/metadata/file/provider/FileTest.java=UTF-8
encoding/bnd.bnd=UTF-8
encoding/readme.md=UTF-8

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package $basePackageName$;

import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {

protected static class Builder {
private String id;
// private String setting0;

private Builder() {
}

public Builder setId(String id) {
this.id = id;
return this;
}

// public Builder setSetting0(String setting0) {
// this.setting0 = setting0;
// return this;
// }

public MyConfig build() {
return new MyConfig(this);
}
}

/**
* Create a Config builder.
*
* @return a {@link Builder}
*/
public static Builder create() {
return new Builder();
}

private final Builder builder;

private MyConfig(Builder builder) {
super(Config.class, builder.id);
this.builder = builder;
}

// @Override
// public String setting0() {
// return this.builder.setting0;
// }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package $basePackageName$;

import org.junit.Test;

import io.openems.edge.common.test.AbstractComponentTest.TestCase;
import io.openems.edge.controller.test.ControllerTest;

public class MyControllerTest {

private static final String CTRL_ID = "ctrl0";

@Test
private void test() throws Exception {
new ControllerTest(new MyController()) //
.activate(MyConfig.create() //
.setId(CTRL_ID) //
.build())
.next(new TestCase());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package $basePackageName$;

import io.openems.common.utils.ConfigUtils;
import io.openems.edge.batteryinverter.kaco.blueplanetgridsave.MyConfig.Builder;
import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {

protected static class Builder {
private String id;
private String modbusId = null;

private Builder() {
}

public Builder setId(String id) {
this.id = id;
return this;
}

public Builder setModbusId(String modbusId) {
this.modbusId = modbusId;
return this;
}

public MyConfig build() {
return new MyConfig(this);
}
}

/**
* Create a Config builder.
*
* @return a {@link Builder}
*/
public static Builder create() {
return new Builder();
}

private final Builder builder;

private MyConfig(Builder builder) {
super(Config.class, builder.id);
this.builder = builder;
}

@Override
public String modbus_id() {
return this.builder.modbusId;
}

@Override
public String Modbus_target() {
return ConfigUtils.generateReferenceTargetFilter(this.id(), this.modbus_id());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package $basePackageName$;

import org.junit.Test;

import io.openems.edge.common.test.AbstractComponentTest.TestCase;
import io.openems.common.types.ChannelAddress;
import io.openems.edge.batteryinverter.kaco.blueplanetgridsave.KacoSunSpecModel;
import io.openems.edge.bridge.modbus.test.DummyModbusBridge;
import io.openems.edge.common.test.ComponentTest;

public class MyModbusDeviceTest {

private static final String COMPONENT_ID = "component0";

private static final String MODBUS_ID = "modbus0";

@Test
private void test() throws Exception {
new ComponentTest(new MyModbusDevice()) //
.addReference("setModbus", new DummyModbusBridge(MODBUS_ID)) //
.activate(MyConfig.create() //
.setId(COMPONENT_ID) //
.setModbusId(MODBUS_ID) //
.build())
.next(new TestCase());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package $basePackageName$;

import io.openems.edge.common.test.AbstractComponentConfig;

@SuppressWarnings("all")
public class MyConfig extends AbstractComponentConfig implements Config {

protected static class Builder {
private String id;
// private String setting0;

private Builder() {
}

public Builder setId(String id) {
this.id = id;
return this;
}

// public Builder setSetting0(String setting0) {
// this.setting0 = setting0;
// return this;
// }

public MyConfig build() {
return new MyConfig(this);
}
}

/**
* Create a Config builder.
*
* @return a {@link Builder}
*/
public static Builder create() {
return new Builder();
}

private final Builder builder;

private MyConfig(Builder builder) {
super(Config.class, builder.id);
this.builder = builder;
}

// @Override
// public String setting0() {
// return this.builder.setting0;
// }

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package $basePackageName$;

import org.junit.Test;

import io.openems.edge.common.test.AbstractComponentTest.TestCase;
import io.openems.edge.common.test.ComponentTest;

public class MyDeviceTest {

private static final String COMPONENT_ID = "component0";

@Test
private void test() throws Exception {
new ComponentTest(new MyDevice()) //
.activate(MyConfig.create() //
.setId(COMPONENT_ID) //
.build())
.next(new TestCase());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class OpenemsConstants {
*
* This is usually the number of the sprint within the year
*/
public final static short VERSION_MINOR = 20;
public final static short VERSION_MINOR = 21;

/**
* The patch version of OpenEMS.
Expand Down
53 changes: 53 additions & 0 deletions io.openems.common/src/io/openems/common/utils/ConfigUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.openems.common.utils;

public class ConfigUtils {

private ConfigUtils() {
}

/**
* Generates a target filter for a Declarative Service @Reference member.
*
* <p>
* Usage:
*
* <pre>
* generateReferenceTargetFilter(config.service_pid(), "Controllers", controllersIds);
* </pre>
*
* <p>
* Generates a 'target' filter on the 'Controllers' member so, that the the
* expected service to be injected needs to fulfill:
* <ul>
* <li>the service must be enabled
* <li>the service must not have the same PID as the calling component
* <li>the service "id" must be one of the provided "ids"
* </ul>
*
* @param pid PID of the calling component (use 'config.service_pid()' or
* '(String)prop.get(Constants.SERVICE_PID)'; if null, PID filter is
* not added to the resulting target filter
* @param ids Component IDs to be filtered for; for empty list, no ids are added
* to the target filter
* @return the target filter
*/
public static String generateReferenceTargetFilter(String pid, String... ids) {
// target component must be enabled
StringBuilder targetBuilder = new StringBuilder("(&(enabled=true)");
if (pid != null && !pid.isEmpty()) {
// target component must not be the same as the calling component
targetBuilder.append("(!(service.pid=" + pid + "))");
}
// add filter for given Component-IDs
if (ids.length > 0) {
targetBuilder.append("(|");
for (String id : ids) {
targetBuilder.append("(id=" + id + ")");
}
targetBuilder.append(")");
}
targetBuilder.append(")");
return targetBuilder.toString();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package io.openems.common.utils;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class ConfigUtilsTest {

private static final String PID = "Abc.Def.12345";

private static final String CTRL0_ID = "ctrl0";
private static final String CTRL1_ID = "ctrl1";

@Test
public void testGenerateReferenceTargetFilter() {
assertEquals(//
"(&(enabled=true)(!(service.pid=" + PID + "))(|(id=" + CTRL0_ID + ")))", //
ConfigUtils.generateReferenceTargetFilter(PID, CTRL0_ID));

assertEquals(//
"(&(enabled=true)(!(service.pid=" + PID + "))(|(id=" + CTRL0_ID + ")(id=" + CTRL1_ID + ")))", //
ConfigUtils.generateReferenceTargetFilter(PID, CTRL0_ID, CTRL1_ID));

assertEquals(//
"(&(enabled=true))", //
ConfigUtils.generateReferenceTargetFilter(null));

assertEquals(//
"(&(enabled=true)(!(service.pid=" + PID + ")))", //
ConfigUtils.generateReferenceTargetFilter(PID));

assertEquals(//
"(&(enabled=true)(|(id=" + CTRL0_ID + ")))", //
ConfigUtils.generateReferenceTargetFilter(null, CTRL0_ID));
}

}
Loading

0 comments on commit 1abc495

Please sign in to comment.