use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class MonitoringService method requestActualMeterReads.
public void requestActualMeterReads(final MessageMetadata messageMetadata, final ActualMeterReadsQuery actualMeterReadsQuery) throws FunctionalException {
LOGGER.info("requestActualMeterReads for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
if (actualMeterReadsQuery.isMbusDevice()) {
if (smartMeter.getChannel() == null) {
/*
* For now, throw a FunctionalException. As soon as we can
* communicate with some types of gas meters directly, and not
* through an M-Bus port of an energy meter, this will have to
* be changed.
*/
throw new FunctionalException(FunctionalExceptionType.VALIDATION_ERROR, ComponentType.DOMAIN_SMART_METERING, new AssertionError("Meter for gas reads should have a channel configured."));
}
final Device gatewayDevice = smartMeter.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."));
}
final ActualMeterReadsQueryDto requestDto = new ActualMeterReadsQueryDto(ChannelDto.fromNumber(smartMeter.getChannel()));
this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withDeviceIdentification(gatewayDevice.getDeviceIdentification()).withIpAddress(gatewayDevice.getIpAddress()).withNetworkSegmentIds(gatewayDevice.getBtsId(), gatewayDevice.getCellId()).build());
} else {
this.osgpCoreRequestMessageSender.send(new ActualMeterReadsQueryDto(), messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class GetPowerQualityProfileResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
if (responseMessage.getDataObject() instanceof GetPowerQualityProfileResponseDto) {
final GetPowerQualityProfileResponseDto getPowerQualityProfileResponseDto = (GetPowerQualityProfileResponseDto) responseMessage.getDataObject();
this.monitoringService.handleGetPowerQualityProfileResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, getPowerQualityProfileResponseDto);
} 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 GetPowerQualityProfileResponseDto"));
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class UpdateFirmwareResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
if (responseMessage.getDataObject() instanceof UpdateFirmwareResponseDto) {
final UpdateFirmwareResponseDto updateFirmwareResponse = (UpdateFirmwareResponseDto) responseMessage.getDataObject();
this.configurationService.handleUpdateFirmwareResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, updateFirmwareResponse);
} 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 UpdateFirmwareResponseDto"));
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException 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"));
}
}
use of org.opensmartgridplatform.shared.exceptionhandling.FunctionalException in project open-smart-grid-platform by OSGP.
the class ScanMbusChannelsResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
if (responseMessage.getDataObject() instanceof ScanMbusChannelsResponseDto) {
final ScanMbusChannelsResponseDto scanMbusChannelsResponseDto = (ScanMbusChannelsResponseDto) responseMessage.getDataObject();
this.adhocService.handleScanMbusChannelsResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, scanMbusChannelsResponseDto);
} 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 ScanMbusChannelsResponseDto"));
}
}
Aggregations