Skip to content

Commit

Permalink
Default timeout to transport timeout when given value is 0.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlohbihler committed Jun 2, 2017
1 parent db4c98b commit aa577fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/main/java/com/serotonin/bacnet4j/LocalDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,13 @@ public LocalDevice withNumberOfApduRetries(final UnsignedInteger numberOfApduRet
return this;
}

/**
* Returns the currently configured timeout in ms within the transport.
*/
public int getTransportTimeout() {
return transport.getTimeout();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Local object management
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/serotonin/bacnet4j/util/PropertyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public static DeviceObjectPropertyValues readProperties(final LocalDevice localD
*/
public static DeviceObjectPropertyValues readProperties(final LocalDevice localDevice,
final DeviceObjectPropertyReferences refs, final ReadListener callback, final long deviceTimeout) {
final long timeoutToUse;
if (deviceTimeout <= 0) {
timeoutToUse = localDevice.getTransportTimeout();
} else {
timeoutToUse = deviceTimeout;
}

final DeviceObjectPropertyValues result = new DeviceObjectPropertyValues();

final Map<Integer, PropertyReferences> properties = refs.getProperties();
Expand Down Expand Up @@ -156,7 +163,7 @@ public static DeviceObjectPropertyValues readProperties(final LocalDevice localD
if (rd == null) {
// Initiate a device lookup
runnable = () -> {
requestPropertiesFromDevice(localDevice, deviceId, deviceTimeout, propRefs, callback, result,
requestPropertiesFromDevice(localDevice, deviceId, timeoutToUse, propRefs, callback, result,
completedProperties, totalProperties);
};
} else {
Expand All @@ -169,7 +176,7 @@ public static DeviceObjectPropertyValues readProperties(final LocalDevice localD
// The cached device appears to be offline. Remove it from the cache, and try discovering it
// again in case its address changed.
localDevice.removeCachedRemoteDevice(deviceId);
requestPropertiesFromDevice(localDevice, deviceId, deviceTimeout, propRefs, callback, result,
requestPropertiesFromDevice(localDevice, deviceId, timeoutToUse, propRefs, callback, result,
completedProperties, totalProperties);
}
};
Expand Down

0 comments on commit aa577fc

Please sign in to comment.