Search in sources :

Example 1 with GetFirmwareVersionQueryDto

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

the class ConfigurationService method requestFirmwareVersion.

/**
 * Delegates the requests of the retrieval of the firmware version(s) from the protocol adapter
 * layer to the core layer
 *
 * @param messageMetadata contains the message meta data
 * @param getFirmwareVersionQuery
 * @throws FunctionalException is thrown when the device cannot be found in the database or when
 *     the device is a G meter and the channel and/or gateway is not configured
 */
public void requestFirmwareVersion(final MessageMetadata messageMetadata, final GetFirmwareVersionQuery getFirmwareVersionQuery) throws FunctionalException {
    log.info("requestFirmwareVersion for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    if (getFirmwareVersionQuery.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("Retrieving firmware version for gas meter. No 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("Retrieving firmware version for gas meter. No gateway device found."));
        }
        final GetFirmwareVersionQueryDto requestDto = new GetFirmwareVersionQueryDto(ChannelDto.fromNumber(smartMeter.getChannel()), messageMetadata.getDeviceIdentification());
        this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withDeviceIdentification(gatewayDevice.getDeviceIdentification()).withIpAddress(gatewayDevice.getIpAddress()).withNetworkSegmentIds(gatewayDevice.getBtsId(), gatewayDevice.getCellId()).build());
    } else {
        final GetFirmwareVersionQueryDto requestDto = new GetFirmwareVersionQueryDto();
        this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
    }
}
Also used : GetFirmwareVersionQueryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetFirmwareVersionQueryDto) Device(org.opensmartgridplatform.domain.core.entities.Device) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)

Example 2 with GetFirmwareVersionQueryDto

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

the class GetFirmwareVersionsGasCommandExecutor method fromBundleRequestInput.

@Override
public GetFirmwareVersionQueryDto fromBundleRequestInput(final ActionRequestDto bundleInput) throws ProtocolAdapterException {
    this.checkActionRequestType(bundleInput);
    final GetFirmwareVersionGasRequestDto getFirmwareVersionGasRequestDto = (GetFirmwareVersionGasRequestDto) bundleInput;
    return new GetFirmwareVersionQueryDto(getFirmwareVersionGasRequestDto.getChannel(), getFirmwareVersionGasRequestDto.getMbusDeviceIdentification());
}
Also used : GetFirmwareVersionQueryDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetFirmwareVersionQueryDto) GetFirmwareVersionGasRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetFirmwareVersionGasRequestDto)

Aggregations

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