use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto 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.GprsOperationModeTypeDto 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.GprsOperationModeTypeDto in project open-smart-grid-platform by OSGP.
the class GetConfigurationObjectResponseMappingTest method testMapGprsOperationModeTypeDto.
@Test
public void testMapGprsOperationModeTypeDto() {
final GprsOperationModeTypeDto dto = GprsOperationModeTypeDto.ALWAYS_ON;
final GprsOperationModeType result = this.mapper.map(dto, GprsOperationModeType.class);
assertThat(result).withFailMessage("mapping GprsOperationModeTypeDto should not return null").isNotNull();
assertThat(result).withFailMessage("mapping GprsOperationModeTypeDto should return correct type").isOfAnyClassIn(GprsOperationModeType.class);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto 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);
}
use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectRequestMappingTest method checkSetConfigurationObjectRequestData.
// method to check values of all objects that are mapped when a
// SetConfigurationObjectRequest is mapped.
private void checkSetConfigurationObjectRequestData(final GprsOperationModeType gprsOperationModeType, final ConfigurationFlagType configurationFlagType, final ConfigurationFlags configurationFlags, final SetConfigurationObjectRequestDto setConfigurationObjectRequestDto) {
// check if SetConfigurationObjectRequesDataDto object is present
final SetConfigurationObjectRequestDataDto setConfigurationObjectRequestDataDto = setConfigurationObjectRequestDto.getSetConfigurationObjectRequestData();
assertThat(setConfigurationObjectRequestDto).isNotNull();
// check if ConfigurationObjectDto object is present
final ConfigurationObjectDto configurationObjectDto = setConfigurationObjectRequestDataDto.getConfigurationObject();
assertThat(configurationObjectDto).isNotNull();
// check the GprsOperationModeTypeDto value
final GprsOperationModeTypeDto gprsOperationModeTypeDto = configurationObjectDto.getGprsOperationMode();
assertThat(gprsOperationModeTypeDto.name()).isEqualTo(gprsOperationModeType.name());
// check if ConfigurationFlagsDto object is present, and if its List is
// of an equal size.
final ConfigurationFlagsDto configurationFlagsDto = configurationObjectDto.getConfigurationFlags();
assertThat(configurationFlagsDto).isNotNull();
assertThat(configurationFlagsDto.getFlags().size()).isEqualTo(configurationFlags.getFlags().size());
// check ConfigurationObjectFlagTypeDto value.
final ConfigurationFlagDto configurationFlagDto = configurationFlagsDto.getFlags().get(0);
final ConfigurationFlagTypeDto configurationFlagTypeDto = configurationFlagDto.getConfigurationFlagType();
assertThat(configurationFlagTypeDto.name()).isEqualTo(configurationFlagType.name());
}
Aggregations