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/21 16:48:37 UTC
[plc4x] 02/02: feat(bacnet): added support for BACnetConfirmedServiceRequestWritePropertyMultiple
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 af95da34b963f556f1f6a708465593338cfded24
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Apr 21 18:48:15 2022 +0200
feat(bacnet): added support for BACnetConfirmedServiceRequestWritePropertyMultiple
---
.../plc4go/bacnetip/readwrite/ParserHelper.go | 5 +
.../plc4go/bacnetip/readwrite/XmlParserHelper.go | 5 +
...ConfirmedServiceRequestWritePropertyMultiple.go | 66 ++++-
.../model/BACnetPropertyWriteDefinition.go | 307 +++++++++++++++++++++
.../model/BACnetWriteAccessSpecification.go | 276 ++++++++++++++++++
.../resources/protocols/bacnetip/bacnetip.mspec | 29 ++
6 files changed, 687 insertions(+), 1 deletion(-)
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/ParserHelper.go b/plc4go/internal/plc4go/bacnetip/readwrite/ParserHelper.go
index 260299f197..13c0b36619 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/ParserHelper.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/ParserHelper.go
@@ -131,6 +131,9 @@ func (m BacnetipParserHelper) Parse(typeName string, arguments []string, io util
return model.BVLCParse(io)
case "BACnetTagPayloadObjectIdentifier":
return model.BACnetTagPayloadObjectIdentifierParse(io)
+ case "BACnetPropertyWriteDefinition":
+ objectType := model.BACnetObjectTypeByName(arguments[0])
+ return model.BACnetPropertyWriteDefinitionParse(io, objectType)
case "BACnetDateTime":
tagNumber, err := utils.StrToUint8(arguments[0])
if err != nil {
@@ -218,6 +221,8 @@ func (m BacnetipParserHelper) Parse(typeName string, arguments []string, io util
return model.BACnetPropertyValueParse(io, objectType)
case "NLMInitalizeRoutingTablePortMapping":
return model.NLMInitalizeRoutingTablePortMappingParse(io)
+ case "BACnetWriteAccessSpecification":
+ return model.BACnetWriteAccessSpecificationParse(io)
case "BACnetServiceAck":
return model.BACnetServiceAckParse(io)
case "BACnetBinaryPV":
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/XmlParserHelper.go b/plc4go/internal/plc4go/bacnetip/readwrite/XmlParserHelper.go
index 3f79cb4b87..2b8c0f2ca8 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/XmlParserHelper.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/XmlParserHelper.go
@@ -154,6 +154,9 @@ func (m BacnetipXmlParserHelper) Parse(typeName string, xmlString string, parser
return model.BVLCParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)))
case "BACnetTagPayloadObjectIdentifier":
return model.BACnetTagPayloadObjectIdentifierParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)))
+ case "BACnetPropertyWriteDefinition":
+ objectType := model.BACnetObjectTypeByName(parserArguments[0])
+ return model.BACnetPropertyWriteDefinitionParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), objectType)
case "BACnetDateTime":
parsedUint0, err := strconv.ParseUint(parserArguments[0], 10, 8)
if err != nil {
@@ -253,6 +256,8 @@ func (m BacnetipXmlParserHelper) Parse(typeName string, xmlString string, parser
return model.BACnetPropertyValueParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), objectType)
case "NLMInitalizeRoutingTablePortMapping":
return model.NLMInitalizeRoutingTablePortMappingParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)))
+ case "BACnetWriteAccessSpecification":
+ return model.BACnetWriteAccessSpecificationParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)))
case "BACnetServiceAck":
return model.BACnetServiceAckParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)))
case "BACnetBinaryPV":
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetConfirmedServiceRequestWritePropertyMultiple.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetConfirmedServiceRequestWritePropertyMultiple.go
index 4bcb9035d0..97e2ceec19 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetConfirmedServiceRequestWritePropertyMultiple.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetConfirmedServiceRequestWritePropertyMultiple.go
@@ -21,6 +21,7 @@ package model
import (
"github.com/apache/plc4x/plc4go/internal/plc4go/spi/utils"
+ "github.com/pkg/errors"
)
// Code generated by code-generation. DO NOT EDIT.
@@ -28,6 +29,7 @@ import (
// BACnetConfirmedServiceRequestWritePropertyMultiple is the data-structure of this message
type BACnetConfirmedServiceRequestWritePropertyMultiple struct {
*BACnetConfirmedServiceRequest
+ Data []*BACnetWriteAccessSpecification
// Arguments.
Len uint16
@@ -36,6 +38,8 @@ type BACnetConfirmedServiceRequestWritePropertyMultiple struct {
// IBACnetConfirmedServiceRequestWritePropertyMultiple is the corresponding interface of BACnetConfirmedServiceRequestWritePropertyMultiple
type IBACnetConfirmedServiceRequestWritePropertyMultiple interface {
IBACnetConfirmedServiceRequest
+ // GetData returns Data (property field)
+ GetData() []*BACnetWriteAccessSpecification
// GetLengthInBytes returns the length in bytes
GetLengthInBytes() uint16
// GetLengthInBits returns the length in bits
@@ -65,9 +69,24 @@ func (m *BACnetConfirmedServiceRequestWritePropertyMultiple) GetParent() *BACnet
return m.BACnetConfirmedServiceRequest
}
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+/////////////////////// Accessors for property fields.
+///////////////////////
+
+func (m *BACnetConfirmedServiceRequestWritePropertyMultiple) GetData() []*BACnetWriteAccessSpecification {
+ return m.Data
+}
+
+///////////////////////
+///////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+
// NewBACnetConfirmedServiceRequestWritePropertyMultiple factory function for BACnetConfirmedServiceRequestWritePropertyMultiple
-func NewBACnetConfirmedServiceRequestWritePropertyMultiple(len uint16) *BACnetConfirmedServiceRequestWritePropertyMultiple {
+func NewBACnetConfirmedServiceRequestWritePropertyMultiple(data []*BACnetWriteAccessSpecification, len uint16) *BACnetConfirmedServiceRequestWritePropertyMultiple {
_result := &BACnetConfirmedServiceRequestWritePropertyMultiple{
+ Data: data,
BACnetConfirmedServiceRequest: NewBACnetConfirmedServiceRequest(len),
}
_result.Child = _result
@@ -101,6 +120,13 @@ func (m *BACnetConfirmedServiceRequestWritePropertyMultiple) GetLengthInBits() u
func (m *BACnetConfirmedServiceRequestWritePropertyMultiple) GetLengthInBitsConditional(lastItem bool) uint16 {
lengthInBits := uint16(m.GetParentLengthInBits())
+ // Array field
+ if len(m.Data) > 0 {
+ for _, element := range m.Data {
+ lengthInBits += element.GetLengthInBits()
+ }
+ }
+
return lengthInBits
}
@@ -115,12 +141,34 @@ func BACnetConfirmedServiceRequestWritePropertyMultipleParse(readBuffer utils.Re
currentPos := readBuffer.GetPos()
_ = currentPos
+ // Array field (data)
+ if pullErr := readBuffer.PullContext("data", utils.WithRenderAsList(true)); pullErr != nil {
+ return nil, pullErr
+ }
+ // Length array
+ data := make([]*BACnetWriteAccessSpecification, 0)
+ {
+ _dataLength := len
+ _dataEndPos := readBuffer.GetPos() + uint16(_dataLength)
+ for readBuffer.GetPos() < _dataEndPos {
+ _item, _err := BACnetWriteAccessSpecificationParse(readBuffer)
+ if _err != nil {
+ return nil, errors.Wrap(_err, "Error parsing 'data' field")
+ }
+ data = append(data, _item)
+ }
+ }
+ if closeErr := readBuffer.CloseContext("data", utils.WithRenderAsList(true)); closeErr != nil {
+ return nil, closeErr
+ }
+
if closeErr := readBuffer.CloseContext("BACnetConfirmedServiceRequestWritePropertyMultiple"); closeErr != nil {
return nil, closeErr
}
// Create a partially initialized instance
_child := &BACnetConfirmedServiceRequestWritePropertyMultiple{
+ Data: data,
BACnetConfirmedServiceRequest: &BACnetConfirmedServiceRequest{},
}
_child.BACnetConfirmedServiceRequest.Child = _child
@@ -133,6 +181,22 @@ func (m *BACnetConfirmedServiceRequestWritePropertyMultiple) Serialize(writeBuff
return pushErr
}
+ // Array Field (data)
+ if m.Data != nil {
+ if pushErr := writeBuffer.PushContext("data", utils.WithRenderAsList(true)); pushErr != nil {
+ return pushErr
+ }
+ for _, _element := range m.Data {
+ _elementErr := _element.Serialize(writeBuffer)
+ if _elementErr != nil {
+ return errors.Wrap(_elementErr, "Error serializing 'data' field")
+ }
+ }
+ if popErr := writeBuffer.PopContext("data", utils.WithRenderAsList(true)); popErr != nil {
+ return popErr
+ }
+ }
+
if popErr := writeBuffer.PopContext("BACnetConfirmedServiceRequestWritePropertyMultiple"); popErr != nil {
return popErr
}
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetPropertyWriteDefinition.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetPropertyWriteDefinition.go
new file mode 100644
index 0000000000..8bb971bae2
--- /dev/null
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetPropertyWriteDefinition.go
@@ -0,0 +1,307 @@
+/*
+ * 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"
+ "github.com/pkg/errors"
+ "io"
+)
+
+// Code generated by code-generation. DO NOT EDIT.
+
+// BACnetPropertyWriteDefinition is the data-structure of this message
+type BACnetPropertyWriteDefinition struct {
+ PropertyIdentifier *BACnetContextTagPropertyIdentifier
+ ArrayIndex *BACnetContextTagUnsignedInteger
+ PropertyValue *BACnetConstructedData
+ Priority *BACnetContextTagUnsignedInteger
+
+ // Arguments.
+ ObjectType BACnetObjectType
+}
+
+// IBACnetPropertyWriteDefinition is the corresponding interface of BACnetPropertyWriteDefinition
+type IBACnetPropertyWriteDefinition interface {
+ // GetPropertyIdentifier returns PropertyIdentifier (property field)
+ GetPropertyIdentifier() *BACnetContextTagPropertyIdentifier
+ // GetArrayIndex returns ArrayIndex (property field)
+ GetArrayIndex() *BACnetContextTagUnsignedInteger
+ // GetPropertyValue returns PropertyValue (property field)
+ GetPropertyValue() *BACnetConstructedData
+ // GetPriority returns Priority (property field)
+ GetPriority() *BACnetContextTagUnsignedInteger
+ // 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 property fields.
+///////////////////////
+
+func (m *BACnetPropertyWriteDefinition) GetPropertyIdentifier() *BACnetContextTagPropertyIdentifier {
+ return m.PropertyIdentifier
+}
+
+func (m *BACnetPropertyWriteDefinition) GetArrayIndex() *BACnetContextTagUnsignedInteger {
+ return m.ArrayIndex
+}
+
+func (m *BACnetPropertyWriteDefinition) GetPropertyValue() *BACnetConstructedData {
+ return m.PropertyValue
+}
+
+func (m *BACnetPropertyWriteDefinition) GetPriority() *BACnetContextTagUnsignedInteger {
+ return m.Priority
+}
+
+///////////////////////
+///////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+
+// NewBACnetPropertyWriteDefinition factory function for BACnetPropertyWriteDefinition
+func NewBACnetPropertyWriteDefinition(propertyIdentifier *BACnetContextTagPropertyIdentifier, arrayIndex *BACnetContextTagUnsignedInteger, propertyValue *BACnetConstructedData, priority *BACnetContextTagUnsignedInteger, objectType BACnetObjectType) *BACnetPropertyWriteDefinition {
+ return &BACnetPropertyWriteDefinition{PropertyIdentifier: propertyIdentifier, ArrayIndex: arrayIndex, PropertyValue: propertyValue, Priority: priority, ObjectType: objectType}
+}
+
+func CastBACnetPropertyWriteDefinition(structType interface{}) *BACnetPropertyWriteDefinition {
+ if casted, ok := structType.(BACnetPropertyWriteDefinition); ok {
+ return &casted
+ }
+ if casted, ok := structType.(*BACnetPropertyWriteDefinition); ok {
+ return casted
+ }
+ return nil
+}
+
+func (m *BACnetPropertyWriteDefinition) GetTypeName() string {
+ return "BACnetPropertyWriteDefinition"
+}
+
+func (m *BACnetPropertyWriteDefinition) GetLengthInBits() uint16 {
+ return m.GetLengthInBitsConditional(false)
+}
+
+func (m *BACnetPropertyWriteDefinition) GetLengthInBitsConditional(lastItem bool) uint16 {
+ lengthInBits := uint16(0)
+
+ // Simple field (propertyIdentifier)
+ lengthInBits += m.PropertyIdentifier.GetLengthInBits()
+
+ // Optional Field (arrayIndex)
+ if m.ArrayIndex != nil {
+ lengthInBits += (*m.ArrayIndex).GetLengthInBits()
+ }
+
+ // Optional Field (propertyValue)
+ if m.PropertyValue != nil {
+ lengthInBits += (*m.PropertyValue).GetLengthInBits()
+ }
+
+ // Optional Field (priority)
+ if m.Priority != nil {
+ lengthInBits += (*m.Priority).GetLengthInBits()
+ }
+
+ return lengthInBits
+}
+
+func (m *BACnetPropertyWriteDefinition) GetLengthInBytes() uint16 {
+ return m.GetLengthInBits() / 8
+}
+
+func BACnetPropertyWriteDefinitionParse(readBuffer utils.ReadBuffer, objectType BACnetObjectType) (*BACnetPropertyWriteDefinition, error) {
+ if pullErr := readBuffer.PullContext("BACnetPropertyWriteDefinition"); pullErr != nil {
+ return nil, pullErr
+ }
+ currentPos := readBuffer.GetPos()
+ _ = currentPos
+
+ // Simple Field (propertyIdentifier)
+ if pullErr := readBuffer.PullContext("propertyIdentifier"); pullErr != nil {
+ return nil, pullErr
+ }
+ _propertyIdentifier, _propertyIdentifierErr := BACnetContextTagParse(readBuffer, uint8(uint8(0)), BACnetDataType(BACnetDataType_BACNET_PROPERTY_IDENTIFIER))
+ if _propertyIdentifierErr != nil {
+ return nil, errors.Wrap(_propertyIdentifierErr, "Error parsing 'propertyIdentifier' field")
+ }
+ propertyIdentifier := CastBACnetContextTagPropertyIdentifier(_propertyIdentifier)
+ if closeErr := readBuffer.CloseContext("propertyIdentifier"); closeErr != nil {
+ return nil, closeErr
+ }
+
+ // Optional Field (arrayIndex) (Can be skipped, if a given expression evaluates to false)
+ var arrayIndex *BACnetContextTagUnsignedInteger = nil
+ {
+ currentPos = readBuffer.GetPos()
+ if pullErr := readBuffer.PullContext("arrayIndex"); pullErr != nil {
+ return nil, pullErr
+ }
+ _val, _err := BACnetContextTagParse(readBuffer, uint8(1), BACnetDataType_UNSIGNED_INTEGER)
+ switch {
+ case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
+ readBuffer.Reset(currentPos)
+ case _err != nil:
+ return nil, errors.Wrap(_err, "Error parsing 'arrayIndex' field")
+ default:
+ arrayIndex = CastBACnetContextTagUnsignedInteger(_val)
+ if closeErr := readBuffer.CloseContext("arrayIndex"); closeErr != nil {
+ return nil, closeErr
+ }
+ }
+ }
+
+ // Optional Field (propertyValue) (Can be skipped, if a given expression evaluates to false)
+ var propertyValue *BACnetConstructedData = nil
+ {
+ currentPos = readBuffer.GetPos()
+ if pullErr := readBuffer.PullContext("propertyValue"); pullErr != nil {
+ return nil, pullErr
+ }
+ _val, _err := BACnetConstructedDataParse(readBuffer, uint8(2), objectType, propertyIdentifier)
+ switch {
+ case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
+ readBuffer.Reset(currentPos)
+ case _err != nil:
+ return nil, errors.Wrap(_err, "Error parsing 'propertyValue' field")
+ default:
+ propertyValue = CastBACnetConstructedData(_val)
+ if closeErr := readBuffer.CloseContext("propertyValue"); closeErr != nil {
+ return nil, closeErr
+ }
+ }
+ }
+
+ // Optional Field (priority) (Can be skipped, if a given expression evaluates to false)
+ var priority *BACnetContextTagUnsignedInteger = nil
+ {
+ currentPos = readBuffer.GetPos()
+ if pullErr := readBuffer.PullContext("priority"); pullErr != nil {
+ return nil, pullErr
+ }
+ _val, _err := BACnetContextTagParse(readBuffer, uint8(3), BACnetDataType_UNSIGNED_INTEGER)
+ switch {
+ case errors.Is(_err, utils.ParseAssertError{}) || errors.Is(_err, io.EOF):
+ readBuffer.Reset(currentPos)
+ case _err != nil:
+ return nil, errors.Wrap(_err, "Error parsing 'priority' field")
+ default:
+ priority = CastBACnetContextTagUnsignedInteger(_val)
+ if closeErr := readBuffer.CloseContext("priority"); closeErr != nil {
+ return nil, closeErr
+ }
+ }
+ }
+
+ if closeErr := readBuffer.CloseContext("BACnetPropertyWriteDefinition"); closeErr != nil {
+ return nil, closeErr
+ }
+
+ // Create the instance
+ return NewBACnetPropertyWriteDefinition(propertyIdentifier, arrayIndex, propertyValue, priority, objectType), nil
+}
+
+func (m *BACnetPropertyWriteDefinition) Serialize(writeBuffer utils.WriteBuffer) error {
+ if pushErr := writeBuffer.PushContext("BACnetPropertyWriteDefinition"); pushErr != nil {
+ return pushErr
+ }
+
+ // Simple Field (propertyIdentifier)
+ if pushErr := writeBuffer.PushContext("propertyIdentifier"); pushErr != nil {
+ return pushErr
+ }
+ _propertyIdentifierErr := m.PropertyIdentifier.Serialize(writeBuffer)
+ if popErr := writeBuffer.PopContext("propertyIdentifier"); popErr != nil {
+ return popErr
+ }
+ if _propertyIdentifierErr != nil {
+ return errors.Wrap(_propertyIdentifierErr, "Error serializing 'propertyIdentifier' field")
+ }
+
+ // Optional Field (arrayIndex) (Can be skipped, if the value is null)
+ var arrayIndex *BACnetContextTagUnsignedInteger = nil
+ if m.ArrayIndex != nil {
+ if pushErr := writeBuffer.PushContext("arrayIndex"); pushErr != nil {
+ return pushErr
+ }
+ arrayIndex = m.ArrayIndex
+ _arrayIndexErr := arrayIndex.Serialize(writeBuffer)
+ if popErr := writeBuffer.PopContext("arrayIndex"); popErr != nil {
+ return popErr
+ }
+ if _arrayIndexErr != nil {
+ return errors.Wrap(_arrayIndexErr, "Error serializing 'arrayIndex' field")
+ }
+ }
+
+ // Optional Field (propertyValue) (Can be skipped, if the value is null)
+ var propertyValue *BACnetConstructedData = nil
+ if m.PropertyValue != nil {
+ if pushErr := writeBuffer.PushContext("propertyValue"); pushErr != nil {
+ return pushErr
+ }
+ propertyValue = m.PropertyValue
+ _propertyValueErr := propertyValue.Serialize(writeBuffer)
+ if popErr := writeBuffer.PopContext("propertyValue"); popErr != nil {
+ return popErr
+ }
+ if _propertyValueErr != nil {
+ return errors.Wrap(_propertyValueErr, "Error serializing 'propertyValue' field")
+ }
+ }
+
+ // Optional Field (priority) (Can be skipped, if the value is null)
+ var priority *BACnetContextTagUnsignedInteger = nil
+ if m.Priority != nil {
+ if pushErr := writeBuffer.PushContext("priority"); pushErr != nil {
+ return pushErr
+ }
+ priority = m.Priority
+ _priorityErr := priority.Serialize(writeBuffer)
+ if popErr := writeBuffer.PopContext("priority"); popErr != nil {
+ return popErr
+ }
+ if _priorityErr != nil {
+ return errors.Wrap(_priorityErr, "Error serializing 'priority' field")
+ }
+ }
+
+ if popErr := writeBuffer.PopContext("BACnetPropertyWriteDefinition"); popErr != nil {
+ return popErr
+ }
+ return nil
+}
+
+func (m *BACnetPropertyWriteDefinition) 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/BACnetWriteAccessSpecification.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetWriteAccessSpecification.go
new file mode 100644
index 0000000000..0d93679a74
--- /dev/null
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/BACnetWriteAccessSpecification.go
@@ -0,0 +1,276 @@
+/*
+ * 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"
+ "github.com/pkg/errors"
+)
+
+// Code generated by code-generation. DO NOT EDIT.
+
+// BACnetWriteAccessSpecification is the data-structure of this message
+type BACnetWriteAccessSpecification struct {
+ ObjectIdentifier *BACnetContextTagObjectIdentifier
+ OpeningTag *BACnetOpeningTag
+ ListOfPropertyWriteDefinition []*BACnetPropertyWriteDefinition
+ ClosingTag *BACnetClosingTag
+}
+
+// IBACnetWriteAccessSpecification is the corresponding interface of BACnetWriteAccessSpecification
+type IBACnetWriteAccessSpecification interface {
+ // GetObjectIdentifier returns ObjectIdentifier (property field)
+ GetObjectIdentifier() *BACnetContextTagObjectIdentifier
+ // GetOpeningTag returns OpeningTag (property field)
+ GetOpeningTag() *BACnetOpeningTag
+ // GetListOfPropertyWriteDefinition returns ListOfPropertyWriteDefinition (property field)
+ GetListOfPropertyWriteDefinition() []*BACnetPropertyWriteDefinition
+ // GetClosingTag returns ClosingTag (property field)
+ GetClosingTag() *BACnetClosingTag
+ // 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 property fields.
+///////////////////////
+
+func (m *BACnetWriteAccessSpecification) GetObjectIdentifier() *BACnetContextTagObjectIdentifier {
+ return m.ObjectIdentifier
+}
+
+func (m *BACnetWriteAccessSpecification) GetOpeningTag() *BACnetOpeningTag {
+ return m.OpeningTag
+}
+
+func (m *BACnetWriteAccessSpecification) GetListOfPropertyWriteDefinition() []*BACnetPropertyWriteDefinition {
+ return m.ListOfPropertyWriteDefinition
+}
+
+func (m *BACnetWriteAccessSpecification) GetClosingTag() *BACnetClosingTag {
+ return m.ClosingTag
+}
+
+///////////////////////
+///////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+
+// NewBACnetWriteAccessSpecification factory function for BACnetWriteAccessSpecification
+func NewBACnetWriteAccessSpecification(objectIdentifier *BACnetContextTagObjectIdentifier, openingTag *BACnetOpeningTag, listOfPropertyWriteDefinition []*BACnetPropertyWriteDefinition, closingTag *BACnetClosingTag) *BACnetWriteAccessSpecification {
+ return &BACnetWriteAccessSpecification{ObjectIdentifier: objectIdentifier, OpeningTag: openingTag, ListOfPropertyWriteDefinition: listOfPropertyWriteDefinition, ClosingTag: closingTag}
+}
+
+func CastBACnetWriteAccessSpecification(structType interface{}) *BACnetWriteAccessSpecification {
+ if casted, ok := structType.(BACnetWriteAccessSpecification); ok {
+ return &casted
+ }
+ if casted, ok := structType.(*BACnetWriteAccessSpecification); ok {
+ return casted
+ }
+ return nil
+}
+
+func (m *BACnetWriteAccessSpecification) GetTypeName() string {
+ return "BACnetWriteAccessSpecification"
+}
+
+func (m *BACnetWriteAccessSpecification) GetLengthInBits() uint16 {
+ return m.GetLengthInBitsConditional(false)
+}
+
+func (m *BACnetWriteAccessSpecification) GetLengthInBitsConditional(lastItem bool) uint16 {
+ lengthInBits := uint16(0)
+
+ // Simple field (objectIdentifier)
+ lengthInBits += m.ObjectIdentifier.GetLengthInBits()
+
+ // Simple field (openingTag)
+ lengthInBits += m.OpeningTag.GetLengthInBits()
+
+ // Array field
+ if len(m.ListOfPropertyWriteDefinition) > 0 {
+ for _, element := range m.ListOfPropertyWriteDefinition {
+ lengthInBits += element.GetLengthInBits()
+ }
+ }
+
+ // Simple field (closingTag)
+ lengthInBits += m.ClosingTag.GetLengthInBits()
+
+ return lengthInBits
+}
+
+func (m *BACnetWriteAccessSpecification) GetLengthInBytes() uint16 {
+ return m.GetLengthInBits() / 8
+}
+
+func BACnetWriteAccessSpecificationParse(readBuffer utils.ReadBuffer) (*BACnetWriteAccessSpecification, error) {
+ if pullErr := readBuffer.PullContext("BACnetWriteAccessSpecification"); pullErr != nil {
+ return nil, pullErr
+ }
+ currentPos := readBuffer.GetPos()
+ _ = currentPos
+
+ // Simple Field (objectIdentifier)
+ if pullErr := readBuffer.PullContext("objectIdentifier"); pullErr != nil {
+ return nil, pullErr
+ }
+ _objectIdentifier, _objectIdentifierErr := BACnetContextTagParse(readBuffer, uint8(uint8(0)), BACnetDataType(BACnetDataType_BACNET_OBJECT_IDENTIFIER))
+ if _objectIdentifierErr != nil {
+ return nil, errors.Wrap(_objectIdentifierErr, "Error parsing 'objectIdentifier' field")
+ }
+ objectIdentifier := CastBACnetContextTagObjectIdentifier(_objectIdentifier)
+ if closeErr := readBuffer.CloseContext("objectIdentifier"); closeErr != nil {
+ return nil, closeErr
+ }
+
+ // Simple Field (openingTag)
+ if pullErr := readBuffer.PullContext("openingTag"); pullErr != nil {
+ return nil, pullErr
+ }
+ _openingTag, _openingTagErr := BACnetContextTagParse(readBuffer, uint8(uint8(1)), BACnetDataType(BACnetDataType_OPENING_TAG))
+ if _openingTagErr != nil {
+ return nil, errors.Wrap(_openingTagErr, "Error parsing 'openingTag' field")
+ }
+ openingTag := CastBACnetOpeningTag(_openingTag)
+ if closeErr := readBuffer.CloseContext("openingTag"); closeErr != nil {
+ return nil, closeErr
+ }
+
+ // Array field (listOfPropertyWriteDefinition)
+ if pullErr := readBuffer.PullContext("listOfPropertyWriteDefinition", utils.WithRenderAsList(true)); pullErr != nil {
+ return nil, pullErr
+ }
+ // Terminated array
+ listOfPropertyWriteDefinition := make([]*BACnetPropertyWriteDefinition, 0)
+ {
+ for !bool(IsBACnetConstructedDataClosingTag(readBuffer, false, 1)) {
+ _item, _err := BACnetPropertyWriteDefinitionParse(readBuffer, objectIdentifier.GetObjectType())
+ if _err != nil {
+ return nil, errors.Wrap(_err, "Error parsing 'listOfPropertyWriteDefinition' field")
+ }
+ listOfPropertyWriteDefinition = append(listOfPropertyWriteDefinition, CastBACnetPropertyWriteDefinition(_item))
+
+ }
+ }
+ if closeErr := readBuffer.CloseContext("listOfPropertyWriteDefinition", utils.WithRenderAsList(true)); closeErr != nil {
+ return nil, closeErr
+ }
+
+ // Simple Field (closingTag)
+ if pullErr := readBuffer.PullContext("closingTag"); pullErr != nil {
+ return nil, pullErr
+ }
+ _closingTag, _closingTagErr := BACnetContextTagParse(readBuffer, uint8(uint8(1)), BACnetDataType(BACnetDataType_CLOSING_TAG))
+ if _closingTagErr != nil {
+ return nil, errors.Wrap(_closingTagErr, "Error parsing 'closingTag' field")
+ }
+ closingTag := CastBACnetClosingTag(_closingTag)
+ if closeErr := readBuffer.CloseContext("closingTag"); closeErr != nil {
+ return nil, closeErr
+ }
+
+ if closeErr := readBuffer.CloseContext("BACnetWriteAccessSpecification"); closeErr != nil {
+ return nil, closeErr
+ }
+
+ // Create the instance
+ return NewBACnetWriteAccessSpecification(objectIdentifier, openingTag, listOfPropertyWriteDefinition, closingTag), nil
+}
+
+func (m *BACnetWriteAccessSpecification) Serialize(writeBuffer utils.WriteBuffer) error {
+ if pushErr := writeBuffer.PushContext("BACnetWriteAccessSpecification"); pushErr != nil {
+ return pushErr
+ }
+
+ // Simple Field (objectIdentifier)
+ if pushErr := writeBuffer.PushContext("objectIdentifier"); pushErr != nil {
+ return pushErr
+ }
+ _objectIdentifierErr := m.ObjectIdentifier.Serialize(writeBuffer)
+ if popErr := writeBuffer.PopContext("objectIdentifier"); popErr != nil {
+ return popErr
+ }
+ if _objectIdentifierErr != nil {
+ return errors.Wrap(_objectIdentifierErr, "Error serializing 'objectIdentifier' field")
+ }
+
+ // Simple Field (openingTag)
+ if pushErr := writeBuffer.PushContext("openingTag"); pushErr != nil {
+ return pushErr
+ }
+ _openingTagErr := m.OpeningTag.Serialize(writeBuffer)
+ if popErr := writeBuffer.PopContext("openingTag"); popErr != nil {
+ return popErr
+ }
+ if _openingTagErr != nil {
+ return errors.Wrap(_openingTagErr, "Error serializing 'openingTag' field")
+ }
+
+ // Array Field (listOfPropertyWriteDefinition)
+ if m.ListOfPropertyWriteDefinition != nil {
+ if pushErr := writeBuffer.PushContext("listOfPropertyWriteDefinition", utils.WithRenderAsList(true)); pushErr != nil {
+ return pushErr
+ }
+ for _, _element := range m.ListOfPropertyWriteDefinition {
+ _elementErr := _element.Serialize(writeBuffer)
+ if _elementErr != nil {
+ return errors.Wrap(_elementErr, "Error serializing 'listOfPropertyWriteDefinition' field")
+ }
+ }
+ if popErr := writeBuffer.PopContext("listOfPropertyWriteDefinition", utils.WithRenderAsList(true)); popErr != nil {
+ return popErr
+ }
+ }
+
+ // Simple Field (closingTag)
+ if pushErr := writeBuffer.PushContext("closingTag"); pushErr != nil {
+ return pushErr
+ }
+ _closingTagErr := m.ClosingTag.Serialize(writeBuffer)
+ if popErr := writeBuffer.PopContext("closingTag"); popErr != nil {
+ return popErr
+ }
+ if _closingTagErr != nil {
+ return errors.Wrap(_closingTagErr, "Error serializing 'closingTag' field")
+ }
+
+ if popErr := writeBuffer.PopContext("BACnetWriteAccessSpecification"); popErr != nil {
+ return popErr
+ }
+ return nil
+}
+
+func (m *BACnetWriteAccessSpecification) 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/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
index 532da918df..6f459521bc 100644
--- a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
+++ b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
@@ -362,6 +362,10 @@
[optional BACnetContextTagUnsignedInteger('4', 'BACnetDataType.UNSIGNED_INTEGER') priority ]
]
['0x10' BACnetConfirmedServiceRequestWritePropertyMultiple
+ [array BACnetWriteAccessSpecification
+ data
+ length
+ 'len' ]
]
['0x11' BACnetConfirmedServiceRequestDeviceCommunicationControl
@@ -434,6 +438,31 @@
arrayIndex ]
]
+[type BACnetWriteAccessSpecification
+ [simple BACnetContextTagObjectIdentifier('0', 'BACnetDataType.BACNET_OBJECT_IDENTIFIER')
+ objectIdentifier ]
+ [simple BACnetOpeningTag('1', 'BACnetDataType.OPENING_TAG')
+ openingTag ]
+ [array BACnetPropertyWriteDefinition('objectIdentifier.objectType')
+ listOfPropertyWriteDefinition
+ terminated
+ 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, 1)'
+ ]
+ [simple BACnetClosingTag('1', 'BACnetDataType.CLOSING_TAG')
+ closingTag ]
+]
+
+[type BACnetPropertyWriteDefinition(BACnetObjectType objectType)
+ [simple BACnetContextTagPropertyIdentifier('0', 'BACnetDataType.BACNET_PROPERTY_IDENTIFIER')
+ propertyIdentifier ]
+ [optional BACnetContextTagUnsignedInteger('1', 'BACnetDataType.UNSIGNED_INTEGER')
+ arrayIndex ]
+ [optional BACnetConstructedData('2', 'objectType', 'propertyIdentifier')
+ propertyValue ]
+ [optional BACnetContextTagUnsignedInteger('3', 'BACnetDataType.UNSIGNED_INTEGER')
+ priority ]
+]
+
// TODO: this is a enum so we should build a static call which maps a enum (could be solved by using only the tag header with a length validation and the enum itself)
[type BACnetConfirmedServiceRequestReinitializeDeviceEnableDisable(uint 8 tagNumber)
[optional BACnetContextTagEnumerated('tagNumber', 'BACnetDataType.ENUMERATED')