Search in sources :

Example 1 with DriverInfo

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);
}
Also used : ChannelConfig(org.openmuc.framework.config.ChannelConfig) DriverNotAvailableException(org.openmuc.framework.config.DriverNotAvailableException) DeviceConfig(org.openmuc.framework.config.DeviceConfig) DriverInfo(org.openmuc.framework.config.DriverInfo) LinkedList(java.util.LinkedList)

Example 2 with DriverInfo

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());
}
Also used : ModbusDriver(org.openmuc.framework.driver.modbus.ModbusDriver) DriverInfo(org.openmuc.framework.config.DriverInfo) Test(org.junit.jupiter.api.Test)

Example 3 with DriverInfo

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());
}
Also used : DriverInfo(org.openmuc.framework.config.DriverInfo) CsvDriver(org.openmuc.framework.driver.csv.CsvDriver) Test(org.junit.Test)

Example 4 with DriverInfo

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);
}
Also used : JsonArray(com.google.gson.JsonArray) RestDriverInfo(org.openmuc.framework.lib.rest.objects.RestDriverInfo) DriverInfo(org.openmuc.framework.config.DriverInfo) RestDriverInfo(org.openmuc.framework.lib.rest.objects.RestDriverInfo)

Example 5 with DriverInfo

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);
}
Also used : ChannelConfig(org.openmuc.framework.config.ChannelConfig) DriverNotAvailableException(org.openmuc.framework.config.DriverNotAvailableException) DriverInfo(org.openmuc.framework.config.DriverInfo) LinkedList(java.util.LinkedList)

Aggregations

DriverInfo (org.openmuc.framework.config.DriverInfo)5 LinkedList (java.util.LinkedList)2 ChannelConfig (org.openmuc.framework.config.ChannelConfig)2 DriverNotAvailableException (org.openmuc.framework.config.DriverNotAvailableException)2 JsonArray (com.google.gson.JsonArray)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1 DeviceConfig (org.openmuc.framework.config.DeviceConfig)1 CsvDriver (org.openmuc.framework.driver.csv.CsvDriver)1 ModbusDriver (org.openmuc.framework.driver.modbus.ModbusDriver)1 RestDriverInfo (org.openmuc.framework.lib.rest.objects.RestDriverInfo)1