use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectCommandExecutorITBase method createConfigurationObjectDto.
ConfigurationObjectDto createConfigurationObjectDto(final GprsOperationModeTypeDto gprsMode, final ConfigurationFlagDto... configurationFlagDtos) {
final List<ConfigurationFlagDto> flags = new ArrayList<>(Arrays.asList(configurationFlagDtos));
final ConfigurationFlagsDto configurationFlags = new ConfigurationFlagsDto(flags);
return new ConfigurationObjectDto(gprsMode, configurationFlags);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto in project open-smart-grid-platform by OSGP.
the class SetRandomisationSettingsCommandExecutor method createNewConfiguration.
private ConfigurationObjectDto createNewConfiguration(final boolean directAttach, final ConfigurationObjectDto configurationOnDevice) {
final List<ConfigurationFlagDto> newConfiguration = new ArrayList<>(configurationOnDevice.getConfigurationFlags().getFlags());
newConfiguration.removeIf(e -> e.getConfigurationFlagType() == ConfigurationFlagTypeDto.DIRECT_ATTACH_AT_POWER_ON);
final ConfigurationFlagDto directAttachAtPowerOn = new ConfigurationFlagDto(ConfigurationFlagTypeDto.DIRECT_ATTACH_AT_POWER_ON, directAttach);
newConfiguration.add(directAttachAtPowerOn);
final ConfigurationFlagsDto configurationFlagsDto = new ConfigurationFlagsDto(newConfiguration);
return new ConfigurationObjectDto(configurationFlagsDto);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto in project open-smart-grid-platform by OSGP.
the class GetConfigurationObjectServiceSmr5 method getConfigurationObject.
@Override
ConfigurationObjectDto getConfigurationObject(final GetResult result) throws ProtocolAdapterException {
final DataObject resultData = result.getResultData();
if (resultData == null || !resultData.isBitString()) {
LOGGER.warn("Configuration object result data is not a BitString: {}", resultData);
throw new ProtocolAdapterException("Expected bit-string data as Configuration object result data, but got: " + (resultData == null ? "null" : resultData.getType()));
}
LOGGER.info("SMR5 Configuration object current BitString: {}", this.dlmsHelper.getDebugInfo(resultData));
final BitString bitString = resultData.getValue();
final byte[] flagByteArray = bitString.getBitString();
final List<ConfigurationFlagDto> configurationFlagDtos = this.toConfigurationFlags(flagByteArray);
final ConfigurationFlagsDto configurationFlagsDto = new ConfigurationFlagsDto(configurationFlagDtos);
return new ConfigurationObjectDto(configurationFlagsDto);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto in project open-smart-grid-platform by OSGP.
the class GetConfigurationObjectServiceDsmr4 method getConfigurationFlags.
private ConfigurationFlagsDto getConfigurationFlags(final DataObject flags) throws ProtocolAdapterException {
if (flags == null || !flags.isBitString()) {
final String message = String.format("Expected ConfigurationObject flags as BitString, but got: %s", flags);
LOGGER.warn(message);
throw new ProtocolAdapterException(message);
}
final BitString bitString = flags.getValue();
final byte[] flagBytes = bitString.getBitString();
final List<ConfigurationFlagDto> configurationFlags = this.toConfigurationFlags(flagBytes);
return new ConfigurationFlagsDto(configurationFlags);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto 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