You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2020/05/09 09:32:40 UTC

[incubator-streampipes-extensions] 01/01: Working on STREAMPIPES-118: Add file upload, update API

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

zehnder pushed a commit to branch STREAMPIPES-118
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes-extensions.git

commit 100c00d125fc0fb439d802db132f42eaff671327
Author: Philipp Zehnder <ze...@fzi.de>
AuthorDate: Sat May 9 11:31:54 2020 +0200

    Working on STREAMPIPES-118: Add file upload, update API
---
 .../connect/adapters/plc4x/s7/Plc4xS7Adapter.java  |  52 +++++++++++----------
 .../documentation.md                               |  33 +++++++++++++
 .../icon.png                                       | Bin 0 -> 46022 bytes
 .../strings.en                                     |  29 ++++++++++++
 4 files changed, 90 insertions(+), 24 deletions(-)

diff --git a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
index 37a286b..2e72cd1 100644
--- a/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
+++ b/streampipes-connect-adapters/src/main/java/org/apache/streampipes/connect/adapters/plc4x/s7/Plc4xS7Adapter.java
@@ -18,6 +18,7 @@
 
 package org.apache.streampipes.connect.adapters.plc4x.s7;
 
+import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIConversion;
 import org.apache.plc4x.java.PlcDriverManager;
 import org.apache.plc4x.java.api.PlcConnection;
 import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
@@ -38,8 +39,11 @@ import org.apache.streampipes.model.schema.EventSchema;
 import org.apache.streampipes.sdk.StaticProperties;
 import org.apache.streampipes.sdk.builder.PrimitivePropertyBuilder;
 import org.apache.streampipes.sdk.builder.adapter.SpecificDataStreamAdapterBuilder;
+import org.apache.streampipes.sdk.helpers.Alternatives;
 import org.apache.streampipes.sdk.helpers.Labels;
+import org.apache.streampipes.sdk.helpers.Locales;
 import org.apache.streampipes.sdk.helpers.Options;
+import org.apache.streampipes.sdk.utils.Assets;
 import org.apache.streampipes.sdk.utils.Datatypes;
 
 import java.util.ArrayList;
