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/21 15:16:23 UTC

[plc4x] branch feature/knxnet-ip updated (f436d68 -> 8ff92d1)

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

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


    from f436d68  - Updated the PR form the StreamPipes guys to work in our build.
     new aab4e24  - Extended the template to auto-generate hashCode, equals and toString methods
     new fb28a8a  - Deleted an obsolete test.
     new 8ff92d1  - Finished a first version of the ETS5 Enricher Processor

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../resources/templates/java/pojo-template.ftlh    |  57 +++++++
 .../java/org/apache/plc4x/karaf/FeatureTest.java   |  91 -----------
 .../adapters/source/KnxNetIpAdapter.java           |  20 +--
 sandbox/test-streampipes-plc4x-processors/pom.xml  |   6 +-
 .../processors/ets5/Ets5DataEnrichment.java        |  81 +++++++++-
 .../ets5/Ets5DataEnrichmentController.java         |  16 +-
 .../ets5/Ets5DataEnrichmentParameters.java         |   6 +-
 .../processors/ets5/model/AddressType.java         |  96 +++++++++++
 .../processors/ets5/model/Ets5Model.java           |  81 ++++++++++
 .../processors/processors/ets5/model/Function.java |  96 +++++++++++
 .../processors/ets5/model/GroupAddress.java        |  99 ++++++++++++
 .../processors/ets5/utils/Ets5Parser.java          | 178 +++++++++++++++++++++
 12 files changed, 708 insertions(+), 119 deletions(-)
 delete mode 100644 plc4j/karaf-features/s7/src/test/java/org/apache/plc4x/karaf/FeatureTest.java
 create mode 100644 sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/AddressType.java
 create mode 100644 sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Ets5Model.java
 create mode 100644 sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Function.java
 create mode 100644 sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/GroupAddress.java
 create mode 100644 sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/utils/Ets5Parser.java


[plc4x] 03/03: - Finished a first version of the ETS5 Enricher Processor

Posted by cd...@apache.org.
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 8ff92d14a5133b5ff0253fc6cda9de46eb79254e
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Nov 21 16:16:15 2019 +0100

    - Finished a first version of the ETS5 Enricher Processor
---
 .../adapters/source/KnxNetIpAdapter.java           |  20 +--
 sandbox/test-streampipes-plc4x-processors/pom.xml  |   6 +-
 .../processors/ets5/Ets5DataEnrichment.java        |  81 +++++++++-
 .../ets5/Ets5DataEnrichmentController.java         |  16 +-
 .../ets5/Ets5DataEnrichmentParameters.java         |   6 +-
 .../processors/ets5/model/AddressType.java         |  96 +++++++++++
 .../processors/ets5/model/Ets5Model.java           |  81 ++++++++++
 .../processors/processors/ets5/model/Function.java |  96 +++++++++++
 .../processors/ets5/model/GroupAddress.java        |  99 ++++++++++++
 .../processors/ets5/utils/Ets5Parser.java          | 178 +++++++++++++++++++++
 10 files changed, 651 insertions(+), 28 deletions(-)

diff --git a/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/KnxNetIpAdapter.java b/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/KnxNetIpAdapter.java
index fd0ded3..6d6f779 100644
--- a/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/KnxNetIpAdapter.java
+++ b/sandbox/test-streampipes-plc4x-adapters/src/main/java/org/apache/plc4x/java/streampipes/adapters/source/KnxNetIpAdapter.java
@@ -28,9 +28,7 @@ import org.apache.plc4x.java.base.connection.UdpSocketChannelFactory;
 import org.apache.plc4x.java.base.messages.PlcRequestContainer;
 import org.apache.plc4x.java.knxnetip.connection.KnxNetIpConnection;
 import org.apache.plc4x.java.knxnetip.readwrite.*;
-import org.apache.plc4x.java.knxnetip.readwrite.io.KNXGroupAddressIO;
 import org.apache.plc4x.java.streampipes.shared.Constants;
