Search in sources :

Example 1 with OutputType

use of com.alliander.osgp.webdevicesimulator.domain.valueobjects.OutputType in project Protocol-Adapter-OSLP 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(com.alliander.osgp.webdevicesimulator.domain.valueobjects.LightType) ArrayList(java.util.ArrayList) DeviceOutputSetting(com.alliander.osgp.webdevicesimulator.domain.entities.DeviceOutputSetting) LinkType(com.alliander.osgp.webdevicesimulator.domain.valueobjects.LinkType) IndexAddressMap(com.alliander.osgp.oslp.Oslp.IndexAddressMap) OutputType(com.alliander.osgp.webdevicesimulator.domain.valueobjects.OutputType)

Aggregations

IndexAddressMap (com.alliander.osgp.oslp.Oslp.IndexAddressMap)1 DeviceOutputSetting (com.alliander.osgp.webdevicesimulator.domain.entities.DeviceOutputSetting)1 LightType (com.alliander.osgp.webdevicesimulator.domain.valueobjects.LightType)1 LinkType (com.alliander.osgp.webdevicesimulator.domain.valueobjects.LinkType)1 OutputType (com.alliander.osgp.webdevicesimulator.domain.valueobjects.OutputType)1 ArrayList (java.util.ArrayList)1