本文整理匯總了Java中io.evercam.network.discovery.ScanRange類的典型用法代碼示例。如果您正苦於以下問題:Java ScanRange類的具體用法?Java ScanRange怎麽用?Java ScanRange使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ScanRange類屬於io.evercam.network.discovery包,在下文中一共展示了ScanRange類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: discardOnvifDeviceIfNotInScanRange
import io.evercam.network.discovery.ScanRange; //導入依賴的package包/類
private void discardOnvifDeviceIfNotInScanRange(ScanRange scanRange) {
@SuppressWarnings("unchecked")
ArrayList<DiscoveredCamera> clonedList = (ArrayList<DiscoveredCamera>) onvifDeviceList
.clone();
if (onvifDeviceList.size() > 0) {
for (DiscoveredCamera discoveredCamera : onvifDeviceList) {
try {
if (!scanRange.containIp(discoveredCamera.getIP())) {
EvercamDiscover
.printLogMessage("Removing ONVIF device: "
+ discoveredCamera.getIP());
clonedList.remove(discoveredCamera);
}
} catch (Exception e) {
if (Constants.ENABLE_LOGGING) {
e.printStackTrace();
}
}
}
onvifDeviceList = clonedList;
}
}
示例2: main
import io.evercam.network.discovery.ScanRange; //導入依賴的package包/類
/**
* Discover all cameras in local network and print them in console
*
* @param args
* pass parameter -v/--verbose to enable verbose logging
*/
public static void main(String[] args) {
String ip = "";
String subnetMask = "";
if (args.length > 0) {
List<String> argsArray = Arrays.asList(args);
if (argsArray.contains("-v") || argsArray.contains("--verbose")) {
Constants.ENABLE_LOGGING = true;
}
if (argsArray.contains(ARG_IP)
&& argsArray.contains(ARG_SUBNET_MASK)) {
int ipIndex = argsArray.indexOf(ARG_IP) + 1;
int subnetIndex = argsArray.indexOf(ARG_SUBNET_MASK) + 1;
ip = argsArray.get(ipIndex);
subnetMask = argsArray.get(subnetIndex);
}
}
if (ip.isEmpty())
ip = NetworkInfo.getLinuxRouterIp();
if (subnetMask.isEmpty())
subnetMask = NetworkInfo.getLinuxSubnetMask();
// String deviceIp = "";
// String subnetMask = "";
// try
// {
// NetworkInterface networkInterface =
// NetworkInfo.getNetworkInterfaceByName("wlan0");
// deviceIp = NetworkInfo.getIpFromInterface(networkInterface);
// subnetMask =
// IpTranslator.cidrToMask(NetworkInfo.getCidrFromInterface(networkInterface));
// }
// catch (Exception e)
// {
// // TODO: handle exception
// }
EvercamDiscover.printLogMessage("Router IP address: " + ip
+ " subnet mask: " + subnetMask);
EvercamDiscover.printLogMessage("Scanning...");
try {
ScanRange scanRange = new ScanRange(ip, subnetMask);
DiscoveryResult discoveryResult = new EvercamDiscover()
.withDefaults(true).discoverAllLinux(scanRange);
ArrayList<DiscoveredCamera> cameraList = discoveryResult
.getCameras();
ArrayList<Device> nonCameraList = discoveryResult.getOtherDevices();
EvercamDiscover.printLogMessage("Scanning finished, found "
+ cameraList.size() + " cameras and "
+ nonCameraList.size() + " other devices.");
printAsJson(cameraList, nonCameraList);
EvercamDiscover.printLogMessage("On normal completion: 0");
System.exit(0);
} catch (Exception e) {
if (Constants.ENABLE_LOGGING) {
e.printStackTrace();
}
EvercamDiscover.printLogMessage("On error: 1");
System.exit(1);
}
}
示例3: testSetRangeByIpAndMask
import io.evercam.network.discovery.ScanRange; //導入依賴的package包/類
@Test
public void testSetRangeByIpAndMask() throws Exception {
ScanRange scanRange = new ScanRange(TEST_IP, TEST_MASK);
assertEquals(TEST_RANGE_SIZE, scanRange.size());
}
示例4: testScanRange
import io.evercam.network.discovery.ScanRange; //導入依賴的package包/類
@Test
public void testScanRange() throws Exception {
ScanRange scanRange = new ScanRange(TEST_IP, TEST_NET_MASK);
assertTrue(scanRange.containIp(TEST_ACTIVE_IP));
assertFalse(scanRange.containIp("192.168.1.6"));
}