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 2021/10/29 12:37:29 UTC

[plc4x] branch feature/mspec-ng updated: - Continued fixing issues releated to string types

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

cdutz pushed a commit to branch feature/mspec-ng
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/feature/mspec-ng by this push:
     new ccea2cf  - Continued fixing issues releated to string types
ccea2cf is described below

commit ccea2cf2d08f28d35aeaa38a0ffab46e32ae3160
Author: cdutz <ch...@c-ware.de>
AuthorDate: Fri Oct 29 14:37:17 2021 +0200

    - Continued fixing issues releated to string types
---
 .../language/java/JavaLanguageTemplateHelper.java  |  24 ++--
 .../templates/java/pojo-template.java.ftlh         |  22 ++--
 .../mspec/parser/MessageFormatListener.java        |  19 ++--
 .../ads/src/main/resources/protocols/ads/ads.mspec | 126 ++++++++++-----------
 .../s7/src/main/resources/protocols/s7/s7.mspec    |  50 ++++----
 .../resources/protocols/simulated/simulated.mspec  |  72 ++++++------
 6 files changed, 161 insertions(+), 152 deletions(-)

diff --git a/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java b/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
index 14bf2a9..0a98ff2 100644
--- a/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
+++ b/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
@@ -340,13 +340,17 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
             case STRING:
             case VSTRING:
                 String stringType = "String";
-                StringTypeReference stringTypeReference = (StringTypeReference) simpleTypeReference;
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if(!(encodingTerm instanceof StringLiteral)) {
                     throw new RuntimeException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
-                return "/*TODO: migrate me*/" + "readBuffer.read" + stringType + "(\"" + logicalName + "\", " + toParseExpression(field, stringTypeReference.getLengthExpression(), null) + ", \"" +
+                String length = Integer.toString(simpleTypeReference.getSizeInBits());
+                if(simpleTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.VSTRING) {
+                    VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
+                    length = toParseExpression(field, vstringTypeReference.getLengthExpression(), null);
+                }
+                return "/*TODO: migrate me*/" + "readBuffer.read" + stringType + "(\"" + logicalName + "\", " + length + ", \"" +
                     encoding + "\")";
         }
         return "/*TODO: migrate me*/" + "";
@@ -433,8 +437,10 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
                 if (sizeInBits <= 64) return "readDouble(readBuffer, " + sizeInBits + ")";
                 return "readBigDecimal(readBuffer, " + sizeInBits + ")";
             case STRING:
-            case VSTRING:
                 return "readString(readBuffer, " + sizeInBits + ")";
+            case VSTRING:
+                VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
+                return "readString(readBuffer, " + toParseExpression(null, vstringTypeReference.getLengthExpression(), null) + ")";
         }
         return "";
     }
@@ -497,13 +503,17 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
                 }
             case STRING:
             case VSTRING:
-                StringTypeReference stringTypeReference = (StringTypeReference) simpleTypeReference;
                 final Term encodingTerm = field.getEncoding().orElse(new DefaultStringLiteral("UTF-8"));
                 if(!(encodingTerm instanceof StringLiteral)) {
                     throw new RuntimeException("Encoding must be a quoted string value");
                 }
                 String encoding = ((StringLiteral) encodingTerm).getValue();
-                return "writeBuffer.writeString(\"" + logicalName + "\", " + toSerializationExpression(field, stringTypeReference.getLengthExpression(), thisType.getParserArguments().orElse(Collections.emptyList())) + ", \"" +
+                String length = Integer.toString(simpleTypeReference.getSizeInBits());
+                if(simpleTypeReference.getBaseType() == SimpleTypeReference.SimpleBaseType.VSTRING) {
+                    VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
+                    length = toSerializationExpression(field, vstringTypeReference.getLengthExpression(), thisType.getParserArguments().orElse(Collections.emptyList()));
+                }
+                return "writeBuffer.writeString(\"" + logicalName + "\", " + length + ", \"" +
                     encoding + "\", (String) " + fieldName + "" + writerArgsString + ")";
         }
         throw new FreemarkerException("Unmapped basetype" + simpleTypeReference.getBaseType());
@@ -961,8 +971,8 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
                     sb.append("(").append(toSerializationExpression(null, manualField.getLengthExpression(), parserArguments)).append(") + ");
                 } else if (type instanceof SimpleTypeReference) {
                     SimpleTypeReference simpleTypeReference = (SimpleTypeReference) type;
-                    if (simpleTypeReference instanceof StringTypeReference) {
-                        sb.append(toSerializationExpression(null, ((StringTypeReference) simpleTypeReference).getLengthExpression(), parserArguments)).append(" + ");
+                    if (simpleTypeReference instanceof VstringTypeReference) {
+                        sb.append(toSerializationExpression(null, ((VstringTypeReference) simpleTypeReference).getLengthExpression(), parserArguments)).append(" + ");
                     } else {
                         sizeInBits += simpleTypeReference.getSizeInBits();
                     }
diff --git a/code-generation/language-java/src/main/resources/templates/java/pojo-template.java.ftlh b/code-generation/language-java/src/main/resources/templates/java/pojo-template.java.ftlh
index 152208c..81e8aa2 100644
--- a/code-generation/language-java/src/main/resources/templates/java/pojo-template.java.ftlh
+++ b/code-generation/language-java/src/main/resources/templates/java/pojo-template.java.ftlh
@@ -215,7 +215,8 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
         // Discriminator Field (${discriminatorField.name})
         <#if helper.isSimpleTypeReference(discriminatorField.type)>
             <#assign simpleTypeReference = discriminatorField.type.asSimpleTypeReference().orElseThrow()>
-            <#if helper.getLanguageTypeNameForTypeReference(discriminatorField.type) = "String">
+            <#if simpleTypeReference.isVstringTypeReference()>
+                <#assign vstringTypeReference = simpleTypeReference.asVstringTypeReference().orElseThrow()>
         lengthInBits += ${helper.toSerializationExpression(discriminatorField, simpleTypeReference.getLengthExpression(), parserArguments)};
             <#else>
         lengthInBits += ${simpleTypeReference.sizeInBits};
@@ -259,8 +260,9 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
         if(${optionalField.name} != null) {
         <#if helper.isSimpleTypeReference(optionalField.type)>
             <#assign simpleTypeReference = optionalField.type.asSimpleTypeReference().orElseThrow()>
-            <#if helper.getLanguageTypeNameForTypeReference(optionalField.type) = "String">
-            lengthInBits += ${helper.toSerializationExpression(discriminatorField, simpleTypeReference.getLengthExpression(), parserArguments)};
+            <#if simpleTypeReference.isVstringTypeReference()>
+                <#assign vstringTypeReference = simpleTypeReference.asVstringTypeReference().orElseThrow()>
+            lengthInBits += ${helper.toSerializationExpression(optionalField, vstringTypeReference.getLengthExpression(), parserArguments)};
             <#else>
             lengthInBits += ${simpleTypeReference.sizeInBits};
             </#if>
@@ -293,14 +295,14 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
         <#assign simpleField = field.asSimpleField().orElseThrow()>
 
         // Simple field (${simpleField.name})
-        <#if helper.isSimpleTypeReference(simpleField.type)>
-                <#if helper.getLanguageTypeNameForTypeReference(simpleField.type) = "String">
-                    <#assign stringTypeReference = simpleField.type.asStringTypeReference().orElseThrow()>
-        lengthInBits += ${helper.toSerializationExpression(simpleField, stringTypeReference.getLengthExpression(), parserArguments)};
-                <#else>
-                    <#assign simpleTypeReference = simpleField.type.asSimpleTypeReference().orElseThrow()>
+        <#if simpleField.type.isSimpleTypeReference()>
+            <#assign simpleTypeReference = simpleField.type.asSimpleTypeReference().orElseThrow()>
+            <#if simpleTypeReference.isVstringTypeReference()>
+                <#assign vstringTypeReference = simpleTypeReference.asVstringTypeReference().orElseThrow()>
+        lengthInBits += ${helper.toSerializationExpression(simpleField, vstringTypeReference.getLengthExpression(), parserArguments)};
+            <#else>
         lengthInBits += ${simpleTypeReference.sizeInBits};
-                </#if>
+            </#if>
         <#elseif helper.isEnumField(field)>
         lengthInBits += ${helper.getEnumBaseTypeReference(simpleField.type).sizeInBits};
         <#else>
diff --git a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
index 211d234..b231ac6 100644
--- a/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
+++ b/code-generation/protocol-base-mspec/src/main/java/org/apache/plc4x/plugins/codegenerator/language/mspec/parser/MessageFormatListener.java
@@ -486,18 +486,12 @@ public class MessageFormatListener extends MSpecBaseListener {
         SimpleTypeReference.SimpleBaseType simpleBaseType =
             SimpleTypeReference.SimpleBaseType.valueOf(ctx.base.getText().toUpperCase());
         // String types need an additional length expression.
-        if ((simpleBaseType == SimpleTypeReference.SimpleBaseType.STRING) ||
-            (simpleBaseType == SimpleTypeReference.SimpleBaseType.VSTRING)) {
-            if (simpleBaseType == SimpleTypeReference.SimpleBaseType.VSTRING) {
-                if (ctx.length != null) {
-                    Term lengthExpression = getExpressionTerm(ctx.length);
-                    return new DefaultStringTypeReference(simpleBaseType, lengthExpression);
-                } else {
-                    return new DefaultStringTypeReference(simpleBaseType, null);
-                }
+        if (simpleBaseType == SimpleTypeReference.SimpleBaseType.VSTRING) {
+            if (ctx.length != null) {
+                Term lengthExpression = getExpressionTerm(ctx.length);
+                return new DefaultVstringTypeReference(simpleBaseType, lengthExpression);
             } else {
-                int size = Integer.parseInt(ctx.size.getText());
-                return new DefaultStringTypeReference(simpleBaseType, new DefaultNumericLiteral(size));
+                return new DefaultVstringTypeReference(simpleBaseType, null);
             }
         }
         switch (simpleBaseType) {
@@ -517,6 +511,9 @@ public class MessageFormatListener extends MSpecBaseListener {
                 return new DefaultBooleanTypeReference();
             case BYTE:
                 return new DefaultByteTypeReference();
+            case STRING:
+                int stringSize = Integer.parseInt(ctx.size.getText());
+                return new DefaultStringTypeReference(simpleBaseType, stringSize);
             default:
                 return new DefaultIntegerTypeReference(simpleBaseType, 1);
         }
diff --git a/protocols/ads/src/main/resources/protocols/ads/ads.mspec b/protocols/ads/src/main/resources/protocols/ads/ads.mspec
index 4b8221a..712e7b1 100644
--- a/protocols/ads/src/main/resources/protocols/ads/ads.mspec
+++ b/protocols/ads/src/main/resources/protocols/ads/ads.mspec
@@ -391,7 +391,7 @@
         // -----------------------------------------
         // Bit
         // -----------------------------------------
-        ['IEC61131_BOOL' BOOL
+        ['"IEC61131_BOOL"' BOOL
             [reserved uint 7 '0x00']
             [simple   bit    'value']
         ]
@@ -400,15 +400,15 @@
         // Bit-strings
         // -----------------------------------------
         // 1 byte
-        ['IEC61131_BYTE' BitString
+        ['"IEC61131_BYTE"' BitString
             [simple uint 8 'value']
         ]
         // 2 byte (16 bit)
-        ['IEC61131_WORD' BitString
+        ['"IEC61131_WORD"' BitString
             [simple uint 16 'value']
         ]
         // 4 byte (32 bit)
-        ['IEC61131_DWORD' BitString
+        ['"IEC61131_DWORD"' BitString
             [simple uint 32 'value']
         ]
 
@@ -416,58 +416,58 @@
         // Integers
         // -----------------------------------------
         // 8 bit:
-        ['IEC61131_SINT' SINT
+        ['"IEC61131_SINT"' SINT
             [simple int 8 'value']
         ]
-        ['IEC61131_USINT' USINT
+        ['"IEC61131_USINT"' USINT
             [simple uint 8 'value']
         ]
         // 16 bit:
-        ['IEC61131_INT' INT
+        ['"IEC61131_INT"' INT
             [simple int 16 'value']
         ]
-        ['IEC61131_UINT' UINT
+        ['"IEC61131_UINT"' UINT
             [simple uint 16 'value']
         ]
         // 32 bit:
-        ['IEC61131_DINT' DINT
+        ['"IEC61131_DINT"' DINT
             [simple int 32 'value']
         ]
-        ['IEC61131_UDINT' UDINT
+        ['"IEC61131_UDINT"' UDINT
             [simple uint 32 'value']
         ]
         // 64 bit:
-        ['IEC61131_LINT' LINT
+        ['"IEC61131_LINT"' LINT
             [simple int 64 'value']
         ]
-        ['IEC61131_ULINT' ULINT
+        ['"IEC61131_ULINT"' ULINT
             [simple uint 64 'value']
         ]
 
         // -----------------------------------------
         // Floating point values
         // -----------------------------------------
-        ['IEC61131_REAL' REAL
+        ['"IEC61131_REAL"' REAL
             [simple float 32  'value']
         ]
-        ['IEC61131_LREAL' LREAL
+        ['"IEC61131_LREAL"' LREAL
             [simple float 64 'value']
         ]
 
         // -----------------------------------------
         // Characters & Strings
         // -----------------------------------------
-        ['IEC61131_CHAR' STRING
+        ['"IEC61131_CHAR"' STRING
             [simple string 8 'value']
         ]
-        ['IEC61131_WCHAR' STRING
+        ['"IEC61131_WCHAR"' STRING
             [simple string 16 'value' encoding='"UTF-16"']
         ]
-        ['IEC61131_STRING' STRING
+        ['"IEC61131_STRING"' STRING
             // TODO: Fix this length
             [manual   vstring 'value' 'STATIC_CALL("org.apache.plc4x.java.ads.utils.StaticHelper.parseAmsString", readBuffer, stringLength, _type.encoding)' 'STATIC_CALL("org.apache.plc4x.java.ads.utils.StaticHelper.serializeAmsString", writeBuffer, _value, stringLength, _type.encoding)' 'stringLength + 1']
         ]
-        ['IEC61131_WSTRING' STRING
+        ['"IEC61131_WSTRING"' STRING
             // TODO: Fix this length
             [manual vstring 'value' 'STATIC_CALL("org.apache.plc4x.java.ads.utils.StaticHelper.parseAmsString", readBuffer, stringLength, _type.encoding)' 'STATIC_CALL("org.apache.plc4x.java.ads.utils.StaticHelper.serializeAmsString", writeBuffer, _value, stringLength, _type.encoding)' '(stringLength * 2) + 2' encoding='"UTF-16"']
         ]
@@ -476,92 +476,92 @@
         // Date & Times
         // -----------------------------------------
         // Interpreted as "milliseconds"
-        ['IEC61131_TIME' TIME
+        ['"IEC61131_TIME"' TIME
             [simple uint 32 'value']
         ]
         // Interpreted as "nanoseconds"
-        ['IEC61131_LTIME' LTIME
+        ['"IEC61131_LTIME"' LTIME
             [simple uint 64 'value']
         ]
         // Interpreted as "seconds since epoch"
-        ['IEC61131_DATE' DATE
+        ['"IEC61131_DATE"' DATE
             [simple uint 32 'value']
         ]
         // Interpreted as "milliseconds since midnight"
-        ['IEC61131_TIME_OF_DAY' TIME_OF_DAY
+        ['"IEC61131_TIME_OF_DAY"' TIME_OF_DAY
             [simple uint 32 'value']
         ]
         // Interpreted as "seconds since epoch"
-        ['IEC61131_DATE_AND_TIME' DATE_AND_TIME
+        ['"IEC61131_DATE_AND_TIME"' DATE_AND_TIME
             [simple uint 32 'secondsSinceEpoch']
         ]
     ]
 ]
 
 [enum int 8 'AdsDataType' (uint 16 'numBytes', vstring 'dataFormatName')
-    ['0x01' BOOL       ['1', 'IEC61131_BOOL']]
-    ['0x02' BIT        ['1', 'IEC61131_BOOL']]
-    ['0x03' BIT8       ['1', 'IEC61131_BOOL']]
+    ['0x01' BOOL       ['1', '"IEC61131_BOOL"']]
+    ['0x02' BIT        ['1', '"IEC61131_BOOL"']]
+    ['0x03' BIT8       ['1', '"IEC61131_BOOL"']]
 
     // -----------------------------------------
     // Bit-strings
     // -----------------------------------------
     // 1 byte
-    ['0x04' BYTE       ['1', 'IEC61131_BYTE']]
-    ['0x05' BITARR8    ['1', 'IEC61131_BYTE']]
+    ['0x04' BYTE       ['1', '"IEC61131_BYTE"']]
+    ['0x05' BITARR8    ['1', '"IEC61131_BYTE"']]
     // 2 byte (16 bit)
-    ['0x06' WORD       ['2', 'IEC61131_WORD']]
-    ['0x07' BITARR16   ['2', 'IEC61131_WORD']]
+    ['0x06' WORD       ['2', '"IEC61131_WORD"']]
+    ['0x07' BITARR16   ['2', '"IEC61131_WORD"']]
     // 4 byte (32 bit)
-    ['0x08' DWORD      ['4', 'IEC61131_DWORD']]
-    ['0x09' BITARR32   ['4', 'IEC61131_DWORD']]
+    ['0x08' DWORD      ['4', '"IEC61131_DWORD"']]
+    ['0x09' BITARR32   ['4', '"IEC61131_DWORD"']]
     // -----------------------------------------
     // Integers
     // -----------------------------------------
     // 8 bit:
-    ['0x0A' SINT       ['1', 'IEC61131_SINT']]
-    ['0x0B' INT8       ['1', 'IEC61131_SINT']]
-    ['0x0C' USINT      ['1', 'IEC61131_USINT']]
-    ['0x0D' UINT8      ['1', 'IEC61131_USINT']]
+    ['0x0A' SINT       ['1', '"IEC61131_SINT"']]
+    ['0x0B' INT8       ['1', '"IEC61131_SINT"']]
+    ['0x0C' USINT      ['1', '"IEC61131_USINT"']]
+    ['0x0D' UINT8      ['1', '"IEC61131_USINT"']]
     // 16 bit:
-    ['0x0E' INT        ['2', 'IEC61131_INT']]
-    ['0x0F' INT16      ['2', 'IEC61131_INT']]
-    ['0x10' UINT       ['2', 'IEC61131_UINT']]
-    ['0x11' UINT16     ['2', 'IEC61131_UINT']]
+    ['0x0E' INT        ['2', '"IEC61131_INT"']]
+    ['0x0F' INT16      ['2', '"IEC61131_INT"']]
+    ['0x10' UINT       ['2', '"IEC61131_UINT"']]
+    ['0x11' UINT16     ['2', '"IEC61131_UINT"']]
     // 32 bit:
-    ['0x12' DINT       ['4', 'IEC61131_DINT']]
-    ['0x13' INT32      ['4', 'IEC61131_DINT']]
-    ['0x14' UDINT      ['4', 'IEC61131_UDINT']]
-    ['0x15' UINT32     ['4', 'IEC61131_UDINT']]
+    ['0x12' DINT       ['4', '"IEC61131_DINT"']]
+    ['0x13' INT32      ['4', '"IEC61131_DINT"']]
+    ['0x14' UDINT      ['4', '"IEC61131_UDINT"']]
+    ['0x15' UINT32     ['4', '"IEC61131_UDINT"']]
     // 64 bit:
-    ['0x16' LINT       ['8', 'IEC61131_LINT']]
-    ['0x17' INT64      ['8', 'IEC61131_LINT']]
-    ['0x18' ULINT      ['8', 'IEC61131_ULINT']]
-    ['0x19' UINT64     ['8', 'IEC61131_ULINT']]
+    ['0x16' LINT       ['8', '"IEC61131_LINT"']]
+    ['0x17' INT64      ['8', '"IEC61131_LINT"']]
+    ['0x18' ULINT      ['8', '"IEC61131_ULINT"']]
+    ['0x19' UINT64     ['8', '"IEC61131_ULINT"']]
     // -----------------------------------------
     // Floating point values
     // -----------------------------------------
-    ['0x1A' REAL       ['4', 'IEC61131_REAL']]
-    ['0x1B' FLOAT      ['4', 'IEC61131_REAL']]
-    ['0x1C' LREAL      ['8', 'IEC61131_LREAL']]
-    ['0x1D' DOUBLE     ['8', 'IEC61131_LREAL']]
+    ['0x1A' REAL       ['4', '"IEC61131_REAL"']]
+    ['0x1B' FLOAT      ['4', '"IEC61131_REAL"']]
+    ['0x1C' LREAL      ['8', '"IEC61131_LREAL"']]
+    ['0x1D' DOUBLE     ['8', '"IEC61131_LREAL"']]
     // -----------------------------------------
     // Characters & Strings
     // -----------------------------------------
-    ['0x1E' CHAR       ['1',   'IEC61131_CHAR']]
-    ['0x1F' WCHAR      ['2',   'IEC61131_WCHAR']]
-    ['0x20' STRING     ['256', 'IEC61131_STRING']]
-    ['0x21' WSTRING    ['512', 'IEC61131_WSTRING']]
+    ['0x1E' CHAR       ['1',   '"IEC61131_CHAR"']]
+    ['0x1F' WCHAR      ['2',   '"IEC61131_WCHAR"']]
+    ['0x20' STRING     ['256', '"IEC61131_STRING"']]
+    ['0x21' WSTRING    ['512', '"IEC61131_WSTRING"']]
     // -----------------------------------------
     // Dates & Times
     // -----------------------------------------
-    ['0x22' TIME           ['4', 'IEC61131_TIME']]
-    ['0x23' LTIME          ['8', 'IEC61131_LTIME']]
-    ['0x24' DATE           ['4', 'IEC61131_DATE']]
-    ['0x25' TIME_OF_DAY    ['4', 'IEC61131_TIME_OF_DAY']]
-    ['0x26' TOD            ['4', 'IEC61131_TIME_OF_DAY']]
-    ['0x27' DATE_AND_TIME  ['4', 'IEC61131_DATE_AND_TIME']]
-    ['0x28' DT             ['4', 'IEC61131_DATE_AND_TIME']]
+    ['0x22' TIME           ['4', '"IEC61131_TIME"']]
+    ['0x23' LTIME          ['8', '"IEC61131_LTIME"']]
+    ['0x24' DATE           ['4', '"IEC61131_DATE"']]
+    ['0x25' TIME_OF_DAY    ['4', '"IEC61131_TIME_OF_DAY"']]
+    ['0x26' TOD            ['4', '"IEC61131_TIME_OF_DAY"']]
+    ['0x27' DATE_AND_TIME  ['4', '"IEC61131_DATE_AND_TIME"']]
+    ['0x28' DT             ['4', '"IEC61131_DATE_AND_TIME"']]
 ]
 
 [enum uint 32 'ReservedIndexGroups'
diff --git a/protocols/s7/src/main/resources/protocols/s7/s7.mspec b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
index 54fa9f6..e967728 100644
--- a/protocols/s7/src/main/resources/protocols/s7/s7.mspec
+++ b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
@@ -526,7 +526,7 @@
         // -----------------------------------------
         // Bit
         // -----------------------------------------
-        ['IEC61131_BOOL' BOOL
+        ['"IEC61131_BOOL"' BOOL
             [reserved uint 7 '0x00']
             [simple   bit    'value']
         ]
@@ -535,19 +535,19 @@
         // Bit-strings
         // -----------------------------------------
         // 1 byte
-        ['IEC61131_BYTE' List
+        ['"IEC61131_BYTE"' List
             [array bit 'value' count '8']
         ]
         // 2 byte (16 bit)
-        ['IEC61131_WORD' List
+        ['"IEC61131_WORD"' List
             [array bit 'value' count '16']
         ]
         // 4 byte (32 bit)
-        ['IEC61131_DWORD' List
+        ['"IEC61131_DWORD"' List
             [array bit 'value' count '32']
         ]
         // 8 byte (64 bit)
-        ['IEC61131_LWORD' List
+        ['"IEC61131_LWORD"' List
             [array bit 'value' count '64']
         ]
 
@@ -555,58 +555,58 @@
         // Integers
         // -----------------------------------------
         // 8 bit:
-        ['IEC61131_SINT' SINT
+        ['"IEC61131_SINT"' SINT
             [simple int 8 'value']
         ]
-        ['IEC61131_USINT' USINT
+        ['"IEC61131_USINT"' USINT
             [simple uint 8 'value']
         ]
         // 16 bit:
-        ['IEC61131_INT' INT
+        ['"IEC61131_INT"' INT
             [simple int 16 'value']
         ]
-        ['IEC61131_UINT' UINT
+        ['"IEC61131_UINT"' UINT
             [simple uint 16 'value']
         ]
         // 32 bit:
-        ['IEC61131_DINT' DINT
+        ['"IEC61131_DINT"' DINT
             [simple int 32 'value']
         ]
-        ['IEC61131_UDINT' UDINT
+        ['"IEC61131_UDINT"' UDINT
             [simple uint 32 'value']
         ]
         // 64 bit:
-        ['IEC61131_LINT' LINT
+        ['"IEC61131_LINT"' LINT
             [simple int 64 'value']
         ]
-        ['IEC61131_ULINT' ULINT
+        ['"IEC61131_ULINT"' ULINT
             [simple uint 64 'value']
         ]
 
         // -----------------------------------------
         // Floating point values
         // -----------------------------------------
-        ['IEC61131_REAL' REAL
+        ['"IEC61131_REAL"' REAL
             [simple float 32  'value']
         ]
-        ['IEC61131_LREAL' LREAL
+        ['"IEC61131_LREAL"' LREAL
             [simple float 64 'value']
         ]
 
         // -----------------------------------------
         // Characters & Strings
         // -----------------------------------------
-        ['IEC61131_CHAR' CHAR
+        ['"IEC61131_CHAR"' CHAR
             [manual string 8 'value'  'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.parseS7Char", readBuffer, _type.encoding)' 'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.serializeS7Char", writeBuffer, _value, _type.encoding)' '1']
         ]
-        ['IEC61131_WCHAR' CHAR
+        ['"IEC61131_WCHAR"' CHAR
             [manual string 16 'value' 'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.parseS7Char", readBuffer, _type.encoding)' 'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.serializeS7Char", writeBuffer, _value, _type.encoding)' '2' encoding='"UTF-16"']
         ]
-        ['IEC61131_STRING' STRING
+        ['"IEC61131_STRING"' STRING
             // TODO: Fix this length
             [manual vstring 'value'  'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.parseS7String", readBuffer, stringLength, _type.encoding)' 'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.serializeS7String", writeBuffer, _value, stringLength, _type.encoding)' 'STR_LEN(_value) + 2']
         ]
-        ['IEC61131_WSTRING' STRING
+        ['"IEC61131_WSTRING"' STRING
             // TODO: Fix this length
             [manual vstring 'value' 'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.parseS7String", readBuffer, stringLength, _type.encoding)' 'STATIC_CALL("org.apache.plc4x.java.s7.utils.StaticHelper.serializeS7String", writeBuffer, _value, stringLength, _type.encoding)' '(STR_LEN(_value) * 2) + 2' encoding='"UTF-16"']
         ]
@@ -615,26 +615,26 @@
         // TIA Date-Formats
         // -----------------------------------------
         // Interpreted as "milliseconds"
-        ['IEC61131_TIME' TIME
+        ['"IEC61131_TIME"' TIME
             [simple uint 32 'value']
         ]
-        //['S7_S5TIME' TIME
+        //['"S7_S5TIME"' TIME
         //    [reserved uint 2  '0x00']
         //    [uint     uint 2  'base']
         //    [simple   uint 12 'value']
         //]
         // Interpreted as "number of nanoseconds"
-        ['IEC61131_LTIME' LTIME
+        ['"IEC61131_LTIME"' LTIME
             [simple uint 64 'value']
         ]
         // Interpreted as "number of days since 1990-01-01"
-        ['IEC61131_DATE' DATE
+        ['"IEC61131_DATE"' DATE
             [simple uint 16 'value']
         ]
-        ['IEC61131_TIME_OF_DAY' TIME_OF_DAY
+        ['"IEC61131_TIME_OF_DAY"' TIME_OF_DAY
             [simple uint 32 'value']
         ]
-        ['IEC61131_DATE_AND_TIME' DATE_AND_TIME
+        ['"IEC61131_DATE_AND_TIME"' DATE_AND_TIME
             [simple uint 16 'year']
             [simple uint 8  'month']
             [simple uint 8  'day']
diff --git a/protocols/simulated/src/main/resources/protocols/simulated/simulated.mspec b/protocols/simulated/src/main/resources/protocols/simulated/simulated.mspec
index 1512728..40251e5 100644
--- a/protocols/simulated/src/main/resources/protocols/simulated/simulated.mspec
+++ b/protocols/simulated/src/main/resources/protocols/simulated/simulated.mspec
@@ -25,112 +25,112 @@
 
 [dataIo 'DataItem'(vstring 'dataType', uint 16 'numberOfValues')
     [typeSwitch 'dataType','numberOfValues'
-        ['BOOL','1' BOOL
+        ['"BOOL"','1' BOOL
             [simple   bit    'value']
         ]
-        ['BOOL' List
+        ['"BOOL"' List
             [array bit 'value' count 'numberOfValues']
         ]
-        ['BYTE','1' BYTE
+        ['"BYTE"','1' BYTE
             [simple uint 8 'value']
         ]
-        ['BYTE' List
+        ['"BYTE"' List
             [array uint 8 'value' count 'numberOfValues']
         ]
-        ['WORD','1' WORD
+        ['"WORD"','1' WORD
             [simple uint 16 'value']
         ]
-        ['WORD' List
+        ['"WORD"' List
             [array uint 16 'value' count 'numberOfValues']
         ]
-        ['DWORD','1' DWORD
+        ['"DWORD"','1' DWORD
             [simple uint 32 'value']
         ]
-        ['DWORD' List
+        ['"DWORD"' List
             [array uint 32 'value' count 'numberOfValues']
         ]
-        ['LWORD','1' LWORD
+        ['"LWORD"','1' LWORD
             [simple uint 64 'value']
         ]
-        ['LWORD' List
+        ['"LWORD"' List
             [array uint 64 'value' count 'numberOfValues']
         ]
-        ['SINT','1' SINT
+        ['"SINT"','1' SINT
             [simple int 8 'value']
         ]
-        ['SINT' List
+        ['"SINT"' List
             [array int 8 'value' count 'numberOfValues']
         ]
-        ['INT','1' INT
+        ['"INT"','1' INT
             [simple int 16 'value']
         ]
-        ['INT' List
+        ['"INT"' List
             [array int 16 'value' count 'numberOfValues']
         ]
-        ['DINT','1' DINT
+        ['"DINT"','1' DINT
             [simple int 32 'value']
         ]
-        ['DINT' List
+        ['"DINT"' List
             [array int 32 'value' count 'numberOfValues']
         ]
-        ['LINT','1' LINT
+        ['"LINT"','1' LINT
             [simple int 64 'value']
         ]
-        ['LINT' List
+        ['"LINT"' List
             [array int 64 'value' count 'numberOfValues']
         ]
-        ['USINT','1' USINT
+        ['"USINT"','1' USINT
             [simple uint 8 'value']
         ]
-        ['USINT' List
+        ['"USINT"' List
             [array uint 8 'value' count 'numberOfValues']
         ]
-        ['UINT','1' UINT
+        ['"UINT"','1' UINT
             [simple uint 16 'value']
         ]
-        ['UINT' List
+        ['"UINT"' List
             [array uint 16 'value' count 'numberOfValues']
         ]
-        ['UDINT','1' UDINT
+        ['"UDINT"','1' UDINT
             [simple uint 32 'value']
         ]
-        ['UDINT' List
+        ['"UDINT"' List
             [array uint 32 'value' count 'numberOfValues']
         ]
-        ['ULINT','1' ULINT
+        ['"ULINT"','1' ULINT
             [simple uint 64 'value']
         ]
-        ['ULINT' List
+        ['"ULINT"' List
             [array uint 64 'value' count 'numberOfValues']
         ]
-        ['REAL','1' REAL
+        ['"REAL"','1' REAL
             [simple float 32  'value']
         ]
-        ['REAL' List
+        ['"REAL"' List
             [array float 32 'value' count 'numberOfValues']
         ]
-        ['LREAL','1' LREAL
+        ['"LREAL"','1' LREAL
             [simple float 64  'value']
         ]
-        ['LREAL' List
+        ['"LREAL"' List
             [array float 64 'value' count 'numberOfValues']
         ]
-        ['CHAR','1' CHAR
+        ['"CHAR"','1' CHAR
             [simple uint 8 'value']
         ]
-        ['CHAR' List
+        ['"CHAR"' List
             [array uint 8 'value' count 'numberOfValues']
         ]
-        ['WCHAR','1' WCHAR
+        ['"WCHAR"','1' WCHAR
             [simple uint 16 'value']
         ]
-        ['WCHAR' List
+        ['"WCHAR"' List
             [array uint 16 'value' count 'numberOfValues']
         ]
-        ['STRING' STRING
+        ['"STRING"' STRING
             [simple string 255 'value']
         ]
-        ['WSTRING' STRING
+        ['"WSTRING"' STRING
             [simple string 255 'value']
         ]
     ]