-import org.apache.plc4x.java.utils.ReadBuffer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.streampipes.connect.adapter.Adapter;
@@ -147,8 +145,6 @@ public class KnxNetIpAdapter extends SpecificDataStreamAdapter {
                             CEMIBusmonInd cemiBusmonInd = (CEMIBusmonInd) cemiPayload;
                             if(cemiBusmonInd.getCemiFrame() instanceof CEMIFrameData) {
                                 CEMIFrameData cemiDataFrame = (CEMIFrameData) cemiBusmonInd.getCemiFrame();
-                                ReadBuffer addressReadBuffer = new ReadBuffer(cemiDataFrame.getDestinationAddress());
-                                KNXGroupAddress destinationAddress = KNXGroupAddressIO.parse(addressReadBuffer, (byte) 3);
 
                                 // The first byte is actually just 6 bit long, but we'll treat it as a full one.
                                 // So here we create a byte array containing the first and all the following bytes.
@@ -159,7 +155,7 @@ public class KnxNetIpAdapter extends SpecificDataStreamAdapter {
                                 Map<String, Object> event = new HashMap<>();
                                 event.put(MAPPING_FIELD_TIME, System.currentTimeMillis());
                                 event.put(MAPPING_FIELD_SOURCE_ADDRESS, addressToString(cemiDataFrame.getSourceAddress()));
-                                event.put(MAPPING_FIELD_DESTINATION_ADDRESS, addressToString(destinationAddress));
+                                event.put(MAPPING_FIELD_DESTINATION_ADDRESS, Hex.encodeHex(cemiDataFrame.getDestinationAddress()));
                                 // Encode the payload as Hex String.
                                 event.put(MAPPING_FIELD_PAYLOAD, Hex.encodeHexString(payload));
 
@@ -222,18 +218,4 @@ public class KnxNetIpAdapter extends SpecificDataStreamAdapter {
         return knxAddress.getMainGroup() + "." + knxAddress.getMiddleGroup() + "." + knxAddress.getSubGroup();
     }
 
-    private String addressToString(KNXGroupAddress knxGroupAddress) {
-        if(knxGroupAddress instanceof KNXGroupAddress3Level) {
-            KNXGroupAddress3Level level3 = (KNXGroupAddress3Level) knxGroupAddress;
-            return level3.getMainGroup() + "/" + level3.getMiddleGroup() + "/" + level3.getSubGroup();
-        } else if(knxGroupAddress instanceof KNXGroupAddress2Level) {
-            KNXGroupAddress2Level level2 = (KNXGroupAddress2Level) knxGroupAddress;
-            return level2.getMainGroup() + "/" + level2.getSubGroup();
-        } else if(knxGroupAddress instanceof KNXGroupAddressFreeLevel) {
-            KNXGroupAddressFreeLevel level1 = (KNXGroupAddressFreeLevel) knxGroupAddress;
-            return level1.getSubGroup() + "";
-        }
-        throw new RuntimeException("Unsupported group address type");
-    }
-
 }
diff --git a/sandbox/test-streampipes-plc4x-processors/pom.xml b/sandbox/test-streampipes-plc4x-processors/pom.xml
index 054de65..e836873 100644
--- a/sandbox/test-streampipes-plc4x-processors/pom.xml
+++ b/sandbox/test-streampipes-plc4x-processors/pom.xml
@@ -147,7 +147,11 @@
       <artifactId>test-streampipes-plc4x-shared</artifactId>
       <version>0.6.0-SNAPSHOT</version>
     </dependency>
-
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-compress</artifactId>
+      <version>1.19</version>
+    </dependency>
     <dependency>
       <groupId>javax.validation</groupId>
       <artifactId>validation-api</artifactId>
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichment.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichment.java
index 20c3049..b6dfcef 100644
--- a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichment.java
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichment.java
@@ -15,33 +15,106 @@ limitations under the License.
 */
 package org.apache.plc4x.java.streampipes.processors.processors.ets5;
 
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.plc4x.java.knxnetip.readwrite.*;
+import org.apache.plc4x.java.knxnetip.readwrite.io.KNXGroupAddressIO;
+import org.apache.plc4x.java.knxnetip.readwrite.io.KnxDatapointIO;
+import org.apache.plc4x.java.streampipes.processors.processors.ets5.model.Ets5Model;
+import org.apache.plc4x.java.streampipes.processors.processors.ets5.model.GroupAddress;
+import org.apache.plc4x.java.streampipes.processors.processors.ets5.utils.Ets5Parser;
+import org.apache.plc4x.java.utils.ParseException;
+import org.apache.plc4x.java.utils.ReadBuffer;
 import org.streampipes.commons.exceptions.SpRuntimeException;
 import org.streampipes.model.runtime.Event;
+import org.streampipes.sdk.builder.PrimitivePropertyBuilder;
+import org.streampipes.sdk.utils.Datatypes;
 import org.streampipes.wrapper.context.EventProcessorRuntimeContext;
 import org.streampipes.wrapper.routing.SpOutputCollector;
 import org.streampipes.wrapper.runtime.EventProcessor;
 
+import java.io.File;
+
 public class Ets5DataEnrichment implements EventProcessor<Ets5DataEnrichmentParameters> {
+
     private String destinationIdFieldName;
     private String payloadIdFieldName;
+    // TODO: Make this dynamic.
+    private static final Ets5Model ets5Model = new Ets5Parser().parse(new File("/Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Stettiner Str. 13/Stettiner Str.knxproj"));;
 
     @Override
     public void onInvocation(Ets5DataEnrichmentParameters params, SpOutputCollector spOutputCollector, EventProcessorRuntimeContext eventProcessorRuntimeContext) throws SpRuntimeException {
         destinationIdFieldName = params.getDestinationIdFieldName();
         payloadIdFieldName = params.getPayloadIdFieldName();
-
-
     }
 
     @Override
     public void onEvent(Event event, SpOutputCollector spOutputCollector) throws SpRuntimeException {
-        String destinationFieldValue = event.getFieldBySelector(this.destinationIdFieldName).getAsPrimitive().getAsString();
+        try {
+            // Get the raw group address data.
+            String destinationFieldValue = event.getFieldBySelector(this.destinationIdFieldName).getAsPrimitive().getAsString();
+            byte[] destinationGroupAddress = Hex.decodeHex(destinationFieldValue);
+            ReadBuffer addressReadBuffer = new ReadBuffer(destinationGroupAddress);
+            // Decode the group address depending on the project settings.
+            KNXGroupAddress destinationAddress =
+                KNXGroupAddressIO.parse(addressReadBuffer, ets5Model.getGroupAddressType());
+            final GroupAddress groupAddress = ets5Model.getGroupAddresses().get(destinationAddress);
+
+            // Get the raw HEX-encoded data
+            String hexEncodedRawData = event.getFieldBySelector(this.payloadIdFieldName).getAsPrimitive().getAsString();
+            // Convert the HEX-encoded data back to byte[]
+            byte[] rawData = Hex.decodeHex(hexEncodedRawData);
+            ReadBuffer rawDataReader = new ReadBuffer(rawData);
+
+            if (groupAddress != null) {
+                // Decode the raw data.
+                final KnxDatapoint datapoint = KnxDatapointIO.parse(rawDataReader, groupAddress.getType().getMainType(), groupAddress.getType().getSubType());
 
-        spOutputCollector.collect(event);
+                // Serialize the decoded object to json
+                final String jsonDatapoint = datapoint.toString(ToStringStyle.JSON_STYLE);
+
+                // Add the additional properties.
+                event.addField(Ets5DataEnrichmentController.MAPPING_FIELD_DECODED_GROUP_ADDRESS,
+                    toGroupAddressString(destinationAddress));
+                event.addField(Ets5DataEnrichmentController.MAPPING_FIELD_TYPE,
+                    groupAddress.getType().getName());
+                event.addField(Ets5DataEnrichmentController.MAPPING_FIELD_LOCATION,
+                    groupAddress.getFunction().getSpaceName());
+                event.addField(Ets5DataEnrichmentController.MAPPING_FIELD_FUNCTION,
+                    groupAddress.getFunction().getName());
+                event.addField(Ets5DataEnrichmentController.MAPPING_FIELD_DECODED_PROPERTY_VALUE,
+                    jsonDatapoint);
+
+                //Event enrichedEvent = new Event()
+                spOutputCollector.collect(event);
+            }
+        } catch (ParseException e) {
+            // Driver Decoding
+            e.printStackTrace();
+        } catch (DecoderException e) {
+            // Hex Decoding
+            e.printStackTrace();
+        }
     }
 
     @Override
     public void onDetach() throws SpRuntimeException {
 
     }
+
+    private String toGroupAddressString(KNXGroupAddress groupAddress) {
+        if(groupAddress instanceof KNXGroupAddress3Level) {
+            KNXGroupAddress3Level castedAddress = (KNXGroupAddress3Level) groupAddress;
+            return castedAddress.getMainGroup() + "/" + castedAddress.getMiddleGroup() + "/" + castedAddress.getSubGroup();
+        } else if(groupAddress instanceof KNXGroupAddress2Level) {
+            KNXGroupAddress2Level castedAddress = (KNXGroupAddress2Level) groupAddress;
+            return castedAddress.getMainGroup() + "/" + castedAddress.getSubGroup();
+        } else if(groupAddress instanceof KNXGroupAddressFreeLevel) {
+            KNXGroupAddressFreeLevel castedAddress = (KNXGroupAddressFreeLevel) groupAddress;
+            return castedAddress.getSubGroup() + "";
+        }
+        throw new RuntimeException("Unknown group address type");
+    }
+
 }
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentController.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentController.java
index 74ed94e..2ca00d5 100644
--- a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentController.java
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentController.java
@@ -23,6 +23,7 @@ import org.streampipes.model.DataProcessorType;
 import org.streampipes.model.graph.DataProcessorDescription;
 import org.streampipes.model.graph.DataProcessorInvocation;
 import org.streampipes.model.schema.PropertyScope;
+import org.streampipes.sdk.builder.PrimitivePropertyBuilder;
 import org.streampipes.sdk.builder.ProcessingElementBuilder;
 import org.streampipes.sdk.builder.StreamRequirementsBuilder;
 import org.streampipes.sdk.extractor.ProcessingElementParameterExtractor;
@@ -31,6 +32,7 @@ import org.streampipes.sdk.helpers.Labels;
 import org.streampipes.sdk.helpers.Locales;
 import org.streampipes.sdk.helpers.OutputStrategies;
 import org.streampipes.sdk.utils.Assets;
+import org.streampipes.sdk.utils.Datatypes;
 import org.streampipes.wrapper.standalone.ConfiguredEventProcessor;
 import org.streampipes.wrapper.standalone.declarer.StandaloneEventProcessingDeclarer;
 
@@ -41,6 +43,12 @@ public class Ets5DataEnrichmentController extends StandaloneEventProcessingDecla
     private static final String DESTINATION_ID_MAPPING = "destination-id-mapping";
     private static final String PAYLOAD_ID_MAPPING = "payload-id-mapping";
 
+    public static final String MAPPING_FIELD_DECODED_GROUP_ADDRESS = "decodedGroupAddress";
+    public static final String MAPPING_FIELD_TYPE = "type";
+    public static final String MAPPING_FIELD_LOCATION = "location";
+    public static final String MAPPING_FIELD_FUNCTION = "function";
+    public static final String MAPPING_FIELD_DECODED_PROPERTY_VALUE = "decodedPropertyValue";
+
     @Override
     public DataProcessorDescription declareModel() {
         return ProcessingElementBuilder
@@ -53,7 +61,13 @@ public class Ets5DataEnrichmentController extends StandaloneEventProcessingDecla
                 .requiredPropertyWithUnaryMapping(EpRequirements.domainPropertyReq(Constants.KNXNET_ID_DESTINATION_ADDRESS), Labels.withId(DESTINATION_ID_MAPPING), PropertyScope.NONE)
                 .requiredPropertyWithUnaryMapping(EpRequirements.domainPropertyReq(Constants.KNXNET_ID_PAYLOAD), Labels.withId(PAYLOAD_ID_MAPPING), PropertyScope.NONE)
                 .build())
-            .outputStrategy(OutputStrategies.keep())
+            .outputStrategy(OutputStrategies.append(
+                PrimitivePropertyBuilder.create(Datatypes.String, MAPPING_FIELD_DECODED_GROUP_ADDRESS).build(),
+                PrimitivePropertyBuilder.create(Datatypes.String, MAPPING_FIELD_TYPE).build(),
+                PrimitivePropertyBuilder.create(Datatypes.String, MAPPING_FIELD_LOCATION).build(),
+                PrimitivePropertyBuilder.create(Datatypes.String, MAPPING_FIELD_FUNCTION).build(),
+                PrimitivePropertyBuilder.create(Datatypes.String, MAPPING_FIELD_DECODED_PROPERTY_VALUE).build()
+            ))
             .requiredFile(Labels.from("File", "ETS5 Project File", "ETS5 Project File (.knxproj)"))
             .build();
     }
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentParameters.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentParameters.java
index a888d7e..e6f010f 100644
--- a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentParameters.java
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/Ets5DataEnrichmentParameters.java
@@ -23,14 +23,13 @@ import org.streampipes.wrapper.params.binding.EventProcessorBindingParams;
 
 public class Ets5DataEnrichmentParameters extends EventProcessorBindingParams {
 
-    private String destinationIdFieldName;
-    private String payloadIdFieldName;
+    private final String destinationIdFieldName;
+    private final String payloadIdFieldName;
 
     public Ets5DataEnrichmentParameters(DataProcessorInvocation graph, String destinationIdFieldName, String payloadIdFieldName) {
         super(graph);
         this.destinationIdFieldName = destinationIdFieldName;
         this.payloadIdFieldName = payloadIdFieldName;
-
     }
 
     public String getDestinationIdFieldName() {
@@ -40,4 +39,5 @@ public class Ets5DataEnrichmentParameters extends EventProcessorBindingParams {
     public String getPayloadIdFieldName() {
         return payloadIdFieldName;
     }
+
 }
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/AddressType.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/AddressType.java
new file mode 100644
index 0000000..45a02d9
--- /dev/null
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/AddressType.java
@@ -0,0 +1,96 @@
+/*
+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.streampipes.processors.processors.ets5.model;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+public class AddressType {
+
+    private final String id;
+    private final int mainType;
+    private final int subType;
+    private final String name;
+
+    public AddressType(String id, int mainType, int subType, String name) {
+        this.id = id;
+        this.mainType = mainType;
+        this.subType = subType;
+        this.name = name;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public int getMainType() {
+        return mainType;
+    }
+
+    public int getSubType() {
+        return subType;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof AddressType)) {
+            return false;
+        }
+
+        AddressType that = (AddressType) o;
+
+        return new EqualsBuilder()
+            .append(getMainType(), that.getMainType())
+            .append(getSubType(), that.getSubType())
+            .append(getId(), that.getId())
+            .append(getName(), that.getName())
+            .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 37)
+            .append(getId())
+            .append(getMainType())
+            .append(getSubType())
+            .append(getName())
+            .toHashCode();
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+            .append("id", id)
+            .append("mainType", mainType)
+            .append("subType", subType)
+            .append("name", name)
+            .toString();
+    }
+
+}
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Ets5Model.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Ets5Model.java
new file mode 100644
index 0000000..274b38f
--- /dev/null
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Ets5Model.java
@@ -0,0 +1,81 @@
+/*
+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.streampipes.processors.processors.ets5.model;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.plc4x.java.knxnetip.readwrite.KNXGroupAddress;
+
+import java.util.Map;
+
+public class Ets5Model {
+
+    private final byte groupAddressType;
+    private final Map<KNXGroupAddress, GroupAddress> groupAddresses;
+
+    public Ets5Model(byte groupAddressType, Map<KNXGroupAddress, GroupAddress> groupAddresses) {
+        this.groupAddressType = groupAddressType;
+        this.groupAddresses = groupAddresses;
+    }
+
+    public byte getGroupAddressType() {
+        return groupAddressType;
+    }
+
+    public Map<KNXGroupAddress, GroupAddress> getGroupAddresses() {
+        return groupAddresses;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof Ets5Model)) {
+            return false;
+        }
+
+        Ets5Model ets5Model = (Ets5Model) o;
+
+        return new EqualsBuilder()
+            .append(getGroupAddressType(), ets5Model.getGroupAddressType())
+            .append(getGroupAddresses(), ets5Model.getGroupAddresses())
+            .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 37)
+            .append(getGroupAddressType())
+            .append(getGroupAddresses())
+            .toHashCode();
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+            .append("groupAddressType", groupAddressType)
+            .append("groupAddresses", groupAddresses)
+            .toString();
+    }
+
+}
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Function.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Function.java
new file mode 100644
index 0000000..fdc9d9c
--- /dev/null
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/Function.java
@@ -0,0 +1,96 @@
+/*
+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.streampipes.processors.processors.ets5.model;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+public class Function {
+
+    private final String id;
+    private final String name;
+    private final String type;
+    private final String spaceName;
+
+    public Function(String id, String name, String type, String spaceName) {
+        this.id = id;
+        this.name = name;
+        this.type = type;
+        this.spaceName = spaceName;
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getSpaceName() {
+        return spaceName;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof Function)) {
+            return false;
+        }
+
+        Function function = (Function) o;
+
+        return new EqualsBuilder()
+            .append(getId(), function.getId())
+            .append(getName(), function.getName())
+            .append(getType(), function.getType())
+            .append(getSpaceName(), function.getSpaceName())
+            .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 37)
+            .append(getId())
+            .append(getName())
+            .append(getType())
+            .append(getSpaceName())
+            .toHashCode();
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+            .append("id", id)
+            .append("name", name)
+            .append("type", type)
+            .append("spaceName", spaceName)
+            .toString();
+    }
+
+}
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/GroupAddress.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/GroupAddress.java
new file mode 100644
index 0000000..42e4344
--- /dev/null
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/model/GroupAddress.java
@@ -0,0 +1,99 @@
+/*
+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.streampipes.processors.processors.ets5.model;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import org.apache.plc4x.java.knxnetip.readwrite.KNXGroupAddress;
+
+import java.util.Objects;
+
+public class GroupAddress {
+
+    private final KNXGroupAddress groupAddress;
+    private final String name;
+    private final AddressType type;
+    private final Function function;
+
+    public GroupAddress(KNXGroupAddress groupAddress, String name, AddressType type, Function function) {
+        this.groupAddress = groupAddress;
+        this.name = name;
+        this.type = type;
+        this.function = function;
+    }
+
+    public KNXGroupAddress getGroupAddress() {
+        return groupAddress;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public AddressType getType() {
+        return type;
+    }
+
+    public Function getFunction() {
+        return function;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof GroupAddress)) {
+            return false;
+        }
+
+        GroupAddress that = (GroupAddress) o;
+
+        return new EqualsBuilder()
+            .append(getGroupAddress(), that.getGroupAddress())
+            .append(getName(), that.getName())
+            .append(getType(), that.getType())
+            .append(getFunction(), that.getFunction())
+            .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder(17, 37)
+            .append(getGroupAddress())
+            .append(getName())
+            .append(getType())
+            .append(getFunction())
+            .toHashCode();
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+            .append("groupAddress", groupAddress.toString(ToStringStyle.SHORT_PREFIX_STYLE))
+            .append("name", name)
+            .append("type", type)
+            .append("function", function)
+            .toString();
+    }
+
+}
diff --git a/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/utils/Ets5Parser.java b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/utils/Ets5Parser.java
new file mode 100644
index 0000000..7244d4a
--- /dev/null
+++ b/sandbox/test-streampipes-plc4x-processors/src/main/java/org/apache/plc4x/java/streampipes/processors/processors/ets5/utils/Ets5Parser.java
@@ -0,0 +1,178 @@
+/*
+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.streampipes.processors.processors.ets5.utils;
+
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipFile;
+import org.apache.plc4x.java.knxnetip.readwrite.KNXGroupAddress;
+import org.apache.plc4x.java.knxnetip.readwrite.io.KNXGroupAddressIO;
+import org.apache.plc4x.java.streampipes.processors.processors.ets5.model.AddressType;
+import org.apache.plc4x.java.streampipes.processors.processors.ets5.model.Ets5Model;
+import org.apache.plc4x.java.streampipes.processors.processors.ets5.model.Function;
+import org.apache.plc4x.java.streampipes.processors.processors.ets5.model.GroupAddress;
+import org.apache.plc4x.java.utils.ParseException;
+import org.apache.plc4x.java.utils.ReadBuffer;
+import org.mapdb.Fun;
+import org.w3c.dom.*;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class Ets5Parser {
+
+    public Ets5Model parse(File knxprojFile) {
+        try {
+            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+            DocumentBuilder builder = factory.newDocumentBuilder();
+            XPathFactory xPathFactory = XPathFactory.newInstance();
+            XPath xPath = xPathFactory.newXPath();
+
+            ZipFile zipFile = new ZipFile(knxprojFile);
+
+            ////////////////////////////////////////////////////////////////////////////////
+            // File containing the information on the type of encoding used for group addresses.
+            ////////////////////////////////////////////////////////////////////////////////
+            ZipArchiveEntry projectHeaderFile = zipFile.getEntry("P-05CD/project.xml");
+            if(projectHeaderFile == null) {
+                throw new RuntimeException("Error accessing project header file.");
+            }
+            Document projectHeaderDoc = builder.parse(zipFile.getInputStream(projectHeaderFile));
+            final XPathExpression xpathGroupAddressStyle = xPath.compile("/KNX/Project/ProjectInformation/@GroupAddressStyle");
+            Attr groupAddressStyle = (Attr) xpathGroupAddressStyle.evaluate(projectHeaderDoc, XPathConstants.NODE);
+            byte groupAddressStyleCode = getGroupAddressLevel(groupAddressStyle.getTextContent());
+
+            ////////////////////////////////////////////////////////////////////////////////
+            // General information on the type of encoding and the value ranges.
+            ////////////////////////////////////////////////////////////////////////////////
+            ZipArchiveEntry knxMasterDataFile = zipFile.getEntry("knx_master.xml");
+            if(knxMasterDataFile == null) {
+                throw new RuntimeException("Error accessing KNX master file.");
+            }
+            Document knxMasterDoc = builder.parse(zipFile.getInputStream(knxMasterDataFile));
+            final XPathExpression xpathDatapointSubtype = xPath.compile("//DatapointSubtype");
+            NodeList datapointSubtypeNodes = (NodeList) xpathDatapointSubtype.evaluate(knxMasterDoc, XPathConstants.NODESET);
+            Map<String, AddressType> addressTypes = new HashMap<>();
+            for(int i = 0; i < datapointSubtypeNodes.getLength(); i++) {
+                final Element datapointSubtypeNode = (Element) datapointSubtypeNodes.item(i);
+                final String id = datapointSubtypeNode.getAttribute("Id");
+                final int subType = Integer.parseInt(datapointSubtypeNode.getAttribute("Number"));
+                final int mainType = Integer.parseInt(
+                    ((Element) datapointSubtypeNode.getParentNode().getParentNode()).getAttribute("Number"));
+                final String name = datapointSubtypeNode.getAttribute("Text");
+                addressTypes.put(id, new AddressType(id, mainType, subType, name));
+            }
+
+            ////////////////////////////////////////////////////////////////////////////////
+            // File containing all the information about group addresses used, their names, types etc.
+            ////////////////////////////////////////////////////////////////////////////////
+            ZipArchiveEntry projectFile = zipFile.getEntry("P-05CD/0.xml");
+            if(projectFile == null) {
+                throw new RuntimeException("Error accessing project file.");
+            }
+            Document projectDoc = builder.parse(zipFile.getInputStream(projectFile));
+
+            final Map<String, Function> groupAddressRefs = new HashMap();
+            final XPathExpression xpathGroupAddressRef = xPath.compile("//GroupAddressRef");
+            NodeList groupAddressRefNodes = (NodeList) xpathGroupAddressRef.evaluate(projectDoc, XPathConstants.NODESET);
+            for(int i = 0; i < groupAddressRefNodes.getLength(); i++) {
+                final Element groupAddressRefNode = (Element) groupAddressRefNodes.item(i);
+                final String refId = groupAddressRefNode.getAttribute("RefId");
+                final Element functionNode = (Element) groupAddressRefNode.getParentNode();
+                final String functionName = functionNode.getAttribute("Name");
+                // Function Type information is stored in knx_master.xml (//FunctionType[@id='functionTypeId']
+                final String functionTypeId = functionNode.getAttribute("Type");
+                final Element spaceNode = (Element) functionNode.getParentNode();
+                final String spaceName = spaceNode.getAttribute("Name");
+
+                final Function function = new Function(refId, functionName, functionTypeId, spaceName);
+                if(groupAddressRefs.containsKey(refId)) {
+                    System.out.println("Duplicate refId");
+                }
+                groupAddressRefs.put(refId, function);
+            }
+
+            final XPathExpression xpathGroupAddresses = xPath.compile("//GroupAddress");
+            NodeList groupAddressNodes = (NodeList) xpathGroupAddresses.evaluate(projectDoc, XPathConstants.NODESET);
+            Map<KNXGroupAddress, GroupAddress> groupAddresses = new HashMap<>();
+            for(int i = 0; i < groupAddressNodes.getLength(); i++) {
+                final Element groupAddressNode = (Element) groupAddressNodes.item(i);
+
+                final String id = groupAddressNode.getAttribute("Id");
+                final Function function = groupAddressRefs.get(id);
+
+                final int addressInt = Integer.parseInt(groupAddressNode.getAttribute("Address"));
+                final byte[] addressBytes = new byte[2];
+                addressBytes[0] = (byte) ((addressInt >> 8) & 0xFF);
+                addressBytes[1] = (byte) (addressInt & 0xFF);
+                ReadBuffer readBuffer = new ReadBuffer(addressBytes);
+                final KNXGroupAddress knxGroupAddress = KNXGroupAddressIO.parse(readBuffer, groupAddressStyleCode);
+
+                final String name = groupAddressNode.getAttribute("Name");
+
+                final String typeString = groupAddressNode.getAttribute("DatapointType");
+                final AddressType addressType = addressTypes.get(typeString);
+
+                GroupAddress groupAddress = new GroupAddress(knxGroupAddress, name, addressType, function);
+                groupAddresses.put(knxGroupAddress, groupAddress);
+            }
+
+            return new Ets5Model(groupAddressStyleCode, groupAddresses);
+        } catch (IOException e) {
+            // Zip and Xml Stuff
+            e.printStackTrace();
+        } catch (ParserConfigurationException e) {
+            // XML Stuff
+            e.printStackTrace();
+        } catch (SAXException e) {
+            // XML Stuff
+            e.printStackTrace();
+        } catch (XPathExpressionException e) {
+            // XML Stuff
+            e.printStackTrace();
+        } catch (ParseException e) {
+            // KNXNet/IP Parser Stuff
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    private byte getGroupAddressLevel(String knxprojValue) {
+        if("ThreeLevel".equals(knxprojValue)) {
+            return (byte) 3;
+        } else if("TwoLevel".equals(knxprojValue)) {
+            return (byte) 2;
+        } else if("Free".equals(knxprojValue)) {
+            return (byte) 1;
+        }
+        throw new RuntimeException("Unsupported GroupAddressStyle=" + knxprojValue);
+    }
+
+    public static void main(String[] args) {
+        final Ets5Model model = new Ets5Parser().parse(new File("/Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Stettiner Str. 13/Stettiner Str.knxproj"));
+        System.out.println(model);
+    }
+
+}


[plc4x] 01/03: - Extended the template to auto-generate hashCode, equals and toString methods

Posted by cd...@apache.org.
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 aab4e24b91b5182588fd84c4b459f99712665de3
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Nov 21 16:15:10 2019 +0100

    - Extended the template to auto-generate hashCode, equals and toString methods
---
 .../resources/templates/java/pojo-template.ftlh    | 57 ++++++++++++++++++++++
 1 file changed, 57 insertions(+)

diff --git a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
index a5c1e60..e4c5ff1 100644
--- a/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
+++ b/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
@@ -41,8 +41,12 @@ package ${helper.packageName(protocolName, languageName, outputFlavor)};
 <#if helper.getEnumTypes(type)?has_content>import ${helper.packageName(protocolName, languageName, outputFlavor)}.types.*;</#if>
 
 import com.fasterxml.jackson.annotation.*;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
 import org.apache.plc4x.java.utils.Message;
 
+import java.util.Objects;
+
 <#if type.abstract>@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "className")</#if>
 public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??> extends ${type.parentType.name}</#if> implements Message {
 
@@ -206,4 +210,57 @@ public<#if type.abstract> abstract</#if> class ${typeName}<#if type.parentType??
         return lengthInBits / 8;
     }
 
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (!(o instanceof ${typeName})) {
+            return false;
+        }
+        ${typeName} that = (${typeName}) o;
+        return
+            <#if type.propertyFields?has_content>
+            <#list type.propertyFields as field>
+            (get${field.name?cap_first}() == that.get${field.name?cap_first}()) &&
+            </#list>
+            </#if>
+            <#if type.parentType??>
+            super.equals(that) &&
+            </#if>
+            true;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(
+            <#if type.parentType??>
+            super.hashCode()<#if type.propertyFields?has_content>,</#if>
+            </#if>
+            <#if type.propertyFields?has_content>
+            <#list type.propertyFields as field>
+            get${field.name?cap_first}()<#sep>,</#sep>
+            </#list>
+            </#if>
+        );
+    }
+
+    @Override
+    public String toString() {
+        return toString(ToStringStyle.SHORT_PREFIX_STYLE);
+    }
+
+    public String toString(ToStringStyle style) {
+        return new ToStringBuilder(this, style)
+            <#if type.parentType??>
+            .appendSuper(super.toString(style))
+            </#if>
+            <#if type.propertyFields?has_content>
+            <#list type.propertyFields as field>
+            .append("${field.name}", get${field.name?cap_first}())
+            </#list>
+            </#if>
+            .toString();
+    }
+
 }
\ No newline at end of file


[plc4x] 02/03: - Deleted an obsolete test.

Posted by cd...@apache.org.
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 fb28a8acad6ddc30fa70b4b367f1f3dacbd41e1f
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Nov 21 16:15:35 2019 +0100

    - Deleted an obsolete test.
---
 .../java/org/apache/plc4x/karaf/FeatureTest.java   | 91 ----------------------
 1 file changed, 91 deletions(-)

diff --git a/plc4j/karaf-features/s7/src/test/java/org/apache/plc4x/karaf/FeatureTest.java b/plc4j/karaf-features/s7/src/test/java/org/apache/plc4x/karaf/FeatureTest.java
deleted file mode 100644
index eb74608..0000000
--- a/plc4j/karaf-features/s7/src/test/java/org/apache/plc4x/karaf/FeatureTest.java
+++ /dev/null
@@ -1,91 +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
-
-  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.karaf;
-
-import org.apache.plc4x.java.spi.PlcDriver;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.Configuration;
-import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.PaxExam;
-import org.ops4j.pax.exam.options.MavenArtifactUrlReference;
-import org.ops4j.pax.exam.options.MavenUrlReference;
-import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
-import org.ops4j.pax.exam.spi.reactors.PerClass;
-import org.ops4j.pax.exam.spi.reactors.PerMethod;
-
-import javax.inject.Inject;
-
-import java.io.File;
-
-import static org.junit.Assert.assertNotNull;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
-import static org.ops4j.pax.exam.CoreOptions.junitBundles;
-import static org.ops4j.pax.exam.CoreOptions.maven;
-import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
-import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
-
-@RunWith(PaxExam.class)
-@ExamReactorStrategy(PerMethod.class)
-public class FeatureTest {
-
-    @Inject
-    private PlcDriver plcDriver;
-
-    @Configuration
-    public Option[] config() {
-        MavenArtifactUrlReference karafUrl = maven()
-            .groupId("org.apache.karaf")
-            .artifactId("apache-karaf")
-            .version("3.0.0")
-            .type("tar.gz");
-        MavenUrlReference karafStandardRepo = maven()
-            .groupId("org.apache.karaf.features")
-            .artifactId("standard")
-            .classifier("features")
-            .version("4.2.1")
-            .type("xml")
-            .versionAsInProject();
-        return new Option[] {
-            // KarafDistributionOption.debugConfiguration("5005", true),
-            karafDistributionConfiguration()
-                .frameworkUrl(karafUrl)
-                .unpackDirectory(new File("target/exam"))
-                .useDeployFolder(false),
-            keepRuntimeFolder(),
-            features(karafStandardRepo , "scr"),
-            mavenBundle()
-                .groupId("org.ops4j.pax.exam.samples")
-                .artifactId("pax-exam-sample8-ds")
-                .version("4.2.1")
-                //.versionAsInProject()
-            .start(),
-        };
-    }
-
-    @Test
-    public void getHelloService() {
-        assertNotNull(plcDriver);
-        // assertEquals("Hello Pax!", helloService.getMessage());
-    }
-
-}