use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto 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.ConfigurationObjectDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final ConfigurationObjectDto configurationToSet, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final Protocol protocol = Protocol.forDevice(device);
final GetConfigurationObjectService getService = this.protocolServiceLookup.lookupGetService(protocol);
final ConfigurationObjectDto configurationOnDevice = getService.getConfigurationObject(conn);
final SetConfigurationObjectService setService = this.protocolServiceLookup.lookupSetService(protocol);
return setService.setConfigurationObject(conn, configurationToSet, configurationOnDevice);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto 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.ConfigurationObjectDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectRequestMappingTest method testMappingWithNullConfigurationObject.
// Test if mapping with a null ConfigurationObject succeeds
@Test
public void testMappingWithNullConfigurationObject() {
// build test data
final String deviceIdentification = "nr1";
final ConfigurationObjectDto configurationObject = null;
final SetConfigurationObjectRequestDataDto setConfigurationObjectRequestData = new SetConfigurationObjectRequestDataDto(configurationObject);
// actual mapping
final SetConfigurationObjectRequestDto setConfigurationObjectRequest = new SetConfigurationObjectRequestDto(deviceIdentification, setConfigurationObjectRequestData);
final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto = this.configurationMapper.map(setConfigurationObjectRequest, SetConfigurationObjectRequestDto.class);
// check values
assertThat(setConfigurationObjectRequestDto).isNotNull();
assertThat(setConfigurationObjectRequestDto.getDeviceIdentification()).isEqualTo(deviceIdentification);
assertThat(setConfigurationObjectRequestDto.getSetConfigurationObjectRequestData().getConfigurationObject()).isNull();
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectCommandExecutorSmr5IT method execute.
@Test
public void execute() throws IOException, ProtocolAdapterException {
// SETUP
// configurationToSet: ------1---10101-
// GPRS operation mode is not part of the ConfigurationObject in SMR5
final GprsOperationModeTypeDto gprsMode = null;
final ConfigurationObjectDto configurationToSet = this.createConfigurationObjectDto(gprsMode, this.createFlagDto(ConfigurationFlagTypeDto.HLS_5_ON_P_3_ENABLE, true), this.createFlagDto(ConfigurationFlagTypeDto.DIRECT_ATTACH_AT_POWER_ON, true), this.createFlagDto(ConfigurationFlagTypeDto.HLS_6_ON_P3_ENABLE, false), this.createFlagDto(ConfigurationFlagTypeDto.HLS_7_ON_P3_ENABLE, true), this.createFlagDto(ConfigurationFlagTypeDto.HLS_6_ON_P0_ENABLE, false), this.createFlagDto(ConfigurationFlagTypeDto.HLS_7_ON_P0_ENABLE, true));
// flagsOnDevice: 0000000001110100
final byte[] flagsOnDevice = this.createFlagBytes(ConfigurationFlagTypeDto.HLS_5_ON_PO_ENABLE, ConfigurationFlagTypeDto.DIRECT_ATTACH_AT_POWER_ON, ConfigurationFlagTypeDto.HLS_6_ON_P3_ENABLE, ConfigurationFlagTypeDto.HLS_6_ON_P0_ENABLE);
// result of merging configurationToSet and flagsOnDevice
final byte firstExpectedByte = this.asByte("00000010");
final byte secondExpectedByte = this.asByte("01101010");
final DataObject deviceData = this.createBitStringData(flagsOnDevice);
when(this.getResult.getResultData()).thenReturn(deviceData);
final DlmsDevice device = new DlmsDevice();
device.setProtocol(Protocol.SMR_5_0_0);
// CALL
final AccessResultCode result = this.instance.execute(this.conn, device, configurationToSet, this.messageMetadata);
// VERIFY
assertThat(result).isEqualTo(AccessResultCode.SUCCESS);
final BitString configurationFlags = this.captureSetParameterBitStringData();
final byte[] flagsSentToDevice = configurationFlags.getBitString();
assertThat(flagsSentToDevice[0]).isEqualTo(firstExpectedByte);
assertThat(flagsSentToDevice[1]).isEqualTo(secondExpectedByte);
}
Aggregations