use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto 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.ConfigurationObjectDto 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);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto in project open-smart-grid-platform by OSGP.
the class GetConfigurationObjectCommandExecutorTest method execute.
@Test
public void execute() throws ProtocolAdapterException {
// SETUP
final DlmsDevice device = new DlmsDevice();
final Protocol protocol = Protocol.DSMR_4_2_2;
final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
device.setProtocol(protocol);
when(this.protocolServiceLookup.lookupGetService(protocol)).thenReturn(this.getService);
when(this.getService.getConfigurationObject(this.conn)).thenReturn(this.configurationObjectDto);
// CALL
final ConfigurationObjectDto result = this.instance.execute(this.conn, device, null, messageMetadata);
// VERIFY
assertThat(result).isSameAs(this.configurationObjectDto);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto in project open-smart-grid-platform by OSGP.
the class SetRandomisationSettingsCommandExecutor method writeDirectAttach.
private void writeDirectAttach(final DlmsConnectionManager conn, final DlmsDevice device, final boolean directAttach) throws ProtocolAdapterException {
final Protocol protocol = Protocol.forDevice(device);
final GetConfigurationObjectService getConfigurationObjectService = this.protocolServiceLookup.lookupGetService(protocol);
final ConfigurationObjectDto configurationOnDevice = getConfigurationObjectService.getConfigurationObject(conn);
final SetConfigurationObjectService setService = this.protocolServiceLookup.lookupSetService(protocol);
final ConfigurationObjectDto configurationToSet = this.createNewConfiguration(directAttach, configurationOnDevice);
final AccessResultCode result = setService.setConfigurationObject(conn, configurationToSet, configurationOnDevice);
this.checkResult(result, "directAttach");
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto 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);
}
Aggregations