Search in sources :

Example 1 with ActualMeterReadsDataGasDto

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

the class GetActualMeterReadsGasCommandExecutor method fromBundleRequestInput.

@Override
public ActualMeterReadsQueryDto fromBundleRequestInput(final ActionRequestDto bundleInput) throws ProtocolAdapterException {
    this.checkActionRequestType(bundleInput);
    final ActualMeterReadsDataGasDto actualMeterReadsDataGasDto = (ActualMeterReadsDataGasDto) bundleInput;
    return new ActualMeterReadsQueryDto(actualMeterReadsDataGasDto.getChannel());
}
Also used : ActualMeterReadsDataGasDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualMeterReadsDataGasDto) ActualMeterReadsQueryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualMeterReadsQueryDto)

Example 2 with ActualMeterReadsDataGasDto

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

the class ActualMeterReadsRequestGasRequestDataConverter method convert.

@Override
public ActualMeterReadsDataGasDto convert(final ActualMeterReadsGasRequestData value, final SmartMeter smartMeter) throws FunctionalException {
    final SmartMeter gasMeter = this.domainHelperService.findSmartMeter(value.getDeviceIdentification());
    if (gasMeter.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 = gasMeter.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 ActualMeterReadsDataGasDto(ChannelDto.fromNumber(gasMeter.getChannel()));
}
Also used : ActualMeterReadsDataGasDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualMeterReadsDataGasDto) Device(org.opensmartgridplatform.domain.core.entities.Device) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)

Aggregations

ActualMeterReadsDataGasDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualMeterReadsDataGasDto)2 Device (org.opensmartgridplatform.domain.core.entities.Device)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 ActualMeterReadsQueryDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActualMeterReadsQueryDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1