Search in sources :

Example 1 with ProfileEntryDto

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

the class PowerQualityProfileResponseDataMapperTest method makeProfileEntryDtos.

private List<ProfileEntryDto> makeProfileEntryDtos() {
    final List<ProfileEntryDto> result = new ArrayList<>();
    result.add(new ProfileEntryDto(this.makeProfileEntryValueDtos()));
    return result;
}
Also used : ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) ArrayList(java.util.ArrayList)

Example 2 with ProfileEntryDto

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

the class AbstractGetPowerQualityProfileHandler method createProfileEntries.

private List<ProfileEntryDto> createProfileEntries(final List<GetResult> bufferList, final List<ScalerUnitInfo> scalerUnitInfos, final Map<Integer, CaptureObjectDefinitionDto> selectableCaptureObjects, final int timeInterval) {
    final List<ProfileEntryDto> profileEntryDtos = new ArrayList<>();
    // there is always only one GetResult, which is an array of array data
    for (final GetResult buffer : bufferList) {
        final DataObject dataObject = buffer.getResultData();
        final List<DataObject> dataObjectValue = dataObject.getValue();
        ProfileEntryDto previousProfileEntryDto = null;
        for (final DataObject profileEntryDataObject : dataObjectValue) {
            final ProfileEntryDto profileEntryDto = new ProfileEntryDto(this.createProfileEntryValueDto(profileEntryDataObject, scalerUnitInfos, previousProfileEntryDto, selectableCaptureObjects, timeInterval));
            profileEntryDtos.add(profileEntryDto);
            previousProfileEntryDto = profileEntryDto;
        }
    }
    return profileEntryDtos;
}
Also used : ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) GetResult(org.openmuc.jdlms.GetResult) ArrayList(java.util.ArrayList)

Example 3 with ProfileEntryDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto 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)

Example 4 with ProfileEntryDto

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

the class GetPowerQualityProfileNoSelectiveAccessHandlerTest method testHandlePublicProfileWithoutSelectiveAccess.

@Test
public void testHandlePublicProfileWithoutSelectiveAccess() throws ProtocolAdapterException {
    // SETUP
    final GetPowerQualityProfileRequestDataDto requestDto = new GetPowerQualityProfileRequestDataDto("PUBLIC", Date.from(Instant.now().minus(2, ChronoUnit.DAYS)), new Date(), new ArrayList<>());
    when(this.dlmsHelper.getAndCheck(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(String.class), any(AttributeAddress.class))).thenReturn(this.createPartialNotAllowedCaptureObjects(), this.createProfileEntries(), this.createPartialNotAllowedCaptureObjects(), this.createProfileEntries());
    when(this.dlmsHelper.readLogicalName(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readObjectDefinition(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLongNotNull(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLong(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenCallRealMethod();
    when(this.dlmsHelper.fromDateTimeValue(any())).thenCallRealMethod();
    when(this.dlmsHelper.getClockDefinition()).thenCallRealMethod();
    final GetPowerQualityProfileNoSelectiveAccessHandler handler = new GetPowerQualityProfileNoSelectiveAccessHandler(this.dlmsHelper);
    // EXECUTE
    final GetPowerQualityProfileResponseDto responseDto = handler.handle(this.conn, this.dlmsDevice, requestDto);
    // ASSERT
    assertThat(responseDto.getPowerQualityProfileResponseDatas().size()).isEqualTo(2);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getCaptureObjects().size()).isEqualTo(2);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries().size()).isEqualTo(4);
    for (final ProfileEntryDto profileEntryDto : responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries()) {
        assertThat(profileEntryDto.getProfileEntryValues().size()).isEqualTo(2);
    }
}
Also used : ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) GetPowerQualityProfileResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 5 with ProfileEntryDto

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

the class GetPowerQualityProfileSelectiveAccessHandlerTest method testHandlePrivateProfileSelectiveAccess.

@Test
public void testHandlePrivateProfileSelectiveAccess() throws ProtocolAdapterException {
    // SETUP
    final GetPowerQualityProfileRequestDataDto requestDto = new GetPowerQualityProfileRequestDataDto("PRIVATE", Date.from(Instant.now().minus(2, ChronoUnit.DAYS)), new Date(), new ArrayList<>());
    when(this.dlmsHelper.getAndCheck(any(DlmsConnectionManager.class), any(DlmsDevice.class), any(String.class), any(AttributeAddress.class))).thenReturn(this.createCaptureObjects(), this.createProfileEntries(), this.createCaptureObjectsProfile2(), this.createProfileEntries());
    when(this.dlmsHelper.readLogicalName(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readObjectDefinition(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLongNotNull(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.readLong(any(DataObject.class), any(String.class))).thenCallRealMethod();
    when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenCallRealMethod();
    when(this.dlmsHelper.fromDateTimeValue(any())).thenCallRealMethod();
    when(this.dlmsHelper.getClockDefinition()).thenCallRealMethod();
    final GetPowerQualityProfileSelectiveAccessHandler handler = new GetPowerQualityProfileSelectiveAccessHandler(this.dlmsHelper);
    // EXECUTE
    final GetPowerQualityProfileResponseDto responseDto = handler.handle(this.conn, this.dlmsDevice, requestDto);
    // ASSERT
    assertThat(responseDto.getPowerQualityProfileResponseDatas().size()).isEqualTo(2);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getCaptureObjects().size()).isEqualTo(3);
    assertThat(responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries().size()).isEqualTo(4);
    for (final ProfileEntryDto profileEntryDto : responseDto.getPowerQualityProfileResponseDatas().get(0).getProfileEntries()) {
        assertThat(profileEntryDto.getProfileEntryValues().size()).isEqualTo(3);
    }
}
Also used : ProfileEntryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) GetPowerQualityProfileRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto) GetPowerQualityProfileResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

ProfileEntryDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryDto)5 ArrayList (java.util.ArrayList)3 DataObject (org.openmuc.jdlms.datatypes.DataObject)3 Date (java.util.Date)2 Test (org.junit.jupiter.api.Test)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)2 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)2 GetPowerQualityProfileRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileRequestDataDto)2 GetPowerQualityProfileResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetPowerQualityProfileResponseDto)2 GetResult (org.openmuc.jdlms.GetResult)1 ProfileEntry (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntry)1 ProfileEntryValue (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ProfileEntryValue)1 ProfileEntryValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ProfileEntryValueDto)1