@@ -53,17 +57,21 @@ public class Plc4xS7Adapter extends PullAdapter {
 
     /**
      * A unique id to identify the Plc4xS7Adapter
-      */
+     */
     public static final String ID = "org.apache.streampipes.connect.adapters.plc4x.s7";
 
     /**
      * Keys of user configuration parameters
      */
-    private static final String PLC_IP = "PLC_IP";
-    private static final String PLC_NODES = "PLC_NODES";
-    private static final String PLC_NODE_NAME = "PLC_NODE_NAME";
-    private static final String PLC_NODE_RUNTIME_NAME = "PLC_NODE_RUNTIME_NAME";
-    private static final String PLC_NODE_TYPE = "PLC_NODE_TYPE";
+    private static final String PLC_IP = "plc_ip";
+    private static final String PLC_NODES = "plc_nodes";
+    private static final String PLC_NODE_NAME = "plc_node_name";
+    private static final String PLC_NODE_RUNTIME_NAME = "plc_node_runtime_name";
+    private static final String PLC_NODE_TYPE = "plc_node_type";
+    private static final String PLC_NODES_FILE = "plc_nodes_file";
+    private static final String CONFIGURE = "configure";
+    private static final String MANUALLY = "manually";
+    private static final String CSV_UPLOAD = "csv-upload";
 
     /**
      * Values of user configuration parameters
@@ -87,6 +95,7 @@ public class Plc4xS7Adapter extends PullAdapter {
     }
 
 
+
     /**
      * Describe the adapter adapter and define what user inputs are required. Currently users can just select one node, this will be extended in the future
      * @return
@@ -94,28 +103,23 @@ public class Plc4xS7Adapter extends PullAdapter {
     @Override
     public SpecificAdapterStreamDescription declareModel() {
 
-        SpecificAdapterStreamDescription description = SpecificDataStreamAdapterBuilder.create(ID, "PLC4X S7", "Connect directly to your PLC")
-                .iconUrl("plc4x.png")
+        SpecificAdapterStreamDescription description = SpecificDataStreamAdapterBuilder.create(ID)
+                .withLocales(Locales.EN)
+                .withAssets(Assets.DOCUMENTATION, Assets.ICON)
                 .category(AdapterType.Manufacturing)
-                .requiredTextParameter(Labels.from(PLC_IP, "PLC Address", "Example: 192.168.34.56"))
-
-//                .requiredAlternatives(Labels.withId(ACCESS_MODE),
-//                  Alternatives.from(Labels.withId(ANONYMOUS_ACCESS)),
-//                  Alternatives.from(Labels.withId(USERNAME_ACCESS),
-//        StaticProperties.group(Labels.withId(USERNAME_GROUP),
-//                StaticProperties.stringFreeTextProperty(Labels.withId(USERNAME)),
-//                StaticProperties.secretValue(Labels.withId(PASSWORD))))
-                .requiredCollection(Labels.from(PLC_NODES, "Nodes", "The PLC Nodes"),
-                    StaticProperties.stringFreeTextProperty(Labels.from(PLC_NODE_RUNTIME_NAME, "Runtime Name", "example: temperatur")),
-                    StaticProperties.stringFreeTextProperty(Labels.from(PLC_NODE_NAME, "Node Name", "example: %Q0.4")),
-                    StaticProperties.singleValueSelection(Labels.from(PLC_NODE_TYPE, "Data Type", "example: bool"),
-                            Options.from("Bool",  "Byte", "Int", "Word", "Real"))
-
-                )
+                .requiredTextParameter(Labels.withId(PLC_IP))
+                .requiredAlternatives(Labels.withId(CONFIGURE),
+                                Alternatives.from(Labels.withId(MANUALLY),
+                                StaticProperties.collection(Labels.withId(PLC_NODES),
+                                        StaticProperties.stringFreeTextProperty(Labels.withId(PLC_NODE_RUNTIME_NAME)),
+                                        StaticProperties.stringFreeTextProperty(Labels.withId(PLC_NODE_NAME)),
+                                        StaticProperties.singleValueSelection(Labels.withId(PLC_NODE_TYPE),
+                                                Options.from("Bool",  "Byte", "Int", "Word", "Real")))),
+                                Alternatives.from(Labels.withId(CSV_UPLOAD),
+                                StaticProperties.fileProperty(Labels.withId(PLC_NODES_FILE))))
                 .build();
         description.setAppId(ID);
 
-
         return description;
     }
 
diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/documentation.md b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/documentation.md
new file mode 100644
index 0000000..c3da505
--- /dev/null
+++ b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/documentation.md
@@ -0,0 +1,33 @@
+<!--
+  ~ 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.
+  ~
+  -->
+
+## ISS Adapter
+
+<p align="center"> 
+    <img src="icon.png" width="150px;" class="pe-image-documentation"/>
+</p>
+
+***
+
+## Description
+
+Shows the live position of the International Space Station (ISS), updated every two seconds.
+
+
+***
+
diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/icon.png b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/icon.png
new file mode 100644
index 0000000..cfb6339
Binary files /dev/null and b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/icon.png differ
diff --git a/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/strings.en b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/strings.en
new file mode 100644
index 0000000..5615e66
--- /dev/null
+++ b/streampipes-connect-adapters/src/main/resources/org.apache.streampipes.connect.adapters.plc4x.s7/strings.en
@@ -0,0 +1,29 @@
+org.apache.streampipes.connect.adapters.plc4x.s7.title=PLC4X S7
+org.apache.streampipes.connect.adapters.plc4x.s7.description=Connect directly to your PLC
+
+plc_ip.title=PLC Address
+plc_ip.description=Example: 192.168.34.56
+
+configure.title=Configuration
+configure.description=
+
+manually.title=Enter Manually
+manually.description=Enter the addresses to read the data from manually
+
+plc_nodes.title=Nodes
+plc_nodes.description=Define the nodes of the PLC
+
+plc_node_runtime_name.title=Runtime Name
+plc_node_runtime_name.description=example: temperature
+
+plc_node_name.title=Node Name
+plc_node_name.description=example: %Q0.4
+
+plc_node_type.title=Data Type
+plc_node_type.description=example: bool
+
+csv-upload.title=Upload CSV
+csv-upload.description=Export a CSV file with the configurations from the TIA portal
+
+plc_nodes_file.title=CSV File
+plc_nodes_file.description=Contains three columns 'Name', 'Data Type', 'Logical Address'