Search in sources :

Example 1 with SetRandomisationSettingsRequestDataDto

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

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

the class ConfigurationService method setRandomisationSettings.

public void setRandomisationSettings(final MessageMetadata messageMetadata, final SetRandomisationSettingsRequestData data) throws FunctionalException {
    log.info("setRandomisationSettings for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    final SetRandomisationSettingsRequestDataDto requestDto = new SetRandomisationSettingsRequestDataDto(data.getDirectAttach(), data.getRandomisationStartWindow(), data.getMultiplicationFactor(), data.getNumberOfRetries());
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Also used : SetRandomisationSettingsRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetRandomisationSettingsRequestDataDto) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter)

Example 3 with SetRandomisationSettingsRequestDataDto

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

the class SetRandomisationSettingsMessageProcessor method handleMessage.

@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
    this.assertRequestObjectType(SetRandomisationSettingsRequestDataDto.class, requestObject);
    final SetRandomisationSettingsRequestDataDto setRandomisationSettingsRequestDataDto = (SetRandomisationSettingsRequestDataDto) requestObject;
    this.configurationService.requestSetRandomizationSettings(conn, device, setRandomisationSettingsRequestDataDto, messageMetadata);
    return null;
}
Also used : SetRandomisationSettingsRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetRandomisationSettingsRequestDataDto)

Aggregations

SetRandomisationSettingsRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetRandomisationSettingsRequestDataDto)3 BeforeEach (org.junit.jupiter.api.BeforeEach)1 AttributeAddress (org.openmuc.jdlms.AttributeAddress)1 ObisCode (org.openmuc.jdlms.ObisCode)1 SetParameter (org.openmuc.jdlms.SetParameter)1 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)1 DlmsConnectionManager (org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager)1 SmartMeter (org.opensmartgridplatform.domain.core.entities.SmartMeter)1 ConfigurationFlagsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto)1 ConfigurationObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)1