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