Search in sources :

Example 1 with ConfigurationFlagsDto

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

the class ConfigurationService method requestSetConfiguration.

// === REQUEST Configuration Object DATA ===
public void requestSetConfiguration(final DlmsConnectionManager conn, final DlmsDevice device, final SetConfigurationObjectRequestDto setConfigurationObjectRequest, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    // Configuration Object towards the Smart Meter
    final ConfigurationObjectDto configurationObject = setConfigurationObjectRequest.getSetConfigurationObjectRequestData().getConfigurationObject();
    final GprsOperationModeTypeDto gprsOperationModeType = configurationObject.getGprsOperationMode();
    final ConfigurationFlagsDto configurationFlags = configurationObject.getConfigurationFlags();
    LOGGER.info(VISUAL_SEPARATOR);
    LOGGER.info("******** Configuration Object: 0-1:94.31.3.255 *******");
    LOGGER.info(VISUAL_SEPARATOR);
    LOGGER.info("Operation mode: {}", gprsOperationModeType == null ? "not altered by this request" : gprsOperationModeType);
    if (configurationFlags == null) {
        LOGGER.info("Flags: none enabled or disabled by this request");
    } else {
        LOGGER.info("{}", configurationFlags);
    }
    LOGGER.info(VISUAL_SEPARATOR);
    final AccessResultCode accessResultCode = this.setConfigurationObjectCommandExecutor.execute(conn, device, configurationObject, messageMetadata);
    if (!AccessResultCode.SUCCESS.equals(accessResultCode)) {
        throw new ProtocolAdapterException("Set configuration object reported result is: " + accessResultCode);
    }
}
Also used : GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) AccessResultCode(org.openmuc.jdlms.AccessResultCode) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 2 with ConfigurationFlagsDto

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

the class GetConfigurationObjectServiceDsmr4 method getConfigurationObject.

private ConfigurationObjectDto getConfigurationObject(final List<DataObject> elements) throws ProtocolAdapterException {
    final Optional<GprsOperationModeTypeDto> gprsMode = this.getGprsOperationMode(elements.get(INDEX_OF_GPRS_OPERATION_MODE));
    final ConfigurationFlagsDto flags = this.getConfigurationFlags(elements.get(INDEX_OF_CONFIGURATION_FLAGS));
    return gprsMode.map(c -> new ConfigurationObjectDto(c, flags)).orElseGet(() -> new ConfigurationObjectDto(flags));
}
Also used : GetResult(org.openmuc.jdlms.GetResult) Logger(org.slf4j.Logger) DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) LoggerFactory(org.slf4j.LoggerFactory) DataObject(org.openmuc.jdlms.datatypes.DataObject) ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) BitString(org.openmuc.jdlms.datatypes.BitString) List(java.util.List) Component(org.springframework.stereotype.Component) ConfigurationFlagTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto) Optional(java.util.Optional) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)

Example 3 with ConfigurationFlagsDto

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

the class SetRandomisationSettingsCommandExecutorTest method init.

@BeforeEach
public void init() throws ProtocolAdapterException, IOException {
    // SETUP
    final Protocol smr51 = Protocol.SMR_5_1;
    this.device = this.createDlmsDevice(smr51);
    this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
    final AttributeAddress address = new AttributeAddress(1, new ObisCode("0.1.94.31.12.255"), 1);
    this.dataDto = new SetRandomisationSettingsRequestDataDto(0, 1, 1, 1);
    final ConfigurationFlagsDto currentConfigurationFlagsDto = new ConfigurationFlagsDto(this.getFlags());
    final ConfigurationObjectDto currentConfigurationObjectDto = new ConfigurationObjectDto(currentConfigurationFlagsDto);
    when(this.protocolServiceLookup.lookupGetService(smr51)).thenReturn(this.getConfigurationObjectService);
    when(this.protocolServiceLookup.lookupSetService(smr51)).thenReturn(this.setConfigurationObjectService);
    when(this.getConfigurationObjectService.getConfigurationObject(this.dlmsConnectionManager)).thenReturn(currentConfigurationObjectDto);
    when(this.setConfigurationObjectService.setConfigurationObject(any(DlmsConnectionManager.class), any(ConfigurationObjectDto.class), any(ConfigurationObjectDto.class))).thenReturn(AccessResultCode.SUCCESS);
    when(this.dlmsObjectConfigService.getAttributeAddress(this.device, DlmsObjectType.RANDOMISATION_SETTINGS, null)).thenReturn(address);
    when(this.dlmsConnectionManager.getConnection()).thenReturn(this.dlmsConnection);
    when(this.dlmsConnection.set(any(SetParameter.class))).thenReturn(AccessResultCode.SUCCESS);
}
Also used : SetRandomisationSettingsRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetRandomisationSettingsRequestDataDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) ObisCode(org.openmuc.jdlms.ObisCode) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) SetParameter(org.openmuc.jdlms.SetParameter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ConfigurationFlagsDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto 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 5 with ConfigurationFlagsDto

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

Aggregations

ConfigurationFlagsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto)10 ConfigurationFlagDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto)8 ConfigurationObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)8 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)5 ArrayList (java.util.ArrayList)4 BitString (org.openmuc.jdlms.datatypes.BitString)3 GprsOperationModeTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto)3 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)2 ConfigurationFlagTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto)2 List (java.util.List)1 Optional (java.util.Optional)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1 AccessResultCode (org.openmuc.jdlms.AccessResultCode)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 GetResult (org.openmuc.jdlms.GetResult)1 ObisCode (org.openmuc.jdlms.ObisCode)1 SetParameter (org.openmuc.jdlms.SetParameter)1 DlmsHelper (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper)1