Skip to content

Commit

Permalink
fix(bacnet): only supply proprietary value to objects...
Browse files Browse the repository at this point in the history
... if they are indeed proprietary
  • Loading branch information
sruehl committed Apr 19, 2022
1 parent 4b151e3 commit 1947a2a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 9 additions & 3 deletions plc4go/internal/plc4go/bacnetip/readwrite/model/StaticHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,32 +351,38 @@ func CreateBACnetTagHeaderBalanced(isContext bool, id uint8, value uint32) *BACn
func CreateBACnetApplicationTagObjectIdentifier(objectType uint16, instance uint32) *BACnetApplicationTagObjectIdentifier {
header := NewBACnetTagHeader(0xC, TagClass_APPLICATION_TAGS, uint8(4), nil, nil, nil, nil)
objectTypeEnum := BACnetObjectTypeByValue(objectType)
proprietaryValue := uint16(0)
if objectType >= 128 || !BACnetObjectTypeKnows(objectType) {
objectTypeEnum = BACnetObjectType_VENDOR_PROPRIETARY_VALUE
proprietaryValue = objectType
}
payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance)
payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, proprietaryValue, instance)
result := NewBACnetApplicationTagObjectIdentifier(payload, header)
return CastBACnetApplicationTagObjectIdentifier(result)
}

func CreateBACnetContextTagObjectIdentifier(tagNum uint8, objectType uint16, instance uint32) *BACnetContextTagObjectIdentifier {
header := NewBACnetTagHeader(tagNum, TagClass_CONTEXT_SPECIFIC_TAGS, uint8(4), nil, nil, nil, nil)
objectTypeEnum := BACnetObjectTypeByValue(objectType)
proprietaryValue := uint16(0)
if objectType >= 128 {
objectTypeEnum = BACnetObjectType_VENDOR_PROPRIETARY_VALUE
proprietaryValue = objectType
}
payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance)
payload := NewBACnetTagPayloadObjectIdentifier(objectTypeEnum, proprietaryValue, instance)
result := NewBACnetContextTagObjectIdentifier(payload, header, tagNum, true)
return CastBACnetContextTagObjectIdentifier(result)
}

func CreateBACnetContextTagPropertyIdentifier(tagNum uint8, propertyType uint32) *BACnetContextTagPropertyIdentifier {
header := NewBACnetTagHeader(tagNum, TagClass_CONTEXT_SPECIFIC_TAGS, uint8(requiredLength(uint(propertyType))), nil, nil, nil, nil)
propertyTypeEnum := BACnetPropertyIdentifierByValue(propertyType)
proprietaryValue := uint32(0)
if !BACnetPropertyIdentifierKnows(propertyType) {
propertyTypeEnum = BACnetPropertyIdentifier_VENDOR_PROPRIETARY_VALUE
proprietaryValue = uint32(0)
}
result := NewBACnetContextTagPropertyIdentifier(propertyTypeEnum, propertyType, header, tagNum, true, 0)
result := NewBACnetContextTagPropertyIdentifier(propertyTypeEnum, proprietaryValue, header, tagNum, true, 0)
return CastBACnetContextTagPropertyIdentifier(result)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,30 +391,36 @@ public static BACnetTagHeader createBACnetTagHeaderBalanced(boolean isContext, s
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);
int proprietaryValue = 0;
if (objectType >= 128 || !BACnetObjectType.isDefined(objectType)) {
objectTypeEnum = BACnetObjectType.VENDOR_PROPRIETARY_VALUE;
proprietaryValue = objectType;
}
BACnetTagPayloadObjectIdentifier payload = new BACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance);
BACnetTagPayloadObjectIdentifier payload = new BACnetTagPayloadObjectIdentifier(objectTypeEnum, proprietaryValue, 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);
int proprietaryValue = 0;
if (objectType >= 128 || !BACnetObjectType.isDefined(objectType)) {
objectTypeEnum = BACnetObjectType.VENDOR_PROPRIETARY_VALUE;
proprietaryValue = objectType;
}
BACnetTagPayloadObjectIdentifier payload = new BACnetTagPayloadObjectIdentifier(objectTypeEnum, objectType, instance);
BACnetTagPayloadObjectIdentifier payload = new BACnetTagPayloadObjectIdentifier(objectTypeEnum, proprietaryValue, instance);
return new BACnetContextTagObjectIdentifier(header, payload, (short) tagNum, true);
}

public static BACnetContextTagPropertyIdentifier createBACnetContextTagPropertyIdentifier(byte tagNum, int propertyType) {
BACnetPropertyIdentifier propertyIdentifier = BACnetPropertyIdentifier.enumForValue(propertyType);
int proprietaryValue = 0;
if (!BACnetPropertyIdentifier.isDefined(propertyType)) {
propertyIdentifier = BACnetPropertyIdentifier.VENDOR_PROPRIETARY_VALUE;
proprietaryValue = propertyType;
}
BACnetTagHeader header = new BACnetTagHeader(tagNum, TagClass.CONTEXT_SPECIFIC_TAGS, (byte) requiredLength(propertyType), null, null, null, null);
return new BACnetContextTagPropertyIdentifier(header, propertyIdentifier, propertyType, (short) tagNum, true, 0L);
return new BACnetContextTagPropertyIdentifier(header, propertyIdentifier, proprietaryValue, (short) tagNum, true, 0L);
}

public static BACnetApplicationTagEnumerated createBACnetApplicationTagEnumerated(long value) {
Expand Down

0 comments on commit 1947a2a

Please sign in to comment.