use of org.openmuc.framework.config.DriverNotAvailableException in project OpenMUC by isc-konstanz.
the class DataManager method scanForChannels.
@Override
public List<ChannelScanInfo> scanForChannels(String deviceId, String settings) throws DriverNotAvailableException, UnsupportedOperationException, ArgumentSyntaxException, ScanException {
// TODO this function is probably not thread safe
DeviceConfigImpl config = (DeviceConfigImpl) this.rootConfig.getDevice(deviceId);
if (config == null) {
throw new ScanException("No device with ID \"" + deviceId + "\" found.");
}
DriverService activeDriver = activeDrivers.get(config.driverParent.id);
if (activeDriver == null) {
throw new DriverNotAvailableException();
}
waitTilDeviceIsConnected(config.device);
try {
return config.device.connection.scanForChannels(settings);
} catch (ConnectionException e) {
config.device.disconnectedSignal();
throw new ScanException(e.getMessage(), e);
}
}
use of org.openmuc.framework.config.DriverNotAvailableException in project OpenMUC by isc-konstanz.
the class DataManager method interruptDeviceScan.
@Override
public void interruptDeviceScan(String driverId) throws DriverNotAvailableException, UnsupportedOperationException {
DriverService driver = activeDrivers.get(driverId);
if (driver == null) {
throw new DriverNotAvailableException();
}
driver.interruptDeviceScan();
}
use of org.openmuc.framework.config.DriverNotAvailableException in project OpenMUC by isc-konstanz.
the class RestDriverWrapper method getDriver.
public static RestDriverWrapper getDriver(DriverConfig config, ConfigService configService, DataAccessService data) {
boolean running;
DriverInfo driver;
try {
driver = configService.getDriverInfo(config.getId());
running = true;
} catch (DriverNotAvailableException e) {
driver = new DriverInfo(config.getId(), null, null, null, null, null);
running = false;
}
List<RestDevice> devices = new LinkedList<RestDevice>();
for (DeviceConfig device : config.getDevices()) {
List<RestChannel> channels = new LinkedList<RestChannel>();
for (ChannelConfig channel : device.getChannels()) {
channels.add(RestChannelMapper.getRestChannel(data.getChannel(channel.getId())));
}
devices.add(RestDeviceMapper.getRestDevice(device, configService.getDeviceState(device.getId()), channels));
}
return new RestDriverWrapper(config, driver, devices, running);
}
use of org.openmuc.framework.config.DriverNotAvailableException in project OpenMUC by isc-konstanz.
the class DeviceResourceServlet method scanForAllChannels.
private List<ChannelScanInfo> scanForAllChannels(String deviceId, String settings, HttpServletResponse response) {
List<ChannelScanInfo> channelList = new ArrayList<>();
List<ChannelScanInfo> scannedDevicesList;
try {
scannedDevicesList = configService.scanForChannels(deviceId, settings);
for (ChannelScanInfo scannedDevice : scannedDevicesList) {
channelList.add(scannedDevice);
}
} catch (UnsupportedOperationException e) {
ServletLib.sendHTTPErrorAndLogDebug(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, logger, "Device does not support scanning.", REST_ID, deviceId);
} catch (DriverNotAvailableException e) {
ServletLib.sendHTTPErrorAndLogDebug(response, HttpServletResponse.SC_NOT_FOUND, logger, REQUESTED_ID_IS_NOT_AVAILABLE, REST_ID, deviceId);
} catch (ArgumentSyntaxException e) {
ServletLib.sendHTTPErrorAndLogDebug(response, HttpServletResponse.SC_NOT_ACCEPTABLE, logger, "Argument syntax was wrong.", REST_ID, deviceId, " Settings = ", settings);
} catch (ScanException e) {
ServletLib.sendHTTPErrorAndLogDebug(response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, logger, "Error while scan device channels", REST_ID, deviceId, " Settings = ", settings);
}
return channelList;
}
use of org.openmuc.framework.config.DriverNotAvailableException in project OpenMUC by isc-konstanz.
the class RestDeviceWrapper method getDevice.
public static RestDeviceWrapper getDevice(DeviceConfig config, ConfigService configService, DataAccessService data) {
String driverId = config.getDriver().getId();
DriverInfo driver;
try {
driver = configService.getDriverInfo(driverId);
} catch (DriverNotAvailableException e) {
driver = new DriverInfo(driverId, null, null, null, null, null);
}
List<RestChannel> channels = new LinkedList<RestChannel>();
for (ChannelConfig channelConfig : config.getChannels()) {
channels.add(RestChannelMapper.getRestChannel(data.getChannel(channelConfig.getId())));
}
return new RestDeviceWrapper(config, configService.getDeviceState(config.getId()), driver, channels);
}
Aggregations