Search in sources :

Example 1 with OutputType

use of org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.OutputType in project open-smart-grid-platform by OSGP.

the class OslpChannelHandler method handleSetConfigurationRequest.

private void handleSetConfigurationRequest(final Device device, final Oslp.SetConfigurationRequest setConfigurationRequest) {
    if (setConfigurationRequest.hasPreferredLinkType()) {
        device.setPreferredLinkType(Enum.valueOf(LinkType.class, setConfigurationRequest.getPreferredLinkType().name()));
    }
    if (setConfigurationRequest.hasLightType()) {
        device.setLightType(Enum.valueOf(LightType.class, setConfigurationRequest.getLightType().name()));
    }
    if (setConfigurationRequest.hasRelayConfiguration()) {
        final List<DeviceOutputSetting> outputSettings = new ArrayList<>();
        for (final IndexAddressMap iam : setConfigurationRequest.getRelayConfiguration().getAddressMapList()) {
            final int index = iam.getIndex().byteAt(0);
            final int address = iam.getAddress().byteAt(0);
            final OutputType outputType = OutputType.valueOf(iam.getRelayType().name());
            outputSettings.add(new DeviceOutputSetting(index, address, outputType));
        }
        device.setOutputSettings(outputSettings);
    }
}
Also used : LightType(org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.LightType) ArrayList(java.util.ArrayList) DeviceOutputSetting(org.opensmartgridplatform.webdevicesimulator.domain.entities.DeviceOutputSetting) LinkType(org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.LinkType) IndexAddressMap(org.opensmartgridplatform.oslp.Oslp.IndexAddressMap) OutputType(org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.OutputType)

Aggregations

ArrayList (java.util.ArrayList)1 IndexAddressMap (org.opensmartgridplatform.oslp.Oslp.IndexAddressMap)1 DeviceOutputSetting (org.opensmartgridplatform.webdevicesimulator.domain.entities.DeviceOutputSetting)1 LightType (org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.LightType)1 LinkType (org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.LinkType)1 OutputType (org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.OutputType)1