You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/04/20 14:22:57 UTC
[plc4x] branch develop updated: feat(bacnet): added null context tag
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new 1e426c270a feat(bacnet): added null context tag
1e426c270a is described below
commit 1e426c270a8ab474dd749bb467f7a611ee67fbd7
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Wed Apr 20 16:22:49 2022 +0200
feat(bacnet): added null context tag
---
.../bacnetip/readwrite/model/BACnetContextTag.go | 2 +
.../readwrite/model/BACnetContextTagNull.go | 165 +++++++++++++++++++++
.../bacnetip/readwrite/model/StaticHelper.go | 10 ++
.../bacnetip/readwrite/utils/StaticHelper.java | 10 ++
.../resources/protocols/bacnetip/bacnetip.mspec | 4 +
5 files changed, 191 insertions(+)
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTag.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetContextTag.go
index a67f140a16..52ec5c3e2a 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 0000000000..84bed07d74
--- /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 "<nil>"
+ }
+ 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 9c941cb7f3..ed6bc93aa4 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 7d5f5a3c3c..b6869691ea 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 class StaticHelper {
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 db516a1d86..f7b9816099 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" ]