当前位置: 首页>>代码示例>>Java>>正文


Java ScanRange类代码示例

本文整理汇总了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;
}
   }
 
开发者ID:evercam,项目名称:evercam-discovery-java,代码行数:23,代码来源:EvercamDiscover.java

示例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);
}
   }
 
开发者ID:evercam,项目名称:evercam-discovery-java,代码行数:76,代码来源:Main.java

示例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());
   }
 
开发者ID:evercam,项目名称:evercam-discovery-java,代码行数:6,代码来源:ScanRangeTest.java

示例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"));
   }
 
开发者ID:evercam,项目名称:evercam-discovery-java,代码行数:7,代码来源:IpScanTest.java


注:本文中的io.evercam.network.discovery.ScanRange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。