Search in sources :

Example 1 with NotSupportedByProtocolException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException 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 NotSupportedByProtocolException

use of org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException in project open-smart-grid-platform by OSGP.

the class SetConfigurationObjectService method toWord.

private String toWord(final List<ConfigurationFlagDto> flags) throws ProtocolAdapterException {
    final StringBuilder sb = this.createEmptyWord();
    for (final ConfigurationFlagDto flag : flags) {
        if (flag.isEnabled()) {
            final ConfigurationFlagTypeDto flagType = flag.getConfigurationFlagType();
            final Integer bitPosition = this.getBitPosition(flagType).orElseThrow(() -> new NotSupportedByProtocolException(String.format("ConfigurationFlagTypeDto %s not known for protocol", flagType)));
            sb.setCharAt(bitPosition, '1');
        }
    }
    return sb.toString();
}
Also used : ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationFlagTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto) NotSupportedByProtocolException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException)

Aggregations

NotSupportedByProtocolException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 ObisCode (org.openmuc.jdlms.ObisCode)1 FirmwareVersionGasDto (org.opensmartgridplatform.dto.valueobjects.FirmwareVersionGasDto)1 ConfigurationFlagDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto)1 ConfigurationFlagTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto)1