This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new f62f7dd plc4go: introduced WriterArgs for optional arguments
f62f7dd is described below
commit f62f7dd9c37773359019d62145789c851ea8073e
Author: Sebastian Rühl <[email protected]>
AuthorDate: Mon Apr 19 12:09:02 2021 +0200
plc4go: introduced WriterArgs for optional arguments
+ Currently enums can supply a rendered variant for itself.
---
.../language/go/GoLanguageTemplateHelper.java | 54 +++++-----
.../resources/templates/go/enum-template.go.ftlh | 2 +-
go.mod | 2 +-
go.sum | 2 +
.../plc4go/ads/readwrite/model/AdsDataType.go | 2 +-
.../plc4go/ads/readwrite/model/CommandId.go | 2 +-
.../ads/readwrite/model/ReservedIndexGroups.go | 2 +-
.../plc4go/ads/readwrite/model/ReturnCode.go | 2 +-
.../bacnetip/readwrite/model/ApplicationTag.go | 2 +-
.../bacnetip/readwrite/model/BACnetNetworkType.go | 2 +-
.../bacnetip/readwrite/model/BACnetNodeType.go | 2 +-
.../bacnetip/readwrite/model/BACnetNotifyType.go | 2 +-
.../bacnetip/readwrite/model/BACnetObjectType.go | 2 +-
.../plc4go/knxnetip/readwrite/model/AccessLevel.go | 2 +-
.../knxnetip/readwrite/model/CEMIPriority.go | 2 +-
.../readwrite/model/ComObjectTableAddresses.go | 2 +-
.../knxnetip/readwrite/model/ComObjectValueType.go | 2 +-
.../knxnetip/readwrite/model/DeviceDescriptor.go | 2 +-
.../readwrite/model/DeviceDescriptorMediumType.go | 2 +-
.../knxnetip/readwrite/model/FirmwareType.go | 2 +-
.../knxnetip/readwrite/model/HostProtocolCode.go | 2 +-
.../readwrite/model/KnxDatapointMainType.go | 2 +-
.../knxnetip/readwrite/model/KnxDatapointType.go | 2 +-
.../readwrite/model/KnxInterfaceObjectProperty.go | 2 +-
.../readwrite/model/KnxInterfaceObjectType.go | 2 +-
.../plc4go/knxnetip/readwrite/model/KnxLayer.go | 2 +-
.../knxnetip/readwrite/model/KnxManufacturer.go | 2 +-
.../plc4go/knxnetip/readwrite/model/KnxMedium.go | 2 +-
.../readwrite/model/KnxPropertyDataType.go | 2 +-
.../plc4go/knxnetip/readwrite/model/Status.go | 2 +-
.../readwrite/model/SupportedPhysicalMedia.go | 2 +-
.../modbus/readwrite/model/ModbusDataType.go | 2 +-
.../modbus/readwrite/model/ModbusErrorCode.go | 2 +-
.../plc4go/s7/readwrite/model/COTPProtocolClass.go | 2 +-
.../plc4go/s7/readwrite/model/COTPTpduSize.go | 2 +-
.../s7/readwrite/model/DataTransportErrorCode.go | 2 +-
.../plc4go/s7/readwrite/model/DataTransportSize.go | 2 +-
.../plc4go/s7/readwrite/model/DeviceGroup.go | 2 +-
.../plc4go/s7/readwrite/model/MemoryArea.go | 2 +-
.../s7/readwrite/model/SzlModuleTypeClass.go | 2 +-
.../plc4go/s7/readwrite/model/SzlSublist.go | 2 +-
.../plc4go/s7/readwrite/model/TransportSize.go | 2 +-
plc4go/internal/plc4go/s7/s7Io_test.go | 10 +-
plc4go/internal/plc4go/spi/utils/WriteBuffer.go | 54 +++++++---
.../plc4go/spi/utils/WriteBufferBoxBased.go | 109 +++++++++++++++------
.../plc4go/spi/utils/WriteBufferByteBased.go | 30 +++---
46 files changed, 211 insertions(+), 128 deletions(-)
diff --git
a/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
b/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
index 7ba2332..84f0dcc 100644
---
a/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
+++
b/build-utils/language-go/src/main/java/org/apache/plc4x/language/go/GoLanguageTemplateHelper.java
@@ -74,7 +74,7 @@ public class GoLanguageTemplateHelper extends
BaseFreemarkerLanguageTemplateHelp
}
public boolean isComplex(Field field) {
- return field instanceof PropertyField &&
((PropertyField)field).getType() instanceof ComplexTypeReference;
+ return field instanceof PropertyField && ((PropertyField)
field).getType() instanceof ComplexTypeReference;
}
@Override
@@ -335,64 +335,68 @@ public class GoLanguageTemplateHelper extends
BaseFreemarkerLanguageTemplateHelp
@Override
public String getWriteBufferWriteMethodCall(SimpleTypeReference
simpleTypeReference, String fieldName, TypedField field) {
// Fallback if somewhere the method gets called without a name
- String logicalName =
fieldName.replaceAll("[\"()*]","").replaceFirst("_","");
- return getWriteBufferWriteMethodCall(logicalName,simpleTypeReference,
fieldName, field);
+ String logicalName = fieldName.replaceAll("[\"()*]",
"").replaceFirst("_", "");
+ return getWriteBufferWriteMethodCall(logicalName, simpleTypeReference,
fieldName, field);
}
- public String getWriteBufferWriteMethodCall(String
logicalName,SimpleTypeReference simpleTypeReference, String fieldName,
TypedField field) {
+ public String getWriteBufferWriteMethodCall(String logicalName,
SimpleTypeReference simpleTypeReference, String fieldName, TypedField field,
String... writerArgs) {
+ String writerArgsString = "";
+ if (writerArgs.length > 0) {
+ writerArgsString += ", " + StringUtils.join(writerArgs, ", ");
+ }
switch (simpleTypeReference.getBaseType()) {
case BIT: {
- return "io.WriteBit(\""+logicalName+"\", " + fieldName + ")";
+ return "io.WriteBit(\"" + logicalName + "\", " + fieldName +
writerArgsString + ")";
}
case UINT: {
IntegerTypeReference integerTypeReference =
(IntegerTypeReference) simpleTypeReference;
if (integerTypeReference.getSizeInBits() <= 8) {
- return "io.WriteUint8(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteUint8(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
if (integerTypeReference.getSizeInBits() <= 16) {
- return "io.WriteUint16(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteUint16(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
if (integerTypeReference.getSizeInBits() <= 32) {
- return "io.WriteUint32(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteUint32(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
if (integerTypeReference.getSizeInBits() <= 64) {
- return "io.WriteUint64(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteUint64(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
- return "io.WriteBigInt(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteBigInt(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
case INT: {
IntegerTypeReference integerTypeReference =
(IntegerTypeReference) simpleTypeReference;
if (integerTypeReference.getSizeInBits() <= 8) {
- return "io.WriteInt8(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteInt8(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
if (integerTypeReference.getSizeInBits() <= 16) {
- return "io.WriteInt16(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteInt16(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
if (integerTypeReference.getSizeInBits() <= 32) {
- return "io.WriteInt32(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteInt32(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
if (integerTypeReference.getSizeInBits() <= 64) {
- return "io.WriteInt64(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteInt64(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
- return "io.WriteBigInt(\""+logicalName+"\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteBigInt(\"" + logicalName + "\", " +
integerTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString +
")";
}
case FLOAT:
case UFLOAT: {
FloatTypeReference floatTypeReference = (FloatTypeReference)
simpleTypeReference;
if (floatTypeReference.getSizeInBits() <= 32) {
- return "io.WriteFloat32(\""+logicalName+"\", " +
floatTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteFloat32(\"" + logicalName + "\", " +
floatTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString + ")";
}
if (floatTypeReference.getSizeInBits() <= 64) {
- return "io.WriteFloat64(\""+logicalName+"\", " +
floatTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteFloat64(\"" + logicalName + "\", " +
floatTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString + ")";
}
- return "io.WriteBigFloat(\""+logicalName+"\", " +
floatTypeReference.getSizeInBits() + ", " + fieldName + ")";
+ return "io.WriteBigFloat(\"" + logicalName + "\", " +
floatTypeReference.getSizeInBits() + ", " + fieldName + writerArgsString + ")";
}
case STRING: {
StringTypeReference stringTypeReference =
(StringTypeReference) simpleTypeReference;
String encoding = ((stringTypeReference.getEncoding() != null)
&& (stringTypeReference.getEncoding().length() > 2)) ?
stringTypeReference.getEncoding().substring(1,
stringTypeReference.getEncoding().length() - 1) : "UTF-8";
- return "io.WriteString(\""+logicalName+"\", uint8(" +
toSerializationExpression(field, stringTypeReference.getLengthExpression(),
getThisTypeDefinition().getParserArguments()) + "), \"" +
- encoding + "\", " + fieldName + ")";
+ return "io.WriteString(\"" + logicalName + "\", uint8(" +
toSerializationExpression(field, stringTypeReference.getLengthExpression(),
getThisTypeDefinition().getParserArguments()) + "), \"" +
+ encoding + "\", " + fieldName + writerArgsString + ")";
}
}
return "Hurz";
@@ -528,7 +532,7 @@ public class GoLanguageTemplateHelper extends
BaseFreemarkerLanguageTemplateHelp
" (" + toExpression(null, b, parserArguments,
serializerArguments, serialize, suppressPointerAccessOverride) + "))";
default:
if (fieldType instanceof StringTypeReference) {
- return toExpression(fieldType, a, parserArguments,
serializerArguments, serialize, false) +
+ return toExpression(fieldType, a, parserArguments,
serializerArguments, serialize, false) +
operation + " " +
toExpression(fieldType, b, parserArguments,
serializerArguments, serialize, false);
}
@@ -757,12 +761,12 @@ public class GoLanguageTemplateHelper extends
BaseFreemarkerLanguageTemplateHelp
return vl.getName() + ((vl.getChild() != null) ?
"." + toVariableExpression(typeReference, vl.getChild(),
parserArguments, serializerArguments, false, suppressPointerAccess) : "");
}
- String indexCall="";
- if (vl.getIndex() >= 0){
+ String indexCall = "";
+ if (vl.getIndex() >= 0) {
// We have a index call
- indexCall = "["+vl.getIndex()+"]";
+ indexCall = "[" + vl.getIndex() + "]";
}
- return (serialize ? "m." + StringUtils.capitalize(vl.getName()) :
vl.getName()) +indexCall+ ((vl.getChild() != null) ?
+ return (serialize ? "m." + StringUtils.capitalize(vl.getName()) :
vl.getName()) + indexCall + ((vl.getChild() != null) ?
"." + StringUtils.capitalize(toVariableExpression(typeReference,
vl.getChild(), parserArguments, serializerArguments, false,
suppressPointerAccess)) : "");
}
diff --git
a/build-utils/language-go/src/main/resources/templates/go/enum-template.go.ftlh
b/build-utils/language-go/src/main/resources/templates/go/enum-template.go.ftlh
index 65f0414..2887de0 100644
---
a/build-utils/language-go/src/main/resources/templates/go/enum-template.go.ftlh
+++
b/build-utils/language-go/src/main/resources/templates/go/enum-template.go.ftlh
@@ -168,7 +168,7 @@ func ${type.name}Parse(io utils.ReadBuffer) (${type.name},
error) {
}
func (e ${type.name}) Serialize(io utils.WriteBuffer) error {
- err := ${helper.getWriteBufferWriteMethodCall(type.name,
helper.getEnumBaseTypeReference(type.typeReference),
helper.getLanguageTypeNameForTypeReference(helper.getEnumBaseTypeReference(type.typeReference))
+ "(e)", null)}
+ err := ${helper.getWriteBufferWriteMethodCall(type.name,
helper.getEnumBaseTypeReference(type.typeReference),
helper.getLanguageTypeNameForTypeReference(helper.getEnumBaseTypeReference(type.typeReference))
+ "(e)", null, "utils.WithAdditionalStringRepresentation(e.name())")}
return err
}
</#if>
diff --git a/go.mod b/go.mod
index 4b9be64..4bac427 100644
--- a/go.mod
+++ b/go.mod
@@ -21,6 +21,6 @@ module github.com/apache/plc4x
go 1.15
require (
- github.com/apache/plc4x/plc4go v0.0.0-20210418221506-2292848a04fe //
indirect
+ github.com/apache/plc4x/plc4go v0.0.0-20210419074057-6deb18d3d472 //
indirect
github.com/sirupsen/logrus v1.7.0 // indirect
)
diff --git a/go.sum b/go.sum
index 086eeb2..9e5f90c 100644
--- a/go.sum
+++ b/go.sum
@@ -86,6 +86,8 @@ github.com/apache/plc4x/plc4go
v0.0.0-20210418200404-fc1c1b76ee32 h1:jsUKZHIEse3
github.com/apache/plc4x/plc4go v0.0.0-20210418200404-fc1c1b76ee32/go.mod
h1:d7O6kgWHhwFxXbMbl1DSu55qCYcQz9uwjdsSSJOEA/4=
github.com/apache/plc4x/plc4go v0.0.0-20210418221506-2292848a04fe
h1:paOfmjd5VH3e+sqZBboWchU+pZk2qDWLKdrXBUiv2D8=
github.com/apache/plc4x/plc4go v0.0.0-20210418221506-2292848a04fe/go.mod
h1:d7O6kgWHhwFxXbMbl1DSu55qCYcQz9uwjdsSSJOEA/4=
+github.com/apache/plc4x/plc4go v0.0.0-20210419074057-6deb18d3d472
h1:Z4OnG7I8U3Q2sVvHBFLbWBO4WO22VWuxpoFeCqVAVL0=
+github.com/apache/plc4x/plc4go v0.0.0-20210419074057-6deb18d3d472/go.mod
h1:d7O6kgWHhwFxXbMbl1DSu55qCYcQz9uwjdsSSJOEA/4=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod
h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.1/go.mod
h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dnephin/pflag v1.0.7/go.mod
h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE=
diff --git a/plc4go/internal/plc4go/ads/readwrite/model/AdsDataType.go
b/plc4go/internal/plc4go/ads/readwrite/model/AdsDataType.go
index 79c2b1a..b0c37d3 100644
--- a/plc4go/internal/plc4go/ads/readwrite/model/AdsDataType.go
+++ b/plc4go/internal/plc4go/ads/readwrite/model/AdsDataType.go
@@ -664,7 +664,7 @@ func AdsDataTypeParse(io utils.ReadBuffer) (AdsDataType,
error) {
}
func (e AdsDataType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteInt8("AdsDataType", 8, int8(e))
+ err := io.WriteInt8("AdsDataType", 8, int8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/ads/readwrite/model/CommandId.go
b/plc4go/internal/plc4go/ads/readwrite/model/CommandId.go
index 14eb7ae..3960ed5 100644
--- a/plc4go/internal/plc4go/ads/readwrite/model/CommandId.go
+++ b/plc4go/internal/plc4go/ads/readwrite/model/CommandId.go
@@ -145,7 +145,7 @@ func CommandIdParse(io utils.ReadBuffer) (CommandId, error)
{
}
func (e CommandId) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("CommandId", 16, uint16(e))
+ err := io.WriteUint16("CommandId", 16, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/ads/readwrite/model/ReservedIndexGroups.go
b/plc4go/internal/plc4go/ads/readwrite/model/ReservedIndexGroups.go
index 1338937..f0daafd 100644
--- a/plc4go/internal/plc4go/ads/readwrite/model/ReservedIndexGroups.go
+++ b/plc4go/internal/plc4go/ads/readwrite/model/ReservedIndexGroups.go
@@ -265,7 +265,7 @@ func ReservedIndexGroupsParse(io utils.ReadBuffer)
(ReservedIndexGroups, error)
}
func (e ReservedIndexGroups) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint32("ReservedIndexGroups", 32, uint32(e))
+ err := io.WriteUint32("ReservedIndexGroups", 32, uint32(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/ads/readwrite/model/ReturnCode.go
b/plc4go/internal/plc4go/ads/readwrite/model/ReturnCode.go
index d0e4725..c56c5fc 100644
--- a/plc4go/internal/plc4go/ads/readwrite/model/ReturnCode.go
+++ b/plc4go/internal/plc4go/ads/readwrite/model/ReturnCode.go
@@ -817,7 +817,7 @@ func ReturnCodeParse(io utils.ReadBuffer) (ReturnCode,
error) {
}
func (e ReturnCode) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint32("ReturnCode", 32, uint32(e))
+ err := io.WriteUint32("ReturnCode", 32, uint32(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go
b/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go
index 9eaae3e..965a10a 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/ApplicationTag.go
@@ -163,7 +163,7 @@ func ApplicationTagParse(io utils.ReadBuffer)
(ApplicationTag, error) {
}
func (e ApplicationTag) Serialize(io utils.WriteBuffer) error {
- err := io.WriteInt8("ApplicationTag", 4, int8(e))
+ err := io.WriteInt8("ApplicationTag", 4, int8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go
b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go
index 78e2912..e1d7d86 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNetworkType.go
@@ -151,7 +151,7 @@ func BACnetNetworkTypeParse(io utils.ReadBuffer)
(BACnetNetworkType, error) {
}
func (e BACnetNetworkType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("BACnetNetworkType", 4, uint8(e))
+ err := io.WriteUint8("BACnetNetworkType", 4, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go
b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go
index bc042a3..ed9378a 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNodeType.go
@@ -217,7 +217,7 @@ func BACnetNodeTypeParse(io utils.ReadBuffer)
(BACnetNodeType, error) {
}
func (e BACnetNodeType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("BACnetNodeType", 8, uint8(e))
+ err := io.WriteUint8("BACnetNodeType", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go
b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go
index f975401..7888ec4 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetNotifyType.go
@@ -103,7 +103,7 @@ func BACnetNotifyTypeParse(io utils.ReadBuffer)
(BACnetNotifyType, error) {
}
func (e BACnetNotifyType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("BACnetNotifyType", 4, uint8(e))
+ err := io.WriteUint8("BACnetNotifyType", 4, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go
b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go
index 84fd255..c8b3502 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetObjectType.go
@@ -439,7 +439,7 @@ func BACnetObjectTypeParse(io utils.ReadBuffer)
(BACnetObjectType, error) {
}
func (e BACnetObjectType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("BACnetObjectType", 10, uint16(e))
+ err := io.WriteUint16("BACnetObjectType", 10, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/AccessLevel.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/AccessLevel.go
index 26359f3..2e62da1 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/AccessLevel.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/AccessLevel.go
@@ -174,7 +174,7 @@ func AccessLevelParse(io utils.ReadBuffer) (AccessLevel,
error) {
}
func (e AccessLevel) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("AccessLevel", 4, uint8(e))
+ err := io.WriteUint8("AccessLevel", 4, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go
index 14cc206..a909614 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/CEMIPriority.go
@@ -109,7 +109,7 @@ func CEMIPriorityParse(io utils.ReadBuffer) (CEMIPriority,
error) {
}
func (e CEMIPriority) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("CEMIPriority", 2, uint8(e))
+ err := io.WriteUint8("CEMIPriority", 2, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectTableAddresses.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectTableAddresses.go
index 43fd569..fbab9cb 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectTableAddresses.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectTableAddresses.go
@@ -17154,7 +17154,7 @@ func ComObjectTableAddressesParse(io utils.ReadBuffer)
(ComObjectTableAddresses,
}
func (e ComObjectTableAddresses) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("ComObjectTableAddresses", 16, uint16(e))
+ err := io.WriteUint16("ComObjectTableAddresses", 16, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectValueType.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectValueType.go
index 3e01681..6094260 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectValueType.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/ComObjectValueType.go
@@ -244,7 +244,7 @@ func ComObjectValueTypeParse(io utils.ReadBuffer)
(ComObjectValueType, error) {
}
func (e ComObjectValueType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("ComObjectValueType", 8, uint8(e))
+ err := io.WriteUint8("ComObjectValueType", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptor.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptor.go
index 4030c56..5651167 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptor.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptor.go
@@ -510,7 +510,7 @@ func DeviceDescriptorParse(io utils.ReadBuffer)
(DeviceDescriptor, error) {
}
func (e DeviceDescriptor) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("DeviceDescriptor", 16, uint16(e))
+ err := io.WriteUint16("DeviceDescriptor", 16, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptorMediumType.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptorMediumType.go
index ece2a6a..28bb0bf 100644
---
a/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptorMediumType.go
+++
b/plc4go/internal/plc4go/knxnetip/readwrite/model/DeviceDescriptorMediumType.go
@@ -121,7 +121,7 @@ func DeviceDescriptorMediumTypeParse(io utils.ReadBuffer)
(DeviceDescriptorMediu
}
func (e DeviceDescriptorMediumType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("DeviceDescriptorMediumType", 4, uint8(e))
+ err := io.WriteUint8("DeviceDescriptorMediumType", 4, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/FirmwareType.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/FirmwareType.go
index 808e268..a0dbacb 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/FirmwareType.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/FirmwareType.go
@@ -181,7 +181,7 @@ func FirmwareTypeParse(io utils.ReadBuffer) (FirmwareType,
error) {
}
func (e FirmwareType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("FirmwareType", 16, uint16(e))
+ err := io.WriteUint16("FirmwareType", 16, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go
index dd8ab7f..bed9127 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/HostProtocolCode.go
@@ -97,7 +97,7 @@ func HostProtocolCodeParse(io utils.ReadBuffer)
(HostProtocolCode, error) {
}
func (e HostProtocolCode) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("HostProtocolCode", 8, uint8(e))
+ err := io.WriteUint8("HostProtocolCode", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointMainType.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointMainType.go
index 088e1a6..d41ec29 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointMainType.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointMainType.go
@@ -1194,7 +1194,7 @@ func KnxDatapointMainTypeParse(io utils.ReadBuffer)
(KnxDatapointMainType, error
}
func (e KnxDatapointMainType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("KnxDatapointMainType", 16, uint16(e))
+ err := io.WriteUint16("KnxDatapointMainType", 16, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointType.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointType.go
index 2537d35..a108349 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointType.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxDatapointType.go
@@ -6378,7 +6378,7 @@ func KnxDatapointTypeParse(io utils.ReadBuffer)
(KnxDatapointType, error) {
}
func (e KnxDatapointType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint32("KnxDatapointType", 32, uint32(e))
+ err := io.WriteUint32("KnxDatapointType", 32, uint32(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectProperty.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectProperty.go
index d66316e..2c39654 100644
---
a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectProperty.go
+++
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectProperty.go
@@ -4876,7 +4876,7 @@ func KnxInterfaceObjectPropertyParse(io utils.ReadBuffer)
(KnxInterfaceObjectPro
}
func (e KnxInterfaceObjectProperty) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint32("KnxInterfaceObjectProperty", 32, uint32(e))
+ err := io.WriteUint32("KnxInterfaceObjectProperty", 32, uint32(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectType.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectType.go
index 8728556..88875c0 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectType.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxInterfaceObjectType.go
@@ -454,7 +454,7 @@ func KnxInterfaceObjectTypeParse(io utils.ReadBuffer)
(KnxInterfaceObjectType, e
}
func (e KnxInterfaceObjectType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("KnxInterfaceObjectType", 16, uint16(e))
+ err := io.WriteUint16("KnxInterfaceObjectType", 16, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go
index ae6b5a0..0d126db 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxLayer.go
@@ -103,7 +103,7 @@ func KnxLayerParse(io utils.ReadBuffer) (KnxLayer, error) {
}
func (e KnxLayer) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("KnxLayer", 8, uint8(e))
+ err := io.WriteUint8("KnxLayer", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
index c90c205..2d472e8 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxManufacturer.go
@@ -7804,7 +7804,7 @@ func KnxManufacturerParse(io utils.ReadBuffer)
(KnxManufacturer, error) {
}
func (e KnxManufacturer) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint16("KnxManufacturer", 16, uint16(e))
+ err := io.WriteUint16("KnxManufacturer", 16, uint16(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxMedium.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxMedium.go
index e95bb23..5369305 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxMedium.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxMedium.go
@@ -121,7 +121,7 @@ func KnxMediumParse(io utils.ReadBuffer) (KnxMedium, error)
{
}
func (e KnxMedium) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("KnxMedium", 8, uint8(e))
+ err := io.WriteUint8("KnxMedium", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxPropertyDataType.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxPropertyDataType.go
index 71c8ae5..5e89488 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxPropertyDataType.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/KnxPropertyDataType.go
@@ -1014,7 +1014,7 @@ func KnxPropertyDataTypeParse(io utils.ReadBuffer)
(KnxPropertyDataType, error)
}
func (e KnxPropertyDataType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("KnxPropertyDataType", 8, uint8(e))
+ err := io.WriteUint8("KnxPropertyDataType", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go
index 965c01e..67c513b 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/Status.go
@@ -157,7 +157,7 @@ func StatusParse(io utils.ReadBuffer) (Status, error) {
}
func (e Status) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("Status", 8, uint8(e))
+ err := io.WriteUint8("Status", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/knxnetip/readwrite/model/SupportedPhysicalMedia.go
b/plc4go/internal/plc4go/knxnetip/readwrite/model/SupportedPhysicalMedia.go
index 6bec2d2..283e884 100644
--- a/plc4go/internal/plc4go/knxnetip/readwrite/model/SupportedPhysicalMedia.go
+++ b/plc4go/internal/plc4go/knxnetip/readwrite/model/SupportedPhysicalMedia.go
@@ -398,7 +398,7 @@ func SupportedPhysicalMediaParse(io utils.ReadBuffer)
(SupportedPhysicalMedia, e
}
func (e SupportedPhysicalMedia) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("SupportedPhysicalMedia", 8, uint8(e))
+ err := io.WriteUint8("SupportedPhysicalMedia", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
b/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
index bc5d5c3..b9c5409 100644
--- a/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
+++ b/plc4go/internal/plc4go/modbus/readwrite/model/ModbusDataType.go
@@ -364,7 +364,7 @@ func ModbusDataTypeParse(io utils.ReadBuffer)
(ModbusDataType, error) {
}
func (e ModbusDataType) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("ModbusDataType", 8, uint8(e))
+ err := io.WriteUint8("ModbusDataType", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go
b/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go
index 95d8090..adcd0ff 100644
--- a/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go
+++ b/plc4go/internal/plc4go/modbus/readwrite/model/ModbusErrorCode.go
@@ -145,7 +145,7 @@ func ModbusErrorCodeParse(io utils.ReadBuffer)
(ModbusErrorCode, error) {
}
func (e ModbusErrorCode) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("ModbusErrorCode", 8, uint8(e))
+ err := io.WriteUint8("ModbusErrorCode", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
b/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
index 8cb92cc..44dac52 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/COTPProtocolClass.go
@@ -115,7 +115,7 @@ func COTPProtocolClassParse(io utils.ReadBuffer)
(COTPProtocolClass, error) {
}
func (e COTPProtocolClass) Serialize(io utils.WriteBuffer) error {
- err := io.WriteInt8("COTPProtocolClass", 8, int8(e))
+ err := io.WriteInt8("COTPProtocolClass", 8, int8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
b/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
index e9b442d..1e8d64f 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/COTPTpduSize.go
@@ -164,7 +164,7 @@ func COTPTpduSizeParse(io utils.ReadBuffer) (COTPTpduSize,
error) {
}
func (e COTPTpduSize) Serialize(io utils.WriteBuffer) error {
- err := io.WriteInt8("COTPTpduSize", 8, int8(e))
+ err := io.WriteInt8("COTPTpduSize", 8, int8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git
a/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
b/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
index 90037c3..20c483b 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/DataTransportErrorCode.go
@@ -121,7 +121,7 @@ func DataTransportErrorCodeParse(io utils.ReadBuffer)
(DataTransportErrorCode, e
}
func (e DataTransportErrorCode) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("DataTransportErrorCode", 8, uint8(e))
+ err := io.WriteUint8("DataTransportErrorCode", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
b/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
index 83f3f5a..e5b3261 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/DataTransportSize.go
@@ -164,7 +164,7 @@ func DataTransportSizeParse(io utils.ReadBuffer)
(DataTransportSize, error) {
}
func (e DataTransportSize) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("DataTransportSize", 8, uint8(e))
+ err := io.WriteUint8("DataTransportSize", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
b/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
index 8966932..4927f15 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/DeviceGroup.go
@@ -103,7 +103,7 @@ func DeviceGroupParse(io utils.ReadBuffer) (DeviceGroup,
error) {
}
func (e DeviceGroup) Serialize(io utils.WriteBuffer) error {
- err := io.WriteInt8("DeviceGroup", 8, int8(e))
+ err := io.WriteInt8("DeviceGroup", 8, int8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
b/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
index 8bc1b66..762b7e4 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/MemoryArea.go
@@ -184,7 +184,7 @@ func MemoryAreaParse(io utils.ReadBuffer) (MemoryArea,
error) {
}
func (e MemoryArea) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("MemoryArea", 8, uint8(e))
+ err := io.WriteUint8("MemoryArea", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
b/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
index 1d3beee..9fd3591 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/SzlModuleTypeClass.go
@@ -109,7 +109,7 @@ func SzlModuleTypeClassParse(io utils.ReadBuffer)
(SzlModuleTypeClass, error) {
}
func (e SzlModuleTypeClass) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("SzlModuleTypeClass", 4, uint8(e))
+ err := io.WriteUint8("SzlModuleTypeClass", 4, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
b/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
index 814ace5..a13511f 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/SzlSublist.go
@@ -199,7 +199,7 @@ func SzlSublistParse(io utils.ReadBuffer) (SzlSublist,
error) {
}
func (e SzlSublist) Serialize(io utils.WriteBuffer) error {
- err := io.WriteUint8("SzlSublist", 8, uint8(e))
+ err := io.WriteUint8("SzlSublist", 8, uint8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
b/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
index f9b96fa..1ea3010 100644
--- a/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
+++ b/plc4go/internal/plc4go/s7/readwrite/model/TransportSize.go
@@ -1494,7 +1494,7 @@ func TransportSizeParse(io utils.ReadBuffer)
(TransportSize, error) {
}
func (e TransportSize) Serialize(io utils.WriteBuffer) error {
- err := io.WriteInt8("TransportSize", 8, int8(e))
+ err := io.WriteInt8("TransportSize", 8, int8(e),
utils.WithAdditionalStringRepresentation(e.name()))
return err
}
diff --git a/plc4go/internal/plc4go/s7/s7Io_test.go
b/plc4go/internal/plc4go/s7/s7Io_test.go
index 4125f75..5dd413d 100644
--- a/plc4go/internal/plc4go/s7/s7Io_test.go
+++ b/plc4go/internal/plc4go/s7/s7Io_test.go
@@ -115,10 +115,10 @@ func TestS7MessageBytes(t *testing.T) {
║╔═COTPPacket═══════════════════════════════════════════════════════════════════════════════════════════════════╗║
║║╔═headerLength╗╔═tpduCode╗╔═COTPPacketData═════╗╔═parameters═════════════════════════════════════════════════╗║║
║║║ 0x05 5 ║║0xf0 240
║║╔═eot════╗╔═tpduRef╗║║╔═COTPParameter════════════════════════════════════════════╗║║║
-║║╚═════════════╝╚═════════╝║║b0 false║║0x0d 13
║║║║╔═parameterType╗╔═parameterLength╗╔═COTPParameterTpduSize╗║║║║
-║║ ║╚════════╝╚════════╝║║║║ 0xc0 192 ║║ 0x01
1 ║║ ╔═COTPTpduSize╗ ║║║║║
-║║
╚════════════════════╝║║╚══════════════╝╚════════════════╝║ ║ 0x0c 12 ║
║║║║║
-║║ ║║
║ ╚═════════════╝ ║║║║║
+║║╚═════════════╝╚═════════╝║║b0 false║║ 0xd 13
║║║║╔═parameterType╗╔═parameterLength╗╔═COTPParameterTpduSize╗║║║║
+║║ ║╚════════╝╚════════╝║║║║ 0xc0 192 ║║ 0x01
1 ║║ ╔═COTPTpduSize════╗ ║║║║║
+║║
╚════════════════════╝║║╚══════════════╝╚════════════════╝║ ║0x0c 12 SIZE_4096║
║║║║║
+║║ ║║
║ ╚═════════════════╝ ║║║║║
║║ ║║
╚══════════════════════╝║║║║
║║
║╚══════════════════════════════════════════════════════════╝║║║
║║
╚════════════════════════════════════════════════════════════╝║║
@@ -138,7 +138,7 @@ func TestS7MessageBytes(t *testing.T) {
║║║║║╔═items══════════════════════════════════════════════════════════════════════════╗║║
║ ║║
║║║║║║╔═S7VarPayloadDataItem═════════════════════════════════════════════════════════╗║║║
║ ║║
║║║║║║║╔═DataTransportErrorCode╗╔═DataTransportSize╗╔═dataLength╗╔═data═══╗╔═padding╗║║║║
║ ║║
-║║║║║║║║ 0xff 255 ║║ 0x03 3 ║║ 0x0001 1 ║║╔══════╗║║
║║║║║ ║ ║║
+║║║║║║║║ 0xff 255 OK ║║ 0x03 3 BIT ║║ 0x0001 1 ║║╔══════╗║║
║║║║║ ║ ║║
║║║║║║║╚═══════════════════════╝╚══════════════════╝╚═══════════╝║║0x01
1║║╚════════╝║║║║ ║ ║║
║║║║║║║ ║╚══════╝║
║║║║ ║ ║║
║║║║║║║ ╚════════╝
║║║║ ║ ║║
diff --git a/plc4go/internal/plc4go/spi/utils/WriteBuffer.go
b/plc4go/internal/plc4go/spi/utils/WriteBuffer.go
index 31a2741..1fd4978 100644
--- a/plc4go/internal/plc4go/spi/utils/WriteBuffer.go
+++ b/plc4go/internal/plc4go/spi/utils/WriteBuffer.go
@@ -24,19 +24,43 @@ import (
)
type WriteBuffer interface {
- PushContext(logicalName string) error
- WriteBit(logicalName string, value bool) error
- WriteUint8(logicalName string, bitLength uint8, value uint8) error
- WriteUint16(logicalName string, bitLength uint8, value uint16) error
- WriteUint32(logicalName string, bitLength uint8, value uint32) error
- WriteUint64(logicalName string, bitLength uint8, value uint64) error
- WriteInt8(logicalName string, bitLength uint8, value int8) error
- WriteInt16(logicalName string, bitLength uint8, value int16) error
- WriteInt32(logicalName string, bitLength uint8, value int32) error
- WriteInt64(logicalName string, bitLength uint8, value int64) error
- WriteBigInt(logicalName string, bitLength uint8, value *big.Int) error
- WriteFloat32(logicalName string, bitLength uint8, value float32) error
- WriteFloat64(logicalName string, bitLength uint8, value float64) error
- WriteString(logicalName string, bitLength uint8, encoding string, value
string) error
- PopContext(logicalName string) error
+ PushContext(logicalName string, writerArgs ...WithWriterArgs) error
+ WriteBit(logicalName string, value bool, writerArgs ...WithWriterArgs)
error
+ WriteUint8(logicalName string, bitLength uint8, value uint8, writerArgs
...WithWriterArgs) error
+ WriteUint16(logicalName string, bitLength uint8, value uint16,
writerArgs ...WithWriterArgs) error
+ WriteUint32(logicalName string, bitLength uint8, value uint32,
writerArgs ...WithWriterArgs) error
+ WriteUint64(logicalName string, bitLength uint8, value uint64,
writerArgs ...WithWriterArgs) error
+ WriteInt8(logicalName string, bitLength uint8, value int8, writerArgs
...WithWriterArgs) error
+ WriteInt16(logicalName string, bitLength uint8, value int16, writerArgs
...WithWriterArgs) error
+ WriteInt32(logicalName string, bitLength uint8, value int32, writerArgs
...WithWriterArgs) error
+ WriteInt64(logicalName string, bitLength uint8, value int64, writerArgs
...WithWriterArgs) error
+ WriteBigInt(logicalName string, bitLength uint8, value *big.Int,
writerArgs ...WithWriterArgs) error
+ WriteFloat32(logicalName string, bitLength uint8, value float32,
writerArgs ...WithWriterArgs) error
+ WriteFloat64(logicalName string, bitLength uint8, value float64,
writerArgs ...WithWriterArgs) error
+ WriteString(logicalName string, bitLength uint8, encoding string, value
string, writerArgs ...WithWriterArgs) error
+ PopContext(logicalName string, writerArgs ...WithWriterArgs) error
}
+
+// WithWriterArgs is a marker interface for writer args supplied by the
builders like WithAdditionalStringRepresentation
+type WithWriterArgs interface {
+ isWriterArgs() bool
+}
+
+///////////////////////////////////////
+///////////////////////////////////////
+//
+// Internal section
+//
+
+type writerArg struct {
+}
+
+func (_ writerArg) isWriterArgs() bool {
+ return true
+}
+
+//
+// Internal section
+//
+///////////////////////////////////////
+///////////////////////////////////////
diff --git a/plc4go/internal/plc4go/spi/utils/WriteBufferBoxBased.go
b/plc4go/internal/plc4go/spi/utils/WriteBufferBoxBased.go
index 0471f53..7a556e3 100644
--- a/plc4go/internal/plc4go/spi/utils/WriteBufferBoxBased.go
+++ b/plc4go/internal/plc4go/spi/utils/WriteBufferBoxBased.go
@@ -21,6 +21,7 @@ package utils
import (
"container/list"
+ "fmt"
"math/big"
)
@@ -37,89 +38,128 @@ func NewBoxedWriteBuffer() WriteBufferBoxBased {
}
}
+// WithAdditionalStringRepresentation can be used by e.g. enums to supply an
additional string representation
+func WithAdditionalStringRepresentation(stringRepresentation string)
WithWriterArgs {
+ return withAdditionalStringRepresentation{stringRepresentation:
stringRepresentation}
+}
+
+///////////////////////////////////////
+///////////////////////////////////////
+//
+// Internal section
+//
+
+type withAdditionalStringRepresentation struct {
+ writerArg
+ stringRepresentation string
+}
+
type boxedWriteBuffer struct {
*list.List
desiredWidth int
currentWidth int
}
+//
+// Internal section
+//
+///////////////////////////////////////
+///////////////////////////////////////
+
func (b *boxedWriteBuffer) GetBox() AsciiBox {
back := b.Back()
return back.Value.(AsciiBox)
}
-func (b *boxedWriteBuffer) PushContext(logicalName string) error {
+func (b *boxedWriteBuffer) PushContext(_ string, _ ...WithWriterArgs) error {
b.currentWidth -= boxLineOverheat
b.PushBack(make([]AsciiBox, 0))
return nil
}
-func (b *boxedWriteBuffer) WriteBit(logicalName string, value bool) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteBit(logicalName string, value bool, writerArgs
...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ asInt := 0
+ if value {
+ asInt = 1
+ }
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("b%d %t%s", asInt, value,
additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteUint8(logicalName string, bitLength uint8,
value uint8) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteUint8(logicalName string, bitLength uint8,
value uint8, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteUint16(logicalName string, bitLength uint8,
value uint16) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteUint16(logicalName string, bitLength uint8,
value uint16, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteUint32(logicalName string, bitLength uint8,
value uint32) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteUint32(logicalName string, bitLength uint8,
value uint32, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteUint64(logicalName string, bitLength uint8,
value uint64) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteUint64(logicalName string, bitLength uint8,
value uint64, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteInt8(logicalName string, bitLength uint8,
value int8) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteInt8(logicalName string, bitLength uint8,
value int8, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteInt16(logicalName string, bitLength uint8,
value int16) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteInt16(logicalName string, bitLength uint8,
value int16, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteInt32(logicalName string, bitLength uint8,
value int32) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteInt32(logicalName string, bitLength uint8,
value int32, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteInt64(logicalName string, bitLength uint8,
value int64) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteInt64(logicalName string, bitLength uint8,
value int64, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteBigInt(logicalName string, bitLength uint8,
value *big.Int) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteBigInt(logicalName string, bitLength uint8,
value *big.Int, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %d%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteFloat32(logicalName string, bitLength uint8,
value float32) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteFloat32(logicalName string, bitLength uint8,
value float32, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %f%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteFloat64(logicalName string, bitLength uint8,
value float64) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteFloat64(logicalName string, bitLength uint8,
value float64, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %f%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) WriteString(logicalName string, bitLength uint8,
encoding string, value string) error {
- b.PushBack(BoxAnything(logicalName, value, b.currentWidth))
+func (b *boxedWriteBuffer) WriteString(logicalName string, bitLength uint8, _
string, value string, writerArgs ...WithWriterArgs) error {
+ additionalStringRepresentation :=
extractAdditionalStringRepresentation(writerArgs...)
+ b.PushBack(BoxString(logicalName, fmt.Sprintf("%#0*x %s%s",
bitLength/4, value, value, additionalStringRepresentation), 0))
return nil
}
-func (b *boxedWriteBuffer) PopContext(logicalName string) error {
+func (b *boxedWriteBuffer) PopContext(logicalName string, _ ...WithWriterArgs)
error {
b.currentWidth += boxLineOverheat
finalBoxes := make([]AsciiBox, 0)
findTheBox:
@@ -141,3 +181,16 @@ findTheBox:
b.PushBack(asciiBox)
return nil
}
+
+func extractAdditionalStringRepresentation(writerArgs ...WithWriterArgs)
string {
+ for _, arg := range writerArgs {
+ if !arg.isWriterArgs() {
+ panic("not a writer arg")
+ }
+ switch arg.(type) {
+ case withAdditionalStringRepresentation:
+ return " " +
arg.(withAdditionalStringRepresentation).stringRepresentation
+ }
+ }
+ return ""
+}
diff --git a/plc4go/internal/plc4go/spi/utils/WriteBufferByteBased.go
b/plc4go/internal/plc4go/spi/utils/WriteBufferByteBased.go
index 597a2f3..6654938 100644
--- a/plc4go/internal/plc4go/spi/utils/WriteBufferByteBased.go
+++ b/plc4go/internal/plc4go/spi/utils/WriteBufferByteBased.go
@@ -73,11 +73,11 @@ type writeBuffer struct {
///////////////////////////////////////
///////////////////////////////////////
-func (rb *writeBuffer) PushContext(_ string) error {
+func (rb *writeBuffer) PushContext(_ string, writerArgs ...WithWriterArgs)
error {
return nil
}
-func (rb *writeBuffer) PopContext(_ string) error {
+func (rb *writeBuffer) PopContext(_ string, writerArgs ...WithWriterArgs)
error {
return nil
}
@@ -93,15 +93,15 @@ func (rb *writeBuffer) GetTotalBytes() uint64 {
return uint64(rb.data.Len())
}
-func (rb *writeBuffer) WriteBit(_ string, value bool) error {
+func (rb *writeBuffer) WriteBit(_ string, value bool, _ ...WithWriterArgs)
error {
return rb.writer.WriteBool(value)
}
-func (rb *writeBuffer) WriteUint8(_ string, bitLength uint8, value uint8)
error {
+func (rb *writeBuffer) WriteUint8(_ string, bitLength uint8, value uint8, _
...WithWriterArgs) error {
return rb.writer.WriteBits(uint64(value), bitLength)
}
-func (rb *writeBuffer) WriteUint16(_ string, bitLength uint8, value uint16)
error {
+func (rb *writeBuffer) WriteUint16(_ string, bitLength uint8, value uint16, _
...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -110,7 +110,7 @@ func (rb *writeBuffer) WriteUint16(_ string, bitLength
uint8, value uint16) erro
return rb.writer.WriteBits(uint64(value), bitLength)
}
-func (rb *writeBuffer) WriteUint32(_ string, bitLength uint8, value uint32)
error {
+func (rb *writeBuffer) WriteUint32(_ string, bitLength uint8, value uint32, _
...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -119,7 +119,7 @@ func (rb *writeBuffer) WriteUint32(_ string, bitLength
uint8, value uint32) erro
return rb.writer.WriteBits(uint64(value), bitLength)
}
-func (rb *writeBuffer) WriteUint64(_ string, bitLength uint8, value uint64)
error {
+func (rb *writeBuffer) WriteUint64(_ string, bitLength uint8, value uint64, _
...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -128,11 +128,11 @@ func (rb *writeBuffer) WriteUint64(_ string, bitLength
uint8, value uint64) erro
return rb.writer.WriteBits(value, bitLength)
}
-func (rb *writeBuffer) WriteInt8(_ string, bitLength uint8, value int8) error {
+func (rb *writeBuffer) WriteInt8(_ string, bitLength uint8, value int8, _
...WithWriterArgs) error {
return rb.writer.WriteBits(uint64(value), bitLength)
}
-func (rb *writeBuffer) WriteInt16(_ string, bitLength uint8, value int16)
error {
+func (rb *writeBuffer) WriteInt16(_ string, bitLength uint8, value int16, _
...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -141,7 +141,7 @@ func (rb *writeBuffer) WriteInt16(_ string, bitLength
uint8, value int16) error
return rb.writer.WriteBits(uint64(value), bitLength)
}
-func (rb *writeBuffer) WriteInt32(_ string, bitLength uint8, value int32)
error {
+func (rb *writeBuffer) WriteInt32(_ string, bitLength uint8, value int32, _
...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -150,7 +150,7 @@ func (rb *writeBuffer) WriteInt32(_ string, bitLength
uint8, value int32) error
return rb.writer.WriteBits(uint64(value), bitLength)
}
-func (rb *writeBuffer) WriteInt64(_ string, bitLength uint8, value int64)
error {
+func (rb *writeBuffer) WriteInt64(_ string, bitLength uint8, value int64, _
...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -159,11 +159,11 @@ func (rb *writeBuffer) WriteInt64(_ string, bitLength
uint8, value int64) error
return rb.writer.WriteBits(uint64(value), bitLength)
}
-func (rb *writeBuffer) WriteBigInt(_ string, bitLength uint8, value *big.Int)
error {
+func (rb *writeBuffer) WriteBigInt(_ string, bitLength uint8, value *big.Int,
_ ...WithWriterArgs) error {
return errors.New("not implemented yet")
}
-func (rb *writeBuffer) WriteFloat32(_ string, bitLength uint8, value float32)
error {
+func (rb *writeBuffer) WriteFloat32(_ string, bitLength uint8, value float32,
_ ...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -173,7 +173,7 @@ func (rb *writeBuffer) WriteFloat32(_ string, bitLength
uint8, value float32) er
return rb.writer.WriteBits(uint64(res), bitLength)
}
-func (rb *writeBuffer) WriteFloat64(_ string, bitLength uint8, value float64)
error {
+func (rb *writeBuffer) WriteFloat64(_ string, bitLength uint8, value float64,
_ ...WithWriterArgs) error {
if rb.byteOrder == binary.LittleEndian {
// TODO: indirection till we have a native LE implementation
// TODO: validate that this produces the desired result
@@ -183,6 +183,6 @@ func (rb *writeBuffer) WriteFloat64(_ string, bitLength
uint8, value float64) er
return rb.writer.WriteBits(res, bitLength)
}
-func (rb *writeBuffer) WriteString(_ string, bitLength uint8, encoding string,
value string) error {
+func (rb *writeBuffer) WriteString(_ string, bitLength uint8, encoding string,
value string, _ ...WithWriterArgs) error {
return errors.New("WriteString is currently not implemented")
}