Trying to fix consistent netscan pings
This commit is contained in:
parent
2b5182b56a
commit
dd163a797e
1 changed files with 5 additions and 6 deletions
|
|
@ -69,15 +69,14 @@ public class NetScanController implements HalEventController, HalAutoScannableCo
|
||||||
SwitchEventData prevData = entry.getValue();
|
SwitchEventData prevData = entry.getValue();
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
//logger.finest("Pinging IP "+ device.getHost());
|
//logger.finest("Pinging IP "+ device.getHost());
|
||||||
SwitchEventData newData = new SwitchEventData(
|
boolean ping1 = InetScanner.isReachable(device.getHost(), executor);
|
||||||
InetScanner.isReachable(device.getHost(), executor),
|
boolean ping2 = InetScanner.isReachable(device.getHost(), executor);
|
||||||
System.currentTimeMillis());
|
|
||||||
entry.setValue(newData);
|
|
||||||
|
|
||||||
// Should we report?
|
// Should we report?
|
||||||
if (prevData == null ||
|
if (prevData == null ||
|
||||||
(!prevData.isOn() && newData.isOn()) ||
|
(ping1 == ping2 && prevData.isOn() != ping1)) { // only store if we get consistent pings
|
||||||
(!prevData.isOn() && !newData.isOn()) ) { // require two off measurements to report off
|
SwitchEventData newData = new SwitchEventData(ping1, System.currentTimeMillis());
|
||||||
|
entry.setValue(newData);
|
||||||
logger.fine("IP "+device.getHost() +" state has changed to "+ newData.isOn());
|
logger.fine("IP "+device.getHost() +" state has changed to "+ newData.isOn());
|
||||||
listener.reportReceived(device, newData);
|
listener.reportReceived(device, newData);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue