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