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/06/26 05:27:50 UTC
[plc4x] branch develop updated: - Moved the code-generation modules
outside the sandbox
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new a49baff - Moved the code-generation modules outside the sandbox
a49baff is described below
commit a49baff55406842b4560317fbc26f31ad04cf805
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Jun 26 07:27:36 2019 +0200
- Moved the code-generation modules outside the sandbox
---
.../language-base-freemarker/pom.xml | 8 +-
.../freemarker/FreemarkerLanguageOutput.java | 0
.../FreemarkerLanguageTemplateHelper.java | 0
{plc4j/utils => build-utils}/pom.xml | 24 +-
.../protocol-base-mspec/pom.xml | 8 +-
.../plugins/codegenerator/language/mspec/MSpec.g4 | 0
.../language/mspec/expression/Expression.g4 | 0
.../mspec/expression/ExpressionStringListener.java | 0
.../mspec/expression/ExpressionStringParser.java | 0
.../definitions/DefaultComplexTypeDefinition.java | 0
.../DefaultDiscriminatedComplexTypeDefinition.java | 0
.../definitions/DefaultEnumTypeDefinition.java | 0
.../model/definitions/DefaultTypeDefinition.java | 0
.../mspec/model/fields/DefaultArrayField.java | 0
.../mspec/model/fields/DefaultConstField.java | 0
.../model/fields/DefaultDiscriminatorField.java | 0
.../mspec/model/fields/DefaultImplicitField.java | 0
.../mspec/model/fields/DefaultOptionalField.java | 0
.../mspec/model/fields/DefaultReservedField.java | 0
.../mspec/model/fields/DefaultSimpleField.java | 0
.../mspec/model/fields/DefaultSwitchField.java | 0
.../references/DefaultComplexTypeReference.java | 0
.../references/DefaultSimpleTypeReference.java | 0
.../DefaultSimpleVarLengthTypeReference.java | 0
.../mspec/parser/MessageFormatListener.java | 0
.../language/mspec/parser/MessageFormatParser.java | 0
.../src/remote-resources/LICENSE | 0
.../src/remote-resources/UNLICENSE | 0
.../build-utils}/language-java/pom.xml | 20 +-
.../plc4x/language/java/JavaLanguageOutput.java | 0
.../language/java/JavaLanguageTemplateHelper.java | 0
...x.plugins.codegenerator.language.LanguageOutput | 0
.../main/resources/templates/java/io-template.ftlh | 0
.../resources/templates/java/pojo-template.ftlh | 0
.../build-utils/pom.xml | 26 +-
plc4j/pom.xml | 1 +
.../utils}/driver-base-java/pom.xml | 14 +-
.../github/jinahya/bit/io/MyDefaultBitInput.java | 0
.../apache/plc4x/java/utils/EvaluationHelper.java | 0
.../apache/plc4x/java/utils/ParseException.java | 0
.../org/apache/plc4x/java/utils/ReadBuffer.java | 0
.../org/apache/plc4x/java/utils/SizeAware.java | 0
.../org/apache/plc4x/java/utils/WriteBuffer.java | 0
plc4j/utils/pom.xml | 2 +
pom.xml | 7 +
protocols/s7/pom.xml | 45 +-
.../org/apache/plc4x/protocol/s7/S7Protocol.java | 0
...e.plc4x.plugins.codegenerator.protocol.Protocol | 0
.../org/apache/plc4x/protocols/protocol.dfdl.xsd | 129 ---
.../apache/plc4x/protocols/s7/protocol.dfdl.xsd | 897 ---------------------
.../apache/plc4x/protocols/s7/protocol.scxml.xml | 526 ------------
.../src/main/resources/protocols/s7/protocol.spec | 0
.../org/apache/plc4x/protocols/s7/ManualTest.java | 83 --
.../apache/plc4x/protocols/s7/ProtocolTest.java | 33 -
sandbox/code-generation/pom.xml | 49 --
sandbox/code-generation/protocol-s7/pom.xml | 48 --
sandbox/dynamic-driver-base/pom.xml | 126 ---
.../java/dynamic/actions/BaseConnectedAction.java | 37 -
.../java/dynamic/actions/BaseDaffodilAction.java | 56 --
.../java/dynamic/actions/BasePlc4xAction.java | 52 --
.../java/dynamic/actions/ConnectAction.java | 91 ---
.../java/dynamic/actions/InitContextAction.java | 106 ---
.../java/dynamic/actions/ReceiveAction.java | 202 -----
.../actions/ReceiveExtractVerifyAction.java | 114 ---
.../java/dynamic/actions/ReceiveRequestAction.java | 52 --
.../dynamic/actions/ReceiveResponseAction.java | 65 --
.../sandbox/java/dynamic/actions/SendAction.java | 103 ---
.../java/dynamic/actions/SendRequestAction.java | 57 --
.../connection/DynamicDriverConnectionBase.java | 153 ----
.../dynamic/exceptions/DynamicDriverException.java | 34 -
.../plc4x/sandbox/java/dynamic/io/ProtocolIO.java | 28 -
.../sandbox/java/dynamic/io/TcpProtocolIO.java | 49 --
.../sandbox/java/dynamic/io/UdpProtocolIO.java | 50 --
.../java/dynamic/utils/RequestRegistry.java | 66 --
.../utils/JDOMTemplateInfosetInputter.scala | 45 --
sandbox/dynamic-driver-knxnet-ip/pom.xml | 119 ---
.../dynamic/knxnetip/DynamicKnxNetIpDriver.java | 79 --
.../connection/DynamicKnxNetIpConnection.java | 134 ---
.../services/org.apache.plc4x.java.spi.PlcDriver | 76 --
sandbox/dynamic-driver-s7/pom.xml | 103 ---
.../sandbox/java/dynamic/s7/DynamicS7Driver.java | 80 --
.../dynamic/s7/actions/S7DecodeArticleNumber.java | 91 ---
.../s7/actions/S7DecodeReadResponseAction.java | 315 --------
.../s7/actions/S7DecodeWriteResponseAction.java | 34 -
.../dynamic/s7/connection/DynamicS7Connection.java | 186 -----
.../dynamic/s7/types/DataTransportErrorCode.java | 62 --
.../java/dynamic/s7/types/DataTransportSize.java | 64 --
.../sandbox/java/dynamic/s7/types/MemoryArea.java | 83 --
.../java/dynamic/s7/types/S7ControllerType.java | 30 -
.../java/dynamic/s7/types/TransportSize.java | 195 -----
.../sandbox/java/dynamic/s7/utils/S7Field.java | 194 -----
.../java/dynamic/s7/utils/S7PlcFieldHandler.java | 569 -------------
.../java/dynamic/s7/utils/S7TsapIdEncoder.java | 45 --
.../services/org.apache.plc4x.java.spi.PlcDriver | 38 -
sandbox/pom.xml | 5 +-
.../test-java-s7-driver/pom.xml | 18 +-
.../src/test/java/BenchmarkGeneratedS7.java | 0
97 files changed, 67 insertions(+), 5859 deletions(-)
diff --git a/sandbox/code-generation/language-base-freemarker/pom.xml b/build-utils/language-base-freemarker/pom.xml
similarity index 87%
rename from sandbox/code-generation/language-base-freemarker/pom.xml
rename to build-utils/language-base-freemarker/pom.xml
index 184e3fe..a4613b4 100644
--- a/sandbox/code-generation/language-base-freemarker/pom.xml
+++ b/build-utils/language-base-freemarker/pom.xml
@@ -22,14 +22,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generaton</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-build-utils</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>
- <artifactId>plc4x-code-generation-language-base-freemarker</artifactId>
+ <artifactId>plc4x-build-utils-language-base-freemarker</artifactId>
- <name>Sandbox: Code Generation: Language Base: Freemarker</name>
+ <name>PLC4X: Build Utils: Language Base: Freemarker</name>
<description>Base code for building language outputs based on Freemarker</description>
<dependencies>
diff --git a/sandbox/code-generation/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageOutput.java b/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageOutput.java
similarity index 100%
rename from sandbox/code-generation/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageOutput.java
rename to build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageOutput.java
diff --git a/sandbox/code-generation/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageTemplateHelper.java b/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageTemplateHelper.java
similarity index 100%
rename from sandbox/code-generation/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageTemplateHelper.java
rename to build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/FreemarkerLanguageTemplateHelper.java
diff --git a/plc4j/utils/pom.xml b/build-utils/pom.xml
similarity index 71%
copy from plc4j/utils/pom.xml
copy to build-utils/pom.xml
index 666e954..e4c3f2e 100644
--- a/plc4j/utils/pom.xml
+++ b/build-utils/pom.xml
@@ -23,31 +23,19 @@
<parent>
<groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j</artifactId>
+ <artifactId>plc4x-parent</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>
- <artifactId>plc4j-utils</artifactId>
+ <artifactId>plc4x-build-utils</artifactId>
<packaging>pom</packaging>
- <name>PLC4J: Utils</name>
- <description>A collection of utilities used in multiple modules.</description>
+ <name>PLC4X: Build Utils</name>
+ <description>Some build related utilities.</description>
<modules>
- <module>connection-pool</module>
- <module>opm</module>
- <module>raw-sockets</module>
- <module>test-utils</module>
- <module>scraper</module>
+ <module>language-base-freemarker</module>
+ <module>protocol-base-mspec</module>
</modules>
- <profiles>
- <profile>
- <id>with-proxies</id>
- <modules>
- <module>interop</module>
- </modules>
- </profile>
- </profiles>
-
</project>
\ No newline at end of file
diff --git a/sandbox/code-generation/protocol-base-mspec/pom.xml b/build-utils/protocol-base-mspec/pom.xml
similarity index 89%
rename from sandbox/code-generation/protocol-base-mspec/pom.xml
rename to build-utils/protocol-base-mspec/pom.xml
index 7052107..dfe07f4 100644
--- a/sandbox/code-generation/protocol-base-mspec/pom.xml
+++ b/build-utils/protocol-base-mspec/pom.xml
@@ -22,14 +22,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generaton</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-build-utils</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>
- <artifactId>plc4x-code-generation-protocol-base-mspec</artifactId>
+ <artifactId>plc4x-build-utils-protocol-base-mspec</artifactId>
- <name>Sandbox: Code Generation: Protocol Base: MSpec</name>
+ <name>PLC4X: Build Utils: Protocol Base: MSpec</name>
<description>Base stuff for building protocols using our custom MSpec format.</description>
<build>
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4 b/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
rename to build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/MSpec.g4
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/Expression.g4 b/build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/Expression.g4
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/Expression.g4
rename to build-utils/protocol-base-mspec/src/main/antlr4/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/Expression.g4
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringListener.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParser.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParser.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParser.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/expression/ExpressionStringParser.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultComplexTypeDefinition.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultComplexTypeDefinition.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultComplexTypeDefinition.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultComplexTypeDefinition.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDiscriminatedComplexTypeDefinition.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDiscriminatedComplexTypeDefinition.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDiscriminatedComplexTypeDefinition.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultDiscriminatedComplexTypeDefinition.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultEnumTypeDefinition.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultEnumTypeDefinition.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultEnumTypeDefinition.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultEnumTypeDefinition.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultTypeDefinition.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultTypeDefinition.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultTypeDefinition.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/definitions/DefaultTypeDefinition.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultArrayField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultArrayField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultArrayField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultArrayField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultConstField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultConstField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultConstField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultConstField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultDiscriminatorField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultDiscriminatorField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultDiscriminatorField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultDiscriminatorField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultImplicitField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultImplicitField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultImplicitField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultImplicitField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultOptionalField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultOptionalField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultOptionalField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultOptionalField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultReservedField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultReservedField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultReservedField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultReservedField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSimpleField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSimpleField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSimpleField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSimpleField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSwitchField.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSwitchField.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSwitchField.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/fields/DefaultSwitchField.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultComplexTypeReference.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultComplexTypeReference.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultComplexTypeReference.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultComplexTypeReference.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleTypeReference.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/model/references/DefaultSimpleVarLengthTypeReference.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParser.java b/build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParser.java
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParser.java
rename to build-utils/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatParser.java
diff --git a/sandbox/code-generation/protocol-base-mspec/src/remote-resources/LICENSE b/build-utils/protocol-base-mspec/src/remote-resources/LICENSE
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/remote-resources/LICENSE
rename to build-utils/protocol-base-mspec/src/remote-resources/LICENSE
diff --git a/sandbox/code-generation/protocol-base-mspec/src/remote-resources/UNLICENSE b/build-utils/protocol-base-mspec/src/remote-resources/UNLICENSE
similarity index 100%
rename from sandbox/code-generation/protocol-base-mspec/src/remote-resources/UNLICENSE
rename to build-utils/protocol-base-mspec/src/remote-resources/UNLICENSE
diff --git a/sandbox/code-generation/language-java/pom.xml b/plc4j/build-utils/language-java/pom.xml
similarity index 75%
rename from sandbox/code-generation/language-java/pom.xml
rename to plc4j/build-utils/language-java/pom.xml
index 86731da..304f89a 100644
--- a/sandbox/code-generation/language-java/pom.xml
+++ b/plc4j/build-utils/language-java/pom.xml
@@ -22,26 +22,27 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generaton</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-build-utils</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>
- <artifactId>plc4x-code-generation-language-java</artifactId>
+ <artifactId>plc4j-build-utils-language-java</artifactId>
- <name>Sandbox: Code Generation: Language: Java</name>
+ <name>PLC4J: Build Utils: Language: Java</name>
<description>Code generation template for generating Java code</description>
<dependencies>
+ <!-- We are using the Freemarker module to generate Java code -->
<dependency>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generation-language-base-freemarker</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-build-utils-language-base-freemarker</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generation-language-base</artifactId>
+ <artifactId>plc4x-code-generation-types-base</artifactId>
</dependency>
<dependency>
@@ -52,11 +53,6 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/sandbox/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageOutput.java b/plc4j/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageOutput.java
similarity index 100%
rename from sandbox/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageOutput.java
rename to plc4j/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageOutput.java
diff --git a/sandbox/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java b/plc4j/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
similarity index 100%
rename from sandbox/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
rename to plc4j/build-utils/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
diff --git a/sandbox/code-generation/language-java/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.language.LanguageOutput b/plc4j/build-utils/language-java/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.language.LanguageOutput
similarity index 100%
rename from sandbox/code-generation/language-java/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.language.LanguageOutput
rename to plc4j/build-utils/language-java/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.language.LanguageOutput
diff --git a/sandbox/code-generation/language-java/src/main/resources/templates/java/io-template.ftlh b/plc4j/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
similarity index 100%
rename from sandbox/code-generation/language-java/src/main/resources/templates/java/io-template.ftlh
rename to plc4j/build-utils/language-java/src/main/resources/templates/java/io-template.ftlh
diff --git a/sandbox/code-generation/language-java/src/main/resources/templates/java/pojo-template.ftlh b/plc4j/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
similarity index 100%
rename from sandbox/code-generation/language-java/src/main/resources/templates/java/pojo-template.ftlh
rename to plc4j/build-utils/language-java/src/main/resources/templates/java/pojo-template.ftlh
diff --git a/protocols/s7/src/main/resources/daffodil-built-in-catalog.xml b/plc4j/build-utils/pom.xml
similarity index 56%
rename from protocols/s7/src/main/resources/daffodil-built-in-catalog.xml
rename to plc4j/build-utils/pom.xml
index 617b0ba..d86e58a 100644
--- a/protocols/s7/src/main/resources/daffodil-built-in-catalog.xml
+++ b/plc4j/build-utils/pom.xml
@@ -1,5 +1,6 @@
<?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.
@@ -14,13 +15,26 @@
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.
+
-->
-<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j</artifactId>
+ <version>0.5.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>plc4j-build-utils</artifactId>
+ <packaging>pom</packaging>
- <uri name="http://plc4x.apache.org/plc4x"
- uri="org/apache/plc4x/protocols/protocol.dfdl.xsd"/>
+ <name>PLC4J: Build Utils</name>
+ <description>Some build related utilities for Java modules.</description>
- <uri name="http://plc4x.apache.org/s7"
- uri="org/apache/plc4x/protocols/s7/protocol.dfdl.xsd"/>
+ <modules>
+ <module>language-java</module>
+ </modules>
-</catalog>
\ No newline at end of file
+</project>
\ No newline at end of file
diff --git a/plc4j/pom.xml b/plc4j/pom.xml
index 8f85e15..eff2401 100644
--- a/plc4j/pom.xml
+++ b/plc4j/pom.xml
@@ -35,6 +35,7 @@
<modules>
<module>api</module>
+ <module>build-utils</module>
<module>drivers</module>
<module>protocols</module>
<module>utils</module>
diff --git a/sandbox/code-generation/driver-base-java/pom.xml b/plc4j/utils/driver-base-java/pom.xml
similarity index 78%
rename from sandbox/code-generation/driver-base-java/pom.xml
rename to plc4j/utils/driver-base-java/pom.xml
index 1a2f6d8..122aab3 100644
--- a/sandbox/code-generation/driver-base-java/pom.xml
+++ b/plc4j/utils/driver-base-java/pom.xml
@@ -22,14 +22,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generaton</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-utils</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>
- <artifactId>plc4x-code-generation-driver-base-java</artifactId>
+ <artifactId>plc4j-utils-driver-base-java</artifactId>
- <name>Sandbox: Code Generation: Driver Base: Java</name>
+ <name>PLC4J: Utils: Driver Base: Java</name>
<description>Base stuff containing shared base classes for java drivers.</description>
<dependencies>
@@ -37,11 +37,5 @@
<groupId>com.github.jinahya</groupId>
<artifactId>bit-io</artifactId>
</dependency>
-
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/sandbox/code-generation/driver-base-java/src/main/java/com/github/jinahya/bit/io/MyDefaultBitInput.java b/plc4j/utils/driver-base-java/src/main/java/com/github/jinahya/bit/io/MyDefaultBitInput.java
similarity index 100%
rename from sandbox/code-generation/driver-base-java/src/main/java/com/github/jinahya/bit/io/MyDefaultBitInput.java
rename to plc4j/utils/driver-base-java/src/main/java/com/github/jinahya/bit/io/MyDefaultBitInput.java
diff --git a/sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/EvaluationHelper.java b/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/EvaluationHelper.java
similarity index 100%
rename from sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/EvaluationHelper.java
rename to plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/EvaluationHelper.java
diff --git a/sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ParseException.java b/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ParseException.java
similarity index 100%
rename from sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ParseException.java
rename to plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ParseException.java
diff --git a/sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ReadBuffer.java b/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ReadBuffer.java
similarity index 100%
rename from sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ReadBuffer.java
rename to plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/ReadBuffer.java
diff --git a/sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/SizeAware.java b/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/SizeAware.java
similarity index 100%
rename from sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/SizeAware.java
rename to plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/SizeAware.java
diff --git a/sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/WriteBuffer.java b/plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/WriteBuffer.java
similarity index 100%
rename from sandbox/code-generation/driver-base-java/src/main/java/org/apache/plc4x/java/utils/WriteBuffer.java
rename to plc4j/utils/driver-base-java/src/main/java/org/apache/plc4x/java/utils/WriteBuffer.java
diff --git a/plc4j/utils/pom.xml b/plc4j/utils/pom.xml
index 666e954..cde00e4 100644
--- a/plc4j/utils/pom.xml
+++ b/plc4j/utils/pom.xml
@@ -34,6 +34,8 @@
<description>A collection of utilities used in multiple modules.</description>
<modules>
+ <module>driver-base-java</module>
+
<module>connection-pool</module>
<module>opm</module>
<module>raw-sockets</module>
diff --git a/pom.xml b/pom.xml
index 0ffce9d..cc72766 100644
--- a/pom.xml
+++ b/pom.xml
@@ -169,6 +169,8 @@
</properties>
<modules>
+ <module>build-utils</module>
+
<!-- Definition of the protocol message formats -->
<module>protocols</module>
@@ -511,6 +513,11 @@
</dependency>
<dependency>
<groupId>org.apache.plc4x.plugins</groupId>
+ <artifactId>plc4x-code-generation-types-base</artifactId>
+ <version>${plc4x-code-generation.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x.plugins</groupId>
<artifactId>plc4x-code-generation-language-base</artifactId>
<version>${plc4x-code-generation.version}</version>
</dependency>
diff --git a/protocols/s7/pom.xml b/protocols/s7/pom.xml
index b297bab..8605974 100644
--- a/protocols/s7/pom.xml
+++ b/protocols/s7/pom.xml
@@ -33,54 +33,11 @@
<description>Base protocol specifications for the Siemens S7 protocol</description>
<dependencies>
- <!-- Import the base types -->
<dependency>
<groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-protocols-plc4x</artifactId>
+ <artifactId>plc4x-build-utils-protocol-base-mspec</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
-
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-protocols-test-utils</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.daffodil</groupId>
- <artifactId>daffodil-japi_2.12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom2</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/sandbox/code-generation/protocol-s7/src/main/java/org/apache/plc4x/protocol/s7/S7Protocol.java b/protocols/s7/src/main/java/org/apache/plc4x/protocol/s7/S7Protocol.java
similarity index 100%
rename from sandbox/code-generation/protocol-s7/src/main/java/org/apache/plc4x/protocol/s7/S7Protocol.java
rename to protocols/s7/src/main/java/org/apache/plc4x/protocol/s7/S7Protocol.java
diff --git a/sandbox/code-generation/protocol-s7/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol b/protocols/s7/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol
similarity index 100%
rename from sandbox/code-generation/protocol-s7/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol
rename to protocols/s7/src/main/resources/META-INF/services/org.apache.plc4x.plugins.codegenerator.protocol.Protocol
diff --git a/protocols/s7/src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd b/protocols/s7/src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd
deleted file mode 100644
index 7cf31f4..0000000
--- a/protocols/s7/src/main/resources/org/apache/plc4x/protocols/protocol.dfdl.xsd
+++ /dev/null
@@ -1,129 +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.
- -->
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
- xmlns:plc4x="http://plc4x.apache.org/plc4x"
- targetNamespace="http://plc4x.apache.org/plc4x">
-
- <!--
-
- Simple type definition.
-
- These are the types language adapters must provide mappings for.
-
- -->
-
- <xs:simpleType name="null" dfdl:lengthUnits="bytes" dfdl:length="0" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:hexBinary"/>
- </xs:simpleType>
-
-
-
- <xs:simpleType name="bit" dfdl:lengthUnits="bits" dfdl:length="1" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:boolean"/>
- </xs:simpleType>
-
-
-
- <!--
- UINT values are always referenced with 'bit' lengths
- -->
- <xs:simpleType name="uint8" dfdl:lengthUnits="bits" dfdl:length="8" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:unsignedByte"/>
- </xs:simpleType>
-
- <xs:simpleType name="uint16" dfdl:lengthUnits="bits" dfdl:length="16" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:unsignedShort"/>
- </xs:simpleType>
-
- <xs:simpleType name="uint32" dfdl:lengthUnits="bits" dfdl:length="32" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:unsignedInt"/>
- </xs:simpleType>
-
- <xs:simpleType name="uint64" dfdl:lengthUnits="bits" dfdl:length="64" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:unsignedLong"/>
- </xs:simpleType>
-
- <xs:simpleType name="uintN" dfdl:lengthUnits="bits" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:unsignedLong"/>
- </xs:simpleType>
-
-
-
- <!--
- INT values are always referenced with 'bit' lengths
- -->
- <xs:simpleType name="int8" dfdl:lengthUnits="bits" dfdl:length="8" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:byte"/>
- </xs:simpleType>
-
- <xs:simpleType name="int16" dfdl:lengthUnits="bits" dfdl:length="16" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:short"/>
- </xs:simpleType>
-
- <xs:simpleType name="int32" dfdl:lengthUnits="bits" dfdl:length="32" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:int"/>
- </xs:simpleType>
-
- <xs:simpleType name="int64" dfdl:lengthUnits="bits" dfdl:length="64" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:long"/>
- </xs:simpleType>
-
- <xs:simpleType name="intN" dfdl:lengthUnits="bits" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:long"/>
- </xs:simpleType>
-
-
-
- <!--
- BYTE values are always referenced with 'byte' lengths because
- it doesn't make sense to read part of a byte as hex value.
- -->
- <xs:simpleType name="byte8" dfdl:lengthUnits="bytes" dfdl:length="1" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:hexBinary"/>
- </xs:simpleType>
-
- <xs:simpleType name="byte16" dfdl:lengthUnits="bytes" dfdl:length="2" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:hexBinary"/>
- </xs:simpleType>
-
- <xs:simpleType name="byte32" dfdl:lengthUnits="bytes" dfdl:length="3" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:hexBinary"/>
- </xs:simpleType>
-
- <xs:simpleType name="byte64" dfdl:lengthUnits="bytes" dfdl:length="4" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:hexBinary"/>
- </xs:simpleType>
-
- <xs:simpleType name="byteN" dfdl:lengthUnits="bytes" dfdl:lengthKind="explicit">
- <xs:restriction base="xs:hexBinary"/>
- </xs:simpleType>
-
-
-
- <!--
- STRING values are always referenced with 'byte' lengths because
- it doesn't make sense to read part of a string character.
- -->
- <xs:simpleType name="stringN" dfdl:lengthUnits="bytes" dfdl:lengthKind="explicit"
- dfdl:textTrimKind="none" dfdl:alignmentUnits="bytes">
- <xs:restriction base="xs:string"/>
- </xs:simpleType>
-
-</xs:schema>
\ No newline at end of file
diff --git a/protocols/s7/src/main/resources/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd b/protocols/s7/src/main/resources/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd
deleted file mode 100644
index 20a5813..0000000
--- a/protocols/s7/src/main/resources/org/apache/plc4x/protocols/s7/protocol.dfdl.xsd
+++ /dev/null
@@ -1,897 +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.
- -->
-<xs:schema targetNamespace="http://plc4x.apache.org/s7"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/"
- xmlns:plc4x="http://plc4x.apache.org/plc4x"
- xmlns:s7="http://plc4x.apache.org/s7"
- xmlns:fn="http://www.w3.org/2005/xpath-functions">
-
- <xs:import namespace="http://plc4x.apache.org/plc4x"/>
-
- <xs:annotation>
- <xs:appinfo source="http://www.ogf.org/dfdl/">
- <dfdl:defineVariable name="messageType" type="xs:string"/>
- <dfdl:defineFormat name="s7FullFormat">
- <dfdl:format representation="binary"
- binaryNumberRep="binary"
- byteOrder="bigEndian"
- lengthKind="implicit" lengthUnits="bytes" length="0"
- binaryBooleanTrueRep="1"
- binaryBooleanFalseRep="0"
- occursCountKind="implicit"
- textOutputMinLength="0"
- alignment="1" alignmentUnits="bits"
- leadingSkip="0" trailingSkip="0"
- textPadKind="none" ignoreCase="no"
- textBidi="no" floating="no"
- encoding="utf-8" truncateSpecifiedLengthString="no"
- initiator="" terminator=""
- sequenceKind="ordered" separator=""
- escapeSchemeRef="" initiatedContent="no"
- encodingErrorPolicy="replace"/>
- </dfdl:defineFormat>
- <dfdl:format ref="s7:s7FullFormat"/>
- </xs:appinfo>
- </xs:annotation>
-
- <!--
-
- TPKT - Iso-On-TCP
-
- -->
-
- <xs:element name="TpktMessage" type="s7:TpktMessage"/>
-
- <xs:complexType name="TpktMessage">
- <xs:sequence>
- <!-- TPKT Magic Byte always 0x03 -->
- <xs:element name="magicByte" type="plc4x:uint8" fixed="3">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/dfdl">
- <plc4x:noProperty/>
- </xs:appinfo>
- <xs:appinfo source="http://www.ogf.org/dfdl/">
- <dfdl:assert message="Magic number was not 0x03."
- test="{. eq 3}"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:element>
- <xs:element name="reserved" type="plc4x:uint8">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/dfdl">
- <plc4x:noProperty/>
- </xs:appinfo>
- </xs:annotation>
- </xs:element>
- <xs:element name="length" type="plc4x:uint16"/>
- <xs:element name="userData" type="s7:CotpMessage"/>
- </xs:sequence>
- </xs:complexType>
-
- <!--
-
- ISO 8073/X.224 - ISO-TP - COTP - Connection-Oriented Transport Protocol Messages
-
- -->
-
- <xs:simpleType name="CotpTpduType">
- <xs:restriction base="plc4x:uint8">
- <xs:enumeration value="224">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>ConnectionRequest</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="208">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>ConnectionResponse</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="128">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>DisconnectRequest</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="192">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>DisconnectResponse</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="112">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>Error</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="240">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>Data</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:simpleType name="CotpParameterType">
- <xs:restriction base="plc4x:uint8">
- <xs:enumeration value="192">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>TpduSize</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="193">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>CallingTsap</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="194">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>CalledTsap</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="195">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>Checksum</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- <xs:enumeration value="224">
- <xs:annotation>
- <xs:appinfo source="http://plc4x.apache.org/plc4x">
- <plc4x:enumName>DisconnectAdditionalInformation</plc4x:enumName>
- </xs:appinfo>
- </xs:annotation>
- </xs:enumeration>
- </xs:restriction>
- </xs:simpleType>
-
- <xs:complexType name="CotpMessage">
- <xs:sequence>
- <!-- Length of the COTP header data -->
- <xs:element name="headerLength" type="plc4x:uint8"/>
- <xs:element name="type" type="s7:CotpTpduType"/>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="224" name="cotpTpduConnectionRequest"
- type="s7:CotpTpduConnectionRequest"/>
- <xs:element dfdl:choiceBranchKey="208" name="cotpTpduConnectionResponse"
- type="s7:CotpTpduConnectionResponse"/>
- <xs:element dfdl:choiceBranchKey="128" name="cotpTpduDisconnectRequest"
- type="s7:CotpTpduDisconnectRequest"/>
- <xs:element dfdl:choiceBranchKey="192" name="cotpTpduDisconnectResponse"
- type="s7:CotpTpduDisconnectResponse"/>
- <xs:element dfdl:choiceBranchKey="112" name="cotpTpduError" type="s7:CotpTpduError"/>
- <xs:element dfdl:choiceBranchKey="240" name="cotpTpduData" type="s7:CotpTpduData"/>
- </xs:choice>
- <xs:element name="userData" type="s7:S7Message" minOccurs="0"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if((../../length - (../headerLength + 5)) gt 0) then 1 else 0}"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpTpduConnectionRequest">
- <xs:sequence>
- <xs:element name="destinationReference" type="plc4x:uint16"/>
- <xs:element name="sourceReference" type="plc4x:uint16"/>
- <xs:element name="protocolClass" type="plc4x:uint8"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../../headerLength - 6}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../../headerLength gt 6) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" type="s7:Parameter" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpTpduConnectionResponse">
- <xs:sequence>
- <xs:element name="destinationReference" type="plc4x:uint16"/>
- <xs:element name="sourceReference" type="plc4x:uint16"/>
- <xs:element name="protocolClass" type="plc4x:uint8"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../../headerLength - 6}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../../headerLength gt 6) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" type="s7:Parameter" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpTpduDisconnectRequest">
- <xs:sequence>
- <xs:element name="destinationReference" type="plc4x:uint16"/>
- <xs:element name="sourceReference" type="plc4x:uint16"/>
- <xs:element name="disconnectReason" type="plc4x:uint8"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../../headerLength - 6}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../../headerLength gt 6) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" type="s7:Parameter" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpTpduDisconnectResponse">
- <xs:sequence>
- <xs:element name="destinationReference" type="plc4x:uint16"/>
- <xs:element name="sourceReference" type="plc4x:uint16"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../../headerLength - 5}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../../headerLength gt 5) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" type="s7:Parameter" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpTpduError">
- <xs:sequence>
- <xs:element name="destinationReference" type="plc4x:uint16"/>
- <xs:element name="rejectCause" type="plc4x:uint8"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../../headerLength - 4}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../../headerLength gt 4) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" type="s7:Parameter" maxOccurs="unbounded"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpTpduData">
- <xs:sequence>
- <xs:element name="endOfTransmission" type="plc4x:bit"/>
- <xs:element name="tpduRef" type="plc4x:uintN" dfdl:length="7"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="Parameter">
- <xs:sequence>
- <xs:element name="type" type="s7:CotpParameterType"/>
- <xs:element name="parameterLength" type="plc4x:uint8"/>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="192" name="cotpParameterTpduSize" type="s7:CotpParameterTpduSize"/>
- <xs:element dfdl:choiceBranchKey="193" name="cotpParameterCallingTsap" type="s7:CotpParameterCallingTsap"/>
- <xs:element dfdl:choiceBranchKey="194" name="cotpParameterCalledTsap" type="s7:CotpParameterCalledTsap"/>
- <xs:element dfdl:choiceBranchKey="195" name="cotpParameterChecksum" type="s7:CotpParameterChecksum"/>
- <xs:element dfdl:choiceBranchKey="224" name="cotpParameterDisconnectAdditionalInformation"
- type="s7:CotpParameterDisconnectAdditionalInformation"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpParameterTpduSize">
- <xs:sequence>
- <xs:element name="tpduSize" type="plc4x:uint8"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpParameterCallingTsap">
- <xs:sequence>
- <xs:element name="tsapId" type="plc4x:uint16"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpParameterCalledTsap">
- <xs:sequence>
- <xs:element name="tsapId" type="plc4x:uint16"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpParameterChecksum">
- <xs:sequence>
- <xs:element name="checksum" type="plc4x:uint8"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="CotpParameterDisconnectAdditionalInformation">
- <xs:sequence>
- <xs:element name="data" type="plc4x:byteN" dfdl:length="{../../parameterLength}"/>
- </xs:sequence>
- </xs:complexType>
-
- <!--
-
- S7 Types
-
- -->
-
- <xs:complexType name="S7Message">
- <xs:sequence>
- <!-- S7 Magic Byte always 0x32 -->
- <xs:element name="magicByte" type="plc4x:uint8">
- <xs:annotation>
- <xs:appinfo source="http://www.ogf.org/dfdl/">
- <dfdl:assert message="Magic number was not 0x32."
- test="{. eq 50}"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:element>
- <xs:element name="type" type="plc4x:uint8"/>
- <!--
- Unfortunately the response for a CPU Functions request follows the rules of a
- response, however has the header structure of a request
- (no error code or error class). As mapping to the same type is not allowed,
- we map to strings and use that as choice-key.
- -->
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="1" name="s7RequestMessage" type="s7:S7RequestMessage"/>
- <xs:element dfdl:choiceBranchKey="3" name="s7ResponseMessage" type="s7:S7ResponseMessage"/>
- <xs:element dfdl:choiceBranchKey="7" name="s7UserDataMessage" type="s7:S7UserDataMessage"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7RequestMessage">
- <xs:sequence>
- <!-- Reserved value always 0x0000 -->
- <xs:element name="reserved" type="plc4x:uint16" fixed="0"/>
- <xs:element name="tpduReference" type="plc4x:uint16"/>
- <xs:element name="parametersLength" type="plc4x:uint16"/>
- <xs:element name="payloadsLength" type="plc4x:uint16"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../parametersLength}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../parametersLength gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="type" type="plc4x:uint8"/>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="240" name="s7GeneralParameterSetupCommunication"
- type="s7:S7GeneralParameterSetupCommunication"/>
- <xs:element dfdl:choiceBranchKey="4" name="s7RequestParameterReadVar"
- type="s7:S7RequestParameterReadVar"/>
- <xs:element dfdl:choiceBranchKey="5" name="s7RequestParameterWriteVar"
- type="s7:S7RequestParameterWriteVar"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <!--
- As we might be outputting an empty payload block for a parameter that might not have a payload,
- we have to output this element if the parameters are not empty. The case that the payloads are
- not empty but the parameters are can't happen during normal operation.
- -->
- <xs:element name="payloads" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../payloadsLength}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../parametersLength gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <!--
- For every parameter we'll be outputting a payload block, even if this might be empty.
- This is required in order to find the matching parameter for every payload we might
- be having. We need to match these as otherwise we couldn't determine the type of a
- payload as this has no type information and we need to be able to access the number
- of items for a read/write request in order to process the correct number of items in
- the payload.
- -->
- <xs:element name="payload" maxOccurs="unbounded"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{fn:count(../../parameters[1]/parameter)}">
- <xs:complexType>
- <xs:sequence>
- <xs:choice
- dfdl:choiceDispatchKey="{xs:string(../../parameters[1]/parameter[dfdl:occursIndex()]/type)}">
- <xs:element dfdl:choiceBranchKey="240" name="s7GeneralPayloadSetupCommunication"
- type="s7:S7GeneralPayloadSetupCommunication"/>
- <xs:element dfdl:choiceBranchKey="4" name="s7RequestPayloadReadVar"
- type="s7:S7RequestPayloadReadVar"/>
- <xs:element dfdl:choiceBranchKey="5" name="s7RequestPayloadWriteVar"
- type="s7:S7RequestPayloadWriteVar"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7ResponseMessage">
- <xs:sequence>
- <!-- Reserved value always 0x0000 -->
- <xs:element name="reserved" type="plc4x:uint16" fixed="0"/>
- <xs:element name="tpduReference" type="plc4x:uint16"/>
- <xs:element name="parametersLength" type="plc4x:uint16"/>
- <xs:element name="payloadsLength" type="plc4x:uint16"/>
- <!-- UserData (type 7) responses don't have the error class and code -->
- <xs:element name="errorClass" type="plc4x:uint8" minOccurs="0"
- dfdl:occursCountKind="expression" dfdl:occursCount="{if(../../type eq 3) then 1 else 0}"/>
- <xs:element name="errorCode" type="plc4x:uint8" minOccurs="0"
- dfdl:occursCountKind="expression" dfdl:occursCount="{if(../../type eq 3) then 1 else 0}"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../parametersLength}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../parametersLength gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="type" type="plc4x:uint8"/>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="240" name="s7GeneralParameterSetupCommunication"
- type="s7:S7GeneralParameterSetupCommunication"/>
- <xs:element dfdl:choiceBranchKey="4" name="s7ResponseParameterReadVar"
- type="s7:S7ResponseParameterReadVar"/>
- <xs:element dfdl:choiceBranchKey="5" name="s7ResponseParameterWriteVar"
- type="s7:S7ResponseParameterWriteVar"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <!--
- As we might be outputting an empty payload block for a parameter that might not have a payload,
- we have to output this element if the parameters are not empty. The case that the payloads are
- not empty but the parameters are can't happen during normal operation.
- -->
- <xs:element name="payloads" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../payloadsLength}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../parametersLength gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <!--
- For every parameter we'll be outputting a payload block, even if this might be empty.
- This is required in order to find the matching parameter for every payload we might
- be having. We need to match these as otherwise we couldn't determin the type of a
- payload as this has no type information and we need to be able to access the number
- of items for a read/write request in order to process the correct number of items in
- the payload.
- -->
- <xs:element name="payload" maxOccurs="unbounded"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{fn:count(../../parameters[1]/parameter)}">
- <xs:complexType>
- <xs:sequence>
- <xs:choice
- dfdl:choiceDispatchKey="{xs:string(../../parameters[1]/parameter[dfdl:occursIndex()]/type)}">
- <xs:element dfdl:choiceBranchKey="240" name="s7GeneralPayloadSetupCommunication"
- type="s7:S7GeneralPayloadSetupCommunication"/>
- <xs:element dfdl:choiceBranchKey="4" name="s7ResponsePayloadReadVar"
- type="s7:S7ResponsePayloadReadVar"/>
- <xs:element dfdl:choiceBranchKey="5" name="s7ResponsePayloadWriteVar"
- type="s7:S7ResponsePayloadWriteVar"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
-
- <xs:complexType name="S7UserDataMessage">
- <xs:sequence>
- <!-- Reserved value always 0x0000 -->
- <xs:element name="reserved" type="plc4x:uint16" fixed="0"/>
- <xs:element name="tpduReference" type="plc4x:uint16"/>
- <xs:element name="parametersLength" type="plc4x:uint16"/>
- <xs:element name="payloadsLength" type="plc4x:uint16"/>
- <xs:element name="parameters" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../parametersLength}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../parametersLength gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="parameter" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="type" type="plc4x:uint8"/>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="0" name="s7UserDataParameterCPUService"
- type="s7:S7UserDataParameterCPUService"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <!--
- As we might be outputting an empty payload block for a parameter that might not have a payload,
- we have to output this element if the parameters are not empty. The case that the payloads are
- not empty but the parameters are can't happen during normal operation.
- -->
- <xs:element name="payloads" minOccurs="0"
- dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" dfdl:length="{../payloadsLength}"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../parametersLength gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <!--
- For every parameter we'll be outputting a payload block, even if this might be empty.
- This is required in order to find the matching parameter for every payload we might
- be having. We need to match these as otherwise we couldn't determine the type of a
- payload as this has no type information and we need to be able to access the number
- of items for a read/write request in order to process the correct number of items in
- the payload.
- -->
- <xs:element name="payload" maxOccurs="unbounded"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{fn:count(../../parameters[1]/parameter)}">
- <xs:complexType>
- <xs:sequence>
- <xs:choice
- dfdl:choiceDispatchKey="{xs:string(../../parameters[1]/parameter[dfdl:occursIndex()]/type)}">
- <xs:element dfdl:choiceBranchKey="0" name="s7UserDataPayloadCpuServices"
- type="s7:S7UserDataPayloadCpuServices"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <!--
-
- Parameters.
-
- -->
-
- <xs:complexType name="S7GeneralParameterSetupCommunication">
- <xs:sequence>
- <!-- Reserved value always 0x00 -->
- <xs:element name="reserved" type="plc4x:uint8" fixed="0"/>
- <xs:element name="maxAmqCaller" type="plc4x:uint16"/>
- <xs:element name="maxAmqCallee" type="plc4x:uint16"/>
- <xs:element name="pduLength" type="plc4x:uint16"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7UserDataParameterCPUService">
- <xs:sequence>
- <!-- Fixed header 0x0112 274 -> -->
- <xs:element name="header" type="plc4x:uint16"/><!-- fixed="274"-->
- <xs:element name="paramLength" type="plc4x:uint8"/><!-- fixed="4"-->
- <!-- Request: 0x11 -> 17 -->
- <xs:element name="typeCode" type="plc4x:uint8"/><!-- fixed="17"-->
- <xs:element name="type" type="plc4x:uintN" dfdl:length="4"/>
- <!-- First 4 bits: Request 0x40, last 4 bits: Function Group 0x04 = 0x44 -> 68 -->
- <xs:element name="functionGroup" type="plc4x:uintN" dfdl:length="4"/><!-- fixed="68"-->
- <!-- READ SSL = 0x01 -->
- <xs:element name="subFunctionGroup" type="plc4x:uint8"/><!-- fixed="1"-->
- <xs:element name="sequenceNumber" type="plc4x:uint8"/>
- <xs:element name="dataUnitReferenceNumber" type="plc4x:uint8" minOccurs="0"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../sequenceNumber eq 2) then 1 else 0}"/>
- <xs:element name="lastDataUnit" type="plc4x:uint8" minOccurs="0"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../sequenceNumber eq 2) then 1 else 0}"/>
- <xs:element name="errorCode" type="plc4x:uint16" minOccurs="0"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../sequenceNumber eq 2) then 1 else 0}"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7RequestParameterReadVar">
- <xs:sequence>
- <xs:element name="numItems" type="plc4x:uint8"/>
- <xs:element name="items" minOccurs="0"
- dfdl:occursCountKind="expression" dfdl:occursCount="{if(../numItems gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="item" minOccurs="0" maxOccurs="unbounded"
- dfdl:occursCountKind="expression" dfdl:occursCount="{../../numItems}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="type" type="plc4x:uint8"/>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="18" name="s7RequestParameterReadVarAnyItem"
- type="s7:S7RequestParameterReadVarAnyItem"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7RequestParameterReadVarAnyItem">
- <xs:sequence>
- <xs:element name="paramLength" type="plc4x:uint8"/><!-- fixed="10"-->
- <!-- Addressing Mode: Any 0x10 -> 16 -->
- <xs:element name="addressingMode" type="plc4x:uint8"/><!-- fixed="16"-->
- <xs:element name="dataType" type="plc4x:uint8"/>
- <xs:element name="numElements" type="plc4x:uint16"/>
- <xs:element name="dataBlockNumber" type="plc4x:uint16"/>
- <xs:element name="memoryArea" type="plc4x:uint8"/>
- <!--
- The next 3 bytes (24 bits) contain the byte- and bit-offset,
- were the last byte contains the bit-offset in the last 3 bits
- and the byteOffset is encoded in the higher level 21 bits
- -->
- <xs:element name="byteOffset" type="plc4x:uintN" dfdl:length="21"/>
- <xs:element name="bitOffset" type="plc4x:uintN" dfdl:length="3"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7ResponseParameterReadVar">
- <xs:sequence>
- <xs:element name="numItems" type="plc4x:uint8"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7RequestParameterWriteVar">
- <xs:sequence>
- <xs:element name="numItems" type="plc4x:uint8"/>
- <xs:element name="items" minOccurs="0"
- dfdl:occursCountKind="expression" dfdl:occursCount="{if(../numItems gt 0) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="item" minOccurs="0" maxOccurs="unbounded"
- dfdl:occursCountKind="expression" dfdl:occursCount="{../../numItems}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="type" type="plc4x:uint8"/>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(type)}">
- <xs:element dfdl:choiceBranchKey="18" name="s7RequestParameterWriteVarAnyItem"
- type="s7:S7RequestParameterWriteVarAnyItem"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7RequestParameterWriteVarAnyItem">
- <xs:sequence>
- <xs:element name="itemLength" type="plc4x:uint8"/><!-- fixed="10"-->
- <!-- Addressing Mode: Any 0x10 -> 16 -->
- <xs:element name="addressingMode" type="plc4x:uint8"/><!-- fixed="16"-->
- <xs:element name="dataType" type="plc4x:uint8"/>
- <xs:element name="numElements" type="plc4x:uint16"/>
- <xs:element name="dataBlockNumber" type="plc4x:uint16"/>
- <xs:element name="memoryArea" type="plc4x:uint8"/>
- <!--
- The next 3 bytes (24 bits) contain the byte- and bit-offset,
- were the last byte contains the bit-offset in the last 3 bits
- and the byteOffset is encoded in the higher level 21 bits
- -->
- <xs:element name="byteOffset" type="plc4x:uintN" dfdl:length="21"/>
- <xs:element name="bitOffset" type="plc4x:uintN" dfdl:length="3"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7ResponseParameterWriteVar">
- <xs:sequence>
- <xs:element name="numItems" type="plc4x:uint8"/>
- </xs:sequence>
- </xs:complexType>
-
- <!--
-
- Payloads.
-
- -->
-
- <xs:complexType name="S7GeneralPayloadSetupCommunication">
- <xs:sequence>
- <xs:element name="data" type="plc4x:null"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7UserDataPayloadCpuServices">
- <xs:sequence>
- <xs:element name="returnCode" type="plc4x:uint8"/>
- <xs:element name="transportSize" type="plc4x:uint8"/><!-- fixed="9"-->
- <xs:element name="length" type="plc4x:uint16"/>
- <xs:element name="sslId" type="plc4x:uint16" minOccurs="0"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../returnCode eq 255) then 1 else 0}"/>
- <xs:element name="sslIndex" type="plc4x:uint16" minOccurs="0"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if(../returnCode eq 255) then 1 else 0}"/>
- <xs:element name="partialList" minOccurs="0"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{if((../returnCode eq 255) and (../length gt 4)) then 1 else 0}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="partialListLengthInBytes" type="plc4x:uint16"/>
- <xs:element name="partialListCount" type="plc4x:uint16"/>
- <xs:element name="sslDataRecords">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="sslDataRecord" maxOccurs="unbounded"
- dfdl:occursCountKind="expression"
- dfdl:occursCount="{../../partialListCount}">
- <xs:complexType>
- <xs:sequence>
- <xs:choice dfdl:choiceDispatchKey="{xs:string(../../../sslId[1])}">
- <xs:element dfdl:choiceBranchKey="17"
- name="s7ResponsePayloadCpuServicesSslDataRecordModuleIdentification"
- type="s7:S7ResponsePayloadCpuServicesSslDataRecordModuleIdentification"/>
- </xs:choice>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7ResponsePayloadCpuServicesSslDataRecordModuleIdentification">
- <xs:sequence>
- <xs:element name="index" type="plc4x:uint16"/>
- <xs:element name="articleNumber" type="plc4x:stringN" dfdl:length="20"/>
- <xs:element name="bgType" type="plc4x:uint16"/>
- <xs:element name="moduleOrOsVersion" type="plc4x:uint16"/>
- <xs:element name="pgDescriptionFileVersion" type="plc4x:uint16"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7RequestPayloadReadVar">
- <xs:sequence>
- <xs:element name="data" type="plc4x:null"/>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7ResponsePayloadReadVar">
- <xs:sequence>
- <!-- The number of items which should be read is transmitted in the matching parameter -->
- <xs:element name="numItems" type="plc4x:uint8"
- dfdl:inputValueCalc="{
- ../../../../parameters[1]/parameter[dfdl:occursIndex()]/s7ResponseParameterReadVar/numItems
- }"/>
- <xs:element name="item" minOccurs="0" maxOccurs="unbounded"
- dfdl:occursCountKind="expression" dfdl:occursCount="{../numItems}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="returnCode" type="plc4x:uint8"/>
- <xs:element name="transportSize" type="plc4x:uint8"/>
- <xs:element name="rawLength" type="plc4x:uint16"/>
- <!--
- For some reason the types BIT, BYTE_WORD_DWORD and INTEGER are transferred in "bits",
- the rest is transferred in "bytes"
- -->
- <xs:element name="lengthInBytes" type="plc4x:uint16" dfdl:inputValueCalc="{
- xs:unsignedShort(if((../transportSize eq 3) or (../transportSize eq 4) or (../transportSize eq 5))
- then fn:ceiling(xs:double(../rawLength div 8))
- else ../rawLength)}"/>
- <xs:element name="data" type="plc4x:byteN" dfdl:length="{../lengthInBytes}"/>
- <!--
- Transport sizes: BIT, BYTE_WORD_DWORD and OCTET_STRING require a blank byte.
- However only if this is not the last item in the result.
- -->
- <xs:element name="fillByte" type="plc4x:uint8" minOccurs="0"
- dfdl:occursCountKind="expression" dfdl:occursCount="{
- if(((../lengthInBytes mod 2) eq 1) and
- (dfdl:occursIndex() ne ../../numItems)) then 1 else 0}"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7RequestPayloadWriteVar">
- <xs:sequence>
- <!-- The number of items which should be read is transmitted in the matching parameter -->
- <xs:element name="numItems" type="plc4x:uint8"
- dfdl:inputValueCalc="{
- ../../../../parameters[1]/parameter[dfdl:occursIndex()]/s7RequestParameterWriteVar/numItems
- }"/>
- <xs:element name="item" minOccurs="0" maxOccurs="unbounded"
- dfdl:occursCountKind="expression" dfdl:occursCount="{../numItems}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="returnCode" type="plc4x:uint8"/>
- <xs:element name="transportSize" type="plc4x:uint8"/>
- <xs:element name="rawLength" type="plc4x:uint16"/>
- <!--
- For some reason the types BIT, BYTE_WORD_DWORD and INTEGER are transferred in "bits",
- the rest is transferred in "bytes"
- -->
- <xs:element name="lengthInBytes" type="plc4x:uint16" dfdl:inputValueCalc="{
- xs:unsignedShort(if((../transportSize eq 3) or (../transportSize eq 4) or (../transportSize eq 5))
- then fn:ceiling(../rawLength div 8)
- else ../rawLength)}"/>
- <xs:element name="data" type="plc4x:byteN" dfdl:length="{../lengthInBytes}"/>
- <!--
- It seems that the item payload must always be an even number of bytes. So if it's
- not an even number, add a fill byte.
- -->
- <xs:element name="fillByte" type="plc4x:uint8" minOccurs="0"
- dfdl:occursCountKind="expression" dfdl:occursCount="{
- if(((../lengthInBytes mod 2) eq 1) and
- (dfdl:occursIndex() ne ../../numItems)) then 1 else 0}"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
- <xs:complexType name="S7ResponsePayloadWriteVar">
- <xs:sequence>
- <!-- The number of items which should be read is transmitted in the matching parameter -->
- <xs:element name="numItems" type="plc4x:uint8"
- dfdl:inputValueCalc="{
- ../../../../parameters[1]/parameter[dfdl:occursIndex()]/s7ResponseParameterWriteVar/numItems
- }"/>
- <xs:element name="item" minOccurs="0" maxOccurs="unbounded"
- dfdl:occursCountKind="expression" dfdl:occursCount="{../numItems}">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="returnCode" type="plc4x:uint8"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
-
-</xs:schema>
\ No newline at end of file
diff --git a/protocols/s7/src/main/resources/org/apache/plc4x/protocols/s7/protocol.scxml.xml b/protocols/s7/src/main/resources/org/apache/plc4x/protocols/s7/protocol.scxml.xml
deleted file mode 100644
index 0f8e98f..0000000
--- a/protocols/s7/src/main/resources/org/apache/plc4x/protocols/s7/protocol.scxml.xml
+++ /dev/null
@@ -1,526 +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.
- -->
-<sc:scxml version="1.0"
- xmlns:plc4x="https://plc4x.apache.org/scxml-extension"
- xmlns:sc="http://www.w3.org/2005/07/scxml"
- xmlns:s7="http://plc4x.apache.org/s7"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- initial="init"
- datamodel="jexl"
- xsi:schemaLocation="http://www.w3.org/2005/07/scxml http://www.w3.org/2011/04/SCXML/scxml.xsd">
-
- <!-- Define all the variables we're going to use -->
- <sc:datamodel>
- <sc:data id="protocolDaffodilSchema"/>
- <sc:data id="cotpLocalReference"/>
- <sc:data id="cotpCalledTsap"/>
- <sc:data id="cotpCallingTsap"/>
- <sc:data id="cotpTpduSize"/>
- <sc:data id="s7MaxAmqCaller"/>
- <sc:data id="s7MaxAmqCallee"/>
- <sc:data id="s7PduLength"/>
- <sc:data id="s7ArticleNumber"/>
- <sc:data id="plcType"/>
-
- <!-- Data container for processing requests -->
- <sc:data id="container"/>
- </sc:datamodel>
-
- <!--
- Setup the initial state ... this usually just initializes the Daffodil subsystem.
- -->
- <sc:state id="init">
- <sc:onentry>
- <!--
- Setup the initial content of the connection context (Callback in the driver)
- (4294967295 is the max unsigned int value)
- -->
- <plc4x:initContext maxRequestId="4294967295" protocolDaffodilSchemaName="protocolDaffodilSchema"/>
- </sc:onentry>
- <sc:transition event="success" target="connect">
- <sc:assign location="args" expr="_event.data"/>
- </sc:transition>
- </sc:state>
-
- <!--
- Sub-Statemachine handling the connection establishment.
- -->
- <sc:state id="connect">
- <sc:initial>
- <sc:transition target="establishNetworkConnection"/>
- </sc:initial>
-
- <!-- This step establishes the physical connection to the remote -->
- <sc:state id="establishNetworkConnection">
- <sc:onentry>
- <!-- Initialize the network connection to the remote host using the tcp adapter with a given host and port -->
- <plc4x:connect type="tcp" host="10.10.64.20" port="102"/>
- </sc:onentry>
- <sc:transition event="success" target="sendCotpConnectionRequest"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- First we have to connect on COTP level, so send CTOP connection request first.
- Some parameters we are sending are a suggestion from our side, the remote will
- respond with values it sees more fitting.
-
- For example the "called-tsap" we just make up an id and the remote will respond
- with its real id.
-
- The pdu size is the one is the maximum PDU size we can live with, the remote
- will respond with a size that is at most this big (usually it's smaller).
- -->
- <sc:state id="sendCotpConnectionRequest">
- <sc:onentry>
- <plc4x:send>
- <s7:TpktMessage>
- <magicByte>3</magicByte>
- <reserved>0</reserved>
- <length>22</length>
- <userData>
- <headerLength>17</headerLength>
- <type>224</type>
- <cotpTpduConnectionRequest>
- <destinationReference>0</destinationReference>
- <!-- Insert the value for "cotpLocalReference" as short here -->
- <sourceReference>${cotpLocalReference}</sourceReference>
- <protocolClass>0</protocolClass>
- <s7:parameters>
- <parameter>
- <type>194</type>
- <parameterLength>2</parameterLength>
- <cotpParameterCalledTsap>
- <tsapId>${cotpCalledTsap}</tsapId>
- </cotpParameterCalledTsap>
- </parameter>
- <parameter>
- <type>193</type>
- <parameterLength>2</parameterLength>
- <cotpParameterCallingTsap>
- <tsapId>${cotpCallingTsap}</tsapId>
- </cotpParameterCallingTsap>
- </parameter>
- <parameter>
- <type>192</type>
- <parameterLength>1</parameterLength>
- <cotpParameterTpduSize>
- <tpduSize>${cotpTpduSize}</tpduSize>
- </cotpParameterTpduSize>
- </parameter>
- </s7:parameters>
- </cotpTpduConnectionRequest>
- </userData>
- </s7:TpktMessage>
- </plc4x:send>
- </sc:onentry>
- <sc:transition event="success" target="receiveCotpConnectionResponse"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- If everything wen't fine, the remote should respond with a connection response.
- As mentioned before we now have to update some of the values with the ones the
- remote responded with.
- -->
- <sc:state id="receiveCotpConnectionResponse">
- <sc:onentry>
- <plc4x:receiveExtractVerify timeout="5000" packetLengthStartPosition="2" packetLengthSizeInBytes="2">
- <verification name="cotpLocalReference" xpath-expression="/s7:TpktMessage/userData/s7:CotpTpduConnectionResponse/destinationReference/text()[1]"/>
- <extraction name="cotpRemoteReference" xpath-expression="/s7:TpktMessage/userData/s7:CotpTpduConnectionResponse/sourceReference/text()[1]"/>
- <extraction name="cotpTpduSize" xpath-expression="/s7:TpktMessage/userData/s7:CotpTpduConnectionResponse/s7:parameters/parameter/s7:CotpParameterTpduSize/tpduSize/text()[1]"/>
- <extraction name="cotpCallingTsap" xpath-expression="/s7:TpktMessage/userData/s7:CotpTpduConnectionResponse/s7:parameters/parameter/s7:CotpParameterCallingTsap/tsapId/text()[1]"/>
- <extraction name="cotpCalledTsap" xpath-expression="/s7:TpktMessage/userData/s7:CotpTpduConnectionResponse/s7:parameters/parameter/s7:CotpParameterCalledTsap/tsapId/text()[1]"/>
- </plc4x:receiveExtractVerify>
- </sc:onentry>
- <sc:transition event="success" target="sendS7SetupCommunicationRequest"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- After the connection is established on COTP level, we now do the same on the S7
- protocol level. Again we will be sending values we think are ok and in the
- response the remote will tell us what it can live with.
- -->
- <sc:state id="sendS7SetupCommunicationRequest">
- <sc:onentry>
- <plc4x:send>
- <s7:TpktMessage>
- <magicByte>3</magicByte>
- <reserved>0</reserved>
- <length>25</length>
- <userData>
- <headerLength>2</headerLength>
- <type>240</type>
- <cotpTpduData>
- <endOfTransmission>1</endOfTransmission>
- <tpduRef>0</tpduRef>
- </cotpTpduData>
- <userData>
- <magicByte>50</magicByte>
- <type>1</type>
- <s7RequestMessage>
- <reserved>0</reserved>
- <tpduReference>0</tpduReference>
- <parametersLength>8</parametersLength>
- <payloadsLength>0</payloadsLength>
- <parameters>
- <parameter>
- <type>240</type>
- <s7GeneralParameterSetupCommunication>
- <reserved>0</reserved>
- <maxAmqCaller>${s7MaxAmqCaller}</maxAmqCaller>
- <maxAmqCallee>${s7MaxAmqCallee}</maxAmqCallee>
- <pduLength>${s7PduLength}</pduLength>
- </s7GeneralParameterSetupCommunication>
- </parameter>
- </parameters>
- <payloads>
- <payload>
- <s7GeneralPayloadSetupCommunication>
- <data/>
- </s7GeneralPayloadSetupCommunication>
- </payload>
- </payloads>
- </s7RequestMessage>
- </userData>
- </userData>
- </s7:TpktMessage>
- </plc4x:send>
- </sc:onentry>
- <sc:transition event="success" target="receiveS7SetupCommunicationResponse"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- If everything wen't fine, the remote should respond with a connection response.
- As mentioned before we now have to update some of the values with the ones the
- remote responded with.
-
- If a "plcType" was provided, we are now connected.
-
- If no "plcType" was provided, the type has to be discovered by sending another
- request and processing that response first.
- -->
- <sc:state id="receiveS7SetupCommunicationResponse">
- <sc:onentry>
- <plc4x:receiveExtractVerify timeout="5000" packetLengthStartPosition="2" packetLengthSizeInBytes="2">
- <extraction name="returnCode" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/errorCode/text()[1]"/>
- <extraction name="s7MaxAmqCaller" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/parameters/parameter/s7:S7GeneralParameterSetupCommunication/maxAmqCaller/text()[1]"/>
- <extraction name="s7MaxAmqCallee" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/parameters/parameter/s7:S7GeneralParameterSetupCommunication/maxAmqCallee/text()[1]"/>
- <extraction name="s7PduLength" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/parameters/parameter/s7:S7GeneralParameterSetupCommunication/pduLength/text()[1]"/>
- </plc4x:receiveExtractVerify>
- </sc:onentry>
- <sc:transition event="success" cond="plcType == null" target="sendS7IdentificationRequest"/>
- <sc:transition event="success" cond="plcType != null" target="connected"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- If no "plcType" was provided, an S7 identification request will ask the
- remote to send back so-called SSLs. These contain information on the type
- and version of the remote PLC.
- -->
- <sc:state id="sendS7IdentificationRequest">
- <sc:onentry>
- <plc4x:send>
- <s7:TpktMessage>
- <magicByte>3</magicByte>
- <reserved>0</reserved>
- <length>33</length>
- <userData>
- <headerLength>2</headerLength>
- <type>240</type>
- <cotpTpduData>
- <endOfTransmission>1</endOfTransmission>
- <tpduRef>0</tpduRef>
- </cotpTpduData>
- <userData>
- <magicByte>50</magicByte>
- <type>7</type>
- <s7UserDataMessage>
- <reserved>0</reserved>
- <tpduReference>1</tpduReference>
- <parametersLength>8</parametersLength>
- <payloadsLength>8</payloadsLength>
- <parameters>
- <parameter>
- <type>0</type>
- <s7UserDataParameterCPUService>
- <header>274</header>
- <paramLength>4</paramLength>
- <typeCode>17</typeCode>
- <type>4</type>
- <functionGroup>4</functionGroup>
- <subFunctionGroup>1</subFunctionGroup>
- <sequenceNumber>0</sequenceNumber>
- </s7UserDataParameterCPUService>
- </parameter>
- </parameters>
- <payloads>
- <payload>
- <s7UserDataPayloadCpuServices>
- <returnCode>255</returnCode>
- <transportSize>9</transportSize>
- <length>4</length>
- <sslId>17</sslId>
- <sslIndex>0</sslIndex>
- </s7UserDataPayloadCpuServices>
- </payload>
- </payloads>
- </s7UserDataMessage>
- </userData>
- </userData>
- </s7:TpktMessage>
- </plc4x:send>
- </sc:onentry>
- <sc:transition event="success" target="receiveS7IdentificationRequest"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- As we're currently only interested in the type of the PLC, we simply
- take the article number returned and decode that in a S7 specific
- custom action.
- -->
- <sc:state id="receiveS7IdentificationRequest">
- <sc:onentry>
- <plc4x:receiveExtractVerify timeout="5000" packetLengthStartPosition="2" packetLengthSizeInBytes="2">
- <!-- Ensure everything is ok -->
- <!--verification value="255" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7UserDataMessage/payloads/payload/s7:S7UserDataPayloadCpuServices/returnCode/text()"/-->
- <!-- Extract the article-number of the SslDataRecordModuleIdentification with the index 1 -->
- <extraction name="s7ArticleNumber" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7UserDataMessage/payloads/payload/s7:S7UserDataPayloadCpuServices/partialList/sslDataRecords/sslDataRecord//s7:S7ResponsePayloadCpuServicesSslDataRecordModuleIdentification[index='1']/articleNumber/text()"/>
- </plc4x:receiveExtractVerify>
- </sc:onentry>
- <sc:transition event="success" target="connected">
- <plc4x:S7DecodeArticleNumber articleNumberParameterName="s7ArticleNumber" plcTypeParameterName="plcType"/>
- <sc:log expr="'Connected to PLC of type: ' + plcType"/>
- </sc:transition>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- Default state after connecting to a PLC.
- -->
- <sc:state id="connected">
- <sc:transition event="read" target="sendS7ReadRequest">
- <sc:assign location="container" expr="_event.data"/>
- </sc:transition>
- <sc:transition event="write" target="sendS7WriteRequest">
- <sc:assign location="container" expr="_event.data"/>
- </sc:transition>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <sc:state id="sendS7ReadRequest">
- <sc:datamodel>
- <sc:data id="requestId"/>
- </sc:datamodel>
- <sc:onentry>
- <plc4x:sendRequest idExpression="/s7:TpktMessage/userData/userData/s7:S7RequestMessage/tpduReference/text()">
- <s7:TpktMessage>
- <magicByte>3</magicByte>
- <reserved>0</reserved>
- <length>31</length>
- <userData>
- <headerLength>2</headerLength>
- <type>240</type>
- <cotpTpduData>
- <endOfTransmission>1</endOfTransmission>
- <tpduRef>0</tpduRef>
- </cotpTpduData>
- <userData>
- <magicByte>50</magicByte>
- <type>1</type>
- <s7RequestMessage>
- <reserved>0</reserved>
- <tpduReference>${requestId}</tpduReference>
- <parametersLength>14</parametersLength>
- <payloadsLength>0</payloadsLength>
- <parameters>
- <parameter>
- <type>4</type>
- <s7RequestParameterReadVar>
- <numItems>1</numItems>
- <items>
- <item>
- <type>18</type>
- <s7RequestParameterReadVarAnyItem>
- <paramLength>10</paramLength>
- <addressingMode>16</addressingMode>
- <dataType>${container.request.fields[0].dataType.typeCode}</dataType><!--8 ${s7ReadDataType}-->
- <numElements>${container.request.fields[0].numElements}</numElements><!--1 ${s7ReadNumElements}-->
- <dataBlockNumber>${container.request.fields[0].blockNumber}</dataBlockNumber><!--0 ${s7ReadDataBlockNumber}-->
- <memoryArea>${container.request.fields[0].memoryArea.code}</memoryArea><!--131 ${s7ReadMemoryArea}-->
- <byteOffset>${container.request.fields[0].byteOffset}</byteOffset><!--16 ${s7ReadByteOffset}-->
- <bitOffset>${container.request.fields[0].bitOffset}</bitOffset><!--0 ${s7ReadBitOffset}-->
- </s7RequestParameterReadVarAnyItem>
- </item>
- </items>
- </s7RequestParameterReadVar>
- </parameter>
- </parameters>
- <payloads>
- <payload>
- <s7RequestPayloadReadVar/>
- </payload>
- </payloads>
- </s7RequestMessage>
- </userData>
- </userData>
- </s7:TpktMessage>
- </plc4x:sendRequest>
- </sc:onentry>
- <sc:transition event="success" target="receiveS7ReadResponse"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <sc:state id="receiveS7ReadResponse">
- <sc:onentry>
- <plc4x:S7DecodeReadResponse timeout="5000" packetLengthStartPosition="2" packetLengthSizeInBytes="2"
- idExpression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/tpduReference/text()">
- <!--verification value="255" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/payloads/payload/s7:S7ResponsePayloadReadVar/item[1]/returnCode/text()"/>
- <extraction name="s7ReadData" xpath-expression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/payloads/payload/s7:S7ResponsePayloadReadVar/item[1]/data/text()"/-->
- </plc4x:S7DecodeReadResponse>
- </sc:onentry>
- <sc:transition event="success" target="connected"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <sc:state id="sendS7WriteRequest">
- <sc:datamodel>
- <sc:data id="requestId"/>
- </sc:datamodel>
- <sc:onentry>
- <plc4x:sendRequest idExpression="/s7:TpktMessage/userData/userData/s7:S7RequestMessage/tpduReference/text()">
- <s7:TpktMessage>
- <magicByte>3</magicByte>
- <reserved>0</reserved>
- <length>39</length>
- <userData>
- <headerLength>2</headerLength>
- <type>240</type>
- <cotpTpduData>
- <endOfTransmission>1</endOfTransmission>
- <tpduRef>0</tpduRef>
- </cotpTpduData>
- <userData>
- <magicByte>50</magicByte>
- <type>1</type>
- <s7RequestMessage>
- <reserved>0</reserved>
- <tpduReference>${requestId}</tpduReference>
- <parametersLength>14</parametersLength>
- <payloadsLength>8</payloadsLength>
- <parameters>
- <parameter>
- <type>5</type>
- <s7RequestParameterWriteVar>
- <numItems>1</numItems>
- <items>
- <item>
- <type>18</type>
- <s7RequestParameterWriteVarAnyItem>
- <itemLength>10</itemLength>
- <addressingMode>16</addressingMode>
- <dataType>8</dataType><!--8 ${s7WriteDataType}-->
- <numElements>1</numElements><!--1 ${s7WriteNumElements}-->
- <dataBlockNumber>0</dataBlockNumber><!--0 ${s7WriteDataBlockNumber}-->
- <memoryArea>131</memoryArea><!--131 ${s7WriteMemoryArea}-->
- <byteOffset>16</byteOffset><!--16 ${s7WriteByteOffset}-->
- <bitOffset>0</bitOffset><!--0 ${s7WriteBitOffset}-->
- </s7RequestParameterWriteVarAnyItem>
- </item>
- </items>
- </s7RequestParameterWriteVar>
- </parameter>
- </parameters>
- <payloads>
- <payload>
- <s7RequestPayloadWriteVar>
- <numItems>1</numItems>
- <item>
- <returnCode>0</returnCode>
- <transportSize>7</transportSize><!--7 ${s7WriteTransportSize}-->
- <rawLength>4</rawLength><!--4 ${s7WriteLength}-->
- <lengthInBytes>4</lengthInBytes><!--4 ${s7WriteLengthInBytes}-->
- <data>79E9F642</data><!--79E9F642 ${s7WriteData}-->
- </item>
- </s7RequestPayloadWriteVar>
- </payload>
- </payloads>
- </s7RequestMessage>
- </userData>
- </userData>
- </s7:TpktMessage>
- </plc4x:sendRequest>
- </sc:onentry>
- <sc:transition event="success" target="receiveS7WriteResponse"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <sc:state id="receiveS7WriteResponse">
- <sc:onentry>
- <plc4x:S7DecodeWriteResponse timeout="5000" packetLengthStartPosition="2" packetLengthSizeInBytes="2"
- idExpression="/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/tpduReference/text()">
- <!--verification value="255" xpath-expression="/s7:tpktMessage/userData/userData/s7:S7ResponseMessage/payloads/payload/s7:S7ResponsePayloadReadVar/item[1]/returnCode/text()"/-->
- </plc4x:S7DecodeWriteResponse>
- </sc:onentry>
- <sc:transition event="success" target="connected"/>
- <sc:transition event="failure" target="error"/>
- <sc:transition event="disconnect" target="disconnect"/>
- </sc:state>
-
- <!--
- Initiate disconnecting.
- -->
- <sc:state id="disconnect">
- <sc:transition event="disconnect" target="disconnected"/>
- </sc:state>
-
- <!--
- Final state of this state-machine, after any of the parties disconnected.
- -->
- <sc:final id="disconnected">
- <sc:onentry>
- <sc:log expr="'Disconnected'"/>
- </sc:onentry>
- </sc:final>
-
- <!--
- Error state in case of any form of error during the processing of data.
- -->
- <sc:final id="error">
- <sc:onentry>
- <sc:log expr="'Error'"/>
- </sc:onentry>
- </sc:final>
- </sc:state>
-
-</sc:scxml>
\ No newline at end of file
diff --git a/sandbox/code-generation/protocol-s7/src/main/resources/protocols/s7/protocol.spec b/protocols/s7/src/main/resources/protocols/s7/protocol.spec
similarity index 100%
rename from sandbox/code-generation/protocol-s7/src/main/resources/protocols/s7/protocol.spec
rename to protocols/s7/src/main/resources/protocols/s7/protocol.spec
diff --git a/protocols/s7/src/test/java/org/apache/plc4x/protocols/s7/ManualTest.java b/protocols/s7/src/test/java/org/apache/plc4x/protocols/s7/ManualTest.java
deleted file mode 100644
index c671787..0000000
--- a/protocols/s7/src/test/java/org/apache/plc4x/protocols/s7/ManualTest.java
+++ /dev/null
@@ -1,83 +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.protocols.s7;
-
-import org.apache.commons.codec.binary.Hex;
-import org.apache.daffodil.japi.Compiler;
-import org.apache.daffodil.japi.*;
-import org.apache.daffodil.japi.infoset.JDOMInfosetOutputter;
-import org.apache.daffodil.japi.io.InputSourceDataInputStream;
-import org.jdom2.Document;
-import org.jdom2.output.Format;
-import org.jdom2.output.XMLOutputter;
-
-import java.io.ByteArrayInputStream;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-
-public class ManualTest {
-
- public static void main(String[] args) throws Exception {
- Compiler c = Daffodil.compiler();
- c.setValidateDFDLSchemas(true);
- URL schemaUrl = ManualTest.class.getClassLoader().getResource("org/apache/plc4x/protocols/s7/protocol.dfdl.xsd");
- if (schemaUrl != null) {
- URI schemaUri = schemaUrl.toURI();
- ProcessorFactory pf = c.compileSource(schemaUri);
- logDiagnosticInformation(pf);
- DataProcessor dp = pf.onPath("/");
- logDiagnosticInformation(dp);
-
- /*byte[] packet = Hex.decodeHex(
- "0300004002f080320300" +
- "0000010002002b000004" +
- "07ff0300010000ff04002000000000ff0400080000ff0500100000ff0400080000ff0400100000ff04000800");*/
- byte[] packet = Hex.decodeHex(
- "0300004002f080320300" +
- "0000010002002b000004" +
- "07ff0300010000ff04002000000000ff0400080000ff0500100000ff0400080000ff0400100000ff04000800");
-
-
- // After having enough bytes available, process the current package.
- JDOMInfosetOutputter outputter = new JDOMInfosetOutputter();
- ParseResult byteMessage = dp.parse(
- new InputSourceDataInputStream(new ByteArrayInputStream(packet)), outputter);
- if (byteMessage.isError()) {
- logDiagnosticInformation(byteMessage);
- return;
- }
-
- // Get the resulting XML document from the parser.
- Document message = outputter.getResult();
-
- System.out.println(new XMLOutputter(Format.getPrettyFormat()).outputString(message));
- }
- }
-
- protected static void logDiagnosticInformation(WithDiagnostics withDiagnostics) {
- List<Diagnostic> diags = withDiagnostics.getDiagnostics();
- for (Diagnostic d : diags) {
- System.err.println(d.getSomeMessage());
- }
- }
-
-
-}
diff --git a/protocols/s7/src/test/java/org/apache/plc4x/protocols/s7/ProtocolTest.java b/protocols/s7/src/test/java/org/apache/plc4x/protocols/s7/ProtocolTest.java
deleted file mode 100644
index a7816e4..0000000
--- a/protocols/s7/src/test/java/org/apache/plc4x/protocols/s7/ProtocolTest.java
+++ /dev/null
@@ -1,33 +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.protocols.s7;
-
-import org.apache.plc4x.protocols.AbstractProtocolTest;
-
-/**
- * Executes all tests for the ISO on TCP / TPKT protocol.
- */
-public class ProtocolTest extends AbstractProtocolTest {
-
- public ProtocolTest() {
- super("org/apache/plc4x/protocols/s7/protocol.tdml");
- }
-
-}
diff --git a/sandbox/code-generation/pom.xml b/sandbox/code-generation/pom.xml
deleted file mode 100644
index 20a3152..0000000
--- a/sandbox/code-generation/pom.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.sandbox</groupId>
- <artifactId>plc4x-sandbox</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generaton</artifactId>
- <packaging>pom</packaging>
-
- <name>Sandbox: Code Generation</name>
-
- <modules>
- <module>protocol-base-mspec</module>
- <module>protocol-s7</module>
-
- <module>language-base-freemarker</module>
- <module>language-java</module>
-
- <module>driver-base-java</module>
-
- <!--module>test-java-s7-driver</module-->
- </modules>
-
-</project>
diff --git a/sandbox/code-generation/protocol-s7/pom.xml b/sandbox/code-generation/protocol-s7/pom.xml
deleted file mode 100644
index 4f397ad..0000000
--- a/sandbox/code-generation/protocol-s7/pom.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<?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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generaton</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4x-code-generation-protocol-s7</artifactId>
-
- <name>Sandbox: Code Generation: Protocol: S7</name>
- <description>Protocol module for generating S7 drivers</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generation-protocol-base-mspec</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generation-protocol-base</artifactId>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/sandbox/dynamic-driver-base/pom.xml b/sandbox/dynamic-driver-base/pom.xml
deleted file mode 100644
index b23f0d4..0000000
--- a/sandbox/dynamic-driver-base/pom.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-<?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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.sandbox</groupId>
- <artifactId>plc4x-sandbox</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4j-dynamic-driver-base</artifactId>
- <name>Sandbox: Dynamic-Driver: (Base)</name>
- <description>Base Implementation of a driver based on definitions provided by DFDL and SCXML.</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-api</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-protocol-driver-base</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-scxml2</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.daffodil</groupId>
- <artifactId>daffodil-japi_2.12</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.daffodil</groupId>
- <artifactId>daffodil-runtime1_2.12</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom2</artifactId>
- </dependency>
- <dependency>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </dependency>
- <dependency>
- <groupId>jaxen</groupId>
- <artifactId>jaxen</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>net.alchim31.maven</groupId>
- <artifactId>scala-maven-plugin</artifactId>
- <version>3.4.6</version>
- <executions>
- <execution>
- <id>add-scala-sources</id>
- <phase>validate</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sourceDir>src/main/scala</sourceDir>
- </configuration>
- </execution>
- <execution>
- <id>compile-scala</id>
- <!-- Intentionally bound to this phase as we need the scala code compiled first. -->
- <phase>process-sources</phase>
- <goals>
- <goal>compile</goal>
- </goals>
- <configuration>
- <outputDir>${project.build.outputDirectory}</outputDir>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <usedDependencies combine.children="append">
- <usedDependency>jaxen:jaxen</usedDependency>
- <usedDependency>org.apache.commons:commons-jexl3</usedDependency>
- </usedDependencies>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BaseConnectedAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BaseConnectedAction.java
deleted file mode 100644
index 1b26ce3..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BaseConnectedAction.java
+++ /dev/null
@@ -1,37 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.plc4x.sandbox.java.dynamic.io.ProtocolIO;
-
-public abstract class BaseConnectedAction extends BasePlc4xAction {
-
- public static final String SOCKET_PARAMETER_NAME="connection";
-
- protected ProtocolIO getProtocolIo(ActionExecutionContext ctx) {
- Object connection = ctx.getGlobalContext().get(SOCKET_PARAMETER_NAME);
- if(connection instanceof ProtocolIO) {
- return (ProtocolIO) connection;
- }
- return null;
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BaseDaffodilAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BaseDaffodilAction.java
deleted file mode 100644
index b3ef163..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BaseDaffodilAction.java
+++ /dev/null
@@ -1,56 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.commons.scxml2.model.ParsedValue;
-import org.apache.commons.scxml2.model.ParsedValueContainer;
-import org.apache.daffodil.japi.DataProcessor;
-import org.apache.daffodil.japi.Diagnostic;
-import org.apache.daffodil.japi.WithDiagnostics;
-
-import java.util.List;
-
-public abstract class BaseDaffodilAction extends BaseConnectedAction implements ParsedValueContainer {
-
- private ParsedValue message;
-
- @Override
- public ParsedValue getParsedValue() {
- return message;
- }
-
- @Override
- public void setParsedValue(ParsedValue parsedValue) {
- this.message = parsedValue;
- }
-
- protected DataProcessor getDaffodilDataProcessor(ActionExecutionContext ctx) {
- return (DataProcessor) ctx.getGlobalContext().get("dfdl");
- }
-
- protected void logDiagnosticInformation(WithDiagnostics withDiagnostics) {
- List<Diagnostic> diags = withDiagnostics.getDiagnostics();
- for (Diagnostic d : diags) {
- getLogger().error(d.getSomeMessage());
- }
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BasePlc4xAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BasePlc4xAction.java
deleted file mode 100644
index 4aff576..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/BasePlc4xAction.java
+++ /dev/null
@@ -1,52 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.commons.scxml2.EventBuilder;
-import org.apache.commons.scxml2.TriggerEvent;
-import org.apache.commons.scxml2.model.Action;
-import org.slf4j.Logger;
-
-public abstract class BasePlc4xAction extends Action {
-
- protected abstract Logger getLogger();
-
- protected String getStateName() {
- try {
- return getParentEnterableState().getId();
- } catch (Exception e) {
- getLogger().error("Unable to get state.");
- }
- return "unknown";
- }
-
- protected void fireFailureEvent(ActionExecutionContext ctx, String message) {
- TriggerEvent event = new EventBuilder("failure", TriggerEvent.ERROR_EVENT).
- data(getStateName() + ": " + message).build();
- ctx.getInternalIOProcessor().addEvent(event);
- }
-
- protected void fireSuccessEvent(ActionExecutionContext ctx) {
- TriggerEvent event = new EventBuilder("success", TriggerEvent.SIGNAL_EVENT).data(getStateName()).build();
- ctx.getInternalIOProcessor().addEvent(event);
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ConnectAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ConnectAction.java
deleted file mode 100644
index af46171..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ConnectAction.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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
-import org.apache.plc4x.sandbox.java.dynamic.exceptions.DynamicDriverException;
-import org.apache.plc4x.sandbox.java.dynamic.io.TcpProtocolIO;
-import org.apache.plc4x.sandbox.java.dynamic.io.UdpProtocolIO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ConnectAction extends BasePlc4xAction {
-
- private String type;
- private String host;
- private String port;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- public String getPort() {
- return port;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
- @Override
- protected Logger getLogger() {
- return LoggerFactory.getLogger(ConnectAction.class);
- }
-
- @Override
- public void execute(ActionExecutionContext ctx) {
- getLogger().info(getStateName() + ": Connecting...");
- try {
- if ("TCP".equalsIgnoreCase(type)) {
- TcpProtocolIO tcpIo = new TcpProtocolIO(host, Integer.parseInt(port));
- ctx.getGlobalContext().set(BaseConnectedAction.SOCKET_PARAMETER_NAME, tcpIo);
-
- getLogger().info("Connected.");
-
- fireSuccessEvent(ctx);
- } else if ("UDP".equalsIgnoreCase(type)) {
- UdpProtocolIO udpIo = new UdpProtocolIO(host, Integer.parseInt(port));
- ctx.getGlobalContext().set(BaseConnectedAction.SOCKET_PARAMETER_NAME, udpIo);
-
- getLogger().info("Connected.");
-
- fireSuccessEvent(ctx);
- } else {
- throw new PlcRuntimeException("Unsupported connection type " + type);
- }
- } catch (DynamicDriverException e) {
- getLogger().error("Error connecting to remote.", e);
- }
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/InitContextAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/InitContextAction.java
deleted file mode 100644
index 32e9535..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/InitContextAction.java
+++ /dev/null
@@ -1,106 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.commons.scxml2.EventBuilder;
-import org.apache.commons.scxml2.TriggerEvent;
-import org.apache.daffodil.japi.Compiler;
-import org.apache.daffodil.japi.*;
-import org.apache.plc4x.sandbox.java.dynamic.utils.RequestRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-
-public class InitContextAction extends BasePlc4xAction {
-
- private long maxRequestId;
- private String protocolDaffodilSchemaName;
-
- public String getMaxRequestId() {
- return Long.toString(maxRequestId);
- }
-
- public void setMaxRequestId(String maxRequestId) {
- this.maxRequestId = Long.valueOf(maxRequestId);
- }
-
- public String getProtocolDaffodilSchemaName() {
- return protocolDaffodilSchemaName;
- }
-
- public void setProtocolDaffodilSchemaName(String protocolDaffodilSchemaName) {
- this.protocolDaffodilSchemaName = protocolDaffodilSchemaName;
- }
-
- @Override
- protected Logger getLogger() {
- return LoggerFactory.getLogger(InitContextAction.class);
- }
-
- @Override
- public void execute(ActionExecutionContext ctx) {
- getLogger().info(getStateName() + ": Initializing Context...");
-
- // Initialize the Daffodil system for parsing and serializing the
- // protocol messages.
- try {
- Compiler c = Daffodil.compiler();
- c.setValidateDFDLSchemas(true);
- String schemaUrlString = (String) ctx.getGlobalContext().get(protocolDaffodilSchemaName);
- URL schemaUrl = SendAction.class.getClassLoader().getResource(schemaUrlString);
- if (schemaUrl != null) {
- URI schemaUri = schemaUrl.toURI();
- ProcessorFactory pf = c.compileSource(schemaUri);
- logDiagnosticInformation(pf);
- DataProcessor dp = pf.onPath("/");
- logDiagnosticInformation(dp);
- ctx.getGlobalContext().set("dfdl", dp);
- }
- } catch (Exception e) {
- fireFailureEvent(ctx, "Error initializing daffodil schema");
- TriggerEvent event = new EventBuilder("failure", TriggerEvent.SIGNAL_EVENT).data(e).build();
- ctx.getInternalIOProcessor().addEvent(event);
- return;
- }
-
- // Create a new request-registry that will be used for matching
- // requests and responses.
- ctx.getGlobalContext().set("requestRegistry", new RequestRegistry(maxRequestId));
-
- getLogger().info("Context initialized.");
-
- fireSuccessEvent(ctx);
- }
-
- private void logDiagnosticInformation(WithDiagnostics withDiagnostics) throws Exception {
- if(withDiagnostics.isError()) {
- List<Diagnostic> diags = withDiagnostics.getDiagnostics();
- for (Diagnostic d : diags) {
- getLogger().error(d.getSomeMessage());
- }
- throw new Exception();
- }
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveAction.java
deleted file mode 100644
index 7735be8..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveAction.java
+++ /dev/null
@@ -1,202 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.commons.scxml2.EventBuilder;
-import org.apache.commons.scxml2.TriggerEvent;
-import org.apache.daffodil.japi.DataProcessor;
-import org.apache.daffodil.japi.ParseResult;
-import org.apache.daffodil.japi.infoset.JDOMInfosetOutputter;
-import org.apache.daffodil.japi.io.InputSourceDataInputStream;
-import org.apache.plc4x.sandbox.java.dynamic.io.ProtocolIO;
-import org.jdom2.Document;
-import org.jdom2.Namespace;
-import org.jdom2.Text;
-import org.jdom2.filter.Filters;
-import org.jdom2.output.XMLOutputter;
-import org.jdom2.xpath.XPathExpression;
-import org.jdom2.xpath.XPathFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-public abstract class ReceiveAction extends BaseDaffodilAction {
-
- private long timeout = 5000;
- private int packetLengthStartPosition;
- private int packetLengthSizeInBytes;
- private int packetLengthOffset = 0;
-
- @Override
- protected Logger getLogger() {
- return LoggerFactory.getLogger(ReceiveAction.class);
- }
-
- public String getPacketLengthStartPosition() {
- return Integer.toString(packetLengthStartPosition);
- }
-
- public void setPacketLengthStartPosition(String packetLengthStartPosition) {
- this.packetLengthStartPosition = Integer.valueOf(packetLengthStartPosition);
- }
-
- public String getPacketLengthSizeInBytes() {
- return Integer.toString(packetLengthSizeInBytes);
- }
-
- public void setPacketLengthSizeInBytes(String packetLengthSizeInBytes) {
- this.packetLengthSizeInBytes = Integer.valueOf(packetLengthSizeInBytes);
- }
-
- public String getPacketLengthOffset() {
- return Integer.toString(packetLengthOffset);
- }
-
- public void setPacketLengthOffset(String packetLengthOffset) {
- this.packetLengthOffset = Integer.valueOf(packetLengthOffset);
- }
-
- public String getTimeout() {
- return Long.toString(timeout);
- }
-
- public void setTimeout(String timeout) {
- this.timeout = Long.valueOf(timeout);
- }
-
- @Override
- public void execute(ActionExecutionContext ctx) {
- getLogger().info(getStateName() + ": Receiving...");
-
- try {
- DataProcessor dp = getDaffodilDataProcessor(ctx);
- if(dp == null) {
- fireFailureEvent(ctx, "Couldn't initialize daffodil data processor.");
- return;
- }
-
- ProtocolIO protocolIO = getProtocolIo(ctx);
- byte[] data = protocolIO.receive();
-
- DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(data));
-
- // Remember when we started to receive.
- long startTime = System.currentTimeMillis();
-
- // Check if enough bytes are available to at least find out how big the full packet is.
- while(inputStream.available() < packetLengthStartPosition + packetLengthSizeInBytes) {
- waitWithTimeout(ctx, startTime, timeout);
- }
-
- // Read these length bytes and reset the input stream back to the start.
- inputStream.mark(packetLengthStartPosition + packetLengthSizeInBytes);
- // Jump to the start of the length data.
- inputStream.skip(packetLengthStartPosition);
-
- // Read the packet length.
- int packetLength;
- switch (packetLengthSizeInBytes) {
- case 1:
- packetLength = inputStream.readUnsignedByte();
- break;
- case 2:
- packetLength = inputStream.readUnsignedShort();
- break;
- default:
- fireFailureEvent(ctx, "Unsupported size for packet length: " + packetLengthSizeInBytes);
- return;
- }
- packetLength += packetLengthOffset;
-
- // Go back to the beginning of the packet.
- inputStream.reset();
-
- // Wait till the entire packet is available.
- while(inputStream.available() < packetLength) {
- waitWithTimeout(ctx, startTime, timeout);
- }
-
- byte[] packet = new byte[packetLength];
- if(inputStream.read(packet) != packetLength) {
- TriggerEvent event = new EventBuilder("failure", TriggerEvent.SIGNAL_EVENT).
- data("Couldn't read entire packet.").build();
- ctx.getInternalIOProcessor().addEvent(event);
- return;
- }
-
- // After having enough bytes available, process the current package.
- JDOMInfosetOutputter outputter = new JDOMInfosetOutputter();
- ParseResult byteMessage = dp.parse(
- new InputSourceDataInputStream(new ByteArrayInputStream(packet)), outputter);
- if (byteMessage.isError()) {
- logDiagnosticInformation(byteMessage);
- return;
- }
-
- // Get the resulting XML document from the parser.
- Document message = outputter.getResult();
-
- // Do any form of processing.
- processMessage(message, ctx);
- } catch (Exception e) {
- fireFailureEvent(ctx, e.getMessage());
- }
-
- getLogger().info("Received.");
- fireSuccessEvent(ctx);
- }
-
- protected abstract void processMessage(Document message, ActionExecutionContext ctx);
-
- String getRuleText(Document message, String xpathExpression) {
- // Get the namespace definitions from the input document.
- List<Namespace> namespaces = message.getRootElement().getNamespacesInScope();
-
- XPathFactory xPathFactory = XPathFactory.instance();
- XPathExpression<org.jdom2.Text> xpath = xPathFactory.compile(
- xpathExpression, Filters.textOnly(), null, namespaces);
- List<Text> result = xpath.evaluate(message);
- if((result == null) || result.isEmpty()) {
- getLogger().info("Couldn't find value for xpath expression: " + xpathExpression + " in document.");
- if(getLogger().isInfoEnabled()) {
- getLogger().info(new XMLOutputter().outputString(message));
- }
- return null;
- }
- return result.get(0).getTextNormalize();
- }
-
- private void waitWithTimeout(ActionExecutionContext ctx, long startTime, long timeout) {
- try {
- TimeUnit.MILLISECONDS.sleep(20);
- if(System.currentTimeMillis() - startTime > timeout) {
- fireFailureEvent(ctx, "Receive timed out.");
- }
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveExtractVerifyAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveExtractVerifyAction.java
deleted file mode 100644
index 08c27d8..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveExtractVerifyAction.java
+++ /dev/null
@@ -1,114 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.commons.scxml2.model.NodeListValue;
-import org.apache.commons.scxml2.model.NodeValue;
-import org.apache.commons.scxml2.model.ParsedValue;
-import org.jdom2.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class ReceiveExtractVerifyAction extends ReceiveAction {
-
- private final Map<String, String> valueVerificationRules;
- private final Map<String, String> contextVerificationRules;
- private final Map<String, String> extractionRules;
-
- public ReceiveExtractVerifyAction() {
- valueVerificationRules = new HashMap<>();
- contextVerificationRules = new HashMap<>();
- extractionRules = new HashMap<>();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void setParsedValue(ParsedValue parsedValue) {
- super.setParsedValue(parsedValue);
- if(parsedValue != null) {
- if(parsedValue instanceof NodeListValue) {
- List<Node> ruleList = (List<Node>) parsedValue.getValue();
- for (Node node : ruleList) {
- if(node instanceof Element) {
- parseElement((Element) node);
- }
- }
- } else if(parsedValue instanceof NodeValue) {
- parseElement((Element) parsedValue.getValue());
- }
- }
- }
-
- private void parseElement(Element ruleElement) {
- String expression = ruleElement.getAttribute("xpath-expression");
- if ("verification".equals(ruleElement.getTagName())) {
- if(ruleElement.hasAttribute("name")) {
- String name = ruleElement.getAttribute("name");
- contextVerificationRules.put(expression, name);
- } else if(ruleElement.hasAttribute("value")) {
- String value = ruleElement.getAttribute("value");
- valueVerificationRules.put(expression, value);
- }
- } else if ("extraction".equals(ruleElement.getTagName())) {
- String name = ruleElement.getAttribute("name");
- extractionRules.put(expression, name);
- } else {
- getLogger().error("unsupported rule type: " + ruleElement.getTagName());
- }
- }
-
-
- protected void processMessage(Document message, ActionExecutionContext ctx) {
- // First verify all verification conditions.
- for (Map.Entry<String, String> rule : contextVerificationRules.entrySet()) {
- Object reference = ctx.getGlobalContext().get(rule.getValue());
- verifyValue(message, rule.getKey(), reference);
- }
- for (Map.Entry<String, String> rule : valueVerificationRules.entrySet()) {
- Object reference = rule.getValue();
- verifyValue(message, rule.getKey(), reference);
- }
-
- // Then extract data from the document.
- for (Map.Entry<String, String> rule : extractionRules.entrySet()) {
- String current = getRuleText(message, rule.getKey());
- if(current == null) {
- throw new RuntimeException("Error extracting. Got null value");
- }
- ctx.getGlobalContext().set(rule.getValue(), current);
- }
- }
-
- private void verifyValue(Document message, String xpath, Object reference) {
- String current = getRuleText(message, xpath);
- if(current == null) {
- throw new RuntimeException("Error verifying. Expected: " + reference.toString() + " got null value");
- }
- if(!current.equals(reference)) {
- throw new RuntimeException("Error verifying. Expected: " + reference.toString() + " got: " + current);
- }
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveRequestAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveRequestAction.java
deleted file mode 100644
index 19187ab..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveRequestAction.java
+++ /dev/null
@@ -1,52 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.jdom2.Document;
-
-public class ReceiveRequestAction extends ReceiveAction {
-
- private String idExpression = null;
-
- public String getIdExpression() {
- return idExpression;
- }
-
- public void setIdExpression(String idExpression) {
- this.idExpression = idExpression;
- }
-
- @Override
- public void execute(ActionExecutionContext ctx) {
- if (idExpression == null) {
- fireFailureEvent(ctx, "'id' element not present");
- return;
- }
- super.execute(ctx);
- }
-
- @Override
- protected void processMessage(Document message, ActionExecutionContext ctx) {
- String requestId = getRuleText(message, idExpression);
-
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveResponseAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveResponseAction.java
deleted file mode 100644
index 69855df..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/ReceiveResponseAction.java
+++ /dev/null
@@ -1,65 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.plc4x.java.base.messages.PlcRequestContainer;
-import org.apache.plc4x.sandbox.java.dynamic.utils.RequestRegistry;
-import org.jdom2.Document;
-
-public abstract class ReceiveResponseAction extends ReceiveAction {
-
- private String idExpression = null;
-
- public String getIdExpression() {
- return idExpression;
- }
-
- public void setIdExpression(String idExpression) {
- this.idExpression = idExpression;
- }
-
- @Override
- public void execute(ActionExecutionContext ctx) {
- if(idExpression == null) {
- fireFailureEvent(ctx, "'id' element not present");
- return;
- }
- super.execute(ctx);
- }
-
- @Override
- protected void processMessage(Document message, ActionExecutionContext ctx) {
- // Get the responseId (which usually should match the corresponding request id.
- String requestId = getRuleText(message, idExpression);
-
- // Get access to any pre-registered containers.
- RequestRegistry requestRegistry = (RequestRegistry) ctx.getGlobalContext().get("requestRegistry");
- PlcRequestContainer container = requestRegistry.removeContainer(requestId);
-
- // If a container was found, do the processing of the response.
- if(container != null) {
- processResponse(message, ctx, container);
- }
- }
-
- protected abstract void processResponse(Document message, ActionExecutionContext ctx, PlcRequestContainer container);
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/SendAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/SendAction.java
deleted file mode 100644
index 54f36b3..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/SendAction.java
+++ /dev/null
@@ -1,103 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.commons.scxml2.model.ParsedValue;
-import org.apache.daffodil.japi.DataProcessor;
-import org.apache.daffodil.japi.UnparseResult;
-import org.apache.daffodil.japi.infoset.InfosetInputter;
-import org.apache.plc4x.sandbox.java.dynamic.io.ProtocolIO;
-import org.apache.plc4x.sandbox.java.dynamic.utils.JDOMTemplateInfosetInputter;
-import org.jdom2.Document;
-import org.jdom2.Element;
-import org.jdom2.input.DOMBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.nio.channels.Channels;
-import java.nio.channels.WritableByteChannel;
-
-public class SendAction extends BaseDaffodilAction {
-
- private Document messageTemplate;
-
- @Override
- protected Logger getLogger() {
- return LoggerFactory.getLogger(SendAction.class);
- }
-
- @Override
- public void setParsedValue(ParsedValue parsedValue) {
- super.setParsedValue(parsedValue);
-
- // Convert the W3C Dom implementation into JDom2.
- Element element = new DOMBuilder().build(
- (org.w3c.dom.Element) getParsedValue().getValue());
- messageTemplate = element.getDocument();
- }
-
- @Override
- public void execute(ActionExecutionContext ctx) {
- getLogger().info(getStateName() + ": Sending...");
-
- if(getParsedValue() != null) {
- if(getParsedValue().getType() == ParsedValue.ValueType.NODE) {
- try {
- // Do any form of processing.
- processMessage(messageTemplate, ctx);
-
- DataProcessor dp = getDaffodilDataProcessor(ctx);
- if(dp == null) {
- fireFailureEvent(ctx, "Couldn't initialize daffodil data processor.");
- return;
- }
- InfosetInputter inputter = new JDOMTemplateInfosetInputter(messageTemplate, ctx.getGlobalContext());
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- WritableByteChannel wbc = Channels.newChannel(outputStream);
- UnparseResult byteMessage = dp.unparse(inputter, wbc);
- if(byteMessage.isError()) {
- logDiagnosticInformation(byteMessage);
- return;
- }
- outputStream.flush();
-
- ProtocolIO protocolIO = getProtocolIo(ctx);
- protocolIO.send(outputStream.toByteArray());
- } catch(IOException e) {
- e.printStackTrace();
- }
- } else {
- fireFailureEvent(ctx, "type '" + getParsedValue().getType() + "' not supported");
- return;
- }
- }
-
- getLogger().info("Sent.");
- fireSuccessEvent(ctx);
- }
-
- protected void processMessage(Document message, ActionExecutionContext ctx) {
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/SendRequestAction.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/SendRequestAction.java
deleted file mode 100644
index 92f0f17..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/actions/SendRequestAction.java
+++ /dev/null
@@ -1,57 +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.sandbox.java.dynamic.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.plc4x.java.base.messages.PlcRequestContainer;
-import org.apache.plc4x.sandbox.java.dynamic.utils.RequestRegistry;
-import org.jdom2.Document;
-
-public class SendRequestAction extends SendAction {
-
- private String idExpression = null;
-
- public String getIdExpression() {
- return idExpression;
- }
-
- public void setIdExpression(String idExpression) {
- this.idExpression = idExpression;
- }
-
- @Override
- protected void processMessage(Document message, ActionExecutionContext ctx) {
- // Generate a new request and add that to the context.
- RequestRegistry requestRegistry = (RequestRegistry) ctx.getGlobalContext().get("requestRegistry");
- String requestId = requestRegistry.generateRequestId();
- ctx.getGlobalContext().set("requestId", requestId);
-
- // If a container is present, we want to respond to a call from outside the driver.
- // Register the container with the registry using the requestId as key.
- PlcRequestContainer container = (PlcRequestContainer) ctx.getGlobalContext().get("container");
- if(container != null) {
- requestRegistry.addContainer(requestId, container);
- }
-
- // Do the normal processing.
- super.processMessage(message, ctx);
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/connection/DynamicDriverConnectionBase.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/connection/DynamicDriverConnectionBase.java
deleted file mode 100644
index bb1ea8f..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/connection/DynamicDriverConnectionBase.java
+++ /dev/null
@@ -1,153 +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.sandbox.java.dynamic.connection;
-
-import org.apache.commons.scxml2.EventBuilder;
-import org.apache.commons.scxml2.SCXMLExecutor;
-import org.apache.commons.scxml2.TriggerEvent;
-import org.apache.commons.scxml2.env.SimpleDispatcher;
-import org.apache.commons.scxml2.env.SimpleErrorReporter;
-import org.apache.commons.scxml2.invoke.SimpleSCXMLInvoker;
-import org.apache.commons.scxml2.io.SCXMLReader;
-import org.apache.commons.scxml2.model.CustomAction;
-import org.apache.commons.scxml2.model.ModelException;
-import org.apache.commons.scxml2.model.SCXML;
-import org.apache.plc4x.java.api.PlcConnection;
-import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
-import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
-import org.apache.plc4x.java.base.connection.AbstractPlcConnection;
-import org.apache.plc4x.sandbox.java.dynamic.actions.*;
-
-import javax.xml.stream.XMLStreamException;
-import java.io.IOException;
-import java.util.*;
-
-public abstract class DynamicDriverConnectionBase extends AbstractPlcConnection implements PlcConnection {
-
- private String stateMachineURI;
- private String dataFormatURI;
- private SCXMLExecutor executor;
-
- protected DynamicDriverConnectionBase(String stateMachineURI, String dataFormatURI) {
- this.stateMachineURI = stateMachineURI;
- this.dataFormatURI = dataFormatURI;
- }
-
- private void init() throws PlcConnectionException {
- // Initialize our PLC4X specific actions.
- List<CustomAction> customActions = new LinkedList<>();
- customActions.add(
- new CustomAction("https://plc4x.apache.org/scxml-extension", "initContext", InitContextAction.class));
- customActions.add(
- new CustomAction("https://plc4x.apache.org/scxml-extension", "connect", ConnectAction.class));
- customActions.add(
- new CustomAction("https://plc4x.apache.org/scxml-extension", "send", SendAction.class));
- customActions.add(
- new CustomAction("https://plc4x.apache.org/scxml-extension", "receiveExtractVerify", ReceiveExtractVerifyAction.class));
- customActions.add(
- new CustomAction("https://plc4x.apache.org/scxml-extension", "sendRequest", SendRequestAction.class));
- customActions.addAll(getAdditionalCustomActions());
-
- try {
- // Initialize the state-machine with the definition from the protocol module.
- SCXML scxml = SCXMLReader.read(
- DynamicDriverConnectionBase.class.getClassLoader().getResource(stateMachineURI),
- new SCXMLReader.Configuration(null, null, customActions));
-
- // Create an executor for running the state-machine.
- executor = new SCXMLExecutor(null, new SimpleDispatcher(), new SimpleErrorReporter());
- executor.setStateMachine(scxml);
- executor.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);
- } catch (XMLStreamException | IOException | ModelException e) {
- throw new PlcConnectionException("Error initializing driver state-machine", e);
- }
- }
-
- protected SCXMLExecutor getExecutor() {
- return executor;
- }
-
- protected Collection<CustomAction> getAdditionalCustomActions() {
- return Collections.emptyList();
- }
-
- protected Map<String, Object> getAdditionalContextDataItems() {
- return Collections.emptyMap();
- }
-
- protected abstract String getConnectedStateName();
-
- protected abstract String getDisconnectTransitionName();
-
- @Override
- public void connect() throws PlcConnectionException {
- // Setup the driver.
- init();
-
- // Initialize the drivers state.
- Map<String, Object> context = new HashMap<>();
- context.put("protocolDaffodilSchema", dataFormatURI);
- getAdditionalContextDataItems().forEach(context::put);
-
- try {
- // Run the state-machine.
- executor.go(context);
- } catch (ModelException e) {
- throw new PlcConnectionException("Error initializing driver state-machine", e);
- }
- }
-
- @Override
- public boolean isConnected() {
- if(executor == null) {
- return false;
- }
- return executor.getStatus().isInState(getConnectedStateName());
- }
-
- @Override
- public void close() throws Exception {
- if(executor == null) {
- return;
- }
- executor.triggerEvent(new EventBuilder(getDisconnectTransitionName(), TriggerEvent.CALL_EVENT).build());
- }
-
- @Override
- public PlcConnectionMetadata getMetadata() {
- return new PlcConnectionMetadata() {
- @Override
- public boolean canRead() {
- return true;
- }
-
- @Override
- public boolean canWrite() {
- return false;
- }
-
- @Override
- public boolean canSubscribe() {
- return false;
- }
- };
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/exceptions/DynamicDriverException.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/exceptions/DynamicDriverException.java
deleted file mode 100644
index c7bcb5c..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/exceptions/DynamicDriverException.java
+++ /dev/null
@@ -1,34 +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.sandbox.java.dynamic.exceptions;
-
-import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
-
-public class DynamicDriverException extends PlcProtocolException {
-
- public DynamicDriverException(String message) {
- super(message);
- }
-
- public DynamicDriverException(String message, Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/ProtocolIO.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/ProtocolIO.java
deleted file mode 100644
index ba810b8..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/ProtocolIO.java
+++ /dev/null
@@ -1,28 +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.sandbox.java.dynamic.io;
-
-public interface ProtocolIO {
-
- void send(byte[] data);
-
- byte[] receive();
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/TcpProtocolIO.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/TcpProtocolIO.java
deleted file mode 100644
index 2366986..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/TcpProtocolIO.java
+++ /dev/null
@@ -1,49 +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.sandbox.java.dynamic.io;
-
-import org.apache.plc4x.sandbox.java.dynamic.exceptions.DynamicDriverException;
-
-import java.io.IOException;
-import java.net.Socket;
-
-public class TcpProtocolIO implements ProtocolIO {
-
- private Socket socket;
-
- public TcpProtocolIO(String host, int port) throws DynamicDriverException {
- try {
- this.socket = new Socket(host, port);
- } catch (IOException e) {
- throw new DynamicDriverException("Error creating TCP Socket", e);
- }
- }
-
- @Override
- public void send(byte[] data) {
-
- }
-
- @Override
- public byte[] receive() {
- return new byte[0];
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/UdpProtocolIO.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/UdpProtocolIO.java
deleted file mode 100644
index 2cffa16..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/io/UdpProtocolIO.java
+++ /dev/null
@@ -1,50 +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.sandbox.java.dynamic.io;
-
-import org.apache.plc4x.sandbox.java.dynamic.exceptions.DynamicDriverException;
-
-import java.net.DatagramSocket;
-import java.net.SocketException;
-
-public class UdpProtocolIO implements ProtocolIO {
-
- private DatagramSocket socket;
-
- public UdpProtocolIO(String host, int port) throws DynamicDriverException {
- try {
- socket = new DatagramSocket(port);
- //socket.receive();
- } catch (SocketException e) {
- throw new DynamicDriverException("Error creating UDP Socket", e);
- }
- }
-
- @Override
- public void send(byte[] data) {
-
- }
-
- @Override
- public byte[] receive() {
- return new byte[0];
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/utils/RequestRegistry.java b/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/utils/RequestRegistry.java
deleted file mode 100644
index 9176b94..0000000
--- a/sandbox/dynamic-driver-base/src/main/java/org/apache/plc4x/sandbox/java/dynamic/utils/RequestRegistry.java
+++ /dev/null
@@ -1,66 +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.sandbox.java.dynamic.utils;
-
-import org.apache.commons.scxml2.env.AbstractSCXMLListener;
-import org.apache.commons.scxml2.model.EnterableState;
-import org.apache.plc4x.java.base.messages.PlcRequestContainer;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-public class RequestRegistry extends AbstractSCXMLListener {
-
- private final long maxValue;
- private AtomicLong idGenerator = new AtomicLong(0);
-
- // TODO: Add some timeout stuff here ...
- private ConcurrentHashMap<String, PlcRequestContainer> requestContainers;
-
- public RequestRegistry(long maxValue) {
- this.maxValue = maxValue;
- requestContainers = new ConcurrentHashMap<>();
- }
-
- public String generateRequestId() {
- // If we reached the max value, reset to 0.
- if(idGenerator.get() == maxValue) {
- idGenerator.set(0);
- }
- return Long.toString(idGenerator.getAndIncrement());
- }
-
- public void addContainer(String requestId, PlcRequestContainer container) {
- requestContainers.put(requestId, container);
- }
-
- public PlcRequestContainer removeContainer(String requestId) {
- if(requestId != null) {
- return requestContainers.remove(requestId);
- }
- return null;
- }
-
- @Override
- public void onExit(EnterableState state) {
- super.onExit(state);
- }
-
-}
diff --git a/sandbox/dynamic-driver-base/src/main/scala/org/apache/plc4x/sandbox/java/dynamic/utils/JDOMTemplateInfosetInputter.scala b/sandbox/dynamic-driver-base/src/main/scala/org/apache/plc4x/sandbox/java/dynamic/utils/JDOMTemplateInfosetInputter.scala
deleted file mode 100644
index 1a1cb3f..0000000
--- a/sandbox/dynamic-driver-base/src/main/scala/org/apache/plc4x/sandbox/java/dynamic/utils/JDOMTemplateInfosetInputter.scala
+++ /dev/null
@@ -1,45 +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.sandbox.java.dynamic.utils
-
-import org.apache.commons.scxml2.Context
-import org.apache.commons.scxml2.env.jexl.JexlEvaluator
-import org.apache.daffodil.dpath.NodeInfo
-import org.apache.daffodil.infoset.JDOMInfosetInputter
-import org.apache.daffodil.japi.infoset.InfosetInputterProxy
-import org.jdom2.Document
-
-class JDOMTemplateInfosetInputter(document: Document, context: Context) extends InfosetInputterProxy {
-
- override val infosetInputter = new JDOMInfosetInputter(document)
-
- val evaluator = new JexlEvaluator()
-
- override def getSimpleText(primType: NodeInfo.Kind): String = {
- val value = super.getSimpleText(primType)
- if(value.startsWith("${") && value.endsWith("}")) {
- val varName = value.substring(2, value.length - 1)
- val varValue = evaluator.eval(context, varName)
- return varValue.toString
- }
- value
- }
-
-}
diff --git a/sandbox/dynamic-driver-knxnet-ip/pom.xml b/sandbox/dynamic-driver-knxnet-ip/pom.xml
deleted file mode 100644
index b2dccb2..0000000
--- a/sandbox/dynamic-driver-knxnet-ip/pom.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<?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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.sandbox</groupId>
- <artifactId>plc4x-sandbox</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4j-dynamic-driver-knxnetip</artifactId>
- <name>Sandbox: Dynamic-Driver: KNXNet/IP</name>
- <description>Implementation of a KNXNet/IP driver based on definitions provided by DFDL and SCXML.</description>
-
- <build>
- <plugins>
- <!--plugin>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-maven-plugin</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <executions>
- <execution>
- <id>generate-driver</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate-driver</goal>
- </goals>
- <configuration>
- <dfdlSchema>test/protocol.dfdl.xsd</dfdlSchema>
- </configuration>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-protocols-knxnet-ip</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- </plugin-->
-
- <!--plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <usedDependencies combine.children="append">
- <usedDependency>org.apache.plc4x:plc4x-protocols-knxnet-ip</usedDependency>
- <usedDependency>org.apache.commons:commons-jexl3</usedDependency>
- <usedDependency>org.slf4j:slf4j-simple</usedDependency>
- </usedDependencies>
- </configuration>
- </plugin-->
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-api</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-protocol-driver-base</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.plc4x.sandbox</groupId>
- <artifactId>plc4j-dynamic-driver-base</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-scxml2</artifactId>
- </dependency>
-
- <!--dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl3</artifactId>
- </dependency-->
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
-
- <!--dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency-->
-
- <!--dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-protocols-knxnet-ip</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency-->
- </dependencies>
-
-</project>
\ No newline at end of file
diff --git a/sandbox/dynamic-driver-knxnet-ip/src/main/java/org/apache/plc4x/sandbox/java/dynamic/knxnetip/DynamicKnxNetIpDriver.java b/sandbox/dynamic-driver-knxnet-ip/src/main/java/org/apache/plc4x/sandbox/java/dynamic/knxnetip/DynamicKnxNetIpDriver.java
deleted file mode 100644
index b769dd0..0000000
--- a/sandbox/dynamic-driver-knxnet-ip/src/main/java/org/apache/plc4x/sandbox/java/dynamic/knxnetip/DynamicKnxNetIpDriver.java
+++ /dev/null
@@ -1,79 +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.sandbox.java.dynamic.knxnetip;
-
-import org.apache.plc4x.java.api.PlcConnection;
-import org.apache.plc4x.java.api.authentication.PlcAuthentication;
-import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
-import org.apache.plc4x.java.spi.PlcDriver;
-import org.apache.plc4x.sandbox.java.dynamic.knxnetip.connection.DynamicKnxNetIpConnection;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class DynamicKnxNetIpDriver implements PlcDriver {
-
- private static final Pattern KNXNETIP_URI_PATTERN = Pattern.compile("^knxnetip://(?<host>.*)(?<params>\\?.*)?");
-
- @Override
- public String getProtocolCode() {
- return "knxnetip";
- }
-
- @Override
- public String getProtocolName() {
- return "KNXNet/IP (Dynamic)";
- }
-
- @Override
- public PlcConnection connect(String url) throws PlcConnectionException {
- Matcher matcher = KNXNETIP_URI_PATTERN.matcher(url);
- if (!matcher.matches()) {
- throw new PlcConnectionException(
- "Connection url doesn't match the format 'knxnetip://{host|ip}'");
- }
- String host = matcher.group("host");
-
- String params = matcher.group("params") != null ? matcher.group("params").substring(1) : null;
-
- try {
- InetAddress serverInetAddress = InetAddress.getByName(host);
- return new DynamicKnxNetIpConnection(serverInetAddress, params);
- } catch (UnknownHostException e) {
- throw new PlcConnectionException("Error parsing address", e);
- } catch (Exception e) {
- throw new PlcConnectionException("Error connecting to host", e);
- }
- }
-
- @Override
- public PlcConnection connect(String url, PlcAuthentication authentication) throws PlcConnectionException {
- throw new PlcConnectionException("KNXNet/IP connections don't support authentication.");
- }
-
- public static void main(String[] args) throws Exception {
- PlcConnection connection = new DynamicKnxNetIpDriver().connect("knxnetip://192.168.42.11");
- connection.connect();
- connection.isConnected();
- }
-
-}
diff --git a/sandbox/dynamic-driver-knxnet-ip/src/main/java/org/apache/plc4x/sandbox/java/dynamic/knxnetip/connection/DynamicKnxNetIpConnection.java b/sandbox/dynamic-driver-knxnet-ip/src/main/java/org/apache/plc4x/sandbox/java/dynamic/knxnetip/connection/DynamicKnxNetIpConnection.java
deleted file mode 100644
index 1f5cfed..0000000
--- a/sandbox/dynamic-driver-knxnet-ip/src/main/java/org/apache/plc4x/sandbox/java/dynamic/knxnetip/connection/DynamicKnxNetIpConnection.java
+++ /dev/null
@@ -1,134 +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.sandbox.java.dynamic.knxnetip.connection;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.scxml2.EventBuilder;
-import org.apache.commons.scxml2.TriggerEvent;
-import org.apache.commons.scxml2.model.ModelException;
-import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
-import org.apache.plc4x.java.api.messages.PlcReadRequest;
-import org.apache.plc4x.java.api.messages.PlcReadResponse;
-import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
-import org.apache.plc4x.java.base.messages.InternalPlcReadRequest;
-import org.apache.plc4x.java.base.messages.InternalPlcReadResponse;
-import org.apache.plc4x.java.base.messages.PlcReader;
-import org.apache.plc4x.java.base.messages.PlcRequestContainer;
-import org.apache.plc4x.sandbox.java.dynamic.connection.DynamicDriverConnectionBase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
-public class DynamicKnxNetIpConnection extends DynamicDriverConnectionBase implements PlcReader {
-
- private static final Logger logger = LoggerFactory.getLogger(DynamicKnxNetIpConnection.class);
-
- private final InetAddress address;
-
- public DynamicKnxNetIpConnection(InetAddress address, String params) {
- super("org/apache/plc4x/protocols/knxnetip/protocol.scxml.xml",
- "org/apache/plc4x/protocols/knxnetip/protocol.dfdl.xsd");
-
- this.address = address;
-
- if (!StringUtils.isEmpty(params)) {
- for (String param : params.split("&")) {
- String[] paramElements = param.split("=");
- String paramName = paramElements[0];
- if (paramElements.length == 2) {
- String paramValue = paramElements[1];
- switch (paramName) {
- default:
- logger.debug("Unknown parameter {} with value {}", paramName, paramValue);
- }
- } else {
- logger.debug("Unknown no-value parameter {}", paramName);
- }
- }
- }
- }
-
- @Override
- protected String getConnectedStateName() {
- return "connected";
- }
-
- @Override
- protected String getDisconnectTransitionName() {
- return "disconnect";
- }
-
- /*@Override
- protected Collection<CustomAction> getAdditionalCustomActions() {
- return Arrays.asList(
- new CustomAction("https://plc4x.apache.org/scxml-extension", "S7DecodeArticleNumber",
- S7DecodeArticleNumber.class),
- new CustomAction("https://plc4x.apache.org/scxml-extension", "S7DecodeReadResponse",
- S7DecodeReadResponseAction.class),
- new CustomAction("https://plc4x.apache.org/scxml-extension", "S7DecodeWriteResponse",
- S7DecodeWriteResponseAction.class)
- );
- }*/
-
- @Override
- protected Map<String, Object> getAdditionalContextDataItems() {
- Map<String, Object> dataItems = new HashMap<>();
-
- /*<sc:data id="clientIpAddress"/>
- <sc:data id="clientUdpPort"/>*/
-
- dataItems.put("serverIpAddress", address.getHostAddress());
- dataItems.put("serverPort", "102");
-
- return dataItems;
- }
-
- @Override
- public PlcConnectionMetadata getMetadata() {
- return super.getMetadata();
- }
-
- /*@Override
- public PlcReadRequest.Builder readRequestBuilder() {
- return new DefaultPlcReadRequest.Builder(this, new S7PlcFieldHandler());
- }*/
-
- @Override
- public CompletableFuture<PlcReadResponse> read(PlcReadRequest readRequest) {
- InternalPlcReadRequest internalReadRequest = checkInternal(readRequest, InternalPlcReadRequest.class);
- CompletableFuture<InternalPlcReadResponse> future = new CompletableFuture<>();
- PlcRequestContainer<InternalPlcReadRequest, InternalPlcReadResponse> container =
- new PlcRequestContainer<>(internalReadRequest, future);
-
- try {
- getExecutor().triggerEvent(
- new EventBuilder("read", TriggerEvent.CALL_EVENT).data(container).build());
- } catch (ModelException e) {
- throw new PlcRuntimeException("Error reading.", e);
- }
-
- return future.thenApply(PlcReadResponse.class::cast);
- }
-
-}
diff --git a/sandbox/dynamic-driver-knxnet-ip/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver b/sandbox/dynamic-driver-knxnet-ip/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
deleted file mode 100644
index 30b0684..0000000
--- a/sandbox/dynamic-driver-knxnet-ip/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
+++ /dev/null
@@ -1,76 +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.
-#
-
-#
-# 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.
-#
-
-#
-# 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.
-#
-
-#
-# 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.
-#
-org.apache.plc4x.sandbox.java.dynamic.knxnetip.DynamicKnxNetIpDriver
diff --git a/sandbox/dynamic-driver-s7/pom.xml b/sandbox/dynamic-driver-s7/pom.xml
deleted file mode 100644
index 13a9024..0000000
--- a/sandbox/dynamic-driver-s7/pom.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<?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.
- -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x.sandbox</groupId>
- <artifactId>plc4x-sandbox</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4j-dynamic-driver-s7</artifactId>
- <name>Sandbox: Dynamic-Driver: S7</name>
- <description>Implementation of a S7 driver based on definitions provided by DFDL and SCXML.</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-api</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4j-protocol-driver-base</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.plc4x.sandbox</groupId>
- <artifactId>plc4j-dynamic-driver-base</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-scxml2</artifactId>
- </dependency>
-
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.3.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom2</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-protocols-s7</artifactId>
- <version>0.5.0-SNAPSHOT</version>
- <scope>runtime</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <configuration>
- <usedDependencies combine.children="append">
- <usedDependency>org.apache.plc4x:plc4x-protocols-s7</usedDependency>
- <usedDependency>org.apache.commons:commons-jexl3</usedDependency>
- <usedDependency>org.slf4j:slf4j-simple</usedDependency>
- </usedDependencies>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/DynamicS7Driver.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/DynamicS7Driver.java
deleted file mode 100644
index 3b1cadc..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/DynamicS7Driver.java
+++ /dev/null
@@ -1,80 +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.sandbox.java.dynamic.s7;
-
-import org.apache.plc4x.java.api.PlcConnection;
-import org.apache.plc4x.java.api.authentication.PlcAuthentication;
-import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
-import org.apache.plc4x.java.spi.PlcDriver;
-import org.apache.plc4x.sandbox.java.dynamic.s7.connection.DynamicS7Connection;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class DynamicS7Driver implements PlcDriver {
-
- private static final Pattern S7_URI_PATTERN = Pattern.compile("^s7d://(?<host>.*)/(?<rack>\\d{1,4})/(?<slot>\\d{1,4})(?<params>\\?.*)?");
-
- @Override
- public String getProtocolCode() {
- return "s7d";
- }
-
- @Override
- public String getProtocolName() {
- return "Siemens S7 (Basic - Dynamic)";
- }
-
- @Override
- public PlcConnection connect(String url) throws PlcConnectionException {
- Matcher matcher = S7_URI_PATTERN.matcher(url);
- if (!matcher.matches()) {
- throw new PlcConnectionException(
- "Connection url doesn't match the format 's7://{host|ip}/{rack}/{slot}'");
- }
- String host = matcher.group("host");
-
- int rack = Integer.parseInt(matcher.group("rack"));
- int slot = Integer.parseInt(matcher.group("slot"));
- String params = matcher.group("params") != null ? matcher.group("params").substring(1) : null;
-
- try {
- InetAddress serverInetAddress = InetAddress.getByName(host);
- return new DynamicS7Connection(serverInetAddress, rack, slot, params);
- } catch (UnknownHostException e) {
- throw new PlcConnectionException("Error parsing address", e);
- } catch (Exception e) {
- throw new PlcConnectionException("Error connecting to host", e);
- }
- }
-
- @Override
- public PlcConnection connect(String url, PlcAuthentication authentication) throws PlcConnectionException {
- throw new PlcConnectionException("Basic S7 connections don't support authentication.");
- }
-
- public static void main(String[] args) throws Exception {
- PlcConnection connection = new DynamicS7Driver().connect("s7://10.10.64.20/1/1");
- connection.isConnected();
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeArticleNumber.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeArticleNumber.java
deleted file mode 100644
index 8ced6eb..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeArticleNumber.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.sandbox.java.dynamic.s7.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.commons.scxml2.model.ActionExecutionError;
-import org.apache.plc4x.sandbox.java.dynamic.actions.BasePlc4xAction;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class S7DecodeArticleNumber extends BasePlc4xAction {
-
- private String articleNumberParameterName;
- private String plcTypeParameterName;
-
- public String getArticleNumberParameterName() {
- return articleNumberParameterName;
- }
-
- public void setArticleNumberParameterName(String articleNumberParameterName) {
- this.articleNumberParameterName = articleNumberParameterName;
- }
-
- public String getPlcTypeParameterName() {
- return plcTypeParameterName;
- }
-
- public void setPlcTypeParameterName(String plcTypeParameterName) {
- this.plcTypeParameterName = plcTypeParameterName;
- }
-
- @Override
- protected Logger getLogger() {
- return LoggerFactory.getLogger(S7DecodeArticleNumber.class);
- }
-
- @Override
- public void execute(ActionExecutionContext ctx) throws ActionExecutionError {
- String articleNumber = ctx.getGlobalContext().get(articleNumberParameterName).toString();
- if(articleNumber == null) {
- fireFailureEvent(ctx, "Couldn't find article number.");
- return;
- }
-
- String plcType = lookupControllerType(articleNumber);
- if(plcType == null) {
- fireFailureEvent(ctx, "Unknown PLC type for article number: " + articleNumber);
- }
-
- ctx.getGlobalContext().set(plcTypeParameterName, plcType);
- fireSuccessEvent(ctx);
- }
-
- private String lookupControllerType(String articleNumber) {
- if(!articleNumber.startsWith("6ES7 ")) {
- return null;
- }
-
- String model = articleNumber.substring(articleNumber.indexOf(' ') + 1, articleNumber.indexOf(' ') + 2);
- switch (model) {
- case "2":
- return "S7-1200";
- case "5":
- return "S7-1500";
- case "3":
- return "S7-300";
- case "4":
- return "S7-400";
- default:
- return null;
- }
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeReadResponseAction.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeReadResponseAction.java
deleted file mode 100644
index 1b21485..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeReadResponseAction.java
+++ /dev/null
@@ -1,315 +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.sandbox.java.dynamic.s7.actions;
-
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
-import org.apache.plc4x.java.api.messages.PlcReadResponse;
-import org.apache.plc4x.java.api.types.PlcResponseCode;
-import org.apache.plc4x.java.base.messages.DefaultPlcReadResponse;
-import org.apache.plc4x.java.base.messages.InternalPlcReadRequest;
-import org.apache.plc4x.java.base.messages.PlcRequestContainer;
-import org.apache.plc4x.java.base.messages.items.*;
-import org.apache.plc4x.sandbox.java.dynamic.actions.ReceiveResponseAction;
-import org.apache.plc4x.sandbox.java.dynamic.s7.types.DataTransportErrorCode;
-import org.apache.plc4x.sandbox.java.dynamic.s7.utils.S7Field;
-import org.jdom2.Document;
-import org.jdom2.Element;
-import org.jdom2.Namespace;
-import org.jdom2.filter.Filters;
-import org.jdom2.xpath.XPathExpression;
-import org.jdom2.xpath.XPathFactory;
-
-import javax.xml.bind.DatatypeConverter;
-import java.math.BigInteger;
-import java.nio.ByteBuffer;
-import java.util.*;
-
-public class S7DecodeReadResponseAction extends ReceiveResponseAction {
-
- @Override
- protected void processResponse(Document message, ActionExecutionContext ctx, PlcRequestContainer container) {
- InternalPlcReadRequest readRequest = (InternalPlcReadRequest) container.getRequest();
- LinkedHashSet<String> fieldNames = readRequest.getFieldNames();
-
- List<Namespace> namespaces = message.getRootElement().getNamespacesInScope();
- XPathFactory xPathFactory = XPathFactory.instance();
- XPathExpression<Element> xpath = xPathFactory.compile(
- "/s7:TpktMessage/userData/userData/s7:S7ResponseMessage/payloads/payload/s7:S7ResponsePayloadReadVar/item", Filters.element(), null, namespaces);
- List<Element> items = xpath.evaluate(message);
-
- // If the sizes don't match, something is wrong.
- if(items.size() != fieldNames.size()) {
- container.getResponseFuture().completeExceptionally(
- new PlcProtocolException("Response item size doesn't match request item size."));
- return;
- }
-
- Map<String, Pair<PlcResponseCode, BaseDefaultFieldItem>> responseItems = new HashMap<>(items.size());
- int i = 0;
- for (String fieldName : fieldNames) {
- S7Field field = (S7Field) readRequest.getField(fieldName);
-
- Element item = items.get(i);
- String returnCode = item.getChild("returnCode").getTextTrim();
- byte returnCodeValue = (byte) (Short.valueOf(returnCode) & 0xFF);
- PlcResponseCode responseCode = null;
- BaseDefaultFieldItem fieldItem = null;
- switch(DataTransportErrorCode.valueOf(returnCodeValue)) {
- case RESERVED:
- responseCode = PlcResponseCode.INTERNAL_ERROR;
- break;
- case ACCESS_DENIED:
- responseCode = PlcResponseCode.ACCESS_DENIED;
- break;
- case DATA_TYPE_NOT_SUPPORTED:
- responseCode = PlcResponseCode.INVALID_DATATYPE;
- break;
- case INVALID_ADDRESS:
- responseCode = PlcResponseCode.INVALID_ADDRESS;
- break;
- case NOT_FOUND:
- responseCode = PlcResponseCode.NOT_FOUND;
- break;
- case OK: {
- responseCode = PlcResponseCode.OK;
- // Convert the hex encoded payload into a real byte array.
- byte[] data = DatatypeConverter.parseHexBinary(item.getChild("data").getTextTrim());
-
- // Depending on the field type in the request, interpret the data in the response accordingly.
- switch (field.getDataType()) {
- case BOOL: {
- BitSet bits = BitSet.valueOf(data);
- Boolean[] values = new Boolean[field.getNumElements()];
- for (int bitNr = 0; bitNr < field.getNumElements(); bitNr++) {
- values[bitNr] = bits.get(bitNr);
- }
- fieldItem = new DefaultBooleanFieldItem(values);
- break;
- }
- // -----------------------------------------
- // Bit strings
- // In Tia and Step7 these types are marked as bit-strings
- // which is a sequence of bits. Therefore the result will
- // have more items than the request requested.
- // -----------------------------------------
- case BYTE: {
- BitSet bits = BitSet.valueOf(data);
- Boolean[] values = new Boolean[field.getNumElements() * 8];
- for (int bitNr = 0; bitNr < field.getNumElements() * 8; bitNr++) {
- values[bitNr] = bits.get(bitNr);
- }
- fieldItem = new DefaultBooleanFieldItem(values);
- break;
- }
- case WORD: {
- BitSet bits = BitSet.valueOf(data);
- Boolean[] values = new Boolean[field.getNumElements() * 16];
- for (int bitNr = 0; bitNr < field.getNumElements() * 16; bitNr++) {
- values[bitNr] = bits.get(bitNr);
- }
- fieldItem = new DefaultBooleanFieldItem(values);
- break;
- }
- case DWORD: {
- BitSet bits = BitSet.valueOf(data);
- Boolean[] values = new Boolean[field.getNumElements() * 32];
- for (int bitNr = 0; bitNr < field.getNumElements() * 32; bitNr++) {
- values[bitNr] = bits.get(bitNr);
- }
- fieldItem = new DefaultBooleanFieldItem(values);
- break;
- }
- case LWORD: {
- BitSet bits = BitSet.valueOf(data);
- Boolean[] values = new Boolean[field.getNumElements() * 64];
- for (int bitNr = 0; bitNr < field.getNumElements() * 64; bitNr++) {
- values[bitNr] = bits.get(bitNr);
- }
- fieldItem = new DefaultBooleanFieldItem(values);
- break;
- }
-
- // -----------------------------------------
- // Integers
- // -----------------------------------------
- // (Signed) Small Int (8 bit)
- case SINT: {
- Byte[] values = new Byte[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = data[valueNr];
- }
- fieldItem = new DefaultByteFieldItem(values);
- break;
- }
- // Unsigned Small Int (8 bit)
- case USINT: {
- Short[] values = new Short[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = (short) (data[valueNr] & 0xff);
- }
- fieldItem = new DefaultShortFieldItem(values);
- break;
- }
- // Signed Int (16 bit)
- case INT: {
- ByteBuffer buffer = ByteBuffer.wrap(data);
- Short[] values = new Short[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = buffer.getShort();
- }
- fieldItem = new DefaultShortFieldItem(values);
- break;
- }
- // Unsigned Int (16 bit)
- case UINT: {
- ByteBuffer buffer = ByteBuffer.wrap(data);
- Integer[] values = new Integer[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = (buffer.getShort() & 0xFFFF);
- }
- fieldItem = new DefaultIntegerFieldItem(values);
- break;
- }
- // Double Precision Int (32 bit)
- case DINT: {
- ByteBuffer buffer = ByteBuffer.wrap(data);
- Integer[] values = new Integer[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = buffer.getInt();
- }
- fieldItem = new DefaultIntegerFieldItem(values);
- break;
- }
- // Unsigned Double Precision Int (32 bit)
- case UDINT: {
- ByteBuffer buffer = ByteBuffer.wrap(data);
- Long[] values = new Long[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = (buffer.getInt() & 0xFFFFFFFFL);
- }
- fieldItem = new DefaultLongFieldItem(values);
- break;
- }
- // Quadrupal Precision Int (64 bit)
- case LINT: {
- ByteBuffer buffer = ByteBuffer.wrap(data);
- Long[] values = new Long[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = buffer.getLong();
- }
- fieldItem = new DefaultLongFieldItem(values);
- break;
- }
- // Unsigned Quadrupal Precision Int (64 bit)
- case ULINT: {
- BigInteger[] values = new BigInteger[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- byte[] biBytes = new byte[]{data[valueNr * 8], data[(valueNr * 8) + 1],
- data[(valueNr * 8) + 2], data[(valueNr * 8) + 3], data[(valueNr * 8) + 4],
- data[(valueNr * 8) + 5], data[(valueNr * 8) + 6], data[(valueNr * 8) + 7]};
- values[valueNr] = new BigInteger(biBytes);
- }
- fieldItem = new DefaultBigIntegerFieldItem(values);
- break;
- }
-
- // -----------------------------------------
- // Reals
- // -----------------------------------------
- // (32 bit)
- case REAL: {
- ByteBuffer buffer = ByteBuffer.wrap(data);
- Float[] values = new Float[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = buffer.getFloat();
- }
- fieldItem = new DefaultFloatFieldItem(values);
- break;
- }
- // (64 bit)
- case LREAL: {
- ByteBuffer buffer = ByteBuffer.wrap(data);
- Double[] values = new Double[field.getNumElements()];
- for (int valueNr = 0; valueNr < field.getNumElements(); valueNr++) {
- values[valueNr] = buffer.getDouble();
- }
- fieldItem = new DefaultDoubleFieldItem(values);
- break;
- }
-
- // -----------------------------------------
- // Durations
- // -----------------------------------------
- // IEC time
- case TIME:
- break;
- case LTIME:
- break;
-
- // -----------------------------------------
- // Date
- // -----------------------------------------
- // IEC date (yyyy-m-d)
- case DATE:
- break;
-
- // -----------------------------------------
- // Time of day
- // -----------------------------------------
- // Time (hh:mm:ss.S)
- case TIME_OF_DAY:
- break;
-
- // -----------------------------------------
- // Date and time of day
- // -----------------------------------------
- case DATE_AND_TIME:
- break;
-
- // -----------------------------------------
- // ASCII Strings
- // -----------------------------------------
- // Single-byte character
- case CHAR:
- break;
- // Double-byte character
- case WCHAR:
- break;
- // Variable-length single-byte character string
- case STRING:
- break;
- // Variable-length double-byte character string
- case WSTRING:
- break;
- }
- }
- }
- responseItems.put(fieldName, new ImmutablePair<>(responseCode, fieldItem));
- i++;
- }
-
- PlcReadResponse response = new DefaultPlcReadResponse(readRequest, responseItems);
- container.getResponseFuture().complete(response);
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeWriteResponseAction.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeWriteResponseAction.java
deleted file mode 100644
index 868984b..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/actions/S7DecodeWriteResponseAction.java
+++ /dev/null
@@ -1,34 +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.sandbox.java.dynamic.s7.actions;
-
-import org.apache.commons.scxml2.ActionExecutionContext;
-import org.apache.plc4x.java.base.messages.PlcRequestContainer;
-import org.apache.plc4x.sandbox.java.dynamic.actions.ReceiveResponseAction;
-import org.jdom2.Document;
-
-public class S7DecodeWriteResponseAction extends ReceiveResponseAction {
-
- @Override
- protected void processResponse(Document message, ActionExecutionContext ctx, PlcRequestContainer container) {
-
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/connection/DynamicS7Connection.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/connection/DynamicS7Connection.java
deleted file mode 100644
index 2138358..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/connection/DynamicS7Connection.java
+++ /dev/null
@@ -1,186 +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.sandbox.java.dynamic.s7.connection;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.scxml2.EventBuilder;
-import org.apache.commons.scxml2.TriggerEvent;
-import org.apache.commons.scxml2.model.CustomAction;
-import org.apache.commons.scxml2.model.ModelException;
-import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
-import org.apache.plc4x.java.api.messages.PlcReadRequest;
-import org.apache.plc4x.java.api.messages.PlcReadResponse;
-import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
-import org.apache.plc4x.java.base.messages.*;
-import org.apache.plc4x.sandbox.java.dynamic.connection.DynamicDriverConnectionBase;
-import org.apache.plc4x.sandbox.java.dynamic.s7.actions.S7DecodeArticleNumber;
-import org.apache.plc4x.sandbox.java.dynamic.s7.actions.S7DecodeReadResponseAction;
-import org.apache.plc4x.sandbox.java.dynamic.s7.actions.S7DecodeWriteResponseAction;
-import org.apache.plc4x.sandbox.java.dynamic.s7.utils.S7PlcFieldHandler;
-import org.apache.plc4x.sandbox.java.dynamic.s7.utils.S7TsapIdEncoder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.net.InetAddress;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
-public class DynamicS7Connection extends DynamicDriverConnectionBase implements PlcReader {
-
- private static final Logger logger = LoggerFactory.getLogger(DynamicS7Connection.class);
-
- private final InetAddress address;
- private final short calledTsapId;
- private final short callingTsapId;
-
- private short paramPduSize;
- private short paramMaxAmqCaller;
- private short paramMaxAmqCallee;
- private String paramControllerType;
-
- public DynamicS7Connection(InetAddress address, int rack, int slot, String params) {
- super("org/apache/plc4x/protocols/s7/protocol.scxml.xml",
- "org/apache/plc4x/protocols/s7/protocol.dfdl.xsd");
-
- this.address = address;
- this.calledTsapId = S7TsapIdEncoder.encodeS7TsapId((byte) 0x02, 0, 0);
- this.callingTsapId = S7TsapIdEncoder.encodeS7TsapId((byte) 0x01, rack, slot);
-
- short curParamPduSize = 1024;
- short curParamMaxAmqCaller = 8;
- short curParamMaxAmqCallee = 8;
- String curParamControllerType = null;
-
- if (!StringUtils.isEmpty(params)) {
- for (String param : params.split("&")) {
- String[] paramElements = param.split("=");
- String paramName = paramElements[0];
- if (paramElements.length == 2) {
- String paramValue = paramElements[1];
- switch (paramName) {
- case "pdu-size":
- curParamPduSize = Short.parseShort(paramValue);
- break;
- case "max-amq-caller":
- curParamMaxAmqCaller = Short.parseShort(paramValue);
- break;
- case "max-amq-callee":
- curParamMaxAmqCallee = Short.parseShort(paramValue);
- break;
- case "controller-type":
- curParamControllerType = paramValue;
- break;
- default:
- logger.debug("Unknown parameter {} with value {}", paramName, paramValue);
- }
- } else {
- logger.debug("Unknown no-value parameter {}", paramName);
- }
- }
- }
-
- // It seems that the LOGO devices are a little picky about the pdu-size.
- // Instead of handling this out, they just hang up without any error message.
- // So in case of a LOGO controller, set this to a known working value.
- if((curParamControllerType != null) && curParamControllerType.equalsIgnoreCase("logo") && curParamPduSize == 1024) {
- curParamPduSize = 480;
- }
-
- // IsoTP uses pre defined sizes. Find the smallest box,
- // that would be able to contain the requested pdu size.
- this.paramPduSize = curParamPduSize;
- this.paramMaxAmqCaller = curParamMaxAmqCaller;
- this.paramMaxAmqCallee = curParamMaxAmqCallee;
- this.paramControllerType = curParamControllerType;
- }
-
- @Override
- protected String getConnectedStateName() {
- return "connected";
- }
-
- @Override
- protected String getDisconnectTransitionName() {
- return "disconnect";
- }
-
- @Override
- protected Collection<CustomAction> getAdditionalCustomActions() {
- return Arrays.asList(
- new CustomAction("https://plc4x.apache.org/scxml-extension", "S7DecodeArticleNumber",
- S7DecodeArticleNumber.class),
- new CustomAction("https://plc4x.apache.org/scxml-extension", "S7DecodeReadResponse",
- S7DecodeReadResponseAction.class),
- new CustomAction("https://plc4x.apache.org/scxml-extension", "S7DecodeWriteResponse",
- S7DecodeWriteResponseAction.class)
- );
- }
-
- @Override
- protected Map<String, Object> getAdditionalContextDataItems() {
- Map<String, Object> dataItems = new HashMap<>();
-
- dataItems.put("hostname", address.getHostAddress());
- dataItems.put("port", "102");
- dataItems.put("plcType", paramControllerType);
-
- dataItems.put("cotpLocalReference", "15");
- dataItems.put("cotpCalledTsap", Short.toString(calledTsapId));
- dataItems.put("cotpCallingTsap", Short.toString(callingTsapId));
- dataItems.put("cotpTpduSize", "10");
-
- dataItems.put("s7PduLength", Short.toString(paramPduSize));
- dataItems.put("s7MaxAmqCaller", Short.toString(paramMaxAmqCaller));
- dataItems.put("s7MaxAmqCallee", Short.toString(paramMaxAmqCallee));
-
- return dataItems;
- }
-
- @Override
- public PlcConnectionMetadata getMetadata() {
- return super.getMetadata();
- }
-
- @Override
- public PlcReadRequest.Builder readRequestBuilder() {
- return new DefaultPlcReadRequest.Builder(this, new S7PlcFieldHandler());
- }
-
- @Override
- public CompletableFuture<PlcReadResponse> read(PlcReadRequest readRequest) {
- InternalPlcReadRequest internalReadRequest = checkInternal(readRequest, InternalPlcReadRequest.class);
- CompletableFuture<InternalPlcReadResponse> future = new CompletableFuture<>();
- PlcRequestContainer<InternalPlcReadRequest, InternalPlcReadResponse> container =
- new PlcRequestContainer<>(internalReadRequest, future);
-
- try {
- getExecutor().triggerEvent(
- new EventBuilder("read", TriggerEvent.CALL_EVENT).data(container).build());
- } catch (ModelException e) {
- throw new PlcRuntimeException("Error reading.", e);
- }
-
- return future.thenApply(PlcReadResponse.class::cast);
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/DataTransportErrorCode.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/DataTransportErrorCode.java
deleted file mode 100644
index c9f520c..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/DataTransportErrorCode.java
+++ /dev/null
@@ -1,62 +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.sandbox.java.dynamic.s7.types;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public enum DataTransportErrorCode {
- RESERVED((byte) 0x00),
- OK((byte) 0xFF),
- ACCESS_DENIED((byte) 0x03),
- INVALID_ADDRESS((byte) 0x05),
- DATA_TYPE_NOT_SUPPORTED((byte) 0x06),
- NOT_FOUND((byte) 0x0A);
-
- private static final Logger logger = LoggerFactory.getLogger(DataTransportErrorCode.class);
-
- private static final Map<Byte, DataTransportErrorCode> map;
- static {
- map = new HashMap<>();
- for (DataTransportErrorCode dataTransportErrorCode : DataTransportErrorCode.values()) {
- map.put(dataTransportErrorCode.code, dataTransportErrorCode);
- }
- }
-
- private byte code;
-
- DataTransportErrorCode(byte code) {
- this.code = code;
- }
-
- public byte getCode() {
- return code;
- }
-
- public static DataTransportErrorCode valueOf(byte code) {
- if (!map.containsKey(code)) {
- logger.error("No DataTransportErrorCode for code {}", code);
- }
- return map.get(code);
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/DataTransportSize.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/DataTransportSize.java
deleted file mode 100644
index 90924e0..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/DataTransportSize.java
+++ /dev/null
@@ -1,64 +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.sandbox.java.dynamic.s7.types;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * (Values determined by evaluating generated ".pcap" files)
- */
-public enum DataTransportSize {
- NULL((byte) 0x00, false),
- BIT((byte) 0x03, true),
- BYTE_WORD_DWORD((byte) 0x04, true),
- INTEGER((byte) 0x05, true),
- DINTEGER((byte) 0x06, false),
- REAL((byte) 0x07, false),
- OCTET_STRING((byte) 0x09, false);
-
- private static final Map<Byte, DataTransportSize> map;
- static {
- map = new HashMap<>();
- for (DataTransportSize dataTransportSize : DataTransportSize.values()) {
- map.put(dataTransportSize.code, dataTransportSize);
- }
- }
-
- private final byte code;
- private final boolean sizeInBits;
-
- DataTransportSize(byte code, boolean sizeInBits) {
- this.code = code;
- this.sizeInBits = sizeInBits;
- }
-
- public byte getCode() {
- return code;
- }
-
- public boolean isSizeInBits() {
- return sizeInBits;
- }
-
- public static DataTransportSize valueOf(byte code) {
- return map.get(code);
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/MemoryArea.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/MemoryArea.java
deleted file mode 100644
index ead1018..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/MemoryArea.java
+++ /dev/null
@@ -1,83 +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.sandbox.java.dynamic.s7.types;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * (Values determined by evaluating generated ".pcap" files)
- */
-public enum MemoryArea {
- COUNTERS("C", (byte) 0x1C), /* Renamed from "S7 Counters" */ // TODO: Double check shortName
- TIMERS("T", (byte) 0x1D), /* Renamed from "S7 Timers" */ // TODO: Double check shortName
- DIRECT_PERIPHERAL_ACCESS("D", (byte) 0x80), // TODO: Double check shortName
- INPUTS("I", (byte) 0x81),
- OUTPUTS("Q", (byte) 0x82),
- FLAGS("F", (byte) 0x83), // TODO: Double check shortName
- DATA_BLOCKS("DB", (byte) 0x84),
- INSTANCE_DATA_BLOCKS("DBI", (byte) 0x85), // TODO: Double check shortName
- LOCAL_DATA("LD", (byte) 0x86); // TODO: Double check shortName
-
- // TODO: I think we should remove these ...
- /*S7_200_SYSTEM_INFO(null, (byte) 0x03), * Renamed from "System info of 200 family" *
- S7_200_FLAGS(null, (byte) 0x05), * Renamed from "System flags of 200 family" *
- S7_200_INPUTS(null, (byte) 0x06), * Renamed from "System inputs of 200 family" *
- S7_200_OUTPUTS(null, (byte) 0x07), * Renamed from "System outputs of 200 family" *
- S7_200_IEC_COUNTERS(null, (byte) 0x1E), * Renamed from "IEC counters (200 family)" *
- S7_200_IEC_TIMERS(null, (byte) 0x1F); * Renamed from "IEC timers (200 family)" */
-
- private static final Map<Byte, MemoryArea> map;
- static {
- map = new HashMap<>();
- for (MemoryArea memoryArea : MemoryArea.values()) {
- map.put(memoryArea.code, memoryArea);
- }
- }
-
- private final String shortName;
- private final byte code;
-
- MemoryArea(String shortName, byte code) {
- this.shortName = shortName;
- this.code = code;
- }
-
- public String getShortName() {
- return shortName;
- }
-
- public byte getCode() {
- return code;
- }
-
- public static MemoryArea valueOfShortName(String shortName) {
- for (MemoryArea value : MemoryArea.values()) {
- if(value.getShortName().equals(shortName)) {
- return value;
- }
- }
- return null;
- }
-
- public static MemoryArea valueOf(byte code) {
- return map.get(code);
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/S7ControllerType.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/S7ControllerType.java
deleted file mode 100644
index 5fee6dd..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/S7ControllerType.java
+++ /dev/null
@@ -1,30 +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.sandbox.java.dynamic.s7.types;
-
-public enum S7ControllerType {
-
- ANY,
- S7_300,
- S7_400,
- S7_1200,
- S7_1500,
- LOGO
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/TransportSize.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/TransportSize.java
deleted file mode 100644
index 3655993..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/types/TransportSize.java
+++ /dev/null
@@ -1,195 +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.sandbox.java.dynamic.s7.types;
-
-import java.util.*;
-
-public enum TransportSize {
-
- /**
- * TODO: For the types with code 0x00 we need to put some additional effort in reverse engineering the codes for these types.
- */
- // -----------------------------------------
- // Single bit
- // -----------------------------------------
- BOOL(0x01, "X", 1, null, DataTransportSize.BIT, S7ControllerType.ANY),
-
- // -----------------------------------------
- // Bit strings
- // -----------------------------------------
- BYTE(0x02, "B", 1, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- WORD(0x04, "W", 2, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- DWORD(0x06, "D", 4, WORD, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- // Only got a basic TIA license (S7-1500 needed to find this out)
- // TODO: Find the code
- LWORD(0x00, "X", 8, null, null, S7ControllerType.S7_1200, S7ControllerType.S7_1500),
-
- // -----------------------------------------
- // Integers
- // -----------------------------------------
- // Signed Int
- INT(0x05, "W", 2, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- // Unsigned Int
- UINT(0x05, "W", 2, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500),
- // (Signed) Small Int
- SINT(0x02, "B", 1, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500),
- // Unsigned Small Int
- USINT(0x02, "B", 1, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500),
- // Double Precision Int
- DINT(0x07, "D", 4, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- // Unsigned Double Precision Int
- UDINT(0x07, "D", 4, INT, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.S7_1200, S7ControllerType.S7_1500),
- // Only got a basic TIA license (S7-1500 needed to find this out)
- // TODO: Find the code
- LINT(0x00, "X", 8, INT, null, S7ControllerType.S7_1500),
- // Only got a basic TIA license (S7-1500 needed to find this out)
- // TODO: Find the code
- ULINT(0x00, "X", 16, INT, null, S7ControllerType.S7_1500),
-
- // -----------------------------------------
- // Reals
- // -----------------------------------------
- REAL(0x08, "D", 4, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- // TODO: Find the code
- LREAL(0x00, "X", 8, REAL, null, S7ControllerType.S7_1200, S7ControllerType.S7_1200, S7ControllerType.S7_1500),
-
- // -----------------------------------------
- // Durations
- // -----------------------------------------
- // IEC time
- TIME(0x0B, "X", 4, null, null, S7ControllerType.ANY),
- // TODO: Find the code
- LTIME(0x00, "X", 8, TIME, null, S7ControllerType.S7_1500),
-
- // -----------------------------------------
- // Date
- // -----------------------------------------
- // IEC date (yyyy-m-d)
- // TODO: Find the code
- DATE(0x00, "X", 2, null, null, S7ControllerType.ANY),
-
- // -----------------------------------------
- // Time of day
- // -----------------------------------------
- // Time (hh:mm:ss.S)
- TIME_OF_DAY(0x0A, "X", 4, null, null, S7ControllerType.ANY),
-
- // -----------------------------------------
- // Date and time of day
- // -----------------------------------------
- DATE_AND_TIME(0x0F, "X", 8, null, null, S7ControllerType.ANY),
-
- // -----------------------------------------
- // ASCII Strings
- // -----------------------------------------
- // Single-byte character
- CHAR(0x03, "B", 1, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- // Double-byte character
- // TODO: Find the code (Maybe 0x13)
- WCHAR(0x13, "X", 2, null, null, S7ControllerType.S7_1200, S7ControllerType.S7_1500),
- // Variable-length single-byte character string
- STRING(0x03, "X", 1, null, DataTransportSize.BYTE_WORD_DWORD, S7ControllerType.ANY),
- // Variable-length double-byte character string
- // TODO: Find the code (Maybe 0x13)
- WSTRING(0x00, "X", 1, null, null, S7ControllerType.S7_1200, S7ControllerType.S7_1500);
-
- /* TO BE CONTINUED */
-
- // Codes and their types:
- // 0x1C: Counter
- // 0x1D: Timer
- // 0x1E: IEC Timer
- // 0x1F: IEC Counter
- // 0x20: HS Counter
- //
-
- private static final Map<Byte, TransportSize> map;
- static {
- map = new HashMap<>();
- for (TransportSize dataType : TransportSize.values()) {
- map.put(dataType.typeCode, dataType);
- }
- }
-
- private final byte typeCode;
- private final String sizeCode;
- private final int sizeInBytes;
- private final Set<S7ControllerType> supportedControllerTypes;
- private final TransportSize baseType;
- private final DataTransportSize dataTransportSize;
-
- TransportSize(int typeCode, String sizeCode, int sizeInBytes, TransportSize baseType, DataTransportSize dataTransportSize,
- S7ControllerType... supportedControllerTypes) {
- this.typeCode = (byte) typeCode;
- this.sizeCode = sizeCode;
- this.sizeInBytes = sizeInBytes;
- this.supportedControllerTypes = new HashSet<>(Arrays.asList(supportedControllerTypes));
- this.baseType = baseType;
- this.dataTransportSize = dataTransportSize;
- }
-
- public byte getTypeCode() {
- return typeCode;
- }
-
- public String getSizeCode() {
- return sizeCode;
- }
-
- public int getSizeInBytes() {
- return sizeInBytes;
- }
-
- public boolean isBaseType() {
- return baseType == null;
- }
-
- TransportSize getBaseType() {
- // If this is a base-type itself, the baseType is null, in all
- // other cases it is set.
- if (baseType == null) {
- return this;
- } else {
- return baseType;
- }
- }
-
- TransportSize getSubType(String sizeCode) {
- // Try to find a sub-type with this base type for which the size code matches.
- for (TransportSize value : values()) {
- if ((value.baseType == this) && (value.sizeCode != null) && (value.sizeCode.equals(sizeCode))) {
- return value;
- }
- }
- return null;
- }
-
- public DataTransportSize getDataTransportSize() {
- return dataTransportSize;
- }
-
- boolean isControllerTypeSupported(S7ControllerType controllerType) {
- return supportedControllerTypes.contains(controllerType);
- }
-
- public static TransportSize valueOf(byte code) {
- return map.get(code);
- }
-
-}
\ No newline at end of file
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7Field.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7Field.java
deleted file mode 100644
index fde3c74..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7Field.java
+++ /dev/null
@@ -1,194 +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.sandbox.java.dynamic.s7.utils;
-
-import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.model.PlcField;
-import org.apache.plc4x.sandbox.java.dynamic.s7.types.MemoryArea;
-import org.apache.plc4x.sandbox.java.dynamic.s7.types.TransportSize;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class S7Field implements PlcField {
-
- //byteOffset theoretically can reach up to 2097151 ... see checkByteOffset() below --> 7digits
- private static final Pattern ADDRESS_PATTERN =
- Pattern.compile("^%(?<memoryArea>.)(?<transferSizeCode>[XBWD]?)(?<byteOffset>\\d{1,7})(.(?<bitOffset>[0-7]))?:(?<dataType>[a-zA-Z_]+)(\\[(?<numElements>\\d+)])?");
-
- //blockNumber usually has its max hat around 64000 --> 5digits
- private static final Pattern DATA_BLOCK_ADDRESS_PATTERN =
- Pattern.compile("^%DB(?<blockNumber>\\d{1,5}).DB(?<transferSizeCode>[XBWD]?)(?<byteOffset>\\d{1,7})(.(?<bitOffset>[0-7]))?:(?<dataType>[a-zA-Z_]+)(\\[(?<numElements>\\d+)])?");
-
- private static final String DATA_TYPE = "dataType";
- private static final String TRANSFER_SIZE_CODE = "transferSizeCode";
- private static final String BLOCK_NUMBER = "blockNumber";
- private static final String BYTE_OFFSET = "byteOffset";
- private static final String BIT_OFFSET = "bitOffset";
- private static final String NUM_ELEMENTS = "numElements";
- private static final String MEMORY_AREA = "memoryArea";
-
- private final TransportSize dataType;
- private final MemoryArea memoryArea;
- private final int blockNumber;
- private final int byteOffset;
- private final short bitOffset;
- private final int numElements;
-
- private S7Field(TransportSize dataType, MemoryArea memoryArea, int blockNumber, int byteOffset, short bitOffset, int numElements) {
- this.dataType = dataType;
- this.memoryArea = memoryArea;
- this.blockNumber = blockNumber;
- this.byteOffset = byteOffset;
- this.bitOffset = bitOffset;
- this.numElements = numElements;
- }
-
- public TransportSize getDataType() {
- return dataType;
- }
-
- public MemoryArea getMemoryArea() {
- return memoryArea;
- }
-
- public int getBlockNumber() {
- return blockNumber;
- }
-
- public int getByteOffset() {
- return byteOffset;
- }
-
- public short getBitOffset() {
- return bitOffset;
- }
-
- public int getNumElements() {
- return numElements;
- }
-
- public static boolean matches(String fieldString) {
- return DATA_BLOCK_ADDRESS_PATTERN.matcher(fieldString).matches() ||
- ADDRESS_PATTERN.matcher(fieldString).matches();
- }
-
- public static S7Field of(String fieldString) {
- Matcher matcher = DATA_BLOCK_ADDRESS_PATTERN.matcher(fieldString);
- if(matcher.matches()) {
- TransportSize dataType = TransportSize.valueOf(matcher.group(DATA_TYPE));
- MemoryArea memoryArea = MemoryArea.DATA_BLOCKS;
- String transferSizeCode = matcher.group(TRANSFER_SIZE_CODE);
-
- int blockNumber = checkDatablockNumber(Integer.parseInt(matcher.group(BLOCK_NUMBER)));
-
- int byteOffset = checkByteOffset(Integer.parseInt(matcher.group(BYTE_OFFSET)));
-
- short bitOffset = 0;
- if(matcher.group(BIT_OFFSET) != null) {
- bitOffset = Short.parseShort(matcher.group(BIT_OFFSET));
- } else if(dataType == TransportSize.BOOL) {
- throw new PlcInvalidFieldException("Expected bit offset for BOOL parameters.");
- }
- int numElements = 1;
- if(matcher.group(NUM_ELEMENTS) != null) {
- numElements = Integer.parseInt(matcher.group(NUM_ELEMENTS));
- }
- numElements = calcNumberOfElementsForStringTypes(numElements,dataType);
- if(!transferSizeCode.isEmpty() && !dataType.getSizeCode().equals(transferSizeCode)) {
- throw new PlcInvalidFieldException("Transfer size code '" + transferSizeCode +
- "' doesn't match specified data type '" + dataType.name() + "'");
- }
- return new S7Field(dataType, memoryArea, blockNumber, byteOffset, bitOffset, numElements);
- } else {
- matcher = ADDRESS_PATTERN.matcher(fieldString);
- if (matcher.matches()) {
- TransportSize dataType = TransportSize.valueOf(matcher.group(DATA_TYPE));
- MemoryArea memoryArea = MemoryArea.valueOfShortName(matcher.group(MEMORY_AREA));
- String transferSizeCode = matcher.group(TRANSFER_SIZE_CODE);
-
- int byteOffset = checkByteOffset(Integer.parseInt(matcher.group(BYTE_OFFSET)));
-
- short bitOffset = 0;
- if(matcher.group(BIT_OFFSET) != null) {
- bitOffset = Short.parseShort(matcher.group(BIT_OFFSET));
- } else if(dataType == TransportSize.BOOL) {
- throw new PlcInvalidFieldException("Expected bit offset for BOOL parameters.");
- }
- int numElements = 1;
- if(matcher.group(NUM_ELEMENTS) != null) {
- numElements = Integer.parseInt(matcher.group(NUM_ELEMENTS));
- }
- numElements = calcNumberOfElementsForStringTypes(numElements,dataType);
- if(!transferSizeCode.isEmpty() && !dataType.getSizeCode().equals(transferSizeCode)) {
- throw new PlcInvalidFieldException("Transfer size code '" + transferSizeCode +
- "' doesn't match specified data type '" + dataType.name() + "'");
- }
- return new S7Field(dataType, memoryArea, (short) 0, byteOffset, bitOffset, numElements);
- }
- }
- throw new PlcInvalidFieldException("Unable to parse address: " + fieldString);
- }
-
- /**
- * checks if DatablockNumber of S7Field is in valid range
- * @param blockNumber given DatablockNumber
- * @return given blockNumber if Ok, throws PlcInvalidFieldException otherwise
- */
- private static int checkDatablockNumber(int blockNumber){
- //ToDo check the value or add reference - limit eventually depending on active S7 --> make a case selection
- if(blockNumber>64000 || blockNumber<1){
- throw new PlcInvalidFieldException("Datablock numbers larger than 64000 or smaller than 1 are not supported.");
- }
- return blockNumber;
- }
-
- /**
- * checks if ByteOffset from S7Field is in valid range
- * @param byteOffset given byteOffset
- * @return given byteOffset if Ok, throws PlcInvalidFieldException otherwise
- */
- private static int checkByteOffset(int byteOffset){
- //ToDo check the value or add reference
- if(byteOffset>2097151 || byteOffset<0){
- throw new PlcInvalidFieldException("ByteOffset must be smaller than 2097151 and positive.");
- }
- return byteOffset;
- }
-
- /**
- * correct the storage of "array"-like variables like STRING
- * @param numElements auto-detected numElements (1 if no numElements in brackets has been given, x if a specific number has been given)
- * @param dataType detected Transport-Size that represents the data-type
- * @return corrected numElements if nessesary
- */
- private static int calcNumberOfElementsForStringTypes(int numElements,TransportSize dataType){
- //if no String nothing has to be done
- if(!dataType.equals(TransportSize.STRING)){
- return numElements;
- }
- //on valid String-length add two byte because of S7-representation of Strings
- if(numElements>1 && numElements<=254){
- return numElements+2;
- }
- //connection String usage with "STRING" only --> numElements=1 --> enter default value
- return 256;
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7PlcFieldHandler.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7PlcFieldHandler.java
deleted file mode 100644
index d395821..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7PlcFieldHandler.java
+++ /dev/null
@@ -1,569 +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.sandbox.java.dynamic.s7.utils;
-
-import org.apache.plc4x.java.api.exceptions.PlcInvalidFieldException;
-import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
-import org.apache.plc4x.java.api.model.PlcField;
-import org.apache.plc4x.java.base.connection.DefaultPlcFieldHandler;
-import org.apache.plc4x.java.base.messages.items.*;
-
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigInteger;
-import java.nio.charset.StandardCharsets;
-import java.util.BitSet;
-import java.util.LinkedList;
-import java.util.List;
-
-public class S7PlcFieldHandler extends DefaultPlcFieldHandler {
-
- @Override
- public PlcField createField(String fieldQuery) {
- if (S7Field.matches(fieldQuery)) {
- return S7Field.of(fieldQuery);
- }
- throw new PlcInvalidFieldException(fieldQuery);
- }
-
- @Override
- public BaseDefaultFieldItem encodeBoolean(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- // All of these types are declared as Bit or Bit-String types.
- switch (s7Field.getDataType()) {
- case BOOL:
- case BYTE:
- case WORD:
- case DWORD:
- case LWORD:
- return internalEncodeBoolean(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeByte(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- // All of these types are declared as Bit or Bit-String types.
- switch (s7Field.getDataType()) {
- case BYTE:
- case SINT:
- case USINT:
- case CHAR:
- return internalEncodeInteger(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeShort(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case WORD:
- case INT:
- case UINT:
- return internalEncodeInteger(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeInteger(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case DWORD:
- case DINT:
- case UDINT:
- return internalEncodeInteger(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeBigInteger(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case DWORD:
- case DINT:
- case UDINT:
- return internalEncodeInteger(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeLong(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case LWORD:
- case LINT:
- case ULINT:
- return internalEncodeInteger(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeFloat(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case REAL:
- return internalEncodeFloatingPoint(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeDouble(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case LREAL:
- return internalEncodeFloatingPoint(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeString(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case CHAR:
- case WCHAR:
- case STRING:
- case WSTRING:
- return internalEncodeString(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeTime(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case TIME:
- return internalEncodeTemporal(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeDate(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case DATE:
- return internalEncodeTemporal(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- @Override
- public BaseDefaultFieldItem encodeDateTime(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case DATE_AND_TIME:
- return internalEncodeTemporal(field, values);
- default:
- throw new PlcRuntimeException("Invalid encoder for type " + s7Field.getDataType().name());
- }
- }
-
- private BaseDefaultFieldItem internalEncodeBoolean(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case BOOL:
- case BYTE:
- case WORD:
- case DWORD:
- case LWORD:
- break;
- default:
- throw new IllegalArgumentException(
- "Cannot assign boolean values to " + s7Field.getDataType().name() + " fields.");
- }
- List<Boolean> booleanValues = new LinkedList<>();
- for (Object value : values) {
- if (value instanceof Boolean) {
- Boolean booleanValue = (Boolean) value;
- booleanValues.add(booleanValue);
- } else if (value instanceof Byte) {
- Byte byteValue = (Byte) value;
- BitSet bitSet = BitSet.valueOf(new byte[]{byteValue});
- for (int i = 0; i < 8; i++) {
- booleanValues.add(bitSet.get(i));
- }
- } else if (value instanceof Short) {
- Short shortValue = (Short) value;
- BitSet bitSet = BitSet.valueOf(new long[]{shortValue});
- for (int i = 0; i < 16; i++) {
- booleanValues.add(bitSet.get(i));
- }
- } else if (value instanceof Integer) {
- Integer integerValue = (Integer) value;
- BitSet bitSet = BitSet.valueOf(new long[]{integerValue});
- for (int i = 0; i < 32; i++) {
- booleanValues.add(bitSet.get(i));
- }
- } else if (value instanceof Long) {
- long longValue = (Long) value;
- BitSet bitSet = BitSet.valueOf(new long[]{longValue});
- for (int i = 0; i < 64; i++) {
- booleanValues.add(bitSet.get(i));
- }
- } else {
- throw new IllegalArgumentException(
- "Value of type " + value.getClass().getName() +
- " is not assignable to " + s7Field.getDataType().name() + " fields.");
- }
- }
- return new DefaultBooleanFieldItem(booleanValues.toArray(new Boolean[0]));
- }
-
- private BaseDefaultFieldItem internalEncodeInteger(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
-
- // Initialize the constraints.
- BigInteger minValue;
- BigInteger maxValue;
- Class<? extends BaseDefaultFieldItem> fieldType;
- Class<?> valueType;
- Object[] castedValues;
- switch (s7Field.getDataType()) {
- case BYTE:
- minValue = BigInteger.valueOf((long) Byte.MIN_VALUE);
- maxValue = BigInteger.valueOf((long) Byte.MAX_VALUE);
- fieldType = DefaultByteFieldItem.class;
- valueType = Byte[].class;
- castedValues = new Byte[values.length];
- break;
- case WORD:
- minValue = BigInteger.valueOf((long) Short.MIN_VALUE);
- maxValue = BigInteger.valueOf((long) Short.MAX_VALUE);
- fieldType = DefaultShortFieldItem.class;
- valueType = Short[].class;
- castedValues = new Short[values.length];
- break;
- case DWORD:
- minValue = BigInteger.valueOf((long) Integer.MIN_VALUE);
- maxValue = BigInteger.valueOf((long) Integer.MAX_VALUE);
- fieldType = DefaultIntegerFieldItem.class;
- valueType = Integer[].class;
- castedValues = new Integer[values.length];
- break;
- case LWORD:
- minValue = BigInteger.valueOf(Long.MIN_VALUE);
- maxValue = BigInteger.valueOf(Long.MAX_VALUE);
- fieldType = DefaultLongFieldItem.class;
- valueType = Long[].class;
- castedValues = new Long[values.length];
- break;
- case SINT:
- minValue = BigInteger.valueOf((long) Byte.MIN_VALUE);
- maxValue = BigInteger.valueOf((long) Byte.MAX_VALUE);
- fieldType = DefaultByteFieldItem.class;
- valueType = Byte[].class;
- castedValues = new Byte[values.length];
- break;
- case USINT:
- minValue = BigInteger.valueOf((long) 0);
- maxValue = BigInteger.valueOf((long) Byte.MAX_VALUE * 2);
- fieldType = DefaultShortFieldItem.class;
- valueType = Short[].class;
- castedValues = new Short[values.length];
- break;
- case INT:
- minValue = BigInteger.valueOf((long) Short.MIN_VALUE);
- maxValue = BigInteger.valueOf((long) Short.MAX_VALUE);
- fieldType = DefaultShortFieldItem.class;
- valueType = Short[].class;
- castedValues = new Short[values.length];
- break;
- case UINT:
- minValue = BigInteger.valueOf((long) 0);
- maxValue = BigInteger.valueOf(((long) Short.MAX_VALUE) * 2);
- fieldType = DefaultIntegerFieldItem.class;
- valueType = Integer[].class;
- castedValues = new Integer[values.length];
- break;
- case DINT:
- minValue = BigInteger.valueOf((long) Integer.MIN_VALUE);
- maxValue = BigInteger.valueOf((long) Integer.MAX_VALUE);
- fieldType = DefaultIntegerFieldItem.class;
- valueType = Integer[].class;
- castedValues = new Integer[values.length];
- break;
- case UDINT:
- minValue = BigInteger.valueOf((long) 0);
- maxValue = BigInteger.valueOf(((long) Integer.MAX_VALUE) * 2);
- fieldType = DefaultLongFieldItem.class;
- valueType = Long[].class;
- castedValues = new Long[values.length];
- break;
- case LINT:
- minValue = BigInteger.valueOf(Long.MIN_VALUE);
- maxValue = BigInteger.valueOf(Long.MAX_VALUE);
- fieldType = DefaultLongFieldItem.class;
- valueType = Long[].class;
- castedValues = new Long[values.length];
- break;
- case ULINT:
- minValue = BigInteger.valueOf((long) 0);
- maxValue = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf((long) 2));
- fieldType = DefaultBigIntegerFieldItem.class;
- valueType = BigInteger[].class;
- castedValues = new BigInteger[values.length];
- break;
- default:
- throw new IllegalArgumentException(
- "Cannot assign integer values to " + s7Field.getDataType().name() + " fields.");
- }
-
- // Check the constraints
- for (int i = 0; i < values.length; i++) {
- BigInteger value;
- if (values[i] instanceof BigInteger) {
- value = (BigInteger) values[i];
- } else if ((values[i] instanceof Byte) || (values[i] instanceof Short) ||
- (values[i] instanceof Integer) || (values[i] instanceof Long)) {
- value = BigInteger.valueOf(((Number) values[i]).longValue());
- } else {
- throw new IllegalArgumentException(
- "Value of type " + values[i].getClass().getName() +
- " is not assignable to " + s7Field.getDataType().name() + " fields.");
- }
- if (minValue.compareTo(value) > 0) {
- throw new IllegalArgumentException(
- "Value of " + value.toString() + " exceeds allowed minimum for type "
- + s7Field.getDataType().name() + " (min " + minValue.toString() + ")");
- }
- if (maxValue.compareTo(value) < 0) {
- throw new IllegalArgumentException(
- "Value of " + value.toString() + " exceeds allowed maximum for type "
- + s7Field.getDataType().name() + " (max " + maxValue.toString() + ")");
- }
- if (valueType == Byte[].class) {
- castedValues[i] = value.byteValue();
- } else if (valueType == Short[].class) {
- castedValues[i] = value.shortValue();
- } else if (valueType == Integer[].class) {
- castedValues[i] = value.intValue();
- } else if (valueType == Long[].class) {
- castedValues[i] = value.longValue();
- } else {
- castedValues[i] = value;
- }
- }
-
- // Create the field item.
- try {
- return fieldType.getDeclaredConstructor(valueType).newInstance(new Object[]{castedValues});
- } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- throw new PlcRuntimeException("Error initializing field class " + fieldType.getSimpleName(), e);
- }
- }
-
- private BaseDefaultFieldItem internalEncodeFloatingPoint(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
-
- // Initialize the constraints.
- Double minValue;
- Double maxValue;
- Class<? extends BaseDefaultFieldItem> fieldType;
- Class<?> valueType;
- Object[] castedValues;
- switch (s7Field.getDataType()) {
- case REAL:
- minValue = (double) -Float.MAX_VALUE;
- maxValue = (double) Float.MAX_VALUE;
- fieldType = DefaultFloatFieldItem.class;
- valueType = Float[].class;
- castedValues = new Float[values.length];
- break;
- case LREAL:
- minValue = -Double.MAX_VALUE;
- maxValue = Double.MAX_VALUE;
- fieldType = DefaultDoubleFieldItem.class;
- valueType = Double[].class;
- castedValues = new Double[values.length];
- break;
- default:
- throw new IllegalArgumentException(
- "Cannot assign floating point values to " + s7Field.getDataType().name() + " fields.");
- }
-
- // Check the constraints
- for (int i = 0; i < values.length; i++) {
- Double value;
- if (values[i] instanceof Float) {
- value = ((Float) values[i]).doubleValue();
- } else if (values[i] instanceof Double) {
- value = (Double) values[i];
- } else {
- throw new IllegalArgumentException(
- "Value of type " + values[i].getClass().getName() +
- " is not assignable to " + s7Field.getDataType().name() + " fields.");
- }
- if (value < minValue) {
- throw new IllegalArgumentException(
- "Value of " + value + " exceeds allowed minimum for type "
- + s7Field.getDataType().name() + " (min " + minValue.toString() + ")");
- }
- if (value > maxValue) {
- throw new IllegalArgumentException(
- "Value of " + value + " exceeds allowed maximum for type "
- + s7Field.getDataType().name() + " (max " + maxValue.toString() + ")");
- }
- if (valueType == Float[].class) {
- castedValues[i] = value.floatValue();
- } else {
- castedValues[i] = value;
- }
- }
-
- // Create the field item.
- try {
- return fieldType.getDeclaredConstructor(valueType).newInstance(new Object[]{castedValues});
- } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
- throw new PlcRuntimeException("Error initializing field class " + fieldType.getSimpleName(), e);
- }
- }
-
- private BaseDefaultFieldItem internalEncodeString(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
-
- // Initialize the constraints.
- int maxLength;
- boolean encoding16Bit;
- switch (s7Field.getDataType()) {
- case CHAR:
- maxLength = 1;
- encoding16Bit = false;
- break;
- case WCHAR:
- maxLength = 1;
- encoding16Bit = true;
- break;
- case STRING:
- maxLength = 254;
- encoding16Bit = false;
- break;
- case WSTRING:
- maxLength = 254;
- encoding16Bit = true;
- break;
- default:
- throw new IllegalArgumentException(
- "Cannot assign string values to " + s7Field.getDataType().name() + " fields.");
- }
-
- // Check the constraints and create the strings.
- List<String> stringValues = new LinkedList<>();
- for (Object value : values) {
- if (value instanceof String) {
- String stringValue = (String) value;
- if (stringValue.length() > maxLength) {
- throw new IllegalArgumentException(
- "String length " + stringValue.length() + " exceeds allowed maximum for type "
- + s7Field.getDataType().name() + " (max " + maxLength + ")");
- }
- stringValues.add(stringValue);
- }
- // All other types just translate to max one String character.
- else if (value instanceof Byte) {
- Byte byteValue = (Byte) value;
- byte[] stringBytes = new byte[]{byteValue};
- if (encoding16Bit) {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_16));
- } else {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_8));
- }
- } else if (value instanceof Short) {
- Short shortValue = (Short) value;
- byte[] stringBytes = new byte[2];
- stringBytes[0] = (byte) (shortValue >> 8);
- stringBytes[1] = (byte) (shortValue & 0xFF);
- if (encoding16Bit) {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_16));
- } else {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_8));
- }
- } else if (value instanceof Integer) {
- Integer integerValue = (Integer) value;
- byte[] stringBytes = new byte[4];
- stringBytes[0] = (byte) ((integerValue >> 24) & 0xFF);
- stringBytes[1] = (byte) ((integerValue >> 16) & 0xFF);
- stringBytes[2] = (byte) ((integerValue >> 8) & 0xFF);
- stringBytes[3] = (byte) (integerValue & 0xFF);
- if (encoding16Bit) {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_16));
- } else {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_8));
- }
- } else if (value instanceof Long) {
- Long longValue = (Long) value;
- byte[] stringBytes = new byte[8];
- stringBytes[0] = (byte) ((longValue >> 56) & 0xFF);
- stringBytes[1] = (byte) ((longValue >> 48) & 0xFF);
- stringBytes[2] = (byte) ((longValue >> 40) & 0xFF);
- stringBytes[3] = (byte) ((longValue >> 32) & 0xFF);
- stringBytes[4] = (byte) ((longValue >> 24) & 0xFF);
- stringBytes[5] = (byte) ((longValue >> 16) & 0xFF);
- stringBytes[6] = (byte) ((longValue >> 8) & 0xFF);
- stringBytes[7] = (byte) (longValue & 0xFF);
- if (encoding16Bit) {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_16));
- } else {
- stringValues.add(new String(stringBytes, StandardCharsets.UTF_8));
- }
- } else {
- throw new IllegalArgumentException(
- "Value of type " + value.getClass().getName() +
- " is not assignable to " + s7Field.getDataType().name() + " fields.");
- }
- }
-
- // Create the field item.
- return new DefaultStringFieldItem(stringValues.toArray(new String[0]));
- }
-
- private BaseDefaultFieldItem internalEncodeTemporal(PlcField field, Object[] values) {
- S7Field s7Field = (S7Field) field;
- switch (s7Field.getDataType()) {
- case TIME:
- // TODO: I think I should implement this some time ...
- case DATE:
- // TODO: I think I should implement this some time ...
- case DATE_AND_TIME:
- return new DefaultLocalDateTimeFieldItem();
- default:
- throw new IllegalArgumentException(
- "Cannot assign temporal values to " + s7Field.getDataType().name() + " fields.");
- }
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7TsapIdEncoder.java b/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7TsapIdEncoder.java
deleted file mode 100644
index 9e87c51..0000000
--- a/sandbox/dynamic-driver-s7/src/main/java/org/apache/plc4x/sandbox/java/dynamic/s7/utils/S7TsapIdEncoder.java
+++ /dev/null
@@ -1,45 +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.sandbox.java.dynamic.s7.utils;
-
-public class S7TsapIdEncoder {
-
- private S7TsapIdEncoder() {
- // Prevent this from being instantiated.
- }
-
- public static short encodeS7TsapId(byte deviceGroup, int rack, int slot) {
- short firstByte = (short) (deviceGroup << 8);
- short secondByte = (short) ((rack << 4) | (slot & 0x0F));
- return (short) (firstByte | secondByte);
- }
-
- public static byte decodeDeviceGroup(short tsapId) {
- return (byte) ((tsapId >> 8) & (0xFF));
- }
-
- public static int decodeRack(short tsapId) {
- return (tsapId >> 4) & 0xF;
- }
-
- public static int decodeSlot(short tsapId) {
- return tsapId & 0xF;
- }
-
-}
diff --git a/sandbox/dynamic-driver-s7/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver b/sandbox/dynamic-driver-s7/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
deleted file mode 100644
index 8609dd7..0000000
--- a/sandbox/dynamic-driver-s7/src/main/resources/META-INF/services/org.apache.plc4x.java.spi.PlcDriver
+++ /dev/null
@@ -1,38 +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.
-#
-
-#
-# 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.
-#
-org.apache.plc4x.sandbox.java.dynamic.s7.DynamicS7Driver
diff --git a/sandbox/pom.xml b/sandbox/pom.xml
index 6935f75..5ae2fdf 100644
--- a/sandbox/pom.xml
+++ b/sandbox/pom.xml
@@ -35,11 +35,8 @@
<description>Place where new stuff is located before it is regarded production-quality.</description>
<modules>
- <module>dynamic-driver-base</module>
- <module>dynamic-driver-knxnet-ip</module>
- <module>dynamic-driver-s7</module>
<module>code-gen</module>
- <module>code-generation</module>
+ <module>test-java-s7-driver</module>
</modules>
<dependencyManagement>
diff --git a/sandbox/code-generation/test-java-s7-driver/pom.xml b/sandbox/test-java-s7-driver/pom.xml
similarity index 83%
rename from sandbox/code-generation/test-java-s7-driver/pom.xml
rename to sandbox/test-java-s7-driver/pom.xml
index 2d55561..00c30fc 100644
--- a/sandbox/code-generation/test-java-s7-driver/pom.xml
+++ b/sandbox/test-java-s7-driver/pom.xml
@@ -23,14 +23,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generaton</artifactId>
+ <groupId>org.apache.plc4x.sandbox</groupId>
+ <artifactId>plc4x-sandbox</artifactId>
<version>0.5.0-SNAPSHOT</version>
</parent>
<artifactId>test-java-s7-driver</artifactId>
- <name>Test GenerateMojo</name>
+ <name>Sandbox: Test GenerateMojo</name>
<build>
<plugins>
@@ -56,8 +56,8 @@
<dependencies>
<dependency>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generation-driver-base-java</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-utils-driver-base-java</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
@@ -68,16 +68,16 @@
</dependency>
<dependency>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generation-language-java</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-build-utils-language-java</artifactId>
<version>0.5.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.apache.plc4x.plugins</groupId>
- <artifactId>plc4x-code-generation-protocol-s7</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4x-protocols-s7</artifactId>
<version>0.5.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
diff --git a/sandbox/code-generation/test-java-s7-driver/src/test/java/BenchmarkGeneratedS7.java b/sandbox/test-java-s7-driver/src/test/java/BenchmarkGeneratedS7.java
similarity index 100%
rename from sandbox/code-generation/test-java-s7-driver/src/test/java/BenchmarkGeneratedS7.java
rename to sandbox/test-java-s7-driver/src/test/java/BenchmarkGeneratedS7.java