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/24 15:52:30 UTC
[plc4x-build-tools] 01/03: - Major refactoring of the code
generator -- Split up the plugin and the imaginary format parser -- Renamed
the imaginary format parser to "MSpec" parser (Message Spec) -- Split up
the java template into a java template and a freemarker template base --
Moved the modules that will be released separately into an external
directory -- Changed the inheritance and versions of the modules staying in
the main plc4x repo back to 0.5.0-SNAPSHOT and included them back into the
normal build
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-build-tools.git
commit 7a00a85d0a89cba5270545debe1190fa074a5fdd
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Jun 19 12:10:29 2019 +0200
- Major refactoring of the code generator
-- Split up the plugin and the imaginary format parser
-- Renamed the imaginary format parser to "MSpec" parser (Message Spec)
-- Split up the java template into a java template and a freemarker template base
-- Moved the modules that will be released separately into an external directory
-- Changed the inheritance and versions of the modules staying in the main plc4x repo back to 0.5.0-SNAPSHOT and included them back into the normal build
---
language-base/pom.xml | 42 ++++
.../codegenerator/language/LanguageOutput.java | 40 ++++
plc4x-maven-plugin/pom.xml | 178 +++++++++++++++++
plc4x-maven-plugin/src/it/settings.xml | 53 +++++
plc4x-maven-plugin/src/it/simple-it/pom.xml | 67 +++++++
.../src/main/resources/test/protocol.dfdl.xsd | 114 +++++++++++
plc4x-maven-plugin/src/it/simple-it/verify.groovy | 21 ++
.../plc4x/plugins/codegenerator/GenerateMojo.java | 140 +++++++++++++
plc4x-maven-plugin/src/site/asciidoc/index.adoc | 20 ++
.../src/site/asciidoc/message-format-language.adoc | 21 ++
.../plugins/codegenerator/GenerateMojoTest.java | 87 ++++++++
.../test/projects/simple-embedded-schema/pom.xml | 48 +++++
.../src/main/resources/protocol.spec | 222 +++++++++++++++++++++
.../src/main/resources/template.ftlh | 59 ++++++
.../src/test/resources/specs/s7.spec | 219 ++++++++++++++++++++
pom.xml | 113 +++++++++++
protocol-base/pom.xml | 43 ++++
.../plugins/codegenerator/protocol/Protocol.java | 44 ++++
types-base/pom.xml | 35 ++++
.../codegenerator/types/definitions/Argument.java | 42 ++++
.../types/definitions/ComplexTypeDefinition.java | 75 +++++++
.../DiscriminatedComplexTypeDefinition.java | 26 +++
.../types/definitions/EnumTypeDefinition.java | 48 +++++
.../types/definitions/TypeDefinition.java | 30 +++
.../types/exceptions/GenerationException.java | 32 +++
.../codegenerator/types/fields/ArrayField.java | 40 ++++
.../codegenerator/types/fields/ConstField.java | 30 +++
.../types/fields/DiscriminatorField.java | 30 +++
.../plugins/codegenerator/types/fields/Field.java | 27 +++
.../codegenerator/types/fields/ImplicitField.java | 34 ++++
.../codegenerator/types/fields/OptionalField.java | 33 +++
.../codegenerator/types/fields/PropertyField.java | 26 +++
.../codegenerator/types/fields/ReservedField.java | 30 +++
.../codegenerator/types/fields/SimpleField.java | 28 +++
.../codegenerator/types/fields/SwitchField.java | 36 ++++
.../codegenerator/types/fields/TypedField.java | 28 +++
.../types/references/ComplexTypeReference.java | 26 +++
.../types/references/SimpleTypeReference.java | 37 ++++
.../references/SimpleVarLengthTypeReference.java | 24 +++
.../types/references/TypeReference.java | 24 +++
.../codegenerator/types/terms/BinaryTerm.java | 51 +++++
.../codegenerator/types/terms/BooleanLiteral.java | 39 ++++
.../plugins/codegenerator/types/terms/Literal.java | 23 +++
.../codegenerator/types/terms/NullLiteral.java | 32 +++
.../codegenerator/types/terms/NumericLiteral.java | 39 ++++
.../codegenerator/types/terms/StringLiteral.java | 39 ++++
.../plugins/codegenerator/types/terms/Term.java | 26 +++
.../codegenerator/types/terms/TernaryTerm.java | 57 ++++++
.../codegenerator/types/terms/UnaryTerm.java | 45 +++++
.../codegenerator/types/terms/VariableLiteral.java | 75 +++++++
50 files changed, 2698 insertions(+)
diff --git a/language-base/pom.xml b/language-base/pom.xml
new file mode 100644
index 0000000..8896b2b
--- /dev/null
+++ b/language-base/pom.xml
@@ -0,0 +1,42 @@
+<?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>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>plc4x-code-generation-language-base</artifactId>
+
+ <name>Sandbox: Code Generation: Language Template Base</name>
+ <description>Base stuff for building language templates</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.plc4x.plugins</groupId>
+ <artifactId>plc4x-code-generation-types-base</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
diff --git a/language-base/src/main/java/org/apache/plc4x/plugins/codegenerator/language/LanguageOutput.java b/language-base/src/main/java/org/apache/plc4x/plugins/codegenerator/language/LanguageOutput.java
new file mode 100644
index 0000000..c190a6f
--- /dev/null
+++ b/language-base/src/main/java/org/apache/plc4x/plugins/codegenerator/language/LanguageOutput.java
@@ -0,0 +1,40 @@
+/*
+ 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.plugins.codegenerator.language;
+
+import org.apache.plc4x.plugins.codegenerator.types.definitions.ComplexTypeDefinition;
+import org.apache.plc4x.plugins.codegenerator.types.exceptions.GenerationException;
+
+import java.io.File;
+import java.util.Map;
+
+public interface LanguageOutput {
+
+ /**
+ * The name of the template is what the plugin will use to select the correct language module.
+ *
+ * @return the name of the template.
+ */
+ String getName();
+
+ void generate(File outputDir, String packageName, Map<String, ComplexTypeDefinition> types)
+ throws GenerationException;
+
+}
diff --git a/plc4x-maven-plugin/pom.xml b/plc4x-maven-plugin/pom.xml
new file mode 100644
index 0000000..5b7c946
--- /dev/null
+++ b/plc4x-maven-plugin/pom.xml
@@ -0,0 +1,178 @@
+<?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>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>plc4x-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+
+ <name>Sandbox: Code Generation: PLC4X Maven Plugin</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.plc4x.plugins</groupId>
+ <artifactId>plc4x-code-generation-language-base</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x.plugins</groupId>
+ <artifactId>plc4x-code-generation-protocol-base</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.9.3</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.6</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>${maven.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.6.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-compat</artifactId>
+ <version>${maven.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-testing</groupId>
+ <artifactId>maven-plugin-testing-harness</artifactId>
+ <version>3.3.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.6.0</version>
+ <configuration>
+ <!-- <goalPrefix>maven-archetype-plugin</goalPrefix> -->
+ <!--skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound-->
+ </configuration>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>help-goal</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>run-its</id>
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>3.1.0</version>
+ <configuration>
+ <debug>true</debug>
+ <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
+ <pomIncludes>
+ <pomInclude>*/pom.xml</pomInclude>
+ </pomIncludes>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <goals>
+ <goal>clean</goal>
+ <goal>test-compile</goal>
+ </goals>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/plc4x-maven-plugin/src/it/settings.xml b/plc4x-maven-plugin/src/it/settings.xml
new file mode 100644
index 0000000..1eaaf27
--- /dev/null
+++ b/plc4x-maven-plugin/src/it/settings.xml
@@ -0,0 +1,53 @@
+<?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.
+ -->
+<settings>
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>@localRepositoryUrl@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>
diff --git a/plc4x-maven-plugin/src/it/simple-it/pom.xml b/plc4x-maven-plugin/src/it/simple-it/pom.xml
new file mode 100644
index 0000000..e43d806
--- /dev/null
+++ b/plc4x-maven-plugin/src/it/simple-it/pom.xml
@@ -0,0 +1,67 @@
+<?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>
+
+ <groupId>org.apache.plc4x.plugins.it</groupId>
+ <artifactId>simple-it</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <description>A simple IT verifying the basic use case.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>@project.groupId@</groupId>
+ <artifactId>@project.artifactId@</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>generate-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate-driver</goal>
+ </goals>
+ <configuration>
+ <dfdl-schema>test/protocol.dfdl.xsd</dfdl-schema>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/plc4x-maven-plugin/src/it/simple-it/src/main/resources/test/protocol.dfdl.xsd b/plc4x-maven-plugin/src/it/simple-it/src/main/resources/test/protocol.dfdl.xsd
new file mode 100644
index 0000000..5e322f5
--- /dev/null
+++ b/plc4x-maven-plugin/src/it/simple-it/src/main/resources/test/protocol.dfdl.xsd
@@ -0,0 +1,114 @@
+<!--
+ 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:knx="http://plc4x.apache.org/knxnet-ip"
+ targetNamespace="http://plc4x.apache.org/knxnet-ip">
+
+ <xs:annotation>
+ <xs:appinfo source="http://www.ogf.org/dfdl/">
+ <dfdl:defineVariable name="messageType" type="xs:string"/>
+ <dfdl:defineFormat name="knxNetIpFullFormat">
+ <dfdl:format representation="binary"
+ binaryNumberRep="binary"
+ byteOrder="bigEndian"
+ lengthKind="implicit" lengthUnits="bytes" length="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="knx:knxNetIpFullFormat"/>
+ </xs:appinfo>
+ </xs:annotation>
+
+ <!--
+
+ Simple type definition.
+
+ -->
+
+ <xs:simpleType name="bit" dfdl:lengthUnits="bits" dfdl:length="1" dfdl:lengthKind="explicit">
+ <xs:restriction base="xs:boolean"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="byte" dfdl:lengthUnits="bytes" dfdl:length="1" dfdl:lengthKind="explicit">
+ <xs:restriction base="xs:unsignedByte"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="short" dfdl:lengthUnits="bytes" dfdl:length="2" dfdl:lengthKind="explicit">
+ <xs:restriction base="xs:unsignedShort"/>
+ </xs:simpleType>
+
+ <xs:simpleType name="hexByte" dfdl:lengthUnits="bytes" dfdl:length="1" dfdl:lengthKind="explicit">
+ <xs:restriction base="xs:hexBinary"/>
+ </xs:simpleType>
+
+ <!--
+
+ TPKT - Iso-On-TCP
+
+ -->
+
+ <xs:element name="KNXNetIPMessage" type="knx:KNXNetIPMessageType"/>
+
+ <xs:complexType name="KNXNetIPMessageType">
+ <xs:sequence>
+ <xs:element name="header">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="headerLength" type="knx:byte" fixed="06"/>
+ <xs:element name="protocolVersion" type="knx:byte" fixed="10"/>
+ <xs:element name="serviceTypeIdentifier" type="knx:short"/>
+ <!-- length of the entire message (including header) -->
+ <xs:element name="totalLength" type="knx:short"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="body">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="cEMIFrame" type="knx:cEMIFrameType"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ http://www.eb-systeme.de/?page_id=479
+ <xs:complexType name="cEMIFrameType">
+ <xs:sequence>
+ <xs:element name="structureLength" type="knx:byte"/>
+ <xs:element name="descriptionType" type="knx:byte"/>
+ <xs:choice dfdl:choiceDispatchKey="{descriptionType}">
+ <xs:element dfdl:choiceBranchKey="" ref="knx:blah"/>
+ <xs:element dfdl:choiceBranchKey="" ref="knx:blah"/>
+ <xs:element dfdl:choiceBranchKey="" ref="knx:blah"/>
+ <xs:element dfdl:choiceBranchKey="" ref="knx:blah"/>
+ </xs:choice>
+ </xs:sequence>
+ </xs:complexType>
+
+</xs:schema>
\ No newline at end of file
diff --git a/plc4x-maven-plugin/src/it/simple-it/verify.groovy b/plc4x-maven-plugin/src/it/simple-it/verify.groovy
new file mode 100644
index 0000000..86b2598
--- /dev/null
+++ b/plc4x-maven-plugin/src/it/simple-it/verify.groovy
@@ -0,0 +1,21 @@
+/*
+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.
+*/
+File touchFile = new File( basedir, "target/touch.txt" )
+
+assert touchFile.isFile()
diff --git a/plc4x-maven-plugin/src/main/java/org/apache/plc4x/plugins/codegenerator/GenerateMojo.java b/plc4x-maven-plugin/src/main/java/org/apache/plc4x/plugins/codegenerator/GenerateMojo.java
new file mode 100644
index 0000000..1d11d3f
--- /dev/null
+++ b/plc4x-maven-plugin/src/main/java/org/apache/plc4x/plugins/codegenerator/GenerateMojo.java
@@ -0,0 +1,140 @@
+/*
+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.plugins.codegenerator;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.apache.plc4x.plugins.codegenerator.language.LanguageOutput;
+import org.apache.plc4x.plugins.codegenerator.types.definitions.ComplexTypeDefinition;
+import org.apache.plc4x.plugins.codegenerator.types.exceptions.GenerationException;
+import org.apache.plc4x.plugins.codegenerator.protocol.Protocol;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.*;
+
+/**
+ * Generate the types, serializer and parser classes based on a DFDL shema.
+ */
+@Mojo(name = "generate-driver",
+ defaultPhase = LifecyclePhase.GENERATE_SOURCES,
+ requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
+public class GenerateMojo extends AbstractMojo {
+
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
+ private MavenProject project;
+
+ /**
+ * Where to generate the code.
+ */
+ @Parameter(defaultValue = "${project.build.directory}/generated-sources/plc4x/", required = true)
+ private File outputDir;
+
+ /**
+ * The name of the protocol module that will be used to generate the driver.
+ */
+ @Parameter(required = true)
+ private String protocolName;
+
+ /**
+ * The name of the language name that will be used to generate the driver.
+ */
+ @Parameter(required = true)
+ private String languageName;
+
+ public void execute()
+ throws MojoExecutionException {
+
+ // Make sure the output directory exists.
+ if (!outputDir.exists()) {
+ if (!outputDir.mkdirs()) {
+ throw new MojoExecutionException("Could not generate output directory " + outputDir.getAbsolutePath());
+ }
+ }
+
+ // Build a classloader that can access the projects classpath (read from dependencies)
+ ClassLoader moduleClassloader;
+ try {
+ Set<Artifact> artifacts = project.getArtifacts();
+ List<URL> classpathElements = new ArrayList<>(artifacts.size() + 1);
+ // Add the normal class output (needed for embedded schemas)
+ classpathElements.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
+ // Add all the other artifacts (no matter what scope)
+ for (Artifact artifact : artifacts) {
+ classpathElements.add(artifact.getFile().toURI().toURL());
+ }
+ moduleClassloader = new URLClassLoader(
+ classpathElements.toArray(new URL[0]), GenerateMojo.class.getClassLoader());
+ } catch (MalformedURLException e) {
+ throw new MojoExecutionException(
+ "Error creating classloader for loading message format schema from module dependencies", e);
+ }
+
+ // Load the protocol module.
+ Protocol protocol = null;
+ ServiceLoader<Protocol> protocols = ServiceLoader.load(Protocol.class, moduleClassloader);
+ for (Protocol curProtocol : protocols) {
+ if(curProtocol.getName().equalsIgnoreCase(protocolName)) {
+ protocol = curProtocol;
+ break;
+ }
+ }
+ if(protocol == null) {
+ throw new MojoExecutionException(
+ "Unable to find protocol specification module '" + protocolName + "' on modules classpath");
+ }
+
+ // Load the language module.
+ LanguageOutput language = null;
+ ServiceLoader<LanguageOutput> languages = ServiceLoader.load(LanguageOutput.class, moduleClassloader);
+ for (LanguageOutput curLanguage : languages) {
+ if(curLanguage.getName().equalsIgnoreCase(languageName)) {
+ language = curLanguage;
+ break;
+ }
+ }
+ if(language == null) {
+ throw new MojoExecutionException(
+ "Unable to find language output module '" + languageName + "' on modules classpath");
+ }
+
+ try {
+ // Parse the type definitions.
+ Map<String, ComplexTypeDefinition> types = protocol.getTypeDefinitions();
+
+ // Generate output for the type definitions.
+ language.generate(outputDir, "org.apache.plc4x." + languageName.toLowerCase() +
+ "." + protocolName.toLowerCase(), types);
+ } catch (GenerationException e) {
+ getLog().error("Error generating sources", e);
+ }
+
+ // Add the generated sources to the project internally.
+ project.addCompileSourceRoot(outputDir.getPath());
+ }
+
+}
diff --git a/plc4x-maven-plugin/src/site/asciidoc/index.adoc b/plc4x-maven-plugin/src/site/asciidoc/index.adoc
new file mode 100644
index 0000000..f5e41cd
--- /dev/null
+++ b/plc4x-maven-plugin/src/site/asciidoc/index.adoc
@@ -0,0 +1,20 @@
+//
+// 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.
+//
+:imagesdir: img/
+:icons: font
+
+== PLC4X Maven Plugin
diff --git a/plc4x-maven-plugin/src/site/asciidoc/message-format-language.adoc b/plc4x-maven-plugin/src/site/asciidoc/message-format-language.adoc
new file mode 100644
index 0000000..95f7fb7
--- /dev/null
+++ b/plc4x-maven-plugin/src/site/asciidoc/message-format-language.adoc
@@ -0,0 +1,21 @@
+//
+// 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.
+//
+:imagesdir: img/
+:icons: font
+
+== PLC4X Message-Format-Definition-Language
+
diff --git a/plc4x-maven-plugin/src/test/java/org/apache/plc4x/plugins/codegenerator/GenerateMojoTest.java b/plc4x-maven-plugin/src/test/java/org/apache/plc4x/plugins/codegenerator/GenerateMojoTest.java
new file mode 100644
index 0000000..5846f38
--- /dev/null
+++ b/plc4x-maven-plugin/src/test/java/org/apache/plc4x/plugins/codegenerator/GenerateMojoTest.java
@@ -0,0 +1,87 @@
+/*
+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.plugins.codegenerator;
+
+import org.apache.maven.plugin.testing.MojoRule;
+import org.apache.maven.plugin.testing.WithoutMojo;
+import org.apache.maven.plugin.testing.resources.TestResources;
+import org.apache.maven.project.MavenProject;
+import org.junit.Ignore;
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class GenerateMojoTest {
+
+ @Rule
+ public MojoRule rule = new MojoRule();
+
+ @Rule
+ public TestResources testResources = new TestResources();
+
+ /**
+ * @throws Exception if any
+ */
+ @Test
+ @Ignore
+ public void testEmbeddedSchema() throws Exception {
+ File baseDir = testResources.getBasedir("simple-embedded-schema");
+ MavenProject project = rule.readMavenProject(baseDir);
+
+ GenerateMojo generateMojo = (GenerateMojo) rule.lookupConfiguredMojo(project, "generate-driver");
+ assertNotNull(generateMojo);
+ generateMojo.execute();
+
+ File outputDirectory = (File) rule.getVariableValueFromObject(generateMojo, "outputDir");
+ assertNotNull(outputDirectory);
+ assertTrue(outputDirectory.exists());
+ }
+
+ /**
+ * @throws Exception if any
+ */
+ @Test
+ public void testExternalSchema() throws Exception {
+ File baseDir = testResources.getBasedir("s7-external-schema");
+ MavenProject project = rule.readMavenProject(baseDir);
+
+/* GenerateMojo generateMojo = (GenerateMojo) rule.lookupConfiguredMojo(project, "generate-driver");
+ assertNotNull(generateMojo);
+ generateMojo.execute();
+
+ File outputDirectory = (File) rule.getVariableValueFromObject(generateMojo, "outputDir");
+ assertNotNull(outputDirectory);
+ assertTrue(outputDirectory.exists());*/
+ }
+
+ /**
+ * Do not need the MojoRule.
+ */
+ @WithoutMojo
+ @Test
+ public void testSomethingWhichDoesNotNeedTheMojoAndProbablyShouldBeExtractedIntoANewClassOfItsOwn() {
+ assertTrue(true);
+ }
+
+}
+
diff --git a/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/pom.xml b/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/pom.xml
new file mode 100644
index 0000000..c8a28ea
--- /dev/null
+++ b/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/pom.xml
@@ -0,0 +1,48 @@
+<?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>
+
+ <groupId>org.apache.plc4x.plugins.ut</groupId>
+ <artifactId>test-plc4x-maven-plugin-embedded-schema</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <name>Test GenerateMojo with embedded DFDL schema</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.plc4x.plugins</groupId>
+ <artifactId>plc4x-maven-plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <configuration>
+ <messageFormatSchema>${pom.basedir}/src/main/resources/protocol.spec</messageFormatSchema>
+ <packageName>org.apache.plc4x.test</packageName>
+ <templates>
+ <tempate>${pom.basedir}/src/main/resources/template.ftlh</tempate>
+ </templates>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/src/main/resources/protocol.spec b/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/src/main/resources/protocol.spec
new file mode 100644
index 0000000..5c4aae1
--- /dev/null
+++ b/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/src/main/resources/protocol.spec
@@ -0,0 +1,222 @@
+//
+// 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.
+//
+
+////////////////////////////////////////////////////////////////
+// IsoOnTcp/TPKT
+////////////////////////////////////////////////////////////////
+
+[type 'TPKTPacket'
+ [const uint 8 'protocolId' '0x3']
+ [reserved uint 8 '0x0']
+ [implicit uint 16 'len' 'payload.size + 4']
+ [field COTPPacket 'payload' {payloadLength: 'len - 4'}]
+]
+
+////////////////////////////////////////////////////////////////
+// COTP
+////////////////////////////////////////////////////////////////
+
+[discriminatedType 'COTPPacket' ['payloadLength']
+ [implicit uint 8 'headerLength' 'this.size - (payload.size + 1)']
+ [discriminator uint 8 'tpduCode']
+ [typeSwitch 'tpduCode'
+ ['0xF0' Data
+ [field bit 'eot']
+ [field uint 7 'tpduRef']
+ ]
+ ['0xE0' ConnectionRequest
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ [field uint 8 'protocolClass']
+ ]
+ ['0xD0' ConnectionResponse
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ [field uint 8 'protocolClass']
+ ]
+ ['0x80' DisconnectRequest
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ [field uint 8 'protocolClass']
+ ]
+ ['0xC0' DisconnectResponse
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ ]
+ ['0x70' TpduError
+ [field uint 16 'destinationReference']
+ [field uint 8 'rejectCause']
+ ]
+ ]
+ [arrayField COTPParameter 'parameters' length '(headerLength + 1) - cur']
+ [field S7Message 'payload' {payloadLength: 'payloadLength - (headerLength + 1)'}]
+]
+
+[discriminatedType 'COTPParameter'
+ [discriminator uint 8 'parameterType']
+ [typeSwitch 'parameterType'
+ ['0xC0' TpduSize
+ [field uint 8 'tpduSize']
+ ]
+ ['0xC1' CallingTsap
+ [field uint 16 'tsapId']
+ ]
+ ['0xC2' CalledTsap
+ [field uint 16 'tsapId']
+ ]
+ ['0xC3' Checksum
+ [field uint 8 'checksum']
+ ]
+ ['0xE0' DisconnectAdditionalInformation
+ [arrayField uint 8 'data' count 'rest']
+ ]
+ ]
+]
+
+////////////////////////////////////////////////////////////////
+// S7
+////////////////////////////////////////////////////////////////
+
+[discriminatedType 'S7Message' ['payloadLength']
+ [const uint 8 'protocolId' '0x32']
+ [discriminator uint 8 'messageType']
+ [reserved uint 16 '0x00']
+ [field uint 16 'tpduReference']
+ [implicit uint 16 'parameterLength' 'parameter.size']
+ [implicit uint 16 'payloadLength' 'payload.size']
+ [typeSwitch 'messageType'
+ ['0x01' Request
+ [context string 'messageType' 'request']
+ ]
+ ['0x03' Response
+ [context string 'messageType' 'response']
+ [field uint 8 'errorClass']
+ [field uint 8 'errorCode']
+ ]
+ ['0x07' UserData
+ [context string 'messageType' 'userData']
+ ]
+ ]
+ [optionalField S7Parameter 'parameter' 'parameterLength > 0' {messageType: 'messageType'}]
+ [optionalField S7Payload 'payload' 'payloadLength > 0' {messageType: 'messageType', parameter: 'parameter'}]
+]
+
+////////////////////////////////////////////////////////////////
+// Parameters
+
+[discriminatedType 'S7Parameter' ['messageType']
+ [discriminator uint 8 'parameterType']
+ [typeSwitch 'parameterType','messageType'
+ ['0xF0' SetupCommunication
+ [reserved uint 8 '0x0']
+ [field uint 16 'maxAmqCaller']
+ [field uint 16 'maxAmqCallee']
+ [field uint 16 'pduLength']
+ ]
+ ['0x04','request' ReadVarRequest
+ [implicit uint 8 'numItems' 'items.size']
+ [arrayField S7VarRequestParameterItem 'items' count 'numItems']
+ ]
+ ['0x04','response' ReadVarResponse
+ [field uint 8 'numItems']
+ ]
+ ['0x05','request' WriteVarRequest
+ [implicit uint 8 'numItems' 'items.size']
+ [arrayField S7VarRequestParameterItem 'items' count 'numItems']
+ ]
+ ['0x05','response' WriteVarResponse
+ [field uint 8 'numItems']
+ ]
+ ['0x00','userData' UserData
+ [implicit uint 8 'numItems' 'items.size']
+ [arrayField UserDataItem 'items' count 'numItems']
+ ]
+ ]
+]
+
+[discriminatedType 'S7VarRequestParameterItem'
+ [discriminator uint 8 'parameterItemType']
+ [typeSwitch 'parameterItemType'
+ ['0x12' Address
+ [implicit uint 8 'addressLength' 'address.size']
+ [field S7Address 'address']
+ ]
+ ]
+]
+
+[discriminatedType 'S7Address'
+ [discriminator uint 8 'addressType']
+ [typeSwitch 'addressType'
+ ['0x10' Any
+ [field uint 8 'transportSize']
+ [field uint 16 'numberOfElements']
+ [field uint 8 'dbNumber']
+ [field uint 8 'area']
+ [reserved uint 5 '0x0']
+ [field uint 16 'byteAddress']
+ [field uint 3 'bitAddress']
+ ]
+ ]
+]
+
+// TODO: CPUFunctions still need some love ...
+[discriminatedType 'UserDataItem'
+ [discriminator uint 8 'itemType']
+ [typeSwitch 'itemType'
+ ['0x12' CPUFunctions
+ [implicit uint 8 'parameterLength' 'size']
+ [field uint 16 'cpuFunctionType']
+ [field uint 8 'subFunctionGroup']
+ [field uint 8 'sequenceNumber']
+ [optionalField uint 8 'dataUnitReferenceNumber' 'parameterLength == 8']
+ [optionalField uint 8 'lastDataUnit' 'parameterLength == 8']
+ [optionalField uint 8 'errorCode' 'parameterLength == 8']
+ ]
+ ]
+]
+
+////////////////////////////////////////////////////////////////
+// Payloads
+
+[discriminatedType 'S7Payload' ['messageType', 'parameter']
+ [typeSwitch 'parameter.parameterType', 'messageType'
+ ['0x04','response' ReadVarResponse
+ [arrayField S7VarPayloadDataItem 'items' count 'parameter.numItems']
+ ]
+ ['0x05','request' WriteVarRequest
+ [arrayField S7VarPayloadDataItem 'items' count 'parameter.numItems']
+ ]
+ ['0x05','response' WriteVarResponse
+ [arrayField S7VarPayloadStatusItem 'items' count 'parameter.numItems']
+ ]
+ ['0x00','userData' UserData
+ ]
+ ]
+]
+
+[type 'S7VarPayloadDataItem'
+ [field uint 8 'returnCode']
+ [field uint 8 'transportSize']
+ [field uint 16 'dataLength']
+ [arrayField uint 8 'data' count 'dataLength']
+]
+
+[type 'S7VarPayloadStatusItem'
+ [field uint 8 'returnCode']
+]
\ No newline at end of file
diff --git a/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/src/main/resources/template.ftlh b/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/src/main/resources/template.ftlh
new file mode 100644
index 0000000..42e782a
--- /dev/null
+++ b/plc4x-maven-plugin/src/test/projects/simple-embedded-schema/src/main/resources/template.ftlh
@@ -0,0 +1,59 @@
+<#--
+ 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.
+-->
+${packageName?replace(".", "/")}/${typeName}.java
+/*
+ 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 ${packageName};
+
+public class ${typeName} {
+
+<#list type.simpleFields as simpleField>
+ private final ${simpleField.type.name} ${simpleField.name};
+</#list>
+
+ public ${typeName}(<#list type.simpleFields as simpleField>${simpleField.type.name} ${simpleField.name}<#sep>, </#sep></#list>) {
+<#list type.simpleFields as simpleField>
+ this.${simpleField.name} = ${simpleField.name};
+</#list>
+ }
+
+<#list type.simpleFields as simpleField>
+ public ${simpleField.type.name} get${simpleField.name?cap_first}() {
+ return ${simpleField.name};
+ }
+
+</#list>
+}
\ No newline at end of file
diff --git a/plc4x-maven-plugin/src/test/resources/specs/s7.spec b/plc4x-maven-plugin/src/test/resources/specs/s7.spec
new file mode 100644
index 0000000..1f4b52e
--- /dev/null
+++ b/plc4x-maven-plugin/src/test/resources/specs/s7.spec
@@ -0,0 +1,219 @@
+//
+// 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.
+//
+
+////////////////////////////////////////////////////////////////
+// IsoOnTcp/TPKT
+////////////////////////////////////////////////////////////////
+
+[type 'TPKTPacket'
+ [const uint 8 'protocolId' '0x03']
+ [reserved uint 8 '0x00']
+ [implicit uint 16 'len' 'payload.size + 4']
+ [field COTPPacket 'payload']
+]
+
+////////////////////////////////////////////////////////////////
+// COTP
+////////////////////////////////////////////////////////////////
+
+[discriminatedType 'COTPPacket'
+ [implicit uint 8 'headerLength' 'this.size - (payload.size + 1)']
+ [discriminator uint 8 'tpduCode']
+ [typeSwitch 'tpduCode'
+ ['0xF0' COTPPacketData
+ [field bit 'eot']
+ [field uint 7 'tpduRef']
+ ]
+ ['0xE0' COTPPacketConnectionRequest
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ [field uint 8 'protocolClass']
+ ]
+ ['0xD0' COTPPacketConnectionResponse
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ [field uint 8 'protocolClass']
+ ]
+ ['0x80' COTPPacketDisconnectRequest
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ [field uint 8 'protocolClass']
+ ]
+ ['0xC0' COTPPacketDisconnectResponse
+ [field uint 16 'destinationReference']
+ [field uint 16 'sourceReference']
+ ]
+ ['0x70' COTPPacketTpduError
+ [field uint 16 'destinationReference']
+ [field uint 8 'rejectCause']
+ ]
+ ]
+ [arrayField COTPParameter 'parameters' length '(headerLength + 1) - cur']
+ [field S7Message 'payload']
+]
+
+[discriminatedType 'COTPParameter'
+ [discriminator uint 8 'parameterType']
+ [typeSwitch 'parameterType'
+ ['0xC0' COTPParameterTpduSize
+ [field uint 8 'tpduSize']
+ ]
+ ['0xC1' COTPParameterCallingTsap
+ [field uint 16 'tsapId']
+ ]
+ ['0xC2' COTPParameterCalledTsap
+ [field uint 16 'tsapId']
+ ]
+ ['0xC3' COTPParameterChecksum
+ [field uint 8 'checksum']
+ ]
+ ['0xE0' COTPParameterDisconnectAdditionalInformation
+ [arrayField uint 8 'data' count 'rest']
+ ]
+ ]
+]
+
+////////////////////////////////////////////////////////////////
+// S7
+////////////////////////////////////////////////////////////////
+
+[discriminatedType 'S7Message'
+ [const uint 8 'protocolId' '0x32']
+ [discriminator uint 8 'messageType']
+ [reserved uint 16 '0x0000']
+ [field uint 16 'tpduReference']
+ [implicit uint 16 'parameterLength' 'parameters.size']
+ [implicit uint 16 'payloadLength' 'payloads.size']
+ [typeSwitch 'messageType'
+ ['0x01' S7MessageRequest
+ ]
+ ['0x03' S7MessageResponse
+ [field uint 8 'errorClass']
+ [field uint 8 'errorCode']
+ ]
+ ['0x07' S7MessageUserData
+ ]
+ ]
+ [field S7Parameter 'parameter' ['messageType']]
+ [field S7Payload 'payload' ['messageType', 'parameter']]
+]
+
+////////////////////////////////////////////////////////////////
+// Parameters
+
+[discriminatedType 'S7Parameter' [uint 8 'messageType']
+ [discriminator uint 8 'parameterType']
+ [typeSwitch 'parameterType','messageType'
+ ['0xF0' SetupCommunication
+ [reserved uint 8 '0x00']
+ [field uint 16 'maxAmqCaller']
+ [field uint 16 'maxAmqCallee']
+ [field uint 16 'pduLength']
+ ]
+ ['0x04','0x01' S7ParameterReadVarRequest
+ [implicit uint 8 'numItems' 'items.size']
+ [arrayField S7VarRequestParameterItem 'items' count 'numItems']
+ ]
+ ['0x04','0x03' S7ParameterReadVarResponse
+ [field uint 8 'numItems']
+ ]
+ ['0x05','0x01' S7ParameterWriteVarRequest
+ [implicit uint 8 'numItems' 'items.size']
+ [arrayField S7VarRequestParameterItem 'items' count 'numItems']
+ ]
+ ['0x05','0x03' S7ParameterWriteVarResponse
+ [field uint 8 'numItems']
+ ]
+ ['0x00','0x07' S7ParameterUserData
+ [implicit uint 8 'numItems' 'items.size']
+ [arrayField UserDataItem 'items' count 'numItems']
+ ]
+ ]
+]
+
+[discriminatedType 'S7VarRequestParameterItem'
+ [discriminator uint 8 'parameterItemType']
+ [typeSwitch 'parameterItemType'
+ ['0x12' S7VarRequestParameterItemAddress
+ [implicit uint 8 'addressLength' 'address.size']
+ [field S7Address 'address']
+ ]
+ ]
+]
+
+[discriminatedType 'S7Address'
+ [discriminator uint 8 'addressType']
+ [typeSwitch 'addressType'
+ ['0x10' S7AddressAny
+ [field uint 8 'transportSize']
+ [field uint 16 'numberOfElements']
+ [field uint 8 'dbNumber']
+ [field uint 8 'area']
+ [reserved uint 5 '0x00']
+ [field uint 16 'byteAddress']
+ [field uint 3 'bitAddress']
+ ]
+ ]
+]
+
+// TODO: CPUFunctions still need some love ...
+[discriminatedType 'UserDataItem'
+ [discriminator uint 8 'itemType']
+ [typeSwitch 'itemType'
+ ['0x12' UserDataItemCPUFunctions
+ [implicit uint 8 'parameterLength' 'size']
+ [field uint 16 'cpuFunctionType']
+ [field uint 8 'subFunctionGroup']
+ [field uint 8 'sequenceNumber']
+ [optionalField uint 8 'dataUnitReferenceNumber' 'parameterLength == 8']
+ [optionalField uint 8 'lastDataUnit' 'parameterLength == 8']
+ [optionalField uint 8 'errorCode' 'parameterLength == 8']
+ ]
+ ]
+]
+
+////////////////////////////////////////////////////////////////
+// Payloads
+
+[discriminatedType 'S7Payload' [uint 8 'messageType', S7Parameter 'parameter']
+ [typeSwitch 'parameter.parameterType', 'messageType'
+ ['0x04','response' S7PayloadReadVarResponse
+ [arrayField S7VarPayloadDataItem 'items' count 'parameter.numItems']
+ ]
+ ['0x05','request' S7PayloadWriteVarRequest
+ [arrayField S7VarPayloadDataItem 'items' count 'parameter.numItems']
+ ]
+ ['0x05','response' S7PayloadWriteVarResponse
+ [arrayField S7VarPayloadStatusItem 'items' count 'parameter.numItems']
+ ]
+ ['0x00','userData' S7PayloadUserData
+ ]
+ ]
+]
+
+[type 'S7VarPayloadDataItem'
+ [field uint 8 'returnCode']
+ [field uint 8 'transportSize']
+ [field uint 16 'dataLength']
+ [arrayField uint 8 'data' count 'dataLength']
+]
+
+[type 'S7VarPayloadStatusItem'
+ [field uint 8 'returnCode']
+]
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..b15d1e7
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,113 @@
+<?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>
+
+ <!--
+ This is intentionally set to the apache parent as this way
+ we can release this module separately from the rest of the project
+ -->
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>21</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.apache.plc4x.plugins</groupId>
+ <artifactId>plc4x-code-generaton-external</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>Sandbox: Code Generation: External</name>
+ <description>This module groups all the modules that will be moved outside the core repository.</description>
+
+ <properties>
+ <maven.version>3.3.9</maven.version>
+ <java.version>1.8</java.version>
+ </properties>
+
+ <prerequisites>
+ <maven>${maven.version}</maven>
+ </prerequisites>
+
+ <modules>
+ <module>types-base</module>
+ <module>language-base</module>
+ <module>protocol-base</module>
+ <module>plc4x-maven-plugin</module>
+ </modules>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-clean-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>3.0.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.8.0</version>
+ <configuration>
+ <source>${java.version}</source>
+ <target>${java.version}</target>
+ <testSource>${java.version}</testSource>
+ <testTarget>${java.version}</testTarget>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.6.0</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.1</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.0.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-install-plugin</artifactId>
+ <version>2.5.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.8.2</version>
+ </plugin>
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <version>3.1.0</version>
+ </plugin>
+ <plugin>
+ <groupId>org.antlr</groupId>
+ <artifactId>antlr4-maven-plugin</artifactId>
+ <version>${antlr.version}</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/protocol-base/pom.xml b/protocol-base/pom.xml
new file mode 100644
index 0000000..c8ea9a4
--- /dev/null
+++ b/protocol-base/pom.xml
@@ -0,0 +1,43 @@
+<?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>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>plc4x-code-generation-protocol-base</artifactId>
+
+ <name>Sandbox: Code Generation: Protocol Base</name>
+ <description>Base stuff for building protocols</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.plc4x.plugins</groupId>
+ <artifactId>plc4x-code-generation-types-base</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/protocol-base/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/Protocol.java b/protocol-base/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/Protocol.java
new file mode 100644
index 0000000..a55b5ad
--- /dev/null
+++ b/protocol-base/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/Protocol.java
@@ -0,0 +1,44 @@
+/*
+ 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.plugins.codegenerator.protocol;
+
+import org.apache.plc4x.plugins.codegenerator.types.definitions.ComplexTypeDefinition;
+import org.apache.plc4x.plugins.codegenerator.types.exceptions.GenerationException;
+
+import java.util.Map;
+
+public interface Protocol {
+
+ /**
+ * The name of the protocol what the plugin will use to select the correct protocol module.
+ *
+ * @return the name of the protocol.
+ */
+ String getName();
+
+ /**
+ * Returns a map of complex type definitions for which code has to be generated.
+ *
+ * @return the Map of types that need to be generated.
+ * @throws GenerationException if anything goes wrong parsing.
+ */
+ Map<String, ComplexTypeDefinition> getTypeDefinitions() throws GenerationException;
+
+}
diff --git a/types-base/pom.xml b/types-base/pom.xml
new file mode 100644
index 0000000..d5f2aa9
--- /dev/null
+++ b/types-base/pom.xml
@@ -0,0 +1,35 @@
+<?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>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>plc4x-code-generation-types-base</artifactId>
+
+ <name>Sandbox: Code Generation: Base Types</name>
+ <description>Base used throughout the code-generation.</description>
+
+</project>
\ No newline at end of file
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/Argument.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/Argument.java
new file mode 100644
index 0000000..3564015
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/Argument.java
@@ -0,0 +1,42 @@
+/*
+ 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.plugins.codegenerator.types.definitions;
+
+import org.apache.plc4x.plugins.codegenerator.types.references.TypeReference;
+
+public class Argument {
+
+ private final TypeReference type;
+ private final String name;
+
+ public Argument(TypeReference type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ public TypeReference getType() {
+ return type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/ComplexTypeDefinition.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/ComplexTypeDefinition.java
new file mode 100644
index 0000000..81edc53
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/ComplexTypeDefinition.java
@@ -0,0 +1,75 @@
+/*
+ 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.plugins.codegenerator.types.definitions;
+
+import org.apache.plc4x.plugins.codegenerator.types.fields.ConstField;
+import org.apache.plc4x.plugins.codegenerator.types.fields.Field;
+import org.apache.plc4x.plugins.codegenerator.types.fields.PropertyField;
+import org.apache.plc4x.plugins.codegenerator.types.fields.SimpleField;
+
+import java.util.List;
+
+public interface ComplexTypeDefinition extends TypeDefinition {
+
+ boolean isAbstract();
+
+ /**
+ * Get all fields no matter the type.
+ *
+ * @return all fields ;-)
+ */
+ List<Field> getFields();
+
+ /**
+ * Get only the fields which are of type SimpleField.
+ *
+ * @return all simple fields ;-)
+ */
+ List<SimpleField> getSimpleFields();
+
+ /**
+ * Get only the fields which are of type ConstField.
+ *
+ * @return all constant fields ;-)
+ */
+ List<ConstField> getConstFields();
+
+ /**
+ * Get only the fields which are of type SimpleField or OptionalField.
+ *
+ * @return all simple and optional fields ;-)
+ */
+ List<PropertyField> getPropertyFields();
+
+ /**
+ * In contrast to getFields, this also gets all property fields of any parent type.
+ *
+ * @return all simple fields including any parents simple fields
+ */
+ List<PropertyField> getAllPropertyFields();
+
+ /**
+ * Returns all protery fields defined by any parent type.
+ *
+ * @return all parent types simple fields.
+ */
+ List<PropertyField> getParentPropertyFields();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/DiscriminatedComplexTypeDefinition.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/DiscriminatedComplexTypeDefinition.java
new file mode 100644
index 0000000..f547354
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/DiscriminatedComplexTypeDefinition.java
@@ -0,0 +1,26 @@
+/*
+ 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.plugins.codegenerator.types.definitions;
+
+public interface DiscriminatedComplexTypeDefinition extends ComplexTypeDefinition {
+
+ String[] getDiscriminatorValues();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/EnumTypeDefinition.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/EnumTypeDefinition.java
new file mode 100644
index 0000000..9153988
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/EnumTypeDefinition.java
@@ -0,0 +1,48 @@
+/*
+ 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.plugins.codegenerator.types.definitions;
+
+import java.util.List;
+
+public interface EnumTypeDefinition extends TypeDefinition {
+
+ TypeDefinition getBaseType();
+
+ List<EnumValue> getValues();
+
+ class EnumValue {
+ private final String name;
+ private final Object value;
+
+ public EnumValue(String name, Object value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/TypeDefinition.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/TypeDefinition.java
new file mode 100644
index 0000000..806436b
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/definitions/TypeDefinition.java
@@ -0,0 +1,30 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+package org.apache.plc4x.plugins.codegenerator.types.definitions;
+
+public interface TypeDefinition {
+
+ String getName();
+
+ Argument[] getParserArguments();
+
+ TypeDefinition getParentType();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/exceptions/GenerationException.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/exceptions/GenerationException.java
new file mode 100644
index 0000000..c387df1
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/exceptions/GenerationException.java
@@ -0,0 +1,32 @@
+/*
+ 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.plugins.codegenerator.types.exceptions;
+
+public class GenerationException extends Exception {
+
+ public GenerationException(String message) {
+ super(message);
+ }
+
+ public GenerationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ArrayField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ArrayField.java
new file mode 100644
index 0000000..2023e0c
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ArrayField.java
@@ -0,0 +1,40 @@
+/*
+ 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.plugins.codegenerator.types.fields;
+
+
+import org.apache.plc4x.plugins.codegenerator.types.terms.Term;
+
+public interface ArrayField extends PropertyField {
+
+ default String getTypeName() {
+ return "array";
+ }
+
+ LengthType getLengthType();
+
+ Term getLengthExpression();
+
+ enum LengthType {
+ COUNT,
+ LENGTH
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ConstField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ConstField.java
new file mode 100644
index 0000000..9c0029f
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ConstField.java
@@ -0,0 +1,30 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+package org.apache.plc4x.plugins.codegenerator.types.fields;
+
+public interface ConstField extends PropertyField {
+
+ default String getTypeName() {
+ return "const";
+ }
+
+ Object getReferenceValue();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/DiscriminatorField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/DiscriminatorField.java
new file mode 100644
index 0000000..c5c0552
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/DiscriminatorField.java
@@ -0,0 +1,30 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+package org.apache.plc4x.plugins.codegenerator.types.fields;
+
+public interface DiscriminatorField extends TypedField {
+
+ default String getTypeName() {
+ return "discriminator";
+ }
+
+ String getName();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/Field.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/Field.java
new file mode 100644
index 0000000..5863cc4
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/Field.java
@@ -0,0 +1,27 @@
+/*
+ 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.plugins.codegenerator.types.fields;
+
+public interface Field {
+
+ String getTypeName();
+ String[] getParams();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ImplicitField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ImplicitField.java
new file mode 100644
index 0000000..1cc5f97
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ImplicitField.java
@@ -0,0 +1,34 @@
+/*
+ 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.plugins.codegenerator.types.fields;
+
+import org.apache.plc4x.plugins.codegenerator.types.terms.Term;
+
+public interface ImplicitField extends TypedField {
+
+ default String getTypeName() {
+ return "implicit";
+ }
+
+ String getName();
+
+ Term getSerializationExpression();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/OptionalField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/OptionalField.java
new file mode 100644
index 0000000..ecef3be
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/OptionalField.java
@@ -0,0 +1,33 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+package org.apache.plc4x.plugins.codegenerator.types.fields;
+
+
+import org.apache.plc4x.plugins.codegenerator.types.terms.Term;
+
+public interface OptionalField extends PropertyField {
+
+ default String getTypeName() {
+ return "optional";
+ }
+
+ Term getConditionExpression();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/PropertyField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/PropertyField.java
new file mode 100644
index 0000000..b336f4f
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/PropertyField.java
@@ -0,0 +1,26 @@
+/*
+ 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.plugins.codegenerator.types.fields;
+
+public interface PropertyField extends TypedField {
+
+ String getName();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ReservedField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ReservedField.java
new file mode 100644
index 0000000..5426d48
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ReservedField.java
@@ -0,0 +1,30 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+package org.apache.plc4x.plugins.codegenerator.types.fields;
+
+public interface ReservedField extends TypedField {
+
+ default String getTypeName() {
+ return "reserved";
+ }
+
+ Object getReferenceValue();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/SimpleField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/SimpleField.java
new file mode 100644
index 0000000..966faac
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/SimpleField.java
@@ -0,0 +1,28 @@
+/*
+ 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.plugins.codegenerator.types.fields;
+
+public interface SimpleField extends PropertyField {
+
+ default String getTypeName() {
+ return "simple";
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/SwitchField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/SwitchField.java
new file mode 100644
index 0000000..a6b4df7
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/SwitchField.java
@@ -0,0 +1,36 @@
+/*
+ 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.plugins.codegenerator.types.fields;
+
+import org.apache.plc4x.plugins.codegenerator.types.definitions.DiscriminatedComplexTypeDefinition;
+
+import java.util.List;
+
+public interface SwitchField extends Field {
+
+ default String getTypeName() {
+ return "switch";
+ }
+
+ String[] getDiscriminatorNames();
+
+ List<DiscriminatedComplexTypeDefinition> getCases();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/TypedField.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/TypedField.java
new file mode 100644
index 0000000..4bb2006
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/TypedField.java
@@ -0,0 +1,28 @@
+/*
+ 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.plugins.codegenerator.types.fields;
+
+import org.apache.plc4x.plugins.codegenerator.types.references.TypeReference;
+
+public interface TypedField extends Field {
+
+ TypeReference getType();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/ComplexTypeReference.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/ComplexTypeReference.java
new file mode 100644
index 0000000..bc760ea
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/ComplexTypeReference.java
@@ -0,0 +1,26 @@
+/*
+ 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.plugins.codegenerator.types.references;
+
+public interface ComplexTypeReference extends TypeReference {
+
+ String getName();
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/SimpleTypeReference.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/SimpleTypeReference.java
new file mode 100644
index 0000000..834033d
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/SimpleTypeReference.java
@@ -0,0 +1,37 @@
+/*
+ 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.plugins.codegenerator.types.references;
+
+public interface SimpleTypeReference extends TypeReference {
+
+ SimpleBaseType getBaseType();
+
+ int getSize();
+
+ enum SimpleBaseType {
+
+ BIT,
+ UINT,
+ INT,
+ FLOAT,
+ STRING
+
+ }
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/SimpleVarLengthTypeReference.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/SimpleVarLengthTypeReference.java
new file mode 100644
index 0000000..052ca91
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/SimpleVarLengthTypeReference.java
@@ -0,0 +1,24 @@
+/*
+ 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.plugins.codegenerator.types.references;
+
+public interface SimpleVarLengthTypeReference {
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/TypeReference.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/TypeReference.java
new file mode 100644
index 0000000..3c33b3e
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/references/TypeReference.java
@@ -0,0 +1,24 @@
+/*
+ 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.plugins.codegenerator.types.references;
+
+public interface TypeReference {
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/BinaryTerm.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/BinaryTerm.java
new file mode 100644
index 0000000..534a8cb
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/BinaryTerm.java
@@ -0,0 +1,51 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public class BinaryTerm implements Term {
+
+ private final Term a;
+ private final Term b;
+ private final String operation;
+
+ public BinaryTerm(Term a, Term b, String operation) {
+ this.a = a;
+ this.b = b;
+ this.operation = operation;
+ }
+
+ public Term getA() {
+ return a;
+ }
+
+ public Term getB() {
+ return b;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ @Override
+ public boolean contains(String str) {
+ return ((a != null) && a.contains(str)) || ((b != null) && b.contains(str));
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/BooleanLiteral.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/BooleanLiteral.java
new file mode 100644
index 0000000..2ae9283
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/BooleanLiteral.java
@@ -0,0 +1,39 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public class BooleanLiteral implements Literal {
+
+ private final boolean value;
+
+ public BooleanLiteral(boolean value) {
+ this.value = value;
+ }
+
+ public boolean getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean contains(String str) {
+ return false;
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/Literal.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/Literal.java
new file mode 100644
index 0000000..225ec37
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/Literal.java
@@ -0,0 +1,23 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public interface Literal extends Term {
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/NullLiteral.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/NullLiteral.java
new file mode 100644
index 0000000..153acc7
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/NullLiteral.java
@@ -0,0 +1,32 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public class NullLiteral implements Literal {
+
+ public NullLiteral() {
+ }
+
+ @Override
+ public boolean contains(String str) {
+ return false;
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/NumericLiteral.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/NumericLiteral.java
new file mode 100644
index 0000000..320421c
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/NumericLiteral.java
@@ -0,0 +1,39 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public class NumericLiteral implements Literal {
+
+ private Number number;
+
+ public NumericLiteral(Number number) {
+ this.number = number;
+ }
+
+ public Number getNumber() {
+ return number;
+ }
+
+ @Override
+ public boolean contains(String str) {
+ return false;
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/StringLiteral.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/StringLiteral.java
new file mode 100644
index 0000000..f67982f
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/StringLiteral.java
@@ -0,0 +1,39 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public class StringLiteral implements Literal {
+
+ private final String value;
+
+ public StringLiteral(String value) {
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public boolean contains(String str) {
+ return (value != null) && value.contains(str);
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/Term.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/Term.java
new file mode 100644
index 0000000..389f6e4
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/Term.java
@@ -0,0 +1,26 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public interface Term {
+
+ boolean contains(String str);
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/TernaryTerm.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/TernaryTerm.java
new file mode 100644
index 0000000..484eb11
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/TernaryTerm.java
@@ -0,0 +1,57 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public class TernaryTerm implements Term {
+
+ private final Term a;
+ private final Term b;
+ private final Term c;
+ private final String operation;
+
+ public TernaryTerm(Term a, Term b, Term c, String operation) {
+ this.a = a;
+ this.b = b;
+ this.c = c;
+ this.operation = operation;
+ }
+
+ public Term getA() {
+ return a;
+ }
+
+ public Term getB() {
+ return b;
+ }
+
+ public Term getC() {
+ return c;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ @Override
+ public boolean contains(String str) {
+ return ((a != null) && a.contains(str)) || ((b != null) && b.contains(str)) ||((c != null) && c.contains(str));
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/UnaryTerm.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/UnaryTerm.java
new file mode 100644
index 0000000..27ec739
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/UnaryTerm.java
@@ -0,0 +1,45 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+public class UnaryTerm implements Term {
+
+ private final Term a;
+ private final String operation;
+
+ public UnaryTerm(Term a, String operation) {
+ this.a = a;
+ this.operation = operation;
+ }
+
+ public Term getA() {
+ return a;
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ @Override
+ public boolean contains(String str) {
+ return (a != null) && a.contains(str);
+ }
+
+}
diff --git a/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/VariableLiteral.java b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/VariableLiteral.java
new file mode 100644
index 0000000..68ece64
--- /dev/null
+++ b/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/terms/VariableLiteral.java
@@ -0,0 +1,75 @@
+/*
+ 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.plugins.codegenerator.types.terms;
+
+import java.util.List;
+
+public class VariableLiteral implements Literal {
+
+ public static final int NO_INDEX = -1;
+
+ private final String name;
+ private final List<Term> args;
+ private final int index;
+ private final VariableLiteral child;
+
+ public VariableLiteral(String name, List<Term> args, int index, VariableLiteral child) {
+ this.name = name;
+ this.args = args;
+ this.index = index;
+ this.child = child;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List<Term> getArgs() {
+ return args;
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public VariableLiteral getChild() {
+ return child;
+ }
+
+ public boolean isIndexed() {
+ return index != NO_INDEX;
+ }
+
+ @Override
+ public boolean contains(String str) {
+ if(((name != null) && name.contains(str)) || ((child != null) && child.contains(str))) {
+ return true;
+ }
+ if(args != null) {
+ for(Term arg : args) {
+ if(arg.contains(str)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}