Bug in Destination/DaysOfWeek class
-
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.