use of org.openmuc.framework.driver.spi.DriverDeviceScanListener in project OpenMUC by isc-konstanz.
the class DriverTest method testInterrupedException.
@Test(expected = ScanInterruptedException.class)
public void testInterrupedException() throws Exception {
final Driver mdriver = new Driver();
DriverDeviceScanListener ddsl = mock(DriverDeviceScanListener.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
mdriver.interruptDeviceScan();
return null;
}
}).when(ddsl).deviceFound(any(DeviceScanInfo.class));
MBusConnection con = mock(MBusConnection.class);
when(con.read(anyInt())).thenReturn(new VariableDataStructure(null, 0, 0, null, null));
whenNew(MBusConnection.class).withAnyArguments().thenReturn(con);
doNothing().when(con).linkReset(ArgumentMatchers.anyInt());
PowerMockito.when(con.read(ArgumentMatchers.anyInt())).thenReturn(null);
mdriver.scanForDevices("/dev/ttyS100:2400", ddsl);
}
use of org.openmuc.framework.driver.spi.DriverDeviceScanListener in project OpenMUC by isc-konstanz.
the class CsvScanDeviceTest method testDeviceScan.
@Test
public void testDeviceScan() throws ArgumentSyntaxException, UnsupportedOperationException, ScanException, ScanInterruptedException {
CsvDriver csvDriver = new CsvDriver();
String settings = "path=" + dir + "/src/test/resources";
csvDriver.scanForDevices(settings, new DriverDeviceScanListener() {
@Override
public void scanProgressUpdate(int progress) {
System.out.println("Scan progress: " + progress + " %");
}
@Override
public void deviceFound(DeviceScanInfo scanInfo) {
System.out.println(scanInfo.toString());
}
});
}
use of org.openmuc.framework.driver.spi.DriverDeviceScanListener in project OpenMUC by isc-konstanz.
the class SnmpScannerExample method main.
/**
* @param args
*/
public static void main(String[] args) {
SnmpDriver myDriver = new SnmpDriver();
String settings = SnmpDriverSettingVariableNames.AUTHENTICATIONPASSPHRASE + "=adminadmin:" + SnmpDriverScanSettingVariableNames.STARTIP + "=192.168.1.0:" + SnmpDriverScanSettingVariableNames.ENDIP + "=192.168.10.0";
class TestListener implements DriverDeviceScanListener {
@Override
public void scanProgressUpdate(int progress) {
}
@Override
public void deviceFound(DeviceScanInfo device) {
System.out.println("-----------------------------");
System.out.println("New device found: ");
System.out.println("Address: " + device.getAddress());
System.out.println("Description: " + device.getDescription());
System.out.println("-----------------------------");
}
}
;
TestListener listener = new TestListener();
try {
myDriver.scanForDevices(settings, listener);
Thread.sleep(100);
} catch (InterruptedException iex) {
System.out.println("Request cancelled: " + iex.getMessage());
} catch (ArgumentSyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ScanException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ScanInterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations