Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
Request list of object properties
-
I'm trying to get a list of all the properties defined in an object on a remote device.
RequestUtils.getProperty( localDevice, remoteDevice, AnalogInRef, PropertyIdentifier.propertyList);
But it just throws and returns
com.serotonin.bacnet4j.exception.BACnetErrorException: device: other at com.serotonin.bacnet4j.util.RequestUtils.getProperty(RequestUtils.java:104) at test.main(test.java:101)
Same for PropertyIdentifier.listOfObjectPropertyReferences
So I am not sure how to go about this.
I'm using YABE (Yet Another BACnet Explorer) to run a simulator. -
Hi Daniel, welcome to the forum!
Hmm, I don't recognize that BACnetErrorException message's meaning. I'd have to guess it doesn't have the property on the object? Is there a reason try-catching when you figure out what properties will work on that device isn't the solution?
-
I was hoping there was a simple way to just get the objects property list since there are nearly 500 defined properties making try-catching a bit inefficient.
When using YABE I noticed how when you view a devices object it lists only the properties it has instead of a defined list of the same properties for every object of that type. -
Have you seen the ObjectProperties class? It would at least narrow down what properties typically exist on an object type, https://github.com/infiniteautomation/BACnet4J/blob/master/src/main/java/com/serotonin/bacnet4j/obj/ObjectProperties.java
But no, I do not think there is a simple way to get the list of properties supported by an object other than reading its propertyList property (which wasn't working in your initial post, although perhaps the reason is other than there isn't such a property on that object?)
-
Wish I knew about that before! Thanks heaps for the reference.
Gonna put my function here for any future references too. Feel free to point out any improvements.public Map<PropertyIdentifier, Encodable> getObjectPropertyListNotNull(RemoteDevice d, ObjectIdentifier obj) throws BACnetException{ List<ObjectPropertyTypeDefinition> propsDefs = ObjectProperties.getObjectPropertyTypeDefinitions(obj.getObjectType()); ArrayList<PropertyIdentifier> props = new ArrayList<PropertyIdentifier>(propsDefs.size()); Map<PropertyIdentifier, Encodable> propValuesFinal = new HashMap<>(); for(ObjectPropertyTypeDefinition prop : propsDefs){props.add(prop.getPropertyTypeDefinition().getPropertyIdentifier());} if(d.getObject(obj) == null){ Map<PropertyIdentifier, Encodable> propValues = RequestUtils.getProperties(localDevice, d, obj, null, props.toArray(new PropertyIdentifier[props.size()])); propValues.forEach((pid, val) -> { if(val instanceof ErrorClassAndCode) return; propValuesFinal.put(pid, val); d.setObjectProperty(obj, pid, val); }); } else{ for(PropertyIdentifier pid : props){ Encodable val = d.getObject(obj).getProperty(pid); if(val != null){ propValuesFinal.put(pid, val); } } } return propValuesFinal; }