Search in sources :

Example 1 with GMeterInfoDto

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

the class ConfigurationService method setEncryptionKeyExchangeOnGMeter.

public void setEncryptionKeyExchangeOnGMeter(final MessageMetadata messageMetadata) throws FunctionalException {
    log.info("set Encryption Key Exchange On G-Meter for organisationIdentification: {} for deviceIdentification: " + "{}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter gasDevice = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final Device gatewayDevice = gasDevice.getGatewayDevice();
    if (gatewayDevice == null) {
        /*
       * For now throw a FunctionalException, based on the same reasoning
       * as with the channel a couple of lines up. As soon as we have
       * scenario's with direct communication with gas meters this will
       * have to be changed.
       */
        throw new FunctionalException(FunctionalExceptionType.GATEWAY_DEVICE_NOT_SET_FOR_MBUS_DEVICE, ComponentType.DOMAIN_SMART_METERING, new GatewayDeviceNotSetForMbusDeviceException());
    }
    final GMeterInfoDto requestDto = new GMeterInfoDto(gasDevice.getChannel(), gasDevice.getDeviceIdentification());
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withDeviceIdentification(gatewayDevice.getDeviceIdentification()).withIpAddress(gatewayDevice.getIpAddress()).withNetworkSegmentIds(gatewayDevice.getBtsId(), gatewayDevice.getCellId()).build());
}
Also used : GatewayDeviceNotSetForMbusDeviceException(org.opensmartgridplatform.domain.smartmetering.exceptions.GatewayDeviceNotSetForMbusDeviceException) Device(org.opensmartgridplatform.domain.core.entities.Device) GMeterInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)

Example 2 with GMeterInfoDto

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

the class SetMbusUserKeyByChannelCommandExecutor method executeBundleAction.

@Override
public ActionResponseDto executeBundleAction(final DlmsConnectionManager conn, final DlmsDevice device, final ActionRequestDto actionRequestDto, final MessageMetadata messageMetadata) throws OsgpException {
    this.checkActionRequestType(actionRequestDto);
    final SetMbusUserKeyByChannelRequestDataDto setMbusUserKeyByChannelRequestData = (SetMbusUserKeyByChannelRequestDataDto) actionRequestDto;
    final GMeterInfoDto gMeterInfo = this.configurationService.getMbusKeyExchangeData(conn, device, setMbusUserKeyByChannelRequestData, messageMetadata);
    final MethodResultCode executionResult = this.execute(conn, device, gMeterInfo, messageMetadata);
    return this.asBundleResponse(executionResult);
}
Also used : MethodResultCode(org.openmuc.jdlms.MethodResultCode) GMeterInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto) SetMbusUserKeyByChannelRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetMbusUserKeyByChannelRequestDataDto)

Example 3 with GMeterInfoDto

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

the class SetEncryptionKeyExchangeOnGMeterDataConverter method convert.

@Override
public GMeterInfoDto convert(final SetEncryptionKeyExchangeOnGMeterRequestData value, final SmartMeter smartMeter) throws FunctionalException {
    final SmartMeter gasDevice = this.domainHelperService.findSmartMeter(value.getDeviceIdentification());
    final Device gatewayDevice = gasDevice.getGatewayDevice();
    if (gatewayDevice == null) {
        /*
       * For now throw a FunctionalException, based on the same reasoning
       * as with the channel a couple of lines up. As soon as we have
       * scenario's with direct communication with gas meters this will
       * have to be changed.
       */
        throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new AssertionError("Meter for gas reads should have an energy meter as gateway device."));
    }
    return new GMeterInfoDto(gasDevice.getChannel(), gasDevice.getDeviceIdentification());
}
Also used : Device(org.opensmartgridplatform.domain.core.entities.Device) GMeterInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)

Example 4 with GMeterInfoDto

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

the class ConfigurationService method setMbusUserKeyByChannel.

public String setMbusUserKeyByChannel(final DlmsConnectionManager conn, final DlmsDevice device, final SetMbusUserKeyByChannelRequestDataDto setMbusUserKeyByChannelRequestDataDto, final MessageMetadata messageMetadata) throws OsgpException {
    LOGGER.info("Device for Set M-Bus User Key By Channel is: {}", device);
    final GMeterInfoDto gMeterInfo = this.getMbusKeyExchangeData(conn, device, setMbusUserKeyByChannelRequestDataDto, messageMetadata);
    this.setEncryptionKeyExchangeOnGMeterCommandExecutor.execute(conn, device, gMeterInfo, messageMetadata);
    return "Set M-Bus User Key By Channel Result is OK for device id: " + device.getDeviceIdentification();
}
Also used : GMeterInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto)

Example 5 with GMeterInfoDto

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

the class ConfigurationService method getMbusKeyExchangeData.

public GMeterInfoDto getMbusKeyExchangeData(final DlmsConnectionManager conn, final DlmsDevice device, final SetMbusUserKeyByChannelRequestDataDto setMbusUserKeyByChannelRequestData, final MessageMetadata messageMetadata) throws OsgpException {
    final GetMBusDeviceOnChannelRequestDataDto mbusDeviceOnChannelRequest = new GetMBusDeviceOnChannelRequestDataDto(device.getDeviceIdentification(), setMbusUserKeyByChannelRequestData.getChannel());
    final ChannelElementValuesDto channelElementValues = this.getMBusDeviceOnChannelCommandExecutor.execute(conn, device, mbusDeviceOnChannelRequest, messageMetadata);
    final DlmsDevice mbusDevice = this.domainHelperService.findMbusDevice(channelElementValues.getIdentificationNumber(), channelElementValues.getManufacturerIdentification());
    return new GMeterInfoDto(setMbusUserKeyByChannelRequestData.getChannel(), mbusDevice.getDeviceIdentification());
}
Also used : ChannelElementValuesDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto) GMeterInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) GetMBusDeviceOnChannelRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMBusDeviceOnChannelRequestDataDto)

Aggregations

GMeterInfoDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GMeterInfoDto)6 Device (org.opensmartgridplatform.domain.core.entities.Device)2 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)2 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)2 MethodResultCode (org.openmuc.jdlms.MethodResultCode)1 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)1 GatewayDeviceNotSetForMbusDeviceException (org.opensmartgridplatform.domain.smartmetering.exceptions.GatewayDeviceNotSetForMbusDeviceException)1 ChannelElementValuesDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ChannelElementValuesDto)1 GetMBusDeviceOnChannelRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetMBusDeviceOnChannelRequestDataDto)1 SetMbusUserKeyByChannelRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetMbusUserKeyByChannelRequestDataDto)1