use of org.openmuc.framework.config.DriverInfo 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.DriverInfo in project OpenMUC by isc-konstanz.
the class DriverTest method printDriverInfo.
@Test
public void printDriverInfo() {
ModbusDriver driver = new ModbusDriver();
DriverInfo info = driver.getInfo();
StringBuilder sb = new StringBuilder();
sb.append("\n");
sb.append("Driver Id = " + info.getId() + "\n");
sb.append("Description = " + info.getDescription() + "\n");
sb.append("DeviceAddressSyntax = " + info.getDevice().getAddressSyntax() + "\n");
sb.append("DeviceSettingsSyntax = " + info.getDevice().getSettingsSyntax() + "\n");
sb.append("ChannelAddressSyntax = " + info.getChannel().getAddressSyntax() + "\n");
logger.info(sb.toString());
}
use of org.openmuc.framework.config.DriverInfo in project OpenMUC by isc-konstanz.
the class DriverInfoTest method printDriverInfo.
@Test
public void printDriverInfo() {
CsvDriver driver = new CsvDriver();
DriverInfo info = driver.getInfo();
System.out.println("Id: " + info.getId());
System.out.println("Description: " + info.getDescription());
System.out.println("DeviceAddressSyntax: " + info.getDevice().getAddressSyntax());
System.out.println("DeviceSettingsSyntax: " + info.getDevice().getSettingsSyntax());
System.out.println("DeviceScanSettingsSyntax: " + info.getDevice().getScanSettingsSyntax());
System.out.println("ChannelAddressSyntax: " + info.getChannel().getAddressSyntax());
}
use of org.openmuc.framework.config.DriverInfo in project OpenMUC by isc-konstanz.
the class ToJson method addDriverInfoList.
public void addDriverInfoList(List<DriverInfo> infoList) {
JsonArray jsa = new JsonArray();
for (DriverInfo driverInfo : infoList) {
RestDriverInfo restDriverDesc = RestDriverMapper.getRestDriverDescription(driverInfo);
jsa.add(gson.toJsonTree(restDriverDesc, RestDriverInfo.class).getAsJsonObject());
}
jsonObject.add(Const.DRIVERS, jsa);
}
use of org.openmuc.framework.config.DriverInfo 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