Search in sources :

Example 1 with SetDeviceLifecycleStatusByChannelResponseDto

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

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

the class SetDeviceLifecycleStatusByChannelCommandExecutor method execute.

@Override
public SetDeviceLifecycleStatusByChannelResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice gatewayDevice, final SetDeviceLifecycleStatusByChannelRequestDataDto request, final MessageMetadata messageMetadata) throws OsgpException {
    final GetMBusDeviceOnChannelRequestDataDto mbusDeviceOnChannelRequest = new GetMBusDeviceOnChannelRequestDataDto(gatewayDevice.getDeviceIdentification(), request.getChannel());
    final ChannelElementValuesDto channelElementValues = this.getMBusDeviceOnChannelCommandExecutor.execute(conn, gatewayDevice, mbusDeviceOnChannelRequest, messageMetadata);
    if (!channelElementValues.hasChannel() || !channelElementValues.hasDeviceTypeIdentification() || !channelElementValues.hasManufacturerIdentification()) {
        throw new FunctionalException(FunctionalExceptionType.NO_DEVICE_FOUND_ON_CHANNEL, ComponentType.PROTOCOL_DLMS);
    }
    final DlmsDevice mbusDevice = this.dlmsDeviceRepository.findByMbusIdentificationNumberAndMbusManufacturerIdentification(channelElementValues.getIdentificationNumber(), channelElementValues.getManufacturerIdentification());
    if (mbusDevice == null) {
        throw new FunctionalException(FunctionalExceptionType.NO_MATCHING_MBUS_DEVICE_FOUND, ComponentType.PROTOCOL_DLMS);
    }
    return new SetDeviceLifecycleStatusByChannelResponseDto(gatewayDevice.getDeviceIdentification(), request.getChannel(), mbusDevice.getDeviceIdentification(), request.getDeviceLifecycleStatus());
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) SetDeviceLifecycleStatusByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) GetMBusDeviceOnChannelRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMBusDeviceOnChannelRequestDataDto)

Aggregations

SetDeviceLifecycleStatusByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseDto)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)1 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)1 ActionResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto)1 ChannelElementValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto)1 CoupleMbusDeviceByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto)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 GetMBusDeviceOnChannelRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMBusDeviceOnChannelRequestDataDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1