You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by jf...@apache.org on 2020/01/29 12:57:40 UTC

[plc4x] 03/06: [added] added first Milo ExampleServer inside of the manual tests

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

jfeinauer pushed a commit to branch fixes-mathi
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit bf68bfb467b42d4c4a59bc012f47f33091181809
Author: Matthias Milan Strljic <ma...@gmail.com>
AuthorDate: Tue Jan 28 21:40:28 2020 +0100

    [added] added first Milo ExampleServer inside of the manual tests
    
    Signed-off-by: Matthias Milan Strljic <Ma...@googlemail.com>
---
 .../apache/plc4x/java/opcua/ManualPLC4XOpcua.java  | 48 +++++++++++++---------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
index 14c51b5..ce35fe9 100644
--- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
+++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java
@@ -24,11 +24,12 @@ import org.apache.plc4x.java.api.messages.*;
 import org.apache.plc4x.java.api.model.PlcConsumerRegistration;
 import org.apache.plc4x.java.api.model.PlcField;
 import org.apache.plc4x.java.api.types.PlcSubscriptionType;
-import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionRequest;
-import org.apache.plc4x.java.spi.model.SubscriptionPlcField;
 import org.apache.plc4x.java.opcua.connection.OpcuaTcpPlcConnection;
 import org.apache.plc4x.java.opcua.protocol.OpcuaField;
 import org.apache.plc4x.java.opcua.protocol.OpcuaPlcFieldHandler;
+import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionRequest;
+import org.apache.plc4x.java.spi.model.SubscriptionPlcField;
+import org.eclipse.milo.examples.server.ExampleServer;
 
 import java.math.BigInteger;
 import java.time.Duration;
@@ -50,30 +51,37 @@ import java.util.function.Consumer;
  * Created by Matthias Milan Strljic on 10.05.2019
  */
 public class ManualPLC4XOpcua {
-    private static final String BOOL_IDENTIFIER = "ns=2;i=10844";
-    private static final String BYTE_STRING_IDENTIFIER = "ns=2;i=10858";
-    private static final String BYTE_IDENTIFIER = "ns=2;i=10846";
-    private static final String DOUBLE_IDENTIFIER = "ns=2;i=10854";
-    private static final String FLOAT_IDENTIFIER = "ns=2;i=10853";
-    private static final String INT16_IDENTIFIER = "ns=2;i=10847";
-    private static final String INT32_IDENTIFIER = "ns=2;i=10849";
-    private static final String INT64_IDENTIFIER = "ns=2;i=10851";
-    private static final String INTEGER_IDENTIFIER = "ns=2;i=10869";
-    private static final String SBYTE_IDENTIFIER = "ns=2;i=10845";
-    private static final String STRING_IDENTIFIER = "ns=2;i=10855";
-    private static final String UINT16_IDENTIFIER = "ns=2;i=10848";
-    private static final String UINT32_IDENTIFIER = "ns=2;i=10850";
-    private static final String UINT64_IDENTIFIER = "ns=2;i=10852";
-    private static final String UINTEGER_IDENTIFIER = "ns=2;i=10870";
+    private static final String BOOL_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Boolean";
+    private static final String BYTE_STRING_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/ByteString";
+    private static final String BYTE_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Byte";
+    private static final String DOUBLE_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Double";
+    private static final String FLOAT_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Float";
+    private static final String INT16_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Int16";
+    private static final String INT32_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Int32";
+    private static final String INT64_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Int64";
+    private static final String INTEGER_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Integer";
+    private static final String SBYTE_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/SByte";
+    private static final String STRING_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/String";
+    private static final String UINT16_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/UInt16";
+    private static final String UINT32_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/UInt32";
+    private static final String UINT64_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/UInt64";
+    private static final String UINTEGER_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/UInteger";
     private static final String DOES_NOT_EXIST_IDENTIFIER = "ns=2;i=12512623";
 
     public static void main(String args[]) {
+        try {
+            ExampleServer testServer = new ExampleServer();
+            testServer.startup().get();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         OpcuaTcpPlcConnection opcuaConnection = null;
         OpcuaPlcFieldHandler fieldH = new OpcuaPlcFieldHandler();
-        PlcField field = fieldH.createField("ns=2;i=10855");
+        PlcField field = fieldH.createField(BOOL_IDENTIFIER);
         try {
             opcuaConnection = (OpcuaTcpPlcConnection)
-                new PlcDriverManager().getConnection("opcua:tcp://localhost:4843?discovery=true");
+                new PlcDriverManager().getConnection("opcua:tcp://127.0.0.1:12686/milo?discovery=false");
 
         } catch (PlcConnectionException e) {
             e.printStackTrace();
@@ -108,7 +116,7 @@ public class ManualPLC4XOpcua {
 
             PlcWriteRequest.Builder wBuilder = opcuaConnection.writeRequestBuilder();
             wBuilder.addItem("w-Bool", BOOL_IDENTIFIER, true);
-            wBuilder.addItem("w-ByteString", BYTE_STRING_IDENTIFIER, "TEST".getBytes());
+            //wBuilder.addItem("w-ByteString", BYTE_STRING_IDENTIFIER, "TEST".getBytes());
             wBuilder.addItem("w-Byte", BYTE_IDENTIFIER, (byte) 1);
             wBuilder.addItem("w-Double", DOUBLE_IDENTIFIER, (double) 0.25);
             wBuilder.addItem("w-Float", FLOAT_IDENTIFIER, (float) 0.25);