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

  • Hi all
    I am using BACnet4J in my second project now the first one went well. Thankyou "m" for sharing your work.
    I found a little error .... when removing an object from the local device as follows

    com.serotonin.bacnet4j.LocalDevice
    
    public void removeObject(ObjectIdentifier id) throws BACnetServiceException {
        BACnetObject obj = getObject(id);
        if (obj != null)
            localObjects.remove(obj);
        else
            throw new BACnetServiceException(ErrorClass.object, ErrorCode.unknownObject);
        
        // Remove the reference in the device's object list for this id.
        //dwb change 20090813
        //getObjectList().add(id);
        getObjectList().remove(id);
    
    }
    

    and added the following

    com.serotonin.bacnet4j.type.constructed.SequenceOf
    
    //dwb added 20090813
    import java.util.ListIterator;
    
    //dwb added 20090813
    public void remove(E value) {
     E e;
     for (ListIterator<E> it = values.listIterator(); it.hasNext();  ) {
      e = it.next();
      if (ObjectUtils.isEqual(e, value)) {
       it.remove();
      }
     }
    }
    

    didn't spend a lot of time thinking about above fixed so wouldn't feel sad if someone recomends a better option.


  • Hi Dave,

    Yes, that certainly was a bug. I've applied your fixes with a small difference.

    Your code locates all instances where the given object matches the current object in the list, and shifts all remaining objects on the right one slot to the left to affect the remove. However, the implementation of the remove(int indexBase1) sets the value at the index to null and then trims nulls from the end of the list.

    The remove implementation that i've applied will only remove the first occurrence of a matching object (from left to right), and will remove it by setting it to null (via a call to the remove(int) method, so trimming of nulls on the right will also occur). This is only for consistency sake.

    I've also implemented your original code, but renamed it removeAll(E). The code changes have been checked into the CVS repo. Let me know if this doesn't work for your purposes and we'll figure something out.