Search in sources :

Example 1 with PowerQualityProfileDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto in project open-smart-grid-platform by OSGP.

the class GetPowerQualityProfileDtoConverter method convert.

@Override
public GetPowerQualityProfileResponse convert(final GetPowerQualityProfileResponseDto source, final Type<? extends GetPowerQualityProfileResponse> destinationType, final MappingContext mappingContext) {
    final GetPowerQualityProfileResponse response = new GetPowerQualityProfileResponse();
    final List<PowerQualityProfileData> powerQualityProfileDatas = new ArrayList<>();
    for (final PowerQualityProfileDataDto responseDataDto : source.getPowerQualityProfileResponseDatas()) {
        final ObisCodeValues obisCodeValues = this.mapperFactory.getMapperFacade().map(responseDataDto.getLogicalName(), ObisCodeValues.class);
        final List<CaptureObject> captureObjects = new ArrayList<>(this.mapperFacade.mapAsList(responseDataDto.getCaptureObjects(), CaptureObject.class));
        final List<ProfileEntry> profileEntries = this.makeProfileEntries(responseDataDto);
        powerQualityProfileDatas.add(new PowerQualityProfileData(obisCodeValues, captureObjects, profileEntries));
    }
    response.setPowerQualityProfileDatas(powerQualityProfileDatas);
    return response;
}
Also used : GetPowerQualityProfileResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileResponse) ObisCodeValues(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ObisCodeValues) PowerQualityProfileDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto) CaptureObject(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject) ProfileEntry(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry) ArrayList(java.util.ArrayList) PowerQualityProfileData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData)

Example 2 with PowerQualityProfileDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto in project open-smart-grid-platform by OSGP.

the class AbstractGetPowerQualityProfileHandler method handle.

protected GetPowerQualityProfileResponseDto handle(final DlmsConnectionManager conn, final DlmsDevice device, final GetPowerQualityProfileRequestDataDto getPowerQualityProfileRequestDataDto) throws ProtocolAdapterException {
    final String profileType = getPowerQualityProfileRequestDataDto.getProfileType();
    final List<Profile> profiles = this.determineProfileForDevice(profileType);
    final GetPowerQualityProfileResponseDto response = new GetPowerQualityProfileResponseDto();
    final List<PowerQualityProfileDataDto> responseDatas = new ArrayList<>();
    for (final Profile profile : profiles) {
        final ObisCode obisCode = this.makeObisCode(profile.getObisCodeValuesDto());
        final DateTime beginDateTime = new DateTime(getPowerQualityProfileRequestDataDto.getBeginDate());
        final DateTime endDateTime = new DateTime(getPowerQualityProfileRequestDataDto.getEndDate());
        // all value types that can be selected within this profile.
        final List<GetResult> captureObjects = this.retrieveCaptureObjects(conn, device, obisCode);
        // the values that are allowed to be retrieved from the meter, used
        // as filter either before (SMR 5.1+) or
        // after data retrieval
        final Map<Integer, CaptureObjectDefinitionDto> selectableCaptureObjects = this.createSelectableCaptureObjects(captureObjects, profile.getLogicalNames());
        // the units of measure for all Selectable Capture objects
        final List<ScalerUnitInfo> scalerUnitInfos = this.createScalerUnitInfos(conn, device, selectableCaptureObjects.values());
        final List<GetResult> bufferList = this.retrieveBuffer(conn, device, obisCode, beginDateTime, endDateTime, new ArrayList<>(selectableCaptureObjects.values()));
        final PowerQualityProfileDataDto responseDataDto = this.processData(profile, captureObjects, scalerUnitInfos, selectableCaptureObjects, bufferList);
        responseDatas.add(responseDataDto);
    }
    response.setPowerQualityProfileDatas(responseDatas);
    return response;
}
Also used : PowerQualityProfileDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto) GetResult(org.openmuc.jdlms.GetResult) ArrayList(java.util.ArrayList) ObisCode(org.openmuc.jdlms.ObisCode) LocalDateTime(java.time.LocalDateTime) DateTime(org.joda.time.DateTime) CaptureObjectDefinitionDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto) ScalerUnitInfo(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo) GetPowerQualityProfileResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto)

Example 3 with PowerQualityProfileDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto in project open-smart-grid-platform by OSGP.

the class PowerQualityProfileResponseDataMapperTest method testConvertGetPowerQualityProfileResponseVo.

@Test
public void testConvertGetPowerQualityProfileResponseVo() {
    final PowerQualityProfileDataDto responseDto = this.makeResponseDataDto();
    final PowerQualityProfileData responseVo = this.mapper.map(responseDto, PowerQualityProfileData.class);
    assertThat(responseVo).withFailMessage("response object should not be null").isNotNull();
    assertThat(responseVo.getProfileEntries().get(0).getProfileEntryValues().size()).withFailMessage("response object should return same number of profilentries").isEqualTo(EXPECTED_CLASS.length);
    int i = 0;
    for (final ProfileEntryValue profileEntryValueVo : responseVo.getProfileEntries().get(0).getProfileEntryValues()) {
        final Class<?> clazz = profileEntryValueVo.getValue().getClass();
        assertThat(clazz).withFailMessage("the return class should be of the same type").isEqualTo(EXPECTED_CLASS[i++]);
    }
}
Also used : PowerQualityProfileDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto) ProfileEntryValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue) PowerQualityProfileData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData) Test(org.junit.jupiter.api.Test)

Example 4 with PowerQualityProfileDataDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto in project open-smart-grid-platform by OSGP.

the class PowerQualityProfileResponseDataMappingTest method testConvertGetPowerQualityProfileResponseDto.

@Test
public void testConvertGetPowerQualityProfileResponseDto() {
    final PowerQualityProfileDataDto dto = this.makePowerQualityProfileResponseDataDto();
    final PowerQualityProfileData result = this.mapper.map(dto, PowerQualityProfileData.class);
    assertThat(result).withFailMessage("mapping GetPowerQualityProfileResponseData should not return null").isNotNull();
    assertThat(result).withFailMessage("mapping GetPowerQualityProfileResponseData should return correct type").isOfAnyClassIn(PowerQualityProfileData.class);
}
Also used : PowerQualityProfileDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto) PowerQualityProfileData(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData) Test(org.junit.jupiter.api.Test)

Aggregations

PowerQualityProfileDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityProfileDataDto)4 PowerQualityProfileData (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.PowerQualityProfileData)3 ArrayList (java.util.ArrayList)2 Test (org.junit.jupiter.api.Test)2 LocalDateTime (java.time.LocalDateTime)1 DateTime (org.joda.time.DateTime)1 GetResult (org.openmuc.jdlms.GetResult)1 ObisCode (org.openmuc.jdlms.ObisCode)1 ScalerUnitInfo (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.ScalerUnitInfo)1 CaptureObject (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.CaptureObject)1 GetPowerQualityProfileResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GetPowerQualityProfileResponse)1 ObisCodeValues (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ObisCodeValues)1 ProfileEntry (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry)1 ProfileEntryValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue)1 CaptureObjectDefinitionDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CaptureObjectDefinitionDto)1 GetPowerQualityProfileResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto)1