Skip to content

Commit

Permalink
feat(bacnet): added helper for opening and closing tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Apr 20, 2022
1 parent a7ebaa9 commit 373d618
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ func CreateBACnetTagHeaderBalanced(isContext bool, id uint8, value uint32) *BACn
return NewBACnetTagHeader(tagNumber, tagClass, lengthValueType, extTagNumber, extLength, extExtLength, extExtExtLength)
}

func createBACnetOpeningTag(tagNum uint8) *BACnetOpeningTag {
header := CreateBACnetTagHeaderBalanced(true, tagNum, 0x6)
return NewBACnetOpeningTag(header, tagNum, 6)
}

func createBACnetClosingTag(tagNum uint8) *BACnetClosingTag {
header := CreateBACnetTagHeaderBalanced(true, tagNum, 0x7)
return NewBACnetClosingTag(header, tagNum, 7)
}

func CreateBACnetApplicationTagObjectIdentifier(objectType uint16, instance uint32) *BACnetApplicationTagObjectIdentifier {
header := NewBACnetTagHeader(0xC, TagClass_APPLICATION_TAGS, uint8(4), nil, nil, nil, nil)
objectTypeEnum := BACnetObjectTypeByValue(objectType)
Expand All @@ -357,8 +367,7 @@ func CreateBACnetApplicationTagObjectIdentifier(objectType uint16, instance uint
proprietaryValue = objectType
}
payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, proprietaryValue, instance)
result := NewBACnetApplicationTagObjectIdentifier(payload, header)
return CastBACnetApplicationTagObjectIdentifier(result)
return NewBACnetApplicationTagObjectIdentifier(payload, header)
}

func CreateBACnetContextTagObjectIdentifier(tagNum uint8, objectType uint16, instance uint32) *BACnetContextTagObjectIdentifier {
Expand All @@ -370,8 +379,7 @@ func CreateBACnetContextTagObjectIdentifier(tagNum uint8, objectType uint16, ins
proprietaryValue = objectType
}
payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, proprietaryValue, instance)
result := NewBACnetContextTagObjectIdentifier(payload, header, tagNum, true)
return CastBACnetContextTagObjectIdentifier(result)
return NewBACnetContextTagObjectIdentifier(payload, header, tagNum, true)
}

func CreateBACnetContextTagPropertyIdentifier(tagNum uint8, propertyType uint32) *BACnetContextTagPropertyIdentifier {
Expand All @@ -382,8 +390,7 @@ func CreateBACnetContextTagPropertyIdentifier(tagNum uint8, propertyType uint32)
propertyTypeEnum = BACnetPropertyIdentifier_VENDOR_PROPRIETARY_VALUE
proprietaryValue = propertyType
}
result := NewBACnetContextTagPropertyIdentifier(propertyTypeEnum, proprietaryValue, header, tagNum, true, 0)
return CastBACnetContextTagPropertyIdentifier(result)
return NewBACnetContextTagPropertyIdentifier(propertyTypeEnum, proprietaryValue, header, tagNum, true, 0)
}

func CreateBACnetApplicationTagEnumerated(value uint32) *BACnetApplicationTagEnumerated {
Expand All @@ -410,15 +417,13 @@ func CreateEnumeratedPayload(value uint32) (uint32, *BACnetTagPayloadEnumerated)
func CreateBACnetApplicationTagUnsignedInteger(value uint32) *BACnetApplicationTagUnsignedInteger {
length, payload := CreateUnsignedPayload(value)
header := CreateBACnetTagHeaderBalanced(false, 0x2, length)
result := NewBACnetApplicationTagUnsignedInteger(payload, header)
return CastBACnetApplicationTagUnsignedInteger(result)
return NewBACnetApplicationTagUnsignedInteger(payload, header)
}

func CreateBACnetContextTagUnsignedInteger(tagNumber uint8, value uint32) *BACnetContextTagUnsignedInteger {
length, payload := CreateUnsignedPayload(value)
header := CreateBACnetTagHeaderBalanced(true, tagNumber, length)
result := NewBACnetContextTagUnsignedInteger(payload, header, tagNumber, true)
return CastBACnetContextTagUnsignedInteger(result)
return NewBACnetContextTagUnsignedInteger(payload, header, tagNumber, true)
}

func CreateUnsignedPayload(value uint32) (uint32, *BACnetTagPayloadUnsignedInteger) {
Expand Down Expand Up @@ -455,15 +460,13 @@ func CreateUnsignedPayload(value uint32) (uint32, *BACnetTagPayloadUnsignedInteg
func CreateBACnetApplicationTagSignedInteger(value int32) *BACnetApplicationTagSignedInteger {
length, payload := CreateSignedPayload(value)
header := CreateBACnetTagHeaderBalanced(true, 0x3, length)
result := NewBACnetApplicationTagSignedInteger(payload, header)
return CastBACnetApplicationTagSignedInteger(result)
return NewBACnetApplicationTagSignedInteger(payload, header)
}

func CreateBACnetContextTagSignedInteger(tagNumber uint8, value int32) *BACnetContextTagSignedInteger {
length, payload := CreateSignedPayload(value)
header := CreateBACnetTagHeaderBalanced(true, tagNumber, length)
result := NewBACnetContextTagSignedInteger(payload, header, tagNumber, true)
return CastBACnetContextTagSignedInteger(result)
return NewBACnetContextTagSignedInteger(payload, header, tagNumber, true)
}

func CreateSignedPayload(value int32) (uint32, *BACnetTagPayloadSignedInteger) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,16 @@ public static BACnetTagHeader createBACnetTagHeaderBalanced(boolean isContext, s
return new BACnetTagHeader(tagNumber, tagClass, lengthValueType, extTagNumber, extLength, extExtLength, extExtExtLength);
}

public static BACnetOpeningTag createBACnetOpeningTag(short tagNum) {
BACnetTagHeader header = createBACnetTagHeaderBalanced(true, tagNum, 0x6L);
return new BACnetOpeningTag(header, tagNum, 6L);
}

public static BACnetClosingTag createBACnetClosingTag(short tagNum) {
BACnetTagHeader header = createBACnetTagHeaderBalanced(true, tagNum, 0x7L);
return new BACnetClosingTag(header, tagNum, 7L);
}

public static BACnetApplicationTagObjectIdentifier createBACnetApplicationTagObjectIdentifier(int objectType, long instance) {
BACnetTagHeader header = new BACnetTagHeader((byte) 0xC, TagClass.APPLICATION_TAGS, (byte) 4, null, null, null, null);
BACnetObjectType objectTypeEnum = BACnetObjectType.enumForValue(objectType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1311,10 +1311,10 @@
state ]
]
['OPENING_TAG' BACnetOpeningTag(uint 32 actualLength)
[validation 'actualLength == 6' "opening tag should habe a value of 6"]
[validation 'actualLength == 6' "opening tag should have a value of 6"]
]
['CLOSING_TAG' BACnetClosingTag(uint 32 actualLength)
[validation 'actualLength == 7' "closing tag should habe a value of 7"]
[validation 'actualLength == 7' "closing tag should have a value of 7"]
]
[BACnetContextTagEmpty
]
Expand Down

0 comments on commit 373d618

Please sign in to comment.