Skip to content

Commit

Permalink
Merge branch 'release/v1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Nov 2, 2017
2 parents 956e70f + 0ca5eaf commit aaa7930
Show file tree
Hide file tree
Showing 53 changed files with 1,916 additions and 1,651 deletions.
8 changes: 4 additions & 4 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<url>http://openems.io</url>
<groupId>io.openems</groupId>
<artifactId>edge</artifactId>
<version>1.5.1</version>
<version>1.6.0</version>
<packaging>jar</packaging>
<scm>
<url>https://github.com/OpenEMS/openems</url>
Expand All @@ -23,7 +23,7 @@
<maven-assembly-plugin.version>3.1.0</maven-assembly-plugin.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<restlet.version>2.3.10</restlet.version>
<odoo-java-api-version>1.1.0.RELEASE</odoo-java-api-version>
<odoo-java-api.version>3.0.1</odoo-java-api.version>
<slf4j.version>1.7.25</slf4j.version>
<websocket.version>1.3.4</websocket.version>
</properties>
Expand Down Expand Up @@ -71,9 +71,9 @@
<version>${restlet.version}</version>
</dependency>
<dependency>
<groupId>com.abercap</groupId>
<groupId>com.odoojava</groupId>
<artifactId>odoo-java-api</artifactId>
<version>${odoo-java-api-version}</version>
<version>${odoo-java-api.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

import org.apache.xmlrpc.XmlRpcException;

import com.abercap.odoo.FilterCollection;
import com.abercap.odoo.ObjectAdapter;
import com.abercap.odoo.OdooApiException;
import com.abercap.odoo.Row;
import com.abercap.odoo.RowCollection;
import com.abercap.odoo.Session;
import com.odoojava.api.FilterCollection;
import com.odoojava.api.ObjectAdapter;
import com.odoojava.api.OdooApiException;
import com.odoojava.api.Row;
import com.odoojava.api.RowCollection;
import com.odoojava.api.Session;

/**
* Represents an abstract model in Odoo object relational mapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.abercap.odoo.OdooApiException;
import com.abercap.odoo.Row;
import com.odoojava.api.OdooApiException;
import com.odoojava.api.Row;

import io.openems.common.exceptions.OpenemsException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

import org.apache.xmlrpc.XmlRpcException;

import com.abercap.odoo.OdooApiException;
import com.abercap.odoo.Session;
import com.google.common.collect.LinkedHashMultimap;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.odoojava.api.OdooApiException;
import com.odoojava.api.Session;

import io.openems.backend.browserwebsocket.session.BrowserSession;
import io.openems.backend.browserwebsocket.session.BrowserSessionData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import java.util.Optional;

import com.abercap.odoo.Row;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.odoojava.api.Row;

import io.openems.backend.metadata.api.device.MetadataDevice;
import io.openems.backend.metadata.odoo.OdooModel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import org.apache.xmlrpc.XmlRpcException;

import com.abercap.odoo.OdooApiException;
import com.abercap.odoo.RowCollection;
import com.abercap.odoo.Session;
import com.odoojava.api.OdooApiException;
import com.odoojava.api.RowCollection;
import com.odoojava.api.Session;

import io.openems.backend.metadata.api.device.MetadataDeviceModel;
import io.openems.backend.metadata.api.device.MetadataDevices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ public void write(MetadataDevices devices, JsonObject jData) {
// Prepare data table
for (Entry<Long, JsonObject> dataEntry : sortedData.entrySet()) {
Long timestamp = dataEntry.getKey();
// use lastDataCache only if we receive the latest data and cache is not elder than 1 minute
boolean useLastDataCache = timestamp > lastTimestamp && timestamp < lastTimestamp + 60000;
this.lastTimestampMap.put(deviceId, timestamp);
JsonObject jChannels = dataEntry.getValue();

Expand All @@ -128,14 +126,16 @@ public void write(MetadataDevices devices, JsonObject jData) {
if (valueOpt.isPresent()) {
Object value = valueOpt.get();
data.put(timestamp, channel, value);
if (useLastDataCache) {
// add to cache
if (timestamp > lastTimestamp) {
this.lastDataCache.put(deviceId, channel, value);
}
}
}

// only for latest data: add the cached data to the InfluxDB point.
if (useLastDataCache) {
// if we receive the latest data and cache is not elder than 10 minutes
if (timestamp > lastTimestamp && timestamp < lastTimestamp + 10 * 60 * 1000) {
for (Entry<String, Object> cacheEntry : this.lastDataCache.row(deviceId).entrySet()) {
String channel = cacheEntry.getKey();
Optional<Object> valueOpt = this.parseValue(channel, cacheEntry.getValue());
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<url>http://openems.io</url>
<groupId>io.openems</groupId>
<artifactId>common</artifactId>
<version>1.5.1</version>
<version>1.6.0</version>
<packaging>jar</packaging>
<scm>
<url>https://github.com/OpenEMS/openems</url>
Expand Down
7 changes: 6 additions & 1 deletion common/src/io/openems/common/types/ChannelAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import io.openems.common.exceptions.OpenemsException;

public class ChannelAddress {
public class ChannelAddress implements Comparable<ChannelAddress> {
private final String thingId;
private final String channelId;

Expand Down Expand Up @@ -35,4 +35,9 @@ public static ChannelAddress fromString(String address) throws OpenemsException
throw new OpenemsException("This [" + address + "] is not a valid channel address.");
}
}

@Override
public int compareTo(ChannelAddress other) {
return this.toString().compareTo(other.toString());
}
}
4 changes: 1 addition & 3 deletions common/src/io/openems/common/types/FieldValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
package io.openems.common.types;

public abstract class FieldValue<T> {
public final String field;
public final T value;

public FieldValue(String field, T value) {
this.field = field;
public FieldValue(T value) {
this.value = value;
}
}
4 changes: 2 additions & 2 deletions common/src/io/openems/common/types/NullFieldValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

public class NullFieldValue extends FieldValue<Object> {

public NullFieldValue(String field) {
super(field, null);
public NullFieldValue() {
super(null);
}

}
4 changes: 2 additions & 2 deletions common/src/io/openems/common/types/NumberFieldValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

public class NumberFieldValue extends FieldValue<Number> {

public NumberFieldValue(String field, Number value) {
super(field, value);
public NumberFieldValue(Number value) {
super(value);
}

}
4 changes: 2 additions & 2 deletions common/src/io/openems/common/types/StringFieldValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

public class StringFieldValue extends FieldValue<String> {

public StringFieldValue(String field, String value) {
super(field, value);
public StringFieldValue(String value) {
super(value);
}

}
19 changes: 19 additions & 0 deletions common/src/io/openems/common/types/TimestampedFieldValue.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.openems.common.types;

public class TimestampedFieldValue {
private long timestamp;
private FieldValue<?> value;

public TimestampedFieldValue(long timestamp, FieldValue<?> value) {
this.timestamp = timestamp;
this.value = value;
}

public long getTimestamp() {
return timestamp;
}

public FieldValue<?> getValue() {
return value;
}
}
Loading

0 comments on commit aaa7930

Please sign in to comment.