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 2020/10/22 20:31:28 UTC

[plc4x] branch feature/plc4go updated: - Implemented the Floating-Point handling

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

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


The following commit(s) were added to refs/heads/feature/plc4go by this push:
     new 7b14da8  - Implemented the Floating-Point handling
7b14da8 is described below

commit 7b14da8802c2b8128a65a09a213aaa429ba6f6c5
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Oct 22 22:31:21 2020 +0200

    - Implemented the Floating-Point handling
---
 .../BaseFreemarkerLanguageTemplateHelper.java      |   5 +
 .../main/resources/templates/go/enum-template.ftlh |  17 +-
 .../main/resources/protocols/modbus/modbus.mspec   |  30 +++
 sandbox/plc4go/cmd/main/drivers/modbus_test.go     |   2 +-
 .../bacnetip/readwrite/model/ApplicationTag.go     |  31 +++
 .../bacnetip/readwrite/model/BACnetNetworkType.go  |  27 +++
 .../bacnetip/readwrite/model/BACnetNodeType.go     |  49 +++++
 .../bacnetip/readwrite/model/BACnetNotifyType.go   |  11 +
 .../bacnetip/readwrite/model/BACnetObjectType.go   | 123 +++++++++++
 .../plc4go/knxnetip/readwrite/model/APCI.go        |  37 ++++
 .../knxnetip/readwrite/model/CEMIPriority.go       |  13 ++
 .../knxnetip/readwrite/model/HostProtocolCode.go   |   9 +
 .../plc4go/knxnetip/readwrite/model/KnxLayer.go    |  11 +
 .../plc4go/knxnetip/readwrite/model/Status.go      |  29 +++
 .../plc4go/knxnetip/readwrite/model/TPCI.go        |  13 ++
 .../plc4go/internal/plc4go/modbus/ModbusReader.go  |   7 +-
 .../modbus/readwrite/model/ModbusDataType.go       |  61 ++++++
 .../modbus/readwrite/model/ModbusDataTypeSizes.go  | 236 +++++++++++++++++++++
 .../modbus/readwrite/model/ModbusErrorCode.go      |  25 +++
 .../plc4go/s7/readwrite/model/COTPProtocolClass.go |  15 ++
 .../plc4go/s7/readwrite/model/COTPTpduSize.go      |  19 ++
 .../s7/readwrite/model/DataTransportErrorCode.go   |  17 ++
 .../plc4go/s7/readwrite/model/DataTransportSize.go |  19 ++
 .../plc4go/s7/readwrite/model/DeviceGroup.go       |  11 +
 .../plc4go/s7/readwrite/model/MemoryArea.go        |  23 ++
 .../s7/readwrite/model/SzlModuleTypeClass.go       |  13 ++
 .../plc4go/s7/readwrite/model/SzlSublist.go        |  43 ++++
 .../plc4go/s7/readwrite/model/TransportSize.go     |  37 ++++
 sandbox/plc4go/internal/plc4go/spi/ReadBuffer.go   |   7 +-
 29 files changed, 930 insertions(+), 10 deletions(-)

diff --git a/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java b/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java
index c74d5a0..c3e168a 100644
--- a/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java
+++ b/build-utils/language-base-freemarker/src/main/java/org/apache/plc4x/plugins/codegenerator/protocol/freemarker/BaseFreemarkerLanguageTemplateHelper.java
@@ -18,6 +18,7 @@ under the License.
 */
 package org.apache.plc4x.plugins.codegenerator.protocol.freemarker;
 
+import jdk.nashorn.internal.runtime.regexp.joni.constants.StringType;
 import net.objecthunter.exp4j.Expression;
 import net.objecthunter.exp4j.ExpressionBuilder;
 import org.apache.plc4x.plugins.codegenerator.types.definitions.*;
@@ -144,6 +145,10 @@ public abstract class BaseFreemarkerLanguageTemplateHelper implements Freemarker
         return typeReference instanceof ComplexTypeReference;
     }
 
+    public boolean isStringTypeReference(TypeReference typeReference) {
+        return typeReference instanceof StringTypeReference;
+    }
+
     /**
      * Helper for collecting referenced complex types as these usually ned to be
      * imported in some way.
diff --git a/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh b/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
index 0a1cf59..c70a84f 100644
--- a/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
+++ b/build-utils/language-go/src/main/resources/templates/go/enum-template.ftlh
@@ -63,7 +63,7 @@ type I${type.name} interface {
 
 const(
 <#list type.enumValues as enumValue>
-    ${type.name}_${enumValue.name} ${type.name} = ${enumValue.value}
+    ${type.name}_${enumValue.name} ${type.name} = <#if helper.isStringTypeReference(type.type)>"${enumValue.value}"<#else>${enumValue.value}</#if>
 </#list>
 )
 
@@ -89,20 +89,29 @@ func (e ${type.name}) ${constantName?cap_first}() ${helper.getLanguageTypeNameFo
 }
     </#list>
 </#if>
+func ${type.name}ValueOf(value <#if type.type?has_content>${helper.getLanguageTypeNameForTypeReference(type.type)}<#else>string</#if>) ${type.name} {
+    switch value {
+<#list helper.getUniqueEnumValues(type.enumValues) as enumValue>
+        case <#if helper.isStringTypeReference(type.type)>"${enumValue.value}"<#else>${enumValue.value}</#if>:
+            return ${type.name}_${enumValue.name}
+</#list>
+    }
+    return <#if helper.isStringTypeReference(type.type)>""<#else>0</#if>
+}
 
 func Cast${type.name}(structType interface{}) ${type.name} {
     castFunc := func(typ interface{}) ${type.name} {
         if s${type.name}, ok := typ.(${type.name}); ok {
             return s${type.name}
         }
-        return 0
+        return <#if helper.isStringTypeReference(type.type)>""<#else>0</#if>
     }
     return castFunc(structType)
 }
 
 func (m ${type.name}) LengthInBits() uint16 {
     <#assign simpleTypeReference = type.type>
-    return ${simpleTypeReference.sizeInBits}
+    return <#if helper.isStringTypeReference(type.type)>0<#else>${simpleTypeReference.sizeInBits}</#if>
 }
 
 func (m ${type.name}) LengthInBytes() uint16 {
@@ -112,7 +121,7 @@ func (m ${type.name}) LengthInBytes() uint16 {
 <#if type.type?has_content>
 func ${type.name}Parse(io *spi.ReadBuffer) (${type.name}, error) {
     // TODO: Implement ...
-    return 0, nil
+    return <#if helper.isStringTypeReference(type.type)>""<#else>0</#if>, nil
 }
 
 func (e ${type.name}) Serialize(io spi.WriteBuffer) error {
diff --git a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
index 7e18661..84a9d4c 100644
--- a/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
+++ b/protocols/modbus/src/main/resources/protocols/modbus/modbus.mspec
@@ -378,6 +378,36 @@
     ]
 ]
 
+[enum string 'ModbusDataTypeSizes' [uint 8 'dataTypeSize']
+    ['IEC61131_BOOL' BOOL ['1']]
+    ['IEC61131_BYTE' BYTE ['1']]
+    ['IEC61131_WORD' WORD ['2']]
+    ['IEC61131_DWORD' DWORD ['4']]
+    ['IEC61131_LWORD' LWORD ['8']]
+    ['IEC61131_SINT' SINT ['1']]
+    ['IEC61131_INT' INT ['2']]
+    ['IEC61131_DINT' DINT ['4']]
+    ['IEC61131_LINT' LINT ['8']]
+    ['IEC61131_USINT' USINT ['1']]
+    ['IEC61131_UINT' UINT ['2']]
+    ['IEC61131_UDINT' UDINT ['4']]
+    ['IEC61131_ULINT' ULINT ['8']]
+    ['IEC61131_REAL' REAL ['4']]
+    ['IEC61131_LREAL' LREAL ['8']]
+    ['IEC61131_TIME' TIME ['8']]
+    ['IEC61131_LTIME' LTIME ['8']]
+    ['IEC61131_DATE' DATE ['8']]
+    ['IEC61131_LDATE' LDATE ['8']]
+    ['IEC61131_TIME_OF_DAY' TIME_OF_DAY ['8']]
+    ['IEC61131_LTIME_OF_DAY' LTIME_OF_DAY ['8']]
+    ['IEC61131_DATE_AND_TIME' DATE_AND_TIME ['8']]
+    ['IEC61131_LDATE_AND_TIME' LDATE_AND_TIME ['8']]
+    ['IEC61131_CHAR' CHAR ['1']]
+    ['IEC61131_WCHAR' WCHAR ['2']]
+    ['IEC61131_STRING' STRING ['1']]
+    ['IEC61131_WSTRING' WSTRING ['2']]
+]
+
 [enum uint 8 'ModbusDataType' [uint 8 'dataTypeSize']
     ['00' NULL ['0']]
     ['01' BOOL ['1']]
diff --git a/sandbox/plc4go/cmd/main/drivers/modbus_test.go b/sandbox/plc4go/cmd/main/drivers/modbus_test.go
index a96e8b0..2560457 100644
--- a/sandbox/plc4go/cmd/main/drivers/modbus_test.go
+++ b/sandbox/plc4go/cmd/main/drivers/modbus_test.go
@@ -145,7 +145,7 @@ func TestPlc4goDriver(t *testing.T) {
 
 	// Prepare a read-request
 	rrb := connection.ReadRequestBuilder()
-	rrb.AddItem("field", "holding-register:0:UINT[2]")
+	rrb.AddItem("field", "holding-register:0:REAL[2]")
 	readRequest, err := rrb.Build()
 	if err != nil {
 		t.Errorf("error preparing read-request: %s", connectionResult.Err.Error())
diff --git a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go
index e9e8915..4d6b6d3 100644
--- a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go
+++ b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go
@@ -43,6 +43,37 @@ const(
     ApplicationTag_BACNET_OBJECT_IDENTIFIER ApplicationTag = 0xC
 )
 
+func ApplicationTagValueOf(value int8) ApplicationTag {
+    switch value {
+        case 0x0:
+            return ApplicationTag_NULL
+        case 0x1:
+            return ApplicationTag_BOOLEAN
+        case 0x2:
+            return ApplicationTag_UNSIGNED_INTEGER
+        case 0x3:
+            return ApplicationTag_SIGNED_INTEGER
+        case 0x4:
+            return ApplicationTag_REAL
+        case 0x5:
+            return ApplicationTag_DOUBLE
+        case 0x6:
+            return ApplicationTag_OCTET_STRING
+        case 0x7:
+            return ApplicationTag_CHARACTER_STRING
+        case 0x8:
+            return ApplicationTag_BIT_STRING
+        case 0x9:
+            return ApplicationTag_ENUMERATED
+        case 0xA:
+            return ApplicationTag_DATE
+        case 0xB:
+            return ApplicationTag_TIME
+        case 0xC:
+            return ApplicationTag_BACNET_OBJECT_IDENTIFIER
+    }
+    return 0
+}
 
 func CastApplicationTag(structType interface{}) ApplicationTag {
     castFunc := func(typ interface{}) ApplicationTag {
diff --git a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go
index a6f6062..8a183df 100644
--- a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go
+++ b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go
@@ -41,6 +41,33 @@ const(
     BACnetNetworkType_SERIAL BACnetNetworkType = 0xA
 )
 
+func BACnetNetworkTypeValueOf(value uint8) BACnetNetworkType {
+    switch value {
+        case 0x0:
+            return BACnetNetworkType_ETHERNET
+        case 0x1:
+            return BACnetNetworkType_ARCNET
+        case 0x2:
+            return BACnetNetworkType_MSTP
+        case 0x3:
+            return BACnetNetworkType_PTP
+        case 0x4:
+            return BACnetNetworkType_LONTALK
+        case 0x5:
+            return BACnetNetworkType_IPV4
+        case 0x6:
+            return BACnetNetworkType_ZIGBEE
+        case 0x7:
+            return BACnetNetworkType_VIRTUAL
+        case 0x8:
+            return BACnetNetworkType_REMOVED_NON_BACNET
+        case 0x9:
+            return BACnetNetworkType_IPV6
+        case 0xA:
+            return BACnetNetworkType_SERIAL
+    }
+    return 0
+}
 
 func CastBACnetNetworkType(structType interface{}) BACnetNetworkType {
     castFunc := func(typ interface{}) BACnetNetworkType {
diff --git a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go
index 95f5521..dcfe467 100644
--- a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go
+++ b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go
@@ -52,6 +52,55 @@ const(
     BACnetNodeType_ZONE BACnetNodeType = 0x15
 )
 
+func BACnetNodeTypeValueOf(value uint8) BACnetNodeType {
+    switch value {
+        case 0x00:
+            return BACnetNodeType_UNKNOWN
+        case 0x01:
+            return BACnetNodeType_SYSTEM
+        case 0x02:
+            return BACnetNodeType_NETWORK
+        case 0x03:
+            return BACnetNodeType_DEVICE
+        case 0x04:
+            return BACnetNodeType_ORGANIZATIONAL
+        case 0x05:
+            return BACnetNodeType_AREA
+        case 0x06:
+            return BACnetNodeType_EQUIPMENT
+        case 0x07:
+            return BACnetNodeType_POINT
+        case 0x08:
+            return BACnetNodeType_COLLECTION
+        case 0x09:
+            return BACnetNodeType_PROPERTY
+        case 0x0A:
+            return BACnetNodeType_FUNCTIONAL
+        case 0x0B:
+            return BACnetNodeType_OTHER
+        case 0x0C:
+            return BACnetNodeType_SUBSYSTEM
+        case 0x0D:
+            return BACnetNodeType_BUILDING
+        case 0x0E:
+            return BACnetNodeType_FLOOR
+        case 0x0F:
+            return BACnetNodeType_SECTION
+        case 0x10:
+            return BACnetNodeType_MODULE
+        case 0x11:
+            return BACnetNodeType_TREE
+        case 0x12:
+            return BACnetNodeType_MEMBER
+        case 0x13:
+            return BACnetNodeType_PROTOCOL
+        case 0x14:
+            return BACnetNodeType_ROOM
+        case 0x15:
+            return BACnetNodeType_ZONE
+    }
+    return 0
+}
 
 func CastBACnetNodeType(structType interface{}) BACnetNodeType {
     castFunc := func(typ interface{}) BACnetNodeType {
diff --git a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go
index 2aa4cdf..b3a6634 100644
--- a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go
+++ b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go
@@ -33,6 +33,17 @@ const(
     BACnetNotifyType_ACK_NOTIFICATION BACnetNotifyType = 0x2
 )
 
+func BACnetNotifyTypeValueOf(value uint8) BACnetNotifyType {
+    switch value {
+        case 0x0:
+            return BACnetNotifyType_ALARM
+        case 0x1:
+            return BACnetNotifyType_EVENT
+        case 0x2:
+            return BACnetNotifyType_ACK_NOTIFICATION
+    }
+    return 0
+}
 
 func CastBACnetNotifyType(structType interface{}) BACnetNotifyType {
     castFunc := func(typ interface{}) BACnetNotifyType {
diff --git a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go
index 56a8eba..309db9a 100644
--- a/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go
+++ b/sandbox/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go
@@ -89,6 +89,129 @@ const(
     BACnetObjectType_ESCALATOR BACnetObjectType = 0x03A
 )
 
+func BACnetObjectTypeValueOf(value uint16) BACnetObjectType {
+    switch value {
+        case 0x000:
+            return BACnetObjectType_ANALOG_INPUT
+        case 0x001:
+            return BACnetObjectType_ANALOG_OUTPUT
+        case 0x002:
+            return BACnetObjectType_ANALOG_VALUE
+        case 0x003:
+            return BACnetObjectType_BINARY_INPUT
+        case 0x004:
+            return BACnetObjectType_BINARY_OUTPUT
+        case 0x005:
+            return BACnetObjectType_BINARY_VALUE
+        case 0x006:
+            return BACnetObjectType_CALENDAR
+        case 0x007:
+            return BACnetObjectType_COMMAND
+        case 0x008:
+            return BACnetObjectType_DEVICE
+        case 0x009:
+            return BACnetObjectType_EVENT_ENROLLMENT
+        case 0x00A:
+            return BACnetObjectType_FILE
+        case 0x00B:
+            return BACnetObjectType_GROUP
+        case 0x00C:
+            return BACnetObjectType_LOOP
+        case 0x00D:
+            return BACnetObjectType_MULTISTATE_INPUT
+        case 0x00E:
+            return BACnetObjectType_MULTISTATE_OUTPUT
+        case 0x00F:
+            return BACnetObjectType_NOTIFICATION_CLASS
+        case 0x010:
+            return BACnetObjectType_PROGRAM
+        case 0x011:
+            return BACnetObjectType_SCHEDULE
+        case 0x012:
+            return BACnetObjectType_AVERAGING
+        case 0x013:
+            return BACnetObjectType_MULTISTATE_VALUE
+        case 0x014:
+            return BACnetObjectType_TREND_LOG
+        case 0x015:
+            return BACnetObjectType_LIFE_SAFETY_POINT
+        case 0x016:
+            return BACnetObjectType_LIFE_SAFETY_ZONE
+        case 0x017:
+            return BACnetObjectType_ACCUMULATOR
+        case 0x018:
+            return BACnetObjectType_PULSE_CONVERTER
+        case 0x019:
+            return BACnetObjectType_EVENT_LOG
+        case 0x01A:
+            return BACnetObjectType_GLOBAL_GROUP
+        case 0x01B:
+            return BACnetObjectType_TREND_LOG_MULTIPLE
+        case 0x01C:
+            return BACnetObjectType_LOAD_CONTROL
+        case 0x01D:
+            return BACnetObjectType_STRUCTURED_VIEW
+        case 0x01E:
+            return BACnetObjectType_ACCESS_DOOR
+        case 0x01F:
+            return BACnetObjectType_TIMER
+        case 0x020:
+            return BACnetObjectType_ACCESS_CREDENTIAL
+        case 0x021:
+            return BACnetObjectType_ACCESS_POINT
+        case 0x022:
+            return BACnetObjectType_ACCESS_RIGHTS
+        case 0x023:
+            return BACnetObjectType_ACCESS_USER
+        case 0x024:
+            return BACnetObjectType_ACCESS_ZONE
+        case 0x025:
+            return BACnetObjectType_CREDENTIAL_DATA_INPUT
+        case 0x026:
+            return BACnetObjectType_NETWORK_SECURITY
+        case 0x027:
+            return BACnetObjectType_BITSTRING_VALUE
+        case 0x028:
+            return BACnetObjectType_CHARACTERSTRING_VALUE
+        case 0x029:
+            return BACnetObjectType_DATEPATTERN_VALUE
+        case 0x02A:
+            return BACnetObjectType_DATE_VALUE
+        case 0x02B:
+            return BACnetObjectType_DATETIMEPATTERN_VALUE
+        case 0x02C:
+            return BACnetObjectType_DATETIME_VALUE
+        case 0x02D:
+            return BACnetObjectType_INTEGER_VALUE
+        case 0x02E:
+            return BACnetObjectType_LARGE_ANALOG_VALUE
+        case 0x02F:
+            return BACnetObjectType_OCTETSTRING_VALUE
+        case 0x030:
+            return BACnetObjectType_POSITIVE_INTEGER_VALUE
+        case 0x031:
+            return BACnetObjectType_TIMEPATTERN_VALUE
+        case 0x032:
+            return BACnetObjectType_TIME_VALUE
+        case 0x033:
+            return BACnetObjectType_NOTIFICATION_FORWARDER
+        case 0x034:
+            return BACnetObjectType_ALERT_ENROLLMENT
+        case 0x035:
+            return BACnetObjectType_CHANNEL
+        case 0x036:
+            return BACnetObjectType_LIGHTING_OUTPUT
+        case 0x037:
+            return BACnetObjectType_BINARY_LIGHTING_OUTPUT
+        case 0x038:
+            return BACnetObjectType_NETWORK_PORT
+        case 0x039:
+            return BACnetObjectType_ELEVATOR_GROUP
+        case 0x03A:
+            return BACnetObjectType_ESCALATOR
+    }
+    return 0
+}
 
 func CastBACnetObjectType(structType interface{}) BACnetObjectType {
     castFunc := func(typ interface{}) BACnetObjectType {
diff --git a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/APCI.go b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/APCI.go
index 3a12aa8..3790228 100644
--- a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/APCI.go
+++ b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/APCI.go
@@ -46,6 +46,43 @@ const(
     APCI_OTHER_PDU APCI = 0xF
 )
 
+func APCIValueOf(value uint8) APCI {
+    switch value {
+        case 0x0:
+            return APCI_GROUP_VALUE_READ_PDU
+        case 0x1:
+            return APCI_GROUP_VALUE_RESPONSE_PDU
+        case 0x2:
+            return APCI_GROUP_VALUE_WRITE_PDU
+        case 0x3:
+            return APCI_INDIVIDUAL_ADDRESS_WRITE_PDU
+        case 0x4:
+            return APCI_INDIVIDUAL_ADDRESS_READ_PDU
+        case 0x5:
+            return APCI_INDIVIDUAL_ADDRESS_RESPONSE_PDU
+        case 0x6:
+            return APCI_ADC_READ_PDU
+        case 0x7:
+            return APCI_ADC_RESPONSE_PDU
+        case 0x8:
+            return APCI_MEMORY_READ_PDU
+        case 0x9:
+            return APCI_MEMORY_RESPONSE_PDU
+        case 0xA:
+            return APCI_MEMORY_WRITE_PDU
+        case 0xB:
+            return APCI_USER_MESSAGE_PDU
+        case 0xC:
+            return APCI_DEVICE_DESCRIPTOR_READ_PDU
+        case 0xD:
+            return APCI_DEVICE_DESCRIPTOR_RESPONSE_PDU
+        case 0xE:
+            return APCI_RESTART_PDU
+        case 0xF:
+            return APCI_OTHER_PDU
+    }
+    return 0
+}
 
 func CastAPCI(structType interface{}) APCI {
     castFunc := func(typ interface{}) APCI {
diff --git a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go
index b5d2a89..7a9852c 100644
--- a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go
+++ b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go
@@ -34,6 +34,19 @@ const(
     CEMIPriority_LOW CEMIPriority = 0x3
 )
 
+func CEMIPriorityValueOf(value uint8) CEMIPriority {
+    switch value {
+        case 0x0:
+            return CEMIPriority_SYSTEM
+        case 0x1:
+            return CEMIPriority_NORMAL
+        case 0x2:
+            return CEMIPriority_URGENT
+        case 0x3:
+            return CEMIPriority_LOW
+    }
+    return 0
+}
 
 func CastCEMIPriority(structType interface{}) CEMIPriority {
     castFunc := func(typ interface{}) CEMIPriority {
diff --git a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go
index 35a1038..30bb564 100644
--- a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go
+++ b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go
@@ -32,6 +32,15 @@ const(
     HostProtocolCode_IPV4_TCP HostProtocolCode = 0x02
 )
 
+func HostProtocolCodeValueOf(value uint8) HostProtocolCode {
+    switch value {
+        case 0x01:
+            return HostProtocolCode_IPV4_UDP
+        case 0x02:
+            return HostProtocolCode_IPV4_TCP
+    }
+    return 0
+}
 
 func CastHostProtocolCode(structType interface{}) HostProtocolCode {
     castFunc := func(typ interface{}) HostProtocolCode {
diff --git a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go
index 46f247d..3166ecd 100644
--- a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go
+++ b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go
@@ -33,6 +33,17 @@ const(
     KnxLayer_TUNNEL_BUSMONITOR KnxLayer = 0x80
 )
 
+func KnxLayerValueOf(value uint8) KnxLayer {
+    switch value {
+        case 0x02:
+            return KnxLayer_TUNNEL_LINK_LAYER
+        case 0x04:
+            return KnxLayer_TUNNEL_RAW
+        case 0x80:
+            return KnxLayer_TUNNEL_BUSMONITOR
+    }
+    return 0
+}
 
 func CastKnxLayer(structType interface{}) KnxLayer {
     castFunc := func(typ interface{}) KnxLayer {
diff --git a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go
index da8e567..9cfc20e 100644
--- a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go
+++ b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go
@@ -42,6 +42,35 @@ const(
     Status_TUNNELLING_LAYER_NOT_SUPPORTED Status = 0x29
 )
 
+func StatusValueOf(value uint8) Status {
+    switch value {
+        case 0x00:
+            return Status_NO_ERROR
+        case 0x01:
+            return Status_PROTOCOL_TYPE_NOT_SUPPORTED
+        case 0x02:
+            return Status_UNSUPPORTED_PROTOCOL_VERSION
+        case 0x04:
+            return Status_OUT_OF_ORDER_SEQUENCE_NUMBER
+        case 0x21:
+            return Status_INVALID_CONNECTION_ID
+        case 0x22:
+            return Status_CONNECTION_TYPE_NOT_SUPPORTED
+        case 0x23:
+            return Status_CONNECTION_OPTION_NOT_SUPPORTED
+        case 0x24:
+            return Status_NO_MORE_CONNECTIONS
+        case 0x25:
+            return Status_NO_MORE_UNIQUE_CONNECTIONS
+        case 0x26:
+            return Status_DATA_CONNECTION
+        case 0x27:
+            return Status_KNX_CONNECTION
+        case 0x29:
+            return Status_TUNNELLING_LAYER_NOT_SUPPORTED
+    }
+    return 0
+}
 
 func CastStatus(structType interface{}) Status {
     castFunc := func(typ interface{}) Status {
diff --git a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/TPCI.go b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/TPCI.go
index 4a437fa..8706e63 100644
--- a/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/TPCI.go
+++ b/sandbox/plc4go/internal/plc4go/knxnetip/readwrite/model/TPCI.go
@@ -34,6 +34,19 @@ const(
     TPCI_NUMBERED_CONTROL_DATA TPCI = 0x3
 )
 
+func TPCIValueOf(value uint8) TPCI {
+    switch value {
+        case 0x0:
+            return TPCI_UNNUMBERED_DATA_PACKET
+        case 0x1:
+            return TPCI_UNNUMBERED
+        case 0x2:
+            return TPCI_NUMBERED_DATA_PACKET
+        case 0x3:
+            return TPCI_NUMBERED_CONTROL_DATA
+    }
+    return 0
+}
 
 func CastTPCI(structType interface{}) TPCI {
     castFunc := func(typ interface{}) TPCI {
diff --git a/sandbox/plc4go/internal/plc4go/modbus/ModbusReader.go b/sandbox/plc4go/internal/plc4go/modbus/ModbusReader.go
index b21ab91..17a5bea 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/ModbusReader.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/ModbusReader.go
@@ -61,10 +61,11 @@ func (m ModbusReader) Read(readRequest model.PlcReadRequest) <-chan model.PlcRea
             }
             return result
         }
+        numWords := uint16(math.Ceil(float64(modbusField.Quantity * uint16(modbusModel.ModbusDataTypeSizesValueOf(modbusField.Datatype).DataTypeSize())) / float64(2)))
         var pdu modbusModel.IModbusPDU = nil
         switch modbusField.FieldType {
         case MODBUS_FIELD_COIL:
-            pdu = modbusModel.ModbusPDUReadInputRegistersRequest{
+            pdu = modbusModel.ModbusPDUReadCoilsRequest{
                 StartingAddress: modbusField.Address,
                 Quantity:        modbusField.Quantity,
             }
@@ -76,12 +77,12 @@ func (m ModbusReader) Read(readRequest model.PlcReadRequest) <-chan model.PlcRea
         case MODBUS_FIELD_INPUT_REGISTER:
             pdu = modbusModel.ModbusPDUReadInputRegistersRequest{
                 StartingAddress: modbusField.Address,
-                Quantity:        modbusField.Quantity,
+                Quantity:        numWords,
             }
         case MODBUS_FIELD_HOLDING_REGISTER:
             pdu = modbusModel.ModbusPDUReadHoldingRegistersRequest{
                 StartingAddress: modbusField.Address,
-                Quantity:        modbusField.Quantity,
+                Quantity:        numWords,
             }
         case MODBUS_FIELD_EXTENDED_REGISTER:
             result <- model.PlcReadRequestResult{
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
index e22bd4f..572143a 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
@@ -151,6 +151,67 @@ func (e ModbusDataType) DataTypeSize() uint8 {
         }
     }
 }
+func ModbusDataTypeValueOf(value uint8) ModbusDataType {
+    switch value {
+        case 00:
+            return ModbusDataType_NULL
+        case 01:
+            return ModbusDataType_BOOL
+        case 10:
+            return ModbusDataType_BYTE
+        case 11:
+            return ModbusDataType_WORD
+        case 12:
+            return ModbusDataType_DWORD
+        case 13:
+            return ModbusDataType_LWORD
+        case 20:
+            return ModbusDataType_SINT
+        case 21:
+            return ModbusDataType_INT
+        case 22:
+            return ModbusDataType_DINT
+        case 23:
+            return ModbusDataType_LINT
+        case 24:
+            return ModbusDataType_USINT
+        case 25:
+            return ModbusDataType_UINT
+        case 26:
+            return ModbusDataType_UDINT
+        case 27:
+            return ModbusDataType_ULINT
+        case 30:
+            return ModbusDataType_REAL
+        case 31:
+            return ModbusDataType_LREAL
+        case 40:
+            return ModbusDataType_TIME
+        case 41:
+            return ModbusDataType_LTIME
+        case 50:
+            return ModbusDataType_DATE
+        case 51:
+            return ModbusDataType_LDATE
+        case 60:
+            return ModbusDataType_TIME_OF_DAY
+        case 61:
+            return ModbusDataType_LTIME_OF_DAY
+        case 70:
+            return ModbusDataType_DATE_AND_TIME
+        case 71:
+            return ModbusDataType_LDATE_AND_TIME
+        case 80:
+            return ModbusDataType_CHAR
+        case 81:
+            return ModbusDataType_WCHAR
+        case 82:
+            return ModbusDataType_STRING
+        case 83:
+            return ModbusDataType_WSTRING
+    }
+    return 0
+}
 
 func CastModbusDataType(structType interface{}) ModbusDataType {
     castFunc := func(typ interface{}) ModbusDataType {
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataTypeSizes.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataTypeSizes.go
new file mode 100644
index 0000000..a9cc009
--- /dev/null
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataTypeSizes.go
@@ -0,0 +1,236 @@
+//
+// 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 model
+
+import "plc4x.apache.org/plc4go-modbus-driver/v0/internal/plc4go/spi"
+
+type ModbusDataTypeSizes string
+
+type IModbusDataTypeSizes interface {
+    spi.Message
+    DataTypeSize() uint8
+    Serialize(io spi.WriteBuffer) error
+}
+
+const(
+    ModbusDataTypeSizes_BOOL ModbusDataTypeSizes = "IEC61131_BOOL"
+    ModbusDataTypeSizes_BYTE ModbusDataTypeSizes = "IEC61131_BYTE"
+    ModbusDataTypeSizes_WORD ModbusDataTypeSizes = "IEC61131_WORD"
+    ModbusDataTypeSizes_DWORD ModbusDataTypeSizes = "IEC61131_DWORD"
+    ModbusDataTypeSizes_LWORD ModbusDataTypeSizes = "IEC61131_LWORD"
+    ModbusDataTypeSizes_SINT ModbusDataTypeSizes = "IEC61131_SINT"
+    ModbusDataTypeSizes_INT ModbusDataTypeSizes = "IEC61131_INT"
+    ModbusDataTypeSizes_DINT ModbusDataTypeSizes = "IEC61131_DINT"
+    ModbusDataTypeSizes_LINT ModbusDataTypeSizes = "IEC61131_LINT"
+    ModbusDataTypeSizes_USINT ModbusDataTypeSizes = "IEC61131_USINT"
+    ModbusDataTypeSizes_UINT ModbusDataTypeSizes = "IEC61131_UINT"
+    ModbusDataTypeSizes_UDINT ModbusDataTypeSizes = "IEC61131_UDINT"
+    ModbusDataTypeSizes_ULINT ModbusDataTypeSizes = "IEC61131_ULINT"
+    ModbusDataTypeSizes_REAL ModbusDataTypeSizes = "IEC61131_REAL"
+    ModbusDataTypeSizes_LREAL ModbusDataTypeSizes = "IEC61131_LREAL"
+    ModbusDataTypeSizes_TIME ModbusDataTypeSizes = "IEC61131_TIME"
+    ModbusDataTypeSizes_LTIME ModbusDataTypeSizes = "IEC61131_LTIME"
+    ModbusDataTypeSizes_DATE ModbusDataTypeSizes = "IEC61131_DATE"
+    ModbusDataTypeSizes_LDATE ModbusDataTypeSizes = "IEC61131_LDATE"
+    ModbusDataTypeSizes_TIME_OF_DAY ModbusDataTypeSizes = "IEC61131_TIME_OF_DAY"
+    ModbusDataTypeSizes_LTIME_OF_DAY ModbusDataTypeSizes = "IEC61131_LTIME_OF_DAY"
+    ModbusDataTypeSizes_DATE_AND_TIME ModbusDataTypeSizes = "IEC61131_DATE_AND_TIME"
+    ModbusDataTypeSizes_LDATE_AND_TIME ModbusDataTypeSizes = "IEC61131_LDATE_AND_TIME"
+    ModbusDataTypeSizes_CHAR ModbusDataTypeSizes = "IEC61131_CHAR"
+    ModbusDataTypeSizes_WCHAR ModbusDataTypeSizes = "IEC61131_WCHAR"
+    ModbusDataTypeSizes_STRING ModbusDataTypeSizes = "IEC61131_STRING"
+    ModbusDataTypeSizes_WSTRING ModbusDataTypeSizes = "IEC61131_WSTRING"
+)
+
+
+func (e ModbusDataTypeSizes) DataTypeSize() uint8 {
+    switch e  {
+        case "IEC61131_BOOL": { /* 'IEC61131_BOOL' */
+            return 1
+        }
+        case "IEC61131_BYTE": { /* 'IEC61131_BYTE' */
+            return 1
+        }
+        case "IEC61131_CHAR": { /* 'IEC61131_CHAR' */
+            return 1
+        }
+        case "IEC61131_DATE": { /* 'IEC61131_DATE' */
+            return 8
+        }
+        case "IEC61131_DATE_AND_TIME": { /* 'IEC61131_DATE_AND_TIME' */
+            return 8
+        }
+        case "IEC61131_DINT": { /* 'IEC61131_DINT' */
+            return 4
+        }
+        case "IEC61131_DWORD": { /* 'IEC61131_DWORD' */
+            return 4
+        }
+        case "IEC61131_INT": { /* 'IEC61131_INT' */
+            return 2
+        }
+        case "IEC61131_LDATE": { /* 'IEC61131_LDATE' */
+            return 8
+        }
+        case "IEC61131_LDATE_AND_TIME": { /* 'IEC61131_LDATE_AND_TIME' */
+            return 8
+        }
+        case "IEC61131_LINT": { /* 'IEC61131_LINT' */
+            return 8
+        }
+        case "IEC61131_LREAL": { /* 'IEC61131_LREAL' */
+            return 8
+        }
+        case "IEC61131_LTIME": { /* 'IEC61131_LTIME' */
+            return 8
+        }
+        case "IEC61131_LTIME_OF_DAY": { /* 'IEC61131_LTIME_OF_DAY' */
+            return 8
+        }
+        case "IEC61131_LWORD": { /* 'IEC61131_LWORD' */
+            return 8
+        }
+        case "IEC61131_REAL": { /* 'IEC61131_REAL' */
+            return 4
+        }
+        case "IEC61131_SINT": { /* 'IEC61131_SINT' */
+            return 1
+        }
+        case "IEC61131_STRING": { /* 'IEC61131_STRING' */
+            return 1
+        }
+        case "IEC61131_TIME": { /* 'IEC61131_TIME' */
+            return 8
+        }
+        case "IEC61131_TIME_OF_DAY": { /* 'IEC61131_TIME_OF_DAY' */
+            return 8
+        }
+        case "IEC61131_UDINT": { /* 'IEC61131_UDINT' */
+            return 4
+        }
+        case "IEC61131_UINT": { /* 'IEC61131_UINT' */
+            return 2
+        }
+        case "IEC61131_ULINT": { /* 'IEC61131_ULINT' */
+            return 8
+        }
+        case "IEC61131_USINT": { /* 'IEC61131_USINT' */
+            return 1
+        }
+        case "IEC61131_WCHAR": { /* 'IEC61131_WCHAR' */
+            return 2
+        }
+        case "IEC61131_WORD": { /* 'IEC61131_WORD' */
+            return 2
+        }
+        case "IEC61131_WSTRING": { /* 'IEC61131_WSTRING' */
+            return 2
+        }
+        default: {
+            return 0
+        }
+    }
+}
+func ModbusDataTypeSizesValueOf(value string) ModbusDataTypeSizes {
+    switch value {
+        case "IEC61131_BOOL":
+            return ModbusDataTypeSizes_BOOL
+        case "IEC61131_BYTE":
+            return ModbusDataTypeSizes_BYTE
+        case "IEC61131_CHAR":
+            return ModbusDataTypeSizes_CHAR
+        case "IEC61131_DATE":
+            return ModbusDataTypeSizes_DATE
+        case "IEC61131_DATE_AND_TIME":
+            return ModbusDataTypeSizes_DATE_AND_TIME
+        case "IEC61131_DINT":
+            return ModbusDataTypeSizes_DINT
+        case "IEC61131_DWORD":
+            return ModbusDataTypeSizes_DWORD
+        case "IEC61131_INT":
+            return ModbusDataTypeSizes_INT
+        case "IEC61131_LDATE":
+            return ModbusDataTypeSizes_LDATE
+        case "IEC61131_LDATE_AND_TIME":
+            return ModbusDataTypeSizes_LDATE_AND_TIME
+        case "IEC61131_LINT":
+            return ModbusDataTypeSizes_LINT
+        case "IEC61131_LREAL":
+            return ModbusDataTypeSizes_LREAL
+        case "IEC61131_LTIME":
+            return ModbusDataTypeSizes_LTIME
+        case "IEC61131_LTIME_OF_DAY":
+            return ModbusDataTypeSizes_LTIME_OF_DAY
+        case "IEC61131_LWORD":
+            return ModbusDataTypeSizes_LWORD
+        case "IEC61131_REAL":
+            return ModbusDataTypeSizes_REAL
+        case "IEC61131_SINT":
+            return ModbusDataTypeSizes_SINT
+        case "IEC61131_STRING":
+            return ModbusDataTypeSizes_STRING
+        case "IEC61131_TIME":
+            return ModbusDataTypeSizes_TIME
+        case "IEC61131_TIME_OF_DAY":
+            return ModbusDataTypeSizes_TIME_OF_DAY
+        case "IEC61131_UDINT":
+            return ModbusDataTypeSizes_UDINT
+        case "IEC61131_UINT":
+            return ModbusDataTypeSizes_UINT
+        case "IEC61131_ULINT":
+            return ModbusDataTypeSizes_ULINT
+        case "IEC61131_USINT":
+            return ModbusDataTypeSizes_USINT
+        case "IEC61131_WCHAR":
+            return ModbusDataTypeSizes_WCHAR
+        case "IEC61131_WORD":
+            return ModbusDataTypeSizes_WORD
+        case "IEC61131_WSTRING":
+            return ModbusDataTypeSizes_WSTRING
+    }
+    return ""
+}
+
+func CastModbusDataTypeSizes(structType interface{}) ModbusDataTypeSizes {
+    castFunc := func(typ interface{}) ModbusDataTypeSizes {
+        if sModbusDataTypeSizes, ok := typ.(ModbusDataTypeSizes); ok {
+            return sModbusDataTypeSizes
+        }
+        return ""
+    }
+    return castFunc(structType)
+}
+
+func (m ModbusDataTypeSizes) LengthInBits() uint16 {
+    return 0
+}
+
+func (m ModbusDataTypeSizes) LengthInBytes() uint16 {
+    return m.LengthInBits() / 8
+}
+
+func ModbusDataTypeSizesParse(io *spi.ReadBuffer) (ModbusDataTypeSizes, error) {
+    // TODO: Implement ...
+    return "", nil
+}
+
+func (e ModbusDataTypeSizes) Serialize(io spi.WriteBuffer) error {
+    // TODO: Implement ...
+    return nil
+}
diff --git a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go
index 0831eaa..32c42f7 100644
--- a/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go
+++ b/sandbox/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go
@@ -40,6 +40,31 @@ const(
     ModbusErrorCode_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND ModbusErrorCode = 11
 )
 
+func ModbusErrorCodeValueOf(value uint8) ModbusErrorCode {
+    switch value {
+        case 1:
+            return ModbusErrorCode_ILLEGAL_FUNCTION
+        case 10:
+            return ModbusErrorCode_GATEWAY_PATH_UNAVAILABLE
+        case 11:
+            return ModbusErrorCode_GATEWAY_TARGET_DEVICE_FAILED_TO_RESPOND
+        case 2:
+            return ModbusErrorCode_ILLEGAL_DATA_ADDRESS
+        case 3:
+            return ModbusErrorCode_ILLEGAL_DATA_VALUE
+        case 4:
+            return ModbusErrorCode_SLAVE_DEVICE_FAILURE
+        case 5:
+            return ModbusErrorCode_ACKNOWLEDGE
+        case 6:
+            return ModbusErrorCode_SLAVE_DEVICE_BUSY
+        case 7:
+            return ModbusErrorCode_NEGATIVE_ACKNOWLEDGE
+        case 8:
+            return ModbusErrorCode_MEMORY_PARITY_ERROR
+    }
+    return 0
+}
 
 func CastModbusErrorCode(structType interface{}) ModbusErrorCode {
     castFunc := func(typ interface{}) ModbusErrorCode {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
index c28600c..1efe2d5 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
@@ -35,6 +35,21 @@ const(
     COTPProtocolClass_CLASS_4 COTPProtocolClass = 0x40
 )
 
+func COTPProtocolClassValueOf(value int8) COTPProtocolClass {
+    switch value {
+        case 0x00:
+            return COTPProtocolClass_CLASS_0
+        case 0x10:
+            return COTPProtocolClass_CLASS_1
+        case 0x20:
+            return COTPProtocolClass_CLASS_2
+        case 0x30:
+            return COTPProtocolClass_CLASS_3
+        case 0x40:
+            return COTPProtocolClass_CLASS_4
+    }
+    return 0
+}
 
 func CastCOTPProtocolClass(structType interface{}) COTPProtocolClass {
     castFunc := func(typ interface{}) COTPProtocolClass {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
index 43700e9..9f5cedd 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
@@ -67,6 +67,25 @@ func (e COTPTpduSize) SizeInBytes() uint16 {
         }
     }
 }
+func COTPTpduSizeValueOf(value int8) COTPTpduSize {
+    switch value {
+        case 0x07:
+            return COTPTpduSize_SIZE_128
+        case 0x08:
+            return COTPTpduSize_SIZE_256
+        case 0x09:
+            return COTPTpduSize_SIZE_512
+        case 0x0a:
+            return COTPTpduSize_SIZE_1024
+        case 0x0b:
+            return COTPTpduSize_SIZE_2048
+        case 0x0c:
+            return COTPTpduSize_SIZE_4096
+        case 0x0d:
+            return COTPTpduSize_SIZE_8192
+    }
+    return 0
+}
 
 func CastCOTPTpduSize(structType interface{}) COTPTpduSize {
     castFunc := func(typ interface{}) COTPTpduSize {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
index 9c25171..262996a 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
@@ -36,6 +36,23 @@ const(
     DataTransportErrorCode_NOT_FOUND DataTransportErrorCode = 0x0A
 )
 
+func DataTransportErrorCodeValueOf(value uint8) DataTransportErrorCode {
+    switch value {
+        case 0x00:
+            return DataTransportErrorCode_RESERVED
+        case 0x03:
+            return DataTransportErrorCode_ACCESS_DENIED
+        case 0x05:
+            return DataTransportErrorCode_INVALID_ADDRESS
+        case 0x06:
+            return DataTransportErrorCode_DATA_TYPE_NOT_SUPPORTED
+        case 0x0A:
+            return DataTransportErrorCode_NOT_FOUND
+        case 0xFF:
+            return DataTransportErrorCode_OK
+    }
+    return 0
+}
 
 func CastDataTransportErrorCode(structType interface{}) DataTransportErrorCode {
     castFunc := func(typ interface{}) DataTransportErrorCode {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
index 90e47b6..6db6595 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
@@ -67,6 +67,25 @@ func (e DataTransportSize) SizeInBits() bool {
         }
     }
 }
+func DataTransportSizeValueOf(value uint8) DataTransportSize {
+    switch value {
+        case 0x00:
+            return DataTransportSize_NULL
+        case 0x03:
+            return DataTransportSize_BIT
+        case 0x04:
+            return DataTransportSize_BYTE_WORD_DWORD
+        case 0x05:
+            return DataTransportSize_INTEGER
+        case 0x06:
+            return DataTransportSize_DINTEGER
+        case 0x07:
+            return DataTransportSize_REAL
+        case 0x09:
+            return DataTransportSize_OCTET_STRING
+    }
+    return 0
+}
 
 func CastDataTransportSize(structType interface{}) DataTransportSize {
     castFunc := func(typ interface{}) DataTransportSize {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
index d01ae11..4d47f48 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
@@ -33,6 +33,17 @@ const(
     DeviceGroup_OTHERS DeviceGroup = 0x03
 )
 
+func DeviceGroupValueOf(value int8) DeviceGroup {
+    switch value {
+        case 0x01:
+            return DeviceGroup_PG_OR_PC
+        case 0x02:
+            return DeviceGroup_OS
+        case 0x03:
+            return DeviceGroup_OTHERS
+    }
+    return 0
+}
 
 func CastDeviceGroup(structType interface{}) DeviceGroup {
     castFunc := func(typ interface{}) DeviceGroup {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
index 10db3bd..7ded870 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
@@ -75,6 +75,29 @@ func (e MemoryArea) ShortName() string {
         }
     }
 }
+func MemoryAreaValueOf(value uint8) MemoryArea {
+    switch value {
+        case 0x1C:
+            return MemoryArea_COUNTERS
+        case 0x1D:
+            return MemoryArea_TIMERS
+        case 0x80:
+            return MemoryArea_DIRECT_PERIPHERAL_ACCESS
+        case 0x81:
+            return MemoryArea_INPUTS
+        case 0x82:
+            return MemoryArea_OUTPUTS
+        case 0x83:
+            return MemoryArea_FLAGS_MARKERS
+        case 0x84:
+            return MemoryArea_DATA_BLOCKS
+        case 0x85:
+            return MemoryArea_INSTANCE_DATA_BLOCKS
+        case 0x86:
+            return MemoryArea_LOCAL_DATA
+    }
+    return 0
+}
 
 func CastMemoryArea(structType interface{}) MemoryArea {
     castFunc := func(typ interface{}) MemoryArea {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
index ff33843..64e8754 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
@@ -34,6 +34,19 @@ const(
     SzlModuleTypeClass_CP SzlModuleTypeClass = 0xC
 )
 
+func SzlModuleTypeClassValueOf(value uint8) SzlModuleTypeClass {
+    switch value {
+        case 0x0:
+            return SzlModuleTypeClass_CPU
+        case 0x4:
+            return SzlModuleTypeClass_IM
+        case 0x8:
+            return SzlModuleTypeClass_FM
+        case 0xC:
+            return SzlModuleTypeClass_CP
+    }
+    return 0
+}
 
 func CastSzlModuleTypeClass(structType interface{}) SzlModuleTypeClass {
     castFunc := func(typ interface{}) SzlModuleTypeClass {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
index d04c34b..0885603 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
@@ -49,6 +49,49 @@ const(
     SzlSublist_MODULE_DIAGNOSTIC_DATA SzlSublist = 0xB1
 )
 
+func SzlSublistValueOf(value uint8) SzlSublist {
+    switch value {
+        case 0x11:
+            return SzlSublist_MODULE_IDENTIFICATION
+        case 0x12:
+            return SzlSublist_CPU_FEATURES
+        case 0x13:
+            return SzlSublist_USER_MEMORY_AREA
+        case 0x14:
+            return SzlSublist_SYSTEM_AREAS
+        case 0x15:
+            return SzlSublist_BLOCK_TYPES
+        case 0x19:
+            return SzlSublist_STATUS_MODULE_LEDS
+        case 0x1C:
+            return SzlSublist_COMPONENT_IDENTIFICATION
+        case 0x22:
+            return SzlSublist_INTERRUPT_STATUS
+        case 0x25:
+            return SzlSublist_ASSIGNMENT_BETWEEN_PROCESS_IMAGE_PARTITIONS_AND_OBS
+        case 0x32:
+            return SzlSublist_COMMUNICATION_STATUS_DATA
+        case 0x74:
+            return SzlSublist_STATUS_SINGLE_MODULE_LED
+        case 0x90:
+            return SzlSublist_DP_MASTER_SYSTEM_INFORMATION
+        case 0x91:
+            return SzlSublist_MODULE_STATUS_INFORMATION
+        case 0x92:
+            return SzlSublist_RACK_OR_STATION_STATUS_INFORMATION
+        case 0x94:
+            return SzlSublist_RACK_OR_STATION_STATUS_INFORMATION_2
+        case 0x95:
+            return SzlSublist_ADDITIONAL_DP_MASTER_SYSTEM_OR_PROFINET_IO_SYSTEM_INFORMATION
+        case 0x96:
+            return SzlSublist_MODULE_STATUS_INFORMATION_PROFINET_IO_AND_PROFIBUS_DP
+        case 0xA0:
+            return SzlSublist_DIAGNOSTIC_BUFFER
+        case 0xB1:
+            return SzlSublist_MODULE_DIAGNOSTIC_DATA
+    }
+    return 0
+}
 
 func CastSzlSublist(structType interface{}) SzlSublist {
     castFunc := func(typ interface{}) SzlSublist {
diff --git a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
index 181d922..84881d3 100644
--- a/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
+++ b/sandbox/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
@@ -625,6 +625,43 @@ func (e TransportSize) DataProtocolId() uint8 {
         }
     }
 }
+func TransportSizeValueOf(value int8) TransportSize {
+    switch value {
+        case 0x00:
+            return TransportSize_LWORD
+        case 0x01:
+            return TransportSize_BOOL
+        case 0x02:
+            return TransportSize_BYTE
+        case 0x03:
+            return TransportSize_CHAR
+        case 0x04:
+            return TransportSize_WORD
+        case 0x05:
+            return TransportSize_INT
+        case 0x06:
+            return TransportSize_DWORD
+        case 0x07:
+            return TransportSize_DINT
+        case 0x08:
+            return TransportSize_REAL
+        case 0x09:
+            return TransportSize_DATE
+        case 0x0A:
+            return TransportSize_TIME_OF_DAY
+        case 0x0B:
+            return TransportSize_TIME
+        case 0x0C:
+            return TransportSize_S5TIME
+        case 0x0F:
+            return TransportSize_DATE_AND_TIME
+        case 0x13:
+            return TransportSize_WCHAR
+        case 0x30:
+            return TransportSize_LREAL
+    }
+    return 0
+}
 
 func CastTransportSize(structType interface{}) TransportSize {
     castFunc := func(typ interface{}) TransportSize {
diff --git a/sandbox/plc4go/internal/plc4go/spi/ReadBuffer.go b/sandbox/plc4go/internal/plc4go/spi/ReadBuffer.go
index fd6c33d..e410e61 100644
--- a/sandbox/plc4go/internal/plc4go/spi/ReadBuffer.go
+++ b/sandbox/plc4go/internal/plc4go/spi/ReadBuffer.go
@@ -21,6 +21,7 @@ package spi
 import (
 	"bytes"
 	"github.com/icza/bitio"
+    "math"
 )
 
 type ReadBuffer struct {
@@ -138,7 +139,8 @@ func (rb *ReadBuffer) ReadInt64(bitLength uint8) (int64, error) {
 
 func (rb *ReadBuffer) ReadFloat32(bitLength uint8) (float32, error) {
 	rb.pos += uint64(bitLength)
-	res := float32(rb.reader.TryReadBits(bitLength))
+    uintValue := uint32(rb.reader.TryReadBits(bitLength))
+	res := math.Float32frombits(uintValue)
 	if rb.reader.TryError != nil {
 		return 0, rb.reader.TryError
 	}
@@ -147,7 +149,8 @@ func (rb *ReadBuffer) ReadFloat32(bitLength uint8) (float32, error) {
 
 func (rb *ReadBuffer) ReadFloat64(bitLength uint8) (float64, error) {
 	rb.pos += uint64(bitLength)
-	res := float64(rb.reader.TryReadBits(bitLength))
+	uintValue := rb.reader.TryReadBits(bitLength)
+	res := math.Float64frombits(uintValue)
 	if rb.reader.TryError != nil {
 		return 0, rb.reader.TryError
 	}