-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
197 changed files
with
17,219 additions
and
2,498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;common&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <sourceLookupDirector> <sourceContainers duplicates="false"> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;javaProject name=&quot;common&quot;/&gt;&#13;&#10;" typeId="org.eclipse.jdt.launching.sourceContainer.javaProject"/> <container memento="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;default/&gt;&#13;&#10;" typeId="org.eclipse.debug.core.containerType.default"/> </sourceContainers> </sourceLookupDirector> "/> | ||
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.