• 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

    Bug in Destination/DaysOfWeek class

    BACnet4J general discussion
    1
    1
    1.4k
    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.
    • J
      joolz
      last edited by

      There is a bug in the way the Destination class determines whether or not the specified timestamp falls on a valid day.

      In com.serotonin.bacnet4j.type.constructed.Destination.java:

      public boolean isSuitableForEvent(TimeStamp timeStamp, EventState toState) {
          // Only check date fields if the timestamp is not a sequence number.
          if (!timeStamp.isSequenceNumber()) {
              // Check if the timestamp day of week is in the valid days of week list.
              if (!validDays.contains(timeStamp.getDateTime().getDate().getDayOfWeek().getId()))
                  return false;
      
              // Check if the timestamp is between the from and to times.
              if (timeStamp.getDateTime().getTime().before(fromTime) || timeStamp.getDateTime().getTime().after(toTime))
                  return false;
          }
      
          // Check if the destination is interested in this new event state.
          return transitions.contains(toState);
      }
      

      and com.serotonin.bacnet4j.type.constructed.DaysOfWeek.java

      public boolean contains(int day) {
          return getValue()[day];
      }
      

      timeStamp.getDateTime().getDate().getDayOfWeek().getId() returns a number from 1-7
      However, the DaysOfWeek class stores the days in a 0 indexed array 0-6, which means the wrong index is checked every time this function is called.

      1 Reply Last reply Reply Quote 0
      • First post
        Last post