You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2020/05/05 23:27:19 UTC

[plc4x] branch features/generated-ads-driver created (now 3010fdd)

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

ldywicki pushed a change to branch features/generated-ads-driver
in repository https://gitbox.apache.org/repos/asf/plc4x.git.


      at 3010fdd  PLC4X-191 Rearrange fields in ams status type.

This branch includes the following new commits:

     new f738bc4  Fix generic boundaries for ConversationContext and wrapper of BitOutput.
     new 3010fdd  PLC4X-191 Rearrange fields in ams status type.

The 2 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.



[plc4x] 02/02: PLC4X-191 Rearrange fields in ams status type.

Posted by ld...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ldywicki pushed a commit to branch features/generated-ads-driver
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 3010fdd15524410dfd55746562ed44bcee0fe80f
Author: Łukasz Dywicki <lu...@code-house.org>
AuthorDate: Wed May 6 01:05:03 2020 +0200

    PLC4X-191 Rearrange fields in ams status type.
    
    This change makes parser match received bit order in received byte sequence and not an sequence written using little endian notation.
---
 .../main/resources/protocols/amsads/amsads.mspec   |   6 +-
 .../java/amsads/StateSerializerParserTest.java     |  30 ++++++
 .../testsuite/StateParserSerializerTest.xml        | 119 +++++++++++++++++++++
 3 files changed, 153 insertions(+), 2 deletions(-)

diff --git a/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec b/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec
index 0319554..09497fb 100644
--- a/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec
+++ b/protocols/amsads/src/main/resources/protocols/amsads/amsads.mspec
@@ -157,9 +157,9 @@
     ['0x0009' ADS_READ_WRITE]
 ]
 
+// State is composed of two bytes which can be read as uint with little endian coding
+// that's why order of fields here reflects endianness
 [type 'State'
-    [simple     bit 'broadcast'             ]
-    [reserved   int 7 '0x0'                 ]
     [simple     bit 'initCommand'           ]
     [simple     bit 'updCommand'            ]
     [simple     bit 'timestampAdded'        ]
@@ -168,6 +168,8 @@
     [simple     bit 'adsCommand'            ]
     [simple     bit 'noReturn'              ]
     [simple     bit 'response'              ]
+    [simple     bit 'broadcast'             ]
+    [reserved   int 7 '0x0'                 ]
 ]
 
 // It is not only possible to exchange data between TwinCAT modules on one PC, it is even possible to do so by ADS
