use of com.alliander.osgp.dto.valueobjects.PsldDataDto in project Protocol-Adapter-OSLP by OSGP.
the class PowerUsageDataConverter method convertFrom.
@Override
public PowerUsageDataDto convertFrom(final Oslp.PowerUsageData source, final Type<PowerUsageDataDto> destinationType, final MappingContext context) {
// Check the input parameter.
if (source == null) {
return null;
}
// Parse the time stamp.
final DateTime recordTime = this.mapperFacade.map(source.getRecordTime(), DateTime.class);
// Get the other values.
final MeterTypeDto meterType = MeterTypeDto.valueOf(source.getMeterType().name());
final long totalConsumedEnergy = source.getTotalConsumedEnergy();
final long actualConsumedPower = source.getActualConsumedPower();
// Construct PowerUsageData instance.
final PowerUsageDataDto powerUsageData = new PowerUsageDataDto(recordTime, meterType, totalConsumedEnergy, actualConsumedPower);
// Check SsldData.
if (source.getSsldData() != null) {
final Oslp.SsldData oslpSsldData = source.getSsldData();
// Map the RelayData list.
final List<RelayDataDto> list = this.mapperFacade.mapAsList(oslpSsldData.getRelayDataList(), RelayDataDto.class);
// Construct SsldData instance using the RelayData list and the
// other values.
final SsldDataDto ssldData = SsldDataDto.newBuilder().withActualCurrent1(oslpSsldData.getActualCurrent1()).withActualCurrent2(oslpSsldData.getActualCurrent2()).withActualCurrent3(oslpSsldData.getActualCurrent3()).withActualPower1(oslpSsldData.getActualPower1()).withActualPower2(oslpSsldData.getActualPower2()).withActualPower3(oslpSsldData.getActualPower3()).withAveragePowerFactor1(oslpSsldData.getAveragePowerFactor1()).withAveragePowerFactor2(oslpSsldData.getAveragePowerFactor2()).withAveragePowerFactor3(oslpSsldData.getAveragePowerFactor3()).withRelayData(list).build();
// Set SsldData instance in the PowerUsageData instance.
powerUsageData.setSsldData(ssldData);
}
// Check PsldData.
if (source.getPsldData() != null) {
final Oslp.PsldData oslpPsldData = source.getPsldData();
// Construct PsldData instance using the value.
final PsldDataDto psldData = new PsldDataDto(oslpPsldData.getTotalLightingHours());
// Set PsldData instance in the PowerUsageData instance.
powerUsageData.setPsldData(psldData);
}
return powerUsageData;
}
Aggregations