-
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
331 changed files
with
28,399 additions
and
23,794 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
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
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,25 @@ | ||
<?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="DUMMY"/> | ||
<mapEntry key="OPENEMS_WEBSOCKET_PORT" value="8077"/> | ||
<mapEntry key="TIMEDATA" value="DUMMY"/> | ||
</mapAttribute> | ||
<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,36 @@ | ||
<?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="INFLUX_DATABASE" value="db"/> | ||
<mapEntry key="INFLUX_PASSWORD" value="admin"/> | ||
<mapEntry key="INFLUX_PORT" value="8086"/> | ||
<mapEntry key="INFLUX_URL" value="localhost"/> | ||
<mapEntry key="INFLUX_USERNAME" value="admin"/> | ||
<mapEntry key="METADATA" value="DUMMY"/> | ||
<mapEntry key="ODOO_DATABASE" value=""/> | ||
<mapEntry key="ODOO_PASSWORD" value=""/> | ||
<mapEntry key="ODOO_PORT" value="8069"/> | ||
<mapEntry key="ODOO_URL" value=""/> | ||
<mapEntry key="ODOO_USERNAME" value=""/> | ||
<mapEntry key="OPENEMS_WEBSOCKET_PORT" value="8077"/> | ||
</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
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,78 @@ | ||
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.timedata.Timedata; | ||
import io.openems.common.utils.EnvUtils; | ||
|
||
public class App { | ||
private static Logger log = LoggerFactory.getLogger(App.class); | ||
|
||
public static void main(String[] args) throws Exception { | ||
log.info("OpenEMS-Backend starting..."); | ||
|
||
// Configure everything | ||
initMetadataProvider(); | ||
initTimedataProvider(); | ||
initOpenemsWebsocket(); | ||
initBrowserWebsocket(); | ||
|
||
log.info("OpenEMS Backend started."); | ||
log.info("================================================================================"); | ||
} | ||
|
||
/** | ||
* Configures a metadata provider. It uses either Odoo as backend or a simple Dummy provider. | ||
* | ||
* @throws Exception | ||
*/ | ||
private static void initMetadataProvider() throws Exception { | ||
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 Exception { | ||
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 Exception { | ||
int port = EnvUtils.getAsInt("OPENEMS_WEBSOCKET_PORT"); | ||
log.info("Start OpenEMS Websocket server on port [" + port + "]"); | ||
OpenemsWebsocket.initialize(port); | ||
} | ||
|
||
private static void initBrowserWebsocket() throws Exception { | ||
int port = EnvUtils.getAsInt("BROWSER_WEBSOCKET_PORT"); | ||
log.info("Start Browser Websocket server on port [" + port + "]"); | ||
BrowserWebsocket.initialize(port); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
backend/src/main/java/io/openems/backend/browserwebsocket/BrowserWebsocket.java
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 @@ | ||
package io.openems.backend.browserwebsocket; | ||
|
||
/** | ||
* Provider for OpenemsWebsocketServer singleton | ||
* | ||
* @author stefan.feilmeier | ||
* | ||
*/ | ||
public class BrowserWebsocket { | ||
|
||
private static BrowserWebsocketSingleton instance; | ||
|
||
/** | ||
* Initialize and start the Websocketserver | ||
* | ||
* @param port | ||
* @throws Exception | ||
*/ | ||
public static synchronized void initialize(int port) throws Exception { | ||
BrowserWebsocket.instance = new BrowserWebsocketSingleton(port); | ||
BrowserWebsocket.instance.start(); | ||
} | ||
|
||
/** | ||
* Returns the singleton instance | ||
* | ||
* @return | ||
*/ | ||
public static synchronized BrowserWebsocketSingleton instance() { | ||
return BrowserWebsocket.instance; | ||
} | ||
} |
Oops, something went wrong.