diff --git a/plc4go/protocols/bacnetip/readwrite/ParserHelper.go b/plc4go/protocols/bacnetip/readwrite/ParserHelper.go index 067d1435d8c..0c289f937da 100644 --- a/plc4go/protocols/bacnetip/readwrite/ParserHelper.go +++ b/plc4go/protocols/bacnetip/readwrite/ParserHelper.go @@ -196,6 +196,8 @@ func (m BacnetipParserHelper) Parse(typeName string, arguments []string, io util return nil, errors.Wrap(err, "Error parsing") } return model.APDUParse(io, apduLength) + case "BACnetEventNotificationSubscription": + return model.BACnetEventNotificationSubscriptionParse(io) case "BACnetSegmentationTagged": tagNumber, err := utils.StrToUint8(arguments[0]) if err != nil { @@ -792,6 +794,8 @@ func (m BacnetipParserHelper) Parse(typeName string, arguments []string, io util case "ListOfCovNotificationsValue": objectTypeArgument := model.BACnetObjectTypeByName(arguments[0]) return model.ListOfCovNotificationsValueParse(io, objectTypeArgument) + case "BACnetPortPermission": + return model.BACnetPortPermissionParse(io) case "BACnetConfirmedServiceRequestReadRangeRange": return model.BACnetConfirmedServiceRequestReadRangeRangeParse(io) case "BACnetError": @@ -833,6 +837,8 @@ func (m BacnetipParserHelper) Parse(typeName string, arguments []string, io util } tagClass := model.TagClassByName(arguments[1]) return model.BACnetConfirmedServiceRequestDeviceCommunicationControlEnableDisableTaggedParse(io, tagNumber, tagClass) + case "BACnetProcessIdSelection": + return model.BACnetProcessIdSelectionParse(io) case "BACnetTagPayloadDouble": return model.BACnetTagPayloadDoubleParse(io) case "BACnetTimerStateChangeValue": diff --git a/plc4go/protocols/bacnetip/readwrite/XmlParserHelper.go b/plc4go/protocols/bacnetip/readwrite/XmlParserHelper.go index ecb5f5f828d..71be53f78de 100644 --- a/plc4go/protocols/bacnetip/readwrite/XmlParserHelper.go +++ b/plc4go/protocols/bacnetip/readwrite/XmlParserHelper.go @@ -229,6 +229,8 @@ func (m BacnetipXmlParserHelper) Parse(typeName string, xmlString string, parser } apduLength := uint16(parsedUint0) return model.APDUParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), apduLength) + case "BACnetEventNotificationSubscription": + return model.BACnetEventNotificationSubscriptionParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "BACnetSegmentationTagged": parsedUint0, err := strconv.ParseUint(parserArguments[0], 10, 8) if err != nil { @@ -903,6 +905,8 @@ func (m BacnetipXmlParserHelper) Parse(typeName string, xmlString string, parser case "ListOfCovNotificationsValue": objectTypeArgument := model.BACnetObjectTypeByName(parserArguments[0]) return model.ListOfCovNotificationsValueParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), objectTypeArgument) + case "BACnetPortPermission": + return model.BACnetPortPermissionParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "BACnetConfirmedServiceRequestReadRangeRange": return model.BACnetConfirmedServiceRequestReadRangeRangeParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "BACnetError": @@ -949,6 +953,8 @@ func (m BacnetipXmlParserHelper) Parse(typeName string, xmlString string, parser tagNumber := uint8(parsedUint0) tagClass := model.TagClassByName(parserArguments[1]) return model.BACnetConfirmedServiceRequestDeviceCommunicationControlEnableDisableTaggedParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), tagNumber, tagClass) + case "BACnetProcessIdSelection": + return model.BACnetProcessIdSelectionParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "BACnetTagPayloadDouble": return model.BACnetTagPayloadDoubleParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "BACnetTimerStateChangeValue": diff --git a/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedData.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedData.go index d98a7f5e415..162cc4a0f4b 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedData.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedData.go @@ -458,6 +458,8 @@ func BACnetConstructedDataParse(readBuffer utils.ReadBuffer, tagNumber uint8, ob _child, typeSwitchError = BACnetConstructedDataLimitEnableParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_LIST_OF_OBJECT_PROPERTY_REFERENCES: // BACnetConstructedDataListOfObjectPropertyReferences _child, typeSwitchError = BACnetConstructedDataListOfObjectPropertyReferencesParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) + case true && propertyIdentifierArgument == BACnetPropertyIdentifier_LOCAL_FORWARDING_ONLY: // BACnetConstructedDataLocalForwardingOnly + _child, typeSwitchError = BACnetConstructedDataLocalForwardingOnlyParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_LOCK_STATUS: // BACnetConstructedDataLockStatus _child, typeSwitchError = BACnetConstructedDataLockStatusParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_LOCKOUT: // BACnetConstructedDataLockout @@ -518,12 +520,16 @@ func BACnetConstructedDataParse(readBuffer utils.ReadBuffer, tagNumber uint8, ob _child, typeSwitchError = BACnetConstructedDataOutOfServiceParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_OUTPUT_UNITS: // BACnetConstructedDataOutputUnits _child, typeSwitchError = BACnetConstructedDataOutputUnitsParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) + case true && propertyIdentifierArgument == BACnetPropertyIdentifier_PORT_FILTER: // BACnetConstructedDataPortFilter + _child, typeSwitchError = BACnetConstructedDataPortFilterParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_POSITIVE_ACCESS_RULES: // BACnetConstructedDataPositiveAccessRules _child, typeSwitchError = BACnetConstructedDataPositiveAccessRulesParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case objectTypeArgument == BACnetObjectType_ANALOG_INPUT && propertyIdentifierArgument == BACnetPropertyIdentifier_PRESENT_VALUE: // BACnetConstructedDataAnalogInputPresentValue _child, typeSwitchError = BACnetConstructedDataAnalogInputPresentValueParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_PRIORITY_ARRAY: // BACnetConstructedDataPriorityArray _child, typeSwitchError = BACnetConstructedDataPriorityArrayParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) + case true && propertyIdentifierArgument == BACnetPropertyIdentifier_PROCESS_IDENTIFIER_FILTER: // BACnetConstructedDataProcessIdentifierFilter + _child, typeSwitchError = BACnetConstructedDataProcessIdentifierFilterParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_PROFILE_LOCATION: // BACnetConstructedDataProfileLocation _child, typeSwitchError = BACnetConstructedDataProfileLocationParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_PROFILE_NAME: // BACnetConstructedDataProfileName @@ -572,6 +578,8 @@ func BACnetConstructedDataParse(readBuffer utils.ReadBuffer, tagNumber uint8, ob _child, typeSwitchError = BACnetConstructedDataSubordinateRelationshipsParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_SUBORDINATE_TAGS: // BACnetConstructedDataSubordinateTags _child, typeSwitchError = BACnetConstructedDataSubordinateTagsParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) + case true && propertyIdentifierArgument == BACnetPropertyIdentifier_SUBSCRIBED_RECIPIENTS: // BACnetConstructedDataSubscribedRecipients + _child, typeSwitchError = BACnetConstructedDataSubscribedRecipientsParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_TAGS: // BACnetConstructedDataTags _child, typeSwitchError = BACnetConstructedDataTagsParse(readBuffer, tagNumber, objectTypeArgument, propertyIdentifierArgument) case true && propertyIdentifierArgument == BACnetPropertyIdentifier_THREAT_AUTHORITY: // BACnetConstructedDataThreatAuthority diff --git a/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataLocalForwardingOnly.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataLocalForwardingOnly.go new file mode 100644 index 00000000000..c77e37ea3d5 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataLocalForwardingOnly.go @@ -0,0 +1,211 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetConstructedDataLocalForwardingOnly is the data-structure of this message +type BACnetConstructedDataLocalForwardingOnly struct { + *BACnetConstructedData + LocalForwardingOnly *BACnetApplicationTagBoolean + + // Arguments. + TagNumber uint8 +} + +// IBACnetConstructedDataLocalForwardingOnly is the corresponding interface of BACnetConstructedDataLocalForwardingOnly +type IBACnetConstructedDataLocalForwardingOnly interface { + IBACnetConstructedData + // GetLocalForwardingOnly returns LocalForwardingOnly (property field) + GetLocalForwardingOnly() *BACnetApplicationTagBoolean + // 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 *BACnetConstructedDataLocalForwardingOnly) GetObjectTypeArgument() BACnetObjectType { + return 0 +} + +func (m *BACnetConstructedDataLocalForwardingOnly) GetPropertyIdentifierArgument() BACnetPropertyIdentifier { + return BACnetPropertyIdentifier_LOCAL_FORWARDING_ONLY +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *BACnetConstructedDataLocalForwardingOnly) InitializeParent(parent *BACnetConstructedData, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag) { + m.BACnetConstructedData.OpeningTag = openingTag + m.BACnetConstructedData.ClosingTag = closingTag +} + +func (m *BACnetConstructedDataLocalForwardingOnly) GetParent() *BACnetConstructedData { + return m.BACnetConstructedData +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *BACnetConstructedDataLocalForwardingOnly) GetLocalForwardingOnly() *BACnetApplicationTagBoolean { + return m.LocalForwardingOnly +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetConstructedDataLocalForwardingOnly factory function for BACnetConstructedDataLocalForwardingOnly +func NewBACnetConstructedDataLocalForwardingOnly(localForwardingOnly *BACnetApplicationTagBoolean, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag, tagNumber uint8) *BACnetConstructedDataLocalForwardingOnly { + _result := &BACnetConstructedDataLocalForwardingOnly{ + LocalForwardingOnly: localForwardingOnly, + BACnetConstructedData: NewBACnetConstructedData(openingTag, closingTag, tagNumber), + } + _result.Child = _result + return _result +} + +func CastBACnetConstructedDataLocalForwardingOnly(structType interface{}) *BACnetConstructedDataLocalForwardingOnly { + if casted, ok := structType.(BACnetConstructedDataLocalForwardingOnly); ok { + return &casted + } + if casted, ok := structType.(*BACnetConstructedDataLocalForwardingOnly); ok { + return casted + } + if casted, ok := structType.(BACnetConstructedData); ok { + return CastBACnetConstructedDataLocalForwardingOnly(casted.Child) + } + if casted, ok := structType.(*BACnetConstructedData); ok { + return CastBACnetConstructedDataLocalForwardingOnly(casted.Child) + } + return nil +} + +func (m *BACnetConstructedDataLocalForwardingOnly) GetTypeName() string { + return "BACnetConstructedDataLocalForwardingOnly" +} + +func (m *BACnetConstructedDataLocalForwardingOnly) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetConstructedDataLocalForwardingOnly) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Simple field (localForwardingOnly) + lengthInBits += m.LocalForwardingOnly.GetLengthInBits() + + return lengthInBits +} + +func (m *BACnetConstructedDataLocalForwardingOnly) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetConstructedDataLocalForwardingOnlyParse(readBuffer utils.ReadBuffer, tagNumber uint8, objectTypeArgument BACnetObjectType, propertyIdentifierArgument BACnetPropertyIdentifier) (*BACnetConstructedDataLocalForwardingOnly, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetConstructedDataLocalForwardingOnly"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (localForwardingOnly) + if pullErr := readBuffer.PullContext("localForwardingOnly"); pullErr != nil { + return nil, pullErr + } + _localForwardingOnly, _localForwardingOnlyErr := BACnetApplicationTagParse(readBuffer) + if _localForwardingOnlyErr != nil { + return nil, errors.Wrap(_localForwardingOnlyErr, "Error parsing 'localForwardingOnly' field") + } + localForwardingOnly := CastBACnetApplicationTagBoolean(_localForwardingOnly) + if closeErr := readBuffer.CloseContext("localForwardingOnly"); closeErr != nil { + return nil, closeErr + } + + if closeErr := readBuffer.CloseContext("BACnetConstructedDataLocalForwardingOnly"); closeErr != nil { + return nil, closeErr + } + + // Create a partially initialized instance + _child := &BACnetConstructedDataLocalForwardingOnly{ + LocalForwardingOnly: CastBACnetApplicationTagBoolean(localForwardingOnly), + BACnetConstructedData: &BACnetConstructedData{}, + } + _child.BACnetConstructedData.Child = _child + return _child, nil +} + +func (m *BACnetConstructedDataLocalForwardingOnly) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("BACnetConstructedDataLocalForwardingOnly"); pushErr != nil { + return pushErr + } + + // Simple Field (localForwardingOnly) + if pushErr := writeBuffer.PushContext("localForwardingOnly"); pushErr != nil { + return pushErr + } + _localForwardingOnlyErr := m.LocalForwardingOnly.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("localForwardingOnly"); popErr != nil { + return popErr + } + if _localForwardingOnlyErr != nil { + return errors.Wrap(_localForwardingOnlyErr, "Error serializing 'localForwardingOnly' field") + } + + if popErr := writeBuffer.PopContext("BACnetConstructedDataLocalForwardingOnly"); popErr != nil { + return popErr + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *BACnetConstructedDataLocalForwardingOnly) 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/protocols/bacnetip/readwrite/model/BACnetConstructedDataPortFilter.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataPortFilter.go new file mode 100644 index 00000000000..d7cf8478ac2 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataPortFilter.go @@ -0,0 +1,226 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetConstructedDataPortFilter is the data-structure of this message +type BACnetConstructedDataPortFilter struct { + *BACnetConstructedData + PortFilter []*BACnetPortPermission + + // Arguments. + TagNumber uint8 +} + +// IBACnetConstructedDataPortFilter is the corresponding interface of BACnetConstructedDataPortFilter +type IBACnetConstructedDataPortFilter interface { + IBACnetConstructedData + // GetPortFilter returns PortFilter (property field) + GetPortFilter() []*BACnetPortPermission + // 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 *BACnetConstructedDataPortFilter) GetObjectTypeArgument() BACnetObjectType { + return 0 +} + +func (m *BACnetConstructedDataPortFilter) GetPropertyIdentifierArgument() BACnetPropertyIdentifier { + return BACnetPropertyIdentifier_PORT_FILTER +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *BACnetConstructedDataPortFilter) InitializeParent(parent *BACnetConstructedData, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag) { + m.BACnetConstructedData.OpeningTag = openingTag + m.BACnetConstructedData.ClosingTag = closingTag +} + +func (m *BACnetConstructedDataPortFilter) GetParent() *BACnetConstructedData { + return m.BACnetConstructedData +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *BACnetConstructedDataPortFilter) GetPortFilter() []*BACnetPortPermission { + return m.PortFilter +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetConstructedDataPortFilter factory function for BACnetConstructedDataPortFilter +func NewBACnetConstructedDataPortFilter(portFilter []*BACnetPortPermission, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag, tagNumber uint8) *BACnetConstructedDataPortFilter { + _result := &BACnetConstructedDataPortFilter{ + PortFilter: portFilter, + BACnetConstructedData: NewBACnetConstructedData(openingTag, closingTag, tagNumber), + } + _result.Child = _result + return _result +} + +func CastBACnetConstructedDataPortFilter(structType interface{}) *BACnetConstructedDataPortFilter { + if casted, ok := structType.(BACnetConstructedDataPortFilter); ok { + return &casted + } + if casted, ok := structType.(*BACnetConstructedDataPortFilter); ok { + return casted + } + if casted, ok := structType.(BACnetConstructedData); ok { + return CastBACnetConstructedDataPortFilter(casted.Child) + } + if casted, ok := structType.(*BACnetConstructedData); ok { + return CastBACnetConstructedDataPortFilter(casted.Child) + } + return nil +} + +func (m *BACnetConstructedDataPortFilter) GetTypeName() string { + return "BACnetConstructedDataPortFilter" +} + +func (m *BACnetConstructedDataPortFilter) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetConstructedDataPortFilter) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Array field + if len(m.PortFilter) > 0 { + for _, element := range m.PortFilter { + lengthInBits += element.GetLengthInBits() + } + } + + return lengthInBits +} + +func (m *BACnetConstructedDataPortFilter) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetConstructedDataPortFilterParse(readBuffer utils.ReadBuffer, tagNumber uint8, objectTypeArgument BACnetObjectType, propertyIdentifierArgument BACnetPropertyIdentifier) (*BACnetConstructedDataPortFilter, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetConstructedDataPortFilter"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Array field (portFilter) + if pullErr := readBuffer.PullContext("portFilter", utils.WithRenderAsList(true)); pullErr != nil { + return nil, pullErr + } + // Terminated array + portFilter := make([]*BACnetPortPermission, 0) + { + for !bool(IsBACnetConstructedDataClosingTag(readBuffer, false, tagNumber)) { + _item, _err := BACnetPortPermissionParse(readBuffer) + if _err != nil { + return nil, errors.Wrap(_err, "Error parsing 'portFilter' field") + } + portFilter = append(portFilter, CastBACnetPortPermission(_item)) + + } + } + if closeErr := readBuffer.CloseContext("portFilter", utils.WithRenderAsList(true)); closeErr != nil { + return nil, closeErr + } + + if closeErr := readBuffer.CloseContext("BACnetConstructedDataPortFilter"); closeErr != nil { + return nil, closeErr + } + + // Create a partially initialized instance + _child := &BACnetConstructedDataPortFilter{ + PortFilter: portFilter, + BACnetConstructedData: &BACnetConstructedData{}, + } + _child.BACnetConstructedData.Child = _child + return _child, nil +} + +func (m *BACnetConstructedDataPortFilter) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("BACnetConstructedDataPortFilter"); pushErr != nil { + return pushErr + } + + // Array Field (portFilter) + if m.PortFilter != nil { + if pushErr := writeBuffer.PushContext("portFilter", utils.WithRenderAsList(true)); pushErr != nil { + return pushErr + } + for _, _element := range m.PortFilter { + _elementErr := _element.Serialize(writeBuffer) + if _elementErr != nil { + return errors.Wrap(_elementErr, "Error serializing 'portFilter' field") + } + } + if popErr := writeBuffer.PopContext("portFilter", utils.WithRenderAsList(true)); popErr != nil { + return popErr + } + } + + if popErr := writeBuffer.PopContext("BACnetConstructedDataPortFilter"); popErr != nil { + return popErr + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *BACnetConstructedDataPortFilter) 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/protocols/bacnetip/readwrite/model/BACnetConstructedDataProcessIdentifierFilter.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataProcessIdentifierFilter.go new file mode 100644 index 00000000000..094ae08348a --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataProcessIdentifierFilter.go @@ -0,0 +1,211 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetConstructedDataProcessIdentifierFilter is the data-structure of this message +type BACnetConstructedDataProcessIdentifierFilter struct { + *BACnetConstructedData + ProcessIdentifierFilter *BACnetProcessIdSelection + + // Arguments. + TagNumber uint8 +} + +// IBACnetConstructedDataProcessIdentifierFilter is the corresponding interface of BACnetConstructedDataProcessIdentifierFilter +type IBACnetConstructedDataProcessIdentifierFilter interface { + IBACnetConstructedData + // GetProcessIdentifierFilter returns ProcessIdentifierFilter (property field) + GetProcessIdentifierFilter() *BACnetProcessIdSelection + // 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 *BACnetConstructedDataProcessIdentifierFilter) GetObjectTypeArgument() BACnetObjectType { + return 0 +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) GetPropertyIdentifierArgument() BACnetPropertyIdentifier { + return BACnetPropertyIdentifier_PROCESS_IDENTIFIER_FILTER +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *BACnetConstructedDataProcessIdentifierFilter) InitializeParent(parent *BACnetConstructedData, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag) { + m.BACnetConstructedData.OpeningTag = openingTag + m.BACnetConstructedData.ClosingTag = closingTag +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) GetParent() *BACnetConstructedData { + return m.BACnetConstructedData +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *BACnetConstructedDataProcessIdentifierFilter) GetProcessIdentifierFilter() *BACnetProcessIdSelection { + return m.ProcessIdentifierFilter +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetConstructedDataProcessIdentifierFilter factory function for BACnetConstructedDataProcessIdentifierFilter +func NewBACnetConstructedDataProcessIdentifierFilter(processIdentifierFilter *BACnetProcessIdSelection, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag, tagNumber uint8) *BACnetConstructedDataProcessIdentifierFilter { + _result := &BACnetConstructedDataProcessIdentifierFilter{ + ProcessIdentifierFilter: processIdentifierFilter, + BACnetConstructedData: NewBACnetConstructedData(openingTag, closingTag, tagNumber), + } + _result.Child = _result + return _result +} + +func CastBACnetConstructedDataProcessIdentifierFilter(structType interface{}) *BACnetConstructedDataProcessIdentifierFilter { + if casted, ok := structType.(BACnetConstructedDataProcessIdentifierFilter); ok { + return &casted + } + if casted, ok := structType.(*BACnetConstructedDataProcessIdentifierFilter); ok { + return casted + } + if casted, ok := structType.(BACnetConstructedData); ok { + return CastBACnetConstructedDataProcessIdentifierFilter(casted.Child) + } + if casted, ok := structType.(*BACnetConstructedData); ok { + return CastBACnetConstructedDataProcessIdentifierFilter(casted.Child) + } + return nil +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) GetTypeName() string { + return "BACnetConstructedDataProcessIdentifierFilter" +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Simple field (processIdentifierFilter) + lengthInBits += m.ProcessIdentifierFilter.GetLengthInBits() + + return lengthInBits +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetConstructedDataProcessIdentifierFilterParse(readBuffer utils.ReadBuffer, tagNumber uint8, objectTypeArgument BACnetObjectType, propertyIdentifierArgument BACnetPropertyIdentifier) (*BACnetConstructedDataProcessIdentifierFilter, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetConstructedDataProcessIdentifierFilter"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (processIdentifierFilter) + if pullErr := readBuffer.PullContext("processIdentifierFilter"); pullErr != nil { + return nil, pullErr + } + _processIdentifierFilter, _processIdentifierFilterErr := BACnetProcessIdSelectionParse(readBuffer) + if _processIdentifierFilterErr != nil { + return nil, errors.Wrap(_processIdentifierFilterErr, "Error parsing 'processIdentifierFilter' field") + } + processIdentifierFilter := CastBACnetProcessIdSelection(_processIdentifierFilter) + if closeErr := readBuffer.CloseContext("processIdentifierFilter"); closeErr != nil { + return nil, closeErr + } + + if closeErr := readBuffer.CloseContext("BACnetConstructedDataProcessIdentifierFilter"); closeErr != nil { + return nil, closeErr + } + + // Create a partially initialized instance + _child := &BACnetConstructedDataProcessIdentifierFilter{ + ProcessIdentifierFilter: CastBACnetProcessIdSelection(processIdentifierFilter), + BACnetConstructedData: &BACnetConstructedData{}, + } + _child.BACnetConstructedData.Child = _child + return _child, nil +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("BACnetConstructedDataProcessIdentifierFilter"); pushErr != nil { + return pushErr + } + + // Simple Field (processIdentifierFilter) + if pushErr := writeBuffer.PushContext("processIdentifierFilter"); pushErr != nil { + return pushErr + } + _processIdentifierFilterErr := m.ProcessIdentifierFilter.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("processIdentifierFilter"); popErr != nil { + return popErr + } + if _processIdentifierFilterErr != nil { + return errors.Wrap(_processIdentifierFilterErr, "Error serializing 'processIdentifierFilter' field") + } + + if popErr := writeBuffer.PopContext("BACnetConstructedDataProcessIdentifierFilter"); popErr != nil { + return popErr + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *BACnetConstructedDataProcessIdentifierFilter) 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/protocols/bacnetip/readwrite/model/BACnetConstructedDataSubscribedRecipients.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataSubscribedRecipients.go new file mode 100644 index 00000000000..f4d3fa0cc40 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataSubscribedRecipients.go @@ -0,0 +1,226 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetConstructedDataSubscribedRecipients is the data-structure of this message +type BACnetConstructedDataSubscribedRecipients struct { + *BACnetConstructedData + SubscribedRecipients []*BACnetEventNotificationSubscription + + // Arguments. + TagNumber uint8 +} + +// IBACnetConstructedDataSubscribedRecipients is the corresponding interface of BACnetConstructedDataSubscribedRecipients +type IBACnetConstructedDataSubscribedRecipients interface { + IBACnetConstructedData + // GetSubscribedRecipients returns SubscribedRecipients (property field) + GetSubscribedRecipients() []*BACnetEventNotificationSubscription + // 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 *BACnetConstructedDataSubscribedRecipients) GetObjectTypeArgument() BACnetObjectType { + return 0 +} + +func (m *BACnetConstructedDataSubscribedRecipients) GetPropertyIdentifierArgument() BACnetPropertyIdentifier { + return BACnetPropertyIdentifier_SUBSCRIBED_RECIPIENTS +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *BACnetConstructedDataSubscribedRecipients) InitializeParent(parent *BACnetConstructedData, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag) { + m.BACnetConstructedData.OpeningTag = openingTag + m.BACnetConstructedData.ClosingTag = closingTag +} + +func (m *BACnetConstructedDataSubscribedRecipients) GetParent() *BACnetConstructedData { + return m.BACnetConstructedData +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *BACnetConstructedDataSubscribedRecipients) GetSubscribedRecipients() []*BACnetEventNotificationSubscription { + return m.SubscribedRecipients +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetConstructedDataSubscribedRecipients factory function for BACnetConstructedDataSubscribedRecipients +func NewBACnetConstructedDataSubscribedRecipients(subscribedRecipients []*BACnetEventNotificationSubscription, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag, tagNumber uint8) *BACnetConstructedDataSubscribedRecipients { + _result := &BACnetConstructedDataSubscribedRecipients{ + SubscribedRecipients: subscribedRecipients, + BACnetConstructedData: NewBACnetConstructedData(openingTag, closingTag, tagNumber), + } + _result.Child = _result + return _result +} + +func CastBACnetConstructedDataSubscribedRecipients(structType interface{}) *BACnetConstructedDataSubscribedRecipients { + if casted, ok := structType.(BACnetConstructedDataSubscribedRecipients); ok { + return &casted + } + if casted, ok := structType.(*BACnetConstructedDataSubscribedRecipients); ok { + return casted + } + if casted, ok := structType.(BACnetConstructedData); ok { + return CastBACnetConstructedDataSubscribedRecipients(casted.Child) + } + if casted, ok := structType.(*BACnetConstructedData); ok { + return CastBACnetConstructedDataSubscribedRecipients(casted.Child) + } + return nil +} + +func (m *BACnetConstructedDataSubscribedRecipients) GetTypeName() string { + return "BACnetConstructedDataSubscribedRecipients" +} + +func (m *BACnetConstructedDataSubscribedRecipients) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetConstructedDataSubscribedRecipients) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Array field + if len(m.SubscribedRecipients) > 0 { + for _, element := range m.SubscribedRecipients { + lengthInBits += element.GetLengthInBits() + } + } + + return lengthInBits +} + +func (m *BACnetConstructedDataSubscribedRecipients) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetConstructedDataSubscribedRecipientsParse(readBuffer utils.ReadBuffer, tagNumber uint8, objectTypeArgument BACnetObjectType, propertyIdentifierArgument BACnetPropertyIdentifier) (*BACnetConstructedDataSubscribedRecipients, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetConstructedDataSubscribedRecipients"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Array field (subscribedRecipients) + if pullErr := readBuffer.PullContext("subscribedRecipients", utils.WithRenderAsList(true)); pullErr != nil { + return nil, pullErr + } + // Terminated array + subscribedRecipients := make([]*BACnetEventNotificationSubscription, 0) + { + for !bool(IsBACnetConstructedDataClosingTag(readBuffer, false, tagNumber)) { + _item, _err := BACnetEventNotificationSubscriptionParse(readBuffer) + if _err != nil { + return nil, errors.Wrap(_err, "Error parsing 'subscribedRecipients' field") + } + subscribedRecipients = append(subscribedRecipients, CastBACnetEventNotificationSubscription(_item)) + + } + } + if closeErr := readBuffer.CloseContext("subscribedRecipients", utils.WithRenderAsList(true)); closeErr != nil { + return nil, closeErr + } + + if closeErr := readBuffer.CloseContext("BACnetConstructedDataSubscribedRecipients"); closeErr != nil { + return nil, closeErr + } + + // Create a partially initialized instance + _child := &BACnetConstructedDataSubscribedRecipients{ + SubscribedRecipients: subscribedRecipients, + BACnetConstructedData: &BACnetConstructedData{}, + } + _child.BACnetConstructedData.Child = _child + return _child, nil +} + +func (m *BACnetConstructedDataSubscribedRecipients) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("BACnetConstructedDataSubscribedRecipients"); pushErr != nil { + return pushErr + } + + // Array Field (subscribedRecipients) + if m.SubscribedRecipients != nil { + if pushErr := writeBuffer.PushContext("subscribedRecipients", utils.WithRenderAsList(true)); pushErr != nil { + return pushErr + } + for _, _element := range m.SubscribedRecipients { + _elementErr := _element.Serialize(writeBuffer) + if _elementErr != nil { + return errors.Wrap(_elementErr, "Error serializing 'subscribedRecipients' field") + } + } + if popErr := writeBuffer.PopContext("subscribedRecipients", utils.WithRenderAsList(true)); popErr != nil { + return popErr + } + } + + if popErr := writeBuffer.PopContext("BACnetConstructedDataSubscribedRecipients"); popErr != nil { + return popErr + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *BACnetConstructedDataSubscribedRecipients) 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/protocols/bacnetip/readwrite/model/BACnetEventNotificationSubscription.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetEventNotificationSubscription.go new file mode 100644 index 00000000000..ee888b446e9 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetEventNotificationSubscription.go @@ -0,0 +1,280 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" + "io" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetEventNotificationSubscription is the data-structure of this message +type BACnetEventNotificationSubscription struct { + Recipient *BACnetRecipientEnclosed + ProcessIdentifier *BACnetContextTagUnsignedInteger + IssueConfirmedNotifications *BACnetContextTagBoolean + TimeRemaining *BACnetContextTagUnsignedInteger +} + +// IBACnetEventNotificationSubscription is the corresponding interface of BACnetEventNotificationSubscription +type IBACnetEventNotificationSubscription interface { + // GetRecipient returns Recipient (property field) + GetRecipient() *BACnetRecipientEnclosed + // GetProcessIdentifier returns ProcessIdentifier (property field) + GetProcessIdentifier() *BACnetContextTagUnsignedInteger + // GetIssueConfirmedNotifications returns IssueConfirmedNotifications (property field) + GetIssueConfirmedNotifications() *BACnetContextTagBoolean + // GetTimeRemaining returns TimeRemaining (property field) + GetTimeRemaining() *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 *BACnetEventNotificationSubscription) GetRecipient() *BACnetRecipientEnclosed { + return m.Recipient +} + +func (m *BACnetEventNotificationSubscription) GetProcessIdentifier() *BACnetContextTagUnsignedInteger { + return m.ProcessIdentifier +} + +func (m *BACnetEventNotificationSubscription) GetIssueConfirmedNotifications() *BACnetContextTagBoolean { + return m.IssueConfirmedNotifications +} + +func (m *BACnetEventNotificationSubscription) GetTimeRemaining() *BACnetContextTagUnsignedInteger { + return m.TimeRemaining +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetEventNotificationSubscription factory function for BACnetEventNotificationSubscription +func NewBACnetEventNotificationSubscription(recipient *BACnetRecipientEnclosed, processIdentifier *BACnetContextTagUnsignedInteger, issueConfirmedNotifications *BACnetContextTagBoolean, timeRemaining *BACnetContextTagUnsignedInteger) *BACnetEventNotificationSubscription { + return &BACnetEventNotificationSubscription{Recipient: recipient, ProcessIdentifier: processIdentifier, IssueConfirmedNotifications: issueConfirmedNotifications, TimeRemaining: timeRemaining} +} + +func CastBACnetEventNotificationSubscription(structType interface{}) *BACnetEventNotificationSubscription { + if casted, ok := structType.(BACnetEventNotificationSubscription); ok { + return &casted + } + if casted, ok := structType.(*BACnetEventNotificationSubscription); ok { + return casted + } + return nil +} + +func (m *BACnetEventNotificationSubscription) GetTypeName() string { + return "BACnetEventNotificationSubscription" +} + +func (m *BACnetEventNotificationSubscription) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetEventNotificationSubscription) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(0) + + // Simple field (recipient) + lengthInBits += m.Recipient.GetLengthInBits() + + // Simple field (processIdentifier) + lengthInBits += m.ProcessIdentifier.GetLengthInBits() + + // Optional Field (issueConfirmedNotifications) + if m.IssueConfirmedNotifications != nil { + lengthInBits += (*m.IssueConfirmedNotifications).GetLengthInBits() + } + + // Simple field (timeRemaining) + lengthInBits += m.TimeRemaining.GetLengthInBits() + + return lengthInBits +} + +func (m *BACnetEventNotificationSubscription) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetEventNotificationSubscriptionParse(readBuffer utils.ReadBuffer) (*BACnetEventNotificationSubscription, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetEventNotificationSubscription"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (recipient) + if pullErr := readBuffer.PullContext("recipient"); pullErr != nil { + return nil, pullErr + } + _recipient, _recipientErr := BACnetRecipientEnclosedParse(readBuffer, uint8(uint8(0))) + if _recipientErr != nil { + return nil, errors.Wrap(_recipientErr, "Error parsing 'recipient' field") + } + recipient := CastBACnetRecipientEnclosed(_recipient) + if closeErr := readBuffer.CloseContext("recipient"); closeErr != nil { + return nil, closeErr + } + + // Simple Field (processIdentifier) + if pullErr := readBuffer.PullContext("processIdentifier"); pullErr != nil { + return nil, pullErr + } + _processIdentifier, _processIdentifierErr := BACnetContextTagParse(readBuffer, uint8(uint8(1)), BACnetDataType(BACnetDataType_UNSIGNED_INTEGER)) + if _processIdentifierErr != nil { + return nil, errors.Wrap(_processIdentifierErr, "Error parsing 'processIdentifier' field") + } + processIdentifier := CastBACnetContextTagUnsignedInteger(_processIdentifier) + if closeErr := readBuffer.CloseContext("processIdentifier"); closeErr != nil { + return nil, closeErr + } + + // Optional Field (issueConfirmedNotifications) (Can be skipped, if a given expression evaluates to false) + var issueConfirmedNotifications *BACnetContextTagBoolean = nil + { + currentPos = positionAware.GetPos() + if pullErr := readBuffer.PullContext("issueConfirmedNotifications"); pullErr != nil { + return nil, pullErr + } + _val, _err := BACnetContextTagParse(readBuffer, uint8(2), BACnetDataType_BOOLEAN) + 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 'issueConfirmedNotifications' field") + default: + issueConfirmedNotifications = CastBACnetContextTagBoolean(_val) + if closeErr := readBuffer.CloseContext("issueConfirmedNotifications"); closeErr != nil { + return nil, closeErr + } + } + } + + // Simple Field (timeRemaining) + if pullErr := readBuffer.PullContext("timeRemaining"); pullErr != nil { + return nil, pullErr + } + _timeRemaining, _timeRemainingErr := BACnetContextTagParse(readBuffer, uint8(uint8(3)), BACnetDataType(BACnetDataType_UNSIGNED_INTEGER)) + if _timeRemainingErr != nil { + return nil, errors.Wrap(_timeRemainingErr, "Error parsing 'timeRemaining' field") + } + timeRemaining := CastBACnetContextTagUnsignedInteger(_timeRemaining) + if closeErr := readBuffer.CloseContext("timeRemaining"); closeErr != nil { + return nil, closeErr + } + + if closeErr := readBuffer.CloseContext("BACnetEventNotificationSubscription"); closeErr != nil { + return nil, closeErr + } + + // Create the instance + return NewBACnetEventNotificationSubscription(recipient, processIdentifier, issueConfirmedNotifications, timeRemaining), nil +} + +func (m *BACnetEventNotificationSubscription) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + if pushErr := writeBuffer.PushContext("BACnetEventNotificationSubscription"); pushErr != nil { + return pushErr + } + + // Simple Field (recipient) + if pushErr := writeBuffer.PushContext("recipient"); pushErr != nil { + return pushErr + } + _recipientErr := m.Recipient.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("recipient"); popErr != nil { + return popErr + } + if _recipientErr != nil { + return errors.Wrap(_recipientErr, "Error serializing 'recipient' field") + } + + // Simple Field (processIdentifier) + if pushErr := writeBuffer.PushContext("processIdentifier"); pushErr != nil { + return pushErr + } + _processIdentifierErr := m.ProcessIdentifier.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("processIdentifier"); popErr != nil { + return popErr + } + if _processIdentifierErr != nil { + return errors.Wrap(_processIdentifierErr, "Error serializing 'processIdentifier' field") + } + + // Optional Field (issueConfirmedNotifications) (Can be skipped, if the value is null) + var issueConfirmedNotifications *BACnetContextTagBoolean = nil + if m.IssueConfirmedNotifications != nil { + if pushErr := writeBuffer.PushContext("issueConfirmedNotifications"); pushErr != nil { + return pushErr + } + issueConfirmedNotifications = m.IssueConfirmedNotifications + _issueConfirmedNotificationsErr := issueConfirmedNotifications.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("issueConfirmedNotifications"); popErr != nil { + return popErr + } + if _issueConfirmedNotificationsErr != nil { + return errors.Wrap(_issueConfirmedNotificationsErr, "Error serializing 'issueConfirmedNotifications' field") + } + } + + // Simple Field (timeRemaining) + if pushErr := writeBuffer.PushContext("timeRemaining"); pushErr != nil { + return pushErr + } + _timeRemainingErr := m.TimeRemaining.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("timeRemaining"); popErr != nil { + return popErr + } + if _timeRemainingErr != nil { + return errors.Wrap(_timeRemainingErr, "Error serializing 'timeRemaining' field") + } + + if popErr := writeBuffer.PopContext("BACnetEventNotificationSubscription"); popErr != nil { + return popErr + } + return nil +} + +func (m *BACnetEventNotificationSubscription) 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/protocols/bacnetip/readwrite/model/BACnetPortPermission.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetPortPermission.go new file mode 100644 index 00000000000..0bd8e15da14 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetPortPermission.go @@ -0,0 +1,210 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" + "io" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetPortPermission is the data-structure of this message +type BACnetPortPermission struct { + Port *BACnetContextTagUnsignedInteger + Enable *BACnetContextTagBoolean +} + +// IBACnetPortPermission is the corresponding interface of BACnetPortPermission +type IBACnetPortPermission interface { + // GetPort returns Port (property field) + GetPort() *BACnetContextTagUnsignedInteger + // GetEnable returns Enable (property field) + GetEnable() *BACnetContextTagBoolean + // 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 *BACnetPortPermission) GetPort() *BACnetContextTagUnsignedInteger { + return m.Port +} + +func (m *BACnetPortPermission) GetEnable() *BACnetContextTagBoolean { + return m.Enable +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetPortPermission factory function for BACnetPortPermission +func NewBACnetPortPermission(port *BACnetContextTagUnsignedInteger, enable *BACnetContextTagBoolean) *BACnetPortPermission { + return &BACnetPortPermission{Port: port, Enable: enable} +} + +func CastBACnetPortPermission(structType interface{}) *BACnetPortPermission { + if casted, ok := structType.(BACnetPortPermission); ok { + return &casted + } + if casted, ok := structType.(*BACnetPortPermission); ok { + return casted + } + return nil +} + +func (m *BACnetPortPermission) GetTypeName() string { + return "BACnetPortPermission" +} + +func (m *BACnetPortPermission) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetPortPermission) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(0) + + // Simple field (port) + lengthInBits += m.Port.GetLengthInBits() + + // Optional Field (enable) + if m.Enable != nil { + lengthInBits += (*m.Enable).GetLengthInBits() + } + + return lengthInBits +} + +func (m *BACnetPortPermission) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetPortPermissionParse(readBuffer utils.ReadBuffer) (*BACnetPortPermission, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetPortPermission"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (port) + if pullErr := readBuffer.PullContext("port"); pullErr != nil { + return nil, pullErr + } + _port, _portErr := BACnetContextTagParse(readBuffer, uint8(uint8(0)), BACnetDataType(BACnetDataType_UNSIGNED_INTEGER)) + if _portErr != nil { + return nil, errors.Wrap(_portErr, "Error parsing 'port' field") + } + port := CastBACnetContextTagUnsignedInteger(_port) + if closeErr := readBuffer.CloseContext("port"); closeErr != nil { + return nil, closeErr + } + + // Optional Field (enable) (Can be skipped, if a given expression evaluates to false) + var enable *BACnetContextTagBoolean = nil + { + currentPos = positionAware.GetPos() + if pullErr := readBuffer.PullContext("enable"); pullErr != nil { + return nil, pullErr + } + _val, _err := BACnetContextTagParse(readBuffer, uint8(1), BACnetDataType_BOOLEAN) + 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 'enable' field") + default: + enable = CastBACnetContextTagBoolean(_val) + if closeErr := readBuffer.CloseContext("enable"); closeErr != nil { + return nil, closeErr + } + } + } + + if closeErr := readBuffer.CloseContext("BACnetPortPermission"); closeErr != nil { + return nil, closeErr + } + + // Create the instance + return NewBACnetPortPermission(port, enable), nil +} + +func (m *BACnetPortPermission) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + if pushErr := writeBuffer.PushContext("BACnetPortPermission"); pushErr != nil { + return pushErr + } + + // Simple Field (port) + if pushErr := writeBuffer.PushContext("port"); pushErr != nil { + return pushErr + } + _portErr := m.Port.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("port"); popErr != nil { + return popErr + } + if _portErr != nil { + return errors.Wrap(_portErr, "Error serializing 'port' field") + } + + // Optional Field (enable) (Can be skipped, if the value is null) + var enable *BACnetContextTagBoolean = nil + if m.Enable != nil { + if pushErr := writeBuffer.PushContext("enable"); pushErr != nil { + return pushErr + } + enable = m.Enable + _enableErr := enable.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("enable"); popErr != nil { + return popErr + } + if _enableErr != nil { + return errors.Wrap(_enableErr, "Error serializing 'enable' field") + } + } + + if popErr := writeBuffer.PopContext("BACnetPortPermission"); popErr != nil { + return popErr + } + return nil +} + +func (m *BACnetPortPermission) 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/protocols/bacnetip/readwrite/model/BACnetProcessIdSelection.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetProcessIdSelection.go new file mode 100644 index 00000000000..f44cba1f376 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetProcessIdSelection.go @@ -0,0 +1,218 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetProcessIdSelection is the data-structure of this message +type BACnetProcessIdSelection struct { + PeekedTagHeader *BACnetTagHeader + Child IBACnetProcessIdSelectionChild +} + +// IBACnetProcessIdSelection is the corresponding interface of BACnetProcessIdSelection +type IBACnetProcessIdSelection interface { + // GetPeekedTagHeader returns PeekedTagHeader (property field) + GetPeekedTagHeader() *BACnetTagHeader + // GetPeekedTagNumber returns PeekedTagNumber (virtual field) + GetPeekedTagNumber() uint8 + // 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 +} + +type IBACnetProcessIdSelectionParent interface { + SerializeParent(writeBuffer utils.WriteBuffer, child IBACnetProcessIdSelection, serializeChildFunction func() error) error + GetTypeName() string +} + +type IBACnetProcessIdSelectionChild interface { + Serialize(writeBuffer utils.WriteBuffer) error + InitializeParent(parent *BACnetProcessIdSelection, peekedTagHeader *BACnetTagHeader) + GetParent() *BACnetProcessIdSelection + + GetTypeName() string + IBACnetProcessIdSelection +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *BACnetProcessIdSelection) GetPeekedTagHeader() *BACnetTagHeader { + return m.PeekedTagHeader +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for virtual fields. +/////////////////////// + +func (m *BACnetProcessIdSelection) GetPeekedTagNumber() uint8 { + return uint8(m.GetPeekedTagHeader().GetActualTagNumber()) +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetProcessIdSelection factory function for BACnetProcessIdSelection +func NewBACnetProcessIdSelection(peekedTagHeader *BACnetTagHeader) *BACnetProcessIdSelection { + return &BACnetProcessIdSelection{PeekedTagHeader: peekedTagHeader} +} + +func CastBACnetProcessIdSelection(structType interface{}) *BACnetProcessIdSelection { + if casted, ok := structType.(BACnetProcessIdSelection); ok { + return &casted + } + if casted, ok := structType.(*BACnetProcessIdSelection); ok { + return casted + } + if casted, ok := structType.(IBACnetProcessIdSelectionChild); ok { + return casted.GetParent() + } + return nil +} + +func (m *BACnetProcessIdSelection) GetTypeName() string { + return "BACnetProcessIdSelection" +} + +func (m *BACnetProcessIdSelection) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetProcessIdSelection) GetLengthInBitsConditional(lastItem bool) uint16 { + return m.Child.GetLengthInBits() +} + +func (m *BACnetProcessIdSelection) GetParentLengthInBits() uint16 { + lengthInBits := uint16(0) + + // A virtual field doesn't have any in- or output. + + return lengthInBits +} + +func (m *BACnetProcessIdSelection) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetProcessIdSelectionParse(readBuffer utils.ReadBuffer) (*BACnetProcessIdSelection, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetProcessIdSelection"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Peek Field (peekedTagHeader) + currentPos = positionAware.GetPos() + if pullErr := readBuffer.PullContext("peekedTagHeader"); pullErr != nil { + return nil, pullErr + } + peekedTagHeader, _ := BACnetTagHeaderParse(readBuffer) + readBuffer.Reset(currentPos) + + // Virtual field + _peekedTagNumber := peekedTagHeader.GetActualTagNumber() + peekedTagNumber := uint8(_peekedTagNumber) + _ = peekedTagNumber + + // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) + type BACnetProcessIdSelectionChild interface { + InitializeParent(*BACnetProcessIdSelection, *BACnetTagHeader) + GetParent() *BACnetProcessIdSelection + } + var _child BACnetProcessIdSelectionChild + var typeSwitchError error + switch { + case peekedTagNumber == uint8(0): // BACnetProcessIdSelectionNull + _child, typeSwitchError = BACnetProcessIdSelectionNullParse(readBuffer) + case true: // BACnetProcessIdSelectionValue + _child, typeSwitchError = BACnetProcessIdSelectionValueParse(readBuffer) + default: + // TODO: return actual type + typeSwitchError = errors.New("Unmapped type") + } + if typeSwitchError != nil { + return nil, errors.Wrap(typeSwitchError, "Error parsing sub-type for type-switch.") + } + + if closeErr := readBuffer.CloseContext("BACnetProcessIdSelection"); closeErr != nil { + return nil, closeErr + } + + // Finish initializing + _child.InitializeParent(_child.GetParent(), peekedTagHeader) + return _child.GetParent(), nil +} + +func (m *BACnetProcessIdSelection) Serialize(writeBuffer utils.WriteBuffer) error { + return m.Child.Serialize(writeBuffer) +} + +func (m *BACnetProcessIdSelection) SerializeParent(writeBuffer utils.WriteBuffer, child IBACnetProcessIdSelection, serializeChildFunction func() error) error { + positionAware := writeBuffer + _ = positionAware + if pushErr := writeBuffer.PushContext("BACnetProcessIdSelection"); pushErr != nil { + return pushErr + } + // Virtual field + if _peekedTagNumberErr := writeBuffer.WriteVirtual("peekedTagNumber", m.GetPeekedTagNumber()); _peekedTagNumberErr != nil { + return errors.Wrap(_peekedTagNumberErr, "Error serializing 'peekedTagNumber' field") + } + + // Switch field (Depending on the discriminator values, passes the serialization to a sub-type) + if _typeSwitchErr := serializeChildFunction(); _typeSwitchErr != nil { + return errors.Wrap(_typeSwitchErr, "Error serializing sub-type field") + } + + if popErr := writeBuffer.PopContext("BACnetProcessIdSelection"); popErr != nil { + return popErr + } + return nil +} + +func (m *BACnetProcessIdSelection) 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/protocols/bacnetip/readwrite/model/BACnetProcessIdSelectionNull.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetProcessIdSelectionNull.go new file mode 100644 index 00000000000..70a093cd9a2 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetProcessIdSelectionNull.go @@ -0,0 +1,199 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetProcessIdSelectionNull is the data-structure of this message +type BACnetProcessIdSelectionNull struct { + *BACnetProcessIdSelection + NullValue *BACnetApplicationTagNull +} + +// IBACnetProcessIdSelectionNull is the corresponding interface of BACnetProcessIdSelectionNull +type IBACnetProcessIdSelectionNull interface { + IBACnetProcessIdSelection + // GetNullValue returns NullValue (property field) + GetNullValue() *BACnetApplicationTagNull + // 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 *BACnetProcessIdSelectionNull) InitializeParent(parent *BACnetProcessIdSelection, peekedTagHeader *BACnetTagHeader) { + m.BACnetProcessIdSelection.PeekedTagHeader = peekedTagHeader +} + +func (m *BACnetProcessIdSelectionNull) GetParent() *BACnetProcessIdSelection { + return m.BACnetProcessIdSelection +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *BACnetProcessIdSelectionNull) GetNullValue() *BACnetApplicationTagNull { + return m.NullValue +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetProcessIdSelectionNull factory function for BACnetProcessIdSelectionNull +func NewBACnetProcessIdSelectionNull(nullValue *BACnetApplicationTagNull, peekedTagHeader *BACnetTagHeader) *BACnetProcessIdSelectionNull { + _result := &BACnetProcessIdSelectionNull{ + NullValue: nullValue, + BACnetProcessIdSelection: NewBACnetProcessIdSelection(peekedTagHeader), + } + _result.Child = _result + return _result +} + +func CastBACnetProcessIdSelectionNull(structType interface{}) *BACnetProcessIdSelectionNull { + if casted, ok := structType.(BACnetProcessIdSelectionNull); ok { + return &casted + } + if casted, ok := structType.(*BACnetProcessIdSelectionNull); ok { + return casted + } + if casted, ok := structType.(BACnetProcessIdSelection); ok { + return CastBACnetProcessIdSelectionNull(casted.Child) + } + if casted, ok := structType.(*BACnetProcessIdSelection); ok { + return CastBACnetProcessIdSelectionNull(casted.Child) + } + return nil +} + +func (m *BACnetProcessIdSelectionNull) GetTypeName() string { + return "BACnetProcessIdSelectionNull" +} + +func (m *BACnetProcessIdSelectionNull) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetProcessIdSelectionNull) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Simple field (nullValue) + lengthInBits += m.NullValue.GetLengthInBits() + + return lengthInBits +} + +func (m *BACnetProcessIdSelectionNull) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetProcessIdSelectionNullParse(readBuffer utils.ReadBuffer) (*BACnetProcessIdSelectionNull, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetProcessIdSelectionNull"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (nullValue) + if pullErr := readBuffer.PullContext("nullValue"); pullErr != nil { + return nil, pullErr + } + _nullValue, _nullValueErr := BACnetApplicationTagParse(readBuffer) + if _nullValueErr != nil { + return nil, errors.Wrap(_nullValueErr, "Error parsing 'nullValue' field") + } + nullValue := CastBACnetApplicationTagNull(_nullValue) + if closeErr := readBuffer.CloseContext("nullValue"); closeErr != nil { + return nil, closeErr + } + + if closeErr := readBuffer.CloseContext("BACnetProcessIdSelectionNull"); closeErr != nil { + return nil, closeErr + } + + // Create a partially initialized instance + _child := &BACnetProcessIdSelectionNull{ + NullValue: CastBACnetApplicationTagNull(nullValue), + BACnetProcessIdSelection: &BACnetProcessIdSelection{}, + } + _child.BACnetProcessIdSelection.Child = _child + return _child, nil +} + +func (m *BACnetProcessIdSelectionNull) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("BACnetProcessIdSelectionNull"); pushErr != nil { + return pushErr + } + + // Simple Field (nullValue) + if pushErr := writeBuffer.PushContext("nullValue"); pushErr != nil { + return pushErr + } + _nullValueErr := m.NullValue.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("nullValue"); popErr != nil { + return popErr + } + if _nullValueErr != nil { + return errors.Wrap(_nullValueErr, "Error serializing 'nullValue' field") + } + + if popErr := writeBuffer.PopContext("BACnetProcessIdSelectionNull"); popErr != nil { + return popErr + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *BACnetProcessIdSelectionNull) 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/protocols/bacnetip/readwrite/model/BACnetProcessIdSelectionValue.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetProcessIdSelectionValue.go new file mode 100644 index 00000000000..c4582d8e558 --- /dev/null +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetProcessIdSelectionValue.go @@ -0,0 +1,199 @@ +/* + * 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/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// BACnetProcessIdSelectionValue is the data-structure of this message +type BACnetProcessIdSelectionValue struct { + *BACnetProcessIdSelection + ProcessIdentifier *BACnetApplicationTagUnsignedInteger +} + +// IBACnetProcessIdSelectionValue is the corresponding interface of BACnetProcessIdSelectionValue +type IBACnetProcessIdSelectionValue interface { + IBACnetProcessIdSelection + // GetProcessIdentifier returns ProcessIdentifier (property field) + GetProcessIdentifier() *BACnetApplicationTagUnsignedInteger + // 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 *BACnetProcessIdSelectionValue) InitializeParent(parent *BACnetProcessIdSelection, peekedTagHeader *BACnetTagHeader) { + m.BACnetProcessIdSelection.PeekedTagHeader = peekedTagHeader +} + +func (m *BACnetProcessIdSelectionValue) GetParent() *BACnetProcessIdSelection { + return m.BACnetProcessIdSelection +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *BACnetProcessIdSelectionValue) GetProcessIdentifier() *BACnetApplicationTagUnsignedInteger { + return m.ProcessIdentifier +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewBACnetProcessIdSelectionValue factory function for BACnetProcessIdSelectionValue +func NewBACnetProcessIdSelectionValue(processIdentifier *BACnetApplicationTagUnsignedInteger, peekedTagHeader *BACnetTagHeader) *BACnetProcessIdSelectionValue { + _result := &BACnetProcessIdSelectionValue{ + ProcessIdentifier: processIdentifier, + BACnetProcessIdSelection: NewBACnetProcessIdSelection(peekedTagHeader), + } + _result.Child = _result + return _result +} + +func CastBACnetProcessIdSelectionValue(structType interface{}) *BACnetProcessIdSelectionValue { + if casted, ok := structType.(BACnetProcessIdSelectionValue); ok { + return &casted + } + if casted, ok := structType.(*BACnetProcessIdSelectionValue); ok { + return casted + } + if casted, ok := structType.(BACnetProcessIdSelection); ok { + return CastBACnetProcessIdSelectionValue(casted.Child) + } + if casted, ok := structType.(*BACnetProcessIdSelection); ok { + return CastBACnetProcessIdSelectionValue(casted.Child) + } + return nil +} + +func (m *BACnetProcessIdSelectionValue) GetTypeName() string { + return "BACnetProcessIdSelectionValue" +} + +func (m *BACnetProcessIdSelectionValue) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *BACnetProcessIdSelectionValue) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Simple field (processIdentifier) + lengthInBits += m.ProcessIdentifier.GetLengthInBits() + + return lengthInBits +} + +func (m *BACnetProcessIdSelectionValue) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func BACnetProcessIdSelectionValueParse(readBuffer utils.ReadBuffer) (*BACnetProcessIdSelectionValue, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("BACnetProcessIdSelectionValue"); pullErr != nil { + return nil, pullErr + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (processIdentifier) + if pullErr := readBuffer.PullContext("processIdentifier"); pullErr != nil { + return nil, pullErr + } + _processIdentifier, _processIdentifierErr := BACnetApplicationTagParse(readBuffer) + if _processIdentifierErr != nil { + return nil, errors.Wrap(_processIdentifierErr, "Error parsing 'processIdentifier' field") + } + processIdentifier := CastBACnetApplicationTagUnsignedInteger(_processIdentifier) + if closeErr := readBuffer.CloseContext("processIdentifier"); closeErr != nil { + return nil, closeErr + } + + if closeErr := readBuffer.CloseContext("BACnetProcessIdSelectionValue"); closeErr != nil { + return nil, closeErr + } + + // Create a partially initialized instance + _child := &BACnetProcessIdSelectionValue{ + ProcessIdentifier: CastBACnetApplicationTagUnsignedInteger(processIdentifier), + BACnetProcessIdSelection: &BACnetProcessIdSelection{}, + } + _child.BACnetProcessIdSelection.Child = _child + return _child, nil +} + +func (m *BACnetProcessIdSelectionValue) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("BACnetProcessIdSelectionValue"); pushErr != nil { + return pushErr + } + + // Simple Field (processIdentifier) + if pushErr := writeBuffer.PushContext("processIdentifier"); pushErr != nil { + return pushErr + } + _processIdentifierErr := m.ProcessIdentifier.Serialize(writeBuffer) + if popErr := writeBuffer.PopContext("processIdentifier"); popErr != nil { + return popErr + } + if _processIdentifierErr != nil { + return errors.Wrap(_processIdentifierErr, "Error serializing 'processIdentifier' field") + } + + if popErr := writeBuffer.PopContext("BACnetProcessIdSelectionValue"); popErr != nil { + return popErr + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *BACnetProcessIdSelectionValue) 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/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec index eac1397c851..3fb4aa25e20 100644 --- a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec +++ b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec @@ -2958,14 +2958,16 @@ 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, tagNumber)'] ] //[*, 'LOCAL_DATE' BACnetConstructedDataLocalDate [validation '1 == 2' "TODO: implement me LOCAL_DATE BACnetConstructedDataLocalDate"]] - //[*, 'LOCAL_FORWARDING_ONLY' BACnetConstructedDataLocalForwardingOnly [validation '1 == 2' "TODO: implement me LOCAL_FORWARDING_ONLY BACnetConstructedDataLocalForwardingOnly"]] + [*, 'LOCAL_FORWARDING_ONLY' BACnetConstructedDataLocalForwardingOnly + [simple BACnetApplicationTagBoolean localForwardingOnly ] + ] //[*, 'LOCAL_TIME' BACnetConstructedDataLocalTime [validation '1 == 2' "TODO: implement me LOCAL_TIME BACnetConstructedDataLocalTime"]] //[*, 'LOCATION' BACnetConstructedDataLocation [validation '1 == 2' "TODO: implement me LOCATION BACnetConstructedDataLocation"]] [*, 'LOCK_STATUS' BACnetConstructedDataLockStatus - [simple BACnetLockStatusTagged('0', 'TagClass.APPLICATION_TAGS') lockStatus ] + [simple BACnetLockStatusTagged('0', 'TagClass.APPLICATION_TAGS') lockStatus ] ] [*, 'LOCKOUT' BACnetConstructedDataLockout - [simple BACnetApplicationTagBoolean lockout ] + [simple BACnetApplicationTagBoolean lockout ] ] [*, 'LOCKOUT_RELINQUISH_TIME' BACnetConstructedDataLockoutRelinquishTime [simple BACnetApplicationTagUnsignedInteger lockoutRelinquishTime ] @@ -3120,7 +3122,12 @@ //[*, 'PASSBACK_TIMEOUT' BACnetConstructedDataPassbackTimeout [validation '1 == 2' "TODO: implement me PASSBACK_TIMEOUT BACnetConstructedDataPassbackTimeout"]] //[*, 'PASSENGER_ALARM' BACnetConstructedDataPassengerAlarm [validation '1 == 2' "TODO: implement me PASSENGER_ALARM BACnetConstructedDataPassengerAlarm"]] //[*, 'POLARITY' BACnetConstructedDataPolarity [validation '1 == 2' "TODO: implement me POLARITY BACnetConstructedDataPolarity"]] - //[*, 'PORT_FILTER' BACnetConstructedDataPortFilter [validation '1 == 2' "TODO: implement me PORT_FILTER BACnetConstructedDataPortFilter"]] + [*, 'PORT_FILTER' BACnetConstructedDataPortFilter + [array BACnetPortPermission + portFilter + terminated + 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, tagNumber)' ] + ] [*, 'POSITIVE_ACCESS_RULES' BACnetConstructedDataPositiveAccessRules [array BACnetAccessRule positiveAccessRules @@ -3140,7 +3147,9 @@ ] //[*, 'PRIORITY_FOR_WRITING' BACnetConstructedDataPriorityForWriting [validation '1 == 2' "TODO: implement me PRIORITY_FOR_WRITING BACnetConstructedDataPriorityForWriting"]] //[*, 'PROCESS_IDENTIFIER' BACnetConstructedDataProcessIdentifier [validation '1 == 2' "TODO: implement me PROCESS_IDENTIFIER BACnetConstructedDataProcessIdentifier"]] - //[*, 'PROCESS_IDENTIFIER_FILTER' BACnetConstructedDataProcessIdentifierFilter [validation '1 == 2' "TODO: implement me PROCESS_IDENTIFIER_FILTER BACnetConstructedDataProcessIdentifierFilter"]] + [*, 'PROCESS_IDENTIFIER_FILTER' BACnetConstructedDataProcessIdentifierFilter + [simple BACnetProcessIdSelection processIdentifierFilter ] + ] [*, 'PROFILE_LOCATION' BACnetConstructedDataProfileLocation [simple BACnetApplicationTagCharacterString profileLocation ] ] @@ -3280,16 +3289,21 @@ terminated 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, tagNumber)' ] ] - //[*, 'SUBSCRIBED_RECIPIENTS' BACnetConstructedDataSubscribedRecipients [validation '1 == 2' "TODO: implement me SUBSCRIBED_RECIPIENTS BACnetConstructedDataSubscribedRecipients"]] + [*, 'SUBSCRIBED_RECIPIENTS' BACnetConstructedDataSubscribedRecipients + [array BACnetEventNotificationSubscription + subscribedRecipients + terminated + 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, tagNumber)' ] + ] //[*, 'SUPPORTED_FORMAT_CLASSES' BACnetConstructedDataSupportedFormatClasses [validation '1 == 2' "TODO: implement me SUPPORTED_FORMAT_CLASSES BACnetConstructedDataSupportedFormatClasses"]] //[*, 'SUPPORTED_FORMATS' BACnetConstructedDataSupportedFormats [validation '1 == 2' "TODO: implement me SUPPORTED_FORMATS BACnetConstructedDataSupportedFormats"]] //[*, 'SUPPORTED_SECURITY_ALGORITHMS' BACnetConstructedDataSupportedSecurityAlgorithms [validation '1 == 2' "TODO: implement me SUPPORTED_SECURITY_ALGORITHMS BACnetConstructedDataSupportedSecurityAlgorithms"]] //[*, 'SYSTEM_STATUS' BACnetConstructedDataSystemStatus [validation '1 == 2' "TODO: implement me SYSTEM_STATUS BACnetConstructedDataSystemStatus"]] [*, 'TAGS' BACnetConstructedDataTags [array BACnetNameValue - tags - terminated - 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, tagNumber)' ] + tags + terminated + 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, tagNumber)' ] ] [*, 'THREAT_AUTHORITY' BACnetConstructedDataThreatAuthority [simple BACnetAccessThreatLevel threatAuthority ] @@ -3832,11 +3846,45 @@ [type BACnetDailySchedule [simple BACnetOpeningTag('0') - openingTag ] + openingTag ] [array BACnetTimeValue daySchedule terminated - 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, 0)' ] + 'STATIC_CALL("isBACnetConstructedDataClosingTag", readBuffer, false, 0)' ] [simple BACnetClosingTag('0') closingTag ] ] + +[type BACnetEventNotificationSubscription + [simple BACnetRecipientEnclosed('0') + recipient ] + [simple BACnetContextTagUnsignedInteger('1', 'BACnetDataType.UNSIGNED_INTEGER') + processIdentifier ] + [optional BACnetContextTagBoolean('2', 'BACnetDataType.BOOLEAN') + issueConfirmedNotifications ] + [simple BACnetContextTagUnsignedInteger('3', 'BACnetDataType.UNSIGNED_INTEGER') + timeRemaining ] +] + +[type BACnetPortPermission + [simple BACnetContextTagUnsignedInteger('0', 'BACnetDataType.UNSIGNED_INTEGER') + port ] + [optional BACnetContextTagBoolean('1', 'BACnetDataType.BOOLEAN') + enable ] +] + +[type BACnetProcessIdSelection + [peek BACnetTagHeader + peekedTagHeader ] + [virtual uint 8 peekedTagNumber 'peekedTagHeader.actualTagNumber'] + [typeSwitch peekedTagNumber + ['0' BACnetProcessIdSelectionNull + [simple BACnetApplicationTagNull + nullValue ] + ] + [BACnetProcessIdSelectionValue + [simple BACnetApplicationTagUnsignedInteger + processIdentifier ] + ] + ] +]