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());
}
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);
}
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());
}
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();
}
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());
}
Aggregations