Search in sources :

Example 1 with ProfileEntryValueDto

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;
}
Also used : ProfileEntryValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto) ArrayList(java.util.ArrayList) Date(java.util.Date) BigDecimal(java.math.BigDecimal)

Example 2 with ProfileEntryValueDto

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;
}
Also used : ProfileEntryValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList)

Example 3 with ProfileEntryValueDto

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;
}
Also used : ProfileEntryValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList)

Example 4 with ProfileEntryValueDto

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());
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) ProfileEntryValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto) Date(java.util.Date) CosemDateTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)

Example 5 with ProfileEntryValueDto

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;
}
Also used : ProfileEntryValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto) ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) ProfileEntryValue(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue) ProfileEntry(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry) ArrayList(java.util.ArrayList)

Aggregations

ProfileEntryValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto)5 ArrayList (java.util.ArrayList)4 Date (java.util.Date)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 BigDecimal (java.math.BigDecimal)1 LocalDateTime (java.time.LocalDateTime)1 ProfileEntry (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry)1 ProfileEntryValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue)1 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)1 ProfileEntryDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto)1