You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2022/09/29 16:05:44 UTC
[plc4x] branch rel/0.10 updated: chore(release): Removed example stuff related to apache edgent
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch rel/0.10
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/rel/0.10 by this push:
new 111f2a139 chore(release): Removed example stuff related to apache edgent
111f2a139 is described below
commit 111f2a1396c32cdb1540cca27cf5aa6d0f56cbdb
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Sep 29 18:05:35 2022 +0200
chore(release): Removed example stuff related to apache edgent
---
plc4j/examples/hello-integration-edgent/pom.xml | 71 -------
.../examples/integration/edgent/CliOptions.java | 98 ----------
.../examples/integration/edgent/PlcLogger.java | 59 ------
.../src/main/resources/logback.xml | 34 ----
plc4j/examples/hello-integration-iotdb/pom.xml | 121 ------------
.../examples/integration/iotdb/CliOptions.java | 206 ---------------------
.../examples/integration/iotdb/IIoTDBWriter.java | 26 ---
.../integration/iotdb/IoTDBWriterWithJDBC.java | 86 ---------
.../integration/iotdb/IoTDBWriterWithSession.java | 88 ---------
.../java/examples/integration/iotdb/PlcLogger.java | 117 ------------
.../src/main/resources/logback.xml | 34 ----
plc4j/examples/hello-nats/pom.xml | 88 ---------
.../plc4x/java/examples/hellonats/CliOptions.java | 98 ----------
.../plc4x/java/examples/hellonats/HelloNats.java | 107 -----------
.../hello-nats/src/main/resources/logback.xml | 34 ----
plc4j/examples/pom.xml | 3 -
16 files changed, 1270 deletions(-)
diff --git a/plc4j/examples/hello-integration-edgent/pom.xml b/plc4j/examples/hello-integration-edgent/pom.xml
deleted file mode 100644
index 51fd13f3c..000000000
--- a/plc4j/examples/hello-integration-edgent/pom.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.examples</groupId>
- <artifactId>plc4j-examples</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4j-examples-hello-integration-edgent</artifactId>
- <name>PLC4J: Examples: Edgent</name>
- <description>Application using Edgent to output PLC data to the console.</description>
-
- <properties>
- <app.main.class>org.apache.plc4x.java.examples.integration.edgent.PlcLogger</app.main.class>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-apache-edgent</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.edgent</groupId>
- <artifactId>edgent-api-function</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.edgent</groupId>
- <artifactId>edgent-api-topology</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.edgent</groupId>
- <artifactId>edgent-providers-direct</artifactId>
- <version>1.2.0</version>
- </dependency>
-
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/plc4j/examples/hello-integration-edgent/src/main/java/org/apache/plc4x/java/examples/integration/edgent/CliOptions.java b/plc4j/examples/hello-integration-edgent/src/main/java/org/apache/plc4x/java/examples/integration/edgent/CliOptions.java
deleted file mode 100644
index 6a524169c..000000000
--- a/plc4j/examples/hello-integration-edgent/src/main/java/org/apache/plc4x/java/examples/integration/edgent/CliOptions.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.integration.edgent;
-
-import org.apache.commons.cli.*;
-
-public class CliOptions {
-
- private static Options options;
-
- private final String connectionString;
- private final String fieldAddress;
- private final int pollingInterval;
-
- public static CliOptions fromArgs(String[] args) {
- options = new Options();
- // Required arguments
- options.addOption(
- Option.builder()
- .type(String.class)
- .longOpt("connection-string")
- .hasArg()
- .desc("Connection String")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(String.class)
- .longOpt("field-address")
- .hasArg()
- .desc("Field Address.")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("polling-interval")
- .hasArg()
- .desc("Polling Interval (milliseconds).")
- .required()
- .build());
-
- CommandLineParser parser = new DefaultParser();
- CommandLine commandLine;
- try {
- commandLine = parser.parse(options, args);
-
- String connectionString = commandLine.getOptionValue("connection-string");
- String fieldAddress = commandLine.getOptionValue("field-address");
- int pollingInterval = Integer.parseInt(commandLine.getOptionValue("polling-interval"));
-
- return new CliOptions(connectionString, fieldAddress, pollingInterval);
- } catch (ParseException e) {
- System.err.println(e.getMessage());
- return null;
- }
- }
-
- public static void printHelp() {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("PlcLogger", options);
- }
-
- public CliOptions(String connectionString, String fieldAddress, int pollingInterval) {
- this.connectionString = connectionString;
- this.fieldAddress = fieldAddress;
- this.pollingInterval = pollingInterval;
- }
-
- public String getConnectionString() {
- return connectionString;
- }
-
- public String getFieldAddress() {
- return fieldAddress;
- }
-
- public int getPollingInterval() {
- return pollingInterval;
- }
-
-}
diff --git a/plc4j/examples/hello-integration-edgent/src/main/java/org/apache/plc4x/java/examples/integration/edgent/PlcLogger.java b/plc4j/examples/hello-integration-edgent/src/main/java/org/apache/plc4x/java/examples/integration/edgent/PlcLogger.java
deleted file mode 100644
index 248124549..000000000
--- a/plc4j/examples/hello-integration-edgent/src/main/java/org/apache/plc4x/java/examples/integration/edgent/PlcLogger.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.integration.edgent;
-
-import org.apache.edgent.function.Supplier;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.apache.plc4x.edgent.PlcConnectionAdapter;
-import org.apache.plc4x.edgent.PlcFunctions;
-
-import java.util.concurrent.TimeUnit;
-
-public class PlcLogger {
-
- public static void main(String[] args) throws Exception {
- CliOptions options = CliOptions.fromArgs(args);
- if (options == null) {
- CliOptions.printHelp();
- // Could not parse.
- System.exit(1);
- }
-
- // Get a plc connection.
- try (PlcConnectionAdapter plcAdapter = new PlcConnectionAdapter(options.getConnectionString())) {
- // Initialize the Edgent core.
- DirectProvider dp = new DirectProvider();
- Topology top = dp.newTopology();
-
- // Define the event stream.
- // 1) PLC4X source generating a stream of bytes.
- Supplier<Byte> plcSupplier = PlcFunctions.byteSupplier(plcAdapter, options.getFieldAddress());
- // 2) Use polling to get an item from the byte-stream in regular intervals.
- TStream<Byte> source = top.poll(plcSupplier, options.getPollingInterval(), TimeUnit.MILLISECONDS);
- // 3) Output the events in the stream on the console.
- source.print();
-
- // Submit the topology and hereby start the event streams.
- dp.submit(top);
- }
- }
-
-}
diff --git a/plc4j/examples/hello-integration-edgent/src/main/resources/logback.xml b/plc4j/examples/hello-integration-edgent/src/main/resources/logback.xml
deleted file mode 100644
index 16b83b488..000000000
--- a/plc4j/examples/hello-integration-edgent/src/main/resources/logback.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<configuration xmlns="http://ch.qos.logback/xml/ns/logback"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://ch.qos.logback/xml/ns/logback https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <root level="warn">
- <appender-ref ref="STDOUT" />
- </root>
-
-</configuration>
\ No newline at end of file
diff --git a/plc4j/examples/hello-integration-iotdb/pom.xml b/plc4j/examples/hello-integration-iotdb/pom.xml
deleted file mode 100644
index 53f226416..000000000
--- a/plc4j/examples/hello-integration-iotdb/pom.xml
+++ /dev/null
@@ -1,121 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.examples</groupId>
- <artifactId>plc4j-examples</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4j-examples-hello-integration-iotdb</artifactId>
- <name>PLC4J: Examples: IoTDB</name>
- <description>Application using Edgent to output PLC data to the IoTDB.</description>
-
- <properties>
- <iotdb.version>0.13.0</iotdb.version>
-
- <app.main.class>org.apache.plc4x.java.examples.integration.iotdb.PlcLogger</app.main.class>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <usedDependencies combine.children="append">
- <usedDependency>org.slf4j:log4j-over-slf4j</usedDependency>
- </usedDependencies>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-apache-edgent</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.edgent</groupId>
- <artifactId>edgent-api-function</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.edgent</groupId>
- <artifactId>edgent-api-topology</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.edgent</groupId>
- <artifactId>edgent-providers-direct</artifactId>
- <version>1.2.0</version>
- </dependency>
-
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>tsfile</artifactId>
- <version>${iotdb.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>service-rpc</artifactId>
- <version>${iotdb.version}</version>
- </dependency>
-
- <!-- iotdb JDBC driver-->
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>iotdb-jdbc</artifactId>
- <version>${iotdb.version}</version>
- </dependency>
-
- <!-- iotdb session SDK driver-->
- <dependency>
- <groupId>org.apache.iotdb</groupId>
- <artifactId>iotdb-session</artifactId>
- <version>${iotdb.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/CliOptions.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/CliOptions.java
deleted file mode 100644
index e3ec448a4..000000000
--- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/CliOptions.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.integration.iotdb;
-
-import org.apache.commons.cli.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class CliOptions {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(CliOptions.class);
-
- private static Options options;
-
- private final String connectionString;
- private final String fieldAddress;
- private final int pollingInterval;
- private final String iotdbIpPort;
- private final String user;
- private final String password;
- private final String storageGroup;
- private final String device;
- private final String datatype;
- private final boolean useJDBC;
-
- public static CliOptions fromArgs(String[] args) {
- options = new Options();
- // Required arguments
- options.addOption(
- Option.builder()
- .type(String.class)
- .longOpt("connection-string")
- .hasArg()
- .desc("Connection String")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(String.class)
- .longOpt("field-address")
- .hasArg()
- .desc("Field Address.")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("polling-interval")
- .hasArg()
- .desc("Polling Interval (milliseconds).")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("iotdb-address")
- .hasArg()
- .desc("The address and port of IoTDB server. format: ip:port")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("iotdb-user-name")
- .hasArg()
- .desc("The connection user that has privilege to write data into IoTDB")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("iotdb-user-password")
- .hasArg()
- .desc("The connection user password that has privilege to write data into IoTDB")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("iotdb-sg")
- .hasArg()
- .desc("The Storage group name, e.g., testapp")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("iotdb-device")
- .hasArg()
- .desc("The device name, e.g., mitsubishi.D58501")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Integer.class)
- .longOpt("iotdb-datatype")
- .hasArg()
- .desc("The data type of the field")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(Boolean.class)
- .longOpt("use-jdbc")
- .hasArg()
- .desc("Whether use JDBC API or not")
- .build());
-
- CommandLineParser parser = new DefaultParser();
- CommandLine commandLine;
- try {
- commandLine = parser.parse(options, args);
-
- String connectionString = commandLine.getOptionValue("connection-string");
- String fieldAddress = commandLine.getOptionValue("field-address");
- int pollingInterval = Integer.parseInt(commandLine.getOptionValue("polling-interval"));
- String iotdbIpPort = commandLine.getOptionValue("iotdb-address");
- String user = commandLine.getOptionValue("iotdb-user-name");
- String password = commandLine.getOptionValue("iotdb-user-password");
- String storageGroup = commandLine.getOptionValue("iotdb-sg");
- String device = commandLine.getOptionValue("iotdb-device");
- String datatype = commandLine.getOptionValue("iotdb-datatype");
- boolean useJDBC = Boolean.valueOf(commandLine.getOptionValue("use-jdbc", "false"));
-
- return new CliOptions(connectionString, fieldAddress, pollingInterval, iotdbIpPort, user, password, storageGroup, device, datatype, useJDBC);
- } catch (ParseException e) {
- LOGGER.error(e.getMessage());
- return null;
- }
- }
-
- public static void printHelp() {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("PlcLogger", options);
- }
-
- public CliOptions(String connectionString, String fieldAddress, int pollingInterval, String iotdbIpPort, String user, String password, String storageGroup, String device, String datatype, boolean useJDBC) {
- this.connectionString = connectionString;
- this.fieldAddress = fieldAddress;
- this.pollingInterval = pollingInterval;
- this.iotdbIpPort = iotdbIpPort;
- this.user = user;
- this.password = password;
- this.storageGroup = storageGroup;
- this.device = device;
- this.datatype = datatype;
- this.useJDBC = useJDBC;
- }
-
- public String getConnectionString() {
- return connectionString;
- }
-
- public String getFieldAddress() {
- return fieldAddress;
- }
-
- public int getPollingInterval() {
- return pollingInterval;
- }
-
- public String getIotdbIpPort() {
- return iotdbIpPort;
- }
-
- public String getUser() {
- return user;
- }
-
- public String getPassword() {
- return password;
- }
-
- public String getStorageGroup() {
- return storageGroup;
- }
-
- public String getDevice() {
- return device;
- }
-
- public String getDatatype() {
- return datatype;
- }
-
- public boolean isUseJDBC() {
- return useJDBC;
- }
-
-}
diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IIoTDBWriter.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IIoTDBWriter.java
deleted file mode 100644
index 68b0dfc09..000000000
--- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IIoTDBWriter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.integration.iotdb;
-
-public interface IIoTDBWriter {
- void initStorageGroup(String storageGroup);
- void writeData(String deviceId, String field, long timestamp, Integer value);
- void close();
- void createTimeseries(String timeseries, String dataType);
-}
diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithJDBC.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithJDBC.java
deleted file mode 100644
index 13099e205..000000000
--- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithJDBC.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.integration.iotdb;
-
-import java.sql.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class IoTDBWriterWithJDBC implements IIoTDBWriter {
- private static final Logger LOGGER = LoggerFactory.getLogger(IoTDBWriterWithJDBC.class);
-
- //IoTDB JDBC connection
- private final Connection connection;
-
- public IoTDBWriterWithJDBC(String ipPort, String username, String password)
- throws ClassNotFoundException, SQLException {
- // Get IoTDB connection
- Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
- connection = DriverManager.getConnection("jdbc:iotdb://" + ipPort + "/",
- username, password);
- }
-
- @Override
- public void initStorageGroup(String storageGroup) {
- try (PreparedStatement statement = connection.prepareStatement("SET STORAGE GROUP TO root.?")) {
- statement.setObject(1, storageGroup);
- statement.execute();
- } catch (SQLException e) {
- //from v0.9.0, you can use the error code to check whether the sg exists.
- LOGGER.error(e.getMessage());
- }
- }
-
- @Override
- public void writeData(String deviceId, String field, long timestamp, Integer value) {
- //please modify this method if you want to write multiple fields once.
- try (PreparedStatement statement = connection.prepareStatement("INSERT INTO ? (TIMESTAMP, ?) VALUES (?, ?)")) {
- statement.setString(1, deviceId);
- statement.setString(2, field);
- statement.setLong(3, timestamp);
- statement.setInt(4, value);
- statement.execute();
- } catch (SQLException e) {
- LOGGER.error("Error storing data.", e);
- }
- }
-
- @Override
- public void close() {
- try {
- connection.close();
- } catch (SQLException e) {
- LOGGER.error("Error closing connection.", e);
- }
- }
-
- @Override
- public void createTimeseries(String timeseries, String dataType) {
- try (PreparedStatement statement = connection.prepareStatement("CREATE TIMESERIES ? WITH DATATYPE = ?, ENCODING = RLE")) {
- statement.setString(1, timeseries);
- statement.setString(2, dataType);
- statement.execute();
- } catch (SQLException e) {
- //from v0.9.0, you can use the error code to check whether the sg exists.
- LOGGER.error(e.getMessage());
- }
- }
-
-}
diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithSession.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithSession.java
deleted file mode 100644
index 1515a0ee9..000000000
--- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/IoTDBWriterWithSession.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.integration.iotdb;
-
-import java.util.Collections;
-import org.apache.iotdb.rpc.IoTDBConnectionException;
-import org.apache.iotdb.rpc.StatementExecutionException;
-import org.apache.iotdb.rpc.TSStatusCode;
-import org.apache.iotdb.session.pool.SessionPool;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class IoTDBWriterWithSession implements IIoTDBWriter {
- private static Logger LOGGER = LoggerFactory.getLogger(IoTDBWriterWithSession.class);
-
- //sessionPool is more user friendly than session
- SessionPool sessionPool;
-
- public IoTDBWriterWithSession(String iotdbIpPort, String user, String password) {
- sessionPool = new SessionPool(iotdbIpPort.split(":")[0], Integer.valueOf(iotdbIpPort.split(":")[1]), user, password, 1);
- }
-
- @Override
- public void initStorageGroup(String storageGroup) {
- try {
- sessionPool.setStorageGroup(storageGroup);
- } catch (IoTDBConnectionException e) {
- LOGGER.error("Error", e);
- } catch (StatementExecutionException e) {
- if (e.getStatusCode() != TSStatusCode.PATH_ALREADY_EXIST_ERROR.getStatusCode()) { // 300 means the storage group exist already.
- LOGGER.error("Error", e);
- }
- }
- }
-
- @Override
- public void writeData(String deviceId, String field, long timestamp, Integer value) {
- try {
- //when using the default configuration of IoTDB, then int value will be considered as float.
- //so we use float here.
- //change the data type by modify `integer_string_infer_type` parameter.
-
- //if you create time-series manually, REMEMBER TO MODIFY THE TSDATATYPE.FLOAT AS WHAT YOU REALLY NEED.
- sessionPool.insertRecord(deviceId, timestamp, Collections.singletonList(field), Collections.singletonList(
- TSDataType.FLOAT), Collections.singletonList(value + 0.0f));
- } catch (IoTDBConnectionException | StatementExecutionException e) {
- LOGGER.error("Error storing connection.", e);
- }
- }
-
- @Override
- public void close() {
- sessionPool.close();
- }
-
- @Override
- public void createTimeseries(String timeseries, String dataType) {
- try {
- sessionPool.createTimeseries(timeseries, TSDataType.valueOf(dataType), TSEncoding.RLE, CompressionType.SNAPPY);
- } catch (IoTDBConnectionException e) {
- LOGGER.error("Error", e);
- } catch (StatementExecutionException e) {
- if (e.getStatusCode() != TSStatusCode.PATH_ALREADY_EXIST_ERROR.getStatusCode()) { // 300 means the time series exist already.
- LOGGER.error("Error", e);
- }
- }
- }
-
-}
diff --git a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/PlcLogger.java b/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/PlcLogger.java
deleted file mode 100644
index b796794f9..000000000
--- a/plc4j/examples/hello-integration-iotdb/src/main/java/org/apache/plc4x/java/examples/integration/iotdb/PlcLogger.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.integration.iotdb;
-
-import org.apache.edgent.function.Supplier;
-import org.apache.edgent.providers.direct.DirectProvider;
-import org.apache.edgent.topology.TStream;
-import org.apache.edgent.topology.Topology;
-import org.apache.plc4x.edgent.PlcConnectionAdapter;
-import org.apache.plc4x.edgent.PlcFunctions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * using this example, you can store data one by one into IoTDB.
- *
- * modified according to hello-integration-edgent
- *
- * arguments example:
- * --connection-string simulated://127.0.0.1 --field-address RANDOM/foo:Integer --polling-interval 1000
- * --iotdb-address 127.0.0.1:6667 --iotdb-user-name root --iotdb-user-password root --iotdb-sg mi
- * --iotdb-device d1 --iotdb-datatype INT32
- */
-public class PlcLogger {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(PlcLogger.class);
-
- //Time series ID
- static String timeSeries;
-
- //device ID
- static String deviceId;
-
- //sensor ID
- static String sensor;
-
- static String dataType;
-
- static IIoTDBWriter ioTDBWriter = null;
-
- static boolean useJDBC;
-
- public static void main(String[] args) throws Exception {
- CliOptions options = CliOptions.fromArgs(args);
- if (options == null) {
- CliOptions.printHelp();
- // Could not parse.
- System.exit(1);
- }
- useJDBC = options.isUseJDBC();
- deviceId = String.format("root.%s.%s", options.getStorageGroup(), options.getDevice());
- sensor = options.getFieldAddress().replace("/", "_").replace(":", "_");
- timeSeries = String.format("%s.%s", deviceId, sensor);
- dataType = options.getDevice();
-
- // Get IoTDB connection
- if (useJDBC) {
- ioTDBWriter = new IoTDBWriterWithJDBC(options.getIotdbIpPort(), options.getUser(), options.getPassword());
- } else {
- ioTDBWriter = new IoTDBWriterWithSession(options.getIotdbIpPort(), options.getUser(), options.getPassword());
- }
-
- //as we do not know whether the storage group is created or not, we can init the storage
- // group in force.
- //from v0.9.0 on, IoTDB can automatically create storage group if you enable the parameter
- //`enable_auto_create_schema` and set the suitable `default_storage_group_level`.
- // If so, this method can be ignored.
- ioTDBWriter.initStorageGroup("root." + options.getStorageGroup());
-
- //register the time series. from v0.9.0 on, IoTDB can automatically create timeseries
- //if you enable the parameter `enable_auto_create_schema`.
- //But if you want to explicitly define the series data type, you have to call the method.
-
- //ioTDBWriter.createTimeseries(timeSeries, dataType);
-
- // Get a plc connection.
- try (PlcConnectionAdapter plcAdapter = new PlcConnectionAdapter(options.getConnectionString())) {
- // Initialize the Edgent core.
- DirectProvider dp = new DirectProvider();
- Topology top = dp.newTopology();
-
- // Define the event stream.
- // 1) PLC4X source generating a stream of bytes.
- Supplier<Integer> plcSupplier = PlcFunctions.integerSupplier(plcAdapter,
- options.getFieldAddress());
- // 2) Use polling to get an item from the byte-stream in regular intervals.
- TStream<Integer> source = top.poll(plcSupplier, options.getPollingInterval(),
- TimeUnit.MILLISECONDS);
- // 3) Output the events in the stream to IoTDB.
- source.peek(value -> ioTDBWriter.writeData(deviceId, sensor, System.currentTimeMillis(), value));
- // Submit the topology and hereby start the event streams.
- dp.submit(top);
- }
- //close IoTDB client.
- Runtime.getRuntime().addShutdownHook(new Thread(ioTDBWriter::close));
- }
-
-
-}
diff --git a/plc4j/examples/hello-integration-iotdb/src/main/resources/logback.xml b/plc4j/examples/hello-integration-iotdb/src/main/resources/logback.xml
deleted file mode 100644
index 16b83b488..000000000
--- a/plc4j/examples/hello-integration-iotdb/src/main/resources/logback.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<configuration xmlns="http://ch.qos.logback/xml/ns/logback"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://ch.qos.logback/xml/ns/logback https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <root level="warn">
- <appender-ref ref="STDOUT" />
- </root>
-
-</configuration>
\ No newline at end of file
diff --git a/plc4j/examples/hello-nats/pom.xml b/plc4j/examples/hello-nats/pom.xml
deleted file mode 100644
index fba043b2d..000000000
--- a/plc4j/examples/hello-nats/pom.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.examples</groupId>
- <artifactId>plc4j-examples</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4j-examples-hello-nats</artifactId>
- <name>PLC4J: Examples: Hello-Nats</name>
- <description>Hello world application for PLC4X using Nats.</description>
-
- <properties>
- <app.main.class>org.apache.plc4x.java.examples.hellonats.HelloNats</app.main.class>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-api</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-connection-cache</artifactId>
- <version>0.10.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>io.nats</groupId>
- <artifactId>jnats</artifactId>
- <version>2.15.3</version>
- </dependency>
-
- <dependency>
- <groupId>commons-cli</groupId>
- <artifactId>commons-cli</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>log4j-over-slf4j</artifactId>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <usedDependencies combine.children="append">
- <usedDependency>org.slf4j:log4j-over-slf4j</usedDependency>
- </usedDependencies>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
diff --git a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/CliOptions.java b/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/CliOptions.java
deleted file mode 100644
index 7a4dcc406..000000000
--- a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/CliOptions.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.hellonats;
-
-import org.apache.commons.cli.*;
-
-public class CliOptions {
-
- private static Options options;
-
- private final String natsServerConnectionString;
- private final String natsNodeName;
- private final String natsTopic;
-
- public static CliOptions fromArgs(String[] args) {
- options = new Options();
- // Required arguments
- options.addOption(
- Option.builder()
- .type(String.class)
- .longOpt("nats-server-connection-string")
- .hasArg()
- .desc("Nats Server Connection String")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(String.class)
- .longOpt("nats-node-name")
- .hasArg()
- .desc("Name of this node.")
- .required()
- .build());
- options.addOption(
- Option.builder()
- .type(String.class)
- .longOpt("nats-topic")
- .hasArg()
- .desc("Name of the topic for receiving requests.")
- .required()
- .build());
-
- CommandLineParser parser = new DefaultParser();
- CommandLine commandLine;
- try {
- commandLine = parser.parse(options, args);
-
- String natsServerConnectionString = commandLine.getOptionValue("nats-server-connection-string");
- String natsNodeName = commandLine.getOptionValue("nats-node-name");
- String natsTopic = commandLine.getOptionValue("nats-topic");
-
- return new CliOptions(natsServerConnectionString, natsNodeName, natsTopic);
- } catch (ParseException e) {
- System.err.println(e.getMessage());
- return null;
- }
- }
-
- public static void printHelp() {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("HelloPlc4x", options);
- }
-
- public CliOptions(String natsServerConnectionString, String natsNodeName, String natsTopic) {
- this.natsServerConnectionString = natsServerConnectionString;
- this.natsNodeName = natsNodeName;
- this.natsTopic = natsTopic;
- }
-
- public String getNatsServerConnectionString() {
- return natsServerConnectionString;
- }
-
- public String getNatsNodeName() {
- return natsNodeName;
- }
-
- public String getNatsTopic() {
- return natsTopic;
- }
-
-}
diff --git a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/HelloNats.java b/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/HelloNats.java
deleted file mode 100644
index 766dd1437..000000000
--- a/plc4j/examples/hello-nats/src/main/java/org/apache/plc4x/java/examples/hellonats/HelloNats.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.plc4x.java.examples.hellonats;
-
-import io.nats.client.*;
-import io.nats.client.api.StorageType;
-import io.nats.client.api.StreamConfiguration;
-import io.nats.client.api.StreamInfo;
-import io.nats.client.support.JsonUtils;
-import org.apache.plc4x.java.PlcDriverManager;
-import org.apache.plc4x.java.api.PlcConnection;
-import org.apache.plc4x.java.api.messages.PlcReadRequest;
-import org.apache.plc4x.java.api.messages.PlcReadResponse;
-import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.api.value.PlcValue;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.time.Duration;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-
-public class HelloNats {
-
- private static final Logger logger = LoggerFactory.getLogger(HelloNats.class);
-
- /**
- * Example code do demonstrate using PLC4X.
- *
- * @param args ignored.
- */
- public static void main(String[] args) throws Exception {
- CliOptions options = CliOptions.fromArgs(args);
- if (options == null) {
- CliOptions.printHelp();
- // Could not parse.
- System.exit(1);
- }
-
- try (Connection natsConnection = Nats.connect(options.getNatsServerConnectionString())) {
- final JetStreamManagement jsm = natsConnection.jetStreamManagement();
-
- final StreamConfiguration streamConfiguration = StreamConfiguration.builder().name(options.getNatsNodeName()).subjects(options.getNatsTopic()).storageType(StorageType.Memory).build();
- final StreamInfo streamInfo = jsm.addStream(streamConfiguration);
- JsonUtils.printFormatted(streamInfo);
-
- final JetStream jetStream = natsConnection.jetStream();
-
- final Dispatcher dispatcher = natsConnection.createDispatcher();
- final JetStreamSubscription jetStreamSubscription = jetStream.subscribe(options.getNatsTopic(), dispatcher, msg -> {
- final String connectionUrl = msg.getHeaders().getFirst("connection-url");
- final List<String> fields = msg.getHeaders().get("fields");
-
- // Establish a connection to the plc using the url provided as first argument
- try (PlcConnection plcConnection = new PlcDriverManager().getConnection(connectionUrl)) {
-
- // Check if this connection support reading of data.
- if (!plcConnection.getMetadata().canRead()) {
- logger.error("This connection doesn't support reading.");
- return;
- }
-
- // Create a new read request:
- // - Give the single item requested the alias name "value"
- PlcReadRequest.Builder builder = plcConnection.readRequestBuilder();
- for (int i = 0; i < fields.size(); i++) {
- builder.addItem("value-" + i, fields.get(i));
- }
- PlcReadRequest readRequest = builder.build();
-
- // Actually execute the read request (synchronously)
- PlcReadResponse response = readRequest.execute().get();
-
- for (String fieldName : response.getFieldNames()) {
- if (response.getResponseCode(fieldName) == PlcResponseCode.OK) {
- final PlcValue plcValue = response.getPlcValue(fieldName);
- }
- // Something went wrong, to output an error message instead.
- else {
- logger.error("Error[{}]: {}", fieldName, response.getResponseCode(fieldName).name());
- }
- }
- } catch (ExecutionException e) {
- logger.error("Error[{}]: {}", fieldName, response.getResponseCode(fieldName).name());
- }
- }, false);
- natsConnection.flush(Duration.ofSeconds(1));
- }
- }
-
-}
diff --git a/plc4j/examples/hello-nats/src/main/resources/logback.xml b/plc4j/examples/hello-nats/src/main/resources/logback.xml
deleted file mode 100644
index eee180ec7..000000000
--- a/plc4j/examples/hello-nats/src/main/resources/logback.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- https://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<configuration xmlns="http://ch.qos.logback/xml/ns/logback"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://ch.qos.logback/xml/ns/logback https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <root level="info">
- <appender-ref ref="STDOUT" />
- </root>
-
-</configuration>
\ No newline at end of file
diff --git a/plc4j/examples/pom.xml b/plc4j/examples/pom.xml
index 7e97693cd..3a7884614 100644
--- a/plc4j/examples/pom.xml
+++ b/plc4j/examples/pom.xml
@@ -44,9 +44,6 @@
<module>hello-discovery</module>
<module>hello-connectivity-mqtt</module>
<module>hello-influx-data-collection</module>
- <module>hello-integration-edgent</module>
- <module>hello-integration-iotdb</module>
- <!--module>hello-nats</module-->
<module>hello-opm</module>
<module>hello-webservice</module>
<module>hello-world-kotlin</module>