Search in sources :

Example 1 with ConfigurationFlagTypeDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto 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)

Example 2 with ConfigurationFlagTypeDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto in project open-smart-grid-platform by OSGP.

the class SetConfigurationObjectRequestMappingTest method checkSetConfigurationObjectRequestData.

// method to check values of all objects that are mapped when a
// SetConfigurationObjectRequest is mapped.
private void checkSetConfigurationObjectRequestData(final GprsOperationModeType gprsOperationModeType, final ConfigurationFlagType configurationFlagType, final ConfigurationFlags configurationFlags, final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto) {
    // check if SetConfigurationObjectRequesDataDto object is present
    final SetConfigurationObjectRequestDataDto setConfigurationObjectRequestDataDto = setConfigurationObjectRequestDto.getSetConfigurationObjectRequestData();
    assertThat(setConfigurationObjectRequestDto).isNotNull();
    // check if ConfigurationObjectDto object is present
    final ConfigurationObjectDto configurationObjectDto = setConfigurationObjectRequestDataDto.getConfigurationObject();
    assertThat(configurationObjectDto).isNotNull();
    // check the GprsOperationModeTypeDto value
    final GprsOperationModeTypeDto gprsOperationModeTypeDto = configurationObjectDto.getGprsOperationMode();
    assertThat(gprsOperationModeTypeDto.name()).isEqualTo(gprsOperationModeType.name());
    // check if ConfigurationFlagsDto object is present, and if its List is
    // of an equal size.
    final ConfigurationFlagsDto configurationFlagsDto = configurationObjectDto.getConfigurationFlags();
    assertThat(configurationFlagsDto).isNotNull();
    assertThat(configurationFlagsDto.getFlags().size()).isEqualTo(configurationFlags.getFlags().size());
    // check ConfigurationObjectFlagTypeDto value.
    final ConfigurationFlagDto configurationFlagDto = configurationFlagsDto.getFlags().get(0);
    final ConfigurationFlagTypeDto configurationFlagTypeDto = configurationFlagDto.getConfigurationFlagType();
    assertThat(configurationFlagTypeDto.name()).isEqualTo(configurationFlagType.name());
}
Also used : GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) ConfigurationFlagTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto) SetConfigurationObjectRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto)

Aggregations

ConfigurationFlagDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto)2 ConfigurationFlagTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto)2 NotSupportedByProtocolException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.NotSupportedByProtocolException)1 ConfigurationFlagsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto)1 ConfigurationObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)1 GprsOperationModeTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto)1 SetConfigurationObjectRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto)1