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