Search in sources :

Example 1 with RelayConfiguration

use of com.alliander.osgp.oslp.Oslp.RelayConfiguration in project Protocol-Adapter-OSLP by OSGP.

the class OslpChannelHandler method createRelayConfiguration.

/**
 * Create relay configuration based on stored configuration values.
 */
private static RelayConfiguration createRelayConfiguration(final List<DeviceOutputSetting> outputSettings) {
    final RelayConfiguration.Builder configuration = RelayConfiguration.newBuilder();
    for (final DeviceOutputSetting dos : outputSettings) {
        final IndexAddressMap.Builder relayMap = IndexAddressMap.newBuilder().setIndex(OslpUtils.integerToByteString(dos.getInternalId())).setAddress(OslpUtils.integerToByteString(dos.getExternalId()));
        // Map device-simulator enum OutputType to OSLP enum RelayType
        if (dos.getOutputType() == OutputType.LIGHT) {
            relayMap.setRelayType(RelayType.LIGHT);
        } else if (dos.getOutputType() == OutputType.TARIFF) {
            relayMap.setRelayType(RelayType.TARIFF);
        } else {
            relayMap.setRelayType(RelayType.RT_NOT_SET);
        }
        configuration.addAddressMap(relayMap);
    }
    return configuration.build();
}
Also used : RelayConfiguration(com.alliander.osgp.oslp.Oslp.RelayConfiguration) DeviceOutputSetting(com.alliander.osgp.webdevicesimulator.domain.entities.DeviceOutputSetting) IndexAddressMap(com.alliander.osgp.oslp.Oslp.IndexAddressMap)

Aggregations

IndexAddressMap (com.alliander.osgp.oslp.Oslp.IndexAddressMap)1 RelayConfiguration (com.alliander.osgp.oslp.Oslp.RelayConfiguration)1 DeviceOutputSetting (com.alliander.osgp.webdevicesimulator.domain.entities.DeviceOutputSetting)1