diff --git a/plc4go/protocols/cbus/readwrite/ParserHelper.go b/plc4go/protocols/cbus/readwrite/ParserHelper.go index 5b8dd0adff8..f1b65d3e3de 100644 --- a/plc4go/protocols/cbus/readwrite/ParserHelper.go +++ b/plc4go/protocols/cbus/readwrite/ParserHelper.go @@ -44,6 +44,8 @@ func (m CbusParserHelper) Parse(typeName string, arguments []string, io utils.Re return model.NetworkRouteParse(io) case "NetworkNumber": return model.NetworkNumberParse(io) + case "RequestTermination": + return model.RequestTerminationParse(io) case "StandardFormatStatusReply": return model.StandardFormatStatusReplyParse(io) case "CBusMessage": @@ -56,6 +58,8 @@ func (m CbusParserHelper) Parse(typeName string, arguments []string, io utils.Re return nil, errors.Wrap(err, "Error parsing") } return model.CBusMessageParse(io, response, srchk) + case "ResponseTermination": + return model.ResponseTerminationParse(io) case "CBusOptions": return model.CBusOptionsParse(io) case "SALData": @@ -113,6 +117,12 @@ func (m CbusParserHelper) Parse(typeName string, arguments []string, io utils.Re return model.ExtendedFormatStatusReplyParse(io) case "CBusHeader": return model.CBusHeaderParse(io) + case "Request": + srchk, err := utils.StrToBool(arguments[0]) + if err != nil { + return nil, errors.Wrap(err, "Error parsing") + } + return model.RequestParse(io, srchk) case "CBusPointToPointCommand": srchk, err := utils.StrToBool(arguments[0]) if err != nil { diff --git a/plc4go/protocols/cbus/readwrite/XmlParserHelper.go b/plc4go/protocols/cbus/readwrite/XmlParserHelper.go index 79f4224d18a..0f505af0c34 100644 --- a/plc4go/protocols/cbus/readwrite/XmlParserHelper.go +++ b/plc4go/protocols/cbus/readwrite/XmlParserHelper.go @@ -54,12 +54,16 @@ func (m CbusXmlParserHelper) Parse(typeName string, xmlString string, parserArgu return model.NetworkRouteParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "NetworkNumber": return model.NetworkNumberParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) + case "RequestTermination": + return model.RequestTerminationParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "StandardFormatStatusReply": return model.StandardFormatStatusReplyParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "CBusMessage": response := parserArguments[0] == "true" srchk := parserArguments[1] == "true" return model.CBusMessageParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), response, srchk) + case "ResponseTermination": + return model.ResponseTerminationParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "CBusOptions": return model.CBusOptionsParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "SALData": @@ -111,6 +115,9 @@ func (m CbusXmlParserHelper) Parse(typeName string, xmlString string, parserArgu return model.ExtendedFormatStatusReplyParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) case "CBusHeader": return model.CBusHeaderParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString))) + case "Request": + srchk := parserArguments[0] == "true" + return model.RequestParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), srchk) case "CBusPointToPointCommand": srchk := parserArguments[0] == "true" return model.CBusPointToPointCommandParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), srchk) diff --git a/plc4go/protocols/cbus/readwrite/model/CALReply.go b/plc4go/protocols/cbus/readwrite/model/CALReply.go index eb8853fb341..b5d617fab36 100644 --- a/plc4go/protocols/cbus/readwrite/model/CALReply.go +++ b/plc4go/protocols/cbus/readwrite/model/CALReply.go @@ -20,17 +20,12 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" ) // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const CALReply_CR byte = 0x0D -const CALReply_LF byte = 0x0A - // CALReply is the corresponding interface of CALReply type CALReply interface { utils.LengthAware @@ -39,6 +34,8 @@ type CALReply interface { GetCalType() byte // GetCalData returns CalData (property field) GetCalData() CALData + // GetTermination returns Termination (property field) + GetTermination() ResponseTermination } // CALReplyExactly can be used when we want exactly this type and not a type which fulfills CALReply. @@ -51,8 +48,9 @@ type CALReplyExactly interface { // _CALReply is the data-structure of this message type _CALReply struct { _CALReplyChildRequirements - CalType byte - CalData CALData + CalType byte + CalData CALData + Termination ResponseTermination } type _CALReplyChildRequirements interface { @@ -68,7 +66,7 @@ type CALReplyParent interface { type CALReplyChild interface { utils.Serializable - InitializeParent(parent CALReply, calType byte, calData CALData) + InitializeParent(parent CALReply, calType byte, calData CALData, termination ResponseTermination) GetParent() *CALReply GetTypeName() string @@ -88,21 +86,8 @@ func (m *_CALReply) GetCalData() CALData { return m.CalData } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_CALReply) GetCr() byte { - return CALReply_CR -} - -func (m *_CALReply) GetLf() byte { - return CALReply_LF +func (m *_CALReply) GetTermination() ResponseTermination { + return m.Termination } /////////////////////// @@ -111,8 +96,8 @@ func (m *_CALReply) GetLf() byte { /////////////////////////////////////////////////////////// // NewCALReply factory function for _CALReply -func NewCALReply(calType byte, calData CALData) *_CALReply { - return &_CALReply{CalType: calType, CalData: calData} +func NewCALReply(calType byte, calData CALData, termination ResponseTermination) *_CALReply { + return &_CALReply{CalType: calType, CalData: calData, Termination: termination} } // Deprecated: use the interface for direct cast @@ -136,11 +121,8 @@ func (m *_CALReply) GetParentLengthInBits() uint16 { // Simple field (calData) lengthInBits += m.CalData.GetLengthInBits() - // Const Field (cr) - lengthInBits += 8 - - // Const Field (lf) - lengthInBits += 8 + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() return lengthInBits } @@ -170,7 +152,7 @@ func CALReplyParse(readBuffer utils.ReadBuffer) (CALReply, error) { // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) type CALReplyChildSerializeRequirement interface { CALReply - InitializeParent(CALReply, byte, CALData) + InitializeParent(CALReply, byte, CALData, ResponseTermination) GetParent() CALReply } var _childTemp interface{} @@ -203,22 +185,17 @@ func CALReplyParse(readBuffer utils.ReadBuffer) (CALReply, error) { return nil, errors.Wrap(closeErr, "Error closing for calData") } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") } - if cr != CALReply_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CALReply_CR) + " but got " + fmt.Sprintf("%d", cr)) + _termination, _terminationErr := ResponseTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") } - - // Const Field (lf) - lf, _lfErr := readBuffer.ReadByte("lf") - if _lfErr != nil { - return nil, errors.Wrap(_lfErr, "Error parsing 'lf' field") - } - if lf != CALReply_LF { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CALReply_LF) + " but got " + fmt.Sprintf("%d", lf)) + termination := _termination.(ResponseTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") } if closeErr := readBuffer.CloseContext("CALReply"); closeErr != nil { @@ -226,7 +203,7 @@ func CALReplyParse(readBuffer utils.ReadBuffer) (CALReply, error) { } // Finish initializing - _child.InitializeParent(_child, calType, calData) + _child.InitializeParent(_child, calType, calData, termination) return _child, nil } @@ -257,16 +234,16 @@ func (pm *_CALReply) SerializeParent(writeBuffer utils.WriteBuffer, child CALRep return errors.Wrap(_calDataErr, "Error serializing 'calData' field") } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0x0D) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") } - - // Const Field (lf) - _lfErr := writeBuffer.WriteByte("lf", 0x0A) - if _lfErr != nil { - return errors.Wrap(_lfErr, "Error serializing 'lf' field") + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") } if popErr := writeBuffer.PopContext("CALReply"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/CALReplyLong.go b/plc4go/protocols/cbus/readwrite/model/CALReplyLong.go index 492c7db069a..a1d60ae0967 100644 --- a/plc4go/protocols/cbus/readwrite/model/CALReplyLong.go +++ b/plc4go/protocols/cbus/readwrite/model/CALReplyLong.go @@ -77,9 +77,10 @@ type _CALReplyLong struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CALReplyLong) InitializeParent(parent CALReply, calType byte, calData CALData) { +func (m *_CALReplyLong) InitializeParent(parent CALReply, calType byte, calData CALData, termination ResponseTermination) { m.CalType = calType m.CalData = calData + m.Termination = termination } func (m *_CALReplyLong) GetParent() CALReply { @@ -142,7 +143,7 @@ func (m *_CALReplyLong) GetIsUnitAddress() bool { /////////////////////////////////////////////////////////// // NewCALReplyLong factory function for _CALReplyLong -func NewCALReplyLong(terminatingByte uint32, unitAddress UnitAddress, bridgeAddress BridgeAddress, serialInterfaceAddress SerialInterfaceAddress, reservedByte *byte, replyNetwork ReplyNetwork, calType byte, calData CALData) *_CALReplyLong { +func NewCALReplyLong(terminatingByte uint32, unitAddress UnitAddress, bridgeAddress BridgeAddress, serialInterfaceAddress SerialInterfaceAddress, reservedByte *byte, replyNetwork ReplyNetwork, calType byte, calData CALData, termination ResponseTermination) *_CALReplyLong { _result := &_CALReplyLong{ TerminatingByte: terminatingByte, UnitAddress: unitAddress, @@ -150,7 +151,7 @@ func NewCALReplyLong(terminatingByte uint32, unitAddress UnitAddress, bridgeAddr SerialInterfaceAddress: serialInterfaceAddress, ReservedByte: reservedByte, ReplyNetwork: replyNetwork, - _CALReply: NewCALReply(calType, calData), + _CALReply: NewCALReply(calType, calData, termination), } _result._CALReply._CALReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/CALReplyReply.go b/plc4go/protocols/cbus/readwrite/model/CALReplyReply.go index 354bd141e37..77847fed546 100644 --- a/plc4go/protocols/cbus/readwrite/model/CALReplyReply.go +++ b/plc4go/protocols/cbus/readwrite/model/CALReplyReply.go @@ -58,8 +58,8 @@ type _CALReplyReply struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CALReplyReply) InitializeParent(parent Reply, magicByte byte) { - m.MagicByte = magicByte +func (m *_CALReplyReply) InitializeParent(parent Reply, peekedByte byte) { + m.PeekedByte = peekedByte } func (m *_CALReplyReply) GetParent() Reply { @@ -81,10 +81,10 @@ func (m *_CALReplyReply) GetIsA() CALReply { /////////////////////////////////////////////////////////// // NewCALReplyReply factory function for _CALReplyReply -func NewCALReplyReply(isA CALReply, magicByte byte) *_CALReplyReply { +func NewCALReplyReply(isA CALReply, peekedByte byte) *_CALReplyReply { _result := &_CALReplyReply{ IsA: isA, - _Reply: NewReply(magicByte), + _Reply: NewReply(peekedByte), } _result._Reply._ReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/CALReplyShort.go b/plc4go/protocols/cbus/readwrite/model/CALReplyShort.go index 2aea990ba09..57b8355b571 100644 --- a/plc4go/protocols/cbus/readwrite/model/CALReplyShort.go +++ b/plc4go/protocols/cbus/readwrite/model/CALReplyShort.go @@ -55,9 +55,10 @@ type _CALReplyShort struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CALReplyShort) InitializeParent(parent CALReply, calType byte, calData CALData) { +func (m *_CALReplyShort) InitializeParent(parent CALReply, calType byte, calData CALData, termination ResponseTermination) { m.CalType = calType m.CalData = calData + m.Termination = termination } func (m *_CALReplyShort) GetParent() CALReply { @@ -65,9 +66,9 @@ func (m *_CALReplyShort) GetParent() CALReply { } // NewCALReplyShort factory function for _CALReplyShort -func NewCALReplyShort(calType byte, calData CALData) *_CALReplyShort { +func NewCALReplyShort(calType byte, calData CALData, termination ResponseTermination) *_CALReplyShort { _result := &_CALReplyShort{ - _CALReply: NewCALReply(calType, calData), + _CALReply: NewCALReply(calType, calData, termination), } _result._CALReply._CALReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/CBusCommand.go b/plc4go/protocols/cbus/readwrite/model/CBusCommand.go index 0150558c48b..ef87910eab0 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusCommand.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusCommand.go @@ -20,18 +20,24 @@ package model import ( + "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" ) // Code generated by code-generation. DO NOT EDIT. +// Constant values. +const CBusCommand_INITIATOR byte = 0x5C + // CBusCommand is the corresponding interface of CBusCommand type CBusCommand interface { utils.LengthAware utils.Serializable // GetHeader returns Header (property field) GetHeader() CBusHeader + // GetIsDeviceManagement returns IsDeviceManagement (virtual field) + GetIsDeviceManagement() bool // GetDestinationAddressType returns DestinationAddressType (virtual field) GetDestinationAddressType() DestinationAddressType } @@ -90,10 +96,27 @@ func (m *_CBusCommand) GetHeader() CBusHeader { /////////////////////// Accessors for virtual fields. /////////////////////// +func (m *_CBusCommand) GetIsDeviceManagement() bool { + return bool(m.GetHeader().GetDp()) +} + func (m *_CBusCommand) GetDestinationAddressType() DestinationAddressType { return CastDestinationAddressType(m.GetHeader().GetDestinationAddressType()) } +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_CBusCommand) GetInitiator() byte { + return CBusCommand_INITIATOR +} + /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// @@ -122,11 +145,16 @@ func (m *_CBusCommand) GetTypeName() string { func (m *_CBusCommand) GetParentLengthInBits() uint16 { lengthInBits := uint16(0) + // Const Field (initiator) + lengthInBits += 8 + // Simple field (header) lengthInBits += m.Header.GetLengthInBits() // A virtual field doesn't have any in- or output. + // A virtual field doesn't have any in- or output. + return lengthInBits } @@ -143,6 +171,15 @@ func CBusCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBusCommand, err currentPos := positionAware.GetPos() _ = currentPos + // Const Field (initiator) + initiator, _initiatorErr := readBuffer.ReadByte("initiator") + if _initiatorErr != nil { + return nil, errors.Wrap(_initiatorErr, "Error parsing 'initiator' field") + } + if initiator != CBusCommand_INITIATOR { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CBusCommand_INITIATOR) + " but got " + fmt.Sprintf("%d", initiator)) + } + // Simple Field (header) if pullErr := readBuffer.PullContext("header"); pullErr != nil { return nil, errors.Wrap(pullErr, "Error pulling for header") @@ -156,6 +193,11 @@ func CBusCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBusCommand, err return nil, errors.Wrap(closeErr, "Error closing for header") } + // Virtual field + _isDeviceManagement := header.GetDp() + isDeviceManagement := bool(_isDeviceManagement) + _ = isDeviceManagement + // Virtual field _destinationAddressType := header.GetDestinationAddressType() destinationAddressType := DestinationAddressType(_destinationAddressType) @@ -171,6 +213,8 @@ func CBusCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBusCommand, err var _child CBusCommandChildSerializeRequirement var typeSwitchError error switch { + case true && isDeviceManagement == bool(true): // CBusCommandDeviceManagement + _childTemp, typeSwitchError = CBusCommandDeviceManagementParse(readBuffer, srchk) case destinationAddressType == DestinationAddressType_PointToPointToMultiPoint: // CBusCommandPointToPointToMultiPoint _childTemp, typeSwitchError = CBusCommandPointToPointToMultiPointParse(readBuffer, srchk) case destinationAddressType == DestinationAddressType_PointToMultiPoint: // CBusCommandPointToMultiPoint @@ -179,7 +223,7 @@ func CBusCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBusCommand, err _childTemp, typeSwitchError = CBusCommandPointToPointParse(readBuffer, srchk) default: // TODO: return actual type - typeSwitchError = errors.New("Unmapped type") + typeSwitchError = errors.Errorf("Unmapped type for destinationAddressType:%v isDeviceManagement:%v", destinationAddressType, isDeviceManagement) } if typeSwitchError != nil { return nil, errors.Wrap(typeSwitchError, "Error parsing sub-type for type-switch.") @@ -205,6 +249,12 @@ func (pm *_CBusCommand) SerializeParent(writeBuffer utils.WriteBuffer, child CBu return errors.Wrap(pushErr, "Error pushing for CBusCommand") } + // Const Field (initiator) + _initiatorErr := writeBuffer.WriteByte("initiator", 0x5C) + if _initiatorErr != nil { + return errors.Wrap(_initiatorErr, "Error serializing 'initiator' field") + } + // Simple Field (header) if pushErr := writeBuffer.PushContext("header"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for header") @@ -217,6 +267,10 @@ func (pm *_CBusCommand) SerializeParent(writeBuffer utils.WriteBuffer, child CBu return errors.Wrap(_headerErr, "Error serializing 'header' field") } // Virtual field + if _isDeviceManagementErr := writeBuffer.WriteVirtual("isDeviceManagement", m.GetIsDeviceManagement()); _isDeviceManagementErr != nil { + return errors.Wrap(_isDeviceManagementErr, "Error serializing 'isDeviceManagement' field") + } + // Virtual field if _destinationAddressTypeErr := writeBuffer.WriteVirtual("destinationAddressType", m.GetDestinationAddressType()); _destinationAddressTypeErr != nil { return errors.Wrap(_destinationAddressTypeErr, "Error serializing 'destinationAddressType' field") } diff --git a/plc4go/protocols/cbus/readwrite/model/CBusCommandDeviceManagement.go b/plc4go/protocols/cbus/readwrite/model/CBusCommandDeviceManagement.go new file mode 100644 index 00000000000..32f1bed48a9 --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/CBusCommandDeviceManagement.go @@ -0,0 +1,253 @@ +/* + * 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 + * + * https://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 ( + "fmt" + "github.com/apache/plc4x/plc4go/internal/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// Constant values. +const CBusCommandDeviceManagement_DELIMITER byte = 0x0 + +// CBusCommandDeviceManagement is the corresponding interface of CBusCommandDeviceManagement +type CBusCommandDeviceManagement interface { + utils.LengthAware + utils.Serializable + CBusCommand + // GetParameterNumber returns ParameterNumber (property field) + GetParameterNumber() uint8 + // GetParameterValue returns ParameterValue (property field) + GetParameterValue() byte +} + +// CBusCommandDeviceManagementExactly can be used when we want exactly this type and not a type which fulfills CBusCommandDeviceManagement. +// This is useful for switch cases. +type CBusCommandDeviceManagementExactly interface { + CBusCommandDeviceManagement + isCBusCommandDeviceManagement() bool +} + +// _CBusCommandDeviceManagement is the data-structure of this message +type _CBusCommandDeviceManagement struct { + *_CBusCommand + ParameterNumber uint8 + ParameterValue byte +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for discriminator values. +/////////////////////// + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *_CBusCommandDeviceManagement) InitializeParent(parent CBusCommand, header CBusHeader) { + m.Header = header +} + +func (m *_CBusCommandDeviceManagement) GetParent() CBusCommand { + return m._CBusCommand +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *_CBusCommandDeviceManagement) GetParameterNumber() uint8 { + return m.ParameterNumber +} + +func (m *_CBusCommandDeviceManagement) GetParameterValue() byte { + return m.ParameterValue +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_CBusCommandDeviceManagement) GetDelimiter() byte { + return CBusCommandDeviceManagement_DELIMITER +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewCBusCommandDeviceManagement factory function for _CBusCommandDeviceManagement +func NewCBusCommandDeviceManagement(parameterNumber uint8, parameterValue byte, header CBusHeader, srchk bool) *_CBusCommandDeviceManagement { + _result := &_CBusCommandDeviceManagement{ + ParameterNumber: parameterNumber, + ParameterValue: parameterValue, + _CBusCommand: NewCBusCommand(header, srchk), + } + _result._CBusCommand._CBusCommandChildRequirements = _result + return _result +} + +// Deprecated: use the interface for direct cast +func CastCBusCommandDeviceManagement(structType interface{}) CBusCommandDeviceManagement { + if casted, ok := structType.(CBusCommandDeviceManagement); ok { + return casted + } + if casted, ok := structType.(*CBusCommandDeviceManagement); ok { + return *casted + } + return nil +} + +func (m *_CBusCommandDeviceManagement) GetTypeName() string { + return "CBusCommandDeviceManagement" +} + +func (m *_CBusCommandDeviceManagement) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *_CBusCommandDeviceManagement) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Simple field (parameterNumber) + lengthInBits += 8 + + // Const Field (delimiter) + lengthInBits += 8 + + // Simple field (parameterValue) + lengthInBits += 8 + + return lengthInBits +} + +func (m *_CBusCommandDeviceManagement) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func CBusCommandDeviceManagementParse(readBuffer utils.ReadBuffer, srchk bool) (CBusCommandDeviceManagement, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("CBusCommandDeviceManagement"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for CBusCommandDeviceManagement") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (parameterNumber) + _parameterNumber, _parameterNumberErr := readBuffer.ReadUint8("parameterNumber", 8) + if _parameterNumberErr != nil { + return nil, errors.Wrap(_parameterNumberErr, "Error parsing 'parameterNumber' field") + } + parameterNumber := _parameterNumber + + // Const Field (delimiter) + delimiter, _delimiterErr := readBuffer.ReadByte("delimiter") + if _delimiterErr != nil { + return nil, errors.Wrap(_delimiterErr, "Error parsing 'delimiter' field") + } + if delimiter != CBusCommandDeviceManagement_DELIMITER { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CBusCommandDeviceManagement_DELIMITER) + " but got " + fmt.Sprintf("%d", delimiter)) + } + + // Simple Field (parameterValue) + _parameterValue, _parameterValueErr := readBuffer.ReadByte("parameterValue") + if _parameterValueErr != nil { + return nil, errors.Wrap(_parameterValueErr, "Error parsing 'parameterValue' field") + } + parameterValue := _parameterValue + + if closeErr := readBuffer.CloseContext("CBusCommandDeviceManagement"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for CBusCommandDeviceManagement") + } + + // Create a partially initialized instance + _child := &_CBusCommandDeviceManagement{ + ParameterNumber: parameterNumber, + ParameterValue: parameterValue, + _CBusCommand: &_CBusCommand{ + Srchk: srchk, + }, + } + _child._CBusCommand._CBusCommandChildRequirements = _child + return _child, nil +} + +func (m *_CBusCommandDeviceManagement) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("CBusCommandDeviceManagement"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for CBusCommandDeviceManagement") + } + + // Simple Field (parameterNumber) + parameterNumber := uint8(m.GetParameterNumber()) + _parameterNumberErr := writeBuffer.WriteUint8("parameterNumber", 8, (parameterNumber)) + if _parameterNumberErr != nil { + return errors.Wrap(_parameterNumberErr, "Error serializing 'parameterNumber' field") + } + + // Const Field (delimiter) + _delimiterErr := writeBuffer.WriteByte("delimiter", 0x0) + if _delimiterErr != nil { + return errors.Wrap(_delimiterErr, "Error serializing 'delimiter' field") + } + + // Simple Field (parameterValue) + parameterValue := byte(m.GetParameterValue()) + _parameterValueErr := writeBuffer.WriteByte("parameterValue", (parameterValue)) + if _parameterValueErr != nil { + return errors.Wrap(_parameterValueErr, "Error serializing 'parameterValue' field") + } + + if popErr := writeBuffer.PopContext("CBusCommandDeviceManagement"); popErr != nil { + return errors.Wrap(popErr, "Error popping for CBusCommandDeviceManagement") + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *_CBusCommandDeviceManagement) isCBusCommandDeviceManagement() bool { + return true +} + +func (m *_CBusCommandDeviceManagement) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go index 9a174a52bfb..ca973ffade9 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointNormal.go @@ -20,7 +20,6 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -29,9 +28,6 @@ import ( // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const CBusCommandPointToPointToMultiPointNormal_CR byte = 0xD - // CBusCommandPointToPointToMultiPointNormal is the corresponding interface of CBusCommandPointToPointToMultiPointNormal type CBusCommandPointToPointToMultiPointNormal interface { utils.LengthAware @@ -76,10 +72,11 @@ type _CBusCommandPointToPointToMultiPointNormal struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CBusCommandPointToPointToMultiPointNormal) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte) { +func (m *_CBusCommandPointToPointToMultiPointNormal) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, termination RequestTermination) { m.BridgeAddress = bridgeAddress m.NetworkRoute = networkRoute m.PeekedApplication = peekedApplication + m.Termination = termination } func (m *_CBusCommandPointToPointToMultiPointNormal) GetParent() CBusPointToPointToMultipointCommand { @@ -111,33 +108,20 @@ func (m *_CBusCommandPointToPointToMultiPointNormal) GetAlpha() Alpha { return m.Alpha } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_CBusCommandPointToPointToMultiPointNormal) GetCr() byte { - return CBusCommandPointToPointToMultiPointNormal_CR -} - /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewCBusCommandPointToPointToMultiPointNormal factory function for _CBusCommandPointToPointToMultiPointNormal -func NewCBusCommandPointToPointToMultiPointNormal(application ApplicationIdContainer, salData SALData, crc Checksum, peekAlpha byte, alpha Alpha, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, srchk bool) *_CBusCommandPointToPointToMultiPointNormal { +func NewCBusCommandPointToPointToMultiPointNormal(application ApplicationIdContainer, salData SALData, crc Checksum, peekAlpha byte, alpha Alpha, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, termination RequestTermination, srchk bool) *_CBusCommandPointToPointToMultiPointNormal { _result := &_CBusCommandPointToPointToMultiPointNormal{ Application: application, SalData: salData, Crc: crc, PeekAlpha: peekAlpha, Alpha: alpha, - _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, srchk), + _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, termination, srchk), } _result._CBusPointToPointToMultipointCommand._CBusPointToPointToMultipointCommandChildRequirements = _result return _result @@ -181,9 +165,6 @@ func (m *_CBusCommandPointToPointToMultiPointNormal) GetLengthInBitsConditional( lengthInBits += m.Alpha.GetLengthInBits() } - // Const Field (cr) - lengthInBits += 8 - return lengthInBits } @@ -279,15 +260,6 @@ func CBusCommandPointToPointToMultiPointNormalParse(readBuffer utils.ReadBuffer, } } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") - } - if cr != CBusCommandPointToPointToMultiPointNormal_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CBusCommandPointToPointToMultiPointNormal_CR) + " but got " + fmt.Sprintf("%d", cr)) - } - if closeErr := readBuffer.CloseContext("CBusCommandPointToPointToMultiPointNormal"); closeErr != nil { return nil, errors.Wrap(closeErr, "Error closing for CBusCommandPointToPointToMultiPointNormal") } @@ -371,12 +343,6 @@ func (m *_CBusCommandPointToPointToMultiPointNormal) Serialize(writeBuffer utils } } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0xD) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") - } - if popErr := writeBuffer.PopContext("CBusCommandPointToPointToMultiPointNormal"); popErr != nil { return errors.Wrap(popErr, "Error popping for CBusCommandPointToPointToMultiPointNormal") } diff --git a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go index e548f7feefa..e795e1d2e7e 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusCommandPointToPointToMultiPointStatus.go @@ -20,7 +20,6 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -29,9 +28,6 @@ import ( // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const CBusCommandPointToPointToMultiPointStatus_CR byte = 0xD - // CBusCommandPointToPointToMultiPointStatus is the corresponding interface of CBusCommandPointToPointToMultiPointStatus type CBusCommandPointToPointToMultiPointStatus interface { utils.LengthAware @@ -73,10 +69,11 @@ type _CBusCommandPointToPointToMultiPointStatus struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CBusCommandPointToPointToMultiPointStatus) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte) { +func (m *_CBusCommandPointToPointToMultiPointStatus) InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, termination RequestTermination) { m.BridgeAddress = bridgeAddress m.NetworkRoute = networkRoute m.PeekedApplication = peekedApplication + m.Termination = termination } func (m *_CBusCommandPointToPointToMultiPointStatus) GetParent() CBusPointToPointToMultipointCommand { @@ -104,32 +101,19 @@ func (m *_CBusCommandPointToPointToMultiPointStatus) GetAlpha() Alpha { return m.Alpha } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_CBusCommandPointToPointToMultiPointStatus) GetCr() byte { - return CBusCommandPointToPointToMultiPointStatus_CR -} - /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewCBusCommandPointToPointToMultiPointStatus factory function for _CBusCommandPointToPointToMultiPointStatus -func NewCBusCommandPointToPointToMultiPointStatus(statusRequest StatusRequest, crc Checksum, peekAlpha byte, alpha Alpha, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, srchk bool) *_CBusCommandPointToPointToMultiPointStatus { +func NewCBusCommandPointToPointToMultiPointStatus(statusRequest StatusRequest, crc Checksum, peekAlpha byte, alpha Alpha, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, termination RequestTermination, srchk bool) *_CBusCommandPointToPointToMultiPointStatus { _result := &_CBusCommandPointToPointToMultiPointStatus{ StatusRequest: statusRequest, Crc: crc, PeekAlpha: peekAlpha, Alpha: alpha, - _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, srchk), + _CBusPointToPointToMultipointCommand: NewCBusPointToPointToMultipointCommand(bridgeAddress, networkRoute, peekedApplication, termination, srchk), } _result._CBusPointToPointToMultipointCommand._CBusPointToPointToMultipointCommandChildRequirements = _result return _result @@ -173,9 +157,6 @@ func (m *_CBusCommandPointToPointToMultiPointStatus) GetLengthInBitsConditional( lengthInBits += m.Alpha.GetLengthInBits() } - // Const Field (cr) - lengthInBits += 8 - return lengthInBits } @@ -272,15 +253,6 @@ func CBusCommandPointToPointToMultiPointStatusParse(readBuffer utils.ReadBuffer, } } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") - } - if cr != CBusCommandPointToPointToMultiPointStatus_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CBusCommandPointToPointToMultiPointStatus_CR) + " but got " + fmt.Sprintf("%d", cr)) - } - if closeErr := readBuffer.CloseContext("CBusCommandPointToPointToMultiPointStatus"); closeErr != nil { return nil, errors.Wrap(closeErr, "Error closing for CBusCommandPointToPointToMultiPointStatus") } @@ -359,12 +331,6 @@ func (m *_CBusCommandPointToPointToMultiPointStatus) Serialize(writeBuffer utils } } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0xD) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") - } - if popErr := writeBuffer.PopContext("CBusCommandPointToPointToMultiPointStatus"); popErr != nil { return errors.Wrap(popErr, "Error popping for CBusCommandPointToPointToMultiPointStatus") } diff --git a/plc4go/protocols/cbus/readwrite/model/CBusHeader.go b/plc4go/protocols/cbus/readwrite/model/CBusHeader.go index 80b13159744..c1ccfba624a 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusHeader.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusHeader.go @@ -32,10 +32,10 @@ type CBusHeader interface { utils.Serializable // GetPriorityClass returns PriorityClass (property field) GetPriorityClass() PriorityClass - // GetDpReservedManagement returns DpReservedManagement (property field) - GetDpReservedManagement() bool - // GetRcReservedManagement returns RcReservedManagement (property field) - GetRcReservedManagement() uint8 + // GetDp returns Dp (property field) + GetDp() bool + // GetRc returns Rc (property field) + GetRc() uint8 // GetDestinationAddressType returns DestinationAddressType (property field) GetDestinationAddressType() DestinationAddressType } @@ -50,8 +50,8 @@ type CBusHeaderExactly interface { // _CBusHeader is the data-structure of this message type _CBusHeader struct { PriorityClass PriorityClass - DpReservedManagement bool - RcReservedManagement uint8 + Dp bool + Rc uint8 DestinationAddressType DestinationAddressType } @@ -64,12 +64,12 @@ func (m *_CBusHeader) GetPriorityClass() PriorityClass { return m.PriorityClass } -func (m *_CBusHeader) GetDpReservedManagement() bool { - return m.DpReservedManagement +func (m *_CBusHeader) GetDp() bool { + return m.Dp } -func (m *_CBusHeader) GetRcReservedManagement() uint8 { - return m.RcReservedManagement +func (m *_CBusHeader) GetRc() uint8 { + return m.Rc } func (m *_CBusHeader) GetDestinationAddressType() DestinationAddressType { @@ -82,8 +82,8 @@ func (m *_CBusHeader) GetDestinationAddressType() DestinationAddressType { /////////////////////////////////////////////////////////// // NewCBusHeader factory function for _CBusHeader -func NewCBusHeader(priorityClass PriorityClass, dpReservedManagement bool, rcReservedManagement uint8, destinationAddressType DestinationAddressType) *_CBusHeader { - return &_CBusHeader{PriorityClass: priorityClass, DpReservedManagement: dpReservedManagement, RcReservedManagement: rcReservedManagement, DestinationAddressType: destinationAddressType} +func NewCBusHeader(priorityClass PriorityClass, dp bool, rc uint8, destinationAddressType DestinationAddressType) *_CBusHeader { + return &_CBusHeader{PriorityClass: priorityClass, Dp: dp, Rc: rc, DestinationAddressType: destinationAddressType} } // Deprecated: use the interface for direct cast @@ -111,10 +111,10 @@ func (m *_CBusHeader) GetLengthInBitsConditional(lastItem bool) uint16 { // Simple field (priorityClass) lengthInBits += 2 - // Simple field (dpReservedManagement) + // Simple field (dp) lengthInBits += 1 - // Simple field (rcReservedManagement) + // Simple field (rc) lengthInBits += 2 // Simple field (destinationAddressType) @@ -149,19 +149,19 @@ func CBusHeaderParse(readBuffer utils.ReadBuffer) (CBusHeader, error) { return nil, errors.Wrap(closeErr, "Error closing for priorityClass") } - // Simple Field (dpReservedManagement) - _dpReservedManagement, _dpReservedManagementErr := readBuffer.ReadBit("dpReservedManagement") - if _dpReservedManagementErr != nil { - return nil, errors.Wrap(_dpReservedManagementErr, "Error parsing 'dpReservedManagement' field") + // Simple Field (dp) + _dp, _dpErr := readBuffer.ReadBit("dp") + if _dpErr != nil { + return nil, errors.Wrap(_dpErr, "Error parsing 'dp' field") } - dpReservedManagement := _dpReservedManagement + dp := _dp - // Simple Field (rcReservedManagement) - _rcReservedManagement, _rcReservedManagementErr := readBuffer.ReadUint8("rcReservedManagement", 2) - if _rcReservedManagementErr != nil { - return nil, errors.Wrap(_rcReservedManagementErr, "Error parsing 'rcReservedManagement' field") + // Simple Field (rc) + _rc, _rcErr := readBuffer.ReadUint8("rc", 2) + if _rcErr != nil { + return nil, errors.Wrap(_rcErr, "Error parsing 'rc' field") } - rcReservedManagement := _rcReservedManagement + rc := _rc // Simple Field (destinationAddressType) if pullErr := readBuffer.PullContext("destinationAddressType"); pullErr != nil { @@ -181,7 +181,7 @@ func CBusHeaderParse(readBuffer utils.ReadBuffer) (CBusHeader, error) { } // Create the instance - return NewCBusHeader(priorityClass, dpReservedManagement, rcReservedManagement, destinationAddressType), nil + return NewCBusHeader(priorityClass, dp, rc, destinationAddressType), nil } func (m *_CBusHeader) Serialize(writeBuffer utils.WriteBuffer) error { @@ -203,18 +203,18 @@ func (m *_CBusHeader) Serialize(writeBuffer utils.WriteBuffer) error { return errors.Wrap(_priorityClassErr, "Error serializing 'priorityClass' field") } - // Simple Field (dpReservedManagement) - dpReservedManagement := bool(m.GetDpReservedManagement()) - _dpReservedManagementErr := writeBuffer.WriteBit("dpReservedManagement", (dpReservedManagement)) - if _dpReservedManagementErr != nil { - return errors.Wrap(_dpReservedManagementErr, "Error serializing 'dpReservedManagement' field") + // Simple Field (dp) + dp := bool(m.GetDp()) + _dpErr := writeBuffer.WriteBit("dp", (dp)) + if _dpErr != nil { + return errors.Wrap(_dpErr, "Error serializing 'dp' field") } - // Simple Field (rcReservedManagement) - rcReservedManagement := uint8(m.GetRcReservedManagement()) - _rcReservedManagementErr := writeBuffer.WriteUint8("rcReservedManagement", 2, (rcReservedManagement)) - if _rcReservedManagementErr != nil { - return errors.Wrap(_rcReservedManagementErr, "Error serializing 'rcReservedManagement' field") + // Simple Field (rc) + rc := uint8(m.GetRc()) + _rcErr := writeBuffer.WriteUint8("rc", 2, (rc)) + if _rcErr != nil { + return errors.Wrap(_rcErr, "Error serializing 'rc' field") } // Simple Field (destinationAddressType) diff --git a/plc4go/protocols/cbus/readwrite/model/CBusMessageToClient.go b/plc4go/protocols/cbus/readwrite/model/CBusMessageToClient.go index 9943c38b00f..c1a9aee6208 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusMessageToClient.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusMessageToClient.go @@ -31,8 +31,8 @@ type CBusMessageToClient interface { utils.LengthAware utils.Serializable CBusMessage - // GetConfirmation returns Confirmation (property field) - GetConfirmation() Confirmation + // GetReply returns Reply (property field) + GetReply() Reply } // CBusMessageToClientExactly can be used when we want exactly this type and not a type which fulfills CBusMessageToClient. @@ -45,7 +45,7 @@ type CBusMessageToClientExactly interface { // _CBusMessageToClient is the data-structure of this message type _CBusMessageToClient struct { *_CBusMessage - Confirmation Confirmation + Reply Reply } /////////////////////////////////////////////////////////// @@ -73,8 +73,8 @@ func (m *_CBusMessageToClient) GetParent() CBusMessage { /////////////////////// Accessors for property fields. /////////////////////// -func (m *_CBusMessageToClient) GetConfirmation() Confirmation { - return m.Confirmation +func (m *_CBusMessageToClient) GetReply() Reply { + return m.Reply } /////////////////////// @@ -83,9 +83,9 @@ func (m *_CBusMessageToClient) GetConfirmation() Confirmation { /////////////////////////////////////////////////////////// // NewCBusMessageToClient factory function for _CBusMessageToClient -func NewCBusMessageToClient(confirmation Confirmation, srchk bool) *_CBusMessageToClient { +func NewCBusMessageToClient(reply Reply, srchk bool) *_CBusMessageToClient { _result := &_CBusMessageToClient{ - Confirmation: confirmation, + Reply: reply, _CBusMessage: NewCBusMessage(srchk), } _result._CBusMessage._CBusMessageChildRequirements = _result @@ -114,8 +114,8 @@ func (m *_CBusMessageToClient) GetLengthInBits() uint16 { func (m *_CBusMessageToClient) GetLengthInBitsConditional(lastItem bool) uint16 { lengthInBits := uint16(m.GetParentLengthInBits()) - // Simple field (confirmation) - lengthInBits += m.Confirmation.GetLengthInBits() + // Simple field (reply) + lengthInBits += m.Reply.GetLengthInBits() return lengthInBits } @@ -133,17 +133,17 @@ func CBusMessageToClientParse(readBuffer utils.ReadBuffer, response bool, srchk currentPos := positionAware.GetPos() _ = currentPos - // Simple Field (confirmation) - if pullErr := readBuffer.PullContext("confirmation"); pullErr != nil { - return nil, errors.Wrap(pullErr, "Error pulling for confirmation") + // Simple Field (reply) + if pullErr := readBuffer.PullContext("reply"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for reply") } - _confirmation, _confirmationErr := ConfirmationParse(readBuffer) - if _confirmationErr != nil { - return nil, errors.Wrap(_confirmationErr, "Error parsing 'confirmation' field") + _reply, _replyErr := ReplyParse(readBuffer) + if _replyErr != nil { + return nil, errors.Wrap(_replyErr, "Error parsing 'reply' field") } - confirmation := _confirmation.(Confirmation) - if closeErr := readBuffer.CloseContext("confirmation"); closeErr != nil { - return nil, errors.Wrap(closeErr, "Error closing for confirmation") + reply := _reply.(Reply) + if closeErr := readBuffer.CloseContext("reply"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for reply") } if closeErr := readBuffer.CloseContext("CBusMessageToClient"); closeErr != nil { @@ -152,7 +152,7 @@ func CBusMessageToClientParse(readBuffer utils.ReadBuffer, response bool, srchk // Create a partially initialized instance _child := &_CBusMessageToClient{ - Confirmation: confirmation, + Reply: reply, _CBusMessage: &_CBusMessage{ Srchk: srchk, }, @@ -169,16 +169,16 @@ func (m *_CBusMessageToClient) Serialize(writeBuffer utils.WriteBuffer) error { return errors.Wrap(pushErr, "Error pushing for CBusMessageToClient") } - // Simple Field (confirmation) - if pushErr := writeBuffer.PushContext("confirmation"); pushErr != nil { - return errors.Wrap(pushErr, "Error pushing for confirmation") + // Simple Field (reply) + if pushErr := writeBuffer.PushContext("reply"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for reply") } - _confirmationErr := writeBuffer.WriteSerializable(m.GetConfirmation()) - if popErr := writeBuffer.PopContext("confirmation"); popErr != nil { - return errors.Wrap(popErr, "Error popping for confirmation") + _replyErr := writeBuffer.WriteSerializable(m.GetReply()) + if popErr := writeBuffer.PopContext("reply"); popErr != nil { + return errors.Wrap(popErr, "Error popping for reply") } - if _confirmationErr != nil { - return errors.Wrap(_confirmationErr, "Error serializing 'confirmation' field") + if _replyErr != nil { + return errors.Wrap(_replyErr, "Error serializing 'reply' field") } if popErr := writeBuffer.PopContext("CBusMessageToClient"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/CBusMessageToServer.go b/plc4go/protocols/cbus/readwrite/model/CBusMessageToServer.go index aa2468fe18e..5ac03d7dd63 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusMessageToServer.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusMessageToServer.go @@ -31,8 +31,8 @@ type CBusMessageToServer interface { utils.LengthAware utils.Serializable CBusMessage - // GetCommand returns Command (property field) - GetCommand() CBusCommand + // GetRequest returns Request (property field) + GetRequest() Request } // CBusMessageToServerExactly can be used when we want exactly this type and not a type which fulfills CBusMessageToServer. @@ -45,7 +45,7 @@ type CBusMessageToServerExactly interface { // _CBusMessageToServer is the data-structure of this message type _CBusMessageToServer struct { *_CBusMessage - Command CBusCommand + Request Request } /////////////////////////////////////////////////////////// @@ -73,8 +73,8 @@ func (m *_CBusMessageToServer) GetParent() CBusMessage { /////////////////////// Accessors for property fields. /////////////////////// -func (m *_CBusMessageToServer) GetCommand() CBusCommand { - return m.Command +func (m *_CBusMessageToServer) GetRequest() Request { + return m.Request } /////////////////////// @@ -83,9 +83,9 @@ func (m *_CBusMessageToServer) GetCommand() CBusCommand { /////////////////////////////////////////////////////////// // NewCBusMessageToServer factory function for _CBusMessageToServer -func NewCBusMessageToServer(command CBusCommand, srchk bool) *_CBusMessageToServer { +func NewCBusMessageToServer(request Request, srchk bool) *_CBusMessageToServer { _result := &_CBusMessageToServer{ - Command: command, + Request: request, _CBusMessage: NewCBusMessage(srchk), } _result._CBusMessage._CBusMessageChildRequirements = _result @@ -114,8 +114,8 @@ func (m *_CBusMessageToServer) GetLengthInBits() uint16 { func (m *_CBusMessageToServer) GetLengthInBitsConditional(lastItem bool) uint16 { lengthInBits := uint16(m.GetParentLengthInBits()) - // Simple field (command) - lengthInBits += m.Command.GetLengthInBits() + // Simple field (request) + lengthInBits += m.Request.GetLengthInBits() return lengthInBits } @@ -133,17 +133,17 @@ func CBusMessageToServerParse(readBuffer utils.ReadBuffer, response bool, srchk currentPos := positionAware.GetPos() _ = currentPos - // Simple Field (command) - if pullErr := readBuffer.PullContext("command"); pullErr != nil { - return nil, errors.Wrap(pullErr, "Error pulling for command") + // Simple Field (request) + if pullErr := readBuffer.PullContext("request"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for request") } - _command, _commandErr := CBusCommandParse(readBuffer, bool(srchk)) - if _commandErr != nil { - return nil, errors.Wrap(_commandErr, "Error parsing 'command' field") + _request, _requestErr := RequestParse(readBuffer, bool(srchk)) + if _requestErr != nil { + return nil, errors.Wrap(_requestErr, "Error parsing 'request' field") } - command := _command.(CBusCommand) - if closeErr := readBuffer.CloseContext("command"); closeErr != nil { - return nil, errors.Wrap(closeErr, "Error closing for command") + request := _request.(Request) + if closeErr := readBuffer.CloseContext("request"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for request") } if closeErr := readBuffer.CloseContext("CBusMessageToServer"); closeErr != nil { @@ -152,7 +152,7 @@ func CBusMessageToServerParse(readBuffer utils.ReadBuffer, response bool, srchk // Create a partially initialized instance _child := &_CBusMessageToServer{ - Command: command, + Request: request, _CBusMessage: &_CBusMessage{ Srchk: srchk, }, @@ -169,16 +169,16 @@ func (m *_CBusMessageToServer) Serialize(writeBuffer utils.WriteBuffer) error { return errors.Wrap(pushErr, "Error pushing for CBusMessageToServer") } - // Simple Field (command) - if pushErr := writeBuffer.PushContext("command"); pushErr != nil { - return errors.Wrap(pushErr, "Error pushing for command") + // Simple Field (request) + if pushErr := writeBuffer.PushContext("request"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for request") } - _commandErr := writeBuffer.WriteSerializable(m.GetCommand()) - if popErr := writeBuffer.PopContext("command"); popErr != nil { - return errors.Wrap(popErr, "Error popping for command") + _requestErr := writeBuffer.WriteSerializable(m.GetRequest()) + if popErr := writeBuffer.PopContext("request"); popErr != nil { + return errors.Wrap(popErr, "Error popping for request") } - if _commandErr != nil { - return errors.Wrap(_commandErr, "Error serializing 'command' field") + if _requestErr != nil { + return errors.Wrap(_requestErr, "Error serializing 'request' field") } if popErr := writeBuffer.PopContext("CBusMessageToServer"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go index 60370dbb640..306d5a77ff0 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommand.go @@ -32,6 +32,8 @@ type CBusPointToMultiPointCommand interface { utils.Serializable // GetPeekedApplication returns PeekedApplication (property field) GetPeekedApplication() byte + // GetTermination returns Termination (property field) + GetTermination() RequestTermination } // CBusPointToMultiPointCommandExactly can be used when we want exactly this type and not a type which fulfills CBusPointToMultiPointCommand. @@ -45,6 +47,7 @@ type CBusPointToMultiPointCommandExactly interface { type _CBusPointToMultiPointCommand struct { _CBusPointToMultiPointCommandChildRequirements PeekedApplication byte + Termination RequestTermination // Arguments. Srchk bool @@ -63,7 +66,7 @@ type CBusPointToMultiPointCommandParent interface { type CBusPointToMultiPointCommandChild interface { utils.Serializable - InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte) + InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte, termination RequestTermination) GetParent() *CBusPointToMultiPointCommand GetTypeName() string @@ -79,14 +82,18 @@ func (m *_CBusPointToMultiPointCommand) GetPeekedApplication() byte { return m.PeekedApplication } +func (m *_CBusPointToMultiPointCommand) GetTermination() RequestTermination { + return m.Termination +} + /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewCBusPointToMultiPointCommand factory function for _CBusPointToMultiPointCommand -func NewCBusPointToMultiPointCommand(peekedApplication byte, srchk bool) *_CBusPointToMultiPointCommand { - return &_CBusPointToMultiPointCommand{PeekedApplication: peekedApplication, Srchk: srchk} +func NewCBusPointToMultiPointCommand(peekedApplication byte, termination RequestTermination, srchk bool) *_CBusPointToMultiPointCommand { + return &_CBusPointToMultiPointCommand{PeekedApplication: peekedApplication, Termination: termination, Srchk: srchk} } // Deprecated: use the interface for direct cast @@ -107,6 +114,9 @@ func (m *_CBusPointToMultiPointCommand) GetTypeName() string { func (m *_CBusPointToMultiPointCommand) GetParentLengthInBits() uint16 { lengthInBits := uint16(0) + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() + return lengthInBits } @@ -135,7 +145,7 @@ func CBusPointToMultiPointCommandParse(readBuffer utils.ReadBuffer, srchk bool) // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) type CBusPointToMultiPointCommandChildSerializeRequirement interface { CBusPointToMultiPointCommand - InitializeParent(CBusPointToMultiPointCommand, byte) + InitializeParent(CBusPointToMultiPointCommand, byte, RequestTermination) GetParent() CBusPointToMultiPointCommand } var _childTemp interface{} @@ -155,12 +165,25 @@ func CBusPointToMultiPointCommandParse(readBuffer utils.ReadBuffer, srchk bool) } _child = _childTemp.(CBusPointToMultiPointCommandChildSerializeRequirement) + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") + } + _termination, _terminationErr := RequestTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") + } + termination := _termination.(RequestTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") + } + if closeErr := readBuffer.CloseContext("CBusPointToMultiPointCommand"); closeErr != nil { return nil, errors.Wrap(closeErr, "Error closing for CBusPointToMultiPointCommand") } // Finish initializing - _child.InitializeParent(_child, peekedApplication) + _child.InitializeParent(_child, peekedApplication, termination) return _child, nil } @@ -179,6 +202,18 @@ func (pm *_CBusPointToMultiPointCommand) SerializeParent(writeBuffer utils.Write return errors.Wrap(_typeSwitchErr, "Error serializing sub-type field") } + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") + } + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") + } + if popErr := writeBuffer.PopContext("CBusPointToMultiPointCommand"); popErr != nil { return errors.Wrap(popErr, "Error popping for CBusPointToMultiPointCommand") } diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go index 8a1fb6feb83..dfa7c89bc28 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandNormal.go @@ -20,7 +20,6 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -29,9 +28,6 @@ import ( // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const CBusPointToMultiPointCommandNormal_CR byte = 0xD - // CBusPointToMultiPointCommandNormal is the corresponding interface of CBusPointToMultiPointCommandNormal type CBusPointToMultiPointCommandNormal interface { utils.LengthAware @@ -76,8 +72,9 @@ type _CBusPointToMultiPointCommandNormal struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CBusPointToMultiPointCommandNormal) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte) { +func (m *_CBusPointToMultiPointCommandNormal) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte, termination RequestTermination) { m.PeekedApplication = peekedApplication + m.Termination = termination } func (m *_CBusPointToMultiPointCommandNormal) GetParent() CBusPointToMultiPointCommand { @@ -109,33 +106,20 @@ func (m *_CBusPointToMultiPointCommandNormal) GetAlpha() Alpha { return m.Alpha } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_CBusPointToMultiPointCommandNormal) GetCr() byte { - return CBusPointToMultiPointCommandNormal_CR -} - /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewCBusPointToMultiPointCommandNormal factory function for _CBusPointToMultiPointCommandNormal -func NewCBusPointToMultiPointCommandNormal(application ApplicationIdContainer, salData SALData, crc Checksum, peekAlpha byte, alpha Alpha, peekedApplication byte, srchk bool) *_CBusPointToMultiPointCommandNormal { +func NewCBusPointToMultiPointCommandNormal(application ApplicationIdContainer, salData SALData, crc Checksum, peekAlpha byte, alpha Alpha, peekedApplication byte, termination RequestTermination, srchk bool) *_CBusPointToMultiPointCommandNormal { _result := &_CBusPointToMultiPointCommandNormal{ Application: application, SalData: salData, Crc: crc, PeekAlpha: peekAlpha, Alpha: alpha, - _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, srchk), + _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, termination, srchk), } _result._CBusPointToMultiPointCommand._CBusPointToMultiPointCommandChildRequirements = _result return _result @@ -182,9 +166,6 @@ func (m *_CBusPointToMultiPointCommandNormal) GetLengthInBitsConditional(lastIte lengthInBits += m.Alpha.GetLengthInBits() } - // Const Field (cr) - lengthInBits += 8 - return lengthInBits } @@ -294,15 +275,6 @@ func CBusPointToMultiPointCommandNormalParse(readBuffer utils.ReadBuffer, srchk } } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") - } - if cr != CBusPointToMultiPointCommandNormal_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CBusPointToMultiPointCommandNormal_CR) + " but got " + fmt.Sprintf("%d", cr)) - } - if closeErr := readBuffer.CloseContext("CBusPointToMultiPointCommandNormal"); closeErr != nil { return nil, errors.Wrap(closeErr, "Error closing for CBusPointToMultiPointCommandNormal") } @@ -394,12 +366,6 @@ func (m *_CBusPointToMultiPointCommandNormal) Serialize(writeBuffer utils.WriteB } } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0xD) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") - } - if popErr := writeBuffer.PopContext("CBusPointToMultiPointCommandNormal"); popErr != nil { return errors.Wrap(popErr, "Error popping for CBusPointToMultiPointCommandNormal") } diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go index 93b743c60b5..0507e30c67a 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToMultiPointCommandStatus.go @@ -20,7 +20,6 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -29,9 +28,6 @@ import ( // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const CBusPointToMultiPointCommandStatus_CR byte = 0xD - // CBusPointToMultiPointCommandStatus is the corresponding interface of CBusPointToMultiPointCommandStatus type CBusPointToMultiPointCommandStatus interface { utils.LengthAware @@ -73,8 +69,9 @@ type _CBusPointToMultiPointCommandStatus struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CBusPointToMultiPointCommandStatus) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte) { +func (m *_CBusPointToMultiPointCommandStatus) InitializeParent(parent CBusPointToMultiPointCommand, peekedApplication byte, termination RequestTermination) { m.PeekedApplication = peekedApplication + m.Termination = termination } func (m *_CBusPointToMultiPointCommandStatus) GetParent() CBusPointToMultiPointCommand { @@ -102,32 +99,19 @@ func (m *_CBusPointToMultiPointCommandStatus) GetAlpha() Alpha { return m.Alpha } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_CBusPointToMultiPointCommandStatus) GetCr() byte { - return CBusPointToMultiPointCommandStatus_CR -} - /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewCBusPointToMultiPointCommandStatus factory function for _CBusPointToMultiPointCommandStatus -func NewCBusPointToMultiPointCommandStatus(statusRequest StatusRequest, crc Checksum, peekAlpha byte, alpha Alpha, peekedApplication byte, srchk bool) *_CBusPointToMultiPointCommandStatus { +func NewCBusPointToMultiPointCommandStatus(statusRequest StatusRequest, crc Checksum, peekAlpha byte, alpha Alpha, peekedApplication byte, termination RequestTermination, srchk bool) *_CBusPointToMultiPointCommandStatus { _result := &_CBusPointToMultiPointCommandStatus{ StatusRequest: statusRequest, Crc: crc, PeekAlpha: peekAlpha, Alpha: alpha, - _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, srchk), + _CBusPointToMultiPointCommand: NewCBusPointToMultiPointCommand(peekedApplication, termination, srchk), } _result._CBusPointToMultiPointCommand._CBusPointToMultiPointCommandChildRequirements = _result return _result @@ -174,9 +158,6 @@ func (m *_CBusPointToMultiPointCommandStatus) GetLengthInBitsConditional(lastIte lengthInBits += m.Alpha.GetLengthInBits() } - // Const Field (cr) - lengthInBits += 8 - return lengthInBits } @@ -287,15 +268,6 @@ func CBusPointToMultiPointCommandStatusParse(readBuffer utils.ReadBuffer, srchk } } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") - } - if cr != CBusPointToMultiPointCommandStatus_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CBusPointToMultiPointCommandStatus_CR) + " but got " + fmt.Sprintf("%d", cr)) - } - if closeErr := readBuffer.CloseContext("CBusPointToMultiPointCommandStatus"); closeErr != nil { return nil, errors.Wrap(closeErr, "Error closing for CBusPointToMultiPointCommandStatus") } @@ -382,12 +354,6 @@ func (m *_CBusPointToMultiPointCommandStatus) Serialize(writeBuffer utils.WriteB } } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0xD) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") - } - if popErr := writeBuffer.PopContext("CBusPointToMultiPointCommandStatus"); popErr != nil { return errors.Wrap(popErr, "Error popping for CBusPointToMultiPointCommandStatus") } diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go index 196f85cf237..e89147300b7 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommand.go @@ -20,7 +20,6 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -29,9 +28,6 @@ import ( // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const CBusPointToPointCommand_CR byte = 0xD - // CBusPointToPointCommand is the corresponding interface of CBusPointToPointCommand type CBusPointToPointCommand interface { utils.LengthAware @@ -46,6 +42,8 @@ type CBusPointToPointCommand interface { GetPeekAlpha() byte // GetAlpha returns Alpha (property field) GetAlpha() Alpha + // GetTermination returns Termination (property field) + GetTermination() RequestTermination // GetIsDirect returns IsDirect (virtual field) GetIsDirect() bool } @@ -65,6 +63,7 @@ type _CBusPointToPointCommand struct { Crc Checksum PeekAlpha byte Alpha Alpha + Termination RequestTermination // Arguments. Srchk bool @@ -83,7 +82,7 @@ type CBusPointToPointCommandParent interface { type CBusPointToPointCommandChild interface { utils.Serializable - InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha) + InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, termination RequestTermination) GetParent() *CBusPointToPointCommand GetTypeName() string @@ -115,6 +114,10 @@ func (m *_CBusPointToPointCommand) GetAlpha() Alpha { return m.Alpha } +func (m *_CBusPointToPointCommand) GetTermination() RequestTermination { + return m.Termination +} + /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// @@ -132,27 +135,14 @@ func (m *_CBusPointToPointCommand) GetIsDirect() bool { return bool(bool(((m.GetBridgeAddressCountPeek()) & (0x00FF)) == (0x0000))) } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_CBusPointToPointCommand) GetCr() byte { - return CBusPointToPointCommand_CR -} - /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewCBusPointToPointCommand factory function for _CBusPointToPointCommand -func NewCBusPointToPointCommand(bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, srchk bool) *_CBusPointToPointCommand { - return &_CBusPointToPointCommand{BridgeAddressCountPeek: bridgeAddressCountPeek, CalData: calData, Crc: crc, PeekAlpha: peekAlpha, Alpha: alpha, Srchk: srchk} +func NewCBusPointToPointCommand(bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, termination RequestTermination, srchk bool) *_CBusPointToPointCommand { + return &_CBusPointToPointCommand{BridgeAddressCountPeek: bridgeAddressCountPeek, CalData: calData, Crc: crc, PeekAlpha: peekAlpha, Alpha: alpha, Termination: termination, Srchk: srchk} } // Deprecated: use the interface for direct cast @@ -188,8 +178,8 @@ func (m *_CBusPointToPointCommand) GetParentLengthInBits() uint16 { lengthInBits += m.Alpha.GetLengthInBits() } - // Const Field (cr) - lengthInBits += 8 + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() return lengthInBits } @@ -224,7 +214,7 @@ func CBusPointToPointCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBus // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) type CBusPointToPointCommandChildSerializeRequirement interface { CBusPointToPointCommand - InitializeParent(CBusPointToPointCommand, uint16, CALData, Checksum, byte, Alpha) + InitializeParent(CBusPointToPointCommand, uint16, CALData, Checksum, byte, Alpha, RequestTermination) GetParent() CBusPointToPointCommand } var _childTemp interface{} @@ -310,13 +300,17 @@ func CBusPointToPointCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBus } } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") + } + _termination, _terminationErr := RequestTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") } - if cr != CBusPointToPointCommand_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", CBusPointToPointCommand_CR) + " but got " + fmt.Sprintf("%d", cr)) + termination := _termination.(RequestTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") } if closeErr := readBuffer.CloseContext("CBusPointToPointCommand"); closeErr != nil { @@ -324,7 +318,7 @@ func CBusPointToPointCommandParse(readBuffer utils.ReadBuffer, srchk bool) (CBus } // Finish initializing - _child.InitializeParent(_child, bridgeAddressCountPeek, calData, crc, peekAlpha, alpha) + _child.InitializeParent(_child, bridgeAddressCountPeek, calData, crc, peekAlpha, alpha, termination) return _child, nil } @@ -391,10 +385,16 @@ func (pm *_CBusPointToPointCommand) SerializeParent(writeBuffer utils.WriteBuffe } } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0xD) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") + } + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") } if popErr := writeBuffer.PopContext("CBusPointToPointCommand"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go index 42679214360..320f7d781d8 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandDirect.go @@ -59,12 +59,13 @@ type _CBusPointToPointCommandDirect struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CBusPointToPointCommandDirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha) { +func (m *_CBusPointToPointCommandDirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, termination RequestTermination) { m.BridgeAddressCountPeek = bridgeAddressCountPeek m.CalData = calData m.Crc = crc m.PeekAlpha = peekAlpha m.Alpha = alpha + m.Termination = termination } func (m *_CBusPointToPointCommandDirect) GetParent() CBusPointToPointCommand { @@ -86,10 +87,10 @@ func (m *_CBusPointToPointCommandDirect) GetUnitAddress() UnitAddress { /////////////////////////////////////////////////////////// // NewCBusPointToPointCommandDirect factory function for _CBusPointToPointCommandDirect -func NewCBusPointToPointCommandDirect(unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, srchk bool) *_CBusPointToPointCommandDirect { +func NewCBusPointToPointCommandDirect(unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, termination RequestTermination, srchk bool) *_CBusPointToPointCommandDirect { _result := &_CBusPointToPointCommandDirect{ UnitAddress: unitAddress, - _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, peekAlpha, alpha, srchk), + _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, peekAlpha, alpha, termination, srchk), } _result._CBusPointToPointCommand._CBusPointToPointCommandChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go index 5b06023a03c..41ca11716aa 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointCommandIndirect.go @@ -64,12 +64,13 @@ type _CBusPointToPointCommandIndirect struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_CBusPointToPointCommandIndirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha) { +func (m *_CBusPointToPointCommandIndirect) InitializeParent(parent CBusPointToPointCommand, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, termination RequestTermination) { m.BridgeAddressCountPeek = bridgeAddressCountPeek m.CalData = calData m.Crc = crc m.PeekAlpha = peekAlpha m.Alpha = alpha + m.Termination = termination } func (m *_CBusPointToPointCommandIndirect) GetParent() CBusPointToPointCommand { @@ -99,12 +100,12 @@ func (m *_CBusPointToPointCommandIndirect) GetUnitAddress() UnitAddress { /////////////////////////////////////////////////////////// // NewCBusPointToPointCommandIndirect factory function for _CBusPointToPointCommandIndirect -func NewCBusPointToPointCommandIndirect(bridgeAddress BridgeAddress, networkRoute NetworkRoute, unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, srchk bool) *_CBusPointToPointCommandIndirect { +func NewCBusPointToPointCommandIndirect(bridgeAddress BridgeAddress, networkRoute NetworkRoute, unitAddress UnitAddress, bridgeAddressCountPeek uint16, calData CALData, crc Checksum, peekAlpha byte, alpha Alpha, termination RequestTermination, srchk bool) *_CBusPointToPointCommandIndirect { _result := &_CBusPointToPointCommandIndirect{ BridgeAddress: bridgeAddress, NetworkRoute: networkRoute, UnitAddress: unitAddress, - _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, peekAlpha, alpha, srchk), + _CBusPointToPointCommand: NewCBusPointToPointCommand(bridgeAddressCountPeek, calData, crc, peekAlpha, alpha, termination, srchk), } _result._CBusPointToPointCommand._CBusPointToPointCommandChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go index 5f8a37c859c..17f3884a7d0 100644 --- a/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go +++ b/plc4go/protocols/cbus/readwrite/model/CBusPointToPointToMultipointCommand.go @@ -36,6 +36,8 @@ type CBusPointToPointToMultipointCommand interface { GetNetworkRoute() NetworkRoute // GetPeekedApplication returns PeekedApplication (property field) GetPeekedApplication() byte + // GetTermination returns Termination (property field) + GetTermination() RequestTermination } // CBusPointToPointToMultipointCommandExactly can be used when we want exactly this type and not a type which fulfills CBusPointToPointToMultipointCommand. @@ -51,6 +53,7 @@ type _CBusPointToPointToMultipointCommand struct { BridgeAddress BridgeAddress NetworkRoute NetworkRoute PeekedApplication byte + Termination RequestTermination // Arguments. Srchk bool @@ -69,7 +72,7 @@ type CBusPointToPointToMultipointCommandParent interface { type CBusPointToPointToMultipointCommandChild interface { utils.Serializable - InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte) + InitializeParent(parent CBusPointToPointToMultipointCommand, bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, termination RequestTermination) GetParent() *CBusPointToPointToMultipointCommand GetTypeName() string @@ -93,14 +96,18 @@ func (m *_CBusPointToPointToMultipointCommand) GetPeekedApplication() byte { return m.PeekedApplication } +func (m *_CBusPointToPointToMultipointCommand) GetTermination() RequestTermination { + return m.Termination +} + /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewCBusPointToPointToMultipointCommand factory function for _CBusPointToPointToMultipointCommand -func NewCBusPointToPointToMultipointCommand(bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, srchk bool) *_CBusPointToPointToMultipointCommand { - return &_CBusPointToPointToMultipointCommand{BridgeAddress: bridgeAddress, NetworkRoute: networkRoute, PeekedApplication: peekedApplication, Srchk: srchk} +func NewCBusPointToPointToMultipointCommand(bridgeAddress BridgeAddress, networkRoute NetworkRoute, peekedApplication byte, termination RequestTermination, srchk bool) *_CBusPointToPointToMultipointCommand { + return &_CBusPointToPointToMultipointCommand{BridgeAddress: bridgeAddress, NetworkRoute: networkRoute, PeekedApplication: peekedApplication, Termination: termination, Srchk: srchk} } // Deprecated: use the interface for direct cast @@ -127,6 +134,9 @@ func (m *_CBusPointToPointToMultipointCommand) GetParentLengthInBits() uint16 { // Simple field (networkRoute) lengthInBits += m.NetworkRoute.GetLengthInBits() + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() + return lengthInBits } @@ -181,7 +191,7 @@ func CBusPointToPointToMultipointCommandParse(readBuffer utils.ReadBuffer, srchk // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) type CBusPointToPointToMultipointCommandChildSerializeRequirement interface { CBusPointToPointToMultipointCommand - InitializeParent(CBusPointToPointToMultipointCommand, BridgeAddress, NetworkRoute, byte) + InitializeParent(CBusPointToPointToMultipointCommand, BridgeAddress, NetworkRoute, byte, RequestTermination) GetParent() CBusPointToPointToMultipointCommand } var _childTemp interface{} @@ -201,12 +211,25 @@ func CBusPointToPointToMultipointCommandParse(readBuffer utils.ReadBuffer, srchk } _child = _childTemp.(CBusPointToPointToMultipointCommandChildSerializeRequirement) + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") + } + _termination, _terminationErr := RequestTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") + } + termination := _termination.(RequestTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") + } + if closeErr := readBuffer.CloseContext("CBusPointToPointToMultipointCommand"); closeErr != nil { return nil, errors.Wrap(closeErr, "Error closing for CBusPointToPointToMultipointCommand") } // Finish initializing - _child.InitializeParent(_child, bridgeAddress, networkRoute, peekedApplication) + _child.InitializeParent(_child, bridgeAddress, networkRoute, peekedApplication, termination) return _child, nil } @@ -249,6 +272,18 @@ func (pm *_CBusPointToPointToMultipointCommand) SerializeParent(writeBuffer util return errors.Wrap(_typeSwitchErr, "Error serializing sub-type field") } + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") + } + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") + } + if popErr := writeBuffer.PopContext("CBusPointToPointToMultipointCommand"); popErr != nil { return errors.Wrap(popErr, "Error popping for CBusPointToPointToMultipointCommand") } diff --git a/plc4go/protocols/cbus/readwrite/model/ConfirmationReply.go b/plc4go/protocols/cbus/readwrite/model/ConfirmationReply.go index c0c20e26e0f..258d24dc4b5 100644 --- a/plc4go/protocols/cbus/readwrite/model/ConfirmationReply.go +++ b/plc4go/protocols/cbus/readwrite/model/ConfirmationReply.go @@ -58,8 +58,8 @@ type _ConfirmationReply struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_ConfirmationReply) InitializeParent(parent Reply, magicByte byte) { - m.MagicByte = magicByte +func (m *_ConfirmationReply) InitializeParent(parent Reply, peekedByte byte) { + m.PeekedByte = peekedByte } func (m *_ConfirmationReply) GetParent() Reply { @@ -81,10 +81,10 @@ func (m *_ConfirmationReply) GetIsA() Confirmation { /////////////////////////////////////////////////////////// // NewConfirmationReply factory function for _ConfirmationReply -func NewConfirmationReply(isA Confirmation, magicByte byte) *_ConfirmationReply { +func NewConfirmationReply(isA Confirmation, peekedByte byte) *_ConfirmationReply { _result := &_ConfirmationReply{ IsA: isA, - _Reply: NewReply(magicByte), + _Reply: NewReply(peekedByte), } _result._Reply._ReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/ExclamationMarkReply.go b/plc4go/protocols/cbus/readwrite/model/ExclamationMarkReply.go index c4af8855e7b..a1233884299 100644 --- a/plc4go/protocols/cbus/readwrite/model/ExclamationMarkReply.go +++ b/plc4go/protocols/cbus/readwrite/model/ExclamationMarkReply.go @@ -58,8 +58,8 @@ type _ExclamationMarkReply struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_ExclamationMarkReply) InitializeParent(parent Reply, magicByte byte) { - m.MagicByte = magicByte +func (m *_ExclamationMarkReply) InitializeParent(parent Reply, peekedByte byte) { + m.PeekedByte = peekedByte } func (m *_ExclamationMarkReply) GetParent() Reply { @@ -81,10 +81,10 @@ func (m *_ExclamationMarkReply) GetIsA() ExclamationMark { /////////////////////////////////////////////////////////// // NewExclamationMarkReply factory function for _ExclamationMarkReply -func NewExclamationMarkReply(isA ExclamationMark, magicByte byte) *_ExclamationMarkReply { +func NewExclamationMarkReply(isA ExclamationMark, peekedByte byte) *_ExclamationMarkReply { _result := &_ExclamationMarkReply{ IsA: isA, - _Reply: NewReply(magicByte), + _Reply: NewReply(peekedByte), } _result._Reply._ReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/ExtendedFormatStatusReply.go b/plc4go/protocols/cbus/readwrite/model/ExtendedFormatStatusReply.go index fd790c3e64a..9b84e15dd20 100644 --- a/plc4go/protocols/cbus/readwrite/model/ExtendedFormatStatusReply.go +++ b/plc4go/protocols/cbus/readwrite/model/ExtendedFormatStatusReply.go @@ -20,17 +20,12 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" ) // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const ExtendedFormatStatusReply_CR byte = 0x0D -const ExtendedFormatStatusReply_LF byte = 0x0A - // ExtendedFormatStatusReply is the corresponding interface of ExtendedFormatStatusReply type ExtendedFormatStatusReply interface { utils.LengthAware @@ -47,6 +42,8 @@ type ExtendedFormatStatusReply interface { GetStatusBytes() []StatusByte // GetCrc returns Crc (property field) GetCrc() Checksum + // GetTermination returns Termination (property field) + GetTermination() ResponseTermination } // ExtendedFormatStatusReplyExactly can be used when we want exactly this type and not a type which fulfills ExtendedFormatStatusReply. @@ -64,6 +61,7 @@ type _ExtendedFormatStatusReply struct { BlockStart uint8 StatusBytes []StatusByte Crc Checksum + Termination ResponseTermination } /////////////////////////////////////////////////////////// @@ -95,21 +93,8 @@ func (m *_ExtendedFormatStatusReply) GetCrc() Checksum { return m.Crc } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_ExtendedFormatStatusReply) GetCr() byte { - return ExtendedFormatStatusReply_CR -} - -func (m *_ExtendedFormatStatusReply) GetLf() byte { - return ExtendedFormatStatusReply_LF +func (m *_ExtendedFormatStatusReply) GetTermination() ResponseTermination { + return m.Termination } /////////////////////// @@ -118,8 +103,8 @@ func (m *_ExtendedFormatStatusReply) GetLf() byte { /////////////////////////////////////////////////////////// // NewExtendedFormatStatusReply factory function for _ExtendedFormatStatusReply -func NewExtendedFormatStatusReply(statusHeader ExtendedStatusHeader, coding StatusCoding, application ApplicationIdContainer, blockStart uint8, statusBytes []StatusByte, crc Checksum) *_ExtendedFormatStatusReply { - return &_ExtendedFormatStatusReply{StatusHeader: statusHeader, Coding: coding, Application: application, BlockStart: blockStart, StatusBytes: statusBytes, Crc: crc} +func NewExtendedFormatStatusReply(statusHeader ExtendedStatusHeader, coding StatusCoding, application ApplicationIdContainer, blockStart uint8, statusBytes []StatusByte, crc Checksum, termination ResponseTermination) *_ExtendedFormatStatusReply { + return &_ExtendedFormatStatusReply{StatusHeader: statusHeader, Coding: coding, Application: application, BlockStart: blockStart, StatusBytes: statusBytes, Crc: crc, Termination: termination} } // Deprecated: use the interface for direct cast @@ -167,11 +152,8 @@ func (m *_ExtendedFormatStatusReply) GetLengthInBitsConditional(lastItem bool) u // Simple field (crc) lengthInBits += m.Crc.GetLengthInBits() - // Const Field (cr) - lengthInBits += 8 - - // Const Field (lf) - lengthInBits += 8 + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() return lengthInBits } @@ -271,22 +253,17 @@ func ExtendedFormatStatusReplyParse(readBuffer utils.ReadBuffer) (ExtendedFormat return nil, errors.Wrap(closeErr, "Error closing for crc") } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") } - if cr != ExtendedFormatStatusReply_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ExtendedFormatStatusReply_CR) + " but got " + fmt.Sprintf("%d", cr)) + _termination, _terminationErr := ResponseTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") } - - // Const Field (lf) - lf, _lfErr := readBuffer.ReadByte("lf") - if _lfErr != nil { - return nil, errors.Wrap(_lfErr, "Error parsing 'lf' field") - } - if lf != ExtendedFormatStatusReply_LF { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ExtendedFormatStatusReply_LF) + " but got " + fmt.Sprintf("%d", lf)) + termination := _termination.(ResponseTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") } if closeErr := readBuffer.CloseContext("ExtendedFormatStatusReply"); closeErr != nil { @@ -294,7 +271,7 @@ func ExtendedFormatStatusReplyParse(readBuffer utils.ReadBuffer) (ExtendedFormat } // Create the instance - return NewExtendedFormatStatusReply(statusHeader, coding, application, blockStart, statusBytes, crc), nil + return NewExtendedFormatStatusReply(statusHeader, coding, application, blockStart, statusBytes, crc, termination), nil } func (m *_ExtendedFormatStatusReply) Serialize(writeBuffer utils.WriteBuffer) error { @@ -373,16 +350,16 @@ func (m *_ExtendedFormatStatusReply) Serialize(writeBuffer utils.WriteBuffer) er return errors.Wrap(_crcErr, "Error serializing 'crc' field") } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0x0D) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") } - - // Const Field (lf) - _lfErr := writeBuffer.WriteByte("lf", 0x0A) - if _lfErr != nil { - return errors.Wrap(_lfErr, "Error serializing 'lf' field") + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") } if popErr := writeBuffer.PopContext("ExtendedFormatStatusReply"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/MonitoredSAL.go b/plc4go/protocols/cbus/readwrite/model/MonitoredSAL.go index 7631d11b24f..26ea23668ce 100644 --- a/plc4go/protocols/cbus/readwrite/model/MonitoredSAL.go +++ b/plc4go/protocols/cbus/readwrite/model/MonitoredSAL.go @@ -20,7 +20,6 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" "github.com/rs/zerolog/log" @@ -29,10 +28,6 @@ import ( // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const MonitoredSAL_CR byte = 0x0D -const MonitoredSAL_LF byte = 0x0A - // MonitoredSAL is the corresponding interface of MonitoredSAL type MonitoredSAL interface { utils.LengthAware @@ -41,6 +36,8 @@ type MonitoredSAL interface { GetSalType() byte // GetSalData returns SalData (property field) GetSalData() SALData + // GetTermination returns Termination (property field) + GetTermination() ResponseTermination } // MonitoredSALExactly can be used when we want exactly this type and not a type which fulfills MonitoredSAL. @@ -53,8 +50,9 @@ type MonitoredSALExactly interface { // _MonitoredSAL is the data-structure of this message type _MonitoredSAL struct { _MonitoredSALChildRequirements - SalType byte - SalData SALData + SalType byte + SalData SALData + Termination ResponseTermination } type _MonitoredSALChildRequirements interface { @@ -70,7 +68,7 @@ type MonitoredSALParent interface { type MonitoredSALChild interface { utils.Serializable - InitializeParent(parent MonitoredSAL, salType byte, salData SALData) + InitializeParent(parent MonitoredSAL, salType byte, salData SALData, termination ResponseTermination) GetParent() *MonitoredSAL GetTypeName() string @@ -90,21 +88,8 @@ func (m *_MonitoredSAL) GetSalData() SALData { return m.SalData } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_MonitoredSAL) GetCr() byte { - return MonitoredSAL_CR -} - -func (m *_MonitoredSAL) GetLf() byte { - return MonitoredSAL_LF +func (m *_MonitoredSAL) GetTermination() ResponseTermination { + return m.Termination } /////////////////////// @@ -113,8 +98,8 @@ func (m *_MonitoredSAL) GetLf() byte { /////////////////////////////////////////////////////////// // NewMonitoredSAL factory function for _MonitoredSAL -func NewMonitoredSAL(salType byte, salData SALData) *_MonitoredSAL { - return &_MonitoredSAL{SalType: salType, SalData: salData} +func NewMonitoredSAL(salType byte, salData SALData, termination ResponseTermination) *_MonitoredSAL { + return &_MonitoredSAL{SalType: salType, SalData: salData, Termination: termination} } // Deprecated: use the interface for direct cast @@ -140,11 +125,8 @@ func (m *_MonitoredSAL) GetParentLengthInBits() uint16 { lengthInBits += m.SalData.GetLengthInBits() } - // Const Field (cr) - lengthInBits += 8 - - // Const Field (lf) - lengthInBits += 8 + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() return lengthInBits } @@ -174,7 +156,7 @@ func MonitoredSALParse(readBuffer utils.ReadBuffer) (MonitoredSAL, error) { // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) type MonitoredSALChildSerializeRequirement interface { MonitoredSAL - InitializeParent(MonitoredSAL, byte, SALData) + InitializeParent(MonitoredSAL, byte, SALData, ResponseTermination) GetParent() MonitoredSAL } var _childTemp interface{} @@ -216,22 +198,17 @@ func MonitoredSALParse(readBuffer utils.ReadBuffer) (MonitoredSAL, error) { } } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") } - if cr != MonitoredSAL_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", MonitoredSAL_CR) + " but got " + fmt.Sprintf("%d", cr)) + _termination, _terminationErr := ResponseTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") } - - // Const Field (lf) - lf, _lfErr := readBuffer.ReadByte("lf") - if _lfErr != nil { - return nil, errors.Wrap(_lfErr, "Error parsing 'lf' field") - } - if lf != MonitoredSAL_LF { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", MonitoredSAL_LF) + " but got " + fmt.Sprintf("%d", lf)) + termination := _termination.(ResponseTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") } if closeErr := readBuffer.CloseContext("MonitoredSAL"); closeErr != nil { @@ -239,7 +216,7 @@ func MonitoredSALParse(readBuffer utils.ReadBuffer) (MonitoredSAL, error) { } // Finish initializing - _child.InitializeParent(_child, salType, salData) + _child.InitializeParent(_child, salType, salData, termination) return _child, nil } @@ -274,16 +251,16 @@ func (pm *_MonitoredSAL) SerializeParent(writeBuffer utils.WriteBuffer, child Mo } } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0x0D) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") } - - // Const Field (lf) - _lfErr := writeBuffer.WriteByte("lf", 0x0A) - if _lfErr != nil { - return errors.Wrap(_lfErr, "Error serializing 'lf' field") + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") } if popErr := writeBuffer.PopContext("MonitoredSAL"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/MonitoredSALLongFormSmartMode.go b/plc4go/protocols/cbus/readwrite/model/MonitoredSALLongFormSmartMode.go index ea6cde77f69..67c28812507 100644 --- a/plc4go/protocols/cbus/readwrite/model/MonitoredSALLongFormSmartMode.go +++ b/plc4go/protocols/cbus/readwrite/model/MonitoredSALLongFormSmartMode.go @@ -77,9 +77,10 @@ type _MonitoredSALLongFormSmartMode struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_MonitoredSALLongFormSmartMode) InitializeParent(parent MonitoredSAL, salType byte, salData SALData) { +func (m *_MonitoredSALLongFormSmartMode) InitializeParent(parent MonitoredSAL, salType byte, salData SALData, termination ResponseTermination) { m.SalType = salType m.SalData = salData + m.Termination = termination } func (m *_MonitoredSALLongFormSmartMode) GetParent() MonitoredSAL { @@ -142,7 +143,7 @@ func (m *_MonitoredSALLongFormSmartMode) GetIsUnitAddress() bool { /////////////////////////////////////////////////////////// // NewMonitoredSALLongFormSmartMode factory function for _MonitoredSALLongFormSmartMode -func NewMonitoredSALLongFormSmartMode(terminatingByte uint32, unitAddress UnitAddress, bridgeAddress BridgeAddress, serialInterfaceAddress SerialInterfaceAddress, reservedByte *byte, replyNetwork ReplyNetwork, salType byte, salData SALData) *_MonitoredSALLongFormSmartMode { +func NewMonitoredSALLongFormSmartMode(terminatingByte uint32, unitAddress UnitAddress, bridgeAddress BridgeAddress, serialInterfaceAddress SerialInterfaceAddress, reservedByte *byte, replyNetwork ReplyNetwork, salType byte, salData SALData, termination ResponseTermination) *_MonitoredSALLongFormSmartMode { _result := &_MonitoredSALLongFormSmartMode{ TerminatingByte: terminatingByte, UnitAddress: unitAddress, @@ -150,7 +151,7 @@ func NewMonitoredSALLongFormSmartMode(terminatingByte uint32, unitAddress UnitAd SerialInterfaceAddress: serialInterfaceAddress, ReservedByte: reservedByte, ReplyNetwork: replyNetwork, - _MonitoredSAL: NewMonitoredSAL(salType, salData), + _MonitoredSAL: NewMonitoredSAL(salType, salData, termination), } _result._MonitoredSAL._MonitoredSALChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/MonitoredSALReply.go b/plc4go/protocols/cbus/readwrite/model/MonitoredSALReply.go index fabf10092c7..3809583937f 100644 --- a/plc4go/protocols/cbus/readwrite/model/MonitoredSALReply.go +++ b/plc4go/protocols/cbus/readwrite/model/MonitoredSALReply.go @@ -58,8 +58,8 @@ type _MonitoredSALReply struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_MonitoredSALReply) InitializeParent(parent Reply, magicByte byte) { - m.MagicByte = magicByte +func (m *_MonitoredSALReply) InitializeParent(parent Reply, peekedByte byte) { + m.PeekedByte = peekedByte } func (m *_MonitoredSALReply) GetParent() Reply { @@ -81,10 +81,10 @@ func (m *_MonitoredSALReply) GetIsA() MonitoredSAL { /////////////////////////////////////////////////////////// // NewMonitoredSALReply factory function for _MonitoredSALReply -func NewMonitoredSALReply(isA MonitoredSAL, magicByte byte) *_MonitoredSALReply { +func NewMonitoredSALReply(isA MonitoredSAL, peekedByte byte) *_MonitoredSALReply { _result := &_MonitoredSALReply{ IsA: isA, - _Reply: NewReply(magicByte), + _Reply: NewReply(peekedByte), } _result._Reply._ReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/MonitoredSALShortFormBasicMode.go b/plc4go/protocols/cbus/readwrite/model/MonitoredSALShortFormBasicMode.go index b4229a19631..5d1e0da5a70 100644 --- a/plc4go/protocols/cbus/readwrite/model/MonitoredSALShortFormBasicMode.go +++ b/plc4go/protocols/cbus/readwrite/model/MonitoredSALShortFormBasicMode.go @@ -72,9 +72,10 @@ type _MonitoredSALShortFormBasicMode struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_MonitoredSALShortFormBasicMode) InitializeParent(parent MonitoredSAL, salType byte, salData SALData) { +func (m *_MonitoredSALShortFormBasicMode) InitializeParent(parent MonitoredSAL, salType byte, salData SALData, termination ResponseTermination) { m.SalType = salType m.SalData = salData + m.Termination = termination } func (m *_MonitoredSALShortFormBasicMode) GetParent() MonitoredSAL { @@ -112,14 +113,14 @@ func (m *_MonitoredSALShortFormBasicMode) GetApplication() ApplicationIdContaine /////////////////////////////////////////////////////////// // NewMonitoredSALShortFormBasicMode factory function for _MonitoredSALShortFormBasicMode -func NewMonitoredSALShortFormBasicMode(counts byte, bridgeCount BridgeCount, networkNumber NetworkNumber, noCounts *byte, application ApplicationIdContainer, salType byte, salData SALData) *_MonitoredSALShortFormBasicMode { +func NewMonitoredSALShortFormBasicMode(counts byte, bridgeCount BridgeCount, networkNumber NetworkNumber, noCounts *byte, application ApplicationIdContainer, salType byte, salData SALData, termination ResponseTermination) *_MonitoredSALShortFormBasicMode { _result := &_MonitoredSALShortFormBasicMode{ Counts: counts, BridgeCount: bridgeCount, NetworkNumber: networkNumber, NoCounts: noCounts, Application: application, - _MonitoredSAL: NewMonitoredSAL(salType, salData), + _MonitoredSAL: NewMonitoredSAL(salType, salData, termination), } _result._MonitoredSAL._MonitoredSALChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterChange.go b/plc4go/protocols/cbus/readwrite/model/ParameterChange.go index 2c8a4b90011..b77e35c28d2 100644 --- a/plc4go/protocols/cbus/readwrite/model/ParameterChange.go +++ b/plc4go/protocols/cbus/readwrite/model/ParameterChange.go @@ -30,13 +30,13 @@ import ( // Constant values. const ParameterChange_SPECIALCHAR1 byte = 0x3D const ParameterChange_SPECIALCHAR2 byte = 0x3D -const ParameterChange_CR byte = 0x0D -const ParameterChange_LF byte = 0x0A // ParameterChange is the corresponding interface of ParameterChange type ParameterChange interface { utils.LengthAware utils.Serializable + // GetTermination returns Termination (property field) + GetTermination() ResponseTermination } // ParameterChangeExactly can be used when we want exactly this type and not a type which fulfills ParameterChange. @@ -48,8 +48,22 @@ type ParameterChangeExactly interface { // _ParameterChange is the data-structure of this message type _ParameterChange struct { + Termination ResponseTermination } +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *_ParameterChange) GetTermination() ResponseTermination { + return m.Termination +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////////////////////// Accessors for const fields. @@ -63,22 +77,14 @@ func (m *_ParameterChange) GetSpecialChar2() byte { return ParameterChange_SPECIALCHAR2 } -func (m *_ParameterChange) GetCr() byte { - return ParameterChange_CR -} - -func (m *_ParameterChange) GetLf() byte { - return ParameterChange_LF -} - /////////////////////// /////////////////////// /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // NewParameterChange factory function for _ParameterChange -func NewParameterChange() *_ParameterChange { - return &_ParameterChange{} +func NewParameterChange(termination ResponseTermination) *_ParameterChange { + return &_ParameterChange{Termination: termination} } // Deprecated: use the interface for direct cast @@ -109,11 +115,8 @@ func (m *_ParameterChange) GetLengthInBitsConditional(lastItem bool) uint16 { // Const Field (specialChar2) lengthInBits += 8 - // Const Field (cr) - lengthInBits += 8 - - // Const Field (lf) - lengthInBits += 8 + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() return lengthInBits } @@ -149,22 +152,17 @@ func ParameterChangeParse(readBuffer utils.ReadBuffer) (ParameterChange, error) return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ParameterChange_SPECIALCHAR2) + " but got " + fmt.Sprintf("%d", specialChar2)) } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") - } - if cr != ParameterChange_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ParameterChange_CR) + " but got " + fmt.Sprintf("%d", cr)) + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") } - - // Const Field (lf) - lf, _lfErr := readBuffer.ReadByte("lf") - if _lfErr != nil { - return nil, errors.Wrap(_lfErr, "Error parsing 'lf' field") + _termination, _terminationErr := ResponseTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") } - if lf != ParameterChange_LF { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ParameterChange_LF) + " but got " + fmt.Sprintf("%d", lf)) + termination := _termination.(ResponseTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") } if closeErr := readBuffer.CloseContext("ParameterChange"); closeErr != nil { @@ -172,7 +170,7 @@ func ParameterChangeParse(readBuffer utils.ReadBuffer) (ParameterChange, error) } // Create the instance - return NewParameterChange(), nil + return NewParameterChange(termination), nil } func (m *_ParameterChange) Serialize(writeBuffer utils.WriteBuffer) error { @@ -194,16 +192,16 @@ func (m *_ParameterChange) Serialize(writeBuffer utils.WriteBuffer) error { return errors.Wrap(_specialChar2Err, "Error serializing 'specialChar2' field") } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0x0D) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") } - - // Const Field (lf) - _lfErr := writeBuffer.WriteByte("lf", 0x0A) - if _lfErr != nil { - return errors.Wrap(_lfErr, "Error serializing 'lf' field") + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") } if popErr := writeBuffer.PopContext("ParameterChange"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/ParameterChangeReply.go b/plc4go/protocols/cbus/readwrite/model/ParameterChangeReply.go index f77e1570a4d..90d4ef09053 100644 --- a/plc4go/protocols/cbus/readwrite/model/ParameterChangeReply.go +++ b/plc4go/protocols/cbus/readwrite/model/ParameterChangeReply.go @@ -58,8 +58,8 @@ type _ParameterChangeReply struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_ParameterChangeReply) InitializeParent(parent Reply, magicByte byte) { - m.MagicByte = magicByte +func (m *_ParameterChangeReply) InitializeParent(parent Reply, peekedByte byte) { + m.PeekedByte = peekedByte } func (m *_ParameterChangeReply) GetParent() Reply { @@ -81,10 +81,10 @@ func (m *_ParameterChangeReply) GetIsA() ParameterChange { /////////////////////////////////////////////////////////// // NewParameterChangeReply factory function for _ParameterChangeReply -func NewParameterChangeReply(isA ParameterChange, magicByte byte) *_ParameterChangeReply { +func NewParameterChangeReply(isA ParameterChange, peekedByte byte) *_ParameterChangeReply { _result := &_ParameterChangeReply{ IsA: isA, - _Reply: NewReply(magicByte), + _Reply: NewReply(peekedByte), } _result._Reply._ReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/PowerUp.go b/plc4go/protocols/cbus/readwrite/model/PowerUp.go index 2aaa31f64c1..fc646ee6215 100644 --- a/plc4go/protocols/cbus/readwrite/model/PowerUp.go +++ b/plc4go/protocols/cbus/readwrite/model/PowerUp.go @@ -28,14 +28,18 @@ import ( // Code generated by code-generation. DO NOT EDIT. // Constant values. -const PowerUp_PLUS byte = 0x02B -const PowerUp_CR byte = 0x0D -const PowerUp_LF byte = 0x0A +const PowerUp_POWERUPINDICATOR byte = 0x2B // PowerUp is the corresponding interface of PowerUp type PowerUp interface { utils.LengthAware utils.Serializable + // GetGarbage returns Garbage (property field) + GetGarbage() []byte + // GetReqTermination returns ReqTermination (property field) + GetReqTermination() RequestTermination + // GetResTermination returns ResTermination (property field) + GetResTermination() ResponseTermination } // PowerUpExactly can be used when we want exactly this type and not a type which fulfills PowerUp. @@ -47,23 +51,39 @@ type PowerUpExactly interface { // _PowerUp is the data-structure of this message type _PowerUp struct { + Garbage []byte + ReqTermination RequestTermination + ResTermination ResponseTermination } /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. +/////////////////////// Accessors for property fields. /////////////////////// -func (m *_PowerUp) GetPlus() byte { - return PowerUp_PLUS +func (m *_PowerUp) GetGarbage() []byte { + return m.Garbage } -func (m *_PowerUp) GetCr() byte { - return PowerUp_CR +func (m *_PowerUp) GetReqTermination() RequestTermination { + return m.ReqTermination } -func (m *_PowerUp) GetLf() byte { - return PowerUp_LF +func (m *_PowerUp) GetResTermination() ResponseTermination { + return m.ResTermination +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_PowerUp) GetPowerUpIndicator() byte { + return PowerUp_POWERUPINDICATOR } /////////////////////// @@ -72,8 +92,8 @@ func (m *_PowerUp) GetLf() byte { /////////////////////////////////////////////////////////// // NewPowerUp factory function for _PowerUp -func NewPowerUp() *_PowerUp { - return &_PowerUp{} +func NewPowerUp(garbage []byte, reqTermination RequestTermination, resTermination ResponseTermination) *_PowerUp { + return &_PowerUp{Garbage: garbage, ReqTermination: reqTermination, ResTermination: resTermination} } // Deprecated: use the interface for direct cast @@ -98,14 +118,19 @@ func (m *_PowerUp) GetLengthInBits() uint16 { func (m *_PowerUp) GetLengthInBitsConditional(lastItem bool) uint16 { lengthInBits := uint16(0) - // Const Field (plus) + // Const Field (powerUpIndicator) lengthInBits += 8 - // Const Field (cr) - lengthInBits += 8 + // Array field + if len(m.Garbage) > 0 { + lengthInBits += 8 * uint16(len(m.Garbage)) + } - // Const Field (lf) - lengthInBits += 8 + // Simple field (reqTermination) + lengthInBits += m.ReqTermination.GetLengthInBits() + + // Simple field (resTermination) + lengthInBits += m.ResTermination.GetLengthInBits() return lengthInBits } @@ -123,31 +148,45 @@ func PowerUpParse(readBuffer utils.ReadBuffer) (PowerUp, error) { currentPos := positionAware.GetPos() _ = currentPos - // Const Field (plus) - plus, _plusErr := readBuffer.ReadByte("plus") - if _plusErr != nil { - return nil, errors.Wrap(_plusErr, "Error parsing 'plus' field") + // Const Field (powerUpIndicator) + powerUpIndicator, _powerUpIndicatorErr := readBuffer.ReadByte("powerUpIndicator") + if _powerUpIndicatorErr != nil { + return nil, errors.Wrap(_powerUpIndicatorErr, "Error parsing 'powerUpIndicator' field") } - if plus != PowerUp_PLUS { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", PowerUp_PLUS) + " but got " + fmt.Sprintf("%d", plus)) + if powerUpIndicator != PowerUp_POWERUPINDICATOR { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", PowerUp_POWERUPINDICATOR) + " but got " + fmt.Sprintf("%d", powerUpIndicator)) + } + // Byte Array field (garbage) + numberOfBytesgarbage := int(0x0D) + garbage, _readArrayErr := readBuffer.ReadByteArray("garbage", numberOfBytesgarbage) + if _readArrayErr != nil { + return nil, errors.Wrap(_readArrayErr, "Error parsing 'garbage' field") } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + // Simple Field (reqTermination) + if pullErr := readBuffer.PullContext("reqTermination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for reqTermination") + } + _reqTermination, _reqTerminationErr := RequestTerminationParse(readBuffer) + if _reqTerminationErr != nil { + return nil, errors.Wrap(_reqTerminationErr, "Error parsing 'reqTermination' field") } - if cr != PowerUp_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", PowerUp_CR) + " but got " + fmt.Sprintf("%d", cr)) + reqTermination := _reqTermination.(RequestTermination) + if closeErr := readBuffer.CloseContext("reqTermination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for reqTermination") } - // Const Field (lf) - lf, _lfErr := readBuffer.ReadByte("lf") - if _lfErr != nil { - return nil, errors.Wrap(_lfErr, "Error parsing 'lf' field") + // Simple Field (resTermination) + if pullErr := readBuffer.PullContext("resTermination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for resTermination") + } + _resTermination, _resTerminationErr := ResponseTerminationParse(readBuffer) + if _resTerminationErr != nil { + return nil, errors.Wrap(_resTerminationErr, "Error parsing 'resTermination' field") } - if lf != PowerUp_LF { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", PowerUp_LF) + " but got " + fmt.Sprintf("%d", lf)) + resTermination := _resTermination.(ResponseTermination) + if closeErr := readBuffer.CloseContext("resTermination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for resTermination") } if closeErr := readBuffer.CloseContext("PowerUp"); closeErr != nil { @@ -155,7 +194,7 @@ func PowerUpParse(readBuffer utils.ReadBuffer) (PowerUp, error) { } // Create the instance - return NewPowerUp(), nil + return NewPowerUp(garbage, reqTermination, resTermination), nil } func (m *_PowerUp) Serialize(writeBuffer utils.WriteBuffer) error { @@ -165,22 +204,40 @@ func (m *_PowerUp) Serialize(writeBuffer utils.WriteBuffer) error { return errors.Wrap(pushErr, "Error pushing for PowerUp") } - // Const Field (plus) - _plusErr := writeBuffer.WriteByte("plus", 0x02B) - if _plusErr != nil { - return errors.Wrap(_plusErr, "Error serializing 'plus' field") + // Const Field (powerUpIndicator) + _powerUpIndicatorErr := writeBuffer.WriteByte("powerUpIndicator", 0x2B) + if _powerUpIndicatorErr != nil { + return errors.Wrap(_powerUpIndicatorErr, "Error serializing 'powerUpIndicator' field") } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0x0D) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") + // Array Field (garbage) + // Byte Array field (garbage) + if err := writeBuffer.WriteByteArray("garbage", m.GetGarbage()); err != nil { + return errors.Wrap(err, "Error serializing 'garbage' field") } - // Const Field (lf) - _lfErr := writeBuffer.WriteByte("lf", 0x0A) - if _lfErr != nil { - return errors.Wrap(_lfErr, "Error serializing 'lf' field") + // Simple Field (reqTermination) + if pushErr := writeBuffer.PushContext("reqTermination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for reqTermination") + } + _reqTerminationErr := writeBuffer.WriteSerializable(m.GetReqTermination()) + if popErr := writeBuffer.PopContext("reqTermination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for reqTermination") + } + if _reqTerminationErr != nil { + return errors.Wrap(_reqTerminationErr, "Error serializing 'reqTermination' field") + } + + // Simple Field (resTermination) + if pushErr := writeBuffer.PushContext("resTermination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for resTermination") + } + _resTerminationErr := writeBuffer.WriteSerializable(m.GetResTermination()) + if popErr := writeBuffer.PopContext("resTermination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for resTermination") + } + if _resTerminationErr != nil { + return errors.Wrap(_resTerminationErr, "Error serializing 'resTermination' field") } if popErr := writeBuffer.PopContext("PowerUp"); popErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/PowerUpReply.go b/plc4go/protocols/cbus/readwrite/model/PowerUpReply.go index 86557fde55f..402e86b73dd 100644 --- a/plc4go/protocols/cbus/readwrite/model/PowerUpReply.go +++ b/plc4go/protocols/cbus/readwrite/model/PowerUpReply.go @@ -58,8 +58,8 @@ type _PowerUpReply struct { /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// -func (m *_PowerUpReply) InitializeParent(parent Reply, magicByte byte) { - m.MagicByte = magicByte +func (m *_PowerUpReply) InitializeParent(parent Reply, peekedByte byte) { + m.PeekedByte = peekedByte } func (m *_PowerUpReply) GetParent() Reply { @@ -81,10 +81,10 @@ func (m *_PowerUpReply) GetIsA() PowerUp { /////////////////////////////////////////////////////////// // NewPowerUpReply factory function for _PowerUpReply -func NewPowerUpReply(isA PowerUp, magicByte byte) *_PowerUpReply { +func NewPowerUpReply(isA PowerUp, peekedByte byte) *_PowerUpReply { _result := &_PowerUpReply{ IsA: isA, - _Reply: NewReply(magicByte), + _Reply: NewReply(peekedByte), } _result._Reply._ReplyChildRequirements = _result return _result diff --git a/plc4go/protocols/cbus/readwrite/model/Reply.go b/plc4go/protocols/cbus/readwrite/model/Reply.go index b9b2aa27e0c..b47cba8ea97 100644 --- a/plc4go/protocols/cbus/readwrite/model/Reply.go +++ b/plc4go/protocols/cbus/readwrite/model/Reply.go @@ -30,8 +30,10 @@ import ( type Reply interface { utils.LengthAware utils.Serializable - // GetMagicByte returns MagicByte (property field) - GetMagicByte() byte + // GetPeekedByte returns PeekedByte (property field) + GetPeekedByte() byte + // GetIsAlpha returns IsAlpha (virtual field) + GetIsAlpha() bool } // ReplyExactly can be used when we want exactly this type and not a type which fulfills Reply. @@ -44,7 +46,7 @@ type ReplyExactly interface { // _Reply is the data-structure of this message type _Reply struct { _ReplyChildRequirements - MagicByte byte + PeekedByte byte } type _ReplyChildRequirements interface { @@ -60,7 +62,7 @@ type ReplyParent interface { type ReplyChild interface { utils.Serializable - InitializeParent(parent Reply, magicByte byte) + InitializeParent(parent Reply, peekedByte byte) GetParent() *Reply GetTypeName() string @@ -72,8 +74,21 @@ type ReplyChild interface { /////////////////////// Accessors for property fields. /////////////////////// -func (m *_Reply) GetMagicByte() byte { - return m.MagicByte +func (m *_Reply) GetPeekedByte() byte { + return m.PeekedByte +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for virtual fields. +/////////////////////// + +func (m *_Reply) GetIsAlpha() bool { + return bool(bool(bool(bool((m.GetPeekedByte()) >= (0x67)))) && bool(bool(bool((m.GetPeekedByte()) <= (0x7A))))) } /////////////////////// @@ -82,8 +97,8 @@ func (m *_Reply) GetMagicByte() byte { /////////////////////////////////////////////////////////// // NewReply factory function for _Reply -func NewReply(magicByte byte) *_Reply { - return &_Reply{MagicByte: magicByte} +func NewReply(peekedByte byte) *_Reply { + return &_Reply{PeekedByte: peekedByte} } // Deprecated: use the interface for direct cast @@ -104,6 +119,8 @@ func (m *_Reply) GetTypeName() string { func (m *_Reply) GetParentLengthInBits() uint16 { lengthInBits := uint16(0) + // A virtual field doesn't have any in- or output. + return lengthInBits } @@ -120,15 +137,20 @@ func ReplyParse(readBuffer utils.ReadBuffer) (Reply, error) { currentPos := positionAware.GetPos() _ = currentPos - // Peek Field (magicByte) + // Peek Field (peekedByte) currentPos = positionAware.GetPos() - magicByte, _err := readBuffer.ReadByte("magicByte") + peekedByte, _err := readBuffer.ReadByte("peekedByte") if _err != nil { - return nil, errors.Wrap(_err, "Error parsing 'magicByte' field") + return nil, errors.Wrap(_err, "Error parsing 'peekedByte' field") } readBuffer.Reset(currentPos) + // Virtual field + _isAlpha := bool(bool(bool((peekedByte) >= (0x67)))) && bool(bool(bool((peekedByte) <= (0x7A)))) + isAlpha := bool(_isAlpha) + _ = isAlpha + // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) type ReplyChildSerializeRequirement interface { Reply @@ -139,17 +161,17 @@ func ReplyParse(readBuffer utils.ReadBuffer) (Reply, error) { var _child ReplyChildSerializeRequirement var typeSwitchError error switch { - case magicByte == 0x0: // CALReplyReply + case peekedByte == 0x0: // CALReplyReply _childTemp, typeSwitchError = CALReplyReplyParse(readBuffer) - case magicByte == 0x0: // MonitoredSALReply + case peekedByte == 0x0: // MonitoredSALReply _childTemp, typeSwitchError = MonitoredSALReplyParse(readBuffer) - case magicByte == 0x0: // ConfirmationReply + case true && isAlpha == bool(true): // ConfirmationReply _childTemp, typeSwitchError = ConfirmationReplyParse(readBuffer) - case magicByte == 0x0: // PowerUpReply + case peekedByte == 0x2B: // PowerUpReply _childTemp, typeSwitchError = PowerUpReplyParse(readBuffer) - case magicByte == 0x0: // ParameterChangeReply + case peekedByte == 0x0: // ParameterChangeReply _childTemp, typeSwitchError = ParameterChangeReplyParse(readBuffer) - case magicByte == 0x0: // ExclamationMarkReply + case peekedByte == 0x21: // ExclamationMarkReply _childTemp, typeSwitchError = ExclamationMarkReplyParse(readBuffer) default: // TODO: return actual type @@ -165,7 +187,7 @@ func ReplyParse(readBuffer utils.ReadBuffer) (Reply, error) { } // Finish initializing - _child.InitializeParent(_child, magicByte) + _child.InitializeParent(_child, peekedByte) return _child, nil } @@ -178,6 +200,10 @@ func (pm *_Reply) SerializeParent(writeBuffer utils.WriteBuffer, child Reply, se if pushErr := writeBuffer.PushContext("Reply"); pushErr != nil { return errors.Wrap(pushErr, "Error pushing for Reply") } + // Virtual field + if _isAlphaErr := writeBuffer.WriteVirtual("isAlpha", m.GetIsAlpha()); _isAlphaErr != nil { + return errors.Wrap(_isAlphaErr, "Error serializing 'isAlpha' field") + } // Switch field (Depending on the discriminator values, passes the serialization to a sub-type) if _typeSwitchErr := serializeChildFunction(); _typeSwitchErr != nil { diff --git a/plc4go/protocols/cbus/readwrite/model/Request.go b/plc4go/protocols/cbus/readwrite/model/Request.go new file mode 100644 index 00000000000..8cdc5bcb3cf --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/Request.go @@ -0,0 +1,205 @@ +/* + * 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 + * + * https://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. + +// Request is the corresponding interface of Request +type Request interface { + utils.LengthAware + utils.Serializable + // GetPeekedByte returns PeekedByte (property field) + GetPeekedByte() byte +} + +// RequestExactly can be used when we want exactly this type and not a type which fulfills Request. +// This is useful for switch cases. +type RequestExactly interface { + Request + isRequest() bool +} + +// _Request is the data-structure of this message +type _Request struct { + _RequestChildRequirements + PeekedByte byte + + // Arguments. + Srchk bool +} + +type _RequestChildRequirements interface { + utils.Serializable + GetLengthInBits() uint16 + GetLengthInBitsConditional(lastItem bool) uint16 +} + +type RequestParent interface { + SerializeParent(writeBuffer utils.WriteBuffer, child Request, serializeChildFunction func() error) error + GetTypeName() string +} + +type RequestChild interface { + utils.Serializable + InitializeParent(parent Request, peekedByte byte) + GetParent() *Request + + GetTypeName() string + Request +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *_Request) GetPeekedByte() byte { + return m.PeekedByte +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewRequest factory function for _Request +func NewRequest(peekedByte byte, srchk bool) *_Request { + return &_Request{PeekedByte: peekedByte, Srchk: srchk} +} + +// Deprecated: use the interface for direct cast +func CastRequest(structType interface{}) Request { + if casted, ok := structType.(Request); ok { + return casted + } + if casted, ok := structType.(*Request); ok { + return *casted + } + return nil +} + +func (m *_Request) GetTypeName() string { + return "Request" +} + +func (m *_Request) GetParentLengthInBits() uint16 { + lengthInBits := uint16(0) + + return lengthInBits +} + +func (m *_Request) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func RequestParse(readBuffer utils.ReadBuffer, srchk bool) (Request, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("Request"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for Request") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Peek Field (peekedByte) + currentPos = positionAware.GetPos() + peekedByte, _err := readBuffer.ReadByte("peekedByte") + if _err != nil { + return nil, errors.Wrap(_err, "Error parsing 'peekedByte' field") + } + + readBuffer.Reset(currentPos) + + // Switch Field (Depending on the discriminator values, passes the instantiation to a sub-type) + type RequestChildSerializeRequirement interface { + Request + InitializeParent(Request, byte) + GetParent() Request + } + var _childTemp interface{} + var _child RequestChildSerializeRequirement + var typeSwitchError error + switch { + case peekedByte == 0x7C: // RequestSmartConnectShortcut + _childTemp, typeSwitchError = RequestSmartConnectShortcutParse(readBuffer, srchk) + case peekedByte == 0x7E: // RequestReset + _childTemp, typeSwitchError = RequestResetParse(readBuffer, srchk) + case peekedByte == 0x40: // RequestDirectCommandAccess + _childTemp, typeSwitchError = RequestDirectCommandAccessParse(readBuffer, srchk) + case peekedByte == 0x5C: // RequestCommand + _childTemp, typeSwitchError = RequestCommandParse(readBuffer, srchk) + 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.") + } + _child = _childTemp.(RequestChildSerializeRequirement) + + if closeErr := readBuffer.CloseContext("Request"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for Request") + } + + // Finish initializing + _child.InitializeParent(_child, peekedByte) + return _child, nil +} + +func (pm *_Request) SerializeParent(writeBuffer utils.WriteBuffer, child Request, serializeChildFunction func() error) error { + // We redirect all calls through client as some methods are only implemented there + m := child + _ = m + positionAware := writeBuffer + _ = positionAware + if pushErr := writeBuffer.PushContext("Request"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for Request") + } + + // 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("Request"); popErr != nil { + return errors.Wrap(popErr, "Error popping for Request") + } + return nil +} + +func (m *_Request) isRequest() bool { + return true +} + +func (m *_Request) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/RequestCommand.go b/plc4go/protocols/cbus/readwrite/model/RequestCommand.go new file mode 100644 index 00000000000..9c7424ee81f --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/RequestCommand.go @@ -0,0 +1,203 @@ +/* + * 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 + * + * https://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. + +// RequestCommand is the corresponding interface of RequestCommand +type RequestCommand interface { + utils.LengthAware + utils.Serializable + Request + // GetCbusCommand returns CbusCommand (property field) + GetCbusCommand() CBusCommand +} + +// RequestCommandExactly can be used when we want exactly this type and not a type which fulfills RequestCommand. +// This is useful for switch cases. +type RequestCommandExactly interface { + RequestCommand + isRequestCommand() bool +} + +// _RequestCommand is the data-structure of this message +type _RequestCommand struct { + *_Request + CbusCommand CBusCommand +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for discriminator values. +/////////////////////// + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *_RequestCommand) InitializeParent(parent Request, peekedByte byte) { + m.PeekedByte = peekedByte +} + +func (m *_RequestCommand) GetParent() Request { + return m._Request +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *_RequestCommand) GetCbusCommand() CBusCommand { + return m.CbusCommand +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewRequestCommand factory function for _RequestCommand +func NewRequestCommand(cbusCommand CBusCommand, peekedByte byte, srchk bool) *_RequestCommand { + _result := &_RequestCommand{ + CbusCommand: cbusCommand, + _Request: NewRequest(peekedByte, srchk), + } + _result._Request._RequestChildRequirements = _result + return _result +} + +// Deprecated: use the interface for direct cast +func CastRequestCommand(structType interface{}) RequestCommand { + if casted, ok := structType.(RequestCommand); ok { + return casted + } + if casted, ok := structType.(*RequestCommand); ok { + return *casted + } + return nil +} + +func (m *_RequestCommand) GetTypeName() string { + return "RequestCommand" +} + +func (m *_RequestCommand) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *_RequestCommand) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Simple field (cbusCommand) + lengthInBits += m.CbusCommand.GetLengthInBits() + + return lengthInBits +} + +func (m *_RequestCommand) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func RequestCommandParse(readBuffer utils.ReadBuffer, srchk bool) (RequestCommand, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("RequestCommand"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for RequestCommand") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Simple Field (cbusCommand) + if pullErr := readBuffer.PullContext("cbusCommand"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for cbusCommand") + } + _cbusCommand, _cbusCommandErr := CBusCommandParse(readBuffer, bool(srchk)) + if _cbusCommandErr != nil { + return nil, errors.Wrap(_cbusCommandErr, "Error parsing 'cbusCommand' field") + } + cbusCommand := _cbusCommand.(CBusCommand) + if closeErr := readBuffer.CloseContext("cbusCommand"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for cbusCommand") + } + + if closeErr := readBuffer.CloseContext("RequestCommand"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for RequestCommand") + } + + // Create a partially initialized instance + _child := &_RequestCommand{ + CbusCommand: cbusCommand, + _Request: &_Request{ + Srchk: srchk, + }, + } + _child._Request._RequestChildRequirements = _child + return _child, nil +} + +func (m *_RequestCommand) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("RequestCommand"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for RequestCommand") + } + + // Simple Field (cbusCommand) + if pushErr := writeBuffer.PushContext("cbusCommand"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for cbusCommand") + } + _cbusCommandErr := writeBuffer.WriteSerializable(m.GetCbusCommand()) + if popErr := writeBuffer.PopContext("cbusCommand"); popErr != nil { + return errors.Wrap(popErr, "Error popping for cbusCommand") + } + if _cbusCommandErr != nil { + return errors.Wrap(_cbusCommandErr, "Error serializing 'cbusCommand' field") + } + + if popErr := writeBuffer.PopContext("RequestCommand"); popErr != nil { + return errors.Wrap(popErr, "Error popping for RequestCommand") + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *_RequestCommand) isRequestCommand() bool { + return true +} + +func (m *_RequestCommand) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/RequestDirectCommandAccess.go b/plc4go/protocols/cbus/readwrite/model/RequestDirectCommandAccess.go new file mode 100644 index 00000000000..fa20b27d212 --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/RequestDirectCommandAccess.go @@ -0,0 +1,238 @@ +/* + * 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 + * + * https://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 ( + "fmt" + "github.com/apache/plc4x/plc4go/internal/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// Constant values. +const RequestDirectCommandAccess_AT byte = 0x40 + +// RequestDirectCommandAccess is the corresponding interface of RequestDirectCommandAccess +type RequestDirectCommandAccess interface { + utils.LengthAware + utils.Serializable + Request + // GetTermination returns Termination (property field) + GetTermination() RequestTermination +} + +// RequestDirectCommandAccessExactly can be used when we want exactly this type and not a type which fulfills RequestDirectCommandAccess. +// This is useful for switch cases. +type RequestDirectCommandAccessExactly interface { + RequestDirectCommandAccess + isRequestDirectCommandAccess() bool +} + +// _RequestDirectCommandAccess is the data-structure of this message +type _RequestDirectCommandAccess struct { + *_Request + Termination RequestTermination +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for discriminator values. +/////////////////////// + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *_RequestDirectCommandAccess) InitializeParent(parent Request, peekedByte byte) { + m.PeekedByte = peekedByte +} + +func (m *_RequestDirectCommandAccess) GetParent() Request { + return m._Request +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *_RequestDirectCommandAccess) GetTermination() RequestTermination { + return m.Termination +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_RequestDirectCommandAccess) GetAt() byte { + return RequestDirectCommandAccess_AT +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewRequestDirectCommandAccess factory function for _RequestDirectCommandAccess +func NewRequestDirectCommandAccess(termination RequestTermination, peekedByte byte, srchk bool) *_RequestDirectCommandAccess { + _result := &_RequestDirectCommandAccess{ + Termination: termination, + _Request: NewRequest(peekedByte, srchk), + } + _result._Request._RequestChildRequirements = _result + return _result +} + +// Deprecated: use the interface for direct cast +func CastRequestDirectCommandAccess(structType interface{}) RequestDirectCommandAccess { + if casted, ok := structType.(RequestDirectCommandAccess); ok { + return casted + } + if casted, ok := structType.(*RequestDirectCommandAccess); ok { + return *casted + } + return nil +} + +func (m *_RequestDirectCommandAccess) GetTypeName() string { + return "RequestDirectCommandAccess" +} + +func (m *_RequestDirectCommandAccess) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *_RequestDirectCommandAccess) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Const Field (at) + lengthInBits += 8 + + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() + + return lengthInBits +} + +func (m *_RequestDirectCommandAccess) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func RequestDirectCommandAccessParse(readBuffer utils.ReadBuffer, srchk bool) (RequestDirectCommandAccess, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("RequestDirectCommandAccess"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for RequestDirectCommandAccess") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Const Field (at) + at, _atErr := readBuffer.ReadByte("at") + if _atErr != nil { + return nil, errors.Wrap(_atErr, "Error parsing 'at' field") + } + if at != RequestDirectCommandAccess_AT { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", RequestDirectCommandAccess_AT) + " but got " + fmt.Sprintf("%d", at)) + } + + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") + } + _termination, _terminationErr := RequestTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") + } + termination := _termination.(RequestTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") + } + + if closeErr := readBuffer.CloseContext("RequestDirectCommandAccess"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for RequestDirectCommandAccess") + } + + // Create a partially initialized instance + _child := &_RequestDirectCommandAccess{ + Termination: termination, + _Request: &_Request{ + Srchk: srchk, + }, + } + _child._Request._RequestChildRequirements = _child + return _child, nil +} + +func (m *_RequestDirectCommandAccess) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("RequestDirectCommandAccess"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for RequestDirectCommandAccess") + } + + // Const Field (at) + _atErr := writeBuffer.WriteByte("at", 0x40) + if _atErr != nil { + return errors.Wrap(_atErr, "Error serializing 'at' field") + } + + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") + } + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") + } + + if popErr := writeBuffer.PopContext("RequestDirectCommandAccess"); popErr != nil { + return errors.Wrap(popErr, "Error popping for RequestDirectCommandAccess") + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *_RequestDirectCommandAccess) isRequestDirectCommandAccess() bool { + return true +} + +func (m *_RequestDirectCommandAccess) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/RequestReset.go b/plc4go/protocols/cbus/readwrite/model/RequestReset.go new file mode 100644 index 00000000000..3591ca17dd4 --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/RequestReset.go @@ -0,0 +1,238 @@ +/* + * 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 + * + * https://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 ( + "fmt" + "github.com/apache/plc4x/plc4go/internal/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// Constant values. +const RequestReset_TILDE byte = 0x7E + +// RequestReset is the corresponding interface of RequestReset +type RequestReset interface { + utils.LengthAware + utils.Serializable + Request + // GetTermination returns Termination (property field) + GetTermination() RequestTermination +} + +// RequestResetExactly can be used when we want exactly this type and not a type which fulfills RequestReset. +// This is useful for switch cases. +type RequestResetExactly interface { + RequestReset + isRequestReset() bool +} + +// _RequestReset is the data-structure of this message +type _RequestReset struct { + *_Request + Termination RequestTermination +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for discriminator values. +/////////////////////// + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *_RequestReset) InitializeParent(parent Request, peekedByte byte) { + m.PeekedByte = peekedByte +} + +func (m *_RequestReset) GetParent() Request { + return m._Request +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *_RequestReset) GetTermination() RequestTermination { + return m.Termination +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_RequestReset) GetTilde() byte { + return RequestReset_TILDE +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewRequestReset factory function for _RequestReset +func NewRequestReset(termination RequestTermination, peekedByte byte, srchk bool) *_RequestReset { + _result := &_RequestReset{ + Termination: termination, + _Request: NewRequest(peekedByte, srchk), + } + _result._Request._RequestChildRequirements = _result + return _result +} + +// Deprecated: use the interface for direct cast +func CastRequestReset(structType interface{}) RequestReset { + if casted, ok := structType.(RequestReset); ok { + return casted + } + if casted, ok := structType.(*RequestReset); ok { + return *casted + } + return nil +} + +func (m *_RequestReset) GetTypeName() string { + return "RequestReset" +} + +func (m *_RequestReset) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *_RequestReset) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Const Field (tilde) + lengthInBits += 8 + + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() + + return lengthInBits +} + +func (m *_RequestReset) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func RequestResetParse(readBuffer utils.ReadBuffer, srchk bool) (RequestReset, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("RequestReset"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for RequestReset") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Const Field (tilde) + tilde, _tildeErr := readBuffer.ReadByte("tilde") + if _tildeErr != nil { + return nil, errors.Wrap(_tildeErr, "Error parsing 'tilde' field") + } + if tilde != RequestReset_TILDE { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", RequestReset_TILDE) + " but got " + fmt.Sprintf("%d", tilde)) + } + + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") + } + _termination, _terminationErr := RequestTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") + } + termination := _termination.(RequestTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") + } + + if closeErr := readBuffer.CloseContext("RequestReset"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for RequestReset") + } + + // Create a partially initialized instance + _child := &_RequestReset{ + Termination: termination, + _Request: &_Request{ + Srchk: srchk, + }, + } + _child._Request._RequestChildRequirements = _child + return _child, nil +} + +func (m *_RequestReset) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("RequestReset"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for RequestReset") + } + + // Const Field (tilde) + _tildeErr := writeBuffer.WriteByte("tilde", 0x7E) + if _tildeErr != nil { + return errors.Wrap(_tildeErr, "Error serializing 'tilde' field") + } + + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") + } + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") + } + + if popErr := writeBuffer.PopContext("RequestReset"); popErr != nil { + return errors.Wrap(popErr, "Error popping for RequestReset") + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *_RequestReset) isRequestReset() bool { + return true +} + +func (m *_RequestReset) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/RequestSmartConnectShortcut.go b/plc4go/protocols/cbus/readwrite/model/RequestSmartConnectShortcut.go new file mode 100644 index 00000000000..b6266468858 --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/RequestSmartConnectShortcut.go @@ -0,0 +1,238 @@ +/* + * 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 + * + * https://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 ( + "fmt" + "github.com/apache/plc4x/plc4go/internal/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// Constant values. +const RequestSmartConnectShortcut_PIPE byte = 0x7C + +// RequestSmartConnectShortcut is the corresponding interface of RequestSmartConnectShortcut +type RequestSmartConnectShortcut interface { + utils.LengthAware + utils.Serializable + Request + // GetTermination returns Termination (property field) + GetTermination() RequestTermination +} + +// RequestSmartConnectShortcutExactly can be used when we want exactly this type and not a type which fulfills RequestSmartConnectShortcut. +// This is useful for switch cases. +type RequestSmartConnectShortcutExactly interface { + RequestSmartConnectShortcut + isRequestSmartConnectShortcut() bool +} + +// _RequestSmartConnectShortcut is the data-structure of this message +type _RequestSmartConnectShortcut struct { + *_Request + Termination RequestTermination +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for discriminator values. +/////////////////////// + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +func (m *_RequestSmartConnectShortcut) InitializeParent(parent Request, peekedByte byte) { + m.PeekedByte = peekedByte +} + +func (m *_RequestSmartConnectShortcut) GetParent() Request { + return m._Request +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for property fields. +/////////////////////// + +func (m *_RequestSmartConnectShortcut) GetTermination() RequestTermination { + return m.Termination +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_RequestSmartConnectShortcut) GetPipe() byte { + return RequestSmartConnectShortcut_PIPE +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewRequestSmartConnectShortcut factory function for _RequestSmartConnectShortcut +func NewRequestSmartConnectShortcut(termination RequestTermination, peekedByte byte, srchk bool) *_RequestSmartConnectShortcut { + _result := &_RequestSmartConnectShortcut{ + Termination: termination, + _Request: NewRequest(peekedByte, srchk), + } + _result._Request._RequestChildRequirements = _result + return _result +} + +// Deprecated: use the interface for direct cast +func CastRequestSmartConnectShortcut(structType interface{}) RequestSmartConnectShortcut { + if casted, ok := structType.(RequestSmartConnectShortcut); ok { + return casted + } + if casted, ok := structType.(*RequestSmartConnectShortcut); ok { + return *casted + } + return nil +} + +func (m *_RequestSmartConnectShortcut) GetTypeName() string { + return "RequestSmartConnectShortcut" +} + +func (m *_RequestSmartConnectShortcut) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *_RequestSmartConnectShortcut) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(m.GetParentLengthInBits()) + + // Const Field (pipe) + lengthInBits += 8 + + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() + + return lengthInBits +} + +func (m *_RequestSmartConnectShortcut) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func RequestSmartConnectShortcutParse(readBuffer utils.ReadBuffer, srchk bool) (RequestSmartConnectShortcut, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("RequestSmartConnectShortcut"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for RequestSmartConnectShortcut") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Const Field (pipe) + pipe, _pipeErr := readBuffer.ReadByte("pipe") + if _pipeErr != nil { + return nil, errors.Wrap(_pipeErr, "Error parsing 'pipe' field") + } + if pipe != RequestSmartConnectShortcut_PIPE { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", RequestSmartConnectShortcut_PIPE) + " but got " + fmt.Sprintf("%d", pipe)) + } + + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") + } + _termination, _terminationErr := RequestTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") + } + termination := _termination.(RequestTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") + } + + if closeErr := readBuffer.CloseContext("RequestSmartConnectShortcut"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for RequestSmartConnectShortcut") + } + + // Create a partially initialized instance + _child := &_RequestSmartConnectShortcut{ + Termination: termination, + _Request: &_Request{ + Srchk: srchk, + }, + } + _child._Request._RequestChildRequirements = _child + return _child, nil +} + +func (m *_RequestSmartConnectShortcut) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + ser := func() error { + if pushErr := writeBuffer.PushContext("RequestSmartConnectShortcut"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for RequestSmartConnectShortcut") + } + + // Const Field (pipe) + _pipeErr := writeBuffer.WriteByte("pipe", 0x7C) + if _pipeErr != nil { + return errors.Wrap(_pipeErr, "Error serializing 'pipe' field") + } + + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") + } + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") + } + + if popErr := writeBuffer.PopContext("RequestSmartConnectShortcut"); popErr != nil { + return errors.Wrap(popErr, "Error popping for RequestSmartConnectShortcut") + } + return nil + } + return m.SerializeParent(writeBuffer, m, ser) +} + +func (m *_RequestSmartConnectShortcut) isRequestSmartConnectShortcut() bool { + return true +} + +func (m *_RequestSmartConnectShortcut) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/RequestTermination.go b/plc4go/protocols/cbus/readwrite/model/RequestTermination.go new file mode 100644 index 00000000000..5d476f76035 --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/RequestTermination.go @@ -0,0 +1,159 @@ +/* + * 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 + * + * https://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 ( + "fmt" + "github.com/apache/plc4x/plc4go/internal/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// Constant values. +const RequestTermination_CR byte = 0x0D + +// RequestTermination is the corresponding interface of RequestTermination +type RequestTermination interface { + utils.LengthAware + utils.Serializable +} + +// RequestTerminationExactly can be used when we want exactly this type and not a type which fulfills RequestTermination. +// This is useful for switch cases. +type RequestTerminationExactly interface { + RequestTermination + isRequestTermination() bool +} + +// _RequestTermination is the data-structure of this message +type _RequestTermination struct { +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_RequestTermination) GetCr() byte { + return RequestTermination_CR +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewRequestTermination factory function for _RequestTermination +func NewRequestTermination() *_RequestTermination { + return &_RequestTermination{} +} + +// Deprecated: use the interface for direct cast +func CastRequestTermination(structType interface{}) RequestTermination { + if casted, ok := structType.(RequestTermination); ok { + return casted + } + if casted, ok := structType.(*RequestTermination); ok { + return *casted + } + return nil +} + +func (m *_RequestTermination) GetTypeName() string { + return "RequestTermination" +} + +func (m *_RequestTermination) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *_RequestTermination) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(0) + + // Const Field (cr) + lengthInBits += 8 + + return lengthInBits +} + +func (m *_RequestTermination) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func RequestTerminationParse(readBuffer utils.ReadBuffer) (RequestTermination, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("RequestTermination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for RequestTermination") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Const Field (cr) + cr, _crErr := readBuffer.ReadByte("cr") + if _crErr != nil { + return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + } + if cr != RequestTermination_CR { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", RequestTermination_CR) + " but got " + fmt.Sprintf("%d", cr)) + } + + if closeErr := readBuffer.CloseContext("RequestTermination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for RequestTermination") + } + + // Create the instance + return NewRequestTermination(), nil +} + +func (m *_RequestTermination) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + if pushErr := writeBuffer.PushContext("RequestTermination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for RequestTermination") + } + + // Const Field (cr) + _crErr := writeBuffer.WriteByte("cr", 0x0D) + if _crErr != nil { + return errors.Wrap(_crErr, "Error serializing 'cr' field") + } + + if popErr := writeBuffer.PopContext("RequestTermination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for RequestTermination") + } + return nil +} + +func (m *_RequestTermination) isRequestTermination() bool { + return true +} + +func (m *_RequestTermination) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/ResponseTermination.go b/plc4go/protocols/cbus/readwrite/model/ResponseTermination.go new file mode 100644 index 00000000000..ec5f1088e81 --- /dev/null +++ b/plc4go/protocols/cbus/readwrite/model/ResponseTermination.go @@ -0,0 +1,182 @@ +/* + * 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 + * + * https://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 ( + "fmt" + "github.com/apache/plc4x/plc4go/internal/spi/utils" + "github.com/pkg/errors" +) + +// Code generated by code-generation. DO NOT EDIT. + +// Constant values. +const ResponseTermination_CR byte = 0x0D +const ResponseTermination_LF byte = 0x0A + +// ResponseTermination is the corresponding interface of ResponseTermination +type ResponseTermination interface { + utils.LengthAware + utils.Serializable +} + +// ResponseTerminationExactly can be used when we want exactly this type and not a type which fulfills ResponseTermination. +// This is useful for switch cases. +type ResponseTerminationExactly interface { + ResponseTermination + isResponseTermination() bool +} + +// _ResponseTermination is the data-structure of this message +type _ResponseTermination struct { +} + +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////// Accessors for const fields. +/////////////////////// + +func (m *_ResponseTermination) GetCr() byte { + return ResponseTermination_CR +} + +func (m *_ResponseTermination) GetLf() byte { + return ResponseTermination_LF +} + +/////////////////////// +/////////////////////// +/////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////// + +// NewResponseTermination factory function for _ResponseTermination +func NewResponseTermination() *_ResponseTermination { + return &_ResponseTermination{} +} + +// Deprecated: use the interface for direct cast +func CastResponseTermination(structType interface{}) ResponseTermination { + if casted, ok := structType.(ResponseTermination); ok { + return casted + } + if casted, ok := structType.(*ResponseTermination); ok { + return *casted + } + return nil +} + +func (m *_ResponseTermination) GetTypeName() string { + return "ResponseTermination" +} + +func (m *_ResponseTermination) GetLengthInBits() uint16 { + return m.GetLengthInBitsConditional(false) +} + +func (m *_ResponseTermination) GetLengthInBitsConditional(lastItem bool) uint16 { + lengthInBits := uint16(0) + + // Const Field (cr) + lengthInBits += 8 + + // Const Field (lf) + lengthInBits += 8 + + return lengthInBits +} + +func (m *_ResponseTermination) GetLengthInBytes() uint16 { + return m.GetLengthInBits() / 8 +} + +func ResponseTerminationParse(readBuffer utils.ReadBuffer) (ResponseTermination, error) { + positionAware := readBuffer + _ = positionAware + if pullErr := readBuffer.PullContext("ResponseTermination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for ResponseTermination") + } + currentPos := positionAware.GetPos() + _ = currentPos + + // Const Field (cr) + cr, _crErr := readBuffer.ReadByte("cr") + if _crErr != nil { + return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + } + if cr != ResponseTermination_CR { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ResponseTermination_CR) + " but got " + fmt.Sprintf("%d", cr)) + } + + // Const Field (lf) + lf, _lfErr := readBuffer.ReadByte("lf") + if _lfErr != nil { + return nil, errors.Wrap(_lfErr, "Error parsing 'lf' field") + } + if lf != ResponseTermination_LF { + return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", ResponseTermination_LF) + " but got " + fmt.Sprintf("%d", lf)) + } + + if closeErr := readBuffer.CloseContext("ResponseTermination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for ResponseTermination") + } + + // Create the instance + return NewResponseTermination(), nil +} + +func (m *_ResponseTermination) Serialize(writeBuffer utils.WriteBuffer) error { + positionAware := writeBuffer + _ = positionAware + if pushErr := writeBuffer.PushContext("ResponseTermination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for ResponseTermination") + } + + // Const Field (cr) + _crErr := writeBuffer.WriteByte("cr", 0x0D) + if _crErr != nil { + return errors.Wrap(_crErr, "Error serializing 'cr' field") + } + + // Const Field (lf) + _lfErr := writeBuffer.WriteByte("lf", 0x0A) + if _lfErr != nil { + return errors.Wrap(_lfErr, "Error serializing 'lf' field") + } + + if popErr := writeBuffer.PopContext("ResponseTermination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for ResponseTermination") + } + return nil +} + +func (m *_ResponseTermination) isResponseTermination() bool { + return true +} + +func (m *_ResponseTermination) String() string { + if m == nil { + return "" + } + writeBuffer := utils.NewBoxedWriteBufferWithOptions(true, true) + if err := writeBuffer.WriteSerializable(m); err != nil { + return err.Error() + } + return writeBuffer.GetBox().String() +} diff --git a/plc4go/protocols/cbus/readwrite/model/StandardFormatStatusReply.go b/plc4go/protocols/cbus/readwrite/model/StandardFormatStatusReply.go index 829bf40aec3..9b1577157c9 100644 --- a/plc4go/protocols/cbus/readwrite/model/StandardFormatStatusReply.go +++ b/plc4go/protocols/cbus/readwrite/model/StandardFormatStatusReply.go @@ -20,17 +20,12 @@ package model import ( - "fmt" "github.com/apache/plc4x/plc4go/internal/spi/utils" "github.com/pkg/errors" ) // Code generated by code-generation. DO NOT EDIT. -// Constant values. -const StandardFormatStatusReply_CR byte = 0x0D -const StandardFormatStatusReply_LF byte = 0x0A - // StandardFormatStatusReply is the corresponding interface of StandardFormatStatusReply type StandardFormatStatusReply interface { utils.LengthAware @@ -45,6 +40,8 @@ type StandardFormatStatusReply interface { GetStatusBytes() []StatusByte // GetCrc returns Crc (property field) GetCrc() Checksum + // GetTermination returns Termination (property field) + GetTermination() ResponseTermination } // StandardFormatStatusReplyExactly can be used when we want exactly this type and not a type which fulfills StandardFormatStatusReply. @@ -61,6 +58,7 @@ type _StandardFormatStatusReply struct { BlockStart uint8 StatusBytes []StatusByte Crc Checksum + Termination ResponseTermination } /////////////////////////////////////////////////////////// @@ -88,21 +86,8 @@ func (m *_StandardFormatStatusReply) GetCrc() Checksum { return m.Crc } -/////////////////////// -/////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -/////////////////////// Accessors for const fields. -/////////////////////// - -func (m *_StandardFormatStatusReply) GetCr() byte { - return StandardFormatStatusReply_CR -} - -func (m *_StandardFormatStatusReply) GetLf() byte { - return StandardFormatStatusReply_LF +func (m *_StandardFormatStatusReply) GetTermination() ResponseTermination { + return m.Termination } /////////////////////// @@ -111,8 +96,8 @@ func (m *_StandardFormatStatusReply) GetLf() byte { /////////////////////////////////////////////////////////// // NewStandardFormatStatusReply factory function for _StandardFormatStatusReply -func NewStandardFormatStatusReply(statusHeader StatusHeader, application ApplicationIdContainer, blockStart uint8, statusBytes []StatusByte, crc Checksum) *_StandardFormatStatusReply { - return &_StandardFormatStatusReply{StatusHeader: statusHeader, Application: application, BlockStart: blockStart, StatusBytes: statusBytes, Crc: crc} +func NewStandardFormatStatusReply(statusHeader StatusHeader, application ApplicationIdContainer, blockStart uint8, statusBytes []StatusByte, crc Checksum, termination ResponseTermination) *_StandardFormatStatusReply { + return &_StandardFormatStatusReply{StatusHeader: statusHeader, Application: application, BlockStart: blockStart, StatusBytes: statusBytes, Crc: crc, Termination: termination} } // Deprecated: use the interface for direct cast @@ -157,11 +142,8 @@ func (m *_StandardFormatStatusReply) GetLengthInBitsConditional(lastItem bool) u // Simple field (crc) lengthInBits += m.Crc.GetLengthInBits() - // Const Field (cr) - lengthInBits += 8 - - // Const Field (lf) - lengthInBits += 8 + // Simple field (termination) + lengthInBits += m.Termination.GetLengthInBits() return lengthInBits } @@ -248,22 +230,17 @@ func StandardFormatStatusReplyParse(readBuffer utils.ReadBuffer) (StandardFormat return nil, errors.Wrap(closeErr, "Error closing for crc") } - // Const Field (cr) - cr, _crErr := readBuffer.ReadByte("cr") - if _crErr != nil { - return nil, errors.Wrap(_crErr, "Error parsing 'cr' field") + // Simple Field (termination) + if pullErr := readBuffer.PullContext("termination"); pullErr != nil { + return nil, errors.Wrap(pullErr, "Error pulling for termination") } - if cr != StandardFormatStatusReply_CR { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", StandardFormatStatusReply_CR) + " but got " + fmt.Sprintf("%d", cr)) + _termination, _terminationErr := ResponseTerminationParse(readBuffer) + if _terminationErr != nil { + return nil, errors.Wrap(_terminationErr, "Error parsing 'termination' field") } - - // Const Field (lf) - lf, _lfErr := readBuffer.ReadByte("lf") - if _lfErr != nil { - return nil, errors.Wrap(_lfErr, "Error parsing 'lf' field") - } - if lf != StandardFormatStatusReply_LF { - return nil, errors.New("Expected constant value " + fmt.Sprintf("%d", StandardFormatStatusReply_LF) + " but got " + fmt.Sprintf("%d", lf)) + termination := _termination.(ResponseTermination) + if closeErr := readBuffer.CloseContext("termination"); closeErr != nil { + return nil, errors.Wrap(closeErr, "Error closing for termination") } if closeErr := readBuffer.CloseContext("StandardFormatStatusReply"); closeErr != nil { @@ -271,7 +248,7 @@ func StandardFormatStatusReplyParse(readBuffer utils.ReadBuffer) (StandardFormat } // Create the instance - return NewStandardFormatStatusReply(statusHeader, application, blockStart, statusBytes, crc), nil + return NewStandardFormatStatusReply(statusHeader, application, blockStart, statusBytes, crc, termination), nil } func (m *_StandardFormatStatusReply) Serialize(writeBuffer utils.WriteBuffer) error { @@ -338,16 +315,16 @@ func (m *_StandardFormatStatusReply) Serialize(writeBuffer utils.WriteBuffer) er return errors.Wrap(_crcErr, "Error serializing 'crc' field") } - // Const Field (cr) - _crErr := writeBuffer.WriteByte("cr", 0x0D) - if _crErr != nil { - return errors.Wrap(_crErr, "Error serializing 'cr' field") + // Simple Field (termination) + if pushErr := writeBuffer.PushContext("termination"); pushErr != nil { + return errors.Wrap(pushErr, "Error pushing for termination") } - - // Const Field (lf) - _lfErr := writeBuffer.WriteByte("lf", 0x0A) - if _lfErr != nil { - return errors.Wrap(_lfErr, "Error serializing 'lf' field") + _terminationErr := writeBuffer.WriteSerializable(m.GetTermination()) + if popErr := writeBuffer.PopContext("termination"); popErr != nil { + return errors.Wrap(popErr, "Error popping for termination") + } + if _terminationErr != nil { + return errors.Wrap(_terminationErr, "Error serializing 'termination' field") } if popErr := writeBuffer.PopContext("StandardFormatStatusReply"); popErr != nil { diff --git a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec index 39e776e763e..c841c381437 100644 --- a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec +++ b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec @@ -18,55 +18,82 @@ */ [type CBusConstants - [const uint 16 cbusTcpDefaultPort 10001] + [const uint 16 cbusTcpDefaultPort 10001] +] + +// TODO: check if that can be used in combination with srchk +[type CBusOptions + [simple bit connect] + [simple bit smart ] + [simple bit idmon ] + [simple bit exstat ] + [simple bit monitor] + [simple bit monall ] + [simple bit pun ] + [simple bit pcn ] ] [type CBusMessage(bit response, bit srchk) - // TODO: we need to peek here too [typeSwitch response ['false' *ToServer - [simple CBusCommand('srchk') command] + [simple Request('srchk') request ] ] ['true' *ToClient - [simple Confirmation confirmation] + [simple Reply reply ] ] ] ] +[type Request(bit srchk) + [peek byte peekedByte ] + [typeSwitch peekedByte + ['0x7C' *SmartConnectShortcut + [const byte pipe 0x7C ] + [simple RequestTermination termination ] + ] + ['0x7E' *Reset + [const byte tilde 0x7E ] + [simple RequestTermination termination ] + ] + ['0x40' *DirectCommandAccess + [const byte at 0x40 ] + // TODO: read device_management_cal data here + [simple RequestTermination termination ] + ] + ['0x5C' *Command + [simple CBusCommand('srchk') cbusCommand ] + ] + ] +] + [discriminatedType CBusCommand(bit srchk) - //[const byte initiator 0x5C ] // 0x5C == "/" - [simple CBusHeader header ] + [const byte initiator 0x5C ] // 0x5C == "/" + [simple CBusHeader header ] + [virtual bit isDeviceManagement 'header.dp'] // TODO: header.destinationAddressType could be used directly but for this we need source type resolving to work (WIP) [virtual DestinationAddressType destinationAddressType 'header.destinationAddressType'] - [typeSwitch destinationAddressType - ['PointToPointToMultiPoint' CBusCommandPointToPointToMultiPoint + [typeSwitch destinationAddressType, isDeviceManagement + [*, 'true' *DeviceManagement + [simple uint 8 parameterNumber ] + [const byte delimiter 0x0 ] + [simple byte parameterValue ] + ] + ['PointToPointToMultiPoint' *PointToPointToMultiPoint [simple CBusPointToPointToMultipointCommand('srchk') command] ] - ['PointToMultiPoint' CBusCommandPointToMultiPoint + ['PointToMultiPoint' *PointToMultiPoint [simple CBusPointToMultiPointCommand('srchk') command] ] - ['PointToPoint' CBusCommandPointToPoint + ['PointToPoint' *PointToPoint [simple CBusPointToPointCommand('srchk') command] ] ] ] -// TODO: check if that can be used in combination with srchk -[type CBusOptions - [simple bit connect] - [simple bit smart ] - [simple bit idmon ] - [simple bit exstat ] - [simple bit monitor] - [simple bit monall ] - [simple bit pun ] - [simple bit pcn ] -] - [type CBusHeader [simple PriorityClass priorityClass ] - [simple bit dpReservedManagement ] // Reserved for internal C-Bus management purposes (Referred to as special packet attribute) - [simple uint 2 rcReservedManagement ] // Reserved for internal C-Bus management purposes (Referred to as special packet attribute) + [simple bit dp ] // Reserved for internal C-Bus management purposes (Referred to as special packet attribute) + [simple uint 2 rc ] // Reserved for internal C-Bus management purposes (Referred to as special packet attribute) [simple DestinationAddressType destinationAddressType] ] @@ -143,7 +170,7 @@ [optional Checksum crc 'srchk' ] // checksum is optional but mspec checksum isn't [peek byte peekAlpha ] [optional Alpha alpha '(peekAlpha >= 0x67) && (peekAlpha <= 0x7A)' ] // Read if the peeked byte is between 'g' and 'z' - [const byte cr 0xD ] // 0xD == "" + [simple RequestTermination termination ] ] [discriminatedType CBusPointToMultiPointCommand(bit srchk) @@ -156,7 +183,6 @@ [optional Checksum crc 'srchk' ] // checksum is optional but mspec checksum isn't [peek byte peekAlpha ] [optional Alpha alpha '(peekAlpha >= 0x67) && (peekAlpha <= 0x7A)' ] // Read if the peeked byte is between 'g' and 'z' - [const byte cr 0xD ] // 0xD == "" ] [ CBusPointToMultiPointCommandNormal [simple ApplicationIdContainer application ] @@ -165,9 +191,9 @@ [optional Checksum crc 'srchk' ] // crc is optional but mspec crc isn't [peek byte peekAlpha ] [optional Alpha alpha '(peekAlpha >= 0x67) && (peekAlpha <= 0x7A)'] // Read if the peeked byte is between 'g' and 'z' - [const byte cr 0xD ] // 0xD == "" ] ] + [simple RequestTermination termination ] ] [discriminatedType CBusPointToPointToMultipointCommand(bit srchk) @@ -181,7 +207,6 @@ [optional Checksum crc 'srchk' ] // crc is optional but mspec crc isn't [peek byte peekAlpha ] [optional Alpha alpha '(peekAlpha >= 0x67) && (peekAlpha <= 0x7A)' ] // Read if the peeked byte is between 'g' and 'z' - [const byte cr 0xD ] // 0xD == "" ] [ CBusCommandPointToPointToMultiPointNormal [simple ApplicationIdContainer application ] @@ -189,9 +214,9 @@ [optional Checksum crc 'srchk' ] // crc is optional but mspec crc isn't [peek byte peekAlpha ] [optional Alpha alpha '(peekAlpha >= 0x67) && (peekAlpha <= 0x7A)'] // Read if the peeked byte is between 'g' and 'z' - [const byte cr 0xD ] // 0xD == "" ] ] + [simple RequestTermination termination ] ] /* @@ -851,24 +876,25 @@ ] [type Reply - [peek byte magicByte] - [typeSwitch magicByte + [peek byte peekedByte ] + [virtual bit isAlpha '(peekedByte >= 0x67) && (peekedByte <= 0x7A)' ] + [typeSwitch peekedByte, isAlpha ['0x0' CALReplyReply [simple CALReply isA] ] ['0x0' MonitoredSALReply [simple MonitoredSAL isA] ] - ['0x0' ConfirmationReply + [*, 'true' ConfirmationReply [simple Confirmation isA] ] - ['0x0' PowerUpReply + ['0x2B' PowerUpReply [simple PowerUp isA] ] ['0x0' ParameterChangeReply [simple ParameterChange isA] ] - ['0x0' ExclamationMarkReply + ['0x21' ExclamationMarkReply [simple ExclamationMark isA] ] ] @@ -894,8 +920,7 @@ ] [simple CALData calData ] //[checksum byte crc '0x00' ] // TODO: Fix this - [const byte cr 0x0D ] // 0xD == "" - [const byte lf 0x0A ] // 0xA == "" + [simple ResponseTermination termination ] ] [type BridgeCount @@ -934,8 +959,7 @@ ] [optional SALData salData ] //[checksum byte crc '0x00' ] // TODO: Fix this - [const byte cr 0x0D ] // 0xD == "" - [const byte lf 0x0A ] // 0xA == "" + [simple ResponseTermination termination ] ] [type Confirmation @@ -951,18 +975,16 @@ ] [type PowerUp -// TODO: implement garbage reading -// [array byte garbage terminated '0x2B' ] // "+" - [const byte plus 0x02B ] // 0xD == "" - [const byte cr 0x0D ] // 0xD == "" - [const byte lf 0x0A ] // 0xA == "" + [const byte powerUpIndicator 0x2B ] // "+" + [array byte garbage terminated '0x0D' ] // read all following + + [simple RequestTermination reqTermination ] + [simple ResponseTermination resTermination ] ] [type ParameterChange - [const byte specialChar1 0x3D ] // "=" - [const byte specialChar2 0x3D ] // "=" - [const byte cr 0x0D ] // 0xD == "" - [const byte lf 0x0A ] // 0xA == "" + [const byte specialChar1 0x3D ] // "=" + [const byte specialChar2 0x3D ] // "=" + [simple ResponseTermination termination ] ] [type ExclamationMark @@ -991,8 +1013,7 @@ 'statusHeader.numberOfCharacterPairs - 2' ] [simple Checksum crc ] - [const byte cr 0x0D ] // 0xD == "" - [const byte lf 0x0A ] // 0xA == "" + [simple ResponseTermination termination ] ] [type StatusHeader @@ -1014,8 +1035,7 @@ 'statusHeader.numberOfCharacterPairs - 3' ] [simple Checksum crc ] - [const byte cr 0x0D ] // 0xD == "" - [const byte lf 0x0A ] // 0xA == "" + [simple ResponseTermination termination ] ] [type ExtendedStatusHeader @@ -1049,3 +1069,12 @@ [simple uint 3 stackCounter ] [simple uint 3 stackDepth ] ] + +[type RequestTermination + [const byte cr 0x0D ] // 0xD == "" +] + +[type ResponseTermination + [const byte cr 0x0D ] // 0xD == "" + [const byte lf 0x0A ] // 0xA == "" +] \ No newline at end of file