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