use of com.alliander.osgp.oslp.Oslp.IndexAddressMap 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);
}
}
use of com.alliander.osgp.oslp.Oslp.IndexAddressMap in project Protocol-Adapter-OSLP by OSGP.
the class RelayConfigurationToOslpRelayConfigurationConverter method convertFrom.
@Override
public RelayConfigurationDto convertFrom(final com.alliander.osgp.oslp.Oslp.RelayConfiguration source, final Type<RelayConfigurationDto> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final List<RelayMapDto> indexAddressMap = new ArrayList<RelayMapDto>();
for (final IndexAddressMap entry : source.getAddressMapList()) {
// Map OSLP RT_NOT_SET to null
indexAddressMap.add(new RelayMapDto(this.mapperFacade.map(entry.getIndex(), Integer.class), this.mapperFacade.map(entry.getAddress(), Integer.class), entry.hasRelayType() && entry.getRelayType() != Oslp.RelayType.RT_NOT_SET ? this.mapperFacade.map(entry.getRelayType(), RelayTypeDto.class) : null, null));
}
final List<RelayMapDto> relayMaps = new ArrayList<RelayMapDto>();
return new RelayConfigurationDto(!indexAddressMap.isEmpty() ? indexAddressMap : relayMaps);
}
use of com.alliander.osgp.oslp.Oslp.IndexAddressMap in project Protocol-Adapter-OSLP by OSGP.
the class DaliConfigurationToOslpDaliConfigurationConverter method convertFrom.
@Override
public DaliConfigurationDto convertFrom(final com.alliander.osgp.oslp.Oslp.DaliConfiguration source, final Type<DaliConfigurationDto> destinationType, final MappingContext context) {
if (source == null) {
return null;
}
final Map<Integer, Integer> indexAddressMap = new HashMap<Integer, Integer>();
for (final IndexAddressMap entry : source.getAddressMapList()) {
indexAddressMap.put(this.mapperFacade.map(entry.getIndex(), Integer.class), this.mapperFacade.map(entry.getAddress(), Integer.class));
}
final Integer numberOfLights = Integer.valueOf(0);
final Map<Integer, Integer> adresMap = new HashMap<Integer, Integer>();
return new DaliConfigurationDto(source.hasNumberOfLights() ? this.mapperFacade.map(source.getNumberOfLights(), Integer.class) : numberOfLights, !indexAddressMap.isEmpty() ? indexAddressMap : adresMap);
}
Aggregations