diff --git a/sandbox/test-java-amsads-driver/src/test/java/org/apache/plc4x/java/amsads/StateSerializerParserTest.java b/sandbox/test-java-amsads-driver/src/test/java/org/apache/plc4x/java/amsads/StateSerializerParserTest.java
new file mode 100644
index 0000000..648fc7f
--- /dev/null
+++ b/sandbox/test-java-amsads-driver/src/test/java/org/apache/plc4x/java/amsads/StateSerializerParserTest.java
@@ -0,0 +1,30 @@
+/*
+  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.amsads;
+
+import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner;
+
+public class StateSerializerParserTest extends ParserSerializerTestsuiteRunner {
+
+    public StateSerializerParserTest() {
+        super("/testsuite/StateParserSerializerTest.xml");
+    }
+
+}
diff --git a/sandbox/test-java-amsads-driver/src/test/resources/testsuite/StateParserSerializerTest.xml b/sandbox/test-java-amsads-driver/src/test/resources/testsuite/StateParserSerializerTest.xml
new file mode 100644
index 0000000..3f72908
--- /dev/null
+++ b/sandbox/test-java-amsads-driver/src/test/resources/testsuite/StateParserSerializerTest.xml
@@ -0,0 +1,119 @@
+<?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.
+  -->
+<test:testsuite xmlns:test="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd" bigEndian="true">
+
+  <name>State</name>
+
+  <testcase>
+    <name>State ADS_COMMAND</name>
+    <raw>0400</raw>
+    <root-type>State</root-type>
+    <xml>
+      <State className="org.apache.plc4x.java.amsads.readwrite.State">
+        <initCommand>false</initCommand>
+        <updCommand>false</updCommand>
+        <timestampAdded>false</timestampAdded>
+        <highPriorityCommand>false</highPriorityCommand>
+        <systemCommand>false</systemCommand>
+        <adsCommand>true</adsCommand>
+        <noReturn>false</noReturn>
+        <response>false</response>
+        <broadcast>false</broadcast>
+      </State>
+    </xml>
+  </testcase>
+
+  <testcase>
+    <name>State ADS_COMMAND RESPONSE</name>
+    <raw>0500</raw>
+    <root-type>State</root-type>
+    <xml>
+      <State className="org.apache.plc4x.java.amsads.readwrite.State">
+        <initCommand>false</initCommand>
+        <updCommand>false</updCommand>
+        <timestampAdded>false</timestampAdded>
+        <highPriorityCommand>false</highPriorityCommand>
+        <systemCommand>false</systemCommand>
+        <adsCommand>true</adsCommand>
+        <noReturn>false</noReturn>
+        <response>true</response>
+        <broadcast>false</broadcast>
+      </State>
+    </xml>
+  </testcase>
+
+  <testcase>
+    <name>State ADS_COMMAND RESPONSE BROADCAST</name>
+    <raw>0580</raw>
+    <root-type>State</root-type>
+    <xml>
+      <State className="org.apache.plc4x.java.amsads.readwrite.State">
+        <initCommand>false</initCommand>
+        <updCommand>false</updCommand>
+        <timestampAdded>false</timestampAdded>
+        <highPriorityCommand>false</highPriorityCommand>
+        <systemCommand>false</systemCommand>
+        <adsCommand>true</adsCommand>
+        <noReturn>false</noReturn>
+        <response>true</response>
+        <broadcast>true</broadcast>
+      </State>
+    </xml>
+  </testcase>
+
+  <testcase>
+    <name>State ALL FLAGS 1</name>
+    <raw>FF80</raw>
+    <root-type>State</root-type>
+    <xml>
+      <State className="org.apache.plc4x.java.amsads.readwrite.State">
+        <initCommand>true</initCommand>
+        <updCommand>true</updCommand>
+        <timestampAdded>true</timestampAdded>
+        <highPriorityCommand>true</highPriorityCommand>
+        <systemCommand>true</systemCommand>
+        <adsCommand>true</adsCommand>
+        <noReturn>true</noReturn>
+        <response>true</response>
+        <broadcast>true</broadcast>
+      </State>
+    </xml>
+  </testcase>
+
+  <testcase>
+    <name>State ALL BUT UDP 1</name>
+    <raw>BF80</raw>
+    <root-type>State</root-type>
+    <xml>
+      <State className="org.apache.plc4x.java.amsads.readwrite.State">
+        <initCommand>true</initCommand>
+        <updCommand>false</updCommand>
+        <timestampAdded>true</timestampAdded>
+        <highPriorityCommand>true</highPriorityCommand>
+        <systemCommand>true</systemCommand>
+        <adsCommand>true</adsCommand>
+        <noReturn>true</noReturn>
+        <response>true</response>
+        <broadcast>true</broadcast>
+      </State>
+    </xml>
+  </testcase>
+
+</test:testsuite>
\ No newline at end of file


[plc4x] 01/02: Fix generic boundaries for ConversationContext and wrapper of BitOutput.

Posted by ld...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ldywicki pushed a commit to branch features/generated-ads-driver
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit f738bc4fc963a09bc06d1022220ac5e8c50c06f2
Author: Łukasz Dywicki <lu...@code-house.org>
AuthorDate: Wed Apr 15 00:23:13 2020 +0200

    Fix generic boundaries for ConversationContext and wrapper of BitOutput.
---
 .../src/main/java/org/apache/plc4x/java/spi/ConversationContext.java | 2 +-
 .../org/apache/plc4x/java/spi/generation/io/MyDefaultBitOutput.java  | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/ConversationContext.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/ConversationContext.java
index cce28ca..88e9661 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/ConversationContext.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/ConversationContext.java
@@ -58,7 +58,7 @@ public interface ConversationContext<T> {
         <R> SendRequestContext<R> only(Class<R> clazz);
     }
 
-    ExpectRequestContext expectRequest(Class<T> clazz, Duration timeout);
+    ExpectRequestContext<T> expectRequest(Class<T> clazz, Duration timeout);
 
     interface ExpectRequestContext<T> {
 
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/io/MyDefaultBitOutput.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/io/MyDefaultBitOutput.java
index 086a8e6..a1fc39d 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/io/MyDefaultBitOutput.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/io/MyDefaultBitOutput.java
@@ -23,15 +23,14 @@ import com.github.jinahya.bit.io.DefaultBitOutput;
 
 import java.nio.ByteBuffer;
 
-public class MyDefaultBitOutput extends DefaultBitOutput<BufferByteOutput> {
+public class MyDefaultBitOutput extends DefaultBitOutput<BufferByteOutput<ByteBuffer>> {
 
     public MyDefaultBitOutput(BufferByteOutput delegate) {
         super(delegate);
     }
 
-    @SuppressWarnings("unchecked")
     public long getPos() {
-        return ((BufferByteOutput<ByteBuffer>) getDelegate()).getTarget().position();
+        return getDelegate().getTarget().position();
     }
 
 }