Search in sources :

Example 1 with CoupleMbusDeviceByChannelResponseDto

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

the class CoupleMbusDeviceByChannelCommandExecutorTest method testHappyFlow.

@Test
public void testHappyFlow() throws ProtocolAdapterException {
    final short channel = (short) 1;
    final Short primaryAddress = 9;
    final String manufacturerIdentification = "manufacturerIdentification";
    final short version = 123;
    final short deviceTypeIdentification = 456;
    final String identificationNumber = "identificationNumber";
    final ChannelElementValuesDto dto = new ChannelElementValuesDto(channel, primaryAddress, identificationNumber, manufacturerIdentification, version, deviceTypeIdentification);
    final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
    when(this.coupleMbusDeviceByChannelRequestDataDto.getChannel()).thenReturn(channel);
    when(this.deviceChannelsHelper.getChannelElementValues(this.conn, this.device, channel)).thenReturn(dto);
    final CoupleMbusDeviceByChannelResponseDto responseDto = this.commandExecutor.execute(this.conn, this.device, this.coupleMbusDeviceByChannelRequestDataDto, messageMetadata);
    assertThat(responseDto).isNotNull();
    assertThat(responseDto.getChannelElementValues()).isNotNull();
    assertThat(responseDto.getChannelElementValues().getChannel()).isEqualTo(channel);
    assertThat(responseDto.getChannelElementValues().getDeviceTypeIdentification()).isEqualTo(deviceTypeIdentification);
    assertThat(responseDto.getChannelElementValues().getIdentificationNumber()).isEqualTo(identificationNumber);
    assertThat(responseDto.getChannelElementValues().getManufacturerIdentification()).isEqualTo(manufacturerIdentification);
    assertThat(responseDto.getChannelElementValues().getPrimaryAddress()).isEqualTo(primaryAddress);
    assertThat(responseDto.getChannelElementValues().getVersion()).isEqualTo(version);
    verify(this.deviceChannelsHelper, times(1)).getChannelElementValues(eq(this.conn), eq(this.device), any(Short.class));
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) CoupleMbusDeviceByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto) Test(org.junit.jupiter.api.Test)

Example 2 with CoupleMbusDeviceByChannelResponseDto

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

the class BundleService method checkIfAdditionalActionIsNeeded.

private void checkIfAdditionalActionIsNeeded(final MessageMetadata messageMetadata, final BundleMessagesRequestDto bundleMessagesRequestDto) throws FunctionalException {
    for (final ActionResponseDto action : bundleMessagesRequestDto.getAllResponses()) {
        if (action instanceof CoupleMbusDeviceByChannelResponseDto) {
            this.mBusGatewayService.handleCoupleMbusDeviceByChannelResponse(messageMetadata, (CoupleMbusDeviceByChannelResponseDto) action);
        } else if (action instanceof DecoupleMbusDeviceResponseDto) {
            this.mBusGatewayService.handleDecoupleMbusDeviceResponse(messageMetadata, (DecoupleMbusDeviceResponseDto) action);
        } else if (action instanceof SetDeviceLifecycleStatusByChannelResponseDto) {
            this.managementService.setDeviceLifecycleStatusByChannel((SetDeviceLifecycleStatusByChannelResponseDto) action);
        } else if (action instanceof EventMessageDataResponseDto) {
            this.eventService.enrichEvents(messageMetadata, (EventMessageDataResponseDto) action);
        } else if (action instanceof FirmwareVersionResponseDto) {
            final List<FirmwareVersion> firmwareVersions = this.configurationMapper.mapAsList(((FirmwareVersionResponseDto) action).getFirmwareVersions(), FirmwareVersion.class);
            this.firmwareService.saveFirmwareVersionsReturnedFromDevice(messageMetadata.getDeviceIdentification(), firmwareVersions);
        } else if (action instanceof FirmwareVersionGasResponseDto) {
            final FirmwareVersionGasResponseDto firmwareVersionGasResponseDto = (FirmwareVersionGasResponseDto) action;
            final FirmwareVersion firmwareVersion = this.configurationMapper.map(firmwareVersionGasResponseDto.getFirmwareVersion(), FirmwareVersion.class);
            this.firmwareService.saveFirmwareVersionsReturnedFromDevice(firmwareVersionGasResponseDto.getFirmwareVersion().getMbusDeviceIdentification(), Arrays.asList(firmwareVersion));
        }
    }
}
Also used : ActionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto) SetDeviceLifecycleStatusByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseDto) DecoupleMbusDeviceResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto) FirmwareVersionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionResponseDto) EventMessageDataResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto) CoupleMbusDeviceByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto) FirmwareVersionGasResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionGasResponseDto) FirmwareVersion(org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)

Example 3 with CoupleMbusDeviceByChannelResponseDto

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

the class CoupleMbusDeviceByChannelCommandExecutor method execute.

@Override
public CoupleMbusDeviceByChannelResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final CoupleMbusDeviceByChannelRequestDataDto requestDto, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    log.info("Retrieving values for mbus channel {} on device {}", requestDto.getChannel(), device.getDeviceIdentification());
    final ChannelElementValuesDto channelElementValuesDto = this.deviceChannelsHelper.getChannelElementValues(conn, device, requestDto.getChannel());
    /*
     * Couple M-Bus device by channel is created to couple the M-Bus device
     * in the platform based on a new M-Bus device discovered alarm for a
     * particular channel. As such there is no write action to the M-Bus
     * Client Setup involved, since the platform depends on the attributes
     * on the gateway device to be able to determine which M-Bus device was
     * actually involved when the alarm was triggered for the channel from
     * the request.
     */
    return new CoupleMbusDeviceByChannelResponseDto(channelElementValuesDto);
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) CoupleMbusDeviceByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto)

Aggregations

CoupleMbusDeviceByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto)3 ChannelElementValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto)2 Test (org.junit.jupiter.api.Test)1 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)1 ActionResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto)1 DecoupleMbusDeviceResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto)1 EventMessageDataResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)1 FirmwareVersionGasResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionGasResponseDto)1 FirmwareVersionResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionResponseDto)1 SetDeviceLifecycleStatusByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseDto)1 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)1