• Recent
    • Tags
    • Popular
    • Register
    • Login

    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.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Request list of object properties

    BACnet4J general discussion
    2
    5
    2.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Daniel McKinnell
      last edited by 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.

      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • D
          Daniel McKinnell
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by

            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?)

            1 Reply Last reply Reply Quote 1
            • D
              Daniel McKinnell
              last edited by 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;
                  }
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post