Search in sources :

Example 1 with GetGsmDiagnosticRequestDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto in project open-smart-grid-platform by OSGP.

the class GetGsmDiagnosticCommandExecutor method execute.

@Override
public GetGsmDiagnosticResponseDto execute(final DlmsConnectionManager conn, final DlmsDevice device, final GetGsmDiagnosticRequestDto getGsmDiagnosticQuery, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    final DlmsObject dlmsObject = this.dlmsObjectConfigService.getDlmsObjectForCommunicationMethod(device, DlmsObjectType.GSM_DIAGNOSTIC);
    final AttributeAddress[] addresses = this.createAttributeAddresses(dlmsObject);
    final String addressesDescriptions = JdlmsObjectToStringUtil.describeAttributes(addresses);
    conn.getDlmsMessageListener().setDescription("Get GsmDiagnostic, retrieve attributes: " + addressesDescriptions);
    LOGGER.info("Get GsmDiagnostic, retrieve attributes: {}", addressesDescriptions);
    final List<GetResult> getResultList = this.dlmsHelper.getAndCheck(conn, device, "Get GsmDiagnostic", addresses);
    LOGGER.info("GetResultList: {}", describeGetResults(getResultList));
    if (!getResultList.stream().allMatch(result -> result.getResultCode() == AccessResultCode.SUCCESS)) {
        throw new ProtocolAdapterException("Get gsm diagnostic failed for " + device.getDeviceId());
    }
    return this.createGetGsmDiagnosticResponse(getResultList);
}
Also used : DlmsObjectType(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType) GetResult(org.openmuc.jdlms.GetResult) Date(java.util.Date) LoggerFactory(org.slf4j.LoggerFactory) JdlmsObjectToStringUtil.describeGetResults(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.JdlmsObjectToStringUtil.describeGetResults) BitErrorRateDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.BitErrorRateDto) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) Autowired(org.springframework.beans.factory.annotation.Autowired) MODEM_REGISTRATION_STATUS(org.opensmartgridplatform.dlms.interfaceclass.attribute.GsmDiagnosticAttribute.MODEM_REGISTRATION_STATUS) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject) DlmsObjectConfigService(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService) AttributeAddress(org.openmuc.jdlms.AttributeAddress) PACKET_SWITCHED_STATUS(org.opensmartgridplatform.dlms.interfaceclass.attribute.GsmDiagnosticAttribute.PACKET_SWITCHED_STATUS) ObisCode(org.openmuc.jdlms.ObisCode) CircuitSwitchedStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CircuitSwitchedStatusDto) GetGsmDiagnosticRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) CosemDateTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto) ModemRegistrationStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ModemRegistrationStatusDto) AccessResultCode(org.openmuc.jdlms.AccessResultCode) DlmsConnectionManager(org.opensmartgridplatform.adapter.protocol.dlms.domain.factories.DlmsConnectionManager) PacketSwitchedStatusDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PacketSwitchedStatusDto) Logger(org.slf4j.Logger) DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) AbstractCommandExecutor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.AbstractCommandExecutor) OPERATOR(org.opensmartgridplatform.dlms.interfaceclass.attribute.GsmDiagnosticAttribute.OPERATOR) DataObject(org.openmuc.jdlms.datatypes.DataObject) Collectors(java.util.stream.Collectors) AdjacentCellInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AdjacentCellInfoDto) StandardCharsets(java.nio.charset.StandardCharsets) ActionRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionRequestDto) CELL_INFO(org.opensmartgridplatform.dlms.interfaceclass.attribute.GsmDiagnosticAttribute.CELL_INFO) List(java.util.List) Component(org.springframework.stereotype.Component) ADJACENT_CELLS(org.opensmartgridplatform.dlms.interfaceclass.attribute.GsmDiagnosticAttribute.ADJACENT_CELLS) SignalQualityDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SignalQualityDto) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) CIRCUIT_SWITCHED_STATUS(org.opensmartgridplatform.dlms.interfaceclass.attribute.GsmDiagnosticAttribute.CIRCUIT_SWITCHED_STATUS) Collections(java.util.Collections) CellInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CellInfoDto) JdlmsObjectToStringUtil(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.JdlmsObjectToStringUtil) GetGsmDiagnosticResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticResponseDto) GetResult(org.openmuc.jdlms.GetResult) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)

Example 2 with GetGsmDiagnosticRequestDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto in project open-smart-grid-platform by OSGP.

the class ManagementService method getGsmDiagnostic.

public void getGsmDiagnostic(final MessageMetadata messageMetadata, final GetGsmDiagnosticRequestData request) throws FunctionalException {
    LOGGER.info("Get gsm diagnostic for organisationIdentification: {} for deviceIdentification: {}", messageMetadata.getOrganisationIdentification(), messageMetadata.getDeviceIdentification());
    final GetGsmDiagnosticRequestDto requestDto = this.managementMapper.map(request, GetGsmDiagnosticRequestDto.class);
    final SmartMeter smartMeter = this.domainHelperService.findSmartMeter(messageMetadata.getDeviceIdentification());
    this.osgpCoreRequestMessageSender.send(requestDto, messageMetadata.builder().withIpAddress(smartMeter.getIpAddress()).withNetworkSegmentIds(smartMeter.getBtsId(), smartMeter.getCellId()).build());
}
Also used : GetGsmDiagnosticRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto) SmartMeter(org.opensmartgridplatform.domain.core.entities.SmartMeter)

Example 3 with GetGsmDiagnosticRequestDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto in project open-smart-grid-platform by OSGP.

the class GetGsmDiagnosticCommandExecutorIntegrationTest method testExecute.

private void testExecute(final Protocol protocol, final CommunicationMethod method, final boolean expectObjectNotFound) throws Exception {
    // SETUP
    final MessageMetadata messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
    // Reset stub
    this.connectionStub.clearRequestedAttributeAddresses();
    // Create device with requested protocol version and communication method
    final DlmsDevice device = this.createDlmsDevice(protocol, method);
    // Create request object
    final GetGsmDiagnosticRequestDto request = new GetGsmDiagnosticRequestDto();
    // Get expected addresses
    final AttributeAddress expectedAddressOperator = this.createAttributeAddress(method, 2);
    final AttributeAddress expectedAddressRegistrationStatus = this.createAttributeAddress(method, 3);
    final AttributeAddress expectedAddressCsStatus = this.createAttributeAddress(method, 4);
    final AttributeAddress expectedAddressPsStatus = this.createAttributeAddress(method, 5);
    final AttributeAddress expectedAddressCellInfo = this.createAttributeAddress(method, 6);
    final AttributeAddress expectedAddressAdjacentCells = this.createAttributeAddress(method, 7);
    final AttributeAddress expectedAddressCaptureTime = this.createAttributeAddress(method, 8);
    // Reading of capture_time is disabled for now, therefore only 6 addresses expected
    final int expectedTotalNumberOfAttributeAddresses = 6;
    // Set responses in stub
    this.setResponseForOperator(expectedAddressOperator);
    this.setResponseForRegistrationStatus(expectedAddressRegistrationStatus);
    this.setResponseForCsStatus(expectedAddressCsStatus);
    this.setResponseForPsStatus(expectedAddressPsStatus);
    this.setResponseForCellInfo(expectedAddressCellInfo);
    this.setResponseForAdjacentCells(expectedAddressAdjacentCells);
    this.setResponseForCaptureTime(expectedAddressCaptureTime);
    // CALL
    GetGsmDiagnosticResponseDto response = null;
    try {
        response = this.executor.execute(this.connectionManagerStub, device, request, messageMetadata);
    } catch (final ProtocolAdapterException e) {
        if (expectObjectNotFound) {
            assertThat(e.getMessage()).isEqualTo("Did not find GSM_DIAGNOSTIC object with communication method " + method.getMethodName() + " for device 6789012");
            return;
        } else {
            fail("Unexpected ProtocolAdapterException: " + e.getMessage());
        }
    }
    // VERIFY
    // Get resulting requests from connection stub
    final List<AttributeAddress> requestedAttributeAddresses = this.connectionStub.getRequestedAttributeAddresses();
    assertThat(requestedAttributeAddresses.size()).isEqualTo(expectedTotalNumberOfAttributeAddresses);
    // Check response
    assertThat(response).isNotNull();
    assertThat(response).isNotNull();
    assertThat(response.getOperator()).isEqualTo("Operator");
    assertThat(response.getModemRegistrationStatus()).isEqualTo(ModemRegistrationStatusDto.REGISTERED_ROAMING);
    assertThat(response.getCircuitSwitchedStatus()).isEqualTo(CircuitSwitchedStatusDto.INACTIVE);
    assertThat(response.getPacketSwitchedStatus()).isEqualTo(PacketSwitchedStatusDto.CDMA);
    final CellInfoDto cellInfo = response.getCellInfo();
    assertThat(cellInfo.getCellId()).isEqualTo(93L);
    assertThat(cellInfo.getLocationId()).isEqualTo(2232);
    assertThat(cellInfo.getSignalQuality()).isEqualTo(SignalQualityDto.MINUS_87_DBM);
    assertThat(cellInfo.getBitErrorRate()).isEqualTo(BitErrorRateDto.RXQUAL_6);
    assertThat(cellInfo.getMobileCountryCode()).isEqualTo(204);
    assertThat(cellInfo.getMobileNetworkCode()).isEqualTo(66);
    assertThat(cellInfo.getChannelNumber()).isEqualTo(107);
    final List<AdjacentCellInfoDto> adjacentCells = response.getAdjacentCells();
    assertThat(adjacentCells.size()).isEqualTo(3);
    assertThat(adjacentCells.get(0).getCellId()).isEqualTo(85L);
    assertThat(adjacentCells.get(0).getSignalQuality()).isEqualTo(SignalQualityDto.MINUS_65_DBM);
// Reading of capture_time is disabled, so don't check the capture time
// assertThat(response.getCaptureTime())
// .isEqualTo(new DateTime(2021, 4, 1, 9, 28, DateTimeZone.UTC).toDate());
}
Also used : GetGsmDiagnosticRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto) GetGsmDiagnosticResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticResponseDto) AdjacentCellInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AdjacentCellInfoDto) CellInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CellInfoDto) MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) AdjacentCellInfoDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.AdjacentCellInfoDto) AttributeAddress(org.openmuc.jdlms.AttributeAddress) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)

Example 4 with GetGsmDiagnosticRequestDto

use of org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto in project open-smart-grid-platform by OSGP.

the class GetGsmDiagnosticRequestMessageProcessor method handleMessage.

@Override
protected Serializable handleMessage(final DlmsConnectionManager conn, final DlmsDevice device, final Serializable requestObject, final MessageMetadata messageMetadata) throws OsgpException {
    this.assertRequestObjectType(GetGsmDiagnosticRequestDto.class, requestObject);
    final GetGsmDiagnosticRequestDto requestDto = (GetGsmDiagnosticRequestDto) requestObject;
    return this.managementService.getGsmDiagnostic(conn, device, requestDto, messageMetadata);
}
Also used : GetGsmDiagnosticRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto)

Aggregations

GetGsmDiagnosticRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticRequestDto)4 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 DlmsDevice (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice)2 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)2 AdjacentCellInfoDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.AdjacentCellInfoDto)2 CellInfoDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CellInfoDto)2 GetGsmDiagnosticResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.GetGsmDiagnosticResponseDto)2 MessageMetadata (org.opensmartgridplatform.shared.infra.jms.MessageMetadata)2 StandardCharsets (java.nio.charset.StandardCharsets)1 Collections (java.util.Collections)1 Date (java.util.Date)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 AccessResultCode (org.openmuc.jdlms.AccessResultCode)1 GetResult (org.openmuc.jdlms.GetResult)1 ObisCode (org.openmuc.jdlms.ObisCode)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 AbstractCommandExecutor (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.AbstractCommandExecutor)1 DlmsObjectConfigService (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectConfigService)1 DlmsObjectType (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType)1