Search in sources :

Example 1 with ActualPowerQualityRequestDto

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

the class GetActualPowerQualityCommandExecutorTest method testOtherReasonResult.

@Test
void testOtherReasonResult() throws ProtocolAdapterException {
    this.actualPowerQualityRequestDto = new ActualPowerQualityRequestDto("PRIVATE");
    final List<GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata> metadatas = GetActualPowerQualityCommandExecutor.getMetadatasPrivate();
    doReturn(this.generateMockedResult(metadatas, AccessResultCode.OTHER_REASON)).when(this.dlmsHelper).getAndCheck(eq(this.conn), eq(this.dlmsDevice), eq("retrieve actual power quality"), any(AttributeAddress.class));
    assertThatExceptionOfType(ProtocolAdapterException.class).isThrownBy(() -> {
        new GetActualPowerQualityCommandExecutor(this.dlmsHelper).execute(this.conn, this.dlmsDevice, this.actualPowerQualityRequestDto, this.messageMetadata);
    });
}
Also used : ActualPowerQualityRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) PowerQualityObjectMetadata(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata) Test(org.junit.jupiter.api.Test)

Example 2 with ActualPowerQualityRequestDto

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

the class GetActualPowerQualityCommandExecutorTest method executeAndAssert.

void executeAndAssert(final String profileType, final List<GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata> metadatas) throws ProtocolAdapterException {
    this.actualPowerQualityRequestDto = new ActualPowerQualityRequestDto(profileType);
    doReturn(this.generateMockedResult(metadatas, AccessResultCode.SUCCESS)).when(this.dlmsHelper).getAndCheck(eq(this.conn), eq(this.dlmsDevice), eq("retrieve actual power quality"), any(AttributeAddress.class));
    final GetActualPowerQualityCommandExecutor executor = new GetActualPowerQualityCommandExecutor(this.dlmsHelper);
    final ActualPowerQualityResponseDto responseDto = executor.execute(this.conn, this.dlmsDevice, this.actualPowerQualityRequestDto, this.messageMetadata);
    assertThat(responseDto.getActualPowerQualityData().getPowerQualityValues()).hasSize(metadatas.size());
    assertThat(responseDto.getActualPowerQualityData().getPowerQualityObjects()).hasSize(metadatas.size());
    for (int i = 0; i < metadatas.size(); i++) {
        final GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata metadata = metadatas.get(i);
        final Serializable expectedValue = this.getExpectedValue(i, metadata);
        final String expectedUnit = this.getExpectedUnit(metadata);
        final PowerQualityObjectDto powerQualityObjectDto = responseDto.getActualPowerQualityData().getPowerQualityObjects().get(i);
        assertThat(powerQualityObjectDto.getName()).isEqualTo(metadata.name());
        assertThat(powerQualityObjectDto.getUnit()).isEqualTo(expectedUnit);
        final PowerQualityValueDto powerQualityValue = responseDto.getActualPowerQualityData().getPowerQualityValues().get(i);
        assertThat(powerQualityValue.getValue()).isEqualTo(expectedValue);
    }
}
Also used : Serializable(java.io.Serializable) PowerQualityObjectMetadata(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata) ActualPowerQualityRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) PowerQualityObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityObjectDto) ActualPowerQualityResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto) PowerQualityValueDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityValueDto)

Example 3 with ActualPowerQualityRequestDto

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

the class GetActualPowerQualityRequestMessageProcessor method handleMessage.

@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
    this.assertRequestObjectType(ActualPowerQualityRequestDto.class, requestObject);
    final ActualPowerQualityRequestDto actualPowerQualityRequestDto = (ActualPowerQualityRequestDto) requestObject;
    return this.monitoringService.requestActualPowerQuality(conn, device, actualPowerQualityRequestDto, messageMetadata);
}
Also used : ActualPowerQualityRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto)

Example 4 with ActualPowerQualityRequestDto

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

the class MonitoringService method requestActualPowerQuality.

public void requestActualPowerQuality(final MessageMetadata messageMetadata, final ActualPowerQualityRequest request) throws FunctionalException {
    LOGGER.info("requestActualPowerQuality for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final ActualPowerQualityRequestDto requestDto = this.monitoringMapper.map(request, ActualPowerQualityRequestDto.class);
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Also used : ActualPowerQualityRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter)

Aggregations

ActualPowerQualityRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto)4 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 PowerQualityObjectMetadata (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata)2 Serializable (java.io.Serializable)1 Test (org.junit.jupiter.api.Test)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 ActualPowerQualityResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto)1 PowerQualityObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityObjectDto)1 PowerQualityValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityValueDto)1