use of org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto in project open-smart-grid-platform by OSGP.
the class GetFirmwareVersionsGasCommandExecutor method execute.
@Override
public FirmwareVersionGasDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final GetFirmwareVersionQueryDto queryDto, final MessageMetadata messageMetadata) throws ProtocolAdapterException, FunctionalException {
if (queryDto == null || !queryDto.isMbusQuery()) {
throw new IllegalArgumentException("GetFirmwareVersion called without query object for Gas meter.");
}
if (!Protocol.forDevice(device).isSmr5()) {
throw new NotSupportedByProtocolException("Simple Version Info not supported by protocol");
}
final AttributeAddress attributeAddress = new AttributeAddress(CLASS_ID, new ObisCode(String.format(OBIS_CODE_TEMPLATE, queryDto.getChannel().getChannelNumber())), ATTRIBUTE_ID);
final String versionAsHexString = this.getSimpleVersionInfoAsHexString(conn, device, attributeAddress);
return new FirmwareVersionGasDto(FirmwareModuleType.SIMPLE_VERSION_INFO, versionAsHexString, queryDto.getMbusDeviceIdentification());
}
use of org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto in project open-smart-grid-platform by OSGP.
the class GetFirmwareVersionResponseMessageProcessor method handleMessage.
@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
if (responseMessage.getDataObject() instanceof ArrayList) {
@SuppressWarnings("unchecked") final List<FirmwareVersionDto> firmwareVersionList = (List<FirmwareVersionDto>) responseMessage.getDataObject();
this.configurationService.handleGetFirmwareVersionResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, firmwareVersionList);
} else if (responseMessage.getDataObject() instanceof FirmwareVersionGasDto) {
this.configurationService.handleGetFirmwareVersionGasResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, (FirmwareVersionGasDto) responseMessage.getDataObject());
} 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 ArrayList"));
}
}
Aggregations