You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by hu...@apache.org on 2022/05/25 12:14:05 UTC

[plc4x] branch logix_develop updated: Generating test suite

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

hutcheb pushed a commit to branch logix_develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/logix_develop by this push:
     new c2dbcf36c5 Generating test suite
c2dbcf36c5 is described below

commit c2dbcf36c56c36edd17d407c0db9cc80597c6140
Author: Ben Hutcheson <be...@gmail.com>
AuthorDate: Wed May 25 22:13:30 2022 +1000

    Generating test suite
---
 .../plc4x/java/logix/readwrite/LogixDriver.java    |  2 +-
 .../logix/readwrite/field/LogixFieldHandler.java   |  4 +--
 .../readwrite/protocol/LogixProtocolLogic.java     | 35 ++++++++++++++--------
 .../eip/readwrite/LogixParserSerializerTest.java   |  2 +-
 plc4j/utils/test-generator/pom.xml                 | 25 ++++++++++++++++
 .../src/main/resources/protocols/logix/logix.mspec |  5 ----
 .../protocols/{eip => logix}/DriverTestsuite.xml   |  0
 .../{eip => logix}/ParserSerializerTestsuite.xml   | 22 +++++++-------
 8 files changed, 63 insertions(+), 32 deletions(-)

diff --git a/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/LogixDriver.java b/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/LogixDriver.java
index 47c28f45e0..9a25486f41 100644
--- a/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/LogixDriver.java
+++ b/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/LogixDriver.java
@@ -88,7 +88,7 @@ public class LogixDriver extends GeneratedDriverBase<EipPacket> {
     @Override
     protected ProtocolStackConfigurer<EipPacket> getStackConfigurer() {
         return SingleProtocolStackConfigurer.builder(EipPacket.class, EipPacket::staticParse)
-            .withProtocol(LogixProtocolLogix.class)
+            .withProtocol(LogixProtocolLogic.class)
             .withPacketSizeEstimator(ByteLengthEstimator.class)
             .littleEndian()
             .build();
diff --git a/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/field/LogixFieldHandler.java b/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/field/LogixFieldHandler.java
index bfd97dc53b..f5dddbad41 100644
--- a/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/field/LogixFieldHandler.java
+++ b/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/field/LogixFieldHandler.java
@@ -26,8 +26,8 @@ public class LogixFieldHandler implements PlcFieldHandler {
 
     @Override
     public PlcField createField(String fieldQuery) throws PlcInvalidFieldException {
-       if(EipField.matches(fieldQuery)){
-           return EipField.of(fieldQuery);
+       if(LogixField.matches(fieldQuery)){
+           return LogixField.of(fieldQuery);
        }
        else throw new PlcInvalidFieldException("Invalid field "+fieldQuery);
     }
diff --git a/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/protocol/LogixProtocolLogic.java b/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/protocol/LogixProtocolLogic.java
index 84a9dfcf8a..305e52eb99 100644
--- a/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/protocol/LogixProtocolLogic.java
+++ b/plc4j/drivers/logix/src/main/java/org/apache/plc4x/java/logix/readwrite/protocol/LogixProtocolLogic.java
@@ -210,13 +210,14 @@ public class LogixProtocolLogic extends Plc4xProtocolBase<EipPacket> implements
             Services data = new Services(nb, offsets, serviceArr, -1);
             //Encapsulate the data
 
-            AnsiExtendedSymbolSegment pathSegment0 = new AnsiExtendedSymbolSegment();
+            PathSegment pathSegment0 = new AnsiExtendedSymbolSegment("test");
 
             CipRRData pkt = new CipRRData(sessionHandle, 0L, emptySenderContext, 0L, 0, 2,
                 new CipExchange(
                     new CipUnconnectedRequest(
-                        pathSegment0.length(),
-                        pathSegment0
+                        (short) pathSegment0.getLengthInBytes(),
+                        pathSegment0,
+                        (Integer) 0
                     ),
                     -1
                 ),
@@ -241,13 +242,19 @@ public class LogixProtocolLogic extends Plc4xProtocolBase<EipPacket> implements
                     transaction.endRequest();
                 }));
         } else if (request.size() == 1) {
+
+            PathSegment pathSegment0 = new AnsiExtendedSymbolSegment("test");
+
             CipExchange exchange = new CipExchange(
                 new CipUnconnectedRequest(
-                    request.get(0), (byte) configuration.getBackplane(), (byte) configuration.getSlot(), -1
+                    (short) pathSegment0.getLengthInBytes(),
+                    pathSegment0,
+                    (Integer) 0
                 ),
                 -1
             );
-            CipRRData pkt = new CipRRData(sessionHandle, 0L, emptySenderContext, 0L, exchange, -1);
+
+            CipRRData pkt = new CipRRData(sessionHandle, 0L, emptySenderContext, 0L, 0, 2, exchange, -1);
             transaction.submit(() -> context.sendRequest(pkt)
                 .expectResponse(EipPacket.class, REQUEST_TIMEOUT)
                 .onTimeout(future::completeExceptionally)
@@ -425,10 +432,13 @@ public class LogixProtocolLogic extends Plc4xProtocolBase<EipPacket> implements
         RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
         if (items.size() == 1) {
             tm.startRequest();
-            CipRRData rrdata = new CipRRData(sessionHandle, 0L, senderContext, 0L,
+            PathSegment pathSegment0 = new AnsiExtendedSymbolSegment("test");
+            CipRRData rrdata = new CipRRData(sessionHandle, 0L, senderContext, 0L, 0, 2,
                 new CipExchange(
                     new CipUnconnectedRequest(
-                        items.get(0), (byte) configuration.getBackplane(), (byte) configuration.getSlot(), -1
+                        (short) pathSegment0.getLengthInBytes(),
+                        pathSegment0,
+                        (Integer) 0
                     ),
                     -1
                 ),
@@ -465,13 +475,14 @@ public class LogixProtocolLogic extends Plc4xProtocolBase<EipPacket> implements
             Services data = new Services(nb, offsets, serviceArr, -1);
             //Encapsulate the data
 
-            CipRRData pkt = new CipRRData(sessionHandle, 0L, emptySenderContext, 0L,
+            PathSegment pathSegment0 = new AnsiExtendedSymbolSegment("test");
+
+            CipRRData pkt = new CipRRData(sessionHandle, 0L, emptySenderContext, 0L, 0, 2,
                 new CipExchange(
                     new CipUnconnectedRequest(
-                        new MultipleServiceRequest(data, -1),
-                        (byte) configuration.getBackplane(),
-                        (byte) configuration.getSlot(),
-                        -1
+                        (short) pathSegment0.getLengthInBytes(),
+                        pathSegment0,
+                        (Integer) 0
                     ),
                     -1
                 ),
diff --git a/plc4j/drivers/logix/src/test/java/org/apache/plc4x/java/eip/readwrite/LogixParserSerializerTest.java b/plc4j/drivers/logix/src/test/java/org/apache/plc4x/java/eip/readwrite/LogixParserSerializerTest.java
index 8e22238f1e..aa09eb238b 100644
--- a/plc4j/drivers/logix/src/test/java/org/apache/plc4x/java/eip/readwrite/LogixParserSerializerTest.java
+++ b/plc4j/drivers/logix/src/test/java/org/apache/plc4x/java/eip/readwrite/LogixParserSerializerTest.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.plc4x.java.eip.readwrite;
+package org.apache.plc4x.java.logix.readwrite;
 
 import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner;
 
diff --git a/plc4j/utils/test-generator/pom.xml b/plc4j/utils/test-generator/pom.xml
index 09ee6943b7..02512df0c2 100644
--- a/plc4j/utils/test-generator/pom.xml
+++ b/plc4j/utils/test-generator/pom.xml
@@ -34,6 +34,10 @@
   <name>PLC4J: Utils: Test-Generator</name>
   <description>Generates tests.</description>
 
+  <properties>
+    <app.main.class>org.apache.plc4x.test.generator.ParserSerializerTestsuiteGenerator</app.main.class>
+  </properties>
+
   <build>
     <plugins>
       <plugin>
@@ -85,6 +89,27 @@
           <skip>true</skip>
         </configuration>
       </plugin>
+      <!-- Build a fat jar containing all dependencies -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-uber-jar</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <transformers combine.children="append">
+                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
+                  <mainClass>${app.main.class}</mainClass>
+                </transformer>
+              </transformers>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 
diff --git a/protocols/logix/src/main/resources/protocols/logix/logix.mspec b/protocols/logix/src/main/resources/protocols/logix/logix.mspec
index efb664ea21..fb31f10266 100644
--- a/protocols/logix/src/main/resources/protocols/logix/logix.mspec
+++ b/protocols/logix/src/main/resources/protocols/logix/logix.mspec
@@ -95,11 +95,6 @@
         ['0x52','false'   CipUnconnectedRequest
                [simple     uint    8    requestPathSize ]
                [simple     PathSegment  pathSegment0]
-               [optional   PathSegment  pathSegment1 '(requestPathSize - pathSegment0.dataSize) > 0']
-               [optional   PathSegment  pathSegment2 '(requestPathSize - pathSegment0.dataSize - pathSegment1.dataSize) > 0']
-               [optional   PathSegment  pathSegment3 '(requestPathSize - pathSegment0.dataSize - pathSegment1.dataSize - pathSegment2.dataSize) > 0']
-               [optional   PathSegment  pathSegment4 '(requestPathSize - pathSegment0.dataSize - pathSegment1.dataSize - pathSegment2.dataSize - pathSegment3.dataSize) > 0']
-               [optional   PathSegment  pathSegment5 '(requestPathSize - pathSegment0.dataSize - pathSegment1.dataSize - pathSegment2.dataSize - pathSegment3.dataSize - pathSegment4.dataSize) > 0']
         ]
         ['0x5B','false'     CipConnectionManagerRequest
                [simple      int     8           requestPathSize]
diff --git a/protocols/logix/src/test/resources/protocols/eip/DriverTestsuite.xml b/protocols/logix/src/test/resources/protocols/logix/DriverTestsuite.xml
similarity index 100%
rename from protocols/logix/src/test/resources/protocols/eip/DriverTestsuite.xml
rename to protocols/logix/src/test/resources/protocols/logix/DriverTestsuite.xml
diff --git a/protocols/logix/src/test/resources/protocols/eip/ParserSerializerTestsuite.xml b/protocols/logix/src/test/resources/protocols/logix/ParserSerializerTestsuite.xml
similarity index 94%
rename from protocols/logix/src/test/resources/protocols/eip/ParserSerializerTestsuite.xml
rename to protocols/logix/src/test/resources/protocols/logix/ParserSerializerTestsuite.xml
index c984885589..204c4c9967 100644
--- a/protocols/logix/src/test/resources/protocols/eip/ParserSerializerTestsuite.xml
+++ b/protocols/logix/src/test/resources/protocols/logix/ParserSerializerTestsuite.xml
@@ -18,7 +18,7 @@
   under the License.
   -->
 <test:testsuite xmlns:test="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd"
-                byteOrder="BIG_ENDIAN">
+                byteOrder="LITTLE_ENDIAN">
 
   <name>LOGIX</name>
 
@@ -27,7 +27,7 @@
 
   <testcase>
     <name>Register Session</name>
-    <raw>00650004000000000000000000000000000000000000000000010000</raw>
+    <raw>650004000000000000000000302e382e332020200000000001000000</raw>
     <root-type>EipPacket</root-type>
     <xml>
       <EipPacket>
@@ -36,14 +36,14 @@
         <sessionHandle dataType="uint" bitLength="32">0</sessionHandle>
         <status dataType="uint" bitLength="32">0</status>
         <senderContext isList="true">
-          <value dataType="uint" bitLength="8">0</value>
-          <value dataType="uint" bitLength="8">0</value>
-          <value dataType="uint" bitLength="8">0</value>
-          <value dataType="uint" bitLength="8">0</value>
-          <value dataType="uint" bitLength="8">0</value>
-          <value dataType="uint" bitLength="8">0</value>
-          <value dataType="uint" bitLength="8">0</value>
-          <value dataType="uint" bitLength="8">0</value>
+          <value dataType="uint" bitLength="8">48</value>
+          <value dataType="uint" bitLength="8">46</value>
+          <value dataType="uint" bitLength="8">56</value>
+          <value dataType="uint" bitLength="8">46</value>
+          <value dataType="uint" bitLength="8">51</value>
+          <value dataType="uint" bitLength="8">32</value>
+          <value dataType="uint" bitLength="8">32</value>
+          <value dataType="uint" bitLength="8">32</value>
         </senderContext>
         <options dataType="uint" bitLength="32">0</options>
         <EipConnectionRequest>
@@ -57,7 +57,7 @@
   <testcase>
     <name>CIP Read Request</name>
     <raw>
-      006F0028000012340000000001000000000000010000000000000000000000020000000000B200185202200624019D05000A4C03910472617465000100010104
+      70003800c9070440000000005765277265000000000000000000000000000200a10004005942feffb10024000100520d91124b4347455f534d503030385f4c4331353532910370505600010000000000
     </raw>
     <root-type>EipPacket</root-type>
     <xml>