ReadPropertyMultipleRequest
-
when reading all properties from an object, then all properties defined will be returned.
a bit too much./** * add only defined/implemented properties. * * @param obj * @param results * @param pid * @param pin */ private void addProperty(BACnetObject obj, List<Result> results, PropertyIdentifier pid, UnsignedInteger pin) { if (pid.intValue() == PropertyIdentifier.all.intValue()) { // the properties implemented List<PropertyIdentifier> properties = obj.getProperties(); for (PropertyIdentifier pd : properties) { addProperty(obj, results, pd, pin); } } else if (pid.intValue() == PropertyIdentifier.required.intValue()) { for (PropertyTypeDefinition def : ObjectProperties .getRequiredPropertyTypeDefinitions(obj.getId() .getObjectType())) addProperty(obj, results, def.getPropertyIdentifier(), pin); } else if (pid.intValue() == PropertyIdentifier.optional.intValue()) { for (PropertyTypeDefinition def : ObjectProperties .getOptionalPropertyTypeDefinitions(obj.getId() .getObjectType())) addProperty(obj, results, def.getPropertyIdentifier(), pin); } else { // Get the specified property. try { results.add(new Result(pid, pin, obj.getPropertyRequired(pid, pin))); } catch (BACnetServiceException e) { results.add(new Result(pid, pin, new BACnetError(e .getErrorClass(), e.getErrorCode()))); } } }
in the class BACnetObject we add:
/** * return all implemented properties * * @return */ public List<PropertyIdentifier> getProperties() { ArrayList<PropertyIdentifier> list = new ArrayList<PropertyIdentifier>(); for ( PropertyIdentifier pid : properties.keySet()) { list.add(pid); } return list; }
with this modification only implemented and default properties will be taken into account.
robert
-
The second piece of code is ok, but where should the first go?