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 2019/11/19 10:48:00 UTC

[plc4x] 01/03: - Renamed the test-streampipes-connectors to test-streampipes-bacnetip

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

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

commit 62abbefdea64d2d05b16b7c1d67ef5cfdd5eed9a
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Nov 19 11:44:39 2019 +0100

    - Renamed the test-streampipes-connectors to test-streampipes-bacnetip
---
 .../READMME.adoc                                   |   0
 .../env/development                                |   0
 sandbox/streampipes-bacnetip/pom.xml               | 223 +++++++++++++++++++++
 .../bacnetip/source}/BacNetIpAdapter.java          |  62 +++---
 .../bacnetip/source}/config/ConfigKeys.java        |   2 +-
 .../source}/config/ConnectWorkerConfig.java        |   2 +-
 6 files changed, 259 insertions(+), 30 deletions(-)

diff --git a/sandbox/streampipes-connectors/READMME.adoc b/sandbox/streampipes-bacnetip/READMME.adoc
similarity index 100%
rename from sandbox/streampipes-connectors/READMME.adoc
rename to sandbox/streampipes-bacnetip/READMME.adoc
diff --git a/sandbox/streampipes-connectors/env/development b/sandbox/streampipes-bacnetip/env/development
similarity index 100%
rename from sandbox/streampipes-connectors/env/development
rename to sandbox/streampipes-bacnetip/env/development
diff --git a/sandbox/streampipes-bacnetip/pom.xml b/sandbox/streampipes-bacnetip/pom.xml
new file mode 100644
index 0000000..926ba3d
--- /dev/null
+++ b/sandbox/streampipes-bacnetip/pom.xml
@@ -0,0 +1,223 @@
+<?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.sandbox</groupId>
+    <artifactId>plc4x-sandbox</artifactId>
+    <version>0.6.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>test-streampipes-bacnetip</artifactId>
+
+  <name>Sandbox: StreamPipes BACnet/IP</name>
+
+  <properties>
+    <streampipes.version>0.64.0</streampipes.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-protocol-driver-base</artifactId>
+      <version>0.6.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-protocol-driver-base-raw-socket</artifactId>
+      <version>0.6.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.plc4x</groupId>
+      <artifactId>plc4j-protocol-driver-base-pcap-socket</artifactId>
+      <version>0.6.0-SNAPSHOT</version>
+      <!--scope>test</scope-->
+    </dependency>
+
+    <dependency>
+      <groupId>org.streampipes</groupId>
+      <artifactId>streampipes-connect-container-worker</artifactId>
+      <version>${streampipes.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.spec.javax.annotation</groupId>
+          <artifactId>jboss-annotations-api_1.2_spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.glassfish.hk2.external</groupId>
+          <artifactId>javax.inject</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.glassfish.hk2.external</groupId>
+          <artifactId>aopalliance-repackaged</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>aopalliance</groupId>
+          <artifactId>aopalliance</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.glassfish</groupId>
+          <artifactId>javax.el</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>org.ow2.spec.ee</groupId>
+          <artifactId>ow2-jpa-1.0-spec</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>commons-logging</groupId>
+          <artifactId>commons-logging</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>com.google.code.findbugs</groupId>
+          <artifactId>jsr305</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.streampipes</groupId>
+      <artifactId>streampipes-wrapper</artifactId>
+      <version>${streampipes.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>com.google.code.findbugs</groupId>
+          <artifactId>jsr305</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-csv</artifactId>
+      <version>1.7</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.plc4x.sandbox</groupId>
+      <artifactId>test-java-bacnetip-driver</artifactId>
+      <version>0.6.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>javax.validation</groupId>
+      <artifactId>validation-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-classic</artifactId>
+      <scope>compile</scope>
+    </dependency>
+    <dependency>
+      <groupId>ch.qos.logback</groupId>
+      <artifactId>logback-core</artifactId>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>commons-beanutils</groupId>
+        <artifactId>commons-beanutils</artifactId>
+        <version>1.9.4</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.fasterxml.jackson.datatype</groupId>
+        <artifactId>jackson-datatype-jdk8</artifactId>
+        <version>2.9.9</version>
+      </dependency>
+
+      <dependency>
+        <groupId>com.squareup.okhttp3</groupId>
+        <artifactId>okhttp</artifactId>
+        <version>3.12.1</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.apache.httpcomponents</groupId>
+        <artifactId>fluent-hc</artifactId>
+        <version>${httpclient.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.httpcomponents</groupId>
+        <artifactId>httpclient</artifactId>
+        <version>${httpclient.version}</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.javassist</groupId>
+        <artifactId>javassist</artifactId>
+        <version>3.25.0-GA</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.jboss.logging</groupId>
+        <artifactId>jboss-logging</artifactId>
+        <version>3.3.2.Final</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.objenesis</groupId>
+        <artifactId>objenesis</artifactId>
+        <version>2.5.1</version>
+      </dependency>
+
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-aop</artifactId>
+        <version>5.1.9.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-beans</artifactId>
+        <version>5.1.9.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-context</artifactId>
+        <version>5.1.9.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-core</artifactId>
+        <version>5.1.9.RELEASE</version>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-web</artifactId>
+        <version>5.1.9.RELEASE</version>
+      </dependency>
+
+      <dependency>
+        <groupId>javax.validation</groupId>
+        <artifactId>validation-api</artifactId>
+        <version>2.0.1.Final</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+</project>
diff --git a/sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/BacNetIpAdapter.java b/sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/BacNetIpAdapter.java
similarity index 91%
rename from sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/BacNetIpAdapter.java
rename to sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/BacNetIpAdapter.java
index c053d77..f6c6a21 100644
--- a/sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/BacNetIpAdapter.java
+++ b/sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/BacNetIpAdapter.java
@@ -16,7 +16,7 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */
-package org.apache.plc4x.java.streampipes.bacnetip;
+package org.apache.plc4x.java.streampipes.bacnetip.source;
 
 import io.netty.channel.ChannelHandlerContext;
 import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
@@ -29,7 +29,7 @@ import org.apache.plc4x.java.base.connection.NettyPlcConnection;
 import org.apache.plc4x.java.base.connection.PcapChannelFactory;
 import org.apache.plc4x.java.base.connection.RawSocketChannelFactory;
 import org.apache.plc4x.java.base.messages.PlcRequestContainer;
-import org.apache.plc4x.java.streampipes.bacnetip.config.ConnectWorkerConfig;
+import org.apache.plc4x.java.streampipes.bacnetip.source.config.ConnectWorkerConfig;
 import org.apache.plc4x.java.utils.pcapsockets.netty.PcapSocketAddress;
 import org.apache.plc4x.java.utils.pcapsockets.netty.PcapSocketChannelConfig;
 import org.pcap4j.core.*;
@@ -62,6 +62,15 @@ public class BacNetIpAdapter extends SpecificDataStreamAdapter {
 
     public static final String ID = "http://plc4x.apache.org/streampipes/adapter/bacnetip";
 
+    public static final String MAPPING_FIELD_TIME = "time";
+    public static final String MAPPING_FIELD_OBJECT_ID = "objectId";
+    public static final String MAPPING_FIELD_OBJECT_TYPE = "objectType";
+    public static final String MAPPING_FIELD_NOTIFICATION_INSTANCE_NUMBER = "notificationInstanceNumber";
+    public static final String MAPPING_FIELD_NOTIFICATION_TYPE = "notificationType";
+    public static final String MAPPING_FIELD_VALUE_TYPE = "valueType";
+    public static final String MAPPING_FIELD_VALUE = "value";
+    public static final String MAPPING_FIELD_STATUS = "status";
+
     private static final Logger logger = LoggerFactory.getLogger(BacNetIpAdapter.class);
 
     private String deviceName;
@@ -124,56 +133,54 @@ public class BacNetIpAdapter extends SpecificDataStreamAdapter {
 
         allProperties.add(
             PrimitivePropertyBuilder
-                .create(Datatypes.Long, "time")
+                .create(Datatypes.Long, MAPPING_FIELD_TIME)
                 .label("Time")
                 .description("The time the event was processed in the BACnet adapter")
                 .build());
 
         allProperties.add(
             PrimitivePropertyBuilder
-                .create(Datatypes.Integer, "objectType")
+                .create(Datatypes.Integer, MAPPING_FIELD_OBJECT_ID)
+                .label("Object id")
+                .description("Id of the BACnet object emitting the event (usually 'device id')")
+                .build());
+        allProperties.add(
+            PrimitivePropertyBuilder
+                .create(Datatypes.Integer, MAPPING_FIELD_OBJECT_TYPE)
                 .label("Object type")
                 .description("Type of BACnet object emitting the event (usually 'device')")
                 .build());
-
         allProperties.add(
             PrimitivePropertyBuilder
-                .create(Datatypes.Integer, "objectId")
-                .label("Object id")
-                .description("Id of the BACnet object emitting the event (usually 'device id')")
+                .create(Datatypes.Integer, MAPPING_FIELD_NOTIFICATION_INSTANCE_NUMBER)
+                .label("Notification instance number")
+                .description("The instance number of the component emitting the event (usually the id of the property changed on a device)")
                 .build());
 
         allProperties.add(
             PrimitivePropertyBuilder
-                .create(Datatypes.Integer, "notificationType")
+                .create(Datatypes.Integer, MAPPING_FIELD_NOTIFICATION_TYPE)
                 .label("Notification type")
                 .description("The type of notification this event resembles (usually some type of input)")
                 .build());
 
         allProperties.add(
             PrimitivePropertyBuilder
-                .create(Datatypes.Integer, "notificationInstanceNumber")
-                .label("Notification instance number")
-                .description("The instance number of the component emitting the event (usually the id of the property changed on a device)")
-                .build());
-
-        allProperties.add(
-            PrimitivePropertyBuilder
-                .create(Datatypes.Integer, "valueType")
+                .create(Datatypes.Integer, MAPPING_FIELD_VALUE_TYPE)
                 .label("Value type")
                 .description("The type the value has (real, uint, int, bit-string, ...)")
                 .build());
 
         allProperties.add(
             PrimitivePropertyBuilder
-                .create(Datatypes.String, "value")
+                .create(Datatypes.String, MAPPING_FIELD_VALUE)
                 .label("Value")
                 .description("This is the actual payload of the event.")
                 .build());
 
         allProperties.add(
             PrimitivePropertyBuilder
-                .create(Datatypes.Sequence, "status")
+                .create(Datatypes.Sequence, MAPPING_FIELD_STATUS)
                 .label("Status")
                 .description("Some times an array of status bits are passed along.")
                 .build());
@@ -296,7 +303,6 @@ public class BacNetIpAdapter extends SpecificDataStreamAdapter {
                                     } else if (notification.getVal() instanceof BACnetTagApplicationEnumerated) {
                                         type = "enumeration";
                                         final BACnetTagApplicationEnumerated val = (BACnetTagApplicationEnumerated) notification.getVal();
-
                                     }
                                 }
 
@@ -317,16 +323,16 @@ public class BacNetIpAdapter extends SpecificDataStreamAdapter {
                             if(value != null) {
                                 // Create the event object.
                                 Map<String, Object> event = new HashMap<>();
-                                event.put("time", System.currentTimeMillis());
+                                event.put(MAPPING_FIELD_TIME, System.currentTimeMillis());
 
-                                event.put("objectType", objectType);
-                                event.put("objectId", objectId);
-                                event.put("notificationType", notificationType);
-                                event.put("notificationInstanceNumber", notificationInstanceNumber);
+                                event.put(MAPPING_FIELD_OBJECT_ID, objectId);
+                                event.put(MAPPING_FIELD_OBJECT_TYPE, objectType);
+                                event.put(MAPPING_FIELD_NOTIFICATION_INSTANCE_NUMBER, notificationInstanceNumber);
 
-                                event.put("valueType", type);
-                                event.put("value", value);
-                                event.put("status", status);
+                                event.put(MAPPING_FIELD_NOTIFICATION_TYPE, notificationType);
+                                event.put(MAPPING_FIELD_VALUE_TYPE, type);
+                                event.put(MAPPING_FIELD_VALUE, value);
+                                event.put(MAPPING_FIELD_STATUS, status);
 
                                 // Send it to StreamPipes
                                 adapterPipeline.process(event);
diff --git a/sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/config/ConfigKeys.java b/sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/config/ConfigKeys.java
similarity index 94%
rename from sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/config/ConfigKeys.java
rename to sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/config/ConfigKeys.java
index ecce008..a857694 100644
--- a/sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/config/ConfigKeys.java
+++ b/sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/config/ConfigKeys.java
@@ -15,7 +15,7 @@
  *
  */
 
-package org.apache.plc4x.java.streampipes.bacnetip.config;
+package org.apache.plc4x.java.streampipes.bacnetip.source.config;
 
 public class ConfigKeys {
 
diff --git a/sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/config/ConnectWorkerConfig.java b/sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/config/ConnectWorkerConfig.java
similarity index 97%
rename from sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/config/ConnectWorkerConfig.java
rename to sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/config/ConnectWorkerConfig.java
index 2892a94..5cb1beb 100644
--- a/sandbox/streampipes-connectors/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/config/ConnectWorkerConfig.java
+++ b/sandbox/streampipes-bacnetip/src/main/java/org/apache/plc4x/java/streampipes/bacnetip/source/config/ConnectWorkerConfig.java
@@ -15,7 +15,7 @@
  *
  */
 
-package org.apache.plc4x.java.streampipes.bacnetip.config;
+package org.apache.plc4x.java.streampipes.bacnetip.source.config;
 
 import org.streampipes.config.SpConfig;
 import org.streampipes.connect.init.Config;