Search in sources :

Example 1 with GprsOperationModeTypeDto

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);
    }
}
Also used : GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) AccessResultCode(org.openmuc.jdlms.AccessResultCode) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 2 with GprsOperationModeTypeDto

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));
}
Also used : GetResult(org.openmuc.jdlms.GetResult) Logger(org.slf4j.Logger) DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) LoggerFactory(org.slf4j.LoggerFactory) DataObject(org.openmuc.jdlms.datatypes.DataObject) ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) BitString(org.openmuc.jdlms.datatypes.BitString) List(java.util.List) Component(org.springframework.stereotype.Component) ConfigurationFlagTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto) Optional(java.util.Optional) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)

Example 3 with GprsOperationModeTypeDto

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);
}
Also used : GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) GprsOperationModeType(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GprsOperationModeType) Test(org.junit.jupiter.api.Test)

Example 4 with GprsOperationModeTypeDto

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);
}
Also used : GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) DataObject(org.openmuc.jdlms.datatypes.DataObject) BitString(org.openmuc.jdlms.datatypes.BitString) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) AccessResultCode(org.openmuc.jdlms.AccessResultCode) Test(org.junit.jupiter.api.Test)

Example 5 with GprsOperationModeTypeDto

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());
}
Also used : GprsOperationModeTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto) ConfigurationFlagsDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto) ConfigurationFlagDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto) ConfigurationObjectDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto) ConfigurationFlagTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto) SetConfigurationObjectRequestDataDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto)

Aggregations

GprsOperationModeTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GprsOperationModeTypeDto)6 ConfigurationObjectDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationObjectDto)5 Test (org.junit.jupiter.api.Test)3 AccessResultCode (org.openmuc.jdlms.AccessResultCode)3 BitString (org.openmuc.jdlms.datatypes.BitString)3 DataObject (org.openmuc.jdlms.datatypes.DataObject)3 ConfigurationFlagsDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagsDto)3 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)2 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)2 ConfigurationFlagDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagDto)2 ConfigurationFlagTypeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ConfigurationFlagTypeDto)2 List (java.util.List)1 Optional (java.util.Optional)1 GetResult (org.openmuc.jdlms.GetResult)1 DlmsHelper (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper)1 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)1 GprsOperationModeType (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.GprsOperationModeType)1 SetConfigurationObjectRequestDataDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetConfigurationObjectRequestDataDto)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1