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;
}
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;
}
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++]);
}
}
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);
}
Aggregations