本文整理汇总了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"));
}