• D
    Daniel McKinnell

    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;
        }
    

    posted in BACnet4J general discussion read more
  • D
    Daniel McKinnell

    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.

    posted in BACnet4J general discussion read more
  • D
    Daniel McKinnell

    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.

    posted in BACnet4J general discussion read more