Skip to content

Commit

Permalink
Merge branch 'release/v1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeilmeier committed Nov 30, 2017
2 parents 69cc40a + 2a037fb commit 92656db
Show file tree
Hide file tree
Showing 197 changed files with 17,219 additions and 2,498 deletions.
29 changes: 29 additions & 0 deletions backend/OpenEMS-Backend (File).launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<setAttribute key="name.schedenig.eclipse.grepconsole.DisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.EnabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.FilterDisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.FilterEnabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.StatisticsDisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.StatisticsEnabledIds"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/backend/src/main/java/io/openems/backend/App.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
<mapEntry key="BROWSER_WEBSOCKET_PORT" value="8078"/>
<mapEntry key="METADATA" value="FILE"/>
<mapEntry key="METADATA_FILE" value="C:\Users\matthias.rossmann\Documents\FEMS.csv"/>
<mapEntry key="OPENEMS_WEBSOCKET_PORT" value="8077"/>
<mapEntry key="REST_API_PORT" value="8080"/>
<mapEntry key="TIMEDATA" value="DUMMY"/>
</mapAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;common&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="io.openems.backend.App"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="backend"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
32 changes: 32 additions & 0 deletions backend/OpenEMS-Backend (Odoo-Test).launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<setAttribute key="name.schedenig.eclipse.grepconsole.DisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.EnabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.FilterDisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.FilterEnabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.StatisticsDisabledIds"/>
<setAttribute key="name.schedenig.eclipse.grepconsole.StatisticsEnabledIds"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/backend/src/main/java/io/openems/backend/App.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
<mapEntry key="BROWSER_WEBSOCKET_PORT" value="8078"/>
<mapEntry key="ODOO_DATABASE" value="devel"/>
<mapEntry key="ODOO_PASSWORD" value="QKRYmnBBcePbucRrnFSt"/>
<mapEntry key="ODOO_PORT" value="8069"/>
<mapEntry key="ODOO_URL" value="localhost"/>
<mapEntry key="ODOO_USERNAME" value="admin"/>
<mapEntry key="OPENEMS_WEBSOCKET_PORT" value="8077"/>
<mapEntry key="REST_API_PORT" value="8085"/>
<mapEntry key="TIMEDATA" value="DUMMY"/>
</mapAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;javaProject name=&amp;quot;common&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.javaProject&quot;/&gt;&#13;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10;&lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="io.openems.backend.App"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="backend"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
2 changes: 1 addition & 1 deletion 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.6.0</version>
<version>1.7.0</version>
<packaging>jar</packaging>
<scm>
<url>https://github.com/OpenEMS/openems</url>
Expand Down
188 changes: 97 additions & 91 deletions backend/src/main/java/io/openems/backend/App.java
Original file line number Diff line number Diff line change
@@ -1,91 +1,97 @@
package io.openems.backend;

import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.openems.backend.browserwebsocket.BrowserWebsocket;
import io.openems.backend.metadata.Metadata;
import io.openems.backend.openemswebsocket.OpenemsWebsocket;
import io.openems.backend.restapi.RestApi;
import io.openems.backend.timedata.Timedata;
import io.openems.common.exceptions.OpenemsException;
import io.openems.common.utils.EnvUtils;

public class App {
private static Logger log = LoggerFactory.getLogger(App.class);

public static void main(String[] args) {
log.info("OpenEMS-Backend starting...");

// Configure everything
try {
initMetadataProvider();
initTimedataProvider();
initOpenemsWebsocket();
initBrowserWebsocket();
initRestApi();

log.info("OpenEMS Backend started.");
log.info("================================================================================");
} catch (OpenemsException e) {
log.error("OpenEMS Backend failed to start: " + e.getMessage());
}
}

/**
* Configures a metadata provider. It uses either Odoo as backend or a simple Dummy provider.
*
* @throws Exception
*/
private static void initMetadataProvider() throws OpenemsException {
Optional<String> metadataOpt = EnvUtils.getAsOptionalString("METADATA");
if (metadataOpt.isPresent() && metadataOpt.get().equals("DUMMY")) {
log.info("Start Dummy Metadata provider");
Metadata.initializeDummy();
} else {
int port = EnvUtils.getAsInt("ODOO_PORT");
String url = EnvUtils.getAsString("ODOO_URL");
String database = EnvUtils.getAsString("ODOO_DATABASE");
log.info("Connect to Odoo. Url [" + url + ":" + port + "] Database [" + database + "]");
String username = EnvUtils.getAsString("ODOO_USERNAME");
String password = EnvUtils.getAsString("ODOO_PASSWORD");
Metadata.initializeOdoo(url, port, database, username, password);
}
}

private static void initTimedataProvider() throws OpenemsException {
Optional<String> timedataOpt = EnvUtils.getAsOptionalString("TIMEDATA");
if (timedataOpt.isPresent() && timedataOpt.get().equals("DUMMY")) {
log.info("Start Dummy Timedata provider");
Timedata.initializeDummy();
} else {
int port = Integer.valueOf(System.getenv("INFLUX_PORT"));
String url = EnvUtils.getAsString("INFLUX_URL");
String database = EnvUtils.getAsString("INFLUX_DATABASE");
log.info("Connect to InfluxDB. Url [" + url + ":" + port + "], Database [" + database + "]");
String username = EnvUtils.getAsString("INFLUX_USERNAME");
String password = EnvUtils.getAsString("INFLUX_PASSWORD");
Timedata.initializeInfluxdb(database, url, port, username, password);
}
}

private static void initOpenemsWebsocket() throws OpenemsException {
int port = EnvUtils.getAsInt("OPENEMS_WEBSOCKET_PORT");
log.info("Start OpenEMS Websocket server on port [" + port + "]");
OpenemsWebsocket.initialize(port);
}

private static void initBrowserWebsocket() throws OpenemsException {
int port = EnvUtils.getAsInt("BROWSER_WEBSOCKET_PORT");
log.info("Start Browser Websocket server on port [" + port + "]");
BrowserWebsocket.initialize(port);
}

private static void initRestApi() throws OpenemsException {
int port = EnvUtils.getAsInt("REST_API_PORT");
log.info("Start Rest-Api server on port [" + port + "]");
RestApi.initialize(port);
}
}
package io.openems.backend;

import java.io.File;
import java.util.Optional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.openems.backend.browserwebsocket.BrowserWebsocket;
import io.openems.backend.metadata.Metadata;
import io.openems.backend.openemswebsocket.OpenemsWebsocket;
import io.openems.backend.restapi.RestApi;
import io.openems.backend.timedata.Timedata;
import io.openems.common.exceptions.OpenemsException;
import io.openems.common.utils.EnvUtils;

public class App {
private static Logger log = LoggerFactory.getLogger(App.class);

public static void main(String[] args) {
log.info("OpenEMS-Backend starting...");

// Configure everything
try {
initMetadataProvider();
initTimedataProvider();
initOpenemsWebsocket();
initBrowserWebsocket();
initRestApi();

log.info("OpenEMS Backend started.");
log.info("================================================================================");
} catch (OpenemsException e) {
log.error("OpenEMS Backend failed to start: " + e.getMessage());
System.exit(1);
}
}

/**
* Configures a metadata provider. It uses either Odoo as backend or a simple Dummy provider.
*
* @throws Exception
*/
private static void initMetadataProvider() throws OpenemsException {
Optional<String> metadataOpt = EnvUtils.getAsOptionalString("METADATA");
if (metadataOpt.isPresent() && metadataOpt.get().equals("DUMMY")) {
log.info("Start Dummy Metadata provider");
Metadata.initializeDummy();
} else if (metadataOpt.isPresent() && metadataOpt.get().equals("FILE")) {
log.info("Start FILE Metadata provider");
File file = new File(EnvUtils.getAsString("METADATA_FILE"));
Metadata.initializeFile(file);
} else {
int port = EnvUtils.getAsInt("ODOO_PORT");
String url = EnvUtils.getAsString("ODOO_URL");
String database = EnvUtils.getAsString("ODOO_DATABASE");
log.info("Connect to Odoo. Url [" + url + ":" + port + "] Database [" + database + "]");
String username = EnvUtils.getAsString("ODOO_USERNAME");
String password = EnvUtils.getAsString("ODOO_PASSWORD");
Metadata.initializeOdoo(url, port, database, username, password);
}
}

private static void initTimedataProvider() throws OpenemsException {
Optional<String> timedataOpt = EnvUtils.getAsOptionalString("TIMEDATA");
if (timedataOpt.isPresent() && timedataOpt.get().equals("DUMMY")) {
log.info("Start Dummy Timedata provider");
Timedata.initializeDummy();
} else {
int port = Integer.valueOf(System.getenv("INFLUX_PORT"));
String url = EnvUtils.getAsString("INFLUX_URL");
String database = EnvUtils.getAsString("INFLUX_DATABASE");
log.info("Connect to InfluxDB. Url [" + url + ":" + port + "], Database [" + database + "]");
String username = EnvUtils.getAsString("INFLUX_USERNAME");
String password = EnvUtils.getAsString("INFLUX_PASSWORD");
Timedata.initializeInfluxdb(database, url, port, username, password);
}
}

private static void initOpenemsWebsocket() throws OpenemsException {
int port = EnvUtils.getAsInt("OPENEMS_WEBSOCKET_PORT");
log.info("Start OpenEMS Websocket server on port [" + port + "]");
OpenemsWebsocket.initialize(port);
}

private static void initBrowserWebsocket() throws OpenemsException {
int port = EnvUtils.getAsInt("BROWSER_WEBSOCKET_PORT");
log.info("Start Browser Websocket server on port [" + port + "]");
BrowserWebsocket.initialize(port);
}

private static void initRestApi() throws OpenemsException {
int port = EnvUtils.getAsInt("REST_API_PORT");
log.info("Start Rest-Api server on port [" + port + "]");
RestApi.initialize(port);
}
}
Loading

0 comments on commit 92656db

Please sign in to comment.