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/05/30 12:04:14 UTC

[plc4x] 02/02: feat(bacnet): mapped controlled variable value

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 fc22ff5277ef26336224d7cc2f82a837f020384d
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Mon May 30 14:04:04 2022 +0200

    feat(bacnet): mapped controlled variable value
---
 ...BACnetConstructedDataControlledVariableValue.go | 55 +++++++++++++++++++---
 .../resources/protocols/bacnetip/bacnetip.mspec    | 13 ++++-
 2 files changed, 60 insertions(+), 8 deletions(-)

diff --git a/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataControlledVariableValue.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataControlledVariableValue.go
index 81859fff7b..323b8f3d8d 100644
--- a/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataControlledVariableValue.go
+++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetConstructedDataControlledVariableValue.go
@@ -21,6 +21,7 @@ package model
 
 import (
 	"github.com/apache/plc4x/plc4go/internal/spi/utils"
+	"github.com/pkg/errors"
 )
 
 // Code generated by code-generation. DO NOT EDIT.
@@ -28,6 +29,7 @@ import (
 // BACnetConstructedDataControlledVariableValue is the data-structure of this message
 type BACnetConstructedDataControlledVariableValue struct {
 	*BACnetConstructedData
+	ControlledVariableValue *BACnetApplicationTagReal
 
 	// Arguments.
 	TagNumber uint8
@@ -36,6 +38,8 @@ type BACnetConstructedDataControlledVariableValue struct {
 // IBACnetConstructedDataControlledVariableValue is the corresponding interface of BACnetConstructedDataControlledVariableValue
 type IBACnetConstructedDataControlledVariableValue interface {
 	IBACnetConstructedData
+	// GetControlledVariableValue returns ControlledVariableValue (property field)
+	GetControlledVariableValue() *BACnetApplicationTagReal
 	// GetLengthInBytes returns the length in bytes
 	GetLengthInBytes() uint16
 	// GetLengthInBits returns the length in bits
@@ -71,10 +75,25 @@ func (m *BACnetConstructedDataControlledVariableValue) GetParent() *BACnetConstr
 	return m.BACnetConstructedData
 }
 
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+/////////////////////// Accessors for property fields.
+///////////////////////
+
+func (m *BACnetConstructedDataControlledVariableValue) GetControlledVariableValue() *BACnetApplicationTagReal {
+	return m.ControlledVariableValue
+}
+
+///////////////////////
+///////////////////////
+///////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////
+
 // NewBACnetConstructedDataControlledVariableValue factory function for BACnetConstructedDataControlledVariableValue
-func NewBACnetConstructedDataControlledVariableValue(openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag, tagNumber uint8) *BACnetConstructedDataControlledVariableValue {
+func NewBACnetConstructedDataControlledVariableValue(controlledVariableValue *BACnetApplicationTagReal, openingTag *BACnetOpeningTag, closingTag *BACnetClosingTag, tagNumber uint8) *BACnetConstructedDataControlledVariableValue {
 	_result := &BACnetConstructedDataControlledVariableValue{
-		BACnetConstructedData: NewBACnetConstructedData(openingTag, closingTag, tagNumber),
+		ControlledVariableValue: controlledVariableValue,
+		BACnetConstructedData:   NewBACnetConstructedData(openingTag, closingTag, tagNumber),
 	}
 	_result.Child = _result
 	return _result
@@ -107,6 +126,9 @@ func (m *BACnetConstructedDataControlledVariableValue) GetLengthInBits() uint16
 func (m *BACnetConstructedDataControlledVariableValue) GetLengthInBitsConditional(lastItem bool) uint16 {
 	lengthInBits := uint16(m.GetParentLengthInBits())
 
+	// Simple field (controlledVariableValue)
+	lengthInBits += m.ControlledVariableValue.GetLengthInBits()
+
 	return lengthInBits
 }
 
@@ -123,9 +145,17 @@ func BACnetConstructedDataControlledVariableValueParse(readBuffer utils.ReadBuff
 	currentPos := positionAware.GetPos()
 	_ = currentPos
 
-	// Validation
-	if !(bool((1) == (2))) {
-		return nil, utils.ParseValidationError{"TODO: implement me CONTROLLED_VARIABLE_VALUE BACnetConstructedDataControlledVariableValue"}
+	// Simple Field (controlledVariableValue)
+	if pullErr := readBuffer.PullContext("controlledVariableValue"); pullErr != nil {
+		return nil, pullErr
+	}
+	_controlledVariableValue, _controlledVariableValueErr := BACnetApplicationTagParse(readBuffer)
+	if _controlledVariableValueErr != nil {
+		return nil, errors.Wrap(_controlledVariableValueErr, "Error parsing 'controlledVariableValue' field")
+	}
+	controlledVariableValue := CastBACnetApplicationTagReal(_controlledVariableValue)
+	if closeErr := readBuffer.CloseContext("controlledVariableValue"); closeErr != nil {
+		return nil, closeErr
 	}
 
 	if closeErr := readBuffer.CloseContext("BACnetConstructedDataControlledVariableValue"); closeErr != nil {
@@ -134,7 +164,8 @@ func BACnetConstructedDataControlledVariableValueParse(readBuffer utils.ReadBuff
 
 	// Create a partially initialized instance
 	_child := &BACnetConstructedDataControlledVariableValue{
-		BACnetConstructedData: &BACnetConstructedData{},
+		ControlledVariableValue: CastBACnetApplicationTagReal(controlledVariableValue),
+		BACnetConstructedData:   &BACnetConstructedData{},
 	}
 	_child.BACnetConstructedData.Child = _child
 	return _child, nil
@@ -148,6 +179,18 @@ func (m *BACnetConstructedDataControlledVariableValue) Serialize(writeBuffer uti
 			return pushErr
 		}
 
+		// Simple Field (controlledVariableValue)
+		if pushErr := writeBuffer.PushContext("controlledVariableValue"); pushErr != nil {
+			return pushErr
+		}
+		_controlledVariableValueErr := m.ControlledVariableValue.Serialize(writeBuffer)
+		if popErr := writeBuffer.PopContext("controlledVariableValue"); popErr != nil {
+			return popErr
+		}
+		if _controlledVariableValueErr != nil {
+			return errors.Wrap(_controlledVariableValueErr, "Error serializing 'controlledVariableValue' field")
+		}
+
 		if popErr := writeBuffer.PopContext("BACnetConstructedDataControlledVariableValue"); popErr != nil {
 			return popErr
 		}
diff --git a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
index 273f3fe965..2a9b3cd0ba 100644
--- a/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
+++ b/protocols/bacnetip/src/main/resources/protocols/bacnetip/bacnetip.mspec
@@ -2236,6 +2236,10 @@
         ]
         //[*, 'ALARM_VALUES'                            BACnetConstructedDataAlarmValues [validation    '1 == 2'    "TODO: implement me ALARM_VALUES BACnetConstructedDataAlarmValues"]]
         //[*, 'ALIGN_INTERVALS'                         BACnetConstructedDataAlignIntervals [validation    '1 == 2'    "TODO: implement me ALIGN_INTERVALS BACnetConstructedDataAlignIntervals"]]
+
+        /////
+        // All property implementations for every object
+
         ['ACCESS_CREDENTIAL'     , 'ALL'              BACnetConstructedDataAccessCredentialAl
             [validation '1==2' "TODO: implement me BACnetConstructedData ...ACCESS_CREDENTIAL..."]
         ]
@@ -2458,6 +2462,9 @@
         ['TREND_LOG_MULTIPLE'    , 'ALL'              BACnetConstructedDataTrendLogMultipleAll
             [validation '1==2' "TODO: implement me BACnetConstructedData ...TREND_LOG_MULTIPLE..."]
         ]
+        //
+        /////
+
         //[*, 'ALL_WRITES_SUCCESSFUL'                   BACnetConstructedDataAllWritesSuccessful [validation    '1 == 2'    "TODO: implement me ALL_WRITES_SUCCESSFUL BACnetConstructedDataAllWritesSuccessful"]]
         //[*, 'ALLOW_GROUP_DELAY_INHIBIT'               BACnetConstructedDataAllowGroupDelayInhibit [validation    '1 == 2'    "TODO: implement me ALLOW_GROUP_DELAY_INHIBIT BACnetConstructedDataAllowGroupDelayInhibit"]]
         //[*, 'APDU_LENGTH'                             BACnetConstructedDataAPDULength [validation    '1 == 2'    "TODO: implement me APDU_LENGTH BACnetConstructedDataAPDULength"]]
@@ -2521,9 +2528,11 @@
         //[*, 'CONTROL_GROUPS'                          BACnetConstructedDataControlGroups [validation    '1 == 2'    "TODO: implement me CONTROL_GROUPS BACnetConstructedDataControlGroups"]]
         //[*, 'CONTROLLED_VARIABLE_REFERENCE'           BACnetConstructedDataControlledVariableReference [validation    '1 == 2'    "TODO: implement me CONTROLLED_VARIABLE_REFERENCE BACnetConstructedDataControlledVariableReference"]]
         [*, 'CONTROLLED_VARIABLE_UNITS'               BACnetConstructedDataControlledVariableUnits
-          [simple   BACnetEngineeringUnitsTagged('0', 'TagClass.APPLICATION_TAGS') units                           ]
+            [simple   BACnetEngineeringUnitsTagged('0', 'TagClass.APPLICATION_TAGS') units                           ]
+        ]
+        [*, 'CONTROLLED_VARIABLE_VALUE'               BACnetConstructedDataControlledVariableValue
+            [simple   BACnetApplicationTagReal  controlledVariableValue         ]
         ]
-        //[*, 'CONTROLLED_VARIABLE_VALUE'               BACnetConstructedDataControlledVariableValue [validation    '1 == 2'    "TODO: implement me CONTROLLED_VARIABLE_VALUE BACnetConstructedDataControlledVariableValue"]]
         //[*, 'COUNT'                                   BACnetConstructedDataCount [validation    '1 == 2'    "TODO: implement me COUNT BACnetConstructedDataCount"]]
         //[*, 'COUNT_BEFORE_CHANGE'                     BACnetConstructedDataCountBeforeChange [validation    '1 == 2'    "TODO: implement me COUNT_BEFORE_CHANGE BACnetConstructedDataCountBeforeChange"]]
         //[*, 'COUNT_CHANGE_TIME'                       BACnetConstructedDataCountChangeTime [validation    '1 == 2'    "TODO: implement me COUNT_CHANGE_TIME BACnetConstructedDataCountChangeTime"]]