Skip to content

Commit

Permalink
Merge branch 'release/2020.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Jan 2, 2020
2 parents c534563 + f10e7fc commit 6f019ea
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 534 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -54,14 +54,14 @@ OpenEMS is funded by several federal and EU funding projects. If you are a devel
* OpenEMS Edge
* OpenEMS Backend

Copyright (C) 2016-2019 FENECON GmbH.
Copyright (C) 2016-2020 FENECON GmbH.

This product includes software developed at FENECON GmbH: you can
redistribute it and/or modify it under the terms of the [Eclipse Public License version 2.0](LICENSE-EPL-2.0).

* OpenEMS UI

Copyright (C) 2016-2019 FENECON GmbH.
Copyright (C) 2016-2020 FENECON GmbH.

This product includes software developed at FENECON GmbH: you can
redistribute it and/or modify it under the terms of the [GNU Affero General Public License version 3](LICENSE-AGPL-3.0).
2 changes: 1 addition & 1 deletion cnf/pom.xml
Expand Up @@ -34,7 +34,7 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
<version>28.2-jre</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
4 changes: 2 additions & 2 deletions doc/modules/ROOT/pages/introduction.adoc
Expand Up @@ -65,14 +65,14 @@ OpenEMS is funded by several federal and EU funding projects. If you are a devel
* OpenEMS Edge
* OpenEMS Backend

Copyright (C) 2016-2019 FENECON GmbH.
Copyright (C) 2016-2020 FENECON GmbH.

This product includes software developed at FENECON GmbH: you can
redistribute it and/or modify it under the terms of the https://github.com/OpenEMS/openems/blob/develop/LICENSE-EPL-2.0[Eclipse Public License version 2.0].

* OpenEMS UI

Copyright (C) 2016-2019 FENECON GmbH.
Copyright (C) 2016-2020 FENECON GmbH.

This product includes software developed at FENECON GmbH: you can
redistribute it and/or modify it under the terms of the https://github.com/OpenEMS/openems/blob/develop/LICENSE-AGPL-3.0[GNU Affero General Public License version 3].
4 changes: 2 additions & 2 deletions doc/modules/ROOT/pages/single_document.adoc
@@ -1,7 +1,7 @@
= OpenEMS - Open Energy Management System
ifndef::toc[]
(c) 2019 OpenEMS Association e.V.
Version 2019.18.0
(c) 2020 OpenEMS Association e.V.
Version 2020.1.0
:sectnums:
:sectnumlevels: 4
:toc:
Expand Down
4 changes: 2 additions & 2 deletions io.openems.backend.application/BackendApp.bndrun
Expand Up @@ -31,7 +31,6 @@

-runbundles: \
com.google.gson;version='[2.8.5,2.8.6)',\
com.google.guava;version='[28.1.0,28.1.1)',\
com.google.guava.failureaccess;version='[1.0.1,1.0.2)',\
io.openems.backend.application;version='[1.0.0,1.0.1)',\
io.openems.backend.b2brest;version='[1.0.0,1.0.1)',\
Expand Down Expand Up @@ -69,4 +68,5 @@
org.ops4j.pax.logging.pax-logging-api;version='[1.11.2,1.11.3)',\
org.ops4j.pax.logging.pax-logging-service;version='[1.11.2,1.11.3)',\
org.osgi.service.metatype;version='[1.4.0,1.4.1)',\
org.postgresql.jdbc42;version='[42.2.9,42.2.10)'
org.postgresql.jdbc42;version='[42.2.9,42.2.10)',\
com.google.guava;version='[28.2.0,28.2.1)'
Expand Up @@ -2,6 +2,7 @@

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand All @@ -12,8 +13,8 @@
import io.openems.backend.metadata.odoo.Field;
import io.openems.backend.metadata.odoo.MetadataOdoo;
import io.openems.backend.metadata.odoo.MyEdge;
import io.openems.backend.metadata.odoo.odoo.OdooUtils.JsonrpcResponseSuccessAndHeaders;
import io.openems.backend.metadata.odoo.odoo.jsonrpc.AuthenticateWithUsernameAndPasswordRequest;
import io.openems.backend.metadata.odoo.odoo.jsonrpc.AuthenticateWithUsernameAndPasswordResponse;
import io.openems.common.exceptions.OpenemsError;
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.common.exceptions.OpenemsException;
Expand Down Expand Up @@ -76,11 +77,19 @@ public void addChatterMessage(MyEdge edge, String message) {
public String authenticate(String username, String password) throws OpenemsNamedException {
AuthenticateWithUsernameAndPasswordRequest request = new AuthenticateWithUsernameAndPasswordRequest(
this.credentials.getDatabase(), username, password);
JsonrpcResponseSuccess origResponse = OdooUtils
JsonrpcResponseSuccessAndHeaders response = OdooUtils
.sendJsonrpcRequest(this.credentials.getUrl() + "/web/session/authenticate", request);
AuthenticateWithUsernameAndPasswordResponse response = AuthenticateWithUsernameAndPasswordResponse
.from(origResponse);
return response.getSessionId();
List<String> setCookieHeaders = response.headers.get("Set-Cookie");
if(setCookieHeaders != null && !setCookieHeaders.isEmpty()) {
final String[] setCookieHeader = setCookieHeaders.get(0).split(";");
for(String entry : setCookieHeader) {
String[] values = entry.split("=", 2);
if(values.length == 2 && values[0].equals("session_id")) {
return values[1];
}
}
}
throw OpenemsError.COMMON_AUTHENTICATION_FAILED.exception();
}

/**
Expand All @@ -99,7 +108,7 @@ public JsonrpcResponseSuccess authenticateSession(String sessionId) throws Opene
} catch (UnsupportedEncodingException e) {
throw OpenemsError.GENERIC.exception(e.getMessage());
}
return OdooUtils.sendJsonrpcRequest(this.credentials.getUrl() + "/openems_backend/info?" + query, request);
return OdooUtils.sendJsonrpcRequest(this.credentials.getUrl() + "/openems_backend/info?" + query, request).response;
}

}
Expand Up @@ -9,6 +9,7 @@
import java.net.URL;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.xmlrpc.XmlRpcException;
Expand Down Expand Up @@ -36,6 +37,20 @@ private OdooUtils() {
public static final DateTimeFormatter DATETIME_FORMATTER = DateTimeFormatter
.ofPattern(DEFAULT_SERVER_DATETIME_FORMAT);

/**
* Wrapper for the reply of a call to
* {@link OdooUtils#sendJsonrpcRequest(String, JsonrpcRequest)}.
*/
public static class JsonrpcResponseSuccessAndHeaders {
public final JsonrpcResponseSuccess response;
public final Map<String, List<String>> headers;

public JsonrpcResponseSuccessAndHeaders(JsonrpcResponseSuccess response, Map<String, List<String>> headers) {
this.response = response;
this.headers = headers;
}
}

/**
* Sends a JSON-RPC Request to an Odoo server.
*
Expand All @@ -45,7 +60,7 @@ private OdooUtils() {
* even on error...)
* @throws OpenemsNamedException on error
*/
public static JsonrpcResponseSuccess sendJsonrpcRequest(String url, JsonrpcRequest request)
public static JsonrpcResponseSuccessAndHeaders sendJsonrpcRequest(String url, JsonrpcRequest request)
throws OpenemsNamedException {
HttpURLConnection connection = null;
try {
Expand Down Expand Up @@ -75,7 +90,7 @@ public static JsonrpcResponseSuccess sendJsonrpcRequest(String url, JsonrpcReque

JsonrpcResponse response = JsonrpcResponse.from(sb.toString());
if (response instanceof JsonrpcResponseSuccess) {
return (JsonrpcResponseSuccess) response;
return new JsonrpcResponseSuccessAndHeaders((JsonrpcResponseSuccess) response, connection.getHeaderFields());
} else {
throw OpenemsError.GENERIC.exception(response);
}
Expand Down
4 changes: 2 additions & 2 deletions io.openems.common/src/io/openems/common/OpenemsConstants.java
Expand Up @@ -13,14 +13,14 @@ public class OpenemsConstants {
*
* This is usually the year of the release
*/
public final static short VERSION_MAJOR = 2019;
public final static short VERSION_MAJOR = 2020;

/**
* The minor version of OpenEMS.
*
* This is usually the number of the sprint within the year
*/
public final static short VERSION_MINOR = 18;
public final static short VERSION_MINOR = 1;

/**
* The patch version of OpenEMS.
Expand Down
Expand Up @@ -10,6 +10,7 @@

import io.openems.common.exceptions.OpenemsError;
import io.openems.common.exceptions.OpenemsError.OpenemsNamedException;
import io.openems.common.exceptions.OpenemsException;
import io.openems.common.utils.JsonUtils;

/**
Expand All @@ -32,6 +33,8 @@
*/
public class JsonrpcResponseError extends JsonrpcResponse {

private final static Logger LOG = LoggerFactory.getLogger(JsonrpcResponseError.class);

public static JsonrpcResponseError from(String json) throws OpenemsNamedException {
return from(JsonUtils.parseToJsonObject(json));
}
Expand All @@ -40,7 +43,13 @@ public static JsonrpcResponseError from(JsonObject j) throws OpenemsNamedExcepti
UUID id = UUID.fromString(JsonUtils.getAsString(j, "id"));
JsonObject error = JsonUtils.getAsJsonObject(j, "error");
int code = JsonUtils.getAsInt(error, "code");
OpenemsError openemsError = OpenemsError.fromCode(code);
OpenemsError openemsError;
try {
openemsError = OpenemsError.fromCode(code);
} catch (OpenemsException e) {
LOG.warn("Falling back to Generic Error for JSON-RPC " + j.toString() + "; " + e.getMessage());
openemsError = OpenemsError.GENERIC;
}
if (openemsError == OpenemsError.GENERIC) {
String message = JsonUtils.getAsString(error, "message");
return new JsonrpcResponseError(id, message);
Expand Down
4 changes: 2 additions & 2 deletions io.openems.edge.application/EdgeApp.bndrun
Expand Up @@ -111,7 +111,6 @@
com.fazecast.jSerialComm;version='[2.5.1,2.5.2)',\
com.ghgande.j2mod;version='[2.5.5,2.5.6)',\
com.google.gson;version='[2.8.5,2.8.6)',\
com.google.guava;version='[28.1.0,28.1.1)',\
com.google.guava.failureaccess;version='[1.0.1,1.0.2)',\
com.sun.jna;version='[5.5.0,5.5.1)',\
io.openems.common;version='[1.0.0,1.0.1)',\
Expand Down Expand Up @@ -237,4 +236,5 @@
org.ops4j.pax.logging.pax-logging-service;version='[1.11.2,1.11.3)',\
org.osgi.service.event;version='[1.4.0,1.4.1)',\
org.osgi.service.metatype;version='[1.4.0,1.4.1)',\
rrd4j;version='[3.5.0,3.5.1)'
rrd4j;version='[3.5.0,3.5.1)',\
com.google.guava;version='[28.2.0,28.2.1)'
Expand Up @@ -12,7 +12,6 @@
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.osgi.service.event.EventConstants;
import org.osgi.service.metatype.annotations.Designate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -27,17 +26,14 @@
import io.openems.edge.common.channel.StateChannel;
import io.openems.edge.common.component.AbstractOpenemsComponent;
import io.openems.edge.common.component.OpenemsComponent;
import io.openems.edge.common.event.EdgeEventConstants;
import io.openems.edge.thermometer.api.Thermometer;

@Designate(ocd = Config.class, factory = true)
@Component(//
name = "OneWire.Thermometer", //
immediate = true, //
configurationPolicy = ConfigurationPolicy.REQUIRE, //
property = { //
EventConstants.EVENT_TOPIC + "=" + EdgeEventConstants.TOPIC_CYCLE_BEFORE_PROCESS_IMAGE, //
})
configurationPolicy = ConfigurationPolicy.REQUIRE //
)
public class OneWireThermometer extends AbstractOpenemsComponent implements Thermometer, OpenemsComponent {

private final Logger log = LoggerFactory.getLogger(OneWireThermometer.class);
Expand Down
Expand Up @@ -22,6 +22,9 @@

@AttributeDefinition(name = "TCP Port", description = "TCP Port of InfluxDB server.")
int port() default 8086;

@AttributeDefinition(name = "No of Cycles", description = "How many Cycles till data is written to InfluxDB.")
int noOfCycles() default 1;

@AttributeDefinition(name = "Username", description = "Username of InfluxDB server.")
String username() default "root";
Expand Down

0 comments on commit 6f019ea

Please sign in to comment.