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 2021/03/24 14:58:29 UTC

[plc4x] 01/01: - Setup an empty module for the sparkplug edge gateway - Added a new "tools" module with the Eclips Tahu Sparkplug client (Sort of still integrated quite hackily)

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch feature/sparkplug-gateway
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 41ab78ea1aad36af9ec24d01ee1f69083736182f
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Mar 24 15:58:15 2021 +0100

    - Setup an empty module for the sparkplug edge gateway
    - Added a new "tools" module with the Eclips Tahu Sparkplug client (Sort of still integrated quite hackily)
---
 plc4j/integrations/pom.xml                         |   6 +
 plc4j/integrations/sparkplug-edge-gateway/pom.xml  | 198 +++++++++++++++++++++
 .../plc4x/java/sparkplug/SparkplugEdgeGateway.java |  28 +++
 tools/eclipse-tahu/pom.xml                         | 114 ++++++++++++
 tools/pom.xml                                      |   6 +
 5 files changed, 352 insertions(+)

diff --git a/plc4j/integrations/pom.xml b/plc4j/integrations/pom.xml
index 1a0e473..285a1b9 100644
--- a/plc4j/integrations/pom.xml
+++ b/plc4j/integrations/pom.xml
@@ -48,6 +48,12 @@
         <module>logstash-plugin</module>
       </modules>
     </profile>
+    <profile>
+      <id>with-sparkplug</id>
+      <modules>
+        <module>sparkplug-edge-gateway</module>
+      </modules>
+    </profile>
   </profiles>
 
 </project>
diff --git a/plc4j/integrations/sparkplug-edge-gateway/pom.xml b/plc4j/integrations/sparkplug-edge-gateway/pom.xml
new file mode 100644
index 0000000..073920d
--- /dev/null
+++ b/plc4j/integrations/sparkplug-edge-gateway/pom.xml
@@ -0,0 +1,198 @@
+<?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
+
+      http://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</groupId>
+    <artifactId>plc4j-integrations</artifactId>
+    <version>0.9.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>plc4j-sparkplug-edge-gateway</artifactId>
+
+  <name>PLC4J: Integrations: Sparkplug Edge Gateway</name>
+
+  <properties>
+    <app.main.class>org.apache.plc4x.java.sparkplug.SparkplugEdgeGateway</app.main.class>
+    <tahu-java.version>0.5.9</tahu-java.version>
+  </properties>
+
+  <dependencies>
+    <!-- Eclipse Tahu Sparkplug client lib -->
+    <!-- TODO: If this library is missing, build the tools/eclipse-tahu project first -->
+    <!--dependency>
+      <groupId>org.eclipse.tahu</groupId>
+      <artifactId>tahu-java</artifactId>
+      <version>${tahu-java.version}</version>
+    </dependency-->
+
+    <!-- PLC4X Dependencies -->
+    <!--dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-api</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-connection-pool</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+    </dependency-->
+
+    <!-- Include all drivers -->
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-ab-eth</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-ads</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-canopen</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-eip</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-firmata</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-knxnetip</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-modbus</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-opcua</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-s7</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-driver-simulated</artifactId>
+      <version>0.9.0-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+
+    <!-- Logging dependancies -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <!-- Build a fat jar containing all dependencies -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-uber-jar</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers combine.children="append">
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                  <mainClass>${app.main.class}</mainClass>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>build-helper-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-uber-jar</id>
+            <phase>package</phase>
+            <goals>
+              <goal>attach-artifact</goal>
+            </goals>
+            <configuration>
+              <artifacts>
+                <artifact>
+                  <file>${project.build.directory}/${project.artifactId}-${project.version}-uber-jar.jar</file>
+                  <type>jar</type>
+                  <classifier>standalone</classifier>
+                </artifact>
+              </artifacts>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <configuration>
+          <usedDependencies combine.children="append">
+          </usedDependencies>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/plc4j/integrations/sparkplug-edge-gateway/src/main/java/org/apache/plc4x/java/sparkplug/SparkplugEdgeGateway.java b/plc4j/integrations/sparkplug-edge-gateway/src/main/java/org/apache/plc4x/java/sparkplug/SparkplugEdgeGateway.java
new file mode 100644
index 0000000..ebe49ff
--- /dev/null
+++ b/plc4j/integrations/sparkplug-edge-gateway/src/main/java/org/apache/plc4x/java/sparkplug/SparkplugEdgeGateway.java
@@ -0,0 +1,28 @@
+/*
+ * 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
+ *
+ *   http://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.sparkplug;
+
+public class SparkplugEdgeGateway {
+
+    public static void main(String[] args) {
+        System.out.println("Hello World");
+    }
+
+}
diff --git a/tools/eclipse-tahu/pom.xml b/tools/eclipse-tahu/pom.xml
new file mode 100644
index 0000000..cb1c717
--- /dev/null
+++ b/tools/eclipse-tahu/pom.xml
@@ -0,0 +1,114 @@
+<?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
+
+      http://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</groupId>
+    <artifactId>plc4x-tools</artifactId>
+    <version>0.9.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>plc4x-tools-eclipse-tahu</artifactId>
+  <packaging>pom</packaging>
+
+  <name>Tools: Eclipse Tahu (Java Client)</name>
+  <description>
+    Building of the Eclipse Tahu Java client library. Unfortunately this
+    doesn't seem to be available in a public maven repo, so we have to
+    build it locally.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>com.googlecode.maven-download-plugin</groupId>
+        <artifactId>download-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>get-tahu</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>wget</goal>
+            </goals>
+            <configuration>
+              <url>https://github.com/eclipse/tahu/archive/refs/tags/v0.5.9.zip</url>
+              <unpack>true</unpack>
+              <outputDirectory>${project.build.directory}</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!--plugin>
+        <groupId>com.github.os72</groupId>
+        <artifactId>protoc-jar-maven-plugin</artifactId>
+        <version>3.11.4</version>
+        <executions>
+          <execution>
+            <id>generate-protobuf</id>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <addProtoSources>all</addProtoSources>
+              <includeMavenTypes>direct</includeMavenTypes>
+              <inputDirectories>
+                <include>${project.build.directory}/tahu-0.5.9/sparkplug_b</include>
+              </inputDirectories>
+              <outputDirectory>${project.build.directory}/tahu-0.5.9/client_libraries/java/target/generated-sources/protoc</outputDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin-->
+
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>exec-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate protobu</id>
+            <phase>process-sources</phase>
+            <goals>
+              <goal>exec</goal>
+            </goals>
+            <configuration>
+              <executable>mvn</executable>
+              <!--
+                Make sure Maven is using the same Java version the current build is using.
+                Without this setting it would use the java executable located in the Path.
+              -->
+              <environmentVariables>
+                <JAVA_HOME>${java.home}</JAVA_HOME>
+              </environmentVariables>
+              <arguments>
+                <argument>install</argument>
+              </arguments>
+              <workingDirectory>${project.build.directory}/tahu-0.5.9</workingDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
\ No newline at end of file
diff --git a/tools/pom.xml b/tools/pom.xml
index 254db93..47748aa 100644
--- a/tools/pom.xml
+++ b/tools/pom.xml
@@ -45,6 +45,12 @@
         <module>logstash</module>
       </modules>
     </profile>
+    <profile>
+      <id>with-sparkplug</id>
+      <modules>
+        <module>eclipse-tahu</module>
+      </modules>
+    </profile>
   </profiles>
 
 </project>
\ No newline at end of file