Search in sources :

Example 1 with W1Device

use of com.pi4j.io.w1.W1Device in project OpenMUC by isc-konstanz.

the class W1Scanner method scan.

@Override
public void scan(DriverDeviceScanListener listener) throws ArgumentSyntaxException, ScanException, ScanInterruptedException {
    logger.info("Scan for 1-Wire devices connected to the Raspberry Pi platform.");
    interrupt = false;
    int size = devices.size();
    if (size > 0) {
        logger.debug("Scan discovered {} 1-Wire devices: {}", size, devices.toString());
        int counter = 1;
        for (com.pi4j.io.w1.W1Device device : devices) {
            if (interrupt) {
                break;
            }
            String id = device.getId().trim().replace("\n", "").replace("\r", "");
            if (!ignore || !connected.contains(id)) {
                String name = device.getClass().getSimpleName();
                W1Type type = W1Type.valueOf(device);
                String scanSettings = "type:" + type.name();
                listener.deviceFound(new DeviceScanInfo(name.toLowerCase() + "_" + id, id, scanSettings, "1-Wire " + type.getName() + ": " + name));
            }
            listener.scanProgressUpdate((int) Math.round(counter / (double) size * 100));
            counter++;
        }
    } else
        logger.debug("Scan discovered no 1-Wire devices");
}
Also used : DeviceScanInfo(org.openmuc.framework.config.DeviceScanInfo) W1Device(com.pi4j.io.w1.W1Device)

Aggregations

W1Device (com.pi4j.io.w1.W1Device)1 DeviceScanInfo (org.openmuc.framework.config.DeviceScanInfo)1