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 2023/01/25 10:15:39 UTC
[plc4x] branch develop updated: refactor(plc4j/code-gen): Refactored the way Encoding is handled and added "nullBytesHex" attribute support.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new bcb14d3988 refactor(plc4j/code-gen): Refactored the way Encoding is handled and added "nullBytesHex" attribute support.
bcb14d3988 is described below
commit bcb14d398828bf54d68b9050c5a1861fa9ae000b
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Wed Jan 25 11:15:28 2023 +0100
refactor(plc4j/code-gen): Refactored the way Encoding is handled and added "nullBytesHex" attribute support.
- Changed the string-handling to not use an explicit "encoding" method attribute and moved that to using "WithEncoding" options.
- Added support for a new "nullByteHex" attribute for optional fields
- Added an accessor to the readBuffer instance for DataReaders
- Added an accessor to the writeBuffer instance for DataWriters
- Bumped plc4x-code-generation version to 1.7.0-SNAPSHOT
---
.../language/java/JavaLanguageTemplateHelper.java | 12 +-
.../templates/java/complex-type-template.java.ftlh | 41 ++--
.../templates/java/data-io-template.java.ftlh | 1 +
.../abeth/readwrite/CIPEncapsulationPacket.java | 21 +-
.../ads/readwrite/AdsDataTypeTableChildEntry.java | 46 +++-
.../java/ads/readwrite/AdsDataTypeTableEntry.java | 45 +++-
.../java/ads/readwrite/AdsSymbolTableEntry.java | 47 +++-
.../plc4x/java/ads/readwrite/AmsTCPPacket.java | 9 +-
.../apache/plc4x/java/ads/readwrite/DataItem.java | 20 +-
.../plc4x/java/ads/readwrite/ErrorResponse.java} | 96 ++++----
.../plc4x/java/ads/tag/DirectAdsStringTag.java | 5 +-
.../apache/plc4x/java/ads/tag/DirectAdsTag.java | 6 +-
.../apache/plc4x/java/ads/tag/SymbolicAdsTag.java | 6 +-
.../apache/plc4x/java/bacnetip/readwrite/BVLC.java | 18 +-
.../BVLCDeleteForeignDeviceTableEntry.java | 6 +-
.../java/bacnetip/readwrite/BVLCForwardedNPDU.java | 6 +-
.../BVLCReadBroadcastDistributionTableAck.java | 3 +-
.../readwrite/BVLCReadForeignDeviceTableAck.java | 3 +-
.../plc4x/java/bacnetip/readwrite/BVLCResult.java | 3 +-
.../java/bacnetip/readwrite/BVLCSecureBVLL.java | 6 +-
.../BVLCWriteBroadcastDistributionTable.java | 3 +-
.../plc4x/java/canopen/readwrite/CANOpenFrame.java | 12 +-
.../plc4x/java/canopen/readwrite/DataItem.java | 16 +-
.../java/canopen/readwrite/utils/StaticHelper.java | 5 +-
.../java/canopen/tag/CANOpenHeartbeatTag.java | 5 +-
.../plc4x/java/canopen/tag/CANOpenNMTTag.java | 5 +-
.../plc4x/java/canopen/tag/CANOpenPDOTag.java | 9 +-
.../plc4x/java/canopen/tag/CANOpenSDOTag.java | 5 +-
.../plc4x/java/eip/readwrite/tag/EipTag.java | 13 +-
.../java/firmata/readwrite/FirmataMessage.java | 6 +-
.../firmata/readwrite/FirmataMessageAnalogIO.java | 6 +-
.../firmata/readwrite/FirmataMessageDigitalIO.java | 6 +-
.../FirmataMessageSubscribeAnalogPinValue.java | 3 +-
.../FirmataMessageSubscribeDigitalPinValue.java | 3 +-
.../knxnetip/readwrite/ConnectionResponse.java | 9 +-
.../knxnetip/readwrite/ConnectionStateRequest.java | 3 +-
.../readwrite/ConnectionStateResponse.java | 3 +-
.../java/knxnetip/readwrite/DisconnectRequest.java | 3 +-
.../knxnetip/readwrite/DisconnectResponse.java | 3 +-
.../java/knxnetip/readwrite/KnxDatapoint.java | 36 +--
.../java/knxnetip/readwrite/KnxNetIpMessage.java | 24 +-
.../java/knxnetip/readwrite/UnknownMessage.java | 6 +-
.../plc4x/java/modbus/readwrite/DataItem.java | 21 +-
.../java/modbus/readwrite/ModbusAsciiADU.java | 3 +-
.../plc4x/java/modbus/readwrite/ModbusRtuADU.java | 3 +-
.../plc4x/java/modbus/readwrite/ModbusTcpADU.java | 12 +-
.../plc4x/java/modbus/base/tag/ModbusTag.java | 5 +-
...licationCommunicationStartAcknowledgeBlock.java | 8 +-
...onCommunicationStartAcknowledgeBlockCellId.java | 4 +-
...ommunicationStartAcknowledgeBlockChannelId.java | 4 +-
...CommunicationStartAcknowledgeBlockClientId.java | 7 +-
...unicationStartAcknowledgeBlockSupplierCode.java | 4 +-
.../readwrite/OpenProtocolMessage.java | 259 +++++++++++++--------
...nProtocolMessageApplicationCommandAccepted.java | 61 +++--
...OpenProtocolMessageApplicationCommandError.java | 68 +++---
...otocolMessageApplicationCommunicationStart.java | 55 +++--
...geApplicationCommunicationStartAcknowledge.java | 58 +++--
...rotocolMessageApplicationCommunicationStop.java | 55 +++--
...otocolMessageApplicationGenericDataRequest.java | 111 +++++----
.../OpenProtocolParserSerializerTest.java} | 14 +-
.../src/test/resources/logback-test.xml | 41 ++--
.../java/plc4x/readwrite/Plc4xConnectRequest.java | 5 +-
.../java/plc4x/readwrite/Plc4xConnectResponse.java | 3 +-
.../plc4x/java/plc4x/readwrite/Plc4xMessage.java | 17 +-
.../java/plc4x/readwrite/Plc4xReadRequest.java | 9 +-
.../java/plc4x/readwrite/Plc4xReadResponse.java | 12 +-
.../plc4x/java/plc4x/readwrite/Plc4xValue.java | 11 +-
.../java/plc4x/readwrite/Plc4xWriteRequest.java | 9 +-
.../java/plc4x/readwrite/Plc4xWriteResponse.java | 12 +-
.../org/apache/plc4x/java/plc4x/tag/Plc4xTag.java | 6 +-
.../profinet/readwrite/DceRpc_InterfaceUuid.java | 24 +-
.../java/profinet/readwrite/DceRpc_ObjectUuid.java | 6 +-
.../java/profinet/readwrite/DceRpc_Packet.java | 126 ++++++++--
.../java/profinet/readwrite/PnIoCm_Block.java | 9 +-
.../readwrite/PnIoCm_Block_AlarmCrReq.java | 6 +-
.../readwrite/PnIoCm_Block_AlarmCrRes.java | 3 +-
.../profinet/readwrite/PnIoCm_Block_ArReq.java | 21 +-
.../profinet/readwrite/PnIoCm_Block_ArRes.java | 3 +-
.../PnIoCm_Block_ExpectedSubmoduleReq.java | 9 +-
.../profinet/readwrite/PnIoCm_Block_IoCrReq.java | 21 +-
.../profinet/readwrite/PnIoCm_Block_IoCrRes.java | 3 +-
.../readwrite/PnIoCm_Block_ModuleDiff.java | 9 +-
.../apache/plc4x/java/s7/readwrite/DataItem.java | 11 +-
.../apache/plc4x/java/s7/readwrite/TPKTPacket.java | 15 +-
.../plc4x/java/s7/readwrite/tag/S7StringTag.java | 9 +-
.../apache/plc4x/java/s7/readwrite/tag/S7Tag.java | 9 +-
.../plc4x/java/simulated/readwrite/DataItem.java | 31 ++-
.../plc4x/java/spi/codegen/FieldCommons.java | 17 --
.../apache/plc4x/java/spi/codegen/WithOption.java | 12 +-
.../spi/codegen/fields/FieldReaderOptional.java | 38 ++-
.../spi/codegen/fields/FieldWriterOptional.java | 30 ++-
.../codegen/fields/FieldWriterOptionalEnum.java | 29 ++-
.../plc4x/java/spi/codegen/io/DataReader.java | 3 +
.../spi/codegen/io/DataReaderComplexDefault.java | 5 +
.../java/spi/codegen/io/DataReaderEnumDefault.java | 6 +
.../java/spi/codegen/io/DataReaderSimpleBase.java | 5 +
.../spi/codegen/io/DataReaderSimpleString.java | 2 +-
.../plc4x/java/spi/codegen/io/DataWriter.java | 3 +
.../spi/codegen/io/DataWriterComplexDefault.java | 5 +
.../spi/codegen/io/DataWriterDataIoDefault.java | 5 +
.../java/spi/codegen/io/DataWriterEnumDefault.java | 10 +-
.../java/spi/codegen/io/DataWriterSimpleBase.java | 5 +
.../spi/codegen/io/DataWriterSimpleString.java | 4 +-
.../plc4x/java/spi/generation/BufferCommons.java | 18 ++
.../plc4x/java/spi/generation/ReadBuffer.java | 66 +++---
.../java/spi/generation/ReadBufferByteBased.java | 130 ++++++++---
.../java/spi/generation/ReadBufferJsonBased.java | 2 +-
.../java/spi/generation/ReadBufferXmlBased.java | 3 +-
.../java/spi/generation/WithReaderWriterArgs.java | 36 +++
.../plc4x/java/spi/generation/WriteBuffer.java | 66 +++---
.../java/spi/generation/WriteBufferBoxBased.java | 2 +-
.../java/spi/generation/WriteBufferByteBased.java | 93 ++++++--
.../java/spi/generation/WriteBufferJsonBased.java | 3 +-
.../java/spi/generation/WriteBufferXmlBased.java | 3 +-
.../spi/messages/DefaultListPlcBrowseItem.java | 17 +-
.../java/spi/messages/DefaultPlcBrowseItem.java | 14 +-
.../java/spi/messages/DefaultPlcDiscoveryItem.java | 26 ++-
.../java/spi/messages/DefaultPlcWriteRequest.java | 9 +-
.../java/spi/messages/DefaultPlcWriteResponse.java | 5 +-
.../java/spi/messages/utils/ResponseItem.java | 5 +-
.../org/apache/plc4x/java/spi/values/PlcCHAR.java | 5 +-
.../org/apache/plc4x/java/spi/values/PlcDATE.java | 5 +-
.../plc4x/java/spi/values/PlcDATE_AND_TIME.java | 5 +-
.../apache/plc4x/java/spi/values/PlcIECValue.java | 5 +-
.../org/apache/plc4x/java/spi/values/PlcLDATE.java | 5 +-
.../plc4x/java/spi/values/PlcLDATE_AND_TIME.java | 5 +-
.../org/apache/plc4x/java/spi/values/PlcLTIME.java | 5 +-
.../plc4x/java/spi/values/PlcLTIME_OF_DAY.java | 5 +-
.../apache/plc4x/java/spi/values/PlcSTRING.java | 5 +-
.../org/apache/plc4x/java/spi/values/PlcTIME.java | 5 +-
.../plc4x/java/spi/values/PlcTIME_OF_DAY.java | 5 +-
.../org/apache/plc4x/java/spi/values/PlcWCHAR.java | 5 +-
.../apache/plc4x/java/spi/values/PlcWSTRING.java | 5 +-
.../plc4x/java/spi/generation/ReadBufferTest.java | 5 +-
.../java/plc4x/readwrite/Plc4xConnectRequest.java | 5 +-
.../java/plc4x/readwrite/Plc4xConnectResponse.java | 3 +-
.../plc4x/java/plc4x/readwrite/Plc4xMessage.java | 17 +-
.../java/plc4x/readwrite/Plc4xReadRequest.java | 9 +-
.../java/plc4x/readwrite/Plc4xReadResponse.java | 12 +-
.../plc4x/java/plc4x/readwrite/Plc4xValue.java | 11 +-
.../java/plc4x/readwrite/Plc4xWriteRequest.java | 9 +-
.../java/plc4x/readwrite/Plc4xWriteResponse.java | 12 +-
.../java/socketcan/readwrite/SocketCANFrame.java | 27 ++-
.../apache/plc4x/java/s7/utils/StaticHelper.java | 5 +-
.../plc4x/test/migration/MessageResolver.java | 2 +-
pom.xml | 4 +-
protocols/open-protocol/pom.xml | 6 +
.../protocols/openprotocol/open-protocol.mspec | 84 +++----
.../openprotocol/OpenProtocolProtocolTest.java | 27 +--
.../test/resources/logback-test.xml} | 41 ++--
.../openprotocol/ParserSerializerTestsuite.xml | 95 ++++++++
.../apache/plc4x/java/df1/readwrite/DF1Symbol.java | 12 +-
.../java/df1/readwrite/DF1SymbolMessageFrame.java | 15 +-
153 files changed, 2013 insertions(+), 906 deletions(-)
diff --git a/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java b/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
index 7fde475769..fc44e19a82 100644
--- a/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
+++ b/code-generation/language-java/src/main/java/org/apache/plc4x/language/java/JavaLanguageTemplateHelper.java
@@ -357,8 +357,8 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
length = toParseExpression(field, INT_TYPE_REFERENCE, vstringTypeReference.getLengthExpression(), null);
}
- return "/*TODO: migrate me*/" + "readBuffer.read" + stringType + "(\"" + logicalName + "\", " + length + ", \"" +
- encoding + "\")";
+ return "/*TODO: migrate me*/" + "readBuffer.read" + stringType + "(\"" + logicalName + "\", " + length + ", WithOption.WithEncoding(\"" +
+ encoding + "\"))";
}
return "/*TODO: migrate me*/" + "";
}
@@ -584,8 +584,7 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
VstringTypeReference vstringTypeReference = (VstringTypeReference) simpleTypeReference;
length = toSerializationExpression(field, INT_TYPE_REFERENCE, vstringTypeReference.getLengthExpression(), thisType.getParserArguments().orElse(Collections.emptyList()));
}
- return "/*TODO: migrate me*/" + "writeBuffer.writeString(\"" + logicalName + "\", " + length + ", \"" +
- encoding + "\", (String) " + fieldName + "" + writerArgsString + ")";
+ return "/*TODO: migrate me*/" + "writeBuffer.writeString(\"" + logicalName + "\", " + length + ", (String) " + fieldName + "" + writerArgsString + ", WithOption.WithEncoding(\"" + encoding + "\"))";
}
throw new FreemarkerException("Unmapped basetype" + simpleTypeReference.getBaseType());
}
@@ -1233,6 +1232,11 @@ public class JavaLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHe
final String byteOrder = toParseExpression(field, field.getType(), byteOrderOptional.get(), parserArguments);
sb.append(", WithOption.WithByteOrder(").append(byteOrder).append(")");
}
+ final Optional<Term> nullBytesHexOptional = field.getAttribute("nullBytesHex");
+ if (nullBytesHexOptional.isPresent()) {
+ final String nullBytesHex = toParseExpression(field, field.getType(), nullBytesHexOptional.get(), parserArguments);
+ sb.append(", WithOption.WithNullBytesHex(\"").append(nullBytesHex).append("\")");
+ }
return sb.toString();
}
diff --git a/code-generation/language-java/src/main/resources/templates/java/complex-type-template.java.ftlh b/code-generation/language-java/src/main/resources/templates/java/complex-type-template.java.ftlh
index c712b97723..6b98ee7dea 100644
--- a/code-generation/language-java/src/main/resources/templates/java/complex-type-template.java.ftlh
+++ b/code-generation/language-java/src/main/resources/templates/java/complex-type-template.java.ftlh
@@ -252,11 +252,11 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
// Array Field (${arrayField.name})
<#if arrayField.type.elementTypeReference.isByteBased()>
- writeByteArrayField("${namedField.name}", ${namedField.name}, writeByteArray(writeBuffer, 8));
+ writeByteArrayField("${namedField.name}", ${namedField.name}, writeByteArray(writeBuffer, 8)${helper.getFieldOptions(typedField, parserArguments)});
<#elseif arrayField.type.elementTypeReference.isSimpleTypeReference()>
- writeSimpleTypeArrayField("${namedField.name}", ${namedField.name}, ${helper.getDataWriterCall(arrayField.type.elementTypeReference, namedField.name)});
+ writeSimpleTypeArrayField("${namedField.name}", ${namedField.name}, ${helper.getDataWriterCall(arrayField.type.elementTypeReference, namedField.name)}${helper.getFieldOptions(typedField, parserArguments)});
<#else>
- writeComplexTypeArrayField("${namedField.name}", ${namedField.name}, writeBuffer);
+ writeComplexTypeArrayField("${namedField.name}", ${namedField.name}, writeBuffer${helper.getFieldOptions(typedField, parserArguments)});
</#if>
<#break>
<#case "checksum">
@@ -265,7 +265,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#assign namedField = field.asNamedField().orElseThrow()>
// Checksum Field (checksum) (Calculated)
- writeChecksumField("${namedField.name}", (${helper.getLanguageTypeNameForField(field)}) (${helper.toParseExpression(checksumField, checksumField.type, checksumField.checksumExpression, parserArguments)}), ${helper.getDataWriterCall(typedField.type, namedField.name)});
+ writeChecksumField("${namedField.name}", (${helper.getLanguageTypeNameForField(field)}) (${helper.toParseExpression(checksumField, checksumField.type, checksumField.checksumExpression, parserArguments)}), ${helper.getDataWriterCall(typedField.type, namedField.name)}${helper.getFieldOptions(typedField, parserArguments)});
<#break>
<#case "const">
<#assign constField = field.asConstField().orElseThrow()>
@@ -273,7 +273,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#assign namedField = field.asNamedField().orElseThrow()>
// Const Field (${constField.name})
- <#if typedField.type.isEnumTypeReference()>writeConstField("${constField.name}", ${namedField.name?upper_case}.getValue(), ${helper.getDataWriterCall(helper.getEnumBaseTypeReference(typedField.type), namedField.name)});<#else>writeConstField("${constField.name}", ${namedField.name?upper_case}, ${helper.getDataWriterCall(typedField.type, namedField.name)});</#if>
+ <#if typedField.type.isEnumTypeReference()>writeConstField("${constField.name}", ${namedField.name?upper_case}.getValue(), ${helper.getDataWriterCall(helper.getEnumBaseTypeReference(typedField.type), namedField.name)}${helper.getFieldOptions(typedField, parserArguments)});<#else>writeConstField("${constField.name}", ${namedField.name?upper_case}, ${helper.getDataWriterCall(typedField.type, namedField.name)}${helper.getFieldOptions(typedField, parserArguments)});</#if>
<#break>
<#case "discriminator">
<#assign discriminatorField = field.asDiscriminatorField().orElseThrow()>
@@ -281,7 +281,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#assign namedField = field.asNamedField().orElseThrow()>
// Discriminator Field (${discriminatorField.name}) (Used as input to a switch field)
- <#if typedField.type.isEnumTypeReference()>writeDiscriminatorEnumField("${namedField.name}", "${helper.getLanguageTypeNameForField(field)}", get${discriminatorField.name?cap_first}(), ${helper.getEnumDataWriterCall(typedField.type, namedField.name, "value")});<#else>writeDiscriminatorField("${namedField.name}", get${discriminatorField.name?cap_first}(), ${helper.getDataWriterCall(typedField.type, namedField.name)});</#if>
+ <#if typedField.type.isEnumTypeReference()>writeDiscriminatorEnumField("${namedField.name}", "${helper.getLanguageTypeNameForField(field)}", get${discriminatorField.name?cap_first}(), ${helper.getEnumDataWriterCall(typedField.type, namedField.name, "value")}${helper.getFieldOptions(typedField, parserArguments)});<#else>writeDiscriminatorField("${namedField.name}", get${discriminatorField.name?cap_first}(), ${helper.getDataWriterCall(typedField.type, namedField.nam [...]
<#break>
<#case "enum">
<#assign enumField = field.asEnumField().orElseThrow()>
@@ -289,7 +289,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#assign namedField = field.asNamedField().orElseThrow()>
// Enum field (${namedField.name})
- writeEnumField("${namedField.name}", "${helper.getLanguageTypeNameForField(field)}", ${namedField.name}, ${helper.getEnumDataWriterCall(typedField.type, namedField.name, enumField.fieldName)});
+ writeEnumField("${namedField.name}", "${helper.getLanguageTypeNameForField(field)}", ${namedField.name}, ${helper.getEnumDataWriterCall(typedField.type, namedField.name, enumField.fieldName)}${helper.getFieldOptions(typedField, parserArguments)});
<#break>
<#case "implicit">
<#assign implicitField = field.asImplicitField().orElseThrow()>
@@ -299,7 +299,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
// Implicit Field (${implicitField.name}) (Used for parsing, but its value is not stored as it's implicitly given by the objects content)
<#-- Implicit field values might be used in expressions, in order to avoid problems, we generate a temporary variable with the given name. -->
${helper.getLanguageTypeNameForField(field)} ${implicitField.name} = (${helper.getLanguageTypeNameForField(field)}) (${helper.toSerializationExpression(implicitField, implicitField.type, implicitField.serializeExpression, parserArguments)});
- writeImplicitField("${namedField.name}", ${implicitField.name}, ${helper.getDataWriterCall(typedField.type, namedField.name)});
+ writeImplicitField("${namedField.name}", ${implicitField.name}, ${helper.getDataWriterCall(typedField.type, namedField.name)}${helper.getFieldOptions(typedField, parserArguments)});
<#break>
<#case "manualArray">
<#assign manualArrayField = field.asManualArrayField().orElseThrow()>
@@ -307,7 +307,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#assign namedField = field.asNamedField().orElseThrow()>
// Manual Array Field (${manualArrayField.name})
- writeManualArrayField("${namedField.name}", ${namedField.name}, (${helper.getLanguageTypeNameForTypeReference(manualArrayField.type.elementTypeReference)} _value) -> ${helper.toParseExpression(manualArrayField, manualArrayField.type.elementTypeReference, manualArrayField.serializeExpression, parserArguments)}, writeBuffer);
+ writeManualArrayField("${namedField.name}", ${namedField.name}, (${helper.getLanguageTypeNameForTypeReference(manualArrayField.type.elementTypeReference)} _value) -> ${helper.toParseExpression(manualArrayField, manualArrayField.type.elementTypeReference, manualArrayField.serializeExpression, parserArguments)}, writeBuffer${helper.getFieldOptions(typedField, parserArguments)});
<#break>
<#case "manual">
<#assign manualField = field.asManualField().orElseThrow()>
@@ -315,7 +315,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#assign namedField = field.asNamedField().orElseThrow()>
// Manual Field (${manualField.name})
- writeManualField("${namedField.name}", () -> ${helper.toParseExpression(manualField, manualField.type, manualField.serializeExpression, parserArguments)}, writeBuffer);
+ writeManualField("${namedField.name}", () -> ${helper.toParseExpression(manualField, manualField.type, manualField.serializeExpression, parserArguments)}, writeBuffer${helper.getFieldOptions(typedField, parserArguments)});
<#break>
<#case "optional">
<#assign optionalField = field.asOptionalField().orElseThrow()>
@@ -324,11 +324,11 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
// Optional Field (${optionalField.name}) (Can be skipped, if the value is null)
<#if optionalField.type.isEnumTypeReference()>
- writeOptionalEnumField("${optionalField.name}", "${helper.getLanguageTypeNameForField(field)}", ${optionalField.name}, ${helper.getEnumDataWriterCall(optionalField.type, optionalField.name, "value")}<#if optionalField.conditionExpression.present>, ${helper.toSerializationExpression(optionalField, helper.boolTypeReference, optionalField.conditionExpression.get(), parserArguments)}</#if>);
+ writeOptionalEnumField("${optionalField.name}", "${helper.getLanguageTypeNameForField(field)}", ${optionalField.name}, ${helper.getEnumDataWriterCall(optionalField.type, optionalField.name, "value")}<#if optionalField.conditionExpression.present>, ${helper.toSerializationExpression(optionalField, helper.boolTypeReference, optionalField.conditionExpression.get(), parserArguments)}</#if>${helper.getFieldOptions(typedField, parserArguments)});
<#elseif optionalField.type.isDataIoTypeReference()>
- writeOptionalField("${optionalField.name}", ${optionalField.name}, new DataWriterDataIoDefault(writeBuffer, (wb, val) -> ${optionalField.type.asComplexTypeReference().orElseThrow().name}.staticSerialize(wb, val<#if optionalField.type.asComplexTypeReference().orElseThrow().params?has_content>, <#list optionalField.type.asComplexTypeReference().orElseThrow().params.orElseThrow() as param>${helper.toParseExpression(optionalField, helper.anyTypeReference, param, p [...]
+ writeOptionalField("${optionalField.name}", ${optionalField.name}, new DataWriterDataIoDefault(writeBuffer, (wb, val) -> ${optionalField.type.asComplexTypeReference().orElseThrow().name}.staticSerialize(wb, val<#if optionalField.type.asComplexTypeReference().orElseThrow().params?has_content>, <#list optionalField.type.asComplexTypeReference().orElseThrow().params.orElseThrow() as param>${helper.toParseExpression(optionalField, helper.anyTypeReference, param, p [...]
<#else>
- writeOptionalField("${optionalField.name}", ${optionalField.name}, ${helper.getDataWriterCall(typedField.type, optionalField.name)}<#if optionalField.conditionExpression.present>, ${helper.toSerializationExpression(optionalField, helper.boolTypeReference, optionalField.conditionExpression.get(), parserArguments)}</#if>);
+ writeOptionalField("${optionalField.name}", ${optionalField.name}, ${helper.getDataWriterCall(typedField.type, optionalField.name)}<#if optionalField.conditionExpression.present>, ${helper.toSerializationExpression(optionalField, helper.boolTypeReference, optionalField.conditionExpression.get(), parserArguments)}</#if>${helper.getFieldOptions(typedField, parserArguments)});
</#if>
<#break>
<#case "padding">
@@ -336,14 +336,14 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#assign typedField = field.asTypedField().orElseThrow()>
// Padding Field (padding)
- writePaddingField("padding", (int) (${helper.toParseExpression(paddingField, helper.intTypeReference, paddingField.paddingCondition, parserArguments)}), (${helper.getLanguageTypeNameForField(field)}) ${helper.toSerializationExpression(paddingField, paddingField.type, paddingField.paddingValue, parserArguments)}, ${helper.getDataWriterCall(typedField.type, "padding")});
+ writePaddingField("padding", (int) (${helper.toParseExpression(paddingField, helper.intTypeReference, paddingField.paddingCondition, parserArguments)}), (${helper.getLanguageTypeNameForField(field)}) ${helper.toSerializationExpression(paddingField, paddingField.type, paddingField.paddingValue, parserArguments)}, ${helper.getDataWriterCall(typedField.type, "padding")}${helper.getFieldOptions(typedField, parserArguments)});
<#break>
<#case "reserved">
<#assign reservedField = field.asReservedField().orElseThrow()>
<#assign typedField = field.asTypedField().orElseThrow()>
// Reserved Field (reserved)
- writeReservedField("reserved", reservedField${reservedFieldIndex}!=null?reservedField${reservedFieldIndex}:${helper.getReservedValue(reservedField)}, ${helper.getDataWriterCall(typedField.type, "reserved")});<#assign reservedFieldIndex=reservedFieldIndex+1>
+ writeReservedField("reserved", reservedField${reservedFieldIndex}!=null?reservedField${reservedFieldIndex}:${helper.getReservedValue(reservedField)}, ${helper.getDataWriterCall(typedField.type, "reserved")}${helper.getFieldOptions(typedField, parserArguments)});<#assign reservedFieldIndex=reservedFieldIndex+1>
<#break>
<#case "simple">
<#assign simpleField = field.asSimpleField().orElseThrow()>
@@ -352,9 +352,9 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
// Simple Field (${namedField.name})
<#if typedField.type.isEnumTypeReference()>
- writeSimpleEnumField("${simpleField.name}", "${helper.getLanguageTypeNameForField(field)}", ${simpleField.name}, ${helper.getEnumDataWriterCall(simpleField.type, simpleField.name, "value")});
+ writeSimpleEnumField("${simpleField.name}", "${helper.getLanguageTypeNameForField(field)}", ${simpleField.name}, ${helper.getEnumDataWriterCall(simpleField.type, simpleField.name, "value")}${helper.getFieldOptions(typedField, parserArguments)});
<#elseif simpleField.type.isDataIoTypeReference()>
- writeSimpleField("${simpleField.name}", ${simpleField.name}, new DataWriterDataIoDefault(writeBuffer, (wb, val) -> ${simpleField.type.asComplexTypeReference().orElseThrow().name}.staticSerialize(wb, val<#if simpleField.type.asComplexTypeReference().orElseThrow().params?has_content>, <#list simpleField.type.asComplexTypeReference().orElseThrow().params.orElseThrow() as param>${helper.toParseExpression(simpleField, helper.anyTypeReference, param, parserArguments [...]
+ writeSimpleField("${simpleField.name}", ${simpleField.name}, new DataWriterDataIoDefault(writeBuffer, (wb, val) -> ${simpleField.type.asComplexTypeReference().orElseThrow().name}.staticSerialize(wb, val<#if simpleField.type.asComplexTypeReference().orElseThrow().params?has_content>, <#list simpleField.type.asComplexTypeReference().orElseThrow().params.orElseThrow() as param>${helper.toParseExpression(simpleField, helper.anyTypeReference, param, parserArguments [...]
<#else>
writeSimpleField("${simpleField.name}", ${simpleField.name}, ${helper.getDataWriterCall(typedField.type, simpleField.name)}${helper.getFieldOptions(typedField, parserArguments)});</#if>
<#break>
@@ -481,9 +481,10 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#break>
<#case "optional">
<#assign optionalField = field.asOptionalField().orElseThrow()>
+ <#assign nullBytesHex = optionalField.getNullBytesHex()>
- // Optional Field (${optionalField.name})
- if(${optionalField.name} != null) {
+ // Optional Field (${optionalField.name})<#if nullBytesHex.isEmpty()>
+ if(${optionalField.name} != null) {</#if>
<#if optionalField.type.isSimpleTypeReference()>
<#assign simpleTypeReference = optionalField.type.asSimpleTypeReference().orElseThrow()>
<#if simpleTypeReference.isVstringTypeReference()>
@@ -499,7 +500,7 @@ public<#if type.isDiscriminatedParentTypeDefinition()> abstract</#if> class ${ty
<#else>
lengthInBits += ${optionalField.name}.getLengthInBits();
</#if>
- }
+ <#if nullBytesHex.isEmpty()>}</#if>
<#break>
<#case "padding">
<#assign paddingField = field.asPaddingField().orElseThrow()>
diff --git a/code-generation/language-java/src/main/resources/templates/java/data-io-template.java.ftlh b/code-generation/language-java/src/main/resources/templates/java/data-io-template.java.ftlh
index bd6757104b..a1fda21e90 100644
--- a/code-generation/language-java/src/main/resources/templates/java/data-io-template.java.ftlh
+++ b/code-generation/language-java/src/main/resources/templates/java/data-io-template.java.ftlh
@@ -50,6 +50,7 @@ import static org.apache.plc4x.java.spi.generation.StaticHelper.*;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
import org.apache.plc4x.java.spi.generation.SerializationException;
diff --git a/plc4j/drivers/ab-eth/src/main/generated/org/apache/plc4x/java/abeth/readwrite/CIPEncapsulationPacket.java b/plc4j/drivers/ab-eth/src/main/generated/org/apache/plc4x/java/abeth/readwrite/CIPEncapsulationPacket.java
index 91527e7454..d299a7d8aa 100644
--- a/plc4j/drivers/ab-eth/src/main/generated/org/apache/plc4x/java/abeth/readwrite/CIPEncapsulationPacket.java
+++ b/plc4j/drivers/ab-eth/src/main/generated/org/apache/plc4x/java/abeth/readwrite/CIPEncapsulationPacket.java
@@ -82,12 +82,20 @@ public abstract class CIPEncapsulationPacket implements Message {
writeBuffer.pushContext("CIPEncapsulationPacket");
// Discriminator Field (commandType) (Used as input to a switch field)
- writeDiscriminatorField("commandType", getCommandType(), writeUnsignedInt(writeBuffer, 16));
+ writeDiscriminatorField(
+ "commandType",
+ getCommandType(),
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (packetLen) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
int packetLen = (int) ((getLengthInBytes()) - (28));
- writeImplicitField("packetLen", packetLen, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "packetLen",
+ packetLen,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (sessionHandle)
writeSimpleField(
@@ -104,7 +112,11 @@ public abstract class CIPEncapsulationPacket implements Message {
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (senderContext)
- writeSimpleTypeArrayField("senderContext", senderContext, writeUnsignedShort(writeBuffer, 8));
+ writeSimpleTypeArrayField(
+ "senderContext",
+ senderContext,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (options)
writeSimpleField(
@@ -117,7 +129,8 @@ public abstract class CIPEncapsulationPacket implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (long) 0x00000000,
- writeUnsignedLong(writeBuffer, 32));
+ writeUnsignedLong(writeBuffer, 32),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Switch field (Serialize the sub-type)
serializeCIPEncapsulationPacketChild(writeBuffer);
diff --git a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableChildEntry.java b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableChildEntry.java
index a0b8d20a41..e8c284ca82 100644
--- a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableChildEntry.java
+++ b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableChildEntry.java
@@ -236,17 +236,29 @@ public class AdsDataTypeTableChildEntry implements Message {
// Implicit Field (propertyNameLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int propertyNameLength = (int) (STR_LEN(getPropertyName()));
- writeImplicitField("propertyNameLength", propertyNameLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "propertyNameLength",
+ propertyNameLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (dataTypeNameLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int dataTypeNameLength = (int) (STR_LEN(getDataTypeName()));
- writeImplicitField("dataTypeNameLength", dataTypeNameLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "dataTypeNameLength",
+ dataTypeNameLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (commentLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int commentLength = (int) (STR_LEN(getComment()));
- writeImplicitField("commentLength", commentLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "commentLength",
+ commentLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (arrayDimensions)
writeSimpleField(
@@ -271,7 +283,10 @@ public class AdsDataTypeTableChildEntry implements Message {
// Const Field (propertyNameTerminator)
writeConstField(
- "propertyNameTerminator", PROPERTYNAMETERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ "propertyNameTerminator",
+ PROPERTYNAMETERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (dataTypeName)
writeSimpleField(
@@ -282,7 +297,10 @@ public class AdsDataTypeTableChildEntry implements Message {
// Const Field (dataTypeNameTerminator)
writeConstField(
- "dataTypeNameTerminator", DATATYPENAMETERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ "dataTypeNameTerminator",
+ DATATYPENAMETERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (comment)
writeSimpleField(
@@ -292,16 +310,26 @@ public class AdsDataTypeTableChildEntry implements Message {
WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Const Field (commentTerminator)
- writeConstField("commentTerminator", COMMENTTERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "commentTerminator",
+ COMMENTTERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (arrayInfo)
- writeComplexTypeArrayField("arrayInfo", arrayInfo, writeBuffer);
+ writeComplexTypeArrayField(
+ "arrayInfo", arrayInfo, writeBuffer, WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (children)
- writeComplexTypeArrayField("children", children, writeBuffer);
+ writeComplexTypeArrayField(
+ "children", children, writeBuffer, WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (rest)
- writeByteArrayField("rest", rest, writeByteArray(writeBuffer, 8));
+ writeByteArrayField(
+ "rest",
+ rest,
+ writeByteArray(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
writeBuffer.popContext("AdsDataTypeTableChildEntry");
}
diff --git a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableEntry.java b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableEntry.java
index 370b3d52ea..e905c258ce 100644
--- a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableEntry.java
+++ b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsDataTypeTableEntry.java
@@ -236,18 +236,29 @@ public class AdsDataTypeTableEntry implements Message {
// Implicit Field (dataTypeNameLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int dataTypeNameLength = (int) (STR_LEN(getDataTypeName()));
- writeImplicitField("dataTypeNameLength", dataTypeNameLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "dataTypeNameLength",
+ dataTypeNameLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (simpleTypeNameLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int simpleTypeNameLength = (int) (STR_LEN(getSimpleTypeName()));
writeImplicitField(
- "simpleTypeNameLength", simpleTypeNameLength, writeUnsignedInt(writeBuffer, 16));
+ "simpleTypeNameLength",
+ simpleTypeNameLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (commentLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int commentLength = (int) (STR_LEN(getComment()));
- writeImplicitField("commentLength", commentLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "commentLength",
+ commentLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (arrayDimensions)
writeSimpleField(
@@ -272,7 +283,10 @@ public class AdsDataTypeTableEntry implements Message {
// Const Field (dataTypeNameTerminator)
writeConstField(
- "dataTypeNameTerminator", DATATYPENAMETERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ "dataTypeNameTerminator",
+ DATATYPENAMETERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (simpleTypeName)
writeSimpleField(
@@ -283,7 +297,10 @@ public class AdsDataTypeTableEntry implements Message {
// Const Field (simpleTypeNameTerminator)
writeConstField(
- "simpleTypeNameTerminator", SIMPLETYPENAMETERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ "simpleTypeNameTerminator",
+ SIMPLETYPENAMETERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (comment)
writeSimpleField(
@@ -293,16 +310,26 @@ public class AdsDataTypeTableEntry implements Message {
WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Const Field (commentTerminator)
- writeConstField("commentTerminator", COMMENTTERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "commentTerminator",
+ COMMENTTERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (arrayInfo)
- writeComplexTypeArrayField("arrayInfo", arrayInfo, writeBuffer);
+ writeComplexTypeArrayField(
+ "arrayInfo", arrayInfo, writeBuffer, WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (children)
- writeComplexTypeArrayField("children", children, writeBuffer);
+ writeComplexTypeArrayField(
+ "children", children, writeBuffer, WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (rest)
- writeByteArrayField("rest", rest, writeByteArray(writeBuffer, 8));
+ writeByteArrayField(
+ "rest",
+ rest,
+ writeByteArray(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
writeBuffer.popContext("AdsDataTypeTableEntry");
}
diff --git a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsSymbolTableEntry.java b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsSymbolTableEntry.java
index e89c8181a2..5e300ce7dd 100644
--- a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsSymbolTableEntry.java
+++ b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AdsSymbolTableEntry.java
@@ -317,7 +317,8 @@ public class AdsSymbolTableEntry implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (byte) 0x00,
- writeUnsignedByte(writeBuffer, 3));
+ writeUnsignedByte(writeBuffer, 3),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (flagExtendedFlags)
writeSimpleField(
@@ -358,22 +359,35 @@ public class AdsSymbolTableEntry implements Message {
writeReservedField(
"reserved",
reservedField1 != null ? reservedField1 : (int) 0x0000,
- writeUnsignedInt(writeBuffer, 16));
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (nameLength) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
int nameLength = (int) (STR_LEN(getName()));
- writeImplicitField("nameLength", nameLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "nameLength",
+ nameLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (dataTypeNameLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int dataTypeNameLength = (int) (STR_LEN(getDataTypeName()));
- writeImplicitField("dataTypeNameLength", dataTypeNameLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "dataTypeNameLength",
+ dataTypeNameLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (commentLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int commentLength = (int) (STR_LEN(getComment()));
- writeImplicitField("commentLength", commentLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "commentLength",
+ commentLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (name)
writeSimpleField(
@@ -383,7 +397,11 @@ public class AdsSymbolTableEntry implements Message {
WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Const Field (nameTerminator)
- writeConstField("nameTerminator", NAMETERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "nameTerminator",
+ NAMETERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (dataTypeName)
writeSimpleField(
@@ -394,7 +412,10 @@ public class AdsSymbolTableEntry implements Message {
// Const Field (dataTypeNameTerminator)
writeConstField(
- "dataTypeNameTerminator", DATATYPENAMETERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ "dataTypeNameTerminator",
+ DATATYPENAMETERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (comment)
writeSimpleField(
@@ -404,10 +425,18 @@ public class AdsSymbolTableEntry implements Message {
WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Const Field (commentTerminator)
- writeConstField("commentTerminator", COMMENTTERMINATOR, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "commentTerminator",
+ COMMENTTERMINATOR,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (rest)
- writeByteArrayField("rest", rest, writeByteArray(writeBuffer, 8));
+ writeByteArrayField(
+ "rest",
+ rest,
+ writeByteArray(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
writeBuffer.popContext("AdsSymbolTableEntry");
}
diff --git a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AmsTCPPacket.java b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AmsTCPPacket.java
index 2d323e543e..e16963a1e9 100644
--- a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AmsTCPPacket.java
+++ b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/AmsTCPPacket.java
@@ -60,12 +60,17 @@ public class AmsTCPPacket implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (int) 0x0000,
- writeUnsignedInt(writeBuffer, 16));
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Implicit Field (length) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
long length = (long) (getUserdata().getLengthInBytes());
- writeImplicitField("length", length, writeUnsignedLong(writeBuffer, 32));
+ writeImplicitField(
+ "length",
+ length,
+ writeUnsignedLong(writeBuffer, 32),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (userdata)
writeSimpleField(
diff --git a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/DataItem.java b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/DataItem.java
index 49308516ee..9f41ac621b 100644
--- a/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/DataItem.java
+++ b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/DataItem.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -149,21 +150,21 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8");
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"));
return new PlcCHAR(value);
} else if (EvaluationHelper.equals(plcValueType, PlcValueType.WCHAR)) { // WCHAR
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16LE");
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16LE"));
return new PlcWCHAR(value);
} else if (EvaluationHelper.equals(plcValueType, PlcValueType.STRING)) { // STRING
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", (stringLength) * (8), "UTF-8");
+ readBuffer.readString("", (stringLength) * (8), WithOption.WithEncoding("UTF-8"));
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
@@ -180,7 +181,8 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", ((stringLength) * (8)) * (2), "UTF-16LE");
+ readBuffer.readString(
+ "", ((stringLength) * (8)) * (2), WithOption.WithEncoding("UTF-16LE"));
// Reserved Field (Compartmentalized so the "reserved" variable can't leak)
{
@@ -353,18 +355,20 @@ public class DataItem {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(plcValueType, PlcValueType.WCHAR)) { // WCHAR
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16LE", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16LE"));
} else if (EvaluationHelper.equals(plcValueType, PlcValueType.STRING)) { // STRING
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
/*TODO: migrate me*/ writeBuffer.writeString(
- "", (stringLength) * (8), "UTF-8", (String) (value));
+ "", (stringLength) * (8), (String) (value), WithOption.WithEncoding("UTF-8"));
// Reserved Field
/*TODO: migrate me*/
/*TODO: migrate me*/ writeBuffer.writeUnsignedShort(
@@ -374,7 +378,7 @@ public class DataItem {
String value = (String) _value.getString();
/*TODO: migrate me*/
/*TODO: migrate me*/ writeBuffer.writeString(
- "", ((stringLength) * (8)) * (2), "UTF-16LE", (String) (value));
+ "", ((stringLength) * (8)) * (2), (String) (value), WithOption.WithEncoding("UTF-16LE"));
// Reserved Field
/*TODO: migrate me*/
/*TODO: migrate me*/ writeBuffer.writeUnsignedInt("", 16, ((Number) (int) 0x0000).intValue());
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCResult.java b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/ErrorResponse.java
similarity index 58%
copy from plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCResult.java
copy to plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/ErrorResponse.java
index e52a8e42a0..152d6ab61d 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCResult.java
+++ b/plc4j/drivers/ads/src/main/generated/org/apache/plc4x/java/ads/readwrite/ErrorResponse.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.plc4x.java.bacnetip.readwrite;
+package org.apache.plc4x.java.ads.readwrite;
import static org.apache.plc4x.java.spi.codegen.fields.FieldReaderFactory.*;
import static org.apache.plc4x.java.spi.codegen.fields.FieldWriterFactory.*;
@@ -35,40 +35,34 @@ import org.apache.plc4x.java.spi.generation.*;
// Code generated by code-generation. DO NOT EDIT.
-public class BVLCResult extends BVLC implements Message {
+public class ErrorResponse extends AmsPacket implements Message {
// Accessors for discriminator values.
- public Short getBvlcFunction() {
- return (short) 0x00;
+ public CommandId getCommandId() {
+ return null;
}
- // Properties.
- protected final BVLCResultCode code;
-
- public BVLCResult(BVLCResultCode code) {
- super();
- this.code = code;
+ public Boolean getResponse() {
+ return false;
}
- public BVLCResultCode getCode() {
- return code;
+ public ErrorResponse(
+ AmsNetId targetAmsNetId,
+ int targetAmsPort,
+ AmsNetId sourceAmsNetId,
+ int sourceAmsPort,
+ long errorCode,
+ long invokeId) {
+ super(targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, errorCode, invokeId);
}
@Override
- protected void serializeBVLCChild(WriteBuffer writeBuffer) throws SerializationException {
+ protected void serializeAmsPacketChild(WriteBuffer writeBuffer) throws SerializationException {
PositionAware positionAware = writeBuffer;
int startPos = positionAware.getPos();
- writeBuffer.pushContext("BVLCResult");
-
- // Simple Field (code)
- writeSimpleEnumField(
- "code",
- "BVLCResultCode",
- code,
- new DataWriterEnumDefault<>(
- BVLCResultCode::getValue, BVLCResultCode::name, writeUnsignedInt(writeBuffer, 16)));
+ writeBuffer.pushContext("ErrorResponse");
- writeBuffer.popContext("BVLCResult");
+ writeBuffer.popContext("ErrorResponse");
}
@Override
@@ -79,44 +73,38 @@ public class BVLCResult extends BVLC implements Message {
@Override
public int getLengthInBits() {
int lengthInBits = super.getLengthInBits();
- BVLCResult _value = this;
-
- // Simple field (code)
- lengthInBits += 16;
+ ErrorResponse _value = this;
return lengthInBits;
}
- public static BVLCResultBuilder staticParseBuilder(ReadBuffer readBuffer) throws ParseException {
- readBuffer.pullContext("BVLCResult");
+ public static ErrorResponseBuilder staticParseBuilder(ReadBuffer readBuffer)
+ throws ParseException {
+ readBuffer.pullContext("ErrorResponse");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
int curPos;
- BVLCResultCode code =
- readEnumField(
- "code",
- "BVLCResultCode",
- new DataReaderEnumDefault<>(
- BVLCResultCode::enumForValue, readUnsignedInt(readBuffer, 16)),
- WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
-
- readBuffer.closeContext("BVLCResult");
+ readBuffer.closeContext("ErrorResponse");
// Create the instance
- return new BVLCResultBuilder(code);
+ return new ErrorResponseBuilder();
}
- public static class BVLCResultBuilder implements BVLC.BVLCBuilder {
- private final BVLCResultCode code;
-
- public BVLCResultBuilder(BVLCResultCode code) {
-
- this.code = code;
- }
-
- public BVLCResult build() {
- BVLCResult bVLCResult = new BVLCResult(code);
- return bVLCResult;
+ public static class ErrorResponseBuilder implements AmsPacket.AmsPacketBuilder {
+
+ public ErrorResponseBuilder() {}
+
+ public ErrorResponse build(
+ AmsNetId targetAmsNetId,
+ int targetAmsPort,
+ AmsNetId sourceAmsNetId,
+ int sourceAmsPort,
+ long errorCode,
+ long invokeId) {
+ ErrorResponse errorResponse =
+ new ErrorResponse(
+ targetAmsNetId, targetAmsPort, sourceAmsNetId, sourceAmsPort, errorCode, invokeId);
+ return errorResponse;
}
}
@@ -125,16 +113,16 @@ public class BVLCResult extends BVLC implements Message {
if (this == o) {
return true;
}
- if (!(o instanceof BVLCResult)) {
+ if (!(o instanceof ErrorResponse)) {
return false;
}
- BVLCResult that = (BVLCResult) o;
- return (getCode() == that.getCode()) && super.equals(that) && true;
+ ErrorResponse that = (ErrorResponse) o;
+ return super.equals(that) && true;
}
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), getCode());
+ return Objects.hash(super.hashCode());
}
@Override
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsStringTag.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsStringTag.java
index 669a8e71e1..2627108c4d 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsStringTag.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsStringTag.java
@@ -19,6 +19,7 @@
package org.apache.plc4x.java.ads.tag;
import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -116,7 +117,9 @@ public class DirectAdsStringTag extends DirectAdsTag implements AdsStringTag {
writeBuffer.writeUnsignedLong("indexGroup", 32, getIndexGroup());
writeBuffer.writeUnsignedLong("indexOffset", 32, getIndexOffset());
writeBuffer.writeUnsignedLong("numberOfElements", 32, getNumberOfElements());
- writeBuffer.writeString("dataType", getPlcDataType().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), getPlcDataType());
+ writeBuffer.writeString("dataType",
+ getPlcDataType().getBytes(StandardCharsets.UTF_8).length * 8,
+ getPlcDataType(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.writeUnsignedLong("stringLength", 32, getStringLength());
writeBuffer.popContext(getClass().getSimpleName());
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsTag.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsTag.java
index 8e267716da..9ece366ea5 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsTag.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/DirectAdsTag.java
@@ -21,6 +21,7 @@ package org.apache.plc4x.java.ads.tag;
import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.model.DefaultArrayInfo;
@@ -177,8 +178,9 @@ public class DirectAdsTag implements AdsTag {
writeBuffer.writeUnsignedLong("indexGroup", 32, getIndexGroup());
writeBuffer.writeUnsignedLong("indexOffset", 32, getIndexOffset());
writeBuffer.writeUnsignedLong("numberOfElements", 32, getNumberOfElements());
- String plcDataType = getPlcDataType();
- writeBuffer.writeString("dataType", plcDataType.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), plcDataType);
+ writeBuffer.writeString("dataType",
+ getPlcDataType().getBytes(StandardCharsets.UTF_8).length * 8,
+ getPlcDataType(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java
index 5c702f5971..cf883c82bd 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java
@@ -21,11 +21,11 @@ package org.apache.plc4x.java.ads.tag;
import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
@@ -113,7 +113,9 @@ public class SymbolicAdsTag implements AdsTag {
writeBuffer.pushContext(getClass().getSimpleName());
String symbolicAddress = getSymbolicAddress();
- writeBuffer.writeString("symbolicAddress", symbolicAddress.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), symbolicAddress);
+ writeBuffer.writeString("symbolicAddress",
+ symbolicAddress.getBytes(StandardCharsets.UTF_8).length * 8,
+ symbolicAddress, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLC.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLC.java
index 0fd8738969..2bd90448d4 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLC.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLC.java
@@ -63,15 +63,27 @@ public abstract class BVLC implements Message {
writeBuffer.pushContext("BVLC");
// Const Field (bacnetType)
- writeConstField("bacnetType", BACNETTYPE, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "bacnetType",
+ BACNETTYPE,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Discriminator Field (bvlcFunction) (Used as input to a switch field)
- writeDiscriminatorField("bvlcFunction", getBvlcFunction(), writeUnsignedShort(writeBuffer, 8));
+ writeDiscriminatorField(
+ "bvlcFunction",
+ getBvlcFunction(),
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (bvlcLength) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
int bvlcLength = (int) (getLengthInBytes());
- writeImplicitField("bvlcLength", bvlcLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "bvlcLength",
+ bvlcLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Virtual field (doesn't actually serialize anything, just makes the value available)
int bvlcPayloadLength = getBvlcPayloadLength();
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCDeleteForeignDeviceTableEntry.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCDeleteForeignDeviceTableEntry.java
index 4b9f68f57f..0265c66ce3 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCDeleteForeignDeviceTableEntry.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCDeleteForeignDeviceTableEntry.java
@@ -67,7 +67,11 @@ public class BVLCDeleteForeignDeviceTableEntry extends BVLC implements Message {
writeBuffer.pushContext("BVLCDeleteForeignDeviceTableEntry");
// Array Field (ip)
- writeSimpleTypeArrayField("ip", ip, writeUnsignedShort(writeBuffer, 8));
+ writeSimpleTypeArrayField(
+ "ip",
+ ip,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (port)
writeSimpleField(
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCForwardedNPDU.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCForwardedNPDU.java
index 238fa3f732..4dbb6bee07 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCForwardedNPDU.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCForwardedNPDU.java
@@ -77,7 +77,11 @@ public class BVLCForwardedNPDU extends BVLC implements Message {
writeBuffer.pushContext("BVLCForwardedNPDU");
// Array Field (ip)
- writeSimpleTypeArrayField("ip", ip, writeUnsignedShort(writeBuffer, 8));
+ writeSimpleTypeArrayField(
+ "ip",
+ ip,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (port)
writeSimpleField(
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadBroadcastDistributionTableAck.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadBroadcastDistributionTableAck.java
index 989c800777..99f49e1756 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadBroadcastDistributionTableAck.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadBroadcastDistributionTableAck.java
@@ -66,7 +66,8 @@ public class BVLCReadBroadcastDistributionTableAck extends BVLC implements Messa
writeBuffer.pushContext("BVLCReadBroadcastDistributionTableAck");
// Array Field (table)
- writeComplexTypeArrayField("table", table, writeBuffer);
+ writeComplexTypeArrayField(
+ "table", table, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("BVLCReadBroadcastDistributionTableAck");
}
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadForeignDeviceTableAck.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadForeignDeviceTableAck.java
index a1424b07ff..d54f7723b4 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadForeignDeviceTableAck.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCReadForeignDeviceTableAck.java
@@ -66,7 +66,8 @@ public class BVLCReadForeignDeviceTableAck extends BVLC implements Message {
writeBuffer.pushContext("BVLCReadForeignDeviceTableAck");
// Array Field (table)
- writeComplexTypeArrayField("table", table, writeBuffer);
+ writeComplexTypeArrayField(
+ "table", table, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("BVLCReadForeignDeviceTableAck");
}
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCResult.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCResult.java
index e52a8e42a0..9c6fa694c3 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCResult.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCResult.java
@@ -66,7 +66,8 @@ public class BVLCResult extends BVLC implements Message {
"BVLCResultCode",
code,
new DataWriterEnumDefault<>(
- BVLCResultCode::getValue, BVLCResultCode::name, writeUnsignedInt(writeBuffer, 16)));
+ BVLCResultCode::getValue, BVLCResultCode::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("BVLCResult");
}
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCSecureBVLL.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCSecureBVLL.java
index 37194ef85a..de2c661d3b 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCSecureBVLL.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCSecureBVLL.java
@@ -65,7 +65,11 @@ public class BVLCSecureBVLL extends BVLC implements Message {
writeBuffer.pushContext("BVLCSecureBVLL");
// Array Field (securityWrapper)
- writeByteArrayField("securityWrapper", securityWrapper, writeByteArray(writeBuffer, 8));
+ writeByteArrayField(
+ "securityWrapper",
+ securityWrapper,
+ writeByteArray(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("BVLCSecureBVLL");
}
diff --git a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCWriteBroadcastDistributionTable.java b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCWriteBroadcastDistributionTable.java
index e4560c89dc..b0f7b5b89d 100644
--- a/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCWriteBroadcastDistributionTable.java
+++ b/plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BVLCWriteBroadcastDistributionTable.java
@@ -66,7 +66,8 @@ public class BVLCWriteBroadcastDistributionTable extends BVLC implements Message
writeBuffer.pushContext("BVLCWriteBroadcastDistributionTable");
// Array Field (table)
- writeComplexTypeArrayField("table", table, writeBuffer);
+ writeComplexTypeArrayField(
+ "table", table, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("BVLCWriteBroadcastDistributionTable");
}
diff --git a/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenFrame.java b/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenFrame.java
index 551099a259..1a818f811b 100644
--- a/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenFrame.java
+++ b/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/CANOpenFrame.java
@@ -86,10 +86,15 @@ public class CANOpenFrame implements Message {
"CANOpenService",
service,
new DataWriterEnumDefault<>(
- CANOpenService::getValue, CANOpenService::name, writeUnsignedByte(writeBuffer, 4)));
+ CANOpenService::getValue, CANOpenService::name, writeUnsignedByte(writeBuffer, 4)),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Const Field (alignment)
- writeConstField("alignment", ALIGNMENT, writeUnsignedByte(writeBuffer, 4));
+ writeConstField(
+ "alignment",
+ ALIGNMENT,
+ writeUnsignedByte(writeBuffer, 4),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Simple Field (payload)
writeSimpleField(
@@ -103,7 +108,8 @@ public class CANOpenFrame implements Message {
"padding",
(int) ((8) - ((payload.getLengthInBytes()))),
(short) 0x00,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
writeBuffer.popContext("CANOpenFrame");
}
diff --git a/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/DataItem.java b/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/DataItem.java
index 20aa545e46..c417e260f6 100644
--- a/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/DataItem.java
+++ b/plc4j/drivers/canopen/src/main/generated/org/apache/plc4x/java/canopen/readwrite/DataItem.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -175,21 +176,21 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", size, "UTF-8");
+ readBuffer.readString("", size, WithOption.WithEncoding("UTF-8"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(dataType, CANOpenDataType.VISIBLE_STRING)) { // STRING
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", size, "UTF-8");
+ readBuffer.readString("", size, WithOption.WithEncoding("UTF-8"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(dataType, CANOpenDataType.UNICODE_STRING)) { // STRING
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", (size) / (8), "UTF-8");
+ readBuffer.readString("", (size) / (8), WithOption.WithEncoding("UTF-8"));
return new PlcSTRING(value);
}
@@ -316,17 +317,20 @@ public class DataItem {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", size, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", size, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(dataType, CANOpenDataType.VISIBLE_STRING)) { // STRING
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", size, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", size, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(dataType, CANOpenDataType.UNICODE_STRING)) { // STRING
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", (size) / (8), "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", (size) / (8), (String) (value), WithOption.WithEncoding("UTF-8"));
}
}
diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/readwrite/utils/StaticHelper.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/readwrite/utils/StaticHelper.java
index 87b016139f..4dab9e50d6 100644
--- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/readwrite/utils/StaticHelper.java
+++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/readwrite/utils/StaticHelper.java
@@ -23,6 +23,7 @@ import org.apache.plc4x.java.canopen.readwrite.SDOInitiateExpeditedUploadRespons
import org.apache.plc4x.java.canopen.readwrite.SDOInitiateUploadResponsePayload;
import org.apache.plc4x.java.canopen.readwrite.SDOSegmentUploadResponse;
import org.apache.plc4x.java.canopen.readwrite.CANOpenService;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ParseException;
import org.apache.plc4x.java.spi.generation.ReadBuffer;
import org.apache.plc4x.java.spi.generation.SerializationException;
@@ -49,11 +50,11 @@ public class StaticHelper {
}
public static Object parseString(ReadBuffer io, int length, String charset) throws ParseException {
- return io.readString(8 * length, charset);
+ return io.readString(8 * length, WithOption.WithEncoding(charset));
}
public static void serializeString(WriteBuffer io, PlcValue value, String charset) throws SerializationException {
- io.writeString(8, charset, value.getString());
+ io.writeString(8, value.getString(), WithOption.WithEncoding(charset));
}
public static byte[] parseByteArray(ReadBuffer io, Integer length) {
diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenHeartbeatTag.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenHeartbeatTag.java
index 8c0a2c9bd3..6c99b56500 100644
--- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenHeartbeatTag.java
+++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenHeartbeatTag.java
@@ -22,6 +22,7 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.canopen.readwrite.CANOpenService;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -88,7 +89,9 @@ public class CANOpenHeartbeatTag extends CANOpenTag implements CANOpenSubscripti
writeBuffer.pushContext(getClass().getSimpleName());
String serviceName = getService().name();
- writeBuffer.writeString("service", serviceName.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), serviceName);
+ writeBuffer.writeString("service",
+ serviceName.getBytes(StandardCharsets.UTF_8).length * 8,
+ serviceName, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.writeInt("node", 64, getNodeId());
writeBuffer.popContext(getClass().getSimpleName());
diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenNMTTag.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenNMTTag.java
index fa84cca70d..6f93a585cd 100644
--- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenNMTTag.java
+++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenNMTTag.java
@@ -22,6 +22,7 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.canopen.readwrite.CANOpenService;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -89,7 +90,9 @@ public class CANOpenNMTTag extends CANOpenTag implements CANOpenSubscriptionTag
writeBuffer.pushContext(getClass().getSimpleName());
String serviceName = getService().name();
- writeBuffer.writeString("service", serviceName.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), serviceName);
+ writeBuffer.writeString("service",
+ serviceName.getBytes(StandardCharsets.UTF_8).length * 8,
+ serviceName, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.writeInt("node",64, getNodeId());
writeBuffer.popContext(getClass().getSimpleName());
diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenPDOTag.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenPDOTag.java
index 91bf6d4ff3..d9b707b699 100644
--- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenPDOTag.java
+++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenPDOTag.java
@@ -23,6 +23,7 @@ import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.canopen.readwrite.CANOpenDataType;
import org.apache.plc4x.java.canopen.readwrite.CANOpenService;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -105,10 +106,14 @@ public class CANOpenPDOTag extends CANOpenTag implements CANOpenSubscriptionTag
writeBuffer.pushContext(getClass().getSimpleName());
String serviceName = getService().name();
- writeBuffer.writeString("service", serviceName.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), serviceName);
+ writeBuffer.writeString("service",
+ serviceName.getBytes(StandardCharsets.UTF_8).length * 8,
+ serviceName, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.writeInt("node",64, getNodeId());
String dataTypeName = getCanOpenDataType().name();
- writeBuffer.writeString("dataType", dataTypeName.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), dataTypeName);
+ writeBuffer.writeString("dataType",
+ dataTypeName.getBytes(StandardCharsets.UTF_8).length * 8,
+ dataTypeName, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenSDOTag.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenSDOTag.java
index 55de45c278..f033255ba6 100644
--- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenSDOTag.java
+++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/tag/CANOpenSDOTag.java
@@ -22,6 +22,7 @@ import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.canopen.readwrite.CANOpenDataType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -140,7 +141,9 @@ public class CANOpenSDOTag extends CANOpenTag {
writeBuffer.writeInt("index",64, getIndex());
writeBuffer.writeInt("subIndex",64, getSubIndex());
String dataTypeName = getCanOpenDataType().name();
- writeBuffer.writeString("dataType", dataTypeName.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), dataTypeName);
+ writeBuffer.writeString("dataType",
+ dataTypeName.getBytes(StandardCharsets.UTF_8).length * 8,
+ dataTypeName, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/tag/EipTag.java b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/tag/EipTag.java
index 2312026271..2c3d6b25aa 100644
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/tag/EipTag.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/readwrite/tag/EipTag.java
@@ -23,6 +23,7 @@ import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.eip.readwrite.CIPDataTypeCode;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.utils.Serializable;
@@ -136,14 +137,20 @@ public class EipTag implements PlcTag, Serializable {
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
writeBuffer.pushContext(getClass().getSimpleName());
- writeBuffer.writeString("node", tag.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), tag);
+ writeBuffer.writeString("node",
+ tag.getBytes(StandardCharsets.UTF_8).length * 8,
+ tag, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
if (type != null) {
- writeBuffer.writeString("type", type.name().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), type.name());
+ writeBuffer.writeString("type",
+ type.name().getBytes(StandardCharsets.UTF_8).length * 8,
+ type.name(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
writeBuffer.writeUnsignedInt("elementNb", 16, elementNb);
// TODO: remove this (not language agnostic)
String defaultJavaType = (type == null ? Object.class : getPlcValueType().getDefaultJavaType()).getName();
- writeBuffer.writeString("defaultJavaType", defaultJavaType.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), defaultJavaType);
+ writeBuffer.writeString("defaultJavaType",
+ defaultJavaType.getBytes(StandardCharsets.UTF_8).length * 8,
+ defaultJavaType, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessage.java b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessage.java
index 86557f9430..a86760a1d8 100644
--- a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessage.java
+++ b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessage.java
@@ -57,7 +57,11 @@ public abstract class FirmataMessage implements Message {
writeBuffer.pushContext("FirmataMessage");
// Discriminator Field (messageType) (Used as input to a switch field)
- writeDiscriminatorField("messageType", getMessageType(), writeUnsignedByte(writeBuffer, 4));
+ writeDiscriminatorField(
+ "messageType",
+ getMessageType(),
+ writeUnsignedByte(writeBuffer, 4),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Switch field (Serialize the sub-type)
serializeFirmataMessageChild(writeBuffer);
diff --git a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageAnalogIO.java b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageAnalogIO.java
index 3766b21525..dbfdde33a9 100644
--- a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageAnalogIO.java
+++ b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageAnalogIO.java
@@ -79,7 +79,11 @@ public class FirmataMessageAnalogIO extends FirmataMessage implements Message {
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (data)
- writeSimpleTypeArrayField("data", data, writeSignedByte(writeBuffer, 8));
+ writeSimpleTypeArrayField(
+ "data",
+ data,
+ writeSignedByte(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("FirmataMessageAnalogIO");
}
diff --git a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageDigitalIO.java b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageDigitalIO.java
index 75eb3c5624..08ba4995f7 100644
--- a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageDigitalIO.java
+++ b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageDigitalIO.java
@@ -79,7 +79,11 @@ public class FirmataMessageDigitalIO extends FirmataMessage implements Message {
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (data)
- writeSimpleTypeArrayField("data", data, writeSignedByte(writeBuffer, 8));
+ writeSimpleTypeArrayField(
+ "data",
+ data,
+ writeSignedByte(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("FirmataMessageDigitalIO");
}
diff --git a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeAnalogPinValue.java b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeAnalogPinValue.java
index a6b8c50696..836a71bb74 100644
--- a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeAnalogPinValue.java
+++ b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeAnalogPinValue.java
@@ -84,7 +84,8 @@ public class FirmataMessageSubscribeAnalogPinValue extends FirmataMessage implem
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 7));
+ writeUnsignedShort(writeBuffer, 7),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (enable)
writeSimpleField(
diff --git a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeDigitalPinValue.java b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeDigitalPinValue.java
index 9036cbb557..d56dcddcb8 100644
--- a/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeDigitalPinValue.java
+++ b/plc4j/drivers/firmata/src/main/generated/org/apache/plc4x/java/firmata/readwrite/FirmataMessageSubscribeDigitalPinValue.java
@@ -84,7 +84,8 @@ public class FirmataMessageSubscribeDigitalPinValue extends FirmataMessage imple
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 7));
+ writeUnsignedShort(writeBuffer, 7),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (enable)
writeSimpleField(
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionResponse.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionResponse.java
index a8c6d73ba1..f12d37c118 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionResponse.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionResponse.java
@@ -96,21 +96,24 @@ public class ConnectionResponse extends KnxNetIpMessage implements Message {
"Status",
status,
new DataWriterEnumDefault<>(
- Status::getValue, Status::name, writeUnsignedShort(writeBuffer, 8)));
+ Status::getValue, Status::name, writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Optional Field (hpaiDataEndpoint) (Can be skipped, if the value is null)
writeOptionalField(
"hpaiDataEndpoint",
hpaiDataEndpoint,
new DataWriterComplexDefault<>(writeBuffer),
- (getStatus()) == (Status.NO_ERROR));
+ (getStatus()) == (Status.NO_ERROR),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Optional Field (connectionResponseDataBlock) (Can be skipped, if the value is null)
writeOptionalField(
"connectionResponseDataBlock",
connectionResponseDataBlock,
new DataWriterComplexDefault<>(writeBuffer),
- (getStatus()) == (Status.NO_ERROR));
+ (getStatus()) == (Status.NO_ERROR),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("ConnectionResponse");
}
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateRequest.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateRequest.java
index 503640702c..6316eaea22 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateRequest.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateRequest.java
@@ -81,7 +81,8 @@ public class ConnectionStateRequest extends KnxNetIpMessage implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (hpaiControlEndpoint)
writeSimpleField(
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateResponse.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateResponse.java
index 923575d7be..d379f0e180 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateResponse.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/ConnectionStateResponse.java
@@ -80,7 +80,8 @@ public class ConnectionStateResponse extends KnxNetIpMessage implements Message
"Status",
status,
new DataWriterEnumDefault<>(
- Status::getValue, Status::name, writeUnsignedShort(writeBuffer, 8)));
+ Status::getValue, Status::name, writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("ConnectionStateResponse");
}
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectRequest.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectRequest.java
index c0fb14a57b..9f92158500 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectRequest.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectRequest.java
@@ -80,7 +80,8 @@ public class DisconnectRequest extends KnxNetIpMessage implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (hpaiControlEndpoint)
writeSimpleField(
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectResponse.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectResponse.java
index 5f5f946b7c..cc97a037f4 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectResponse.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/DisconnectResponse.java
@@ -80,7 +80,8 @@ public class DisconnectResponse extends KnxNetIpMessage implements Message {
"Status",
status,
new DataWriterEnumDefault<>(
- Status::getValue, Status::name, writeUnsignedShort(writeBuffer, 8)));
+ Status::getValue, Status::name, writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("DisconnectResponse");
}
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxDatapoint.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxDatapoint.java
index 2683b57074..9db44c3974 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxDatapoint.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxDatapoint.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -298,7 +299,7 @@ public class KnxDatapoint {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8");
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"));
return new PlcCHAR(value);
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.WCHAR)) { // WCHAR
@@ -315,7 +316,7 @@ public class KnxDatapoint {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16");
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"));
return new PlcWCHAR(value);
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.TIME)) { // TIME
@@ -1233,7 +1234,7 @@ public class KnxDatapoint {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "ASCII");
+ readBuffer.readString("", 8, WithOption.WithEncoding("ASCII"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.DPT_Char_8859_1)) { // STRING
@@ -1250,7 +1251,7 @@ public class KnxDatapoint {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "ISO-8859-1");
+ readBuffer.readString("", 8, WithOption.WithEncoding("ISO-8859-1"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.DPT_Scaling)) { // USINT
@@ -4022,7 +4023,7 @@ public class KnxDatapoint {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 112, "ASCII");
+ readBuffer.readString("", 112, WithOption.WithEncoding("ASCII"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(
@@ -4040,7 +4041,7 @@ public class KnxDatapoint {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 112, "ISO-8859-1");
+ readBuffer.readString("", 112, WithOption.WithEncoding("ISO-8859-1"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.DPT_SceneNumber)) { // USINT
@@ -7148,7 +7149,7 @@ public class KnxDatapoint {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "ASCII");
+ readBuffer.readString("", 16, WithOption.WithEncoding("ASCII"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(
@@ -8344,7 +8345,8 @@ public class KnxDatapoint {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.WCHAR)) { // WCHAR
// Reserved Field
/*TODO: migrate me*/
@@ -8353,7 +8355,8 @@ public class KnxDatapoint {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.TIME)) { // TIME
// Reserved Field
/*TODO: migrate me*/
@@ -8903,7 +8906,8 @@ public class KnxDatapoint {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "ASCII", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("ASCII"));
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.DPT_Char_8859_1)) { // STRING
// Reserved Field
/*TODO: migrate me*/
@@ -8912,7 +8916,8 @@ public class KnxDatapoint {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "ISO-8859-1", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("ISO-8859-1"));
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.DPT_Scaling)) { // USINT
// Reserved Field
/*TODO: migrate me*/
@@ -10531,7 +10536,8 @@ public class KnxDatapoint {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 112, "ASCII", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 112, (String) (value), WithOption.WithEncoding("ASCII"));
} else if (EvaluationHelper.equals(
datapointType, KnxDatapointType.DPT_String_8859_1)) { // STRING
// Reserved Field
@@ -10541,7 +10547,8 @@ public class KnxDatapoint {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 112, "ISO-8859-1", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 112, (String) (value), WithOption.WithEncoding("ISO-8859-1"));
} else if (EvaluationHelper.equals(datapointType, KnxDatapointType.DPT_SceneNumber)) { // USINT
// Reserved Field
/*TODO: migrate me*/
@@ -12641,7 +12648,8 @@ public class KnxDatapoint {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "ASCII", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("ASCII"));
} else if (EvaluationHelper.equals(
datapointType, KnxDatapointType.DPT_Tariff_ActiveEnergy)) { // Struct
// Reserved Field
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxNetIpMessage.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxNetIpMessage.java
index 5ef05a9868..7a7f1a64e5 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxNetIpMessage.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxNetIpMessage.java
@@ -62,18 +62,34 @@ public abstract class KnxNetIpMessage implements Message {
// Implicit Field (headerLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
short headerLength = (short) (6);
- writeImplicitField("headerLength", headerLength, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "headerLength",
+ headerLength,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (protocolVersion)
- writeConstField("protocolVersion", PROTOCOLVERSION, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "protocolVersion",
+ PROTOCOLVERSION,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Discriminator Field (msgType) (Used as input to a switch field)
- writeDiscriminatorField("msgType", getMsgType(), writeUnsignedInt(writeBuffer, 16));
+ writeDiscriminatorField(
+ "msgType",
+ getMsgType(),
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (totalLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int totalLength = (int) (getLengthInBytes());
- writeImplicitField("totalLength", totalLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "totalLength",
+ totalLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Switch field (Serialize the sub-type)
serializeKnxNetIpMessageChild(writeBuffer);
diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/UnknownMessage.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/UnknownMessage.java
index 09600ab9a7..e2bbe4c38f 100644
--- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/UnknownMessage.java
+++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/UnknownMessage.java
@@ -66,7 +66,11 @@ public class UnknownMessage extends KnxNetIpMessage implements Message {
writeBuffer.pushContext("UnknownMessage");
// Array Field (unknownData)
- writeByteArrayField("unknownData", unknownData, writeByteArray(writeBuffer, 8));
+ writeByteArrayField(
+ "unknownData",
+ unknownData,
+ writeByteArray(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("UnknownMessage");
}
diff --git a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java
index 025d128973..119e3703ba 100644
--- a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java
+++ b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/DataItem.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -465,7 +466,7 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8");
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"));
return new PlcCHAR(value);
} else if (EvaluationHelper.equals(dataType, ModbusDataType.CHAR)) { // List
@@ -486,7 +487,7 @@ public class DataItem {
value.add(
new PlcSTRING(
(String) /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8")));
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"))));
}
}
@@ -496,7 +497,7 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16");
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"));
return new PlcWCHAR(value);
} else if (EvaluationHelper.equals(dataType, ModbusDataType.WCHAR)) { // List
@@ -517,7 +518,7 @@ public class DataItem {
value.add(
new PlcSTRING(
(String) /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16")));
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"))));
}
}
@@ -754,14 +755,16 @@ public class DataItem {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(dataType, ModbusDataType.CHAR)) { // List
PlcList values = (PlcList) _value;
for (PlcValue val : ((List<PlcValue>) values.getList())) {
String value = (String) val.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
}
} else if (EvaluationHelper.equals(dataType, ModbusDataType.WCHAR)
@@ -769,14 +772,16 @@ public class DataItem {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
} else if (EvaluationHelper.equals(dataType, ModbusDataType.WCHAR)) { // List
PlcList values = (PlcList) _value;
for (PlcValue val : ((List<PlcValue>) values.getList())) {
String value = (String) val.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
}
}
}
diff --git a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusAsciiADU.java b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusAsciiADU.java
index cc2ca28b89..ceae3ab9fb 100644
--- a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusAsciiADU.java
+++ b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusAsciiADU.java
@@ -89,7 +89,8 @@ public class ModbusAsciiADU extends ModbusADU implements Message {
"crc",
(short)
(org.apache.plc4x.java.modbus.readwrite.utils.StaticHelper.asciiLrcCheck(address, pdu)),
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("ModbusAsciiADU");
}
diff --git a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusRtuADU.java b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusRtuADU.java
index ec172ef6f6..2da2a82cd1 100644
--- a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusRtuADU.java
+++ b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusRtuADU.java
@@ -88,7 +88,8 @@ public class ModbusRtuADU extends ModbusADU implements Message {
writeChecksumField(
"crc",
(int) (org.apache.plc4x.java.modbus.readwrite.utils.StaticHelper.rtuCrcCheck(address, pdu)),
- writeUnsignedInt(writeBuffer, 16));
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("ModbusRtuADU");
}
diff --git a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusTcpADU.java b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusTcpADU.java
index 9c43b7036f..509447a5b3 100644
--- a/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusTcpADU.java
+++ b/plc4j/drivers/modbus/src/main/generated/org/apache/plc4x/java/modbus/readwrite/ModbusTcpADU.java
@@ -92,12 +92,20 @@ public class ModbusTcpADU extends ModbusADU implements Message {
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (protocolIdentifier)
- writeConstField("protocolIdentifier", PROTOCOLIDENTIFIER, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "protocolIdentifier",
+ PROTOCOLIDENTIFIER,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (length) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
int length = (int) ((getPdu().getLengthInBytes()) + (1));
- writeImplicitField("length", length, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "length",
+ length,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (unitIdentifier)
writeSimpleField(
diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java
index 6f54812263..e65debcc7b 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/tag/ModbusTag.java
@@ -24,6 +24,7 @@ import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.modbus.readwrite.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.model.DefaultArrayInfo;
@@ -179,7 +180,9 @@ public abstract class ModbusTag implements PlcTag, Serializable {
writeBuffer.writeUnsignedInt("address", 16, address);
writeBuffer.writeUnsignedInt("numberOfElements", 16, getNumberOfElements());
String dataType = getDataType().name();
- writeBuffer.writeString("dataType", dataType.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), dataType);
+ writeBuffer.writeString("dataType",
+ dataType.getBytes(StandardCharsets.UTF_8).length * 8,
+ dataType, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlock.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlock.java
index e4f6a33adf..b344659ad7 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlock.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlock.java
@@ -53,7 +53,11 @@ public abstract class ApplicationCommunicationStartAcknowledgeBlock implements M
writeBuffer.pushContext("ApplicationCommunicationStartAcknowledgeBlock");
// Discriminator Field (blockType) (Used as input to a switch field)
- writeDiscriminatorField("blockType", getBlockType(), writeUnsignedInt(writeBuffer, 16));
+ writeDiscriminatorField(
+ "blockType",
+ getBlockType(),
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithEncoding("ASCII"));
// Switch field (Serialize the sub-type)
serializeApplicationCommunicationStartAcknowledgeBlockChild(writeBuffer);
@@ -94,7 +98,7 @@ public abstract class ApplicationCommunicationStartAcknowledgeBlock implements M
int blockType =
readDiscriminatorField(
- "blockType", readUnsignedInt(readBuffer, 16), WithOption.WithEncoding("AsciiUint"));
+ "blockType", readUnsignedInt(readBuffer, 16), WithOption.WithEncoding("ASCII"));
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
ApplicationCommunicationStartAcknowledgeBlockBuilder builder = null;
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockCellId.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockCellId.java
index b74b70fc2c..650c2a4083 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockCellId.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockCellId.java
@@ -64,7 +64,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockCellId
// Simple Field (cellId)
writeSimpleField(
- "cellId", cellId, writeUnsignedLong(writeBuffer, 32), WithOption.WithEncoding("AsciiUint"));
+ "cellId", cellId, writeUnsignedLong(writeBuffer, 32), WithOption.WithEncoding("ASCII"));
writeBuffer.popContext("ApplicationCommunicationStartAcknowledgeBlockCellId");
}
@@ -94,7 +94,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockCellId
long cellId =
readSimpleField(
- "cellId", readUnsignedLong(readBuffer, 32), WithOption.WithEncoding("AsciiUint"));
+ "cellId", readUnsignedLong(readBuffer, 32), WithOption.WithEncoding("ASCII"));
readBuffer.closeContext("ApplicationCommunicationStartAcknowledgeBlockCellId");
// Create the instance
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockChannelId.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockChannelId.java
index b5103122fa..056e0c5b4f 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockChannelId.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockChannelId.java
@@ -67,7 +67,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockChannelId
"channelId",
channelId,
writeUnsignedInt(writeBuffer, 16),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"));
writeBuffer.popContext("ApplicationCommunicationStartAcknowledgeBlockChannelId");
}
@@ -97,7 +97,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockChannelId
int channelId =
readSimpleField(
- "channelId", readUnsignedInt(readBuffer, 16), WithOption.WithEncoding("AsciiUint"));
+ "channelId", readUnsignedInt(readBuffer, 16), WithOption.WithEncoding("ASCII"));
readBuffer.closeContext("ApplicationCommunicationStartAcknowledgeBlockChannelId");
// Create the instance
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockClientId.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockClientId.java
index 1f7efac0b8..9c12f1467c 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockClientId.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockClientId.java
@@ -64,10 +64,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockClientId
// Simple Field (clientId)
writeSimpleField(
- "clientId",
- clientId,
- writeUnsignedShort(writeBuffer, 8),
- WithOption.WithEncoding("AsciiUint"));
+ "clientId", clientId, writeUnsignedShort(writeBuffer, 8), WithOption.WithEncoding("ASCII"));
writeBuffer.popContext("ApplicationCommunicationStartAcknowledgeBlockClientId");
}
@@ -97,7 +94,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockClientId
short clientId =
readSimpleField(
- "clientId", readUnsignedShort(readBuffer, 8), WithOption.WithEncoding("AsciiUint"));
+ "clientId", readUnsignedShort(readBuffer, 8), WithOption.WithEncoding("ASCII"));
readBuffer.closeContext("ApplicationCommunicationStartAcknowledgeBlockClientId");
// Create the instance
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockSupplierCode.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockSupplierCode.java
index 18e35b3deb..8b65846767 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockSupplierCode.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/ApplicationCommunicationStartAcknowledgeBlockSupplierCode.java
@@ -67,7 +67,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockSupplierCode
"supplierCode",
supplierCode,
writeUnsignedLong(writeBuffer, 24),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"));
writeBuffer.popContext("ApplicationCommunicationStartAcknowledgeBlockSupplierCode");
}
@@ -97,7 +97,7 @@ public class ApplicationCommunicationStartAcknowledgeBlockSupplierCode
long supplierCode =
readSimpleField(
- "supplierCode", readUnsignedLong(readBuffer, 24), WithOption.WithEncoding("AsciiUint"));
+ "supplierCode", readUnsignedLong(readBuffer, 24), WithOption.WithEncoding("ASCII"));
readBuffer.closeContext("ApplicationCommunicationStartAcknowledgeBlockSupplierCode");
// Create the instance
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessage.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessage.java
index 50aae65ee4..ace0cf2455 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessage.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessage.java
@@ -44,57 +44,62 @@ public abstract class OpenProtocolMessage implements Message {
public static final Short END = 0x00;
// Properties.
- protected final OpenProtocolRevision revision;
- protected final short noAckFlag;
- protected final int stationId;
- protected final int spindleId;
- protected final int sequenceNumber;
- protected final short numberOfMessageParts;
- protected final short messagePartNumber;
+ protected final OpenProtocolRevision selectedRevision;
+ protected final Short noAckFlag;
+ protected final Integer stationId;
+ protected final Integer spindleId;
+ protected final Integer sequenceNumber;
+ protected final Short numberOfMessageParts;
+ protected final Short messagePartNumber;
+
+ // Arguments.
+ protected final OpenProtocolRevision connectionRevision;
public OpenProtocolMessage(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
super();
- this.revision = revision;
+ this.selectedRevision = selectedRevision;
this.noAckFlag = noAckFlag;
this.stationId = stationId;
this.spindleId = spindleId;
this.sequenceNumber = sequenceNumber;
this.numberOfMessageParts = numberOfMessageParts;
this.messagePartNumber = messagePartNumber;
+ this.connectionRevision = connectionRevision;
}
- public OpenProtocolRevision getRevision() {
- return revision;
+ public OpenProtocolRevision getSelectedRevision() {
+ return selectedRevision;
}
- public short getNoAckFlag() {
+ public Short getNoAckFlag() {
return noAckFlag;
}
- public int getStationId() {
+ public Integer getStationId() {
return stationId;
}
- public int getSpindleId() {
+ public Integer getSpindleId() {
return spindleId;
}
- public int getSequenceNumber() {
+ public Integer getSequenceNumber() {
return sequenceNumber;
}
- public short getNumberOfMessageParts() {
+ public Short getNumberOfMessageParts() {
return numberOfMessageParts;
}
- public short getMessagePartNumber() {
+ public Short getMessagePartNumber() {
return messagePartNumber;
}
@@ -112,63 +117,77 @@ public abstract class OpenProtocolMessage implements Message {
// Implicit Field (length) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
- long length = (long) (getLengthInBytes());
- writeImplicitField("length", length, writeUnsignedLong(writeBuffer, 32));
+ long length = (long) ((getLengthInBytes()) - (1L));
+ writeImplicitField(
+ "length", length, writeUnsignedLong(writeBuffer, 32), WithOption.WithEncoding("ASCII"));
// Discriminator Field (mid) (Used as input to a switch field)
writeDiscriminatorEnumField(
"mid",
"Mid",
getMid(),
- new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)));
+ new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
- // Simple Field (revision)
- writeSimpleEnumField(
- "revision",
+ // Optional Field (selectedRevision) (Can be skipped, if the value is null)
+ writeOptionalEnumField(
+ "selectedRevision",
"OpenProtocolRevision",
- revision,
+ selectedRevision,
new DataWriterEnumDefault<>(
OpenProtocolRevision::getValue,
OpenProtocolRevision::name,
- writeUnsignedLong(writeBuffer, 24)));
-
- // Simple Field (noAckFlag)
- writeSimpleField("noAckFlag", noAckFlag, writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedLong(writeBuffer, 24)),
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("202020"));
+
+ // Optional Field (noAckFlag) (Can be skipped, if the value is null)
+ writeOptionalField(
+ "noAckFlag",
+ noAckFlag,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("20"));
- // Simple Field (stationId)
- writeSimpleField(
+ // Optional Field (stationId) (Can be skipped, if the value is null)
+ writeOptionalField(
"stationId",
stationId,
writeUnsignedInt(writeBuffer, 16),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("2020"));
- // Simple Field (spindleId)
- writeSimpleField(
+ // Optional Field (spindleId) (Can be skipped, if the value is null)
+ writeOptionalField(
"spindleId",
spindleId,
writeUnsignedInt(writeBuffer, 16),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("2020"));
- // Simple Field (sequenceNumber)
- writeSimpleField(
+ // Optional Field (sequenceNumber) (Can be skipped, if the value is null)
+ writeOptionalField(
"sequenceNumber",
sequenceNumber,
writeUnsignedInt(writeBuffer, 16),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("2020"));
- // Simple Field (numberOfMessageParts)
- writeSimpleField(
+ // Optional Field (numberOfMessageParts) (Can be skipped, if the value is null)
+ writeOptionalField(
"numberOfMessageParts",
numberOfMessageParts,
writeUnsignedShort(writeBuffer, 8),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("20"));
- // Simple Field (messagePartNumber)
- writeSimpleField(
+ // Optional Field (messagePartNumber) (Can be skipped, if the value is null)
+ writeOptionalField(
"messagePartNumber",
messagePartNumber,
writeUnsignedShort(writeBuffer, 8),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("20"));
// Switch field (Serialize the sub-type)
serializeOpenProtocolMessageChild(writeBuffer);
@@ -195,25 +214,25 @@ public abstract class OpenProtocolMessage implements Message {
// Discriminator Field (mid)
lengthInBits += 32;
- // Simple field (revision)
+ // Optional Field (selectedRevision)
lengthInBits += 24;
- // Simple field (noAckFlag)
+ // Optional Field (noAckFlag)
lengthInBits += 8;
- // Simple field (stationId)
+ // Optional Field (stationId)
lengthInBits += 16;
- // Simple field (spindleId)
+ // Optional Field (spindleId)
lengthInBits += 16;
- // Simple field (sequenceNumber)
+ // Optional Field (sequenceNumber)
lengthInBits += 16;
- // Simple field (numberOfMessageParts)
+ // Optional Field (numberOfMessageParts)
lengthInBits += 8;
- // Simple field (messagePartNumber)
+ // Optional Field (messagePartNumber)
lengthInBits += 8;
// Length of sub-type elements will be added by sub-type...
@@ -227,10 +246,26 @@ public abstract class OpenProtocolMessage implements Message {
public static OpenProtocolMessage staticParse(ReadBuffer readBuffer, Object... args)
throws ParseException {
PositionAware positionAware = readBuffer;
- return staticParse(readBuffer);
+ if ((args == null) || (args.length != 1)) {
+ throw new PlcRuntimeException(
+ "Wrong number of arguments, expected 1, but got " + args.length);
+ }
+ OpenProtocolRevision connectionRevision;
+ if (args[0] instanceof OpenProtocolRevision) {
+ connectionRevision = (OpenProtocolRevision) args[0];
+ } else if (args[0] instanceof String) {
+ connectionRevision = OpenProtocolRevision.valueOf((String) args[0]);
+ } else {
+ throw new PlcRuntimeException(
+ "Argument 0 expected to be of type OpenProtocolRevision or a string which is parseable"
+ + " but was "
+ + args[0].getClass().getName());
+ }
+ return staticParse(readBuffer, connectionRevision);
}
- public static OpenProtocolMessage staticParse(ReadBuffer readBuffer) throws ParseException {
+ public static OpenProtocolMessage staticParse(
+ ReadBuffer readBuffer, OpenProtocolRevision connectionRevision) throws ParseException {
readBuffer.pullContext("OpenProtocolMessage");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
@@ -238,64 +273,90 @@ public abstract class OpenProtocolMessage implements Message {
long length =
readImplicitField(
- "length", readUnsignedLong(readBuffer, 32), WithOption.WithEncoding("AsciiUint"));
+ "length", readUnsignedLong(readBuffer, 32), WithOption.WithEncoding("ASCII"));
Mid mid =
readDiscriminatorField(
"mid",
- new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)));
+ new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
- OpenProtocolRevision revision =
- readEnumField(
- "revision",
- "OpenProtocolRevision",
+ OpenProtocolRevision selectedRevision =
+ readOptionalField(
+ "selectedRevision",
new DataReaderEnumDefault<>(
- OpenProtocolRevision::enumForValue, readUnsignedLong(readBuffer, 24)));
+ OpenProtocolRevision::enumForValue, readUnsignedLong(readBuffer, 24)),
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("202020"));
- short noAckFlag = readSimpleField("noAckFlag", readUnsignedShort(readBuffer, 8));
+ Short noAckFlag =
+ readOptionalField(
+ "noAckFlag",
+ readUnsignedShort(readBuffer, 8),
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("20"));
- int stationId =
- readSimpleField(
- "stationId", readUnsignedInt(readBuffer, 16), WithOption.WithEncoding("AsciiUint"));
+ Integer stationId =
+ readOptionalField(
+ "stationId",
+ readUnsignedInt(readBuffer, 16),
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("2020"));
- int spindleId =
- readSimpleField(
- "spindleId", readUnsignedInt(readBuffer, 16), WithOption.WithEncoding("AsciiUint"));
+ Integer spindleId =
+ readOptionalField(
+ "spindleId",
+ readUnsignedInt(readBuffer, 16),
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("2020"));
- int sequenceNumber =
- readSimpleField(
+ Integer sequenceNumber =
+ readOptionalField(
"sequenceNumber",
readUnsignedInt(readBuffer, 16),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("2020"));
- short numberOfMessageParts =
- readSimpleField(
+ Short numberOfMessageParts =
+ readOptionalField(
"numberOfMessageParts",
readUnsignedShort(readBuffer, 8),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("20"));
- short messagePartNumber =
- readSimpleField(
+ Short messagePartNumber =
+ readOptionalField(
"messagePartNumber",
readUnsignedShort(readBuffer, 8),
- WithOption.WithEncoding("AsciiUint"));
+ WithOption.WithEncoding("ASCII"),
+ WithOption.WithNullBytesHex("20"));
// Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type)
OpenProtocolMessageBuilder builder = null;
if (EvaluationHelper.equals(mid, Mid.ApplicationCommunicationStart)) {
- builder = OpenProtocolMessageApplicationCommunicationStart.staticParseBuilder(readBuffer);
+ builder =
+ OpenProtocolMessageApplicationCommunicationStart.staticParseBuilder(
+ readBuffer, connectionRevision);
} else if (EvaluationHelper.equals(mid, Mid.ApplicationCommunicationStartAcknowledge)) {
builder =
OpenProtocolMessageApplicationCommunicationStartAcknowledge.staticParseBuilder(
- readBuffer, revision);
+ readBuffer, connectionRevision);
} else if (EvaluationHelper.equals(mid, Mid.ApplicationCommunicationStop)) {
- builder = OpenProtocolMessageApplicationCommunicationStop.staticParseBuilder(readBuffer);
+ builder =
+ OpenProtocolMessageApplicationCommunicationStop.staticParseBuilder(
+ readBuffer, connectionRevision);
} else if (EvaluationHelper.equals(mid, Mid.ApplicationCommandError)) {
- builder = OpenProtocolMessageApplicationCommandError.staticParseBuilder(readBuffer);
+ builder =
+ OpenProtocolMessageApplicationCommandError.staticParseBuilder(
+ readBuffer, connectionRevision);
} else if (EvaluationHelper.equals(mid, Mid.ApplicationCommandAccepted)) {
- builder = OpenProtocolMessageApplicationCommandAccepted.staticParseBuilder(readBuffer);
+ builder =
+ OpenProtocolMessageApplicationCommandAccepted.staticParseBuilder(
+ readBuffer, connectionRevision);
} else if (EvaluationHelper.equals(mid, Mid.ApplicationGenericDataRequest)) {
- builder = OpenProtocolMessageApplicationGenericDataRequest.staticParseBuilder(readBuffer);
+ builder =
+ OpenProtocolMessageApplicationGenericDataRequest.staticParseBuilder(
+ readBuffer, connectionRevision);
}
if (builder == null) {
throw new ParseException(
@@ -308,25 +369,27 @@ public abstract class OpenProtocolMessage implements Message {
// Create the instance
OpenProtocolMessage _openProtocolMessage =
builder.build(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
return _openProtocolMessage;
}
public static interface OpenProtocolMessageBuilder {
OpenProtocolMessage build(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber);
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision);
}
@Override
@@ -338,7 +401,7 @@ public abstract class OpenProtocolMessage implements Message {
return false;
}
OpenProtocolMessage that = (OpenProtocolMessage) o;
- return (getRevision() == that.getRevision())
+ return (getSelectedRevision() == that.getSelectedRevision())
&& (getNoAckFlag() == that.getNoAckFlag())
&& (getStationId() == that.getStationId())
&& (getSpindleId() == that.getSpindleId())
@@ -351,7 +414,7 @@ public abstract class OpenProtocolMessage implements Message {
@Override
public int hashCode() {
return Objects.hash(
- getRevision(),
+ getSelectedRevision(),
getNoAckFlag(),
getStationId(),
getSpindleId(),
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandAccepted.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandAccepted.java
index ded7fd7e39..58bcb47cae 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandAccepted.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandAccepted.java
@@ -46,24 +46,30 @@ public class OpenProtocolMessageApplicationCommandAccepted extends OpenProtocolM
// Properties.
protected final Mid requestMid;
+ // Arguments.
+ protected final OpenProtocolRevision connectionRevision;
+
public OpenProtocolMessageApplicationCommandAccepted(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber,
- Mid requestMid) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ Mid requestMid,
+ OpenProtocolRevision connectionRevision) {
super(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
this.requestMid = requestMid;
+ this.connectionRevision = connectionRevision;
}
public Mid getRequestMid() {
@@ -82,7 +88,8 @@ public class OpenProtocolMessageApplicationCommandAccepted extends OpenProtocolM
"requestMid",
"Mid",
requestMid,
- new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)));
+ new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
writeBuffer.popContext("OpenProtocolMessageApplicationCommandAccepted");
}
@@ -104,7 +111,7 @@ public class OpenProtocolMessageApplicationCommandAccepted extends OpenProtocolM
}
public static OpenProtocolMessageApplicationCommandAcceptedBuilder staticParseBuilder(
- ReadBuffer readBuffer) throws ParseException {
+ ReadBuffer readBuffer, OpenProtocolRevision connectionRevision) throws ParseException {
readBuffer.pullContext("OpenProtocolMessageApplicationCommandAccepted");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
@@ -114,40 +121,46 @@ public class OpenProtocolMessageApplicationCommandAccepted extends OpenProtocolM
readEnumField(
"requestMid",
"Mid",
- new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)));
+ new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
readBuffer.closeContext("OpenProtocolMessageApplicationCommandAccepted");
// Create the instance
- return new OpenProtocolMessageApplicationCommandAcceptedBuilder(requestMid);
+ return new OpenProtocolMessageApplicationCommandAcceptedBuilder(requestMid, connectionRevision);
}
public static class OpenProtocolMessageApplicationCommandAcceptedBuilder
implements OpenProtocolMessage.OpenProtocolMessageBuilder {
private final Mid requestMid;
+ private final OpenProtocolRevision connectionRevision;
- public OpenProtocolMessageApplicationCommandAcceptedBuilder(Mid requestMid) {
+ public OpenProtocolMessageApplicationCommandAcceptedBuilder(
+ Mid requestMid, OpenProtocolRevision connectionRevision) {
this.requestMid = requestMid;
+ this.connectionRevision = connectionRevision;
}
public OpenProtocolMessageApplicationCommandAccepted build(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
OpenProtocolMessageApplicationCommandAccepted openProtocolMessageApplicationCommandAccepted =
new OpenProtocolMessageApplicationCommandAccepted(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
messagePartNumber,
- requestMid);
+ requestMid,
+ connectionRevision);
return openProtocolMessageApplicationCommandAccepted;
}
}
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandError.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandError.java
index 8ca76c10a5..0450c4909e 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandError.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommandError.java
@@ -47,26 +47,32 @@ public class OpenProtocolMessageApplicationCommandError extends OpenProtocolMess
protected final Mid requestMid;
protected final Error error;
+ // Arguments.
+ protected final OpenProtocolRevision connectionRevision;
+
public OpenProtocolMessageApplicationCommandError(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber,
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
Mid requestMid,
- Error error) {
+ Error error,
+ OpenProtocolRevision connectionRevision) {
super(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
this.requestMid = requestMid;
this.error = error;
+ this.connectionRevision = connectionRevision;
}
public Mid getRequestMid() {
@@ -89,7 +95,8 @@ public class OpenProtocolMessageApplicationCommandError extends OpenProtocolMess
"requestMid",
"Mid",
requestMid,
- new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)));
+ new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
// Simple Field (error)
writeSimpleEnumField(
@@ -97,7 +104,8 @@ public class OpenProtocolMessageApplicationCommandError extends OpenProtocolMess
"Error",
error,
new DataWriterEnumDefault<>(
- Error::getValue, Error::name, writeUnsignedInt(writeBuffer, 16)));
+ Error::getValue, Error::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithEncoding("ASCII"));
writeBuffer.popContext("OpenProtocolMessageApplicationCommandError");
}
@@ -122,7 +130,7 @@ public class OpenProtocolMessageApplicationCommandError extends OpenProtocolMess
}
public static OpenProtocolMessageApplicationCommandErrorBuilder staticParseBuilder(
- ReadBuffer readBuffer) throws ParseException {
+ ReadBuffer readBuffer, OpenProtocolRevision connectionRevision) throws ParseException {
readBuffer.pullContext("OpenProtocolMessageApplicationCommandError");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
@@ -132,41 +140,48 @@ public class OpenProtocolMessageApplicationCommandError extends OpenProtocolMess
readEnumField(
"requestMid",
"Mid",
- new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)));
+ new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
Error error =
readEnumField(
"error",
"Error",
- new DataReaderEnumDefault<>(Error::enumForValue, readUnsignedInt(readBuffer, 16)));
+ new DataReaderEnumDefault<>(Error::enumForValue, readUnsignedInt(readBuffer, 16)),
+ WithOption.WithEncoding("ASCII"));
readBuffer.closeContext("OpenProtocolMessageApplicationCommandError");
// Create the instance
- return new OpenProtocolMessageApplicationCommandErrorBuilder(requestMid, error);
+ return new OpenProtocolMessageApplicationCommandErrorBuilder(
+ requestMid, error, connectionRevision);
}
public static class OpenProtocolMessageApplicationCommandErrorBuilder
implements OpenProtocolMessage.OpenProtocolMessageBuilder {
private final Mid requestMid;
private final Error error;
+ private final OpenProtocolRevision connectionRevision;
- public OpenProtocolMessageApplicationCommandErrorBuilder(Mid requestMid, Error error) {
+ public OpenProtocolMessageApplicationCommandErrorBuilder(
+ Mid requestMid, Error error, OpenProtocolRevision connectionRevision) {
this.requestMid = requestMid;
this.error = error;
+ this.connectionRevision = connectionRevision;
}
public OpenProtocolMessageApplicationCommandError build(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
OpenProtocolMessageApplicationCommandError openProtocolMessageApplicationCommandError =
new OpenProtocolMessageApplicationCommandError(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
@@ -174,7 +189,8 @@ public class OpenProtocolMessageApplicationCommandError extends OpenProtocolMess
numberOfMessageParts,
messagePartNumber,
requestMid,
- error);
+ error,
+ connectionRevision);
return openProtocolMessageApplicationCommandError;
}
}
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStart.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStart.java
index 4cb9c89ba1..a8d1690a1b 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStart.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStart.java
@@ -43,22 +43,28 @@ public class OpenProtocolMessageApplicationCommunicationStart extends OpenProtoc
return Mid.ApplicationCommunicationStart;
}
+ // Arguments.
+ protected final OpenProtocolRevision connectionRevision;
+
public OpenProtocolMessageApplicationCommunicationStart(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
super(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
+ this.connectionRevision = connectionRevision;
}
@Override
@@ -85,7 +91,7 @@ public class OpenProtocolMessageApplicationCommunicationStart extends OpenProtoc
}
public static OpenProtocolMessageApplicationCommunicationStartBuilder staticParseBuilder(
- ReadBuffer readBuffer) throws ParseException {
+ ReadBuffer readBuffer, OpenProtocolRevision connectionRevision) throws ParseException {
readBuffer.pullContext("OpenProtocolMessageApplicationCommunicationStart");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
@@ -93,32 +99,39 @@ public class OpenProtocolMessageApplicationCommunicationStart extends OpenProtoc
readBuffer.closeContext("OpenProtocolMessageApplicationCommunicationStart");
// Create the instance
- return new OpenProtocolMessageApplicationCommunicationStartBuilder();
+ return new OpenProtocolMessageApplicationCommunicationStartBuilder(connectionRevision);
}
public static class OpenProtocolMessageApplicationCommunicationStartBuilder
implements OpenProtocolMessage.OpenProtocolMessageBuilder {
+ private final OpenProtocolRevision connectionRevision;
+
+ public OpenProtocolMessageApplicationCommunicationStartBuilder(
+ OpenProtocolRevision connectionRevision) {
- public OpenProtocolMessageApplicationCommunicationStartBuilder() {}
+ this.connectionRevision = connectionRevision;
+ }
public OpenProtocolMessageApplicationCommunicationStart build(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
OpenProtocolMessageApplicationCommunicationStart
openProtocolMessageApplicationCommunicationStart =
new OpenProtocolMessageApplicationCommunicationStart(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
return openProtocolMessageApplicationCommunicationStart;
}
}
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStartAcknowledge.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStartAcknowledge.java
index bc8bfdd7ca..5313729600 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStartAcknowledge.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStartAcknowledge.java
@@ -46,24 +46,30 @@ public class OpenProtocolMessageApplicationCommunicationStartAcknowledge extends
// Properties.
protected final List<ApplicationCommunicationStartAcknowledgeBlock> blocks;
+ // Arguments.
+ protected final OpenProtocolRevision connectionRevision;
+
public OpenProtocolMessageApplicationCommunicationStartAcknowledge(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber,
- List<ApplicationCommunicationStartAcknowledgeBlock> blocks) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ List<ApplicationCommunicationStartAcknowledgeBlock> blocks,
+ OpenProtocolRevision connectionRevision) {
super(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
this.blocks = blocks;
+ this.connectionRevision = connectionRevision;
}
public List<ApplicationCommunicationStartAcknowledgeBlock> getBlocks() {
@@ -106,7 +112,7 @@ public class OpenProtocolMessageApplicationCommunicationStartAcknowledge extends
}
public static OpenProtocolMessageApplicationCommunicationStartAcknowledgeBuilder
- staticParseBuilder(ReadBuffer readBuffer, OpenProtocolRevision revision)
+ staticParseBuilder(ReadBuffer readBuffer, OpenProtocolRevision connectionRevision)
throws ParseException {
readBuffer.pullContext("OpenProtocolMessageApplicationCommunicationStartAcknowledge");
PositionAware positionAware = readBuffer;
@@ -119,42 +125,48 @@ public class OpenProtocolMessageApplicationCommunicationStartAcknowledge extends
new DataReaderComplexDefault<>(
() -> ApplicationCommunicationStartAcknowledgeBlock.staticParse(readBuffer),
readBuffer),
- revision.getNumCommunicationStartAcknowledgeBlocks());
+ connectionRevision.getNumCommunicationStartAcknowledgeBlocks());
readBuffer.closeContext("OpenProtocolMessageApplicationCommunicationStartAcknowledge");
// Create the instance
- return new OpenProtocolMessageApplicationCommunicationStartAcknowledgeBuilder(blocks);
+ return new OpenProtocolMessageApplicationCommunicationStartAcknowledgeBuilder(
+ blocks, connectionRevision);
}
public static class OpenProtocolMessageApplicationCommunicationStartAcknowledgeBuilder
implements OpenProtocolMessage.OpenProtocolMessageBuilder {
private final List<ApplicationCommunicationStartAcknowledgeBlock> blocks;
+ private final OpenProtocolRevision connectionRevision;
public OpenProtocolMessageApplicationCommunicationStartAcknowledgeBuilder(
- List<ApplicationCommunicationStartAcknowledgeBlock> blocks) {
+ List<ApplicationCommunicationStartAcknowledgeBlock> blocks,
+ OpenProtocolRevision connectionRevision) {
this.blocks = blocks;
+ this.connectionRevision = connectionRevision;
}
public OpenProtocolMessageApplicationCommunicationStartAcknowledge build(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
OpenProtocolMessageApplicationCommunicationStartAcknowledge
openProtocolMessageApplicationCommunicationStartAcknowledge =
new OpenProtocolMessageApplicationCommunicationStartAcknowledge(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
messagePartNumber,
- blocks);
+ blocks,
+ connectionRevision);
return openProtocolMessageApplicationCommunicationStartAcknowledge;
}
}
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStop.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStop.java
index 83ca7ec577..9abf60a9b1 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStop.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationCommunicationStop.java
@@ -43,22 +43,28 @@ public class OpenProtocolMessageApplicationCommunicationStop extends OpenProtoco
return Mid.ApplicationCommunicationStop;
}
+ // Arguments.
+ protected final OpenProtocolRevision connectionRevision;
+
public OpenProtocolMessageApplicationCommunicationStop(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
super(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
+ this.connectionRevision = connectionRevision;
}
@Override
@@ -85,7 +91,7 @@ public class OpenProtocolMessageApplicationCommunicationStop extends OpenProtoco
}
public static OpenProtocolMessageApplicationCommunicationStopBuilder staticParseBuilder(
- ReadBuffer readBuffer) throws ParseException {
+ ReadBuffer readBuffer, OpenProtocolRevision connectionRevision) throws ParseException {
readBuffer.pullContext("OpenProtocolMessageApplicationCommunicationStop");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
@@ -93,32 +99,39 @@ public class OpenProtocolMessageApplicationCommunicationStop extends OpenProtoco
readBuffer.closeContext("OpenProtocolMessageApplicationCommunicationStop");
// Create the instance
- return new OpenProtocolMessageApplicationCommunicationStopBuilder();
+ return new OpenProtocolMessageApplicationCommunicationStopBuilder(connectionRevision);
}
public static class OpenProtocolMessageApplicationCommunicationStopBuilder
implements OpenProtocolMessage.OpenProtocolMessageBuilder {
+ private final OpenProtocolRevision connectionRevision;
+
+ public OpenProtocolMessageApplicationCommunicationStopBuilder(
+ OpenProtocolRevision connectionRevision) {
- public OpenProtocolMessageApplicationCommunicationStopBuilder() {}
+ this.connectionRevision = connectionRevision;
+ }
public OpenProtocolMessageApplicationCommunicationStop build(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
OpenProtocolMessageApplicationCommunicationStop
openProtocolMessageApplicationCommunicationStop =
new OpenProtocolMessageApplicationCommunicationStop(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
return openProtocolMessageApplicationCommunicationStop;
}
}
diff --git a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationGenericDataRequest.java b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationGenericDataRequest.java
index 5381c55931..2d748efa0c 100644
--- a/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationGenericDataRequest.java
+++ b/plc4j/drivers/open-protocol/src/main/generated/org/apache/plc4x/java/openprotocol/readwrite/OpenProtocolMessageApplicationGenericDataRequest.java
@@ -45,39 +45,45 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
// Properties.
protected final Mid requestMid;
- protected final OpenProtocolRevision wantedRevision;
+ protected final OpenProtocolRevision revision;
protected final byte[] extraData;
+ // Arguments.
+ protected final OpenProtocolRevision connectionRevision;
+
public OpenProtocolMessageApplicationGenericDataRequest(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber,
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
Mid requestMid,
- OpenProtocolRevision wantedRevision,
- byte[] extraData) {
+ OpenProtocolRevision revision,
+ byte[] extraData,
+ OpenProtocolRevision connectionRevision) {
super(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
sequenceNumber,
numberOfMessageParts,
- messagePartNumber);
+ messagePartNumber,
+ connectionRevision);
this.requestMid = requestMid;
- this.wantedRevision = wantedRevision;
+ this.revision = revision;
this.extraData = extraData;
+ this.connectionRevision = connectionRevision;
}
public Mid getRequestMid() {
return requestMid;
}
- public OpenProtocolRevision getWantedRevision() {
- return wantedRevision;
+ public OpenProtocolRevision getRevision() {
+ return revision;
}
public byte[] getExtraData() {
@@ -96,22 +102,28 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
"requestMid",
"Mid",
requestMid,
- new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)));
+ new DataWriterEnumDefault<>(Mid::getValue, Mid::name, writeUnsignedLong(writeBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
- // Simple Field (wantedRevision)
+ // Simple Field (revision)
writeSimpleEnumField(
- "wantedRevision",
+ "revision",
"OpenProtocolRevision",
- wantedRevision,
+ revision,
new DataWriterEnumDefault<>(
OpenProtocolRevision::getValue,
OpenProtocolRevision::name,
- writeUnsignedLong(writeBuffer, 24)));
+ writeUnsignedLong(writeBuffer, 24)),
+ WithOption.WithEncoding("ASCII"));
// Implicit Field (extraDataLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int extraDataLength = (int) (COUNT(getExtraData()));
- writeImplicitField("extraDataLength", extraDataLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "extraDataLength",
+ extraDataLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithEncoding("ASCII"));
// Array Field (extraData)
writeByteArrayField("extraData", extraData, writeByteArray(writeBuffer, 8));
@@ -132,7 +144,7 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
// Simple field (requestMid)
lengthInBits += 32;
- // Simple field (wantedRevision)
+ // Simple field (revision)
lengthInBits += 24;
// Implicit Field (extraDataLength)
@@ -147,7 +159,7 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
}
public static OpenProtocolMessageApplicationGenericDataRequestBuilder staticParseBuilder(
- ReadBuffer readBuffer) throws ParseException {
+ ReadBuffer readBuffer, OpenProtocolRevision connectionRevision) throws ParseException {
readBuffer.pullContext("OpenProtocolMessageApplicationGenericDataRequest");
PositionAware positionAware = readBuffer;
int startPos = positionAware.getPos();
@@ -157,51 +169,61 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
readEnumField(
"requestMid",
"Mid",
- new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)));
+ new DataReaderEnumDefault<>(Mid::enumForValue, readUnsignedLong(readBuffer, 32)),
+ WithOption.WithEncoding("ASCII"));
- OpenProtocolRevision wantedRevision =
+ OpenProtocolRevision revision =
readEnumField(
- "wantedRevision",
+ "revision",
"OpenProtocolRevision",
new DataReaderEnumDefault<>(
- OpenProtocolRevision::enumForValue, readUnsignedLong(readBuffer, 24)));
+ OpenProtocolRevision::enumForValue, readUnsignedLong(readBuffer, 24)),
+ WithOption.WithEncoding("ASCII"));
- int extraDataLength = readImplicitField("extraDataLength", readUnsignedInt(readBuffer, 16));
+ int extraDataLength =
+ readImplicitField(
+ "extraDataLength", readUnsignedInt(readBuffer, 16), WithOption.WithEncoding("ASCII"));
byte[] extraData = readBuffer.readByteArray("extraData", Math.toIntExact(extraDataLength));
readBuffer.closeContext("OpenProtocolMessageApplicationGenericDataRequest");
// Create the instance
return new OpenProtocolMessageApplicationGenericDataRequestBuilder(
- requestMid, wantedRevision, extraData);
+ requestMid, revision, extraData, connectionRevision);
}
public static class OpenProtocolMessageApplicationGenericDataRequestBuilder
implements OpenProtocolMessage.OpenProtocolMessageBuilder {
private final Mid requestMid;
- private final OpenProtocolRevision wantedRevision;
+ private final OpenProtocolRevision revision;
private final byte[] extraData;
+ private final OpenProtocolRevision connectionRevision;
public OpenProtocolMessageApplicationGenericDataRequestBuilder(
- Mid requestMid, OpenProtocolRevision wantedRevision, byte[] extraData) {
+ Mid requestMid,
+ OpenProtocolRevision revision,
+ byte[] extraData,
+ OpenProtocolRevision connectionRevision) {
this.requestMid = requestMid;
- this.wantedRevision = wantedRevision;
+ this.revision = revision;
this.extraData = extraData;
+ this.connectionRevision = connectionRevision;
}
public OpenProtocolMessageApplicationGenericDataRequest build(
- OpenProtocolRevision revision,
- short noAckFlag,
- int stationId,
- int spindleId,
- int sequenceNumber,
- short numberOfMessageParts,
- short messagePartNumber) {
+ OpenProtocolRevision selectedRevision,
+ Short noAckFlag,
+ Integer stationId,
+ Integer spindleId,
+ Integer sequenceNumber,
+ Short numberOfMessageParts,
+ Short messagePartNumber,
+ OpenProtocolRevision connectionRevision) {
OpenProtocolMessageApplicationGenericDataRequest
openProtocolMessageApplicationGenericDataRequest =
new OpenProtocolMessageApplicationGenericDataRequest(
- revision,
+ selectedRevision,
noAckFlag,
stationId,
spindleId,
@@ -209,8 +231,9 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
numberOfMessageParts,
messagePartNumber,
requestMid,
- wantedRevision,
- extraData);
+ revision,
+ extraData,
+ connectionRevision);
return openProtocolMessageApplicationGenericDataRequest;
}
}
@@ -226,7 +249,7 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
OpenProtocolMessageApplicationGenericDataRequest that =
(OpenProtocolMessageApplicationGenericDataRequest) o;
return (getRequestMid() == that.getRequestMid())
- && (getWantedRevision() == that.getWantedRevision())
+ && (getRevision() == that.getRevision())
&& (getExtraData() == that.getExtraData())
&& super.equals(that)
&& true;
@@ -234,7 +257,7 @@ public class OpenProtocolMessageApplicationGenericDataRequest extends OpenProtoc
@Override
public int hashCode() {
- return Objects.hash(super.hashCode(), getRequestMid(), getWantedRevision(), getExtraData());
+ return Objects.hash(super.hashCode(), getRequestMid(), getRevision(), getExtraData());
}
@Override
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriter.java b/plc4j/drivers/open-protocol/src/test/java/org/apache/plc4x/java/openprotocol/OpenProtocolParserSerializerTest.java
similarity index 62%
copy from plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriter.java
copy to plc4j/drivers/open-protocol/src/test/java/org/apache/plc4x/java/openprotocol/OpenProtocolParserSerializerTest.java
index 40d6e89324..65f847a914 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriter.java
+++ b/plc4j/drivers/open-protocol/src/test/java/org/apache/plc4x/java/openprotocol/OpenProtocolParserSerializerTest.java
@@ -16,16 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.plc4x.java.spi.codegen.io;
+package org.apache.plc4x.java.openprotocol;
-import org.apache.plc4x.java.spi.generation.SerializationException;
-import org.apache.plc4x.java.spi.generation.WithWriterArgs;
+import org.apache.plc4x.test.parserserializer.ParserSerializerTestsuiteRunner;
-public interface DataWriter<T> extends ByteOrderAware {
+public class OpenProtocolParserSerializerTest extends ParserSerializerTestsuiteRunner {
- void write(String logicalName, T value, WithWriterArgs... writerArgs) throws SerializationException;
-
- void pushContext(String logicalName, WithWriterArgs... writerArgs);
- void popContext(String logicalName, WithWriterArgs... writerArgs);
+ public OpenProtocolParserSerializerTest() {
+ super("/protocols/openprotocol/ParserSerializerTestsuite.xml");
+ }
}
diff --git a/protocols/open-protocol/pom.xml b/plc4j/drivers/open-protocol/src/test/resources/logback-test.xml
similarity index 50%
copy from protocols/open-protocol/pom.xml
copy to plc4j/drivers/open-protocol/src/test/resources/logback-test.xml
index 6ba8760a00..8c25492b16 100644
--- a/protocols/open-protocol/pom.xml
+++ b/plc4j/drivers/open-protocol/src/test/resources/logback-test.xml
@@ -17,27 +17,20 @@
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-protocols</artifactId>
- <version>0.11.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4x-protocols-open-protocol</artifactId>
-
- <name>Protocols: Open-Protocol</name>
- <description>Protocol specifications for the Atlas Copco: Open Protocol protocol</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-code-generation-protocol-base-mspec</artifactId>
- <version>0.11.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
+<configuration xmlns="http://ch.qos.logback/xml/ns/logback"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://ch.qos.logback/xml/ns/logback
+ https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java
index b82eeafa4d..ac206a32d1 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java
@@ -64,7 +64,10 @@ public class Plc4xConnectRequest extends Plc4xMessage implements Message {
// implicitly given by the objects content)
short connectionStringLen = (short) (STR_LEN(getConnectionString()));
writeImplicitField(
- "connectionStringLen", connectionStringLen, writeUnsignedShort(writeBuffer, 8));
+ "connectionStringLen",
+ connectionStringLen,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (connectionString)
writeSimpleField(
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java
index 32341a22c4..37917e9bbb 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java
@@ -81,7 +81,8 @@ public class Plc4xConnectResponse extends Plc4xMessage implements Message {
new DataWriterEnumDefault<>(
Plc4xResponseCode::getValue,
Plc4xResponseCode::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xConnectResponse");
}
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java
index 010af57d63..e3d1814fd6 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java
@@ -68,12 +68,20 @@ public abstract class Plc4xMessage implements Message {
writeBuffer.pushContext("Plc4xMessage");
// Const Field (version)
- writeConstField("version", VERSION, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "version",
+ VERSION,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (packetLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int packetLength = (int) (getLengthInBytes());
- writeImplicitField("packetLength", packetLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "packetLength",
+ packetLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (requestId)
writeSimpleField(
@@ -88,9 +96,8 @@ public abstract class Plc4xMessage implements Message {
"Plc4xRequestType",
getRequestType(),
new DataWriterEnumDefault<>(
- Plc4xRequestType::getValue,
- Plc4xRequestType::name,
- writeUnsignedShort(writeBuffer, 8)));
+ Plc4xRequestType::getValue, Plc4xRequestType::name, writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Switch field (Serialize the sub-type)
serializePlc4xMessageChild(writeBuffer);
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java
index 443aa5a648..d187cc2306 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java
@@ -76,10 +76,15 @@ public class Plc4xReadRequest extends Plc4xMessage implements Message {
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xReadRequest");
}
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java
index 2450c624c0..102969aaa2 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java
@@ -91,15 +91,21 @@ public class Plc4xReadResponse extends Plc4xMessage implements Message {
new DataWriterEnumDefault<>(
Plc4xResponseCode::getValue,
Plc4xResponseCode::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xReadResponse");
}
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java
index ddbf9c4849..6d856ea448 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -148,14 +149,14 @@ public class Plc4xValue {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8");
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.WCHAR)) { // STRING
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16");
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.TIME)) { // TIME
@@ -316,12 +317,14 @@ public class Plc4xValue {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.WCHAR)) { // STRING
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.TIME)) { // TIME
// Simple Field (milliseconds)
long milliseconds = (long) _value.getLong();
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java
index ad2f647deb..33354b88fd 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java
@@ -76,10 +76,15 @@ public class Plc4xWriteRequest extends Plc4xMessage implements Message {
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xWriteRequest");
}
diff --git a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java
index 1b02f9fac4..4e52abc1b8 100644
--- a/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java
+++ b/plc4j/drivers/plc4x/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java
@@ -91,15 +91,21 @@ public class Plc4xWriteResponse extends Plc4xMessage implements Message {
new DataWriterEnumDefault<>(
Plc4xResponseCode::getValue,
Plc4xResponseCode::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xWriteResponse");
}
diff --git a/plc4j/drivers/plc4x/src/main/java/org/apache/plc4x/java/plc4x/tag/Plc4xTag.java b/plc4j/drivers/plc4x/src/main/java/org/apache/plc4x/java/plc4x/tag/Plc4xTag.java
index b6c40790ea..c3d5aa7fdd 100644
--- a/plc4j/drivers/plc4x/src/main/java/org/apache/plc4x/java/plc4x/tag/Plc4xTag.java
+++ b/plc4j/drivers/plc4x/src/main/java/org/apache/plc4x/java/plc4x/tag/Plc4xTag.java
@@ -21,10 +21,12 @@ package org.apache.plc4x.java.plc4x.tag;
import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.utils.Serializable;
+import java.nio.charset.StandardCharsets;
import java.util.List;
public class Plc4xTag implements PlcTag, Serializable {
@@ -57,7 +59,9 @@ public class Plc4xTag implements PlcTag, Serializable {
writeBuffer.pushContext(getClass().getSimpleName());
writeBuffer.writeUnsignedInt("addressLength", 16, address.length());
- writeBuffer.writeString("address",address.length() * 8, "UTF-8", address);
+ writeBuffer.writeString("address",
+ address.length() * 8,
+ address, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_InterfaceUuid.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_InterfaceUuid.java
index 139666f8ce..45becf041b 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_InterfaceUuid.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_InterfaceUuid.java
@@ -95,16 +95,32 @@ public abstract class DceRpc_InterfaceUuid implements Message {
writeConstField("data2", DATA2, writeUnsignedInt(writeBuffer, 16));
// Const Field (data3)
- writeConstField("data3", DATA3, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "data3",
+ DATA3,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (data4)
- writeConstField("data4", DATA4, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "data4",
+ DATA4,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (data5)
- writeConstField("data5", DATA5, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "data5",
+ DATA5,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (data6)
- writeConstField("data6", DATA6, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "data6",
+ DATA6,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Switch field (Serialize the sub-type)
serializeDceRpc_InterfaceUuidChild(writeBuffer);
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_ObjectUuid.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_ObjectUuid.java
index f1739bf31e..0b9f9af9c0 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_ObjectUuid.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_ObjectUuid.java
@@ -104,7 +104,11 @@ public class DceRpc_ObjectUuid implements Message {
writeConstField("data3", DATA3, writeUnsignedInt(writeBuffer, 16));
// Const Field (data4)
- writeConstField("data4", DATA4, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "data4",
+ DATA4,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (interfaceNumber)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_Packet.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_Packet.java
index 224b6c3ffd..2f41431aec 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_Packet.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/DceRpc_Packet.java
@@ -215,7 +215,11 @@ public class DceRpc_Packet implements Message {
writeBuffer.pushContext("DceRpc_Packet");
// Const Field (version)
- writeConstField("version", VERSION, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "version",
+ VERSION,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (packetType)
writeSimpleEnumField(
@@ -225,16 +229,22 @@ public class DceRpc_Packet implements Message {
new DataWriterEnumDefault<>(
DceRpc_PacketType::getValue,
DceRpc_PacketType::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (boolean) false,
- writeBoolean(writeBuffer));
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (broadcast)
- writeConstField("broadcast", BROADCAST, writeBoolean(writeBuffer));
+ writeConstField(
+ "broadcast",
+ BROADCAST,
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (idempotent)
writeSimpleField(
@@ -244,7 +254,8 @@ public class DceRpc_Packet implements Message {
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (maybe)
- writeConstField("maybe", MAYBE, writeBoolean(writeBuffer));
+ writeConstField(
+ "maybe", MAYBE, writeBoolean(writeBuffer), WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (noFragmentAcknowledgeRequested)
writeSimpleField(
@@ -254,7 +265,11 @@ public class DceRpc_Packet implements Message {
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (fragment)
- writeConstField("fragment", FRAGMENT, writeBoolean(writeBuffer));
+ writeConstField(
+ "fragment",
+ FRAGMENT,
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (lastFragment)
writeSimpleField(
@@ -267,22 +282,29 @@ public class DceRpc_Packet implements Message {
writeReservedField(
"reserved",
reservedField1 != null ? reservedField1 : (boolean) false,
- writeBoolean(writeBuffer));
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField2 != null ? reservedField2 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 6));
+ writeUnsignedShort(writeBuffer, 6),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (cancelWasPending)
- writeConstField("cancelWasPending", CANCELWASPENDING, writeBoolean(writeBuffer));
+ writeConstField(
+ "cancelWasPending",
+ CANCELWASPENDING,
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField3 != null ? reservedField3 : (boolean) false,
- writeBoolean(writeBuffer));
+ writeBoolean(writeBuffer),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (integerEncoding)
writeSimpleEnumField(
@@ -290,7 +312,8 @@ public class DceRpc_Packet implements Message {
"IntegerEncoding",
integerEncoding,
new DataWriterEnumDefault<>(
- IntegerEncoding::getValue, IntegerEncoding::name, writeUnsignedByte(writeBuffer, 4)));
+ IntegerEncoding::getValue, IntegerEncoding::name, writeUnsignedByte(writeBuffer, 4)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (characterEncoding)
writeSimpleEnumField(
@@ -300,7 +323,8 @@ public class DceRpc_Packet implements Message {
new DataWriterEnumDefault<>(
CharacterEncoding::getValue,
CharacterEncoding::name,
- writeUnsignedByte(writeBuffer, 4)));
+ writeUnsignedByte(writeBuffer, 4)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (floatingPointEncoding)
writeSimpleEnumField(
@@ -310,16 +334,22 @@ public class DceRpc_Packet implements Message {
new DataWriterEnumDefault<>(
FloatingPointEncoding::getValue,
FloatingPointEncoding::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField4 != null ? reservedField4 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (serialHigh)
- writeConstField("serialHigh", SERIALHIGH, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "serialHigh",
+ SERIALHIGH,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (objectUuid)
writeSimpleField(
@@ -362,7 +392,14 @@ public class DceRpc_Packet implements Message {
: ByteOrder.LITTLE_ENDIAN)));
// Const Field (interfaceVer)
- writeConstField("interfaceVer", INTERFACEVER, writeUnsignedLong(writeBuffer, 32));
+ writeConstField(
+ "interfaceVer",
+ INTERFACEVER,
+ writeUnsignedLong(writeBuffer, 32),
+ WithOption.WithByteOrder(
+ (((integerEncoding) == (IntegerEncoding.BIG_ENDIAN))
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN)));
// Simple Field (sequenceNumber)
writeSimpleField(
@@ -380,27 +417,70 @@ public class DceRpc_Packet implements Message {
"DceRpc_Operation",
operation,
new DataWriterEnumDefault<>(
- DceRpc_Operation::getValue, DceRpc_Operation::name, writeUnsignedInt(writeBuffer, 16)));
+ DceRpc_Operation::getValue, DceRpc_Operation::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(
+ (((integerEncoding) == (IntegerEncoding.BIG_ENDIAN))
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN)));
// Const Field (interfaceHint)
- writeConstField("interfaceHint", INTERFACEHINT, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "interfaceHint",
+ INTERFACEHINT,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(
+ (((integerEncoding) == (IntegerEncoding.BIG_ENDIAN))
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN)));
// Const Field (activityHint)
- writeConstField("activityHint", ACTIVITYHINT, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "activityHint",
+ ACTIVITYHINT,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(
+ (((integerEncoding) == (IntegerEncoding.BIG_ENDIAN))
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN)));
// Implicit Field (lengthOfBody) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int lengthOfBody = (int) (getPayload().getLengthInBytes());
- writeImplicitField("lengthOfBody", lengthOfBody, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "lengthOfBody",
+ lengthOfBody,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(
+ (((integerEncoding) == (IntegerEncoding.BIG_ENDIAN))
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN)));
// Const Field (fragmentNum)
- writeConstField("fragmentNum", FRAGMENTNUM, writeUnsignedInt(writeBuffer, 16));
+ writeConstField(
+ "fragmentNum",
+ FRAGMENTNUM,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(
+ (((integerEncoding) == (IntegerEncoding.BIG_ENDIAN))
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN)));
// Const Field (authProto)
- writeConstField("authProto", AUTHPROTO, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "authProto",
+ AUTHPROTO,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(
+ (((integerEncoding) == (IntegerEncoding.BIG_ENDIAN))
+ ? ByteOrder.BIG_ENDIAN
+ : ByteOrder.LITTLE_ENDIAN)));
// Const Field (serialLow)
- writeConstField("serialLow", SERIALLOW, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "serialLow",
+ SERIALLOW,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (payload)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java
index 804392a5d6..d5fdc69014 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block.java
@@ -72,12 +72,17 @@ public abstract class PnIoCm_Block implements Message {
"PnIoCm_BlockType",
getBlockType(),
new DataWriterEnumDefault<>(
- PnIoCm_BlockType::getValue, PnIoCm_BlockType::name, writeUnsignedInt(writeBuffer, 16)));
+ PnIoCm_BlockType::getValue, PnIoCm_BlockType::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (blockLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int blockLength = (int) ((getLengthInBytes()) - (4));
- writeImplicitField("blockLength", blockLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "blockLength",
+ blockLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (blockVersionHigh)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrReq.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrReq.java
index 8396f92bb7..1e18ee11e6 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrReq.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrReq.java
@@ -136,7 +136,8 @@ public class PnIoCm_Block_AlarmCrReq extends PnIoCm_Block implements Message {
new DataWriterEnumDefault<>(
PnIoCm_AlarmCrType::getValue,
PnIoCm_AlarmCrType::name,
- writeUnsignedInt(writeBuffer, 16)));
+ writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (lt)
writeSimpleField(
@@ -149,7 +150,8 @@ public class PnIoCm_Block_AlarmCrReq extends PnIoCm_Block implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (long) 0x00000000,
- writeUnsignedLong(writeBuffer, 30));
+ writeUnsignedLong(writeBuffer, 30),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (transport)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrRes.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrRes.java
index c1b731c360..3550e9fcda 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrRes.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_AlarmCrRes.java
@@ -85,7 +85,8 @@ public class PnIoCm_Block_AlarmCrRes extends PnIoCm_Block implements Message {
new DataWriterEnumDefault<>(
PnIoCm_AlarmCrType::getValue,
PnIoCm_AlarmCrType::name,
- writeUnsignedInt(writeBuffer, 16)));
+ writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (localAlarmReference)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArReq.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArReq.java
index e28cb398b5..336ea0af59 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArReq.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArReq.java
@@ -184,7 +184,8 @@ public class PnIoCm_Block_ArReq extends PnIoCm_Block implements Message {
"PnIoCm_ArType",
arType,
new DataWriterEnumDefault<>(
- PnIoCm_ArType::getValue, PnIoCm_ArType::name, writeUnsignedInt(writeBuffer, 16)));
+ PnIoCm_ArType::getValue, PnIoCm_ArType::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (arUuid)
writeSimpleField(
@@ -239,7 +240,8 @@ public class PnIoCm_Block_ArReq extends PnIoCm_Block implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (long) 0x00000,
- writeUnsignedLong(writeBuffer, 17));
+ writeUnsignedLong(writeBuffer, 17),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (acknowledgeCompanionAr)
writeSimpleField(
@@ -256,7 +258,8 @@ public class PnIoCm_Block_ArReq extends PnIoCm_Block implements Message {
new DataWriterEnumDefault<>(
PnIoCm_CompanionArType::getValue,
PnIoCm_CompanionArType::name,
- writeUnsignedByte(writeBuffer, 2)));
+ writeUnsignedByte(writeBuffer, 2)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (deviceAccess)
writeSimpleField(
@@ -269,7 +272,8 @@ public class PnIoCm_Block_ArReq extends PnIoCm_Block implements Message {
writeReservedField(
"reserved",
reservedField1 != null ? reservedField1 : (byte) 0x0,
- writeUnsignedByte(writeBuffer, 3));
+ writeUnsignedByte(writeBuffer, 3),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (cmInitiator)
writeSimpleField(
@@ -291,7 +295,8 @@ public class PnIoCm_Block_ArReq extends PnIoCm_Block implements Message {
"PnIoCm_State",
state,
new DataWriterEnumDefault<>(
- PnIoCm_State::getValue, PnIoCm_State::name, writeUnsignedByte(writeBuffer, 3)));
+ PnIoCm_State::getValue, PnIoCm_State::name, writeUnsignedByte(writeBuffer, 3)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (cmInitiatorActivityTimeoutFactor)
writeSimpleField(
@@ -310,7 +315,11 @@ public class PnIoCm_Block_ArReq extends PnIoCm_Block implements Message {
// Implicit Field (stationNameLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int stationNameLength = (int) (STR_LEN(getCmInitiatorStationName()));
- writeImplicitField("stationNameLength", stationNameLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "stationNameLength",
+ stationNameLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (cmInitiatorStationName)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArRes.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArRes.java
index 87f13e635d..bc9326295e 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArRes.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ArRes.java
@@ -97,7 +97,8 @@ public class PnIoCm_Block_ArRes extends PnIoCm_Block implements Message {
"PnIoCm_ArType",
arType,
new DataWriterEnumDefault<>(
- PnIoCm_ArType::getValue, PnIoCm_ArType::name, writeUnsignedInt(writeBuffer, 16)));
+ PnIoCm_ArType::getValue, PnIoCm_ArType::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (arUuid)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ExpectedSubmoduleReq.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ExpectedSubmoduleReq.java
index 91ed03f92d..7cfa9bb3a3 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ExpectedSubmoduleReq.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ExpectedSubmoduleReq.java
@@ -66,10 +66,15 @@ public class PnIoCm_Block_ExpectedSubmoduleReq extends PnIoCm_Block implements M
// Implicit Field (numberOfApis) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int numberOfApis = (int) (COUNT(getApis()));
- writeImplicitField("numberOfApis", numberOfApis, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "numberOfApis",
+ numberOfApis,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (apis)
- writeComplexTypeArrayField("apis", apis, writeBuffer);
+ writeComplexTypeArrayField(
+ "apis", apis, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("PnIoCm_Block_ExpectedSubmoduleReq");
}
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrReq.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrReq.java
index 36b7fb7ede..b232dfa085 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrReq.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrReq.java
@@ -205,7 +205,8 @@ public class PnIoCm_Block_IoCrReq extends PnIoCm_Block implements Message {
"PnIoCm_IoCrType",
ioCrType,
new DataWriterEnumDefault<>(
- PnIoCm_IoCrType::getValue, PnIoCm_IoCrType::name, writeUnsignedInt(writeBuffer, 16)));
+ PnIoCm_IoCrType::getValue, PnIoCm_IoCrType::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (ioCrReference)
writeSimpleField(
@@ -246,7 +247,8 @@ public class PnIoCm_Block_IoCrReq extends PnIoCm_Block implements Message {
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (long) 0x0000,
- writeUnsignedLong(writeBuffer, 17));
+ writeUnsignedLong(writeBuffer, 17),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (mediaRedundancy)
writeSimpleField(
@@ -259,7 +261,8 @@ public class PnIoCm_Block_IoCrReq extends PnIoCm_Block implements Message {
writeReservedField(
"reserved",
reservedField1 != null ? reservedField1 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 7));
+ writeUnsignedShort(writeBuffer, 7),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (rtClass)
writeSimpleEnumField(
@@ -267,7 +270,8 @@ public class PnIoCm_Block_IoCrReq extends PnIoCm_Block implements Message {
"PnIoCm_RtClass",
rtClass,
new DataWriterEnumDefault<>(
- PnIoCm_RtClass::getValue, PnIoCm_RtClass::name, writeUnsignedByte(writeBuffer, 4)));
+ PnIoCm_RtClass::getValue, PnIoCm_RtClass::name, writeUnsignedByte(writeBuffer, 4)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (dataLength)
writeSimpleField(
@@ -349,10 +353,15 @@ public class PnIoCm_Block_IoCrReq extends PnIoCm_Block implements Message {
// Implicit Field (numberOfApis) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int numberOfApis = (int) (COUNT(getApis()));
- writeImplicitField("numberOfApis", numberOfApis, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "numberOfApis",
+ numberOfApis,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (apis)
- writeComplexTypeArrayField("apis", apis, writeBuffer);
+ writeComplexTypeArrayField(
+ "apis", apis, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("PnIoCm_Block_IoCrReq");
}
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrRes.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrRes.java
index ea5e7afc75..fa80c9f6f4 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrRes.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_IoCrRes.java
@@ -83,7 +83,8 @@ public class PnIoCm_Block_IoCrRes extends PnIoCm_Block implements Message {
"PnIoCm_IoCrType",
ioCrType,
new DataWriterEnumDefault<>(
- PnIoCm_IoCrType::getValue, PnIoCm_IoCrType::name, writeUnsignedInt(writeBuffer, 16)));
+ PnIoCm_IoCrType::getValue, PnIoCm_IoCrType::name, writeUnsignedInt(writeBuffer, 16)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (ioCrReference)
writeSimpleField(
diff --git a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ModuleDiff.java b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ModuleDiff.java
index 0f2ccb1e2d..a69691bcb3 100644
--- a/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ModuleDiff.java
+++ b/plc4j/drivers/profinet/src/main/generated/org/apache/plc4x/java/profinet/readwrite/PnIoCm_Block_ModuleDiff.java
@@ -64,10 +64,15 @@ public class PnIoCm_Block_ModuleDiff extends PnIoCm_Block implements Message {
// Implicit Field (numberOfApis) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int numberOfApis = (int) (COUNT(getApis()));
- writeImplicitField("numberOfApis", numberOfApis, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "numberOfApis",
+ numberOfApis,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (apis)
- writeComplexTypeArrayField("apis", apis, writeBuffer);
+ writeComplexTypeArrayField(
+ "apis", apis, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("PnIoCm_Block_ModuleDiff");
}
diff --git a/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/DataItem.java b/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/DataItem.java
index eb15c2beaa..7c5fb803ef 100644
--- a/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/DataItem.java
+++ b/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/DataItem.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -148,14 +149,14 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8");
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"));
return new PlcCHAR(value);
} else if (EvaluationHelper.equals(dataProtocolId, "IEC61131_WCHAR")) { // CHAR
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16");
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"));
return new PlcCHAR(value);
} else if (EvaluationHelper.equals(dataProtocolId, "IEC61131_STRING")) { // STRING
@@ -347,12 +348,14 @@ public class DataItem {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(dataProtocolId, "IEC61131_WCHAR")) { // CHAR
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
} else if (EvaluationHelper.equals(dataProtocolId, "IEC61131_STRING")) { // STRING
// Manual Field (value)
org.apache.plc4x.java.s7.readwrite.utils.StaticHelper.serializeS7String(
diff --git a/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/TPKTPacket.java b/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/TPKTPacket.java
index cc47127910..8fc6233bdd 100644
--- a/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/TPKTPacket.java
+++ b/plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/TPKTPacket.java
@@ -64,18 +64,27 @@ public class TPKTPacket implements Message {
writeBuffer.pushContext("TPKTPacket");
// Const Field (protocolId)
- writeConstField("protocolId", PROTOCOLID, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "protocolId",
+ PROTOCOLID,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (short) 0x00,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (len) (Used for parsing, but its value is not stored as it's implicitly given
// by the objects content)
int len = (int) ((getPayload().getLengthInBytes()) + (4));
- writeImplicitField("len", len, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "len",
+ len,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (payload)
writeSimpleField(
diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7StringTag.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7StringTag.java
index 4b38ae05a3..2435717c44 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7StringTag.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7StringTag.java
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.plc4x.java.s7.readwrite.MemoryArea;
import org.apache.plc4x.java.s7.readwrite.TransportSize;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -49,7 +50,9 @@ public class S7StringTag extends S7Tag {
writeBuffer.pushContext(getClass().getSimpleName());
String memoryArea = getMemoryArea().name();
- writeBuffer.writeString("memoryArea", memoryArea.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), memoryArea);
+ writeBuffer.writeString("memoryArea",
+ memoryArea.getBytes(StandardCharsets.UTF_8).length * 8,
+ memoryArea, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.writeUnsignedInt("blockNumber", 16, getBlockNumber());
writeBuffer.writeUnsignedInt("byteOffset", 16, getByteOffset());
@@ -58,7 +61,9 @@ public class S7StringTag extends S7Tag {
writeBuffer.writeInt("stringLength", 64, getStringLength());
String dataType = getDataType().name();
- writeBuffer.writeString("dataType", dataType.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), dataType);
+ writeBuffer.writeString("dataType",
+ dataType.getBytes(StandardCharsets.UTF_8).length * 8,
+ dataType, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7Tag.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7Tag.java
index c8f762ef86..2a78a33da6 100644
--- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7Tag.java
+++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/tag/S7Tag.java
@@ -31,6 +31,7 @@ import org.apache.plc4x.java.s7.readwrite.S7Address;
import org.apache.plc4x.java.s7.readwrite.S7AddressAny;
import org.apache.plc4x.java.s7.readwrite.MemoryArea;
import org.apache.plc4x.java.s7.readwrite.TransportSize;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.*;
import org.apache.plc4x.java.spi.model.DefaultArrayInfo;
import org.apache.plc4x.java.spi.utils.Serializable;
@@ -342,7 +343,9 @@ public class S7Tag implements PlcTag, Serializable {
writeBuffer.pushContext(getClass().getSimpleName());
String memoryArea = getMemoryArea().name();
- writeBuffer.writeString("memoryArea", memoryArea.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), memoryArea);
+ writeBuffer.writeString("memoryArea",
+ memoryArea.getBytes(StandardCharsets.UTF_8).length * 8,
+ memoryArea, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.writeUnsignedInt("blockNumber", 16, getBlockNumber());
writeBuffer.writeUnsignedInt("byteOffset", 16, getByteOffset());
@@ -350,7 +353,9 @@ public class S7Tag implements PlcTag, Serializable {
writeBuffer.writeUnsignedInt("numElements", 16, getNumberOfElements());
String dataType = getDataType().name();
- writeBuffer.writeString("dataType", dataType.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), dataType);
+ writeBuffer.writeString("dataType",
+ dataType.getBytes(StandardCharsets.UTF_8).length * 8,
+ dataType, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext(getClass().getSimpleName());
}
diff --git a/plc4j/drivers/simulated/src/main/generated/org/apache/plc4x/java/simulated/readwrite/DataItem.java b/plc4j/drivers/simulated/src/main/generated/org/apache/plc4x/java/simulated/readwrite/DataItem.java
index 744392bcf3..978d10d741 100644
--- a/plc4j/drivers/simulated/src/main/generated/org/apache/plc4x/java/simulated/readwrite/DataItem.java
+++ b/plc4j/drivers/simulated/src/main/generated/org/apache/plc4x/java/simulated/readwrite/DataItem.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -494,7 +495,7 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8");
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"));
return new PlcCHAR(value);
} else if (EvaluationHelper.equals(dataType, "CHAR")) { // List
@@ -515,7 +516,7 @@ public class DataItem {
value.add(
new PlcSTRING(
(String) /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8")));
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"))));
}
}
@@ -525,7 +526,7 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16");
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"));
return new PlcWCHAR(value);
} else if (EvaluationHelper.equals(dataType, "WCHAR")) { // List
@@ -546,7 +547,7 @@ public class DataItem {
value.add(
new PlcSTRING(
(String) /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16")));
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"))));
}
}
@@ -555,14 +556,14 @@ public class DataItem {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 255, "UTF-8");
+ readBuffer.readString("", 255, WithOption.WithEncoding("UTF-8"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(dataType, "WSTRING")) { // STRING
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 255, "UTF-16");
+ readBuffer.readString("", 255, WithOption.WithEncoding("UTF-16"));
return new PlcSTRING(value);
}
@@ -812,14 +813,16 @@ public class DataItem {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(dataType, "CHAR")) { // List
PlcList values = (PlcList) _value;
for (PlcValue val : ((List<PlcValue>) values.getList())) {
String value = (String) val.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
}
} else if (EvaluationHelper.equals(dataType, "WCHAR")
@@ -827,26 +830,30 @@ public class DataItem {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
} else if (EvaluationHelper.equals(dataType, "WCHAR")) { // List
PlcList values = (PlcList) _value;
for (PlcValue val : ((List<PlcValue>) values.getList())) {
String value = (String) val.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
}
} else if (EvaluationHelper.equals(dataType, "STRING")) { // STRING
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 255, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 255, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(dataType, "WSTRING")) { // STRING
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 255, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 255, (String) (value), WithOption.WithEncoding("UTF-16"));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/FieldCommons.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/FieldCommons.java
index 900b122da9..92c60e8d3f 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/FieldCommons.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/FieldCommons.java
@@ -44,23 +44,6 @@ public interface FieldCommons {
return Optional.empty();
}
- default Optional<String> extractEncoding(WithReaderArgs... readerArgs) {
- return extractEncoding(Stream.of(readerArgs).map(WithReaderWriterArgs.class::cast).toArray(WithReaderWriterArgs[]::new));
- }
-
- default Optional<String> extractEncoding(WithWriterArgs... writerArgs) {
- return extractEncoding(Stream.of(writerArgs).map(WithReaderWriterArgs.class::cast).toArray(WithReaderWriterArgs[]::new));
- }
-
- default Optional<String> extractEncoding(WithReaderWriterArgs... readerWriterArgs) {
- for (WithReaderWriterArgs arg : readerWriterArgs) {
- if (arg instanceof withOptionEncoding) {
- return Optional.of(((withOptionEncoding) arg).encoding());
- }
- }
- return Optional.empty();
- }
-
default <T> T switchParseByteOrderIfNecessary(RunParseWrapped<T> runnable, ByteOrderAware byteOrderAware, ByteOrder wantedByteOrder) throws ParseException {
Objects.requireNonNull(runnable);
Objects.requireNonNull(byteOrderAware);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/WithOption.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/WithOption.java
index 073ec7885d..ea6101436e 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/WithOption.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/WithOption.java
@@ -27,24 +27,24 @@ public interface WithOption extends WithReaderWriterArgs {
return (withOptionByteOrder) () -> byteOrder;
}
- static WithOption WithEncoding(String encoding) {
- return (withOptionEncoding) () -> encoding;
+ static WithReaderWriterArgs WithEncoding(String encoding) {
+ return WithReaderWriterArgs.WithEncoding(encoding);
}
static WithOption WithSerializationContext(String context) {
return (withOptionSerializationContext) () -> context;
}
+ static WithReaderWriterArgs WithNullBytesHex(String nullBytesHex) {
+ return WithReaderWriterArgs.WithNullBytesHex(nullBytesHex);
+ }
+
}
interface withOptionByteOrder extends WithOption {
ByteOrder byteOrder();
}
-interface withOptionEncoding extends WithOption {
- String encoding();
-}
-
interface withOptionSerializationContext extends WithOption {
String context();
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderOptional.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderOptional.java
index ebecac935f..480f76b5da 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderOptional.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldReaderOptional.java
@@ -18,15 +18,19 @@
*/
package org.apache.plc4x.java.spi.codegen.fields;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.spi.codegen.FieldCommons;
import org.apache.plc4x.java.spi.codegen.io.DataReader;
-import org.apache.plc4x.java.spi.generation.ParseAssertException;
-import org.apache.plc4x.java.spi.generation.ParseException;
-import org.apache.plc4x.java.spi.generation.WithReaderArgs;
+import org.apache.plc4x.java.spi.generation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FieldReaderOptional<T> implements FieldCommons {
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+public class FieldReaderOptional<T> implements FieldCommons, WithReaderWriterArgs {
private static final Logger LOGGER = LoggerFactory.getLogger(FieldReaderOptional.class);
@@ -37,6 +41,29 @@ public class FieldReaderOptional<T> implements FieldCommons {
return null;
}
+ // Check if a nullByteHex is set.
+ // If it is, peek the equivalent number of bytes and compare.
+ // If they match, return null.
+ Optional<String> nullByteHexOptional = extractNullBytesHex(readerArgs);
+ if(nullByteHexOptional.isPresent()) {
+ String nullByteHex = nullByteHexOptional.get();
+ try {
+ byte[] nullBytes = Hex.decodeHex(nullByteHex);
+ ReadBuffer readBuffer = dataReader.getReadBuffer();
+ int pos = readBuffer.getPos();
+ byte[] curBytes = readBuffer.readByteArray("logicalName", nullBytes.length, readerArgs);
+ // Compare them, if they equal, return null, if not reset the position and try to read it again.
+ if (Arrays.equals(nullBytes, curBytes)) {
+ // Abort with null
+ return null;
+ } else {
+ readBuffer.reset(pos);
+ }
+ } catch (DecoderException e) {
+ // Ignore.
+ }
+ }
+
int curPos = dataReader.getPos();
try {
T field = switchParseByteOrderIfNecessary(() -> dataReader.read(logicalName, readerArgs), dataReader, extractByteOrder(readerArgs).orElse(null));
@@ -46,10 +73,11 @@ public class FieldReaderOptional<T> implements FieldCommons {
LOGGER.debug("Assertion doesn't match for field {}. Resetting read position to {}", logicalName, curPos, e);
dataReader.setPos(curPos);
return null;
- } catch (ParseException e) {
+ } catch (ArrayIndexOutOfBoundsException e) {
LOGGER.debug("Not enough bytes for {}. Resetting read position to {}", logicalName, curPos, e);
dataReader.setPos(curPos);
return null;
}
}
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptional.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptional.java
index 0d897f7eef..c34860bff7 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptional.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptional.java
@@ -18,14 +18,18 @@
*/
package org.apache.plc4x.java.spi.codegen.fields;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.spi.codegen.FieldCommons;
import org.apache.plc4x.java.spi.codegen.io.DataWriter;
-import org.apache.plc4x.java.spi.generation.SerializationException;
-import org.apache.plc4x.java.spi.generation.WithWriterArgs;
+import org.apache.plc4x.java.spi.generation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FieldWriterOptional<T> implements FieldCommons {
+import java.util.Arrays;
+import java.util.Optional;
+
+public class FieldWriterOptional<T> implements FieldCommons, WithReaderWriterArgs {
private static final Logger LOGGER = LoggerFactory.getLogger(FieldWriterOptional.class);
@@ -34,7 +38,25 @@ public class FieldWriterOptional<T> implements FieldCommons {
if (condition && value != null) {
switchSerializeByteOrderIfNecessary(() -> dataWriter.write(logicalName, value, writerArgs), dataWriter, extractByteOrder(writerArgs).orElse(null));
} else {
- LOGGER.debug("field {} not written because value is null({}) or condition({}) didn't evaluate to true", logicalName, value != null, condition);
+ WriteBuffer writeBuffer = dataWriter.getWriteBuffer();
+ // This is very special to byte based buffers, it would just confuse the others.
+ if(writeBuffer instanceof WriteBufferByteBased) {
+ // Check if a nullByteHex is set.
+ // If it is, peek the equivalent number of bytes and compare.
+ // If they match, return null.
+ Optional<String> nullByteHexOptional = extractNullBytesHex(writerArgs);
+ if (nullByteHexOptional.isPresent()) {
+ String nullByteHex = nullByteHexOptional.get();
+ try {
+ byte[] nullBytes = Hex.decodeHex(nullByteHex);
+ writeBuffer.writeByteArray(logicalName, nullBytes, writerArgs);
+ } catch (DecoderException e) {
+ // Ignore.
+ }
+ } else {
+ LOGGER.debug("field {} not written because value is null({}) or condition({}) didn't evaluate to true", logicalName, value != null, condition);
+ }
+ }
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptionalEnum.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptionalEnum.java
index 3aac914a88..a8244dd67f 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptionalEnum.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/fields/FieldWriterOptionalEnum.java
@@ -18,14 +18,17 @@
*/
package org.apache.plc4x.java.spi.codegen.fields;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.spi.codegen.FieldCommons;
import org.apache.plc4x.java.spi.codegen.io.DataWriter;
-import org.apache.plc4x.java.spi.generation.SerializationException;
-import org.apache.plc4x.java.spi.generation.WithWriterArgs;
+import org.apache.plc4x.java.spi.generation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class FieldWriterOptionalEnum<T> implements FieldCommons {
+import java.util.Optional;
+
+public class FieldWriterOptionalEnum<T> implements FieldCommons, WithReaderWriterArgs {
private static final Logger LOGGER = LoggerFactory.getLogger(FieldWriterOptionalEnum.class);
@@ -35,7 +38,25 @@ public class FieldWriterOptionalEnum<T> implements FieldCommons {
if (condition && value != null) {
switchSerializeByteOrderIfNecessary(() -> dataWriter.write(innerName, value, writerArgs), dataWriter, extractByteOrder(writerArgs).orElse(null));
} else {
- LOGGER.debug("field {} not written because value is null({}) or condition({}) didn't evaluate to true", logicalName, value != null, condition);
+ WriteBuffer writeBuffer = dataWriter.getWriteBuffer();
+ // This is very special to byte based buffers, it would just confuse the others.
+ if(writeBuffer instanceof WriteBufferByteBased) {
+ // Check if a nullByteHex is set.
+ // If it is, peek the equivalent number of bytes and compare.
+ // If they match, return null.
+ Optional<String> nullByteHexOptional = extractNullBytesHex(writerArgs);
+ if (nullByteHexOptional.isPresent()) {
+ String nullByteHex = nullByteHexOptional.get();
+ try {
+ byte[] nullBytes = Hex.decodeHex(nullByteHex);
+ writeBuffer.writeByteArray(logicalName, nullBytes, writerArgs);
+ } catch (DecoderException e) {
+ // Ignore.
+ }
+ } else {
+ LOGGER.debug("field {} not written because value is null({}) or condition({}) didn't evaluate to true", logicalName, value != null, condition);
+ }
+ }
}
dataWriter.popContext(logicalName);
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReader.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReader.java
index 556cf0cf88..9a1512ab21 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReader.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReader.java
@@ -19,6 +19,7 @@
package org.apache.plc4x.java.spi.codegen.io;
import org.apache.plc4x.java.spi.generation.ParseException;
+import org.apache.plc4x.java.spi.generation.ReadBuffer;
import org.apache.plc4x.java.spi.generation.WithReaderArgs;
public interface DataReader<T> extends ByteOrderAware {
@@ -32,4 +33,6 @@ public interface DataReader<T> extends ByteOrderAware {
void pullContext(String logicalName, WithReaderArgs... readerArgs);
void closeContext(String logicalName, WithReaderArgs... readerArgs);
+ ReadBuffer getReadBuffer();
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java
index 434cd033f0..11b760c048 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderComplexDefault.java
@@ -84,5 +84,10 @@ public class DataReaderComplexDefault<T> implements DataReaderComplex<T> {
readBuffer.closeContext(logicalName, readerArgs);
}
+ @Override
+ public ReadBuffer getReadBuffer() {
+ return readBuffer;
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderEnumDefault.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderEnumDefault.java
index 87e063e5db..c997b3373b 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderEnumDefault.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderEnumDefault.java
@@ -20,6 +20,7 @@ package org.apache.plc4x.java.spi.codegen.io;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.ParseException;
+import org.apache.plc4x.java.spi.generation.ReadBuffer;
import org.apache.plc4x.java.spi.generation.WithReaderArgs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,4 +83,9 @@ public class DataReaderEnumDefault<T, I> implements DataReaderEnum<T> {
dataReader.closeContext(logicalName, readerArgs);
}
+ @Override
+ public ReadBuffer getReadBuffer() {
+ return dataReader.getReadBuffer();
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleBase.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleBase.java
index 9e1e81e015..166ee0af78 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleBase.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleBase.java
@@ -60,4 +60,9 @@ public abstract class DataReaderSimpleBase<T> implements DataReader<T> {
readBuffer.closeContext(logicalName, readerArgs);
}
+ @Override
+ public ReadBuffer getReadBuffer() {
+ return readBuffer;
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleString.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleString.java
index d7c244aaaa..7151dea612 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleString.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataReaderSimpleString.java
@@ -30,7 +30,7 @@ public class DataReaderSimpleString extends DataReaderSimpleBase<String> {
@Override
public String read(String logicalName, WithReaderArgs... readerArgs) throws ParseException {
- return readBuffer.readString(logicalName, bitLength, "UTF-8", readerArgs);
+ return readBuffer.readString(logicalName, bitLength, readerArgs);
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriter.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriter.java
index 40d6e89324..3f75fdb30b 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriter.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriter.java
@@ -20,6 +20,7 @@ package org.apache.plc4x.java.spi.codegen.io;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WithWriterArgs;
+import org.apache.plc4x.java.spi.generation.WriteBuffer;
public interface DataWriter<T> extends ByteOrderAware {
@@ -28,4 +29,6 @@ public interface DataWriter<T> extends ByteOrderAware {
void pushContext(String logicalName, WithWriterArgs... writerArgs);
void popContext(String logicalName, WithWriterArgs... writerArgs);
+ WriteBuffer getWriteBuffer();
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterComplexDefault.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterComplexDefault.java
index e986b0cffd..16e8f1529e 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterComplexDefault.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterComplexDefault.java
@@ -69,4 +69,9 @@ public class DataWriterComplexDefault<T extends Message> implements DataWriterCo
}
}
+ @Override
+ public WriteBuffer getWriteBuffer() {
+ return writeBuffer;
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterDataIoDefault.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterDataIoDefault.java
index 2fb286672d..588e8a0f78 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterDataIoDefault.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterDataIoDefault.java
@@ -64,4 +64,9 @@ public class DataWriterDataIoDefault implements DataWriterComplex<PlcValue> {
}
}
+ @Override
+ public WriteBuffer getWriteBuffer() {
+ return writeBuffer;
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterEnumDefault.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterEnumDefault.java
index bc45008766..6d53bde10d 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterEnumDefault.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterEnumDefault.java
@@ -19,10 +19,7 @@
package org.apache.plc4x.java.spi.codegen.io;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.plc4x.java.spi.generation.ByteOrder;
-import org.apache.plc4x.java.spi.generation.SerializationException;
-import org.apache.plc4x.java.spi.generation.WithReaderWriterArgs;
-import org.apache.plc4x.java.spi.generation.WithWriterArgs;
+import org.apache.plc4x.java.spi.generation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -76,4 +73,9 @@ public class DataWriterEnumDefault<T, I> implements DataWriterEnum<T> {
dataWriter.popContext(logicalName, writerArgs);
}
+ @Override
+ public WriteBuffer getWriteBuffer() {
+ return dataWriter.getWriteBuffer();
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleBase.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleBase.java
index fd47744df0..1c442c7813 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleBase.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleBase.java
@@ -53,4 +53,9 @@ public abstract class DataWriterSimpleBase<T> implements DataWriter<T>, FieldCom
writeBuffer.popContext(logicalName, writerArgs);
}
+ @Override
+ public WriteBuffer getWriteBuffer() {
+ return writeBuffer;
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleString.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleString.java
index 2f356920c4..6da5fc5af3 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleString.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/codegen/io/DataWriterSimpleString.java
@@ -18,7 +18,6 @@
*/
package org.apache.plc4x.java.spi.codegen.io;
-import org.apache.plc4x.java.spi.codegen.FieldCommons;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WithWriterArgs;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -31,8 +30,7 @@ public class DataWriterSimpleString extends DataWriterSimpleBase<String> {
@Override
public void write(String logicalName, String value, WithWriterArgs... writerArgs) throws SerializationException {
- String encoding = extractEncoding(writerArgs).orElse("UTF-8");
- writeBuffer.writeString(logicalName, bitLength, encoding, value, writerArgs);
+ writeBuffer.writeString(logicalName, bitLength, value, writerArgs);
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/BufferCommons.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/BufferCommons.java
index bdc19deec5..494a0b1003 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/BufferCommons.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/BufferCommons.java
@@ -76,4 +76,22 @@ public interface BufferCommons {
}
return Optional.empty();
}
+
+ default Optional<String> extractEncoding(WithReaderArgs... readerArgs) {
+ return extractEncoding(Stream.of(readerArgs).map(WithReaderWriterArgs.class::cast).toArray(WithReaderWriterArgs[]::new));
+ }
+
+ default Optional<String> extractEncoding(WithWriterArgs... writerArgs) {
+ return extractEncoding(Stream.of(writerArgs).map(WithReaderWriterArgs.class::cast).toArray(WithReaderWriterArgs[]::new));
+ }
+
+ default Optional<String> extractEncoding(WithReaderWriterArgs... readerWriterArgs) {
+ for (WithReaderWriterArgs arg : readerWriterArgs) {
+ if (arg instanceof withEncoding) {
+ return Optional.of(((withEncoding) arg).encoding());
+ }
+ }
+ return Optional.empty();
+ }
+
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
index 663a43c783..96968efb0f 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBuffer.java
@@ -34,14 +34,14 @@ public interface ReadBuffer extends ByteOrderAware, PositionAware {
boolean readBit(String logicalName, WithReaderArgs... readerArgs) throws ParseException;
- default boolean readBit() throws ParseException {
- return readBit("");
+ default boolean readBit(WithReaderArgs... readerArgs) throws ParseException {
+ return readBit("", readerArgs);
}
byte readByte(String logicalName, WithReaderArgs... readerArgs) throws ParseException;
- default byte readByte() throws ParseException {
- return readSignedByte("", 8);
+ default byte readByte(WithReaderArgs... readerArgs) throws ParseException {
+ return readSignedByte("", 8, readerArgs);
}
byte[] readByteArray(String logicalName, int numberOfBytes, WithReaderArgs... readerArgs) throws ParseException;
@@ -52,86 +52,86 @@ public interface ReadBuffer extends ByteOrderAware, PositionAware {
byte readUnsignedByte(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default byte readUnsignedByte(int bitLength) throws ParseException {
- return readUnsignedByte("", bitLength);
+ default byte readUnsignedByte(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readUnsignedByte("", bitLength, readerArgs);
}
short readUnsignedShort(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default short readUnsignedShort(int bitLength) throws ParseException {
- return readUnsignedShort("", bitLength);
+ default short readUnsignedShort(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readUnsignedShort("", bitLength, readerArgs);
}
int readUnsignedInt(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default int readUnsignedInt(int bitLength) throws ParseException {
- return readUnsignedInt("", bitLength);
+ default int readUnsignedInt(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readUnsignedInt("", bitLength, readerArgs);
}
long readUnsignedLong(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default long readUnsignedLong(int bitLength) throws ParseException {
- return readUnsignedLong("", bitLength);
+ default long readUnsignedLong(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readUnsignedLong("", bitLength, readerArgs);
}
BigInteger readUnsignedBigInteger(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default BigInteger readUnsignedBigInteger(int bitLength) throws ParseException {
- return readUnsignedBigInteger("", bitLength);
+ default BigInteger readUnsignedBigInteger(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readUnsignedBigInteger("", bitLength, readerArgs);
}
byte readSignedByte(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default byte readSignedByte(int bitLength) throws ParseException {
- return readSignedByte("", bitLength);
+ default byte readSignedByte(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readSignedByte("", bitLength, readerArgs);
}
short readShort(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default short readShort(int bitLength) throws ParseException {
- return readShort("", bitLength);
+ default short readShort(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readShort("", bitLength, readerArgs);
}
int readInt(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default int readInt(int bitLength) throws ParseException {
- return readInt("", bitLength);
+ default int readInt(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readInt("", bitLength, readerArgs);
}
long readLong(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default long readLong(int bitLength) throws ParseException {
- return readLong("", bitLength);
+ default long readLong(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readLong("", bitLength, readerArgs);
}
BigInteger readBigInteger(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default BigInteger readBigInteger(int bitLength) throws ParseException {
- return readBigInteger("", bitLength);
+ default BigInteger readBigInteger(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readBigInteger("", bitLength, readerArgs);
}
float readFloat(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default float readFloat(int bitLength) throws ParseException {
- return readFloat("", bitLength);
+ default float readFloat(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readFloat("", bitLength, readerArgs);
}
double readDouble(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default double readDouble(int bitLength) throws ParseException {
- return readDouble("", bitLength);
+ default double readDouble(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readDouble("", bitLength, readerArgs);
}
BigDecimal readBigDecimal(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default BigDecimal readBigDecimal(int bitLength) throws ParseException {
- return readBigDecimal("", bitLength);
+ default BigDecimal readBigDecimal(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readBigDecimal("", bitLength, readerArgs);
}
- String readString(String logicalName, int bitLength, String encoding, WithReaderArgs... readerArgs) throws ParseException;
+ String readString(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException;
- default String readString(int bitLength, String encoding) throws ParseException {
- return readString("", bitLength, encoding);
+ default String readString(int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ return readString("", bitLength, readerArgs);
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferByteBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferByteBased.java
index 9c41c481c6..f926f6f6cd 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferByteBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferByteBased.java
@@ -18,7 +18,6 @@
*/
package org.apache.plc4x.java.spi.generation;
-import ch.qos.logback.core.encoder.EchoEncoder;
import com.github.jinahya.bit.io.ArrayByteInput;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.spi.generation.io.MyDefaultBitInput;
@@ -30,7 +29,7 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
-public class ReadBufferByteBased implements ReadBuffer {
+public class ReadBufferByteBased implements ReadBuffer, BufferCommons {
private final MyDefaultBitInput bi;
private ByteOrder byteOrder;
@@ -93,7 +92,7 @@ public class ReadBufferByteBased implements ReadBuffer {
bi.getDelegate().index(oldIndex + offset);
// Read the byte.
return bi.readByte(false, 8);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error peeking byte", e);
} finally {
// Reset the delegate to the old index.
@@ -110,7 +109,7 @@ public class ReadBufferByteBased implements ReadBuffer {
public boolean readBit(String logicalName, WithReaderArgs... readerArgs) throws ParseException {
try {
return bi.readBoolean();
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading bit", e);
}
}
@@ -139,7 +138,7 @@ public class ReadBufferByteBased implements ReadBuffer {
}
try {
return bi.readByte(true, bitLength);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading unsigned byte", e);
}
}
@@ -153,9 +152,28 @@ public class ReadBufferByteBased implements ReadBuffer {
throw new ParseException("unsigned short can only contain max 8 bits");
}
try {
- // No need to flip here as we're only reading one byte.
- return bi.readShort(true, bitLength);
- } catch (Exception e) {
+ String encoding = extractEncoding(readerArgs).orElse("default");
+ switch (encoding) {
+ case "ASCII":
+ // AsciiUint can only decode values that have a multiple of 8 length.
+ if (bitLength % 8 != 0) {
+ throw new ParseException("'ASCII' encoded fields must have a length that is a multiple of 8 bits long");
+ }
+ int charLen = bitLength / 8;
+ byte[] stringBytes = new byte[charLen];
+ for (int i = 0; i < charLen; i++) {
+ stringBytes[i] = bi.readByte(false, 8);
+ }
+ String stringValue = new String(stringBytes, StandardCharsets.US_ASCII);
+ stringValue = stringValue.trim();
+ return Short.parseShort(stringValue);
+ case "default":
+ // No need to flip here as we're only reading one byte.
+ return bi.readShort(true, bitLength);
+ default:
+ throw new ParseException("unsupported encoding '" + encoding + "'");
+ }
+ } catch (IOException e) {
throw new ParseException("Error reading unsigned short", e);
}
}
@@ -169,12 +187,31 @@ public class ReadBufferByteBased implements ReadBuffer {
throw new ParseException("unsigned int can only contain max 16 bits");
}
try {
- if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
- int intValue = bi.readInt(true, bitLength);
- return Integer.reverseBytes(intValue) >>> 16;
+ String encoding = extractEncoding(readerArgs).orElse("default");
+ switch (encoding) {
+ case "ASCII":
+ // AsciiUint can only decode values that have a multiple of 8 length.
+ if (bitLength % 8 != 0) {
+ throw new ParseException("'ASCII' encoded fields must have a length that is a multiple of 8 bits long");
+ }
+ int charLen = bitLength / 8;
+ byte[] stringBytes = new byte[charLen];
+ for (int i = 0; i < charLen; i++) {
+ stringBytes[i] = bi.readByte(false, 8);
+ }
+ String stringValue = new String(stringBytes, StandardCharsets.US_ASCII);
+ stringValue = stringValue.trim();
+ return Integer.parseInt(stringValue);
+ case "default":
+ if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
+ final int longValue = bi.readInt(true, bitLength);
+ return Integer.reverseBytes(longValue) >>> 16;
+ }
+ return bi.readInt(true, bitLength);
+ default:
+ throw new ParseException("unsupported encoding '" + encoding + "'");
}
- return bi.readInt(true, bitLength);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading unsigned int", e);
}
}
@@ -188,12 +225,31 @@ public class ReadBufferByteBased implements ReadBuffer {
throw new ParseException("unsigned long can only contain max 32 bits");
}
try {
- if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
- final long longValue = bi.readLong(true, bitLength);
- return Long.reverseBytes(longValue) >>> 32;
+ String encoding = extractEncoding(readerArgs).orElse("default");
+ switch (encoding) {
+ case "ASCII":
+ // AsciiUint can only decode values that have a multiple of 8 length.
+ if (bitLength % 8 != 0) {
+ throw new ParseException("'ASCII' encoded fields must have a length that is a multiple of 8 bits long");
+ }
+ int charLen = bitLength / 8;
+ byte[] stringBytes = new byte[charLen];
+ for (int i = 0; i < charLen; i++) {
+ stringBytes[i] = bi.readByte(false, 8);
+ }
+ String stringValue = new String(stringBytes, StandardCharsets.US_ASCII);
+ stringValue = stringValue.trim();
+ return Long.parseLong(stringValue);
+ case "default":
+ if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
+ final long longValue = bi.readLong(true, bitLength);
+ return Long.reverseBytes(longValue) >>> 32;
+ }
+ return bi.readLong(true, bitLength);
+ default:
+ throw new ParseException("unsupported encoding '" + encoding + "'");
}
- return bi.readLong(true, bitLength);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading unsigned long", e);
}
}
@@ -219,7 +275,7 @@ public class ReadBufferByteBased implements ReadBuffer {
BigInteger constant = BigInteger.valueOf(Long.MAX_VALUE).multiply(BigInteger.valueOf(2)).add(BigInteger.valueOf(2));
return BigInteger.valueOf(val).add(constant);
}
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading unsigned big integer", e);
}
}
@@ -234,7 +290,7 @@ public class ReadBufferByteBased implements ReadBuffer {
}
try {
return bi.readByte(false, bitLength);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading signed byte", e);
}
}
@@ -252,7 +308,7 @@ public class ReadBufferByteBased implements ReadBuffer {
return Short.reverseBytes(bi.readShort(false, bitLength));
}
return bi.readShort(false, bitLength);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading signed short", e);
}
}
@@ -270,7 +326,7 @@ public class ReadBufferByteBased implements ReadBuffer {
return Integer.reverseBytes(bi.readInt(false, bitLength));
}
return bi.readInt(false, bitLength);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading signed int", e);
}
}
@@ -288,7 +344,7 @@ public class ReadBufferByteBased implements ReadBuffer {
return Long.reverseBytes(bi.readLong(false, bitLength));
}
return bi.readLong(false, bitLength);
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading signed long", e);
}
}
@@ -308,7 +364,7 @@ public class ReadBufferByteBased implements ReadBuffer {
} else {
throw new UnsupportedOperationException("unsupported bit length (only 16 and 32 supported)");
}
- } catch (Exception e) {
+ } catch (IOException e) {
throw new ParseException("Error reading float", e);
}
}
@@ -320,7 +376,7 @@ public class ReadBufferByteBased implements ReadBuffer {
short fraction = bi.readShort(true, 11);
// This is a 12-bit 2's complement notation ... the first bit belongs to the last 11 bits.
// If the first bit is set, then we need to also set the upper 5 bits of the fraction part.
- if(sign) {
+ if (sign) {
fraction = (short) (fraction | 0xF800);
}
if ((exponent >= 1) && (exponent < 15)) {
@@ -395,9 +451,29 @@ public class ReadBufferByteBased implements ReadBuffer {
* 0-termination.
*/
@Override
- public String readString(String logicalName, int bitLength, String encoding, WithReaderArgs... readerArgs) throws ParseException {
+ public String readString(String logicalName, int bitLength, WithReaderArgs... readerArgs) throws ParseException {
+ String encoding = extractEncoding(readerArgs).orElse("UTF-8");
encoding = encoding.replaceAll("[^a-zA-Z0-9]", "");
switch (encoding.toUpperCase()) {
+ case "ASCII": {
+ byte[] strBytes = new byte[bitLength / 8];
+ int realLength = 0;
+ boolean finishedReading = false;
+ for (int i = 0; (i < (bitLength / 8)) && hasMore(8); i++) {
+ try {
+ byte b = readByte(logicalName);
+ if (!disable0Termination() && (b == 0x00)) {
+ finishedReading = true;
+ } else if (!finishedReading) {
+ strBytes[i] = b;
+ realLength++;
+ }
+ } catch (Exception e) {
+ throw new PlcRuntimeException(e);
+ }
+ }
+ return new String(strBytes, StandardCharsets.US_ASCII).substring(0, realLength);
+ }
case "UTF8": {
byte[] strBytes = new byte[bitLength / 8];
int realLength = 0;
@@ -429,7 +505,7 @@ public class ReadBufferByteBased implements ReadBuffer {
byte b2 = readByte(logicalName);
if (!disable0Termination() && (b1 == 0x00) && (b2 == 0x00)) {
finishedReading = true;
- } else if (!finishedReading){
+ } else if (!finishedReading) {
strBytes[(i * 2)] = b1;
strBytes[(i * 2) + 1] = b2;
realLength++;
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferJsonBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferJsonBased.java
index c911448bcb..9e7b276ce9 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferJsonBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferJsonBased.java
@@ -346,7 +346,7 @@ public class ReadBufferJsonBased implements ReadBuffer, BufferCommons {
}
@Override
- public String readString(String logicalName, int bitLength, String encoding, WithReaderArgs... readerArgs) {
+ public String readString(String logicalName, int bitLength, WithReaderArgs... readerArgs) {
logicalName = sanitizeLogicalName(logicalName);
move(bitLength);
Map element = getElement(logicalName);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferXmlBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferXmlBased.java
index 39c2a0a432..77de142a68 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferXmlBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/ReadBufferXmlBased.java
@@ -21,7 +21,6 @@ package org.apache.plc4x.java.spi.generation;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
-import javax.xml.XMLConstants;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
@@ -195,7 +194,7 @@ public class ReadBufferXmlBased implements ReadBuffer, BufferCommons {
}
@Override
- public String readString(String logicalName, int bitLength, String encoding, WithReaderArgs... readerArgs) {
+ public String readString(String logicalName, int bitLength, WithReaderArgs... readerArgs) {
move(bitLength);
return decode(logicalName, rwStringKey, bitLength);
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WithReaderWriterArgs.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WithReaderWriterArgs.java
index 3570757a1f..ba850fb3c5 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WithReaderWriterArgs.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WithReaderWriterArgs.java
@@ -18,6 +18,9 @@
*/
package org.apache.plc4x.java.spi.generation;
+import java.util.Optional;
+import java.util.stream.Stream;
+
public interface WithReaderWriterArgs extends WithReaderArgs, WithWriterArgs {
static WithReaderWriterArgs WithRenderAsList(boolean renderAsList) {
@@ -28,6 +31,30 @@ public interface WithReaderWriterArgs extends WithReaderArgs, WithWriterArgs {
return (withAdditionalStringRepresentation) () -> stringRepresentation;
}
+ static WithReaderWriterArgs WithEncoding(String encoding) {
+ return (withEncoding) () -> encoding;
+ }
+
+ static WithReaderWriterArgs WithNullBytesHex(String nullBytesHex) {
+ return (withNullBytesHex) () -> nullBytesHex;
+ }
+
+ default Optional<String> extractNullBytesHex(WithReaderArgs... readerArgs) {
+ return extractNullBytesHex(Stream.of(readerArgs).map(WithReaderWriterArgs.class::cast).toArray(WithReaderWriterArgs[]::new));
+ }
+
+ default Optional<String> extractNullBytesHex(WithWriterArgs... writerArgs) {
+ return extractNullBytesHex(Stream.of(writerArgs).map(WithReaderWriterArgs.class::cast).toArray(WithReaderWriterArgs[]::new));
+ }
+ default Optional<String> extractNullBytesHex(WithReaderWriterArgs... readerWriterArgs) {
+ for (WithReaderWriterArgs arg : readerWriterArgs) {
+ if (arg instanceof withNullBytesHex) {
+ return Optional.of(((withNullBytesHex) arg).nullBytesHex());
+ }
+ }
+ return Optional.empty();
+ }
+
}
interface withRenderAsList extends WithReaderWriterArgs {
@@ -37,3 +64,12 @@ interface withRenderAsList extends WithReaderWriterArgs {
interface withAdditionalStringRepresentation extends WithReaderWriterArgs {
String stringRepresentation();
}
+
+interface withEncoding extends WithReaderWriterArgs {
+ String encoding();
+}
+
+interface withNullBytesHex extends WithReaderWriterArgs {
+
+ String nullBytesHex();
+}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
index 531592ff42..0a6f09ee91 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBuffer.java
@@ -32,14 +32,14 @@ public interface WriteBuffer extends ByteOrderAware, PositionAware {
void writeBit(String logicalName, boolean value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeBit(boolean value) throws SerializationException {
- writeBit("", value);
+ default void writeBit(boolean value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeBit("", value, writerArgs);
}
void writeByte(String logicalName, byte value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeByte(byte value) throws SerializationException {
- writeByte("", value);
+ default void writeByte(byte value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeByte("", value, writerArgs);
}
void writeByteArray(String logicalName, byte[] bytes, WithWriterArgs... writerArgs) throws SerializationException;
@@ -50,90 +50,90 @@ public interface WriteBuffer extends ByteOrderAware, PositionAware {
void writeUnsignedByte(String logicalName, int bitLength, byte value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeUnsignedByte(int bitLength, byte value) throws SerializationException {
- writeUnsignedByte("", bitLength, value);
+ default void writeUnsignedByte(int bitLength, byte value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeUnsignedByte("", bitLength, value, writerArgs);
}
void writeUnsignedShort(String logicalName, int bitLength, short value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeUnsignedShort(int bitLength, short value) throws SerializationException {
- writeUnsignedShort("", bitLength, value);
+ default void writeUnsignedShort(int bitLength, short value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeUnsignedShort("", bitLength, value, writerArgs);
}
void writeUnsignedInt(String logicalName, int bitLength, int value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeUnsignedInt(int bitLength, int value) throws SerializationException {
- writeUnsignedInt("", bitLength, value);
+ default void writeUnsignedInt(int bitLength, int value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeUnsignedInt("", bitLength, value, writerArgs);
}
void writeUnsignedLong(String logicalName, int bitLength, long value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeUnsignedLong(int bitLength, long value) throws SerializationException {
- writeUnsignedLong("", bitLength, value);
+ default void writeUnsignedLong(int bitLength, long value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeUnsignedLong("", bitLength, value, writerArgs);
}
void writeUnsignedBigInteger(String logicalName, int bitLength, BigInteger value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeUnsignedBigInteger(int bitLength, BigInteger value) throws SerializationException {
- writeUnsignedBigInteger("", bitLength, value);
+ default void writeUnsignedBigInteger(int bitLength, BigInteger value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeUnsignedBigInteger("", bitLength, value, writerArgs);
}
void writeSignedByte(String logicalName, int bitLength, byte value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeSignedByte(int bitLength, byte value) throws SerializationException {
- writeSignedByte("", bitLength, value);
+ default void writeSignedByte(int bitLength, byte value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeSignedByte("", bitLength, value, writerArgs);
}
void writeShort(String logicalName, int bitLength, short value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeShort(int bitLength, short value) throws SerializationException {
- writeShort("", bitLength, value);
+ default void writeShort(int bitLength, short value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeShort("", bitLength, value, writerArgs);
}
void writeInt(String logicalName, int bitLength, int value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeInt(int bitLength, int value) throws SerializationException {
- writeInt("", bitLength, value);
+ default void writeInt(int bitLength, int value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeInt("", bitLength, value, writerArgs);
}
void writeLong(String logicalName, int bitLength, long value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeLong(int bitLength, long value) throws SerializationException {
- writeLong("", bitLength, value);
+ default void writeLong(int bitLength, long value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeLong("", bitLength, value, writerArgs);
}
void writeBigInteger(String logicalName, int bitLength, BigInteger value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeBigInteger(int bitLength, BigInteger value) throws SerializationException {
- writeBigInteger("", bitLength, value);
+ default void writeBigInteger(int bitLength, BigInteger value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeBigInteger("", bitLength, value, writerArgs);
}
void writeFloat(String logicalName, int bitLength, float value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeFloat(int bitLength, float value) throws SerializationException {
- writeFloat("", bitLength, value);
+ default void writeFloat(int bitLength, float value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeFloat("", bitLength, value, writerArgs);
}
void writeDouble(String logicalName, int bitLength, double value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeDouble(int bitLength, double value) throws SerializationException {
- writeDouble("", bitLength, value);
+ default void writeDouble(int bitLength, double value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeDouble("", bitLength, value, writerArgs);
}
void writeBigDecimal(String logicalName, int bitLength, BigDecimal value, WithWriterArgs... writerArgs) throws SerializationException;
- default void writeBigDecimal(int bitLength, BigDecimal value) throws SerializationException {
- writeBigDecimal("", bitLength, value);
+ default void writeBigDecimal(int bitLength, BigDecimal value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeBigDecimal("", bitLength, value, writerArgs);
}
- void writeString(String logicalName, int bitLength, String encoding, String value, WithWriterArgs... writerArgs) throws SerializationException;
+ void writeString(String logicalName, int bitLength, String value, WithWriterArgs... writerArgs) throws SerializationException;
default void writeVirtual(String logicalName, Object value, WithWriterArgs... writerArgs) throws SerializationException {
// No-Op
}
- default void writeString(int bitLength, String encoding, String value) throws SerializationException {
- writeString("", bitLength, encoding, value);
+ default void writeString(int bitLength, String value, WithWriterArgs... writerArgs) throws SerializationException {
+ writeString("", bitLength, value, writerArgs);
}
/**
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java
index 96a5e9d1b9..113de7ddf9 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferBoxBased.java
@@ -198,7 +198,7 @@ public class WriteBufferBoxBased implements WriteBuffer, BufferCommons {
}
@Override
- public void writeString(String logicalName, int bitLength, String encoding, String value, WithWriterArgs... writerArgs) throws SerializationException {
+ public void writeString(String logicalName, int bitLength, String value, WithWriterArgs... writerArgs) throws SerializationException {
String additionalStringRepresentation = extractAdditionalStringRepresentation(writerArgs).map(s -> " " + s).orElse("");
boxes.offerLast(Either.left(asciiBoxWriter.boxString(logicalName, String.format("%s%s", value, additionalStringRepresentation), 0)));
move(bitLength);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferByteBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferByteBased.java
index 08ef5345dd..38dba9c549 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferByteBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferByteBased.java
@@ -20,19 +20,15 @@ package org.apache.plc4x.java.spi.generation;
import com.github.jinahya.bit.io.BufferByteOutput;
import org.apache.commons.lang3.ArrayUtils;
-import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.spi.generation.io.MyDefaultBitOutput;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
-import static org.apache.commons.lang3.ArrayUtils.subarray;
-
-public class WriteBufferByteBased implements WriteBuffer {
+public class WriteBufferByteBased implements WriteBuffer, BufferCommons {
private final ByteBuffer bb;
private final MyDefaultBitOutput bo;
@@ -128,7 +124,29 @@ public class WriteBufferByteBased implements WriteBuffer {
throw new SerializationException("unsigned short can only contain max 16 bits");
}
try {
- bo.writeShort(true, bitLength, value);
+ String encoding = extractEncoding(writerArgs).orElse("default");
+ switch (encoding) {
+ case "ASCII":
+ // AsciiUint can only decode values that have a multiple of 8 length.
+ if (bitLength % 8 != 0) {
+ throw new SerializationException("'ASCII' encoded fields must have a length that is a multiple of 8 bits long");
+ }
+ int charLen = bitLength / 8;
+ int maxValue = (int) (Math.pow(10, charLen) - 1);
+ if (value > maxValue) {
+ throw new SerializationException("Provided value of " + value + " exceeds the max value of " + maxValue);
+ }
+ String stringValue = String.format("%0" + charLen + "d", value);
+ for (byte curByte : stringValue.getBytes(StandardCharsets.US_ASCII)) {
+ bo.writeByte(false, 8, curByte);
+ }
+ break;
+ case "default":
+ bo.writeShort(true, bitLength, value);
+ break;
+ default:
+ throw new SerializationException("unsupported encoding '" + encoding + "'");
+ }
} catch (IOException e) {
throw new SerializationException("Error writing unsigned short", e);
}
@@ -143,10 +161,32 @@ public class WriteBufferByteBased implements WriteBuffer {
throw new SerializationException("unsigned int can only contain max 32 bits");
}
try {
- if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
- value = Integer.reverseBytes(value) >> 16;
+ String encoding = extractEncoding(writerArgs).orElse("default");
+ switch (encoding) {
+ case "ASCII":
+ // AsciiUint can only decode values that have a multiple of 8 length.
+ if (bitLength % 8 != 0) {
+ throw new SerializationException("'ASCII' encoded fields must have a length that is a multiple of 8 bits long");
+ }
+ int charLen = bitLength / 8;
+ int maxValue = (int) (Math.pow(10, charLen) - 1);
+ if (value > maxValue) {
+ throw new SerializationException("Provided value of " + value + " exceeds the max value of " + maxValue);
+ }
+ String stringValue = String.format("%0" + charLen + "d", value);
+ for (byte curByte : stringValue.getBytes(StandardCharsets.US_ASCII)) {
+ bo.writeByte(false, 8, curByte);
+ }
+ break;
+ case "default":
+ if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
+ value = Integer.reverseBytes(value) >> 16;
+ }
+ bo.writeInt(true, bitLength, value);
+ break;
+ default:
+ throw new SerializationException("unsupported encoding '" + encoding + "'");
}
- bo.writeInt(true, bitLength, value);
} catch (IOException e) {
throw new SerializationException("Error writing unsigned int", e);
}
@@ -161,10 +201,32 @@ public class WriteBufferByteBased implements WriteBuffer {
throw new SerializationException("unsigned long can only contain max 63 bits");
}
try {
- if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
- value = Long.reverseBytes(value) >> 32;
+ String encoding = extractEncoding(writerArgs).orElse("default");
+ switch (encoding) {
+ case "ASCII":
+ // AsciiUint can only decode values that have a multiple of 8 length.
+ if (bitLength % 8 != 0) {
+ throw new SerializationException("'ASCII' encoded fields must have a length that is a multiple of 8 bits long");
+ }
+ int charLen = bitLength / 8;
+ int maxValue = (int) (Math.pow(10, charLen) - 1);
+ if (value > maxValue) {
+ throw new SerializationException("Provided value of " + value + " exceeds the max value of " + maxValue);
+ }
+ String stringValue = String.format("%0" + charLen + "d", value);
+ for (byte curByte : stringValue.getBytes(StandardCharsets.US_ASCII)) {
+ bo.writeByte(false, 8, curByte);
+ }
+ break;
+ case "default":
+ if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
+ value = Long.reverseBytes(value) >> 32;
+ }
+ bo.writeLong(true, bitLength, value);
+ break;
+ default:
+ throw new SerializationException("unsupported encoding '" + encoding + "'");
}
- bo.writeLong(true, bitLength, value);
} catch (IOException e) {
throw new SerializationException("Error writing unsigned long", e);
}
@@ -309,10 +371,15 @@ public class WriteBufferByteBased implements WriteBuffer {
* 0-termination.
*/
@Override
- public void writeString(String logicalName, int bitLength, String encoding, String value, WithWriterArgs... writerArgs) throws SerializationException {
+ public void writeString(String logicalName, int bitLength, String value, WithWriterArgs... writerArgs) throws SerializationException {
byte[] bytes;
+ String encoding = extractEncoding(writerArgs).orElse("UTF-8");
encoding = encoding.replaceAll("[^a-zA-Z0-9]", "");
switch (encoding.toUpperCase()) {
+ case "ASCII": {
+ bytes = value.getBytes(StandardCharsets.US_ASCII);
+ break;
+ }
case "UTF8": {
bytes = value.getBytes(StandardCharsets.UTF_8);
break;
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferJsonBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferJsonBased.java
index e6f304f532..f6b39c58b2 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferJsonBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferJsonBased.java
@@ -263,7 +263,8 @@ public class WriteBufferJsonBased implements WriteBuffer, BufferCommons, AutoClo
}
@Override
- public void writeString(String logicalName, int bitLength, String encoding, String value, WithWriterArgs... writerArgs) throws SerializationException {
+ public void writeString(String logicalName, int bitLength, String value, WithWriterArgs... writerArgs) throws SerializationException {
+ String encoding = extractEncoding(writerArgs).orElse("UTF-8");
final String sanitizedLogicalName = sanitizeLogicalName(logicalName);
wrapIfNecessary(() -> {
writeAttr(sanitizedLogicalName, rwStringKey, bitLength, writerArgs);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferXmlBased.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferXmlBased.java
index 2e5ca6cdb1..19c080bab9 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferXmlBased.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/generation/WriteBufferXmlBased.java
@@ -201,7 +201,8 @@ public class WriteBufferXmlBased implements WriteBuffer, BufferCommons {
}
@Override
- public void writeString(String logicalName, int bitLength, String encoding, String value, WithWriterArgs... writerArgs) throws SerializationException {
+ public void writeString(String logicalName, int bitLength, String value, WithWriterArgs... writerArgs) throws SerializationException {
+ String encoding = extractEncoding(writerArgs).orElse("UTF-8");
String cleanedUpString = StringUtils.trimToEmpty(value).replaceAll("[^\u0009\r\n\u0020-\uD7FF\uE000-\uFFFD\ud800\udc00-\udbff\udfff]", "");
createAndAppend(logicalName, rwStringKey, bitLength, cleanedUpString, encoding, writerArgs);
move(bitLength);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java
index 4efb6dcd16..f11a551912 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultListPlcBrowseItem.java
@@ -22,16 +22,13 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.messages.PlcBrowseItem;
-import org.apache.plc4x.java.api.messages.PlcBrowseItemArrayInfo;
-import org.apache.plc4x.java.api.model.ArrayInfo;
import org.apache.plc4x.java.api.model.PlcTag;
-import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import java.nio.charset.StandardCharsets;
-import java.util.List;
import java.util.Map;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className")
@@ -51,8 +48,12 @@ public class DefaultListPlcBrowseItem extends DefaultPlcBrowseItem {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
writeBuffer.pushContext(getClass().getSimpleName());
- writeBuffer.writeString("address", getTag().getAddressString().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), getTag().getAddressString());
- writeBuffer.writeString("name", getName().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), getName());
+ writeBuffer.writeString("address",
+ getTag().getAddressString().getBytes(StandardCharsets.UTF_8).length * 8,
+ getTag().getAddressString(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
+ writeBuffer.writeString("name",
+ getName().getBytes(StandardCharsets.UTF_8).length * 8,
+ getName(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
// TODO: Find out how to serialize an enum.
//writeBuffer.writeString("dataType", dataType.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), dataType);
if(getChildren() != null && !getChildren().isEmpty()) {
@@ -68,7 +69,9 @@ public class DefaultListPlcBrowseItem extends DefaultPlcBrowseItem {
writeBuffer.pushContext("options");
for (Map.Entry<String, PlcValue> optionEntry : getOptions().entrySet()) {
writeBuffer.pushContext("option");
- writeBuffer.writeString("name", optionEntry.getKey().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), optionEntry.getKey());
+ writeBuffer.writeString("name",
+ optionEntry.getKey().getBytes(StandardCharsets.UTF_8).length * 8,
+ optionEntry.getKey(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
// TODO: Find out how to serialize a PlcValue
//writeBuffer.writeString("value", optionEntry.getValue().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), optionEntry.getValue());
((DefaultListPlcBrowseItem) optionEntry).serialize(writeBuffer);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java
index e970450cc3..0f8a78d0d4 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcBrowseItem.java
@@ -23,8 +23,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.messages.PlcBrowseItem;
import org.apache.plc4x.java.api.model.PlcTag;
-import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.utils.Serializable;
@@ -99,8 +99,12 @@ public class DefaultPlcBrowseItem implements PlcBrowseItem, Serializable {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
writeBuffer.pushContext(getClass().getSimpleName());
- writeBuffer.writeString("address", tag.getAddressString().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), tag.getAddressString());
- writeBuffer.writeString("name", name.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), name);
+ writeBuffer.writeString("address",
+ tag.getAddressString().getBytes(StandardCharsets.UTF_8).length * 8,
+ tag.getAddressString(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
+ writeBuffer.writeString("name",
+ name.getBytes(StandardCharsets.UTF_8).length * 8,
+ name, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
// TODO: Find out how to serialize an enum.
//writeBuffer.writeString("dataType", dataType.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), dataType);
if(children != null && !children.isEmpty()) {
@@ -116,7 +120,9 @@ public class DefaultPlcBrowseItem implements PlcBrowseItem, Serializable {
writeBuffer.pushContext("options");
for (Map.Entry<String, PlcValue> optionEntry : options.entrySet()) {
writeBuffer.pushContext("option");
- writeBuffer.writeString("name", optionEntry.getKey().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), optionEntry.getKey());
+ writeBuffer.writeString("name",
+ optionEntry.getKey().getBytes(StandardCharsets.UTF_8).length * 8,
+ optionEntry.getKey(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
// TODO: Find out how to serialize a PlcValue
//writeBuffer.writeString("value", optionEntry.getValue().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), optionEntry.getValue());
((DefaultPlcBrowseItem) optionEntry).serialize(writeBuffer);
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcDiscoveryItem.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcDiscoveryItem.java
index 874d7b8ca9..88091db54d 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcDiscoveryItem.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcDiscoveryItem.java
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.messages.PlcDiscoveryItem;
import org.apache.plc4x.java.api.value.PlcValue;
-import org.apache.plc4x.java.spi.generation.ParseException;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.utils.Serializable;
@@ -110,21 +110,33 @@ public class DefaultPlcDiscoveryItem implements PlcDiscoveryItem, Serializable {
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
writeBuffer.pushContext(getClass().getSimpleName());
- writeBuffer.writeString("protocolCode", protocolCode.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), protocolCode);
- writeBuffer.writeString("transportCode", transportCode.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), transportCode);
- writeBuffer.writeString("transportUrl", transportUrl.toString().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), transportUrl.toString());
+ writeBuffer.writeString("protocolCode",
+ protocolCode.getBytes(StandardCharsets.UTF_8).length * 8,
+ protocolCode, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
+ writeBuffer.writeString("transportCode",
+ transportCode.getBytes(StandardCharsets.UTF_8).length * 8,
+ transportCode, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
+ writeBuffer.writeString("transportUrl",
+ transportUrl.toString().getBytes(StandardCharsets.UTF_8).length * 8,
+ transportUrl.toString(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
if(options != null && !options.isEmpty()) {
writeBuffer.pushContext("options");
for (Map.Entry<String, String> optionEntry : options.entrySet()) {
writeBuffer.pushContext("option");
- writeBuffer.writeString("name", optionEntry.getKey().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), optionEntry.getKey());
- writeBuffer.writeString("value", optionEntry.getValue().getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), optionEntry.getValue());
+ writeBuffer.writeString("name",
+ optionEntry.getKey().getBytes(StandardCharsets.UTF_8).length * 8,
+ optionEntry.getKey(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
+ writeBuffer.writeString("value",
+ optionEntry.getValue().getBytes(StandardCharsets.UTF_8).length * 8,
+ optionEntry.getValue(), WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
writeBuffer.popContext("option");
}
writeBuffer.popContext("options");
}
if(name != null && !name.isEmpty()) {
- writeBuffer.writeString("name", name.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), name);
+ writeBuffer.writeString("name",
+ name.getBytes(StandardCharsets.UTF_8).length * 8,
+ name, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
writeBuffer.popContext(getClass().getSimpleName());
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteRequest.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteRequest.java
index 328a898743..2a5b2953e4 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteRequest.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteRequest.java
@@ -27,6 +27,7 @@ import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.messages.PlcWriteRequest;
import org.apache.plc4x.java.api.messages.PlcWriteResponse;
import org.apache.plc4x.java.api.model.PlcTag;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.utils.Serializable;
@@ -136,11 +137,15 @@ public class DefaultPlcWriteRequest implements PlcWriteRequest, Serializable {
PlcList list = (PlcList) value;
for (PlcValue plcValue : list.getList()) {
String plcValueString = plcValue.getString();
- writeBuffer.writeString("value", plcValueString.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), plcValueString);
+ writeBuffer.writeString("value",
+ plcValueString.getBytes(StandardCharsets.UTF_8).length * 8,
+ plcValueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
} else {
String plcValueString = value.getString();
- writeBuffer.writeString("value", plcValueString.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), plcValueString);
+ writeBuffer.writeString("value",
+ plcValueString.getBytes(StandardCharsets.UTF_8).length * 8,
+ plcValueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
writeBuffer.popContext(tagName);
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteResponse.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteResponse.java
index 31649a14ee..7ddcda197c 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteResponse.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/DefaultPlcWriteResponse.java
@@ -26,6 +26,7 @@ import org.apache.plc4x.java.api.messages.PlcWriteRequest;
import org.apache.plc4x.java.api.messages.PlcWriteResponse;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.types.PlcResponseCode;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.utils.Serializable;
@@ -82,7 +83,9 @@ public class DefaultPlcWriteResponse implements PlcWriteResponse, Serializable {
String tagName = tagEntry.getKey();
final PlcResponseCode tagResponseCode = tagEntry.getValue();
String result = tagResponseCode.name();
- writeBuffer.writeString(tagName, result.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), result);
+ writeBuffer.writeString(tagName,
+ result.getBytes(StandardCharsets.UTF_8).length * 8,
+ result, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
writeBuffer.popContext("tags");
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/utils/ResponseItem.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/utils/ResponseItem.java
index d798afe293..e1dbd6e564 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/utils/ResponseItem.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/messages/utils/ResponseItem.java
@@ -19,6 +19,7 @@
package org.apache.plc4x.java.spi.messages.utils;
import org.apache.plc4x.java.api.types.PlcResponseCode;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
import org.apache.plc4x.java.spi.utils.Serializable;
@@ -47,7 +48,9 @@ public class ResponseItem<T> implements Serializable {
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
writeBuffer.pushContext("ResponseItem");
String codeName = code.name();
- writeBuffer.writeString("result", codeName.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), codeName);
+ writeBuffer.writeString("result",
+ codeName.getBytes(StandardCharsets.UTF_8).length * 8,
+ codeName, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
if (value != null) {
if (!(value instanceof Serializable)) {
throw new RuntimeException("Error serializing. Tag value doesn't implement XmlSerializable");
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java
index 87f0ccfba6..54da8290b8 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcCHAR.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -336,7 +337,9 @@ public class PlcCHAR extends PlcIECValue<Short> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), 16, StandardCharsets.UTF_8.name(), valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ 16,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE.java
index 2a0560a5df..b19e143541 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -141,7 +142,9 @@ public class PlcDATE extends PlcSimpleValue<LocalDate> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length * 8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE_AND_TIME.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE_AND_TIME.java
index df224ad99b..03863dd3b0 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE_AND_TIME.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcDATE_AND_TIME.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -177,7 +178,9 @@ public class PlcDATE_AND_TIME extends PlcSimpleValue<LocalDateTime> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcIECValue.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcIECValue.java
index 1de59251ff..b9f136146c 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcIECValue.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcIECValue.java
@@ -20,6 +20,7 @@ package org.apache.plc4x.java.spi.values;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -82,7 +83,9 @@ public abstract class PlcIECValue<T> extends PlcValueAdapter {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE.java
index 5a25a8b498..21ecfb435b 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -117,7 +118,9 @@ public class PlcLDATE extends PlcSimpleValue<LocalDate> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length * 8, StandardCharsets.UTF_8.name(), valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length * 8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE_AND_TIME.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE_AND_TIME.java
index ad6a981edf..13301ee69f 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE_AND_TIME.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLDATE_AND_TIME.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -141,7 +142,9 @@ public class PlcLDATE_AND_TIME extends PlcSimpleValue<LocalDateTime> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME.java
index fbf4adc3ac..60502992ce 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -142,7 +143,9 @@ public class PlcLTIME extends PlcSimpleValue<Duration> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME_OF_DAY.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME_OF_DAY.java
index e7de0dcb39..192ebb73a7 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME_OF_DAY.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcLTIME_OF_DAY.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -119,7 +120,9 @@ public class PlcLTIME_OF_DAY extends PlcSimpleValue<LocalTime> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSTRING.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSTRING.java
index d01fe44319..c4f3420b3a 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSTRING.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcSTRING.java
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -233,7 +234,9 @@ public class PlcSTRING extends PlcSimpleValue<String> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value;
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME.java
index 6460936e4d..23fb48004e 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -118,7 +119,9 @@ public class PlcTIME extends PlcSimpleValue<Duration> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME_OF_DAY.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME_OF_DAY.java
index 48c800de96..17aae62d54 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME_OF_DAY.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcTIME_OF_DAY.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -108,7 +109,9 @@ public class PlcTIME_OF_DAY extends PlcSimpleValue<LocalTime> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_8).length*8,StandardCharsets.UTF_8.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_8).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java
index 1745302654..927cc2b348 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWCHAR.java
@@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -312,7 +313,9 @@ public class PlcWCHAR extends PlcIECValue<Integer> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value.toString();
- writeBuffer.writeString(getClass().getSimpleName(), 16, StandardCharsets.UTF_8.name(), valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ 16,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWSTRING.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWSTRING.java
index 2cf0b07147..a062985f8b 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWSTRING.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/values/PlcWSTRING.java
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -233,7 +234,9 @@ public class PlcWSTRING extends PlcSimpleValue<String> {
@Override
public void serialize(WriteBuffer writeBuffer) throws SerializationException {
String valueString = value;
- writeBuffer.writeString(getClass().getSimpleName(), valueString.getBytes(StandardCharsets.UTF_16).length*8,StandardCharsets.UTF_16.name(),valueString);
+ writeBuffer.writeString(getClass().getSimpleName(),
+ valueString.getBytes(StandardCharsets.UTF_16).length*8,
+ valueString, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
}
}
diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/ReadBufferTest.java b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/ReadBufferTest.java
index aeb6d60a4b..798f2ee220 100644
--- a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/ReadBufferTest.java
+++ b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/ReadBufferTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.plc4x.java.spi.generation;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.junit.jupiter.api.Test;
import java.nio.charset.StandardCharsets;
@@ -31,9 +32,9 @@ class ReadBufferTest {
*/
@Test
void readString() throws ParseException {
- String value = new String("abcdef");
+ String value = "abcdef";
final ReadBuffer buffer = new ReadBufferByteBased(value.getBytes(StandardCharsets.UTF_8));
- String answer = buffer.readString("", value.length() * 8, "UTF-8");
+ String answer = buffer.readString("", value.length() * 8, WithOption.WithEncoding(StandardCharsets.UTF_8.name()));
assertEquals(value, answer);
}
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java
index b82eeafa4d..ac206a32d1 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectRequest.java
@@ -64,7 +64,10 @@ public class Plc4xConnectRequest extends Plc4xMessage implements Message {
// implicitly given by the objects content)
short connectionStringLen = (short) (STR_LEN(getConnectionString()));
writeImplicitField(
- "connectionStringLen", connectionStringLen, writeUnsignedShort(writeBuffer, 8));
+ "connectionStringLen",
+ connectionStringLen,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (connectionString)
writeSimpleField(
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java
index 32341a22c4..37917e9bbb 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xConnectResponse.java
@@ -81,7 +81,8 @@ public class Plc4xConnectResponse extends Plc4xMessage implements Message {
new DataWriterEnumDefault<>(
Plc4xResponseCode::getValue,
Plc4xResponseCode::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xConnectResponse");
}
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java
index 010af57d63..e3d1814fd6 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xMessage.java
@@ -68,12 +68,20 @@ public abstract class Plc4xMessage implements Message {
writeBuffer.pushContext("Plc4xMessage");
// Const Field (version)
- writeConstField("version", VERSION, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "version",
+ VERSION,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (packetLength) (Used for parsing, but its value is not stored as it's
// implicitly given by the objects content)
int packetLength = (int) (getLengthInBytes());
- writeImplicitField("packetLength", packetLength, writeUnsignedInt(writeBuffer, 16));
+ writeImplicitField(
+ "packetLength",
+ packetLength,
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Simple Field (requestId)
writeSimpleField(
@@ -88,9 +96,8 @@ public abstract class Plc4xMessage implements Message {
"Plc4xRequestType",
getRequestType(),
new DataWriterEnumDefault<>(
- Plc4xRequestType::getValue,
- Plc4xRequestType::name,
- writeUnsignedShort(writeBuffer, 8)));
+ Plc4xRequestType::getValue, Plc4xRequestType::name, writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Switch field (Serialize the sub-type)
serializePlc4xMessageChild(writeBuffer);
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java
index 443aa5a648..d187cc2306 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadRequest.java
@@ -76,10 +76,15 @@ public class Plc4xReadRequest extends Plc4xMessage implements Message {
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xReadRequest");
}
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java
index 2450c624c0..102969aaa2 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xReadResponse.java
@@ -91,15 +91,21 @@ public class Plc4xReadResponse extends Plc4xMessage implements Message {
new DataWriterEnumDefault<>(
Plc4xResponseCode::getValue,
Plc4xResponseCode::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xReadResponse");
}
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java
index ddbf9c4849..6d856ea448 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xValue.java
@@ -24,6 +24,7 @@ import java.math.BigInteger;
import java.time.*;
import java.util.*;
import org.apache.plc4x.java.api.value.*;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.java.spi.generation.EvaluationHelper;
import org.apache.plc4x.java.spi.generation.ParseException;
@@ -148,14 +149,14 @@ public class Plc4xValue {
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 8, "UTF-8");
+ readBuffer.readString("", 8, WithOption.WithEncoding("UTF-8"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.WCHAR)) { // STRING
// Simple Field (value)
String value = /*TODO: migrate me*/ /*TODO: migrate me*/
- readBuffer.readString("", 16, "UTF-16");
+ readBuffer.readString("", 16, WithOption.WithEncoding("UTF-16"));
return new PlcSTRING(value);
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.TIME)) { // TIME
@@ -316,12 +317,14 @@ public class Plc4xValue {
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 8, "UTF-8", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 8, (String) (value), WithOption.WithEncoding("UTF-8"));
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.WCHAR)) { // STRING
// Simple Field (value)
String value = (String) _value.getString();
/*TODO: migrate me*/
- /*TODO: migrate me*/ writeBuffer.writeString("", 16, "UTF-16", (String) (value));
+ /*TODO: migrate me*/ writeBuffer.writeString(
+ "", 16, (String) (value), WithOption.WithEncoding("UTF-16"));
} else if (EvaluationHelper.equals(valueType, Plc4xValueType.TIME)) { // TIME
// Simple Field (milliseconds)
long milliseconds = (long) _value.getLong();
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java
index ad2f647deb..33354b88fd 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteRequest.java
@@ -76,10 +76,15 @@ public class Plc4xWriteRequest extends Plc4xMessage implements Message {
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xWriteRequest");
}
diff --git a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java
index 1b02f9fac4..4e52abc1b8 100644
--- a/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java
+++ b/plc4j/tools/plc4x-server/src/main/generated/org/apache/plc4x/java/plc4x/readwrite/Plc4xWriteResponse.java
@@ -91,15 +91,21 @@ public class Plc4xWriteResponse extends Plc4xMessage implements Message {
new DataWriterEnumDefault<>(
Plc4xResponseCode::getValue,
Plc4xResponseCode::name,
- writeUnsignedShort(writeBuffer, 8)));
+ writeUnsignedShort(writeBuffer, 8)),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Implicit Field (numTags) (Used for parsing, but its value is not stored as it's implicitly
// given by the objects content)
short numTags = (short) (COUNT(getTags()));
- writeImplicitField("numTags", numTags, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "numTags",
+ numTags,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Array Field (tags)
- writeComplexTypeArrayField("tags", tags, writeBuffer);
+ writeComplexTypeArrayField(
+ "tags", tags, writeBuffer, WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("Plc4xWriteResponse");
}
diff --git a/plc4j/transports/socketcan/src/main/generated/org/apache/plc4x/java/socketcan/readwrite/SocketCANFrame.java b/plc4j/transports/socketcan/src/main/generated/org/apache/plc4x/java/socketcan/readwrite/SocketCANFrame.java
index a9df575cc9..9bdc83c1b3 100644
--- a/plc4j/transports/socketcan/src/main/generated/org/apache/plc4x/java/socketcan/readwrite/SocketCANFrame.java
+++ b/plc4j/transports/socketcan/src/main/generated/org/apache/plc4x/java/socketcan/readwrite/SocketCANFrame.java
@@ -110,32 +110,47 @@ public class SocketCANFrame implements Message {
// Implicit Field (size) (Used for parsing, but its value is not stored as it's implicitly given
// by the objects content)
short size = (short) (COUNT(getData()));
- writeImplicitField("size", size, writeUnsignedShort(writeBuffer, 8));
+ writeImplicitField(
+ "size",
+ size,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField0 != null ? reservedField0 : (short) 0x0,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField1 != null ? reservedField1 : (short) 0x0,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Reserved Field (reserved)
writeReservedField(
"reserved",
reservedField2 != null ? reservedField2 : (short) 0x0,
- writeUnsignedShort(writeBuffer, 8));
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Array Field (data)
- writeByteArrayField("data", data, writeByteArray(writeBuffer, 8));
+ writeByteArrayField(
+ "data",
+ data,
+ writeByteArray(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
// Padding Field (padding)
writePaddingField(
- "padding", (int) ((8) - ((COUNT(data)))), (short) 0x00, writeUnsignedShort(writeBuffer, 8));
+ "padding",
+ (int) ((8) - ((COUNT(data)))),
+ (short) 0x00,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.LITTLE_ENDIAN));
writeBuffer.popContext("SocketCANFrame");
}
diff --git a/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/java/s7/utils/StaticHelper.java b/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/java/s7/utils/StaticHelper.java
index 5f70844b9f..8311201903 100644
--- a/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/java/s7/utils/StaticHelper.java
+++ b/plc4j/utils/plc-simulator/src/main/java/org/apache/plc4x/java/s7/utils/StaticHelper.java
@@ -20,6 +20,7 @@ package org.apache.plc4x.java.s7.utils;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.java.spi.codegen.WithOption;
import org.apache.plc4x.java.spi.generation.ParseException;
import org.apache.plc4x.java.spi.generation.ReadBuffer;
import org.apache.plc4x.java.spi.generation.WriteBuffer;
@@ -124,7 +125,7 @@ public class StaticHelper {
// This is the total length of the string on the PLC (Not necessarily the number of characters read)
short totalStringLength = io.readShort(8);
// Read the full size of the string.
- String str = io.readString(stringLength * 8, (String) encoding);
+ String str = io.readString(stringLength * 8, WithOption.WithEncoding((String) encoding));
// Cut off the parts that don't belong to it.
return str.substring(0, totalStringLength);
} catch (ParseException e) {
@@ -139,7 +140,7 @@ public class StaticHelper {
public static String parseS7Char(ReadBuffer io, Object encoding) throws ParseException {
// Read the full size of the string.
- return io.readString(8, (String) encoding);
+ return io.readString(8, WithOption.WithEncoding((String) encoding));
}
public static void serializeS7Char(WriteBuffer io, PlcValue value, Object encoding) {
diff --git a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/migration/MessageResolver.java b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/migration/MessageResolver.java
index b7f742db31..94fb952a4c 100644
--- a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/migration/MessageResolver.java
+++ b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/migration/MessageResolver.java
@@ -130,7 +130,7 @@ public class MessageResolver {
} catch (RuntimeException e) {
throw new DriverTestsuiteException("Invalid or non existent package detected: " + driverPackage, e);
}
- String ioRootClassName = driverPackage + "." + typeName;
+ String ioRootClassName = driverPackage.replace("-", "") + "." + typeName;
// make sure both type and it's IO are present
Class<? extends Message> messageType = (Class<? extends Message>) Class.forName(ioRootClassName);
Method staticParse = messageType.getMethod("staticParse", ReadBuffer.class, Object[].class);
diff --git a/pom.xml b/pom.xml
index 1369f7189f..2eba5fcde7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -99,7 +99,7 @@
<sonar.cfamily.threads>1</sonar.cfamily.threads>
<sonar.cfamily.cache.enabled>false</sonar.cfamily.cache.enabled>
- <plc4x-code-generation.version>1.6.0</plc4x-code-generation.version>
+ <plc4x-code-generation.version>1.7.0-SNAPSHOT</plc4x-code-generation.version>
<antlr.version>4.11.1</antlr.version>
<apiguardian.version>1.1.2</apiguardian.version>
@@ -759,7 +759,7 @@
<!-- JEVN local version files -->
<exclude>**/.java-version</exclude>
- <!-- Asciidoctor generated files -->
+ <!-- ASCIIdoctor generated files -->
<exclude>**/.asciidoctor/**</exclude>
<!-- Jenkins build related files -->
diff --git a/protocols/open-protocol/pom.xml b/protocols/open-protocol/pom.xml
index 6ba8760a00..761a8928ef 100644
--- a/protocols/open-protocol/pom.xml
+++ b/protocols/open-protocol/pom.xml
@@ -38,6 +38,12 @@
<artifactId>plc4x-code-generation-protocol-base-mspec</artifactId>
<version>0.11.0-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
diff --git a/protocols/open-protocol/src/main/resources/protocols/openprotocol/open-protocol.mspec b/protocols/open-protocol/src/main/resources/protocols/openprotocol/open-protocol.mspec
index 91234ac3ed..af6fc4c652 100644
--- a/protocols/open-protocol/src/main/resources/protocols/openprotocol/open-protocol.mspec
+++ b/protocols/open-protocol/src/main/resources/protocols/openprotocol/open-protocol.mspec
@@ -24,110 +24,110 @@
[const uint 16 tcpDefaultPort 4545]
]
-[discriminatedType OpenProtocolMessage
- [implicit uint 32 length 'lengthInBytes' encoding='"AsciiUint"']
- [discriminator Mid mid ]
- [simple OpenProtocolRevision revision ]
- [simple uint 8 noAckFlag ]
- [simple uint 16 stationId encoding='"AsciiUint"']
- [simple uint 16 spindleId encoding='"AsciiUint"']
- [simple uint 16 sequenceNumber encoding='"AsciiUint"']
- [simple uint 8 numberOfMessageParts encoding='"AsciiUint"']
- [simple uint 8 messagePartNumber encoding='"AsciiUint"']
+[discriminatedType OpenProtocolMessage(OpenProtocolRevision connectionRevision)
+ [implicit uint 32 length 'lengthInBytes - 1' encoding='"ASCII"' ]
+ [discriminator Mid mid encoding='"ASCII"' ]
+ [optional OpenProtocolRevision selectedRevision encoding='"ASCII"' nullBytesHex='202020']
+ [optional uint 8 noAckFlag encoding='"ASCII"' nullBytesHex='20' ]
+ [optional uint 16 stationId encoding='"ASCII"' nullBytesHex='2020' ]
+ [optional uint 16 spindleId encoding='"ASCII"' nullBytesHex='2020' ]
+ [optional uint 16 sequenceNumber encoding='"ASCII"' nullBytesHex='2020' ]
+ [optional uint 8 numberOfMessageParts encoding='"ASCII"' nullBytesHex='20' ]
+ [optional uint 8 messagePartNumber encoding='"ASCII"' nullBytesHex='20' ]
[typeSwitch mid
['ApplicationCommunicationStart' *ApplicationCommunicationStart
]
- ['ApplicationCommunicationStartAcknowledge' *ApplicationCommunicationStartAcknowledge(OpenProtocolRevision revision)
- [array ApplicationCommunicationStartAcknowledgeBlock blocks count 'revision.numCommunicationStartAcknowledgeBlocks']
+ ['ApplicationCommunicationStartAcknowledge' *ApplicationCommunicationStartAcknowledge
+ [array ApplicationCommunicationStartAcknowledgeBlock blocks count 'connectionRevision.numCommunicationStartAcknowledgeBlocks']
]
['ApplicationCommunicationStop' *ApplicationCommunicationStop
]
['ApplicationCommandError' *ApplicationCommandError
- [simple Mid requestMid]
- [simple Error error ]
+ [simple Mid requestMid encoding='"ASCII"']
+ [simple Error error encoding='"ASCII"']
]
['ApplicationCommandAccepted' *ApplicationCommandAccepted
- [simple Mid requestMid]
+ [simple Mid requestMid encoding='"ASCII"']
]
['ApplicationGenericDataRequest' *ApplicationGenericDataRequest
- [simple Mid requestMid ]
- [simple OpenProtocolRevision wantedRevision ]
- [implicit uint 16 extraDataLength 'COUNT(extraData)' ]
- [array byte extraData count 'extraDataLength']
+ [simple Mid requestMid encoding='"ASCII"']
+ [simple OpenProtocolRevision revision encoding='"ASCII"']
+ [implicit uint 16 extraDataLength 'COUNT(extraData)' encoding='"ASCII"']
+ [array byte extraData count 'extraDataLength' ]
]
]
- [const uint 8 end 0x00 ]
+ [const uint 8 end 0x00 ]
]
[discriminatedType ApplicationCommunicationStartAcknowledgeBlock
- [discriminator uint 16 blockType encoding='"AsciiUint"']
+ [discriminator uint 16 blockType encoding='"ASCII"']
[typeSwitch blockType
// Revision 1
['1' *CellId
- [simple uint 32 cellId encoding='"AsciiUint"']
+ [simple uint 32 cellId encoding='"ASCII"']
]
['2' *ChannelId
- [simple uint 16 channelId encoding='"AsciiUint"']
+ [simple uint 16 channelId encoding='"ASCII"']
]
['3' *ControllerName
- [simple string 200 controllerName encoding='"ASCII"' ]
+ [simple string 200 controllerName encoding='"ASCII"']
]
// Additional Blocks for Revision 2
['4' *SupplierCode
- [simple uint 24 supplierCode encoding='"AsciiUint"']
+ [simple uint 24 supplierCode encoding='"ASCII"']
]
// Additional Blocks for Revision 3
['5' *OpenProtocolVersion
- [simple string 152 openProtocolVersion encoding='"ASCII"' ]
+ [simple string 152 openProtocolVersion encoding='"ASCII"']
]
['6' *ControllerSoftwareVersion
- [simple string 152 controllerSoftwareVersion encoding='"ASCII"' ]
+ [simple string 152 controllerSoftwareVersion encoding='"ASCII"']
]
['7' *ToolSoftwareVersion
- [simple string 152 toolSoftwareVersion encoding='"ASCII"' ]
+ [simple string 152 toolSoftwareVersion encoding='"ASCII"']
]
// Additional Blocks for Revision 4
['8' *RbuType
- [simple string 192 rbuType encoding='"ASCII"' ]
+ [simple string 192 rbuType encoding='"ASCII"']
]
['9' *ControllerSerialNumber
- [simple string 80 controllerSerialNumber encoding='"ASCII"' ]
+ [simple string 80 controllerSerialNumber encoding='"ASCII"']
]
// Additional Blocks for Revision 5
['10' *SystemType
- [simple string 24 systemType encoding='"ASCII"' ]
+ [simple string 24 systemType encoding='"ASCII"']
]
['11' *SystemSubtype
- [simple string 24 systemSubtype encoding='"ASCII"' ]
+ [simple string 24 systemSubtype encoding='"ASCII"']
]
// Additional Blocks for Revision 6
['12' *SequenceNumberSupport
- [reserved uint 7 '0x00' ]
- [simple bit sequenceNumberSupport ]
+ [reserved uint 7 '0x00' ]
+ [simple bit sequenceNumberSupport ]
]
['13' *LinkingHandlingSupport
- [reserved uint 7 '0x00' ]
- [simple bit linkingHandlingSupport ]
+ [reserved uint 7 '0x00' ]
+ [simple bit linkingHandlingSupport ]
]
['14' *StationId
- [simple string 80 stationId encoding='"ASCII"' ]
+ [simple string 80 stationId encoding='"ASCII"']
]
['15' *StationName
- [simple string 200 stationName encoding='"ASCII"' ]
+ [simple string 200 stationName encoding='"ASCII"']
]
['16' *ClientId
- [simple uint 8 clientId encoding='"AsciiUint"']
+ [simple uint 8 clientId encoding='"ASCII"']
]
]
]
// Depending on the revision of the device, a different number of blocks are supported.
-[enum uint 24 OpenProtocolRevision(uint 8 numCommunicationStartAcknowledgeBlocks) encoding='"AsciiUint"'
+[enum uint 24 OpenProtocolRevision(uint 8 numCommunicationStartAcknowledgeBlocks) encoding='"ASCII"'
['1' Revision1 [ '3' ]]
['2' Revision2 [ '4' ]]
['3' Revision3 [ '7' ]]
@@ -160,7 +160,7 @@
[NewGroupsMessage ] // 2600 - 9999
]
-[enum uint 32 Mid encoding='"AsciiUint"'
+[enum uint 32 Mid encoding='"ASCII"'
['1' ApplicationCommunicationStart ] // *
['2' ApplicationCommunicationStartAcknowledge ] // *
['3' ApplicationCommunicationStop ]
@@ -379,7 +379,7 @@
['9999' KeepAliveOpenProtocolCommunication ] // *
]
-[enum uint 16 Error encoding='"AsciiUint"'
+[enum uint 16 Error encoding='"ASCII"'
['0' NoError]
['1' InvalidData]
['2' ParameterSetIdNotPresent]
diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/ReadBufferTest.java b/protocols/open-protocol/src/test/java/org/apache/plc4x/protocol/openprotocol/OpenProtocolProtocolTest.java
similarity index 60%
copy from plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/ReadBufferTest.java
copy to protocols/open-protocol/src/test/java/org/apache/plc4x/protocol/openprotocol/OpenProtocolProtocolTest.java
index aeb6d60a4b..fe1c5e85d2 100644
--- a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/generation/ReadBufferTest.java
+++ b/protocols/open-protocol/src/test/java/org/apache/plc4x/protocol/openprotocol/OpenProtocolProtocolTest.java
@@ -16,25 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.plc4x.java.spi.generation;
+package org.apache.plc4x.protocol.openprotocol;
+import org.apache.plc4x.plugins.codegenerator.protocol.TypeContext;
import org.junit.jupiter.api.Test;
-import java.nio.charset.StandardCharsets;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+class OpenProtocolProtocolTest {
-class ReadBufferTest {
-
- /**
- * Test which makes sure that PLC4X-256 is not happening.
- */
@Test
- void readString() throws ParseException {
- String value = new String("abcdef");
- final ReadBuffer buffer = new ReadBufferByteBased(value.getBytes(StandardCharsets.UTF_8));
- String answer = buffer.readString("", value.length() * 8, "UTF-8");
-
- assertEquals(value, answer);
+ void getTypeContext() throws Exception {
+ TypeContext typeContext = new OpenProtocolProtocol().getTypeContext();
+ assertNotNull(typeContext);
+ assertNotNull(typeContext.getUnresolvedTypeReferences());
+ assertSame(0, typeContext.getUnresolvedTypeReferences().size());
}
-}
\ No newline at end of file
+
+}
diff --git a/protocols/open-protocol/pom.xml b/protocols/open-protocol/src/test/resources/logback-test.xml
similarity index 50%
copy from protocols/open-protocol/pom.xml
copy to protocols/open-protocol/src/test/resources/logback-test.xml
index 6ba8760a00..8c25492b16 100644
--- a/protocols/open-protocol/pom.xml
+++ b/protocols/open-protocol/src/test/resources/logback-test.xml
@@ -17,27 +17,20 @@
specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-protocols</artifactId>
- <version>0.11.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>plc4x-protocols-open-protocol</artifactId>
-
- <name>Protocols: Open-Protocol</name>
- <description>Protocol specifications for the Atlas Copco: Open Protocol protocol</description>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.plc4x</groupId>
- <artifactId>plc4x-code-generation-protocol-base-mspec</artifactId>
- <version>0.11.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
+<configuration xmlns="http://ch.qos.logback/xml/ns/logback"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+ http://ch.qos.logback/xml/ns/logback
+ https://raw.githubusercontent.com/enricopulatzo/logback-XSD/master/src/main/xsd/logback.xsd">
+
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+ </encoder>
+ </appender>
+
+ <root level="debug">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+</configuration>
\ No newline at end of file
diff --git a/protocols/open-protocol/src/test/resources/protocols/openprotocol/ParserSerializerTestsuite.xml b/protocols/open-protocol/src/test/resources/protocols/openprotocol/ParserSerializerTestsuite.xml
new file mode 100644
index 0000000000..09782a67de
--- /dev/null
+++ b/protocols/open-protocol/src/test/resources/protocols/openprotocol/ParserSerializerTestsuite.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ https://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.
+ -->
+<test:testsuite xmlns:test="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd"
+ byteOrder="BIG_ENDIAN">
+
+ <name>Open-Protocol</name>
+
+ <protocolName>open-protocol</protocolName>
+ <outputFlavor>read-write</outputFlavor>
+
+ <testcase>
+ <name>MID 0001 Application Communication start</name>
+ <!-- 0 0 2 0 0 0 0 1 0 0 5 _ _ _ _ _ _ _ _ _ NULL -->
+ <raw>303032303030303130303520202020202020202000</raw>
+ <root-type>OpenProtocolMessage</root-type>
+ <parser-arguments>
+ <connectionRevision>Revision5</connectionRevision>
+ </parser-arguments>
+ <xml>
+ <OpenProtocolMessage>
+ <length dataType="uint" bitLength="32">20</length>
+ <mid>
+ <Mid dataType="uint" bitLength="32" stringRepresentation="ApplicationCommunicationStart">1</Mid>
+ </mid>
+ <selectedRevision>
+ <OpenProtocolRevision dataType="uint" bitLength="24" stringRepresentation="Revision5">5</OpenProtocolRevision>
+ </selectedRevision>
+ <OpenProtocolMessageApplicationCommunicationStart>
+ </OpenProtocolMessageApplicationCommunicationStart>
+ <end dataType="uint" bitLength="8">0</end>
+ </OpenProtocolMessage>
+ </xml>
+ </testcase>
+
+ <testcase>
+ <name>MID 0002 Application Communication start acknowledge</name>
+ <!-- 0 0 5 7 0 0 0 2 _ _ _ _ _ _ _ _ _ _ _ _ 0 1 0 0 0 1 0 2 0 1 0 3 A i r b a g 1 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ NULL-->
+ <raw>30303537303030322020202020202020202020203031303030313032303130334169726261673120202020202020202020202020202020202000</raw>
+ <root-type>OpenProtocolMessage</root-type>
+ <parser-arguments>
+ <connectionRevision>Revision1</connectionRevision>
+ </parser-arguments>
+ <xml>
+ <OpenProtocolMessage>
+ <length dataType="uint" bitLength="32">57</length>
+ <mid>
+ <Mid dataType="uint" bitLength="32" stringRepresentation="ApplicationCommunicationStartAcknowledge">2</Mid>
+ </mid>
+ <selectedRevision>
+ </selectedRevision>
+ <OpenProtocolMessageApplicationCommunicationStartAcknowledge>
+ <blocks isList="true">
+ <ApplicationCommunicationStartAcknowledgeBlock>
+ <blockType dataType="uint" bitLength="16">1</blockType>
+ <ApplicationCommunicationStartAcknowledgeBlockCellId>
+ <cellId dataType="uint" bitLength="32">1</cellId>
+ </ApplicationCommunicationStartAcknowledgeBlockCellId>
+ </ApplicationCommunicationStartAcknowledgeBlock>
+ <ApplicationCommunicationStartAcknowledgeBlock>
+ <blockType dataType="uint" bitLength="16">2</blockType>
+ <ApplicationCommunicationStartAcknowledgeBlockChannelId>
+ <channelId dataType="uint" bitLength="16">1</channelId>
+ </ApplicationCommunicationStartAcknowledgeBlockChannelId>
+ </ApplicationCommunicationStartAcknowledgeBlock>
+ <ApplicationCommunicationStartAcknowledgeBlock>
+ <blockType dataType="uint" bitLength="16">3</blockType>
+ <ApplicationCommunicationStartAcknowledgeBlockControllerName>
+ <controllerName dataType="string" bitLength="200" encoding="ASCII">Airbag1</controllerName>
+ </ApplicationCommunicationStartAcknowledgeBlockControllerName>
+ </ApplicationCommunicationStartAcknowledgeBlock>
+ </blocks>
+ </OpenProtocolMessageApplicationCommunicationStartAcknowledge>
+ <end dataType="uint" bitLength="8">0</end>
+ </OpenProtocolMessage>
+ </xml>
+ </testcase>
+
+</test:testsuite>
diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java
index f6625dbc28..0bfa2f5883 100644
--- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java
+++ b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1Symbol.java
@@ -60,10 +60,18 @@ public abstract class DF1Symbol implements Message {
writeBuffer.pushContext("DF1Symbol");
// Const Field (messageStart)
- writeConstField("messageStart", MESSAGESTART, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "messageStart",
+ MESSAGESTART,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Discriminator Field (symbolType) (Used as input to a switch field)
- writeDiscriminatorField("symbolType", getSymbolType(), writeUnsignedShort(writeBuffer, 8));
+ writeDiscriminatorField(
+ "symbolType",
+ getSymbolType(),
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Switch field (Serialize the sub-type)
serializeDF1SymbolChild(writeBuffer);
diff --git a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java
index 9796970483..d0fa613bf9 100644
--- a/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java
+++ b/sandbox/test-java-df1-driver/src/main/generated/org/apache/plc4x/java/df1/readwrite/DF1SymbolMessageFrame.java
@@ -106,10 +106,18 @@ public class DF1SymbolMessageFrame extends DF1Symbol implements Message {
WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (messageEnd)
- writeConstField("messageEnd", MESSAGEEND, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "messageEnd",
+ MESSAGEEND,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Const Field (endTransaction)
- writeConstField("endTransaction", ENDTRANSACTION, writeUnsignedShort(writeBuffer, 8));
+ writeConstField(
+ "endTransaction",
+ ENDTRANSACTION,
+ writeUnsignedShort(writeBuffer, 8),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
// Checksum Field (checksum) (Calculated)
writeChecksumField(
@@ -117,7 +125,8 @@ public class DF1SymbolMessageFrame extends DF1Symbol implements Message {
(int)
(org.apache.plc4x.java.df1.readwrite.utils.StaticHelper.crcCheck(
destinationAddress, sourceAddress, command)),
- writeUnsignedInt(writeBuffer, 16));
+ writeUnsignedInt(writeBuffer, 16),
+ WithOption.WithByteOrder(ByteOrder.BIG_ENDIAN));
writeBuffer.popContext("DF1SymbolMessageFrame");
}