Search in sources :

Example 1 with PsldDataDto

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;
}
Also used : RelayDataDto(com.alliander.osgp.dto.valueobjects.RelayDataDto) SsldDataDto(com.alliander.osgp.dto.valueobjects.SsldDataDto) MeterTypeDto(com.alliander.osgp.dto.valueobjects.MeterTypeDto) PowerUsageDataDto(com.alliander.osgp.dto.valueobjects.PowerUsageDataDto) Oslp(com.alliander.osgp.oslp.Oslp) PsldDataDto(com.alliander.osgp.dto.valueobjects.PsldDataDto) DateTime(org.joda.time.DateTime)

Aggregations

MeterTypeDto (com.alliander.osgp.dto.valueobjects.MeterTypeDto)1 PowerUsageDataDto (com.alliander.osgp.dto.valueobjects.PowerUsageDataDto)1 PsldDataDto (com.alliander.osgp.dto.valueobjects.PsldDataDto)1 RelayDataDto (com.alliander.osgp.dto.valueobjects.RelayDataDto)1 SsldDataDto (com.alliander.osgp.dto.valueobjects.SsldDataDto)1 Oslp (com.alliander.osgp.oslp.Oslp)1 DateTime (org.joda.time.DateTime)1