diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTag.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTag.go index a67f140a163..52ec5c3e2a4 100644 --- a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTag.go +++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTag.go @@ -206,6 +206,8 @@ func BACnetContextTagParse(readBuffer utils.ReadBuffer, tagNumberArgument uint8, var _child BACnetContextTagChild var typeSwitchError error switch { + case dataType == BACnetDataType_NULL: // BACnetContextTagNull + _child, typeSwitchError = BACnetContextTagNullParse(readBuffer, tagNumberArgument, dataType, isNotOpeningOrClosingTag, header) case dataType == BACnetDataType_BOOLEAN: // BACnetContextTagBoolean _child, typeSwitchError = BACnetContextTagBooleanParse(readBuffer, tagNumberArgument, dataType, isNotOpeningOrClosingTag, header) case dataType == BACnetDataType_UNSIGNED_INTEGER: // BACnetContextTagUnsignedInteger diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTagNull.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTagNull.go new file mode 100644 index 00000000000..84bed07d74a --- /dev/null +++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTagNull.go @@ -0,0 +1,165 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package model + +import ( + "github.com/apache/plc4x/plc4go/internal/plc4go/spi/utils" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetContextTagNull is the data-structure of this message +type BACnetContextTagNull struct { + *BACnetContextTag + + // Arguments. + TagNumberArgument uint8 + IsNotOpeningOrClosingTag bool +} + +// IBACnetContextTagNull is the corresponding interface of BACnetContextTagNull +type IBACnetContextTagNull interface { + IBACnetContextTag + // GetLengthInBytes returns the length in bytes + GetLengthInBytes() uint16 + // GetLengthInBits returns the length in bits + GetLengthInBits() uint16 + // Serialize serializes this type + Serialize(writeBuffer utils.WriteBuffer) error +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for discriminator values. +/////////////////////// + +func (m *BACnetContextTagNull) GetDataType() BACnetDataType { + return BACnetDataType_NULL +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *BACnetContextTagNull) InitializeParent(parent *BACnetContextTag, header *BACnetTagHeader) { + m.BACnetContextTag.Header = header +} + +func (m *BACnetContextTagNull) GetParent() *BACnetContextTag { + return m.BACnetContextTag +} + +// NewBACnetContextTagNull factory function for BACnetContextTagNull +func NewBACnetContextTagNull(header *BACnetTagHeader, tagNumberArgument uint8, isNotOpeningOrClosingTag bool) *BACnetContextTagNull { + _result := &BACnetContextTagNull{ + BACnetContextTag: NewBACnetContextTag(header, tagNumberArgument), + } + _result.Child = _result + return _result +} + +func CastBACnetContextTagNull(structType interface{}) *BACnetContextTagNull { + if casted, ok := structType.(BACnetContextTagNull); ok { + return &casted + } + if casted, ok := structType.(*BACnetContextTagNull); ok { + return casted + } + if casted, ok := structType.(BACnetContextTag); ok { + return CastBACnetContextTagNull(casted.Child) + } + if casted, ok := structType.(*BACnetContextTag); ok { + return CastBACnetContextTagNull(casted.Child) + } + return nil +} + +func (m *BACnetContextTagNull) GetTypeName() string { + return "BACnetContextTagNull" +} + +func (m *BACnetContextTagNull) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetContextTagNull) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + return lengthInBits +} + +func (m *BACnetContextTagNull) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetContextTagNullParse(readBuffer utils.ReadBuffer, tagNumberArgument uint8, dataType BACnetDataType, isNotOpeningOrClosingTag bool, header *BACnetTagHeader) (*BACnetContextTagNull, error) { + if pullErr := readBuffer.PullContext("BACnetContextTagNull"); pullErr != nil { + return nil, pullErr + } + currentPos := readBuffer.GetPos() + _ = currentPos + + // Validation + if !(isNotOpeningOrClosingTag) { + return nil, utils.ParseAssertError{"length 6 and 7 reserved for opening and closing tag"} + } + + // Validation + if !(bool((header.GetActualLength()) == (0))) { + return nil, utils.ParseAssertError{"length field should be 0"} + } + + if closeErr := readBuffer.CloseContext("BACnetContextTagNull"); closeErr != nil { + return nil, closeErr + } + + // Create a partially initialized instance + _child := &BACnetContextTagNull{ + BACnetContextTag: &BACnetContextTag{}, + } + _child.BACnetContextTag.Child = _child + return _child, nil +} + +func (m *BACnetContextTagNull) Serialize(writeBuffer utils.WriteBuffer) error { + ser := func() error { + if pushErr := writeBuffer.PushContext("BACnetContextTagNull"); pushErr != nil { + return pushErr + } + + if popErr := writeBuffer.PopContext("BACnetContextTagNull"); popErr != nil { + return popErr + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *BACnetContextTagNull) String() string { + if m == nil { + return "" + } + buffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := m.Serialize(buffer); err != nil { + return err.Error() + } + return buffer.GetBox().String() +} diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go index 9c941cb7f39..ed6bc93aa49 100644 --- a/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go +++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go @@ -348,6 +348,16 @@ func CreateBACnetTagHeaderBalanced(isContext bool, id uint8, value uint32) *BACn return NewBACnetTagHeader(tagNumber, tagClass, lengthValueType, extTagNumber, extLength, extExtLength, extExtExtLength) } +func CreateBACnetApplicationTagNull() *BACnetApplicationTagNull { + header := CreateBACnetTagHeaderBalanced(false, uint8(BACnetDataType_NULL), 0) + return NewBACnetApplicationTagNull(header) +} + +func CreateBACnetContextTagNull(tagNumber uint8) *BACnetContextTagNull { + header := CreateBACnetTagHeaderBalanced(true, tagNumber, 0) + return NewBACnetContextTagNull(header, tagNumber, true) +} + func CreateBACnetOpeningTag(tagNum uint8) *BACnetOpeningTag { var tagNumber uint8 var extTagNumber *uint8 diff --git a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java index 7d5f5a3c3c4..b6869691ea2 100644 --- a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java +++ b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java @@ -390,6 +390,16 @@ public static BACnetTagHeader createBACnetTagHeaderBalanced(boolean isContext, s return new BACnetTagHeader(tagNumber, tagClass, lengthValueType, extTagNumber, extLength, extExtLength, extExtExtLength); } + public static BACnetApplicationTagNull createBACnetApplicationTagNull() { + BACnetTagHeader header = createBACnetTagHeaderBalanced(false, BACnetDataType.NULL.getValue(), 0); + return new BACnetApplicationTagNull(header); + } + + public static BACnetContextTagNull createBACnetContextTagNull(byte tagNumber) { + BACnetTagHeader header = createBACnetTagHeaderBalanced(true, tagNumber, 0); + return new BACnetContextTagNull(header, (short) tagNumber, true); + } + public static BACnetOpeningTag createBACnetOpeningTag(short tagNum) { byte tagNumber; Short extTagNumber = null; diff --git a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec index db516a1d868..f7b98160990 100644 --- a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec +++ b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec @@ -1179,6 +1179,10 @@ [virtual uint 32 actualLength 'header.actualLength' ] [virtual bit isNotOpeningOrClosingTag 'header.lengthValueType != 6 && header.lengthValueType != 7' ] [typeSwitch dataType + ['NULL' BACnetContextTagNull(bit isNotOpeningOrClosingTag, BACnetTagHeader header) + [validation 'isNotOpeningOrClosingTag' "length 6 and 7 reserved for opening and closing tag" ] + [validation 'header.actualLength == 0' "length field should be 0" ] + ] ['BOOLEAN' BACnetContextTagBoolean(bit isNotOpeningOrClosingTag, BACnetTagHeader header) [validation 'isNotOpeningOrClosingTag' "length 6 and 7 reserved for opening and closing tag" ] [validation 'header.actualLength == 1' "length field should be 1" ]