You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/02/18 11:19:06 UTC
[plc4x] branch develop updated: feat(bacnet): Add util methods in static helper for object identifiers
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new c22fedf feat(bacnet): Add util methods in static helper for object identifiers
c22fedf is described below
commit c22fedf809c5a5171a9e8e5e77294d268b07a7b7
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Fri Feb 18 12:19:00 2022 +0100
feat(bacnet): Add util methods in static helper for object identifiers
---
.../bacnetip/readwrite/model/StaticHelper.go | 26 +++++++++++++++++++++-
.../bacnetip/readwrite/utils/StaticHelper.java | 23 ++++++++++++++++++-
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go b/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go
index 56aaf01..327fe12 100644
--- a/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go
+++ b/plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go
@@ -306,7 +306,7 @@ func WriteVarUint(value uint32) []byte {
return big.NewInt(int64(value)).Bytes()
}
-func NewBACnetTagHeaderBalanced(isContext bool, id uint8, value uint32) *BACnetTagHeader {
+func CreateBACnetTagHeaderBalanced(isContext bool, id uint8, value uint32) *BACnetTagHeader {
tagClass := TagClass_APPLICATION_TAGS
if isContext {
tagClass = TagClass_CONTEXT_SPECIFIC_TAGS
@@ -347,3 +347,27 @@ func NewBACnetTagHeaderBalanced(isContext bool, id uint8, value uint32) *BACnetT
return NewBACnetTagHeader(tagNumber, tagClass, lengthValueType, extTagNumber, extLength, extExtLength, extExtExtLength)
}
+
+func CreateBACnetApplicationTagObjectIdentifier(objectType uint16, instance uint32) *BACnetApplicationTagObjectIdentifier {
+ header := NewBACnetTagHeader(0xC, TagClass_APPLICATION_TAGS, 4, nil, nil, nil, nil)
+ objectTypeEnum := BACnetObjectTypeByValue(objectType)
+ if objectType >= 128 || !BACnetObjectTypeKnows(objectType) {
+ objectTypeEnum = BACnetObjectType_VENDOR_PROPRIETARY_VALUE
+ }
+ payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance)
+ var result interface{}
+ result = NewBACnetApplicationTagObjectIdentifier(payload, header)
+ return result.(*BACnetApplicationTagObjectIdentifier)
+}
+
+func CreateBACnetContextTagObjectIdentifier(tagNum uint8, objectType uint16, instance uint32) *BACnetContextTagObjectIdentifier {
+ header := NewBACnetTagHeader(tagNum, TagClass_CONTEXT_SPECIFIC_TAGS, 4, nil, nil, nil, nil)
+ objectTypeEnum := BACnetObjectTypeByValue(objectType)
+ if objectType >= 128 {
+ objectTypeEnum = BACnetObjectType_VENDOR_PROPRIETARY_VALUE
+ }
+ payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance)
+ var result interface{}
+ result = NewBACnetContextTagObjectIdentifier(payload, header, tagNum, true)
+ return result.(*BACnetContextTagObjectIdentifier)
+}
diff --git a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java
index 1390d1b..c9c72b6 100644
--- a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java
+++ b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/readwrite/utils/StaticHelper.java
@@ -345,7 +345,7 @@ public class StaticHelper {
return new BigInteger(data).longValue();
}
- public static BACnetTagHeader newBACnetTagHeaderBalanced(boolean isContext, short id, long value) {
+ public static BACnetTagHeader createBACnetTagHeaderBalanced(boolean isContext, short id, long value) {
TagClass tagClass = TagClass.APPLICATION_TAGS;
if (isContext) {
tagClass = TagClass.CONTEXT_SPECIFIC_TAGS;
@@ -382,4 +382,25 @@ public class StaticHelper {
return new BACnetTagHeader(tagNumber, tagClass, lengthValueType, extTagNumber, extLength, extExtLength, extExtExtLength);
}
+
+ 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);
+ if (objectType >= 128 || !BACnetObjectType.isDefined(objectType)) {
+ objectTypeEnum = BACnetObjectType.VENDOR_PROPRIETARY_VALUE;
+ }
+ BACnetTagPayloadObjectIdentifier payload = new BACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance);
+ return new BACnetApplicationTagObjectIdentifier(header, payload);
+ }
+
+ public static BACnetContextTagObjectIdentifier createBACnetContextTagObjectIdentifier(byte tagNum, int objectType, long instance) {
+ BACnetTagHeader header = new BACnetTagHeader(tagNum, TagClass.CONTEXT_SPECIFIC_TAGS, (byte) 4, null, null, null, null);
+ BACnetObjectType objectTypeEnum = BACnetObjectType.enumForValue(objectType);
+ if (objectType >= 128 || !BACnetObjectType.isDefined(objectType)) {
+ objectTypeEnum = BACnetObjectType.VENDOR_PROPRIETARY_VALUE;
+ }
+ BACnetTagPayloadObjectIdentifier payload = new BACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance);
+ return new BACnetContextTagObjectIdentifier(header, payload, (short) tagNum, true);
+ }
+
}