This is an automated email from the ASF dual-hosted git repository. sruehl pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit c1ec3d80eccecf9cf06100976a5c1878380882f2 Author: Sebastian Rühl <sru...@apache.org> AuthorDate: Sun Sep 1 10:01:40 2024 +0200 feat(code-gen/go): implicit field writer --- .../templates/go/complex-type-template.go.ftlh | 12 ++++++------ .../abeth/readwrite/model/CIPEncapsulationPacket.go | 7 ++----- .../ads/discovery/readwrite/model/AdsDiscovery.go | 7 ++----- .../readwrite/model/AdsDiscoveryBlockFingerprint.go | 7 ++----- .../readwrite/model/AdsDiscoveryBlockOsData.go | 7 ++----- .../readwrite/model/AdsDiscoveryBlockVersion.go | 7 ++----- .../ads/discovery/readwrite/model/AmsString.go | 7 ++----- .../readwrite/model/AdsDataTypeTableChildEntry.go | 21 ++++++--------------- .../ads/readwrite/model/AdsDataTypeTableEntry.go | 21 ++++++--------------- .../ads/readwrite/model/AdsReadResponse.go | 7 ++----- .../ads/readwrite/model/AdsReadWriteRequest.go | 7 ++----- .../ads/readwrite/model/AdsReadWriteResponse.go | 7 ++----- .../ads/readwrite/model/AdsSymbolTableEntry.go | 21 ++++++--------------- .../ads/readwrite/model/AdsWriteControlRequest.go | 7 ++----- .../ads/readwrite/model/AdsWriteRequest.go | 7 ++----- plc4go/protocols/ads/readwrite/model/AmsPacket.go | 7 ++----- .../protocols/ads/readwrite/model/AmsTCPPacket.go | 7 ++----- plc4go/protocols/bacnetip/readwrite/model/BVLC.go | 7 ++----- .../readwrite/model/AnsiExtendedSymbolSegment.go | 7 ++----- .../protocols/eip/readwrite/model/CIPAttributes.go | 7 ++----- .../eip/readwrite/model/CipConnectedRequest.go | 7 ++----- .../readwrite/model/CipConnectionManagerRequest.go | 7 ++----- .../readwrite/model/CipConnectionManagerResponse.go | 7 ++----- plc4go/protocols/eip/readwrite/model/CipIdentity.go | 14 ++++---------- plc4go/protocols/eip/readwrite/model/CipRRData.go | 7 ++----- .../protocols/eip/readwrite/model/CipReadRequest.go | 7 ++----- .../eip/readwrite/model/CipSecurityInformation.go | 7 ++----- .../eip/readwrite/model/CipUnconnectedRequest.go | 14 ++++---------- .../eip/readwrite/model/CipWriteRequest.go | 7 ++----- .../eip/readwrite/model/ConnectedDataItem.go | 7 ++----- .../eip/readwrite/model/EipListIdentityResponse.go | 7 ++----- plc4go/protocols/eip/readwrite/model/EipPacket.go | 7 ++----- .../eip/readwrite/model/GetAttributeAllRequest.go | 7 ++----- .../eip/readwrite/model/ListServicesResponse.go | 7 ++----- .../protocols/eip/readwrite/model/SendUnitData.go | 7 ++----- plc4go/protocols/eip/readwrite/model/Services.go | 7 ++----- .../eip/readwrite/model/ServicesResponse.go | 7 ++----- .../eip/readwrite/model/UnConnectedDataItem.go | 7 ++----- .../readwrite/model/ApduDataMemoryResponse.go | 7 ++----- .../readwrite/model/ConnectionRequestInformation.go | 7 ++----- .../readwrite/model/ConnectionResponseDataBlock.go | 7 ++----- .../knxnetip/readwrite/model/DIBDeviceInfo.go | 7 ++----- .../knxnetip/readwrite/model/DIBSuppSvcFamilies.go | 7 ++----- .../model/DeviceConfigurationAckDataBlock.go | 7 ++----- .../model/DeviceConfigurationRequestDataBlock.go | 7 ++----- .../knxnetip/readwrite/model/HPAIControlEndpoint.go | 7 ++----- .../knxnetip/readwrite/model/HPAIDataEndpoint.go | 7 ++----- .../readwrite/model/HPAIDiscoveryEndpoint.go | 7 ++----- .../knxnetip/readwrite/model/KnxNetIpMessage.go | 14 ++++---------- .../knxnetip/readwrite/model/LDataExtended.go | 7 ++----- .../readwrite/model/TunnelingRequestDataBlock.go | 7 ++----- .../readwrite/model/TunnelingResponseDataBlock.go | 7 ++----- .../model/ModbusDeviceInformationObject.go | 7 ++----- .../model/ModbusPDUGetComEventLogResponse.go | 7 ++----- .../readwrite/model/ModbusPDUReadCoilsResponse.go | 7 ++----- .../ModbusPDUReadDeviceIdentificationResponse.go | 7 ++----- .../model/ModbusPDUReadDiscreteInputsResponse.go | 7 ++----- .../model/ModbusPDUReadFifoQueueResponse.go | 14 ++++---------- .../model/ModbusPDUReadFileRecordRequest.go | 7 ++----- .../model/ModbusPDUReadFileRecordResponse.go | 7 ++----- .../model/ModbusPDUReadFileRecordResponseItem.go | 7 ++----- .../model/ModbusPDUReadHoldingRegistersResponse.go | 7 ++----- .../model/ModbusPDUReadInputRegistersResponse.go | 7 ++----- ...usPDUReadWriteMultipleHoldingRegistersRequest.go | 7 ++----- ...sPDUReadWriteMultipleHoldingRegistersResponse.go | 7 ++----- .../model/ModbusPDUReportServerIdResponse.go | 7 ++----- .../model/ModbusPDUWriteFileRecordRequest.go | 7 ++----- .../model/ModbusPDUWriteFileRecordRequestItem.go | 7 ++----- .../model/ModbusPDUWriteFileRecordResponse.go | 7 ++----- .../model/ModbusPDUWriteFileRecordResponseItem.go | 7 ++----- .../model/ModbusPDUWriteMultipleCoilsRequest.go | 7 ++----- ...ModbusPDUWriteMultipleHoldingRegistersRequest.go | 7 ++----- .../modbus/readwrite/model/ModbusTcpADU.go | 7 ++----- .../opcua/readwrite/model/DataChangeNotification.go | 7 ++----- .../opcua/readwrite/model/EventNotificationList.go | 7 ++----- .../protocols/opcua/readwrite/model/MessagePDU.go | 7 ++----- .../protocols/opcua/readwrite/model/PascalString.go | 7 ++----- .../readwrite/model/StatusChangeNotification.go | 7 ++----- .../opcua/readwrite/model/UserIdentityToken.go | 7 ++----- plc4go/protocols/s7/readwrite/model/COTPPacket.go | 7 ++----- .../protocols/s7/readwrite/model/COTPParameter.go | 7 ++----- plc4go/protocols/s7/readwrite/model/S7Message.go | 14 ++++---------- .../s7/readwrite/model/S7ParameterModeTransition.go | 7 ++----- .../s7/readwrite/model/S7ParameterReadVarRequest.go | 7 ++----- .../s7/readwrite/model/S7ParameterUserData.go | 7 ++----- .../model/S7ParameterUserDataItemCPUFunctions.go | 7 ++----- .../readwrite/model/S7ParameterWriteVarRequest.go | 7 ++----- ...PayloadUserDataItemCpuFunctionAlarmAckRequest.go | 7 ++----- ...ayloadUserDataItemCpuFunctionAlarmAckResponse.go | 7 ++----- .../s7/readwrite/model/S7VarPayloadDataItem.go | 7 ++----- .../model/S7VarRequestParameterItemAddress.go | 7 ++----- plc4go/protocols/s7/readwrite/model/TPKTPacket.go | 7 ++----- 92 files changed, 210 insertions(+), 516 deletions(-) diff --git a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh index 05f72de4ff..e6022bb844 100644 --- a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh +++ b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh @@ -1267,13 +1267,13 @@ func (m *_${type.name}) SerializeWithWriteBuffer(ctx context.Context, writeBuffe <#break> <#case "implicit"> <#assign implicitField = field.asImplicitField().orElseThrow()> - <#assign simpleTypeReference = implicitField.type.asSimpleTypeReference().orElseThrow()> + <#assign typedField = field.asTypedField().orElseThrow()> + <#assign namedField = field.asNamedField().orElseThrow()> - // Implicit Field (${implicitField.name}) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) - ${implicitField.name} := ${helper.getLanguageTypeNameForField(field)}(${helper.toSerializationExpression(implicitField, implicitField.type, implicitField.serializeExpression, parserArguments)}) - _${implicitField.name}Err := ${helper.getWriteBufferWriteMethodCall(implicitField.name, simpleTypeReference, "(" + implicitField.name + ")", implicitField)} - if _${implicitField.name}Err != nil { - return errors.Wrap(_${implicitField.name}Err, "Error serializing '${implicitField.name}' field")<@emitImport import="github.com/pkg/errors" /> + <#-- Implicit field values might be used in expressions, in order to avoid problems, we generate a temporary variable with the given name. --> + ${implicitField.name} := ${helper.getLanguageTypeNameForField(field)}(${helper.toSerializationExpression(implicitField, implicitField.type, implicitField.serializeExpression, parserArguments)}); + if err := WriteImplicitField(ctx, "${namedField.name}", ${implicitField.name}, ${helper.getDataWriterCall(typedField.type, namedField.name)}${helper.getFieldOptions(typedField, parserArguments)});err != nil{ + return errors.Wrap(err, "Error serializing '${namedField.name}' field")<@emitImport import="github.com/pkg/errors" /> } <#break> <#case "manualArray"> diff --git a/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go b/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go index 2953de8464..97530bd95b 100644 --- a/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go +++ b/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go @@ -279,12 +279,9 @@ func (pm *_CIPEncapsulationPacket) SerializeParent(ctx context.Context, writeBuf if err := WriteDiscriminatorField(ctx, "commandType", m.GetCommandType(), WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { return errors.Wrap(err, "Error serializing 'commandType' field") } - - // Implicit Field (packetLen) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) packetLen := uint16(uint16(uint16(m.GetLengthInBytes(ctx))) - uint16(uint16(28))) - _packetLenErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("packetLen", 16, uint16((packetLen))) - if _packetLenErr != nil { - return errors.Wrap(_packetLenErr, "Error serializing 'packetLen' field") + if err := WriteImplicitField(ctx, "packetLen", packetLen, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'packetLen' field") } // Simple Field (sessionHandle) diff --git a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go index 9461491fee..aab5133e2b 100644 --- a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go +++ b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go @@ -305,12 +305,9 @@ func (m *_AdsDiscovery) SerializeWithWriteBuffer(ctx context.Context, writeBuffe if _portNumberErr != nil { return errors.Wrap(_portNumberErr, "Error serializing 'portNumber' field") } - - // Implicit Field (numBlocks) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numBlocks := uint32(uint32(len(m.GetBlocks()))) - _numBlocksErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("numBlocks", 32, uint32((numBlocks))) - if _numBlocksErr != nil { - return errors.Wrap(_numBlocksErr, "Error serializing 'numBlocks' field") + if err := WriteImplicitField(ctx, "numBlocks", numBlocks, WriteUnsignedInt(writeBuffer, 32), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'numBlocks' field") } if err := WriteComplexTypeArrayField(ctx, "blocks", m.GetBlocks(), writeBuffer, codegen.WithByteOrder(binary.LittleEndian)); err != nil { diff --git a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockFingerprint.go b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockFingerprint.go index 4525441d0f..c7d4a76d98 100644 --- a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockFingerprint.go +++ b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockFingerprint.go @@ -193,12 +193,9 @@ func (m *_AdsDiscoveryBlockFingerprint) SerializeWithWriteBuffer(ctx context.Con if pushErr := writeBuffer.PushContext("AdsDiscoveryBlockFingerprint"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for AdsDiscoveryBlockFingerprint") } - - // Implicit Field (dataLen) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataLen := uint16(uint16(len(m.GetData()))) - _dataLenErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("dataLen", 16, uint16((dataLen))) - if _dataLenErr != nil { - return errors.Wrap(_dataLenErr, "Error serializing 'dataLen' field") + if err := WriteImplicitField(ctx, "dataLen", dataLen, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'dataLen' field") } if err := WriteByteArrayField(ctx, "data", m.GetData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockOsData.go b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockOsData.go index c3378e6947..e7e29e3fb3 100644 --- a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockOsData.go +++ b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockOsData.go @@ -193,12 +193,9 @@ func (m *_AdsDiscoveryBlockOsData) SerializeWithWriteBuffer(ctx context.Context, if pushErr := writeBuffer.PushContext("AdsDiscoveryBlockOsData"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for AdsDiscoveryBlockOsData") } - - // Implicit Field (osDataLen) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) osDataLen := uint16(uint16(len(m.GetOsData()))) - _osDataLenErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("osDataLen", 16, uint16((osDataLen))) - if _osDataLenErr != nil { - return errors.Wrap(_osDataLenErr, "Error serializing 'osDataLen' field") + if err := WriteImplicitField(ctx, "osDataLen", osDataLen, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'osDataLen' field") } if err := WriteByteArrayField(ctx, "osData", m.GetOsData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockVersion.go b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockVersion.go index 3d27eeee28..5b34f5722c 100644 --- a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockVersion.go +++ b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscoveryBlockVersion.go @@ -193,12 +193,9 @@ func (m *_AdsDiscoveryBlockVersion) SerializeWithWriteBuffer(ctx context.Context if pushErr := writeBuffer.PushContext("AdsDiscoveryBlockVersion"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for AdsDiscoveryBlockVersion") } - - // Implicit Field (versionDataLen) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) versionDataLen := uint16(uint16(len(m.GetVersionData()))) - _versionDataLenErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("versionDataLen", 16, uint16((versionDataLen))) - if _versionDataLenErr != nil { - return errors.Wrap(_versionDataLenErr, "Error serializing 'versionDataLen' field") + if err := WriteImplicitField(ctx, "versionDataLen", versionDataLen, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'versionDataLen' field") } if err := WriteByteArrayField(ctx, "versionData", m.GetVersionData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/ads/discovery/readwrite/model/AmsString.go b/plc4go/protocols/ads/discovery/readwrite/model/AmsString.go index 23fd9fd83e..61ca52370f 100644 --- a/plc4go/protocols/ads/discovery/readwrite/model/AmsString.go +++ b/plc4go/protocols/ads/discovery/readwrite/model/AmsString.go @@ -172,12 +172,9 @@ func (m *_AmsString) SerializeWithWriteBuffer(ctx context.Context, writeBuffer u if pushErr := writeBuffer.PushContext("AmsString"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for AmsString") } - - // Implicit Field (strLen) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) strLen := uint16(uint16(uint16(len(m.GetText()))) + uint16(uint16(1))) - _strLenErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("strLen", 16, uint16((strLen))) - if _strLenErr != nil { - return errors.Wrap(_strLenErr, "Error serializing 'strLen' field") + if err := WriteImplicitField(ctx, "strLen", strLen, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'strLen' field") } // Simple Field (text) diff --git a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go index 0460454026..db735b9985 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go +++ b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go @@ -547,26 +547,17 @@ func (m *_AdsDataTypeTableChildEntry) SerializeWithWriteBuffer(ctx context.Conte if _flagsErr != nil { return errors.Wrap(_flagsErr, "Error serializing 'flags' field") } - - // Implicit Field (propertyNameLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) propertyNameLength := uint16(uint16(len(m.GetPropertyName()))) - _propertyNameLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("propertyNameLength", 16, uint16((propertyNameLength))) - if _propertyNameLengthErr != nil { - return errors.Wrap(_propertyNameLengthErr, "Error serializing 'propertyNameLength' field") + if err := WriteImplicitField(ctx, "propertyNameLength", propertyNameLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'propertyNameLength' field") } - - // Implicit Field (dataTypeNameLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataTypeNameLength := uint16(uint16(len(m.GetDataTypeName()))) - _dataTypeNameLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("dataTypeNameLength", 16, uint16((dataTypeNameLength))) - if _dataTypeNameLengthErr != nil { - return errors.Wrap(_dataTypeNameLengthErr, "Error serializing 'dataTypeNameLength' field") + if err := WriteImplicitField(ctx, "dataTypeNameLength", dataTypeNameLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'dataTypeNameLength' field") } - - // Implicit Field (commentLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) commentLength := uint16(uint16(len(m.GetComment()))) - _commentLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("commentLength", 16, uint16((commentLength))) - if _commentLengthErr != nil { - return errors.Wrap(_commentLengthErr, "Error serializing 'commentLength' field") + if err := WriteImplicitField(ctx, "commentLength", commentLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'commentLength' field") } // Simple Field (arrayDimensions) diff --git a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go index 7420cb59d2..6151ef674c 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go +++ b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go @@ -547,26 +547,17 @@ func (m *_AdsDataTypeTableEntry) SerializeWithWriteBuffer(ctx context.Context, w if _flagsErr != nil { return errors.Wrap(_flagsErr, "Error serializing 'flags' field") } - - // Implicit Field (dataTypeNameLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataTypeNameLength := uint16(uint16(len(m.GetDataTypeName()))) - _dataTypeNameLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("dataTypeNameLength", 16, uint16((dataTypeNameLength))) - if _dataTypeNameLengthErr != nil { - return errors.Wrap(_dataTypeNameLengthErr, "Error serializing 'dataTypeNameLength' field") + if err := WriteImplicitField(ctx, "dataTypeNameLength", dataTypeNameLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'dataTypeNameLength' field") } - - // Implicit Field (simpleTypeNameLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) simpleTypeNameLength := uint16(uint16(len(m.GetSimpleTypeName()))) - _simpleTypeNameLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("simpleTypeNameLength", 16, uint16((simpleTypeNameLength))) - if _simpleTypeNameLengthErr != nil { - return errors.Wrap(_simpleTypeNameLengthErr, "Error serializing 'simpleTypeNameLength' field") + if err := WriteImplicitField(ctx, "simpleTypeNameLength", simpleTypeNameLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'simpleTypeNameLength' field") } - - // Implicit Field (commentLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) commentLength := uint16(uint16(len(m.GetComment()))) - _commentLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("commentLength", 16, uint16((commentLength))) - if _commentLengthErr != nil { - return errors.Wrap(_commentLengthErr, "Error serializing 'commentLength' field") + if err := WriteImplicitField(ctx, "commentLength", commentLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'commentLength' field") } // Simple Field (arrayDimensions) diff --git a/plc4go/protocols/ads/readwrite/model/AdsReadResponse.go b/plc4go/protocols/ads/readwrite/model/AdsReadResponse.go index 0c43c8aa13..91d775def2 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsReadResponse.go +++ b/plc4go/protocols/ads/readwrite/model/AdsReadResponse.go @@ -233,12 +233,9 @@ func (m *_AdsReadResponse) SerializeWithWriteBuffer(ctx context.Context, writeBu if _resultErr != nil { return errors.Wrap(_resultErr, "Error serializing 'result' field") } - - // Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) length := uint32(uint32(len(m.GetData()))) - _lengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("length", 32, uint32((length))) - if _lengthErr != nil { - return errors.Wrap(_lengthErr, "Error serializing 'length' field") + if err := WriteImplicitField(ctx, "length", length, WriteUnsignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'length' field") } if err := WriteByteArrayField(ctx, "data", m.GetData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go b/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go index 6a9c0274ab..b4ce19d69a 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go +++ b/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go @@ -300,12 +300,9 @@ func (m *_AdsReadWriteRequest) SerializeWithWriteBuffer(ctx context.Context, wri if _readLengthErr != nil { return errors.Wrap(_readLengthErr, "Error serializing 'readLength' field") } - - // Implicit Field (writeLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) writeLength := uint32(uint32((uint32(uint32(len(m.GetItems()))) * uint32((utils.InlineIf((bool((m.GetIndexGroup()) == (61570))), func() any { return uint32(uint32(16)) }, func() any { return uint32(uint32(12)) }).(uint32))))) + uint32(uint32(len(m.GetData())))) - _writeLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("writeLength", 32, uint32((writeLength))) - if _writeLengthErr != nil { - return errors.Wrap(_writeLengthErr, "Error serializing 'writeLength' field") + if err := WriteImplicitField(ctx, "writeLength", writeLength, WriteUnsignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'writeLength' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/ads/readwrite/model/AdsReadWriteResponse.go b/plc4go/protocols/ads/readwrite/model/AdsReadWriteResponse.go index 7332a38415..048ad2a0fe 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsReadWriteResponse.go +++ b/plc4go/protocols/ads/readwrite/model/AdsReadWriteResponse.go @@ -233,12 +233,9 @@ func (m *_AdsReadWriteResponse) SerializeWithWriteBuffer(ctx context.Context, wr if _resultErr != nil { return errors.Wrap(_resultErr, "Error serializing 'result' field") } - - // Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) length := uint32(uint32(len(m.GetData()))) - _lengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("length", 32, uint32((length))) - if _lengthErr != nil { - return errors.Wrap(_lengthErr, "Error serializing 'length' field") + if err := WriteImplicitField(ctx, "length", length, WriteUnsignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'length' field") } if err := WriteByteArrayField(ctx, "data", m.GetData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/ads/readwrite/model/AdsSymbolTableEntry.go b/plc4go/protocols/ads/readwrite/model/AdsSymbolTableEntry.go index 44da8ec8ef..409805c53d 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsSymbolTableEntry.go +++ b/plc4go/protocols/ads/readwrite/model/AdsSymbolTableEntry.go @@ -752,26 +752,17 @@ func (m *_AdsSymbolTableEntry) SerializeWithWriteBuffer(ctx context.Context, wri return errors.Wrap(_err, "Error serializing 'reserved' field") } } - - // Implicit Field (nameLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) nameLength := uint16(uint16(len(m.GetName()))) - _nameLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("nameLength", 16, uint16((nameLength))) - if _nameLengthErr != nil { - return errors.Wrap(_nameLengthErr, "Error serializing 'nameLength' field") + if err := WriteImplicitField(ctx, "nameLength", nameLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'nameLength' field") } - - // Implicit Field (dataTypeNameLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataTypeNameLength := uint16(uint16(len(m.GetDataTypeName()))) - _dataTypeNameLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("dataTypeNameLength", 16, uint16((dataTypeNameLength))) - if _dataTypeNameLengthErr != nil { - return errors.Wrap(_dataTypeNameLengthErr, "Error serializing 'dataTypeNameLength' field") + if err := WriteImplicitField(ctx, "dataTypeNameLength", dataTypeNameLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'dataTypeNameLength' field") } - - // Implicit Field (commentLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) commentLength := uint16(uint16(len(m.GetComment()))) - _commentLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("commentLength", 16, uint16((commentLength))) - if _commentLengthErr != nil { - return errors.Wrap(_commentLengthErr, "Error serializing 'commentLength' field") + if err := WriteImplicitField(ctx, "commentLength", commentLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'commentLength' field") } // Simple Field (name) diff --git a/plc4go/protocols/ads/readwrite/model/AdsWriteControlRequest.go b/plc4go/protocols/ads/readwrite/model/AdsWriteControlRequest.go index 9601cf7b57..056ffb9209 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsWriteControlRequest.go +++ b/plc4go/protocols/ads/readwrite/model/AdsWriteControlRequest.go @@ -252,12 +252,9 @@ func (m *_AdsWriteControlRequest) SerializeWithWriteBuffer(ctx context.Context, if _deviceStateErr != nil { return errors.Wrap(_deviceStateErr, "Error serializing 'deviceState' field") } - - // Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) length := uint32(uint32(len(m.GetData()))) - _lengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("length", 32, uint32((length))) - if _lengthErr != nil { - return errors.Wrap(_lengthErr, "Error serializing 'length' field") + if err := WriteImplicitField(ctx, "length", length, WriteUnsignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'length' field") } if err := WriteByteArrayField(ctx, "data", m.GetData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/ads/readwrite/model/AdsWriteRequest.go b/plc4go/protocols/ads/readwrite/model/AdsWriteRequest.go index e82d3405e1..f7a5a80eea 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsWriteRequest.go +++ b/plc4go/protocols/ads/readwrite/model/AdsWriteRequest.go @@ -252,12 +252,9 @@ func (m *_AdsWriteRequest) SerializeWithWriteBuffer(ctx context.Context, writeBu if _indexOffsetErr != nil { return errors.Wrap(_indexOffsetErr, "Error serializing 'indexOffset' field") } - - // Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) length := uint32(uint32(len(m.GetData()))) - _lengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("length", 32, uint32((length))) - if _lengthErr != nil { - return errors.Wrap(_lengthErr, "Error serializing 'length' field") + if err := WriteImplicitField(ctx, "length", length, WriteUnsignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'length' field") } if err := WriteByteArrayField(ctx, "data", m.GetData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/ads/readwrite/model/AmsPacket.go b/plc4go/protocols/ads/readwrite/model/AmsPacket.go index daddf99167..45f3810582 100644 --- a/plc4go/protocols/ads/readwrite/model/AmsPacket.go +++ b/plc4go/protocols/ads/readwrite/model/AmsPacket.go @@ -563,12 +563,9 @@ func (pm *_AmsPacket) SerializeParent(ctx context.Context, writeBuffer utils.Wri return errors.Wrap(_err, "Error serializing 'reserved' field") } } - - // Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) length := uint32(uint32(uint32(m.GetLengthInBytes(ctx))) - uint32(uint32(32))) - _lengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("length", 32, uint32((length))) - if _lengthErr != nil { - return errors.Wrap(_lengthErr, "Error serializing 'length' field") + if err := WriteImplicitField(ctx, "length", length, WriteUnsignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'length' field") } // Simple Field (errorCode) diff --git a/plc4go/protocols/ads/readwrite/model/AmsTCPPacket.go b/plc4go/protocols/ads/readwrite/model/AmsTCPPacket.go index 4d9d1a24e2..318ea749e8 100644 --- a/plc4go/protocols/ads/readwrite/model/AmsTCPPacket.go +++ b/plc4go/protocols/ads/readwrite/model/AmsTCPPacket.go @@ -189,12 +189,9 @@ func (m *_AmsTCPPacket) SerializeWithWriteBuffer(ctx context.Context, writeBuffe return errors.Wrap(_err, "Error serializing 'reserved' field") } } - - // Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) length := uint32(m.GetUserdata().GetLengthInBytes(ctx)) - _lengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("length", 32, uint32((length))) - if _lengthErr != nil { - return errors.Wrap(_lengthErr, "Error serializing 'length' field") + if err := WriteImplicitField(ctx, "length", length, WriteUnsignedInt(writeBuffer, 32), codegen.WithByteOrder(binary.LittleEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'length' field") } // Simple Field (userdata) diff --git a/plc4go/protocols/bacnetip/readwrite/model/BVLC.go b/plc4go/protocols/bacnetip/readwrite/model/BVLC.go index 54c4e449a9..0a80d5d7a4 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BVLC.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BVLC.go @@ -269,12 +269,9 @@ func (pm *_BVLC) SerializeParent(ctx context.Context, writeBuffer utils.WriteBuf if err := WriteDiscriminatorField(ctx, "bvlcFunction", m.GetBvlcFunction(), WriteUnsignedByte(writeBuffer, 8), codegen.WithByteOrder(binary.BigEndian)); err != nil { return errors.Wrap(err, "Error serializing 'bvlcFunction' field") } - - // Implicit Field (bvlcLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) bvlcLength := uint16(uint16(m.GetLengthInBytes(ctx))) - _bvlcLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("bvlcLength", 16, uint16((bvlcLength))) - if _bvlcLengthErr != nil { - return errors.Wrap(_bvlcLengthErr, "Error serializing 'bvlcLength' field") + if err := WriteImplicitField(ctx, "bvlcLength", bvlcLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'bvlcLength' field") } // Virtual field bvlcPayloadLength := m.GetBvlcPayloadLength() diff --git a/plc4go/protocols/eip/readwrite/model/AnsiExtendedSymbolSegment.go b/plc4go/protocols/eip/readwrite/model/AnsiExtendedSymbolSegment.go index 041576f7a0..7eec63fcb8 100644 --- a/plc4go/protocols/eip/readwrite/model/AnsiExtendedSymbolSegment.go +++ b/plc4go/protocols/eip/readwrite/model/AnsiExtendedSymbolSegment.go @@ -210,12 +210,9 @@ func (m *_AnsiExtendedSymbolSegment) SerializeWithWriteBuffer(ctx context.Contex if pushErr := writeBuffer.PushContext("AnsiExtendedSymbolSegment"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for AnsiExtendedSymbolSegment") } - - // Implicit Field (dataSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataSize := uint8(uint8(len(m.GetSymbol()))) - _dataSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("dataSize", 8, uint8((dataSize))) - if _dataSizeErr != nil { - return errors.Wrap(_dataSizeErr, "Error serializing 'dataSize' field") + if err := WriteImplicitField(ctx, "dataSize", dataSize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'dataSize' field") } // Simple Field (symbol) diff --git a/plc4go/protocols/eip/readwrite/model/CIPAttributes.go b/plc4go/protocols/eip/readwrite/model/CIPAttributes.go index 8b4467e5f7..55b09d1bd7 100644 --- a/plc4go/protocols/eip/readwrite/model/CIPAttributes.go +++ b/plc4go/protocols/eip/readwrite/model/CIPAttributes.go @@ -222,12 +222,9 @@ func (m *_CIPAttributes) SerializeWithWriteBuffer(ctx context.Context, writeBuff if pushErr := writeBuffer.PushContext("CIPAttributes"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CIPAttributes") } - - // Implicit Field (numberOfClasses) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numberOfClasses := uint16(uint16(len(m.GetClassId()))) - _numberOfClassesErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("numberOfClasses", 16, uint16((numberOfClasses))) - if _numberOfClassesErr != nil { - return errors.Wrap(_numberOfClassesErr, "Error serializing 'numberOfClasses' field") + if err := WriteImplicitField(ctx, "numberOfClasses", numberOfClasses, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'numberOfClasses' field") } if err := WriteSimpleTypeArrayField(ctx, "classId", m.GetClassId(), WriteUnsignedShort(writeBuffer, 16)); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/CipConnectedRequest.go b/plc4go/protocols/eip/readwrite/model/CipConnectedRequest.go index 6e950774af..d5237d4abf 100644 --- a/plc4go/protocols/eip/readwrite/model/CipConnectedRequest.go +++ b/plc4go/protocols/eip/readwrite/model/CipConnectedRequest.go @@ -224,12 +224,9 @@ func (m *_CipConnectedRequest) SerializeWithWriteBuffer(ctx context.Context, wri if pushErr := writeBuffer.PushContext("CipConnectedRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CipConnectedRequest") } - - // Implicit Field (requestPathSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) requestPathSize := uint8(uint8(uint8(len(m.GetPathSegments()))) / uint8(uint8(2))) - _requestPathSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("requestPathSize", 8, uint8((requestPathSize))) - if _requestPathSizeErr != nil { - return errors.Wrap(_requestPathSizeErr, "Error serializing 'requestPathSize' field") + if err := WriteImplicitField(ctx, "requestPathSize", requestPathSize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'requestPathSize' field") } if err := WriteByteArrayField(ctx, "pathSegments", m.GetPathSegments(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/CipConnectionManagerRequest.go b/plc4go/protocols/eip/readwrite/model/CipConnectionManagerRequest.go index 9287464579..7b555b9de4 100644 --- a/plc4go/protocols/eip/readwrite/model/CipConnectionManagerRequest.go +++ b/plc4go/protocols/eip/readwrite/model/CipConnectionManagerRequest.go @@ -505,12 +505,9 @@ func (m *_CipConnectionManagerRequest) SerializeWithWriteBuffer(ctx context.Cont if pushErr := writeBuffer.PushContext("CipConnectionManagerRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CipConnectionManagerRequest") } - - // Implicit Field (requestPathSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) requestPathSize := uint8(uint8((uint8(m.GetClassSegment().GetLengthInBytes(ctx)) + uint8(m.GetInstanceSegment().GetLengthInBytes(ctx)))) / uint8(uint8(2))) - _requestPathSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("requestPathSize", 8, uint8((requestPathSize))) - if _requestPathSizeErr != nil { - return errors.Wrap(_requestPathSizeErr, "Error serializing 'requestPathSize' field") + if err := WriteImplicitField(ctx, "requestPathSize", requestPathSize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'requestPathSize' field") } // Simple Field (classSegment) diff --git a/plc4go/protocols/eip/readwrite/model/CipConnectionManagerResponse.go b/plc4go/protocols/eip/readwrite/model/CipConnectionManagerResponse.go index c1d56906a8..fd0721ea8f 100644 --- a/plc4go/protocols/eip/readwrite/model/CipConnectionManagerResponse.go +++ b/plc4go/protocols/eip/readwrite/model/CipConnectionManagerResponse.go @@ -389,12 +389,9 @@ func (m *_CipConnectionManagerResponse) SerializeWithWriteBuffer(ctx context.Con if _toApiErr != nil { return errors.Wrap(_toApiErr, "Error serializing 'toApi' field") } - - // Implicit Field (replySize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) replySize := uint8(uint8(uint8(m.GetLengthInBytes(ctx))) - uint8(uint8(30))) - _replySizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("replySize", 8, uint8((replySize))) - if _replySizeErr != nil { - return errors.Wrap(_replySizeErr, "Error serializing 'replySize' field") + if err := WriteImplicitField(ctx, "replySize", replySize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'replySize' field") } // Reserved Field (reserved) diff --git a/plc4go/protocols/eip/readwrite/model/CipIdentity.go b/plc4go/protocols/eip/readwrite/model/CipIdentity.go index 70ffd9955e..95c4343ed8 100644 --- a/plc4go/protocols/eip/readwrite/model/CipIdentity.go +++ b/plc4go/protocols/eip/readwrite/model/CipIdentity.go @@ -447,12 +447,9 @@ func (m *_CipIdentity) SerializeWithWriteBuffer(ctx context.Context, writeBuffer if pushErr := writeBuffer.PushContext("CipIdentity"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CipIdentity") } - - // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) itemLength := uint16(uint16(uint16(34)) + uint16(uint8(len(m.GetProductName())))) - _itemLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("itemLength", 16, uint16((itemLength))) - if _itemLengthErr != nil { - return errors.Wrap(_itemLengthErr, "Error serializing 'itemLength' field") + if err := WriteImplicitField(ctx, "itemLength", itemLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'itemLength' field") } // Simple Field (encapsulationProtocolVersion) @@ -536,12 +533,9 @@ func (m *_CipIdentity) SerializeWithWriteBuffer(ctx context.Context, writeBuffer if _serialNumberErr != nil { return errors.Wrap(_serialNumberErr, "Error serializing 'serialNumber' field") } - - // Implicit Field (productNameLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) productNameLength := uint8(uint8(len(m.GetProductName()))) - _productNameLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("productNameLength", 8, uint8((productNameLength))) - if _productNameLengthErr != nil { - return errors.Wrap(_productNameLengthErr, "Error serializing 'productNameLength' field") + if err := WriteImplicitField(ctx, "productNameLength", productNameLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'productNameLength' field") } // Simple Field (productName) diff --git a/plc4go/protocols/eip/readwrite/model/CipRRData.go b/plc4go/protocols/eip/readwrite/model/CipRRData.go index 709dd89834..8a7d1da5fe 100644 --- a/plc4go/protocols/eip/readwrite/model/CipRRData.go +++ b/plc4go/protocols/eip/readwrite/model/CipRRData.go @@ -259,12 +259,9 @@ func (m *_CipRRData) SerializeWithWriteBuffer(ctx context.Context, writeBuffer u if _timeoutErr != nil { return errors.Wrap(_timeoutErr, "Error serializing 'timeout' field") } - - // Implicit Field (typeIdCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) typeIdCount := uint16(uint16(len(m.GetTypeIds()))) - _typeIdCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("typeIdCount", 16, uint16((typeIdCount))) - if _typeIdCountErr != nil { - return errors.Wrap(_typeIdCountErr, "Error serializing 'typeIdCount' field") + if err := WriteImplicitField(ctx, "typeIdCount", typeIdCount, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'typeIdCount' field") } if err := WriteComplexTypeArrayField(ctx, "typeIds", m.GetTypeIds(), writeBuffer); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/CipReadRequest.go b/plc4go/protocols/eip/readwrite/model/CipReadRequest.go index 25fded2f28..c6a1c5560c 100644 --- a/plc4go/protocols/eip/readwrite/model/CipReadRequest.go +++ b/plc4go/protocols/eip/readwrite/model/CipReadRequest.go @@ -220,12 +220,9 @@ func (m *_CipReadRequest) SerializeWithWriteBuffer(ctx context.Context, writeBuf if pushErr := writeBuffer.PushContext("CipReadRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CipReadRequest") } - - // Implicit Field (requestPathSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) requestPathSize := uint8(uint8(uint8(len(m.GetTag()))) / uint8(uint8(2))) - _requestPathSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("requestPathSize", 8, uint8((requestPathSize))) - if _requestPathSizeErr != nil { - return errors.Wrap(_requestPathSizeErr, "Error serializing 'requestPathSize' field") + if err := WriteImplicitField(ctx, "requestPathSize", requestPathSize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'requestPathSize' field") } if err := WriteByteArrayField(ctx, "tag", m.GetTag(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go b/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go index 93d64c8004..50ce376e5e 100644 --- a/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go +++ b/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go @@ -193,12 +193,9 @@ func (m *_CipSecurityInformation) SerializeWithWriteBuffer(ctx context.Context, if pushErr := writeBuffer.PushContext("CipSecurityInformation"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CipSecurityInformation") } - - // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) itemLength := uint16(uint16(len(m.GetTodoImplement()))) - _itemLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("itemLength", 16, uint16((itemLength))) - if _itemLengthErr != nil { - return errors.Wrap(_itemLengthErr, "Error serializing 'itemLength' field") + if err := WriteImplicitField(ctx, "itemLength", itemLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'itemLength' field") } if err := WriteSimpleTypeArrayField(ctx, "todoImplement", m.GetTodoImplement(), WriteUnsignedByte(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/CipUnconnectedRequest.go b/plc4go/protocols/eip/readwrite/model/CipUnconnectedRequest.go index afa8f06594..08f043ed03 100644 --- a/plc4go/protocols/eip/readwrite/model/CipUnconnectedRequest.go +++ b/plc4go/protocols/eip/readwrite/model/CipUnconnectedRequest.go @@ -314,12 +314,9 @@ func (m *_CipUnconnectedRequest) SerializeWithWriteBuffer(ctx context.Context, w if pushErr := writeBuffer.PushContext("CipUnconnectedRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CipUnconnectedRequest") } - - // Implicit Field (requestPathSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) requestPathSize := uint8(uint8((uint8(m.GetClassSegment().GetLengthInBytes(ctx)) + uint8(m.GetInstanceSegment().GetLengthInBytes(ctx)))) / uint8(uint8(2))) - _requestPathSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("requestPathSize", 8, uint8((requestPathSize))) - if _requestPathSizeErr != nil { - return errors.Wrap(_requestPathSizeErr, "Error serializing 'requestPathSize' field") + if err := WriteImplicitField(ctx, "requestPathSize", requestPathSize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'requestPathSize' field") } // Simple Field (classSegment) @@ -361,12 +358,9 @@ func (m *_CipUnconnectedRequest) SerializeWithWriteBuffer(ctx context.Context, w return errors.Wrap(_err, "Error serializing 'reserved' field") } } - - // Implicit Field (messageSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) messageSize := uint16(uint16(uint16(uint16(m.GetLengthInBytes(ctx)))-uint16(uint16(10))) - uint16(uint16(4))) - _messageSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("messageSize", 16, uint16((messageSize))) - if _messageSizeErr != nil { - return errors.Wrap(_messageSizeErr, "Error serializing 'messageSize' field") + if err := WriteImplicitField(ctx, "messageSize", messageSize, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'messageSize' field") } // Simple Field (unconnectedService) diff --git a/plc4go/protocols/eip/readwrite/model/CipWriteRequest.go b/plc4go/protocols/eip/readwrite/model/CipWriteRequest.go index 553052f333..4f562f2731 100644 --- a/plc4go/protocols/eip/readwrite/model/CipWriteRequest.go +++ b/plc4go/protocols/eip/readwrite/model/CipWriteRequest.go @@ -256,12 +256,9 @@ func (m *_CipWriteRequest) SerializeWithWriteBuffer(ctx context.Context, writeBu if pushErr := writeBuffer.PushContext("CipWriteRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for CipWriteRequest") } - - // Implicit Field (requestPathSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) requestPathSize := uint8(uint8(uint8(len(m.GetTag()))) / uint8(uint8(2))) - _requestPathSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("requestPathSize", 8, uint8((requestPathSize))) - if _requestPathSizeErr != nil { - return errors.Wrap(_requestPathSizeErr, "Error serializing 'requestPathSize' field") + if err := WriteImplicitField(ctx, "requestPathSize", requestPathSize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'requestPathSize' field") } if err := WriteByteArrayField(ctx, "tag", m.GetTag(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/ConnectedDataItem.go b/plc4go/protocols/eip/readwrite/model/ConnectedDataItem.go index bdaa5fe0a4..d24c624c32 100644 --- a/plc4go/protocols/eip/readwrite/model/ConnectedDataItem.go +++ b/plc4go/protocols/eip/readwrite/model/ConnectedDataItem.go @@ -208,12 +208,9 @@ func (m *_ConnectedDataItem) SerializeWithWriteBuffer(ctx context.Context, write if pushErr := writeBuffer.PushContext("ConnectedDataItem"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ConnectedDataItem") } - - // Implicit Field (packetSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) packetSize := uint16(uint16(m.GetService().GetLengthInBytes(ctx)) + uint16(uint16(2))) - _packetSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("packetSize", 16, uint16((packetSize))) - if _packetSizeErr != nil { - return errors.Wrap(_packetSizeErr, "Error serializing 'packetSize' field") + if err := WriteImplicitField(ctx, "packetSize", packetSize, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'packetSize' field") } // Simple Field (sequenceCount) diff --git a/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go b/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go index 6f36aecc8b..95a7e52b62 100644 --- a/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go +++ b/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go @@ -211,12 +211,9 @@ func (m *_EipListIdentityResponse) SerializeWithWriteBuffer(ctx context.Context, if pushErr := writeBuffer.PushContext("EipListIdentityResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for EipListIdentityResponse") } - - // Implicit Field (itemCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) itemCount := uint16(uint16(len(m.GetItems()))) - _itemCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("itemCount", 16, uint16((itemCount))) - if _itemCountErr != nil { - return errors.Wrap(_itemCountErr, "Error serializing 'itemCount' field") + if err := WriteImplicitField(ctx, "itemCount", itemCount, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'itemCount' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/EipPacket.go b/plc4go/protocols/eip/readwrite/model/EipPacket.go index 637a647c94..c2873342c0 100644 --- a/plc4go/protocols/eip/readwrite/model/EipPacket.go +++ b/plc4go/protocols/eip/readwrite/model/EipPacket.go @@ -290,12 +290,9 @@ func (pm *_EipPacket) SerializeParent(ctx context.Context, writeBuffer utils.Wri if err := WriteDiscriminatorField(ctx, "command", m.GetCommand(), WriteUnsignedShort(writeBuffer, 16)); err != nil { return errors.Wrap(err, "Error serializing 'command' field") } - - // Implicit Field (packetLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) packetLength := uint16(uint16(uint16(m.GetLengthInBytes(ctx))) - uint16(uint16(24))) - _packetLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("packetLength", 16, uint16((packetLength))) - if _packetLengthErr != nil { - return errors.Wrap(_packetLengthErr, "Error serializing 'packetLength' field") + if err := WriteImplicitField(ctx, "packetLength", packetLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'packetLength' field") } // Simple Field (sessionHandle) diff --git a/plc4go/protocols/eip/readwrite/model/GetAttributeAllRequest.go b/plc4go/protocols/eip/readwrite/model/GetAttributeAllRequest.go index 8e4d2fd4bf..4d250f83b8 100644 --- a/plc4go/protocols/eip/readwrite/model/GetAttributeAllRequest.go +++ b/plc4go/protocols/eip/readwrite/model/GetAttributeAllRequest.go @@ -218,12 +218,9 @@ func (m *_GetAttributeAllRequest) SerializeWithWriteBuffer(ctx context.Context, if pushErr := writeBuffer.PushContext("GetAttributeAllRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for GetAttributeAllRequest") } - - // Implicit Field (requestPathSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) requestPathSize := uint8(uint8((uint8(m.GetClassSegment().GetLengthInBytes(ctx)) + uint8(m.GetInstanceSegment().GetLengthInBytes(ctx)))) / uint8(uint8(2))) - _requestPathSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("requestPathSize", 8, uint8((requestPathSize))) - if _requestPathSizeErr != nil { - return errors.Wrap(_requestPathSizeErr, "Error serializing 'requestPathSize' field") + if err := WriteImplicitField(ctx, "requestPathSize", requestPathSize, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'requestPathSize' field") } // Simple Field (classSegment) diff --git a/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go b/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go index 9fed839885..0e2a5b972b 100644 --- a/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go +++ b/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go @@ -211,12 +211,9 @@ func (m *_ListServicesResponse) SerializeWithWriteBuffer(ctx context.Context, wr if pushErr := writeBuffer.PushContext("ListServicesResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ListServicesResponse") } - - // Implicit Field (typeIdCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) typeIdCount := uint16(uint16(len(m.GetTypeIds()))) - _typeIdCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("typeIdCount", 16, uint16((typeIdCount))) - if _typeIdCountErr != nil { - return errors.Wrap(_typeIdCountErr, "Error serializing 'typeIdCount' field") + if err := WriteImplicitField(ctx, "typeIdCount", typeIdCount, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'typeIdCount' field") } if err := WriteComplexTypeArrayField(ctx, "typeIds", m.GetTypeIds(), writeBuffer); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/SendUnitData.go b/plc4go/protocols/eip/readwrite/model/SendUnitData.go index 339ad1e670..51a650471c 100644 --- a/plc4go/protocols/eip/readwrite/model/SendUnitData.go +++ b/plc4go/protocols/eip/readwrite/model/SendUnitData.go @@ -264,12 +264,9 @@ func (m *_SendUnitData) SerializeWithWriteBuffer(ctx context.Context, writeBuffe if _timeoutErr != nil { return errors.Wrap(_timeoutErr, "Error serializing 'timeout' field") } - - // Implicit Field (typeIdCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) typeIdCount := uint16(uint16(len(m.GetTypeIds()))) - _typeIdCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("typeIdCount", 16, uint16((typeIdCount))) - if _typeIdCountErr != nil { - return errors.Wrap(_typeIdCountErr, "Error serializing 'typeIdCount' field") + if err := WriteImplicitField(ctx, "typeIdCount", typeIdCount, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'typeIdCount' field") } if err := WriteComplexTypeArrayField(ctx, "typeIds", m.GetTypeIds(), writeBuffer); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/Services.go b/plc4go/protocols/eip/readwrite/model/Services.go index 7c287bc025..ec25b91a68 100644 --- a/plc4go/protocols/eip/readwrite/model/Services.go +++ b/plc4go/protocols/eip/readwrite/model/Services.go @@ -189,12 +189,9 @@ func (m *_Services) SerializeWithWriteBuffer(ctx context.Context, writeBuffer ut if pushErr := writeBuffer.PushContext("Services"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for Services") } - - // Implicit Field (serviceNb) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) serviceNb := uint16(uint16(len(m.GetOffsets()))) - _serviceNbErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("serviceNb", 16, uint16((serviceNb))) - if _serviceNbErr != nil { - return errors.Wrap(_serviceNbErr, "Error serializing 'serviceNb' field") + if err := WriteImplicitField(ctx, "serviceNb", serviceNb, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'serviceNb' field") } if err := WriteSimpleTypeArrayField(ctx, "offsets", m.GetOffsets(), WriteUnsignedShort(writeBuffer, 16)); err != nil { diff --git a/plc4go/protocols/eip/readwrite/model/ServicesResponse.go b/plc4go/protocols/eip/readwrite/model/ServicesResponse.go index 63a387a65a..6fdca5485d 100644 --- a/plc4go/protocols/eip/readwrite/model/ServicesResponse.go +++ b/plc4go/protocols/eip/readwrite/model/ServicesResponse.go @@ -265,12 +265,9 @@ func (m *_ServicesResponse) SerializeWithWriteBuffer(ctx context.Context, writeB if pushErr := writeBuffer.PushContext("ServicesResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ServicesResponse") } - - // Implicit Field (serviceLen) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) serviceLen := uint16(uint16(uint16(m.GetLengthInBytes(ctx))) - uint16(uint16(4))) - _serviceLenErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("serviceLen", 16, uint16((serviceLen))) - if _serviceLenErr != nil { - return errors.Wrap(_serviceLenErr, "Error serializing 'serviceLen' field") + if err := WriteImplicitField(ctx, "serviceLen", serviceLen, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'serviceLen' field") } // Simple Field (encapsulationProtocol) diff --git a/plc4go/protocols/eip/readwrite/model/UnConnectedDataItem.go b/plc4go/protocols/eip/readwrite/model/UnConnectedDataItem.go index c692f00d06..f493328878 100644 --- a/plc4go/protocols/eip/readwrite/model/UnConnectedDataItem.go +++ b/plc4go/protocols/eip/readwrite/model/UnConnectedDataItem.go @@ -191,12 +191,9 @@ func (m *_UnConnectedDataItem) SerializeWithWriteBuffer(ctx context.Context, wri if pushErr := writeBuffer.PushContext("UnConnectedDataItem"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for UnConnectedDataItem") } - - // Implicit Field (packetSize) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) packetSize := uint16(m.GetService().GetLengthInBytes(ctx)) - _packetSizeErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("packetSize", 16, uint16((packetSize))) - if _packetSizeErr != nil { - return errors.Wrap(_packetSizeErr, "Error serializing 'packetSize' field") + if err := WriteImplicitField(ctx, "packetSize", packetSize, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'packetSize' field") } // Simple Field (service) diff --git a/plc4go/protocols/knxnetip/readwrite/model/ApduDataMemoryResponse.go b/plc4go/protocols/knxnetip/readwrite/model/ApduDataMemoryResponse.go index 7b303df49b..540e94a2fc 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/ApduDataMemoryResponse.go +++ b/plc4go/protocols/knxnetip/readwrite/model/ApduDataMemoryResponse.go @@ -212,12 +212,9 @@ func (m *_ApduDataMemoryResponse) SerializeWithWriteBuffer(ctx context.Context, if pushErr := writeBuffer.PushContext("ApduDataMemoryResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ApduDataMemoryResponse") } - - // Implicit Field (numBytes) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numBytes := uint8(uint8(len(m.GetData()))) - _numBytesErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("numBytes", 6, uint8((numBytes))) - if _numBytesErr != nil { - return errors.Wrap(_numBytesErr, "Error serializing 'numBytes' field") + if err := WriteImplicitField(ctx, "numBytes", numBytes, WriteUnsignedByte(writeBuffer, 6)); err != nil { + return errors.Wrap(err, "Error serializing 'numBytes' field") } // Simple Field (address) diff --git a/plc4go/protocols/knxnetip/readwrite/model/ConnectionRequestInformation.go b/plc4go/protocols/knxnetip/readwrite/model/ConnectionRequestInformation.go index 63671c4c96..faa880427d 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/ConnectionRequestInformation.go +++ b/plc4go/protocols/knxnetip/readwrite/model/ConnectionRequestInformation.go @@ -186,12 +186,9 @@ func (pm *_ConnectionRequestInformation) SerializeParent(ctx context.Context, wr if pushErr := writeBuffer.PushContext("ConnectionRequestInformation"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ConnectionRequestInformation") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } if err := WriteDiscriminatorField(ctx, "connectionType", m.GetConnectionType(), WriteUnsignedByte(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/knxnetip/readwrite/model/ConnectionResponseDataBlock.go b/plc4go/protocols/knxnetip/readwrite/model/ConnectionResponseDataBlock.go index 77cacc6ba4..6493f28f00 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/ConnectionResponseDataBlock.go +++ b/plc4go/protocols/knxnetip/readwrite/model/ConnectionResponseDataBlock.go @@ -186,12 +186,9 @@ func (pm *_ConnectionResponseDataBlock) SerializeParent(ctx context.Context, wri if pushErr := writeBuffer.PushContext("ConnectionResponseDataBlock"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ConnectionResponseDataBlock") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } if err := WriteDiscriminatorField(ctx, "connectionType", m.GetConnectionType(), WriteUnsignedByte(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/knxnetip/readwrite/model/DIBDeviceInfo.go b/plc4go/protocols/knxnetip/readwrite/model/DIBDeviceInfo.go index fdb4412343..1068f3f212 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/DIBDeviceInfo.go +++ b/plc4go/protocols/knxnetip/readwrite/model/DIBDeviceInfo.go @@ -292,12 +292,9 @@ func (m *_DIBDeviceInfo) SerializeWithWriteBuffer(ctx context.Context, writeBuff if pushErr := writeBuffer.PushContext("DIBDeviceInfo"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for DIBDeviceInfo") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (descriptionType) diff --git a/plc4go/protocols/knxnetip/readwrite/model/DIBSuppSvcFamilies.go b/plc4go/protocols/knxnetip/readwrite/model/DIBSuppSvcFamilies.go index b1659b714d..ad47375810 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/DIBSuppSvcFamilies.go +++ b/plc4go/protocols/knxnetip/readwrite/model/DIBSuppSvcFamilies.go @@ -180,12 +180,9 @@ func (m *_DIBSuppSvcFamilies) SerializeWithWriteBuffer(ctx context.Context, writ if pushErr := writeBuffer.PushContext("DIBSuppSvcFamilies"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for DIBSuppSvcFamilies") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (descriptionType) diff --git a/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationAckDataBlock.go b/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationAckDataBlock.go index 4b19e8d176..23edf3e5e7 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationAckDataBlock.go +++ b/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationAckDataBlock.go @@ -192,12 +192,9 @@ func (m *_DeviceConfigurationAckDataBlock) SerializeWithWriteBuffer(ctx context. if pushErr := writeBuffer.PushContext("DeviceConfigurationAckDataBlock"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for DeviceConfigurationAckDataBlock") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (communicationChannelId) diff --git a/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationRequestDataBlock.go b/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationRequestDataBlock.go index dee26ed542..329e54af5c 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationRequestDataBlock.go +++ b/plc4go/protocols/knxnetip/readwrite/model/DeviceConfigurationRequestDataBlock.go @@ -187,12 +187,9 @@ func (m *_DeviceConfigurationRequestDataBlock) SerializeWithWriteBuffer(ctx cont if pushErr := writeBuffer.PushContext("DeviceConfigurationRequestDataBlock"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for DeviceConfigurationRequestDataBlock") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (communicationChannelId) diff --git a/plc4go/protocols/knxnetip/readwrite/model/HPAIControlEndpoint.go b/plc4go/protocols/knxnetip/readwrite/model/HPAIControlEndpoint.go index d07097679f..3be4fb8249 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/HPAIControlEndpoint.go +++ b/plc4go/protocols/knxnetip/readwrite/model/HPAIControlEndpoint.go @@ -192,12 +192,9 @@ func (m *_HPAIControlEndpoint) SerializeWithWriteBuffer(ctx context.Context, wri if pushErr := writeBuffer.PushContext("HPAIControlEndpoint"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for HPAIControlEndpoint") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (hostProtocolCode) diff --git a/plc4go/protocols/knxnetip/readwrite/model/HPAIDataEndpoint.go b/plc4go/protocols/knxnetip/readwrite/model/HPAIDataEndpoint.go index 4771776fa6..02797a641a 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/HPAIDataEndpoint.go +++ b/plc4go/protocols/knxnetip/readwrite/model/HPAIDataEndpoint.go @@ -192,12 +192,9 @@ func (m *_HPAIDataEndpoint) SerializeWithWriteBuffer(ctx context.Context, writeB if pushErr := writeBuffer.PushContext("HPAIDataEndpoint"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for HPAIDataEndpoint") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (hostProtocolCode) diff --git a/plc4go/protocols/knxnetip/readwrite/model/HPAIDiscoveryEndpoint.go b/plc4go/protocols/knxnetip/readwrite/model/HPAIDiscoveryEndpoint.go index 8fb0503c15..148b1a0716 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/HPAIDiscoveryEndpoint.go +++ b/plc4go/protocols/knxnetip/readwrite/model/HPAIDiscoveryEndpoint.go @@ -192,12 +192,9 @@ func (m *_HPAIDiscoveryEndpoint) SerializeWithWriteBuffer(ctx context.Context, w if pushErr := writeBuffer.PushContext("HPAIDiscoveryEndpoint"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for HPAIDiscoveryEndpoint") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (hostProtocolCode) diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxNetIpMessage.go b/plc4go/protocols/knxnetip/readwrite/model/KnxNetIpMessage.go index eeeee94e1a..1fa17b10cd 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxNetIpMessage.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxNetIpMessage.go @@ -251,12 +251,9 @@ func (pm *_KnxNetIpMessage) SerializeParent(ctx context.Context, writeBuffer uti if pushErr := writeBuffer.PushContext("KnxNetIpMessage"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for KnxNetIpMessage") } - - // Implicit Field (headerLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) headerLength := uint8(uint8(6)) - _headerLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("headerLength", 8, uint8((headerLength))) - if _headerLengthErr != nil { - return errors.Wrap(_headerLengthErr, "Error serializing 'headerLength' field") + if err := WriteImplicitField(ctx, "headerLength", headerLength, WriteUnsignedByte(writeBuffer, 8), codegen.WithByteOrder(binary.BigEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'headerLength' field") } if err := WriteConstField(ctx, "protocolVersion", KnxNetIpMessage_PROTOCOLVERSION, WriteUnsignedByte(writeBuffer, 8), codegen.WithByteOrder(binary.BigEndian)); err != nil { @@ -266,12 +263,9 @@ func (pm *_KnxNetIpMessage) SerializeParent(ctx context.Context, writeBuffer uti if err := WriteDiscriminatorField(ctx, "msgType", m.GetMsgType(), WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { return errors.Wrap(err, "Error serializing 'msgType' field") } - - // Implicit Field (totalLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) totalLength := uint16(uint16(m.GetLengthInBytes(ctx))) - _totalLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("totalLength", 16, uint16((totalLength))) - if _totalLengthErr != nil { - return errors.Wrap(_totalLengthErr, "Error serializing 'totalLength' field") + if err := WriteImplicitField(ctx, "totalLength", totalLength, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'totalLength' field") } // Switch field (Depending on the discriminator values, passes the serialization to a sub-type) diff --git a/plc4go/protocols/knxnetip/readwrite/model/LDataExtended.go b/plc4go/protocols/knxnetip/readwrite/model/LDataExtended.go index 59e727b337..5a99febef3 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/LDataExtended.go +++ b/plc4go/protocols/knxnetip/readwrite/model/LDataExtended.go @@ -325,12 +325,9 @@ func (m *_LDataExtended) SerializeWithWriteBuffer(ctx context.Context, writeBuff if err := WriteByteArrayField(ctx, "destinationAddress", m.GetDestinationAddress(), WriteByteArray(writeBuffer, 8)); err != nil { return errors.Wrap(err, "Error serializing 'destinationAddress' field") } - - // Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataLength := uint8(uint8(m.GetApdu().GetLengthInBytes(ctx)) - uint8(uint8(1))) - _dataLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("dataLength", 8, uint8((dataLength))) - if _dataLengthErr != nil { - return errors.Wrap(_dataLengthErr, "Error serializing 'dataLength' field") + if err := WriteImplicitField(ctx, "dataLength", dataLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'dataLength' field") } // Simple Field (apdu) diff --git a/plc4go/protocols/knxnetip/readwrite/model/TunnelingRequestDataBlock.go b/plc4go/protocols/knxnetip/readwrite/model/TunnelingRequestDataBlock.go index 6679b3c25e..0582c76bcd 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/TunnelingRequestDataBlock.go +++ b/plc4go/protocols/knxnetip/readwrite/model/TunnelingRequestDataBlock.go @@ -187,12 +187,9 @@ func (m *_TunnelingRequestDataBlock) SerializeWithWriteBuffer(ctx context.Contex if pushErr := writeBuffer.PushContext("TunnelingRequestDataBlock"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for TunnelingRequestDataBlock") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (communicationChannelId) diff --git a/plc4go/protocols/knxnetip/readwrite/model/TunnelingResponseDataBlock.go b/plc4go/protocols/knxnetip/readwrite/model/TunnelingResponseDataBlock.go index 3654963506..733fa55fa5 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/TunnelingResponseDataBlock.go +++ b/plc4go/protocols/knxnetip/readwrite/model/TunnelingResponseDataBlock.go @@ -192,12 +192,9 @@ func (m *_TunnelingResponseDataBlock) SerializeWithWriteBuffer(ctx context.Conte if pushErr := writeBuffer.PushContext("TunnelingResponseDataBlock"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for TunnelingResponseDataBlock") } - - // Implicit Field (structureLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) structureLength := uint8(uint8(m.GetLengthInBytes(ctx))) - _structureLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("structureLength", 8, uint8((structureLength))) - if _structureLengthErr != nil { - return errors.Wrap(_structureLengthErr, "Error serializing 'structureLength' field") + if err := WriteImplicitField(ctx, "structureLength", structureLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'structureLength' field") } // Simple Field (communicationChannelId) diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusDeviceInformationObject.go b/plc4go/protocols/modbus/readwrite/model/ModbusDeviceInformationObject.go index f7ab680ba9..9e81ea60ec 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusDeviceInformationObject.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusDeviceInformationObject.go @@ -185,12 +185,9 @@ func (m *_ModbusDeviceInformationObject) SerializeWithWriteBuffer(ctx context.Co if _objectIdErr != nil { return errors.Wrap(_objectIdErr, "Error serializing 'objectId' field") } - - // Implicit Field (objectLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) objectLength := uint8(uint8(len(m.GetData()))) - _objectLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("objectLength", 8, uint8((objectLength))) - if _objectLengthErr != nil { - return errors.Wrap(_objectLengthErr, "Error serializing 'objectLength' field") + if err := WriteImplicitField(ctx, "objectLength", objectLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'objectLength' field") } if err := WriteByteArrayField(ctx, "data", m.GetData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go index 5b12095e3d..8c29c893e2 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUGetComEventLogResponse.go @@ -252,12 +252,9 @@ func (m *_ModbusPDUGetComEventLogResponse) SerializeWithWriteBuffer(ctx context. if pushErr := writeBuffer.PushContext("ModbusPDUGetComEventLogResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUGetComEventLogResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(uint8(len(m.GetEvents()))) + uint8(uint8(6))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } // Simple Field (status) diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go index 8671ef0532..9359d37bd0 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadCoilsResponse.go @@ -201,12 +201,9 @@ func (m *_ModbusPDUReadCoilsResponse) SerializeWithWriteBuffer(ctx context.Conte if pushErr := writeBuffer.PushContext("ModbusPDUReadCoilsResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadCoilsResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go index 4f9ea419ef..ffb9b23685 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go @@ -370,12 +370,9 @@ func (m *_ModbusPDUReadDeviceIdentificationResponse) SerializeWithWriteBuffer(ct if _nextObjectIdErr != nil { return errors.Wrap(_nextObjectIdErr, "Error serializing 'nextObjectId' field") } - - // Implicit Field (numberOfObjects) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numberOfObjects := uint8(uint8(len(m.GetObjects()))) - _numberOfObjectsErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("numberOfObjects", 8, uint8((numberOfObjects))) - if _numberOfObjectsErr != nil { - return errors.Wrap(_numberOfObjectsErr, "Error serializing 'numberOfObjects' field") + if err := WriteImplicitField(ctx, "numberOfObjects", numberOfObjects, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'numberOfObjects' field") } if err := WriteComplexTypeArrayField(ctx, "objects", m.GetObjects(), writeBuffer); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go index 35faa240d8..9879a86886 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDiscreteInputsResponse.go @@ -201,12 +201,9 @@ func (m *_ModbusPDUReadDiscreteInputsResponse) SerializeWithWriteBuffer(ctx cont if pushErr := writeBuffer.PushContext("ModbusPDUReadDiscreteInputsResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadDiscreteInputsResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go index e98fae0c95..3d3260ee9e 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go @@ -210,19 +210,13 @@ func (m *_ModbusPDUReadFifoQueueResponse) SerializeWithWriteBuffer(ctx context.C if pushErr := writeBuffer.PushContext("ModbusPDUReadFifoQueueResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadFifoQueueResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint16(uint16((uint16(uint16(len(m.GetFifoValue()))) * uint16(uint16(2)))) + uint16(uint16(2))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("byteCount", 16, uint16((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } - - // Implicit Field (fifoCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) fifoCount := uint16(uint16((uint16(uint16(len(m.GetFifoValue()))) * uint16(uint16(2)))) / uint16(uint16(2))) - _fifoCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("fifoCount", 16, uint16((fifoCount))) - if _fifoCountErr != nil { - return errors.Wrap(_fifoCountErr, "Error serializing 'fifoCount' field") + if err := WriteImplicitField(ctx, "fifoCount", fifoCount, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'fifoCount' field") } if err := WriteSimpleTypeArrayField(ctx, "fifoValue", m.GetFifoValue(), WriteUnsignedShort(writeBuffer, 16)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go index 2f65c43552..13adbcbf0d 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordRequest.go @@ -210,12 +210,9 @@ func (m *_ModbusPDUReadFileRecordRequest) SerializeWithWriteBuffer(ctx context.C if pushErr := writeBuffer.PushContext("ModbusPDUReadFileRecordRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadFileRecordRequest") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(itemsArraySizeInBytes(m.GetItems()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go index b13589f42b..d681681100 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponse.go @@ -210,12 +210,9 @@ func (m *_ModbusPDUReadFileRecordResponse) SerializeWithWriteBuffer(ctx context. if pushErr := writeBuffer.PushContext("ModbusPDUReadFileRecordResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadFileRecordResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(itemsArraySizeInBytes(m.GetItems()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go index 70f97f0380..82db64454a 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFileRecordResponseItem.go @@ -178,12 +178,9 @@ func (m *_ModbusPDUReadFileRecordResponseItem) SerializeWithWriteBuffer(ctx cont if pushErr := writeBuffer.PushContext("ModbusPDUReadFileRecordResponseItem"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadFileRecordResponseItem") } - - // Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataLength := uint8(uint8(uint8(len(m.GetData()))) + uint8(uint8(1))) - _dataLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("dataLength", 8, uint8((dataLength))) - if _dataLengthErr != nil { - return errors.Wrap(_dataLengthErr, "Error serializing 'dataLength' field") + if err := WriteImplicitField(ctx, "dataLength", dataLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'dataLength' field") } // Simple Field (referenceType) diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go index 1f5fe5527a..bf9a704296 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadHoldingRegistersResponse.go @@ -201,12 +201,9 @@ func (m *_ModbusPDUReadHoldingRegistersResponse) SerializeWithWriteBuffer(ctx co if pushErr := writeBuffer.PushContext("ModbusPDUReadHoldingRegistersResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadHoldingRegistersResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go index 73356e2c65..16b780c4e0 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadInputRegistersResponse.go @@ -201,12 +201,9 @@ func (m *_ModbusPDUReadInputRegistersResponse) SerializeWithWriteBuffer(ctx cont if pushErr := writeBuffer.PushContext("ModbusPDUReadInputRegistersResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadInputRegistersResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go index 62e0d4d18b..1115578d91 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersRequest.go @@ -297,12 +297,9 @@ func (m *_ModbusPDUReadWriteMultipleHoldingRegistersRequest) SerializeWithWriteB if _writeQuantityErr != nil { return errors.Wrap(_writeQuantityErr, "Error serializing 'writeQuantity' field") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go index 806593b6ba..dcc741d0ee 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadWriteMultipleHoldingRegistersResponse.go @@ -201,12 +201,9 @@ func (m *_ModbusPDUReadWriteMultipleHoldingRegistersResponse) SerializeWithWrite if pushErr := writeBuffer.PushContext("ModbusPDUReadWriteMultipleHoldingRegistersResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReadWriteMultipleHoldingRegistersResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go index 7fcc22efd7..6ee0ae6172 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReportServerIdResponse.go @@ -201,12 +201,9 @@ func (m *_ModbusPDUReportServerIdResponse) SerializeWithWriteBuffer(ctx context. if pushErr := writeBuffer.PushContext("ModbusPDUReportServerIdResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUReportServerIdResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go index bf341304cf..3bc4cfe44c 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequest.go @@ -210,12 +210,9 @@ func (m *_ModbusPDUWriteFileRecordRequest) SerializeWithWriteBuffer(ctx context. if pushErr := writeBuffer.PushContext("ModbusPDUWriteFileRecordRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUWriteFileRecordRequest") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(itemsArraySizeInBytes(m.GetItems()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go index 08b37dacbc..2bd04be6f8 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordRequestItem.go @@ -231,12 +231,9 @@ func (m *_ModbusPDUWriteFileRecordRequestItem) SerializeWithWriteBuffer(ctx cont if _recordNumberErr != nil { return errors.Wrap(_recordNumberErr, "Error serializing 'recordNumber' field") } - - // Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) recordLength := uint16(uint16(uint16(len(m.GetRecordData()))) / uint16(uint16(2))) - _recordLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("recordLength", 16, uint16((recordLength))) - if _recordLengthErr != nil { - return errors.Wrap(_recordLengthErr, "Error serializing 'recordLength' field") + if err := WriteImplicitField(ctx, "recordLength", recordLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'recordLength' field") } if err := WriteByteArrayField(ctx, "recordData", m.GetRecordData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go index 827c52394f..22ac9a508a 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponse.go @@ -210,12 +210,9 @@ func (m *_ModbusPDUWriteFileRecordResponse) SerializeWithWriteBuffer(ctx context if pushErr := writeBuffer.PushContext("ModbusPDUWriteFileRecordResponse"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for ModbusPDUWriteFileRecordResponse") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(itemsArraySizeInBytes(m.GetItems()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go index 517a90d181..d62f28d050 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteFileRecordResponseItem.go @@ -231,12 +231,9 @@ func (m *_ModbusPDUWriteFileRecordResponseItem) SerializeWithWriteBuffer(ctx con if _recordNumberErr != nil { return errors.Wrap(_recordNumberErr, "Error serializing 'recordNumber' field") } - - // Implicit Field (recordLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) recordLength := uint16(uint16(uint16(len(m.GetRecordData()))) / uint16(uint16(2))) - _recordLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("recordLength", 16, uint16((recordLength))) - if _recordLengthErr != nil { - return errors.Wrap(_recordLengthErr, "Error serializing 'recordLength' field") + if err := WriteImplicitField(ctx, "recordLength", recordLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'recordLength' field") } if err := WriteByteArrayField(ctx, "recordData", m.GetRecordData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go index 6fdb2a7e85..10053aaedd 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleCoilsRequest.go @@ -249,12 +249,9 @@ func (m *_ModbusPDUWriteMultipleCoilsRequest) SerializeWithWriteBuffer(ctx conte if _quantityErr != nil { return errors.Wrap(_quantityErr, "Error serializing 'quantity' field") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go index 6b05a177b5..4147d5e399 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUWriteMultipleHoldingRegistersRequest.go @@ -249,12 +249,9 @@ func (m *_ModbusPDUWriteMultipleHoldingRegistersRequest) SerializeWithWriteBuffe if _quantityErr != nil { return errors.Wrap(_quantityErr, "Error serializing 'quantity' field") } - - // Implicit Field (byteCount) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) byteCount := uint8(uint8(len(m.GetValue()))) - _byteCountErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("byteCount", 8, uint8((byteCount))) - if _byteCountErr != nil { - return errors.Wrap(_byteCountErr, "Error serializing 'byteCount' field") + if err := WriteImplicitField(ctx, "byteCount", byteCount, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'byteCount' field") } if err := WriteByteArrayField(ctx, "value", m.GetValue(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusTcpADU.go b/plc4go/protocols/modbus/readwrite/model/ModbusTcpADU.go index e085d155ed..d43136c1d4 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusTcpADU.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusTcpADU.go @@ -265,12 +265,9 @@ func (m *_ModbusTcpADU) SerializeWithWriteBuffer(ctx context.Context, writeBuffe if err := WriteConstField(ctx, "protocolIdentifier", ModbusTcpADU_PROTOCOLIDENTIFIER, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { return errors.Wrap(err, "Error serializing 'protocolIdentifier' field") } - - // Implicit Field (length) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) length := uint16(uint16(m.GetPdu().GetLengthInBytes(ctx)) + uint16(uint16(1))) - _lengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("length", 16, uint16((length))) - if _lengthErr != nil { - return errors.Wrap(_lengthErr, "Error serializing 'length' field") + if err := WriteImplicitField(ctx, "length", length, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'length' field") } // Simple Field (unitIdentifier) diff --git a/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go b/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go index 35e1b8a984..27132df3fe 100644 --- a/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go +++ b/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go @@ -256,12 +256,9 @@ func (m *_DataChangeNotification) SerializeWithWriteBuffer(ctx context.Context, if pushErr := writeBuffer.PushContext("DataChangeNotification"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for DataChangeNotification") } - - // Implicit Field (notificationLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) notificationLength := int32(int32(m.GetLengthInBytes(ctx))) - _notificationLengthErr := /*TODO: migrate me*/ writeBuffer.WriteInt32("notificationLength", 32, int32((notificationLength))) - if _notificationLengthErr != nil { - return errors.Wrap(_notificationLengthErr, "Error serializing 'notificationLength' field") + if err := WriteImplicitField(ctx, "notificationLength", notificationLength, WriteSignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'notificationLength' field") } // Simple Field (noOfMonitoredItems) diff --git a/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go b/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go index 99dcc9e17a..fd09eacf03 100644 --- a/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go +++ b/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go @@ -215,12 +215,9 @@ func (m *_EventNotificationList) SerializeWithWriteBuffer(ctx context.Context, w if pushErr := writeBuffer.PushContext("EventNotificationList"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for EventNotificationList") } - - // Implicit Field (notificationLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) notificationLength := int32(int32(m.GetLengthInBytes(ctx))) - _notificationLengthErr := /*TODO: migrate me*/ writeBuffer.WriteInt32("notificationLength", 32, int32((notificationLength))) - if _notificationLengthErr != nil { - return errors.Wrap(_notificationLengthErr, "Error serializing 'notificationLength' field") + if err := WriteImplicitField(ctx, "notificationLength", notificationLength, WriteSignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'notificationLength' field") } // Simple Field (noOfEvents) diff --git a/plc4go/protocols/opcua/readwrite/model/MessagePDU.go b/plc4go/protocols/opcua/readwrite/model/MessagePDU.go index 1d6a411092..0009616fef 100644 --- a/plc4go/protocols/opcua/readwrite/model/MessagePDU.go +++ b/plc4go/protocols/opcua/readwrite/model/MessagePDU.go @@ -242,12 +242,9 @@ func (pm *_MessagePDU) SerializeParent(ctx context.Context, writeBuffer utils.Wr if _chunkErr != nil { return errors.Wrap(_chunkErr, "Error serializing 'chunk' field") } - - // Implicit Field (totalLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) totalLength := uint32(uint32(m.GetLengthInBytes(ctx))) - _totalLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint32("totalLength", 32, uint32((totalLength))) - if _totalLengthErr != nil { - return errors.Wrap(_totalLengthErr, "Error serializing 'totalLength' field") + if err := WriteImplicitField(ctx, "totalLength", totalLength, WriteUnsignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'totalLength' field") } // Switch field (Depending on the discriminator values, passes the serialization to a sub-type) diff --git a/plc4go/protocols/opcua/readwrite/model/PascalString.go b/plc4go/protocols/opcua/readwrite/model/PascalString.go index 55800b163f..daac467c01 100644 --- a/plc4go/protocols/opcua/readwrite/model/PascalString.go +++ b/plc4go/protocols/opcua/readwrite/model/PascalString.go @@ -185,12 +185,9 @@ func (m *_PascalString) SerializeWithWriteBuffer(ctx context.Context, writeBuffe if pushErr := writeBuffer.PushContext("PascalString"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for PascalString") } - - // Implicit Field (sLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) sLength := int32(Utf8LengthToPascalLength(ctx, m.GetStringValue())) - _sLengthErr := /*TODO: migrate me*/ writeBuffer.WriteInt32("sLength", 32, int32((sLength))) - if _sLengthErr != nil { - return errors.Wrap(_sLengthErr, "Error serializing 'sLength' field") + if err := WriteImplicitField(ctx, "sLength", sLength, WriteSignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'sLength' field") } // Virtual field stringLength := m.GetStringLength() diff --git a/plc4go/protocols/opcua/readwrite/model/StatusChangeNotification.go b/plc4go/protocols/opcua/readwrite/model/StatusChangeNotification.go index ade42e9246..683ac29bc4 100644 --- a/plc4go/protocols/opcua/readwrite/model/StatusChangeNotification.go +++ b/plc4go/protocols/opcua/readwrite/model/StatusChangeNotification.go @@ -208,12 +208,9 @@ func (m *_StatusChangeNotification) SerializeWithWriteBuffer(ctx context.Context if pushErr := writeBuffer.PushContext("StatusChangeNotification"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for StatusChangeNotification") } - - // Implicit Field (notificationLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) notificationLength := int32(int32(m.GetLengthInBytes(ctx))) - _notificationLengthErr := /*TODO: migrate me*/ writeBuffer.WriteInt32("notificationLength", 32, int32((notificationLength))) - if _notificationLengthErr != nil { - return errors.Wrap(_notificationLengthErr, "Error serializing 'notificationLength' field") + if err := WriteImplicitField(ctx, "notificationLength", notificationLength, WriteSignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'notificationLength' field") } // Simple Field (status) diff --git a/plc4go/protocols/opcua/readwrite/model/UserIdentityToken.go b/plc4go/protocols/opcua/readwrite/model/UserIdentityToken.go index b6cb48e45f..17c63f0b51 100644 --- a/plc4go/protocols/opcua/readwrite/model/UserIdentityToken.go +++ b/plc4go/protocols/opcua/readwrite/model/UserIdentityToken.go @@ -208,12 +208,9 @@ func (m *_UserIdentityToken) SerializeWithWriteBuffer(ctx context.Context, write if pushErr := writeBuffer.PushContext("UserIdentityToken"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for UserIdentityToken") } - - // Implicit Field (policyLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) policyLength := int32(int32(m.GetPolicyId().GetLengthInBytes(ctx)) + int32(m.GetUserIdentityTokenDefinition().GetLengthInBytes(ctx))) - _policyLengthErr := /*TODO: migrate me*/ writeBuffer.WriteInt32("policyLength", 32, int32((policyLength))) - if _policyLengthErr != nil { - return errors.Wrap(_policyLengthErr, "Error serializing 'policyLength' field") + if err := WriteImplicitField(ctx, "policyLength", policyLength, WriteSignedInt(writeBuffer, 32)); err != nil { + return errors.Wrap(err, "Error serializing 'policyLength' field") } // Simple Field (policyId) diff --git a/plc4go/protocols/s7/readwrite/model/COTPPacket.go b/plc4go/protocols/s7/readwrite/model/COTPPacket.go index 2c706bb149..5d08375229 100644 --- a/plc4go/protocols/s7/readwrite/model/COTPPacket.go +++ b/plc4go/protocols/s7/readwrite/model/COTPPacket.go @@ -249,12 +249,9 @@ func (pm *_COTPPacket) SerializeParent(ctx context.Context, writeBuffer utils.Wr if pushErr := writeBuffer.PushContext("COTPPacket"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for COTPPacket") } - - // Implicit Field (headerLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) headerLength := uint8(uint8(uint8(m.GetLengthInBytes(ctx))) - uint8((uint8((utils.InlineIf((bool((m.GetPayload()) != (nil))), func() any { return uint8((m.GetPayload()).GetLengthInBytes(ctx)) }, func() any { return uint8(uint8(0)) }).(uint8))) + uint8(uint8(1))))) - _headerLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("headerLength", 8, uint8((headerLength))) - if _headerLengthErr != nil { - return errors.Wrap(_headerLengthErr, "Error serializing 'headerLength' field") + if err := WriteImplicitField(ctx, "headerLength", headerLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'headerLength' field") } if err := WriteDiscriminatorField(ctx, "tpduCode", m.GetTpduCode(), WriteUnsignedByte(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/s7/readwrite/model/COTPParameter.go b/plc4go/protocols/s7/readwrite/model/COTPParameter.go index 4271bf2f5c..6400667742 100644 --- a/plc4go/protocols/s7/readwrite/model/COTPParameter.go +++ b/plc4go/protocols/s7/readwrite/model/COTPParameter.go @@ -199,12 +199,9 @@ func (pm *_COTPParameter) SerializeParent(ctx context.Context, writeBuffer utils if err := WriteDiscriminatorField(ctx, "parameterType", m.GetParameterType(), WriteUnsignedByte(writeBuffer, 8)); err != nil { return errors.Wrap(err, "Error serializing 'parameterType' field") } - - // Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) parameterLength := uint8(uint8(uint8(m.GetLengthInBytes(ctx))) - uint8(uint8(2))) - _parameterLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("parameterLength", 8, uint8((parameterLength))) - if _parameterLengthErr != nil { - return errors.Wrap(_parameterLengthErr, "Error serializing 'parameterLength' field") + if err := WriteImplicitField(ctx, "parameterLength", parameterLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'parameterLength' field") } // Switch field (Depending on the discriminator values, passes the serialization to a sub-type) diff --git a/plc4go/protocols/s7/readwrite/model/S7Message.go b/plc4go/protocols/s7/readwrite/model/S7Message.go index 7087378ab3..67533e38b4 100644 --- a/plc4go/protocols/s7/readwrite/model/S7Message.go +++ b/plc4go/protocols/s7/readwrite/model/S7Message.go @@ -333,19 +333,13 @@ func (pm *_S7Message) SerializeParent(ctx context.Context, writeBuffer utils.Wri if _tpduReferenceErr != nil { return errors.Wrap(_tpduReferenceErr, "Error serializing 'tpduReference' field") } - - // Implicit Field (parameterLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) parameterLength := uint16(utils.InlineIf(bool((m.GetParameter()) != (nil)), func() any { return uint16((m.GetParameter()).GetLengthInBytes(ctx)) }, func() any { return uint16(uint16(0)) }).(uint16)) - _parameterLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("parameterLength", 16, uint16((parameterLength))) - if _parameterLengthErr != nil { - return errors.Wrap(_parameterLengthErr, "Error serializing 'parameterLength' field") + if err := WriteImplicitField(ctx, "parameterLength", parameterLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'parameterLength' field") } - - // Implicit Field (payloadLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) payloadLength := uint16(utils.InlineIf(bool((m.GetPayload()) != (nil)), func() any { return uint16((m.GetPayload()).GetLengthInBytes(ctx)) }, func() any { return uint16(uint16(0)) }).(uint16)) - _payloadLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("payloadLength", 16, uint16((payloadLength))) - if _payloadLengthErr != nil { - return errors.Wrap(_payloadLengthErr, "Error serializing 'payloadLength' field") + if err := WriteImplicitField(ctx, "payloadLength", payloadLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'payloadLength' field") } // Switch field (Depending on the discriminator values, passes the serialization to a sub-type) diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterModeTransition.go b/plc4go/protocols/s7/readwrite/model/S7ParameterModeTransition.go index 255efae279..a330054470 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterModeTransition.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterModeTransition.go @@ -290,12 +290,9 @@ func (m *_S7ParameterModeTransition) SerializeWithWriteBuffer(ctx context.Contex return errors.Wrap(_err, "Error serializing 'reserved' field") } } - - // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) itemLength := uint8(uint8(uint8(m.GetLengthInBytes(ctx))) - uint8(uint8(2))) - _itemLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("itemLength", 8, uint8((itemLength))) - if _itemLengthErr != nil { - return errors.Wrap(_itemLengthErr, "Error serializing 'itemLength' field") + if err := WriteImplicitField(ctx, "itemLength", itemLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'itemLength' field") } // Simple Field (method) diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go b/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go index cd91df88aa..22bc322ab8 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go @@ -202,12 +202,9 @@ func (m *_S7ParameterReadVarRequest) SerializeWithWriteBuffer(ctx context.Contex if pushErr := writeBuffer.PushContext("S7ParameterReadVarRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for S7ParameterReadVarRequest") } - - // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numItems := uint8(uint8(len(m.GetItems()))) - _numItemsErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("numItems", 8, uint8((numItems))) - if _numItemsErr != nil { - return errors.Wrap(_numItemsErr, "Error serializing 'numItems' field") + if err := WriteImplicitField(ctx, "numItems", numItems, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'numItems' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go b/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go index a794de76ba..957de576dc 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go @@ -202,12 +202,9 @@ func (m *_S7ParameterUserData) SerializeWithWriteBuffer(ctx context.Context, wri if pushErr := writeBuffer.PushContext("S7ParameterUserData"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for S7ParameterUserData") } - - // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numItems := uint8(uint8(len(m.GetItems()))) - _numItemsErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("numItems", 8, uint8((numItems))) - if _numItemsErr != nil { - return errors.Wrap(_numItemsErr, "Error serializing 'numItems' field") + if err := WriteImplicitField(ctx, "numItems", numItems, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'numItems' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterUserDataItemCPUFunctions.go b/plc4go/protocols/s7/readwrite/model/S7ParameterUserDataItemCPUFunctions.go index 35fb1e1d2a..e1e0ea4bf1 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterUserDataItemCPUFunctions.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterUserDataItemCPUFunctions.go @@ -316,12 +316,9 @@ func (m *_S7ParameterUserDataItemCPUFunctions) SerializeWithWriteBuffer(ctx cont if pushErr := writeBuffer.PushContext("S7ParameterUserDataItemCPUFunctions"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for S7ParameterUserDataItemCPUFunctions") } - - // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) itemLength := uint8(uint8(uint8(m.GetLengthInBytes(ctx))) - uint8(uint8(2))) - _itemLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("itemLength", 8, uint8((itemLength))) - if _itemLengthErr != nil { - return errors.Wrap(_itemLengthErr, "Error serializing 'itemLength' field") + if err := WriteImplicitField(ctx, "itemLength", itemLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'itemLength' field") } // Simple Field (method) diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go b/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go index 346b7d86bf..9096aa091a 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go @@ -202,12 +202,9 @@ func (m *_S7ParameterWriteVarRequest) SerializeWithWriteBuffer(ctx context.Conte if pushErr := writeBuffer.PushContext("S7ParameterWriteVarRequest"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for S7ParameterWriteVarRequest") } - - // Implicit Field (numItems) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numItems := uint8(uint8(len(m.GetItems()))) - _numItemsErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("numItems", 8, uint8((numItems))) - if _numItemsErr != nil { - return errors.Wrap(_numItemsErr, "Error serializing 'numItems' field") + if err := WriteImplicitField(ctx, "numItems", numItems, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'numItems' field") } if err := WriteComplexTypeArrayField(ctx, "items", m.GetItems(), writeBuffer); err != nil { diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go index bf8cd2b903..d426e938eb 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go @@ -239,12 +239,9 @@ func (m *_S7PayloadUserDataItemCpuFunctionAlarmAckRequest) SerializeWithWriteBuf if err := WriteConstField(ctx, "functionId", S7PayloadUserDataItemCpuFunctionAlarmAckRequest_FUNCTIONID, WriteUnsignedByte(writeBuffer, 8)); err != nil { return errors.Wrap(err, "Error serializing 'functionId' field") } - - // Implicit Field (numberOfObjects) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numberOfObjects := uint8(uint8(len(m.GetMessageObjects()))) - _numberOfObjectsErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("numberOfObjects", 8, uint8((numberOfObjects))) - if _numberOfObjectsErr != nil { - return errors.Wrap(_numberOfObjectsErr, "Error serializing 'numberOfObjects' field") + if err := WriteImplicitField(ctx, "numberOfObjects", numberOfObjects, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'numberOfObjects' field") } if err := WriteComplexTypeArrayField(ctx, "messageObjects", m.GetMessageObjects(), writeBuffer); err != nil { diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go index fc22bb70d4..bf1e1c4db4 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go @@ -229,12 +229,9 @@ func (m *_S7PayloadUserDataItemCpuFunctionAlarmAckResponse) SerializeWithWriteBu if _functionIdErr != nil { return errors.Wrap(_functionIdErr, "Error serializing 'functionId' field") } - - // Implicit Field (numberOfObjects) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) numberOfObjects := uint8(uint8(len(m.GetMessageObjects()))) - _numberOfObjectsErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("numberOfObjects", 8, uint8((numberOfObjects))) - if _numberOfObjectsErr != nil { - return errors.Wrap(_numberOfObjectsErr, "Error serializing 'numberOfObjects' field") + if err := WriteImplicitField(ctx, "numberOfObjects", numberOfObjects, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'numberOfObjects' field") } if err := WriteSimpleTypeArrayField(ctx, "messageObjects", m.GetMessageObjects(), WriteUnsignedByte(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/s7/readwrite/model/S7VarPayloadDataItem.go b/plc4go/protocols/s7/readwrite/model/S7VarPayloadDataItem.go index 667248a180..ec2ae350eb 100644 --- a/plc4go/protocols/s7/readwrite/model/S7VarPayloadDataItem.go +++ b/plc4go/protocols/s7/readwrite/model/S7VarPayloadDataItem.go @@ -229,14 +229,11 @@ func (m *_S7VarPayloadDataItem) SerializeWithWriteBuffer(ctx context.Context, wr if _transportSizeErr != nil { return errors.Wrap(_transportSizeErr, "Error serializing 'transportSize' field") } - - // Implicit Field (dataLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) dataLength := uint16(uint16(uint16(len(m.GetData()))) * uint16((utils.InlineIf((bool((m.GetTransportSize()) == (DataTransportSize_BIT))), func() any { return uint16(uint16(1)) }, func() any { return uint16((utils.InlineIf(m.GetTransportSize().SizeInBits(), func() any { return uint16(uint16(8)) }, func() any { return uint16(uint16(1)) }).(uint16))) }).(uint16)))) - _dataLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("dataLength", 16, uint16((dataLength))) - if _dataLengthErr != nil { - return errors.Wrap(_dataLengthErr, "Error serializing 'dataLength' field") + if err := WriteImplicitField(ctx, "dataLength", dataLength, WriteUnsignedShort(writeBuffer, 16)); err != nil { + return errors.Wrap(err, "Error serializing 'dataLength' field") } if err := WriteByteArrayField(ctx, "data", m.GetData(), WriteByteArray(writeBuffer, 8)); err != nil { diff --git a/plc4go/protocols/s7/readwrite/model/S7VarRequestParameterItemAddress.go b/plc4go/protocols/s7/readwrite/model/S7VarRequestParameterItemAddress.go index 618c7b2433..b62fee9190 100644 --- a/plc4go/protocols/s7/readwrite/model/S7VarRequestParameterItemAddress.go +++ b/plc4go/protocols/s7/readwrite/model/S7VarRequestParameterItemAddress.go @@ -191,12 +191,9 @@ func (m *_S7VarRequestParameterItemAddress) SerializeWithWriteBuffer(ctx context if pushErr := writeBuffer.PushContext("S7VarRequestParameterItemAddress"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for S7VarRequestParameterItemAddress") } - - // Implicit Field (itemLength) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) itemLength := uint8(m.GetAddress().GetLengthInBytes(ctx)) - _itemLengthErr := /*TODO: migrate me*/ writeBuffer.WriteUint8("itemLength", 8, uint8((itemLength))) - if _itemLengthErr != nil { - return errors.Wrap(_itemLengthErr, "Error serializing 'itemLength' field") + if err := WriteImplicitField(ctx, "itemLength", itemLength, WriteUnsignedByte(writeBuffer, 8)); err != nil { + return errors.Wrap(err, "Error serializing 'itemLength' field") } // Simple Field (address) diff --git a/plc4go/protocols/s7/readwrite/model/TPKTPacket.go b/plc4go/protocols/s7/readwrite/model/TPKTPacket.go index 4d10438c24..183bf55e25 100644 --- a/plc4go/protocols/s7/readwrite/model/TPKTPacket.go +++ b/plc4go/protocols/s7/readwrite/model/TPKTPacket.go @@ -218,12 +218,9 @@ func (m *_TPKTPacket) SerializeWithWriteBuffer(ctx context.Context, writeBuffer return errors.Wrap(_err, "Error serializing 'reserved' field") } } - - // Implicit Field (len) (Used for parsing, but it's value is not stored as it's implicitly given by the objects content) len := uint16(uint16(m.GetPayload().GetLengthInBytes(ctx)) + uint16(uint16(4))) - _lenErr := /*TODO: migrate me*/ writeBuffer.WriteUint16("len", 16, uint16((len))) - if _lenErr != nil { - return errors.Wrap(_lenErr, "Error serializing 'len' field") + if err := WriteImplicitField(ctx, "len", len, WriteUnsignedShort(writeBuffer, 16), codegen.WithByteOrder(binary.BigEndian)); err != nil { + return errors.Wrap(err, "Error serializing 'len' field") } // Simple Field (payload)