use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto in project open-smart-grid-platform by OSGP.
the class PowerQualityProfileResponseDataMapperTest method makeProfileEntryValueDtos.
private List<ProfileEntryValueDto> makeProfileEntryValueDtos() {
final List<ProfileEntryValueDto> result = new ArrayList<>();
result.add(new ProfileEntryValueDto("Test"));
result.add(new ProfileEntryValueDto(new Date()));
result.add(new ProfileEntryValueDto(new BigDecimal(123.45d)));
result.add(new ProfileEntryValueDto(12345L));
return result;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileNoSelectiveAccessHandler method createProfileEntryValueDto.
@Override
protected List<ProfileEntryValueDto> createProfileEntryValueDto(final DataObject profileEntryDataObject, final List<ScalerUnitInfo> scalerUnitInfos, final ProfileEntryDto previousProfileEntryDto, final Map<Integer, CaptureObjectDefinitionDto> selectableCaptureObjects, final int timeInterval) {
final List<ProfileEntryValueDto> result = new ArrayList<>();
final List<DataObject> dataObjects = profileEntryDataObject.getValue();
for (int i = 0; i < dataObjects.size(); i++) {
if (selectableCaptureObjects.containsKey(i)) {
final ProfileEntryValueDto currentProfileEntryValueDto = this.makeProfileEntryValueDto(dataObjects.get(i), scalerUnitInfos.get(result.size()), previousProfileEntryDto, timeInterval);
result.add(currentProfileEntryValueDto);
}
}
return result;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileSelectiveAccessHandler method createProfileEntryValueDto.
@Override
protected List<ProfileEntryValueDto> createProfileEntryValueDto(final DataObject profileEntryDataObject, final List<ScalerUnitInfo> scalerUnitInfos, final ProfileEntryDto previousProfileEntryDto, final Map<Integer, CaptureObjectDefinitionDto> selectableCaptureObjects, final int timeInterval) {
final List<ProfileEntryValueDto> result = new ArrayList<>();
final List<DataObject> dataObjects = profileEntryDataObject.getValue();
for (int i = 0; i < dataObjects.size(); i++) {
final ProfileEntryValueDto currentProfileEntryValueDto = super.makeProfileEntryValueDto(dataObjects.get(i), scalerUnitInfos.get(i), previousProfileEntryDto, timeInterval);
result.add(currentProfileEntryValueDto);
}
return result;
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto in project open-smart-grid-platform by OSGP.
the class AbstractGetPowerQualityProfileHandler method makeDateProfileEntryValueDto.
private ProfileEntryValueDto makeDateProfileEntryValueDto(final DataObject dataObject, final ProfileEntryDto previousProfileEntryDto, final int timeInterval) {
final CosemDateTimeDto cosemDateTime = this.dlmsHelper.convertDataObjectToDateTime(dataObject);
if (cosemDateTime == null) {
// in case of null date, we calculate the date based on the always
// existing previous value plus interval
final Date previousDate = (Date) previousProfileEntryDto.getProfileEntryValues().get(0).getValue();
final LocalDateTime newLocalDateTime = Instant.ofEpochMilli(previousDate.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime().plusMinutes(timeInterval);
return new ProfileEntryValueDto(Date.from(newLocalDateTime.atZone(ZoneId.systemDefault()).toInstant()));
} else {
return new ProfileEntryValueDto(cosemDateTime.asDateTime().toDate());
}
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileDtoConverter method makeProfileEntries.
private List<ProfileEntry> makeProfileEntries(final PowerQualityProfileDataDto responseDataDto) {
final List<ProfileEntry> profileEntries = new ArrayList<>();
for (final ProfileEntryDto profileEntryDto : responseDataDto.getProfileEntries()) {
final List<ProfileEntryValue> profileEntryValues = new ArrayList<>();
for (final ProfileEntryValueDto profileEntryValueDto : profileEntryDto.getProfileEntryValues()) {
final ProfileEntryValue profileEntryValue = this.mapperFactory.getMapperFacade().map(profileEntryValueDto, ProfileEntryValue.class);
profileEntryValues.add(profileEntryValue);
}
profileEntries.add(new ProfileEntry(profileEntryValues));
}
return profileEntries;
}
Aggregations