Search in sources :

Example 1 with ConfigurationFlagDto

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);
}
Also used : ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ArrayList(java.util.ArrayList) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)

Example 2 with ConfigurationFlagDto

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);
}
Also used : ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ArrayList(java.util.ArrayList) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)

Example 3 with ConfigurationFlagDto

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);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) BitString(org.openmuc.jdlms.datatypes.BitString) ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 4 with ConfigurationFlagDto

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);
}
Also used : BitString(org.openmuc.jdlms.datatypes.BitString) ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) BitString(org.openmuc.jdlms.datatypes.BitString) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 5 with ConfigurationFlagDto

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

ConfigurationFlagDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto)9 ConfigurationFlagsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto)7 ConfigurationObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)5 ArrayList (java.util.ArrayList)4 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)3 Test (org.junit.jupiter.api.Test)2 BitString (org.openmuc.jdlms.datatypes.BitString)2 ConfigurationFlagTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 NotSupportedByProtocolException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException)1 ConfigurationFlag (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.ConfigurationFlag)1 GprsOperationModeTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto)1 SetConfigurationObjectRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto)1