Search in sources :

Example 1 with FirmwareVersionGasDto

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());
}
Also used : FirmwareVersionGasDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ObisCode(org.openmuc.jdlms.ObisCode) NotSupportedByProtocolException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException)

Example 2 with FirmwareVersionGasDto

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"));
    }
}
Also used : OsgpException(org.opensmartgridplatform.shared.exceptionhandling.OsgpException) FirmwareVersionGasDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) FirmwareVersionDto(org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)

Aggregations

FirmwareVersionGasDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 ObisCode (org.openmuc.jdlms.ObisCode)1 NotSupportedByProtocolException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException)1 FirmwareVersionDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)1