Search in sources :

Example 1 with ActualPowerQualityResponseDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto 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 2 with ActualPowerQualityResponseDto

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

the class GetActualPowerQualityCommandExecutor method makeActualPowerQualityResponseDto.

private ActualPowerQualityResponseDto makeActualPowerQualityResponseDto(final List<GetResult> resultList, final List<PowerQualityObjectMetadata> metadatas) throws ProtocolAdapterException {
    final ActualPowerQualityResponseDto responseDto = new ActualPowerQualityResponseDto();
    final ActualPowerQualityDataDto actualPowerQualityDataDto = this.makeActualPowerQualityDataDto(resultList, metadatas);
    responseDto.setActualPowerQualityDataDto(actualPowerQualityDataDto);
    return responseDto;
}
Also used : ActualPowerQualityDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityDataDto) ActualPowerQualityResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto)

Example 3 with ActualPowerQualityResponseDto

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

the class ActualPowerQualityResponseMessageProcessor method handleMessage.

@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
    if (this.hasRegularResponseObject(responseMessage)) {
        final ActualPowerQualityResponseDto actualPowerQualityResponseDto = (ActualPowerQualityResponseDto) responseMessage.getDataObject();
        this.monitoringService.handleActualPowerQualityResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, actualPowerQualityResponseDto);
    } else {
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new OsgpException(ComponentType.DOMAIN_SMART_METERING, "DataObject for response message should be of type ActualPowerQualityResponseDto"));
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) ActualPowerQualityResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto)

Aggregations

ActualPowerQualityResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityResponseDto)3 Serializable (java.io.Serializable)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 PowerQualityObjectMetadata (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.misc.GetActualPowerQualityCommandExecutor.PowerQualityObjectMetadata)1 ActualPowerQualityDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityDataDto)1 ActualPowerQualityRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualPowerQualityRequestDto)1 PowerQualityObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityObjectDto)1 PowerQualityValueDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.PowerQualityValueDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1