Search in sources :

Example 1 with EventMessageDataResponseDto

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

the class ManagementService method findEvents.

// === FIND EVENTS ===
public EventMessageDataResponseDto findEvents(final DlmsConnectionManager conn, final DlmsDevice device, final FindEventsRequestList findEventsQueryMessageDataContainer, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
    final List<EventDto> events = new ArrayList<>();
    log.info("findEvents setting up connection with meter {}", device.getDeviceIdentification());
    for (final FindEventsRequestDto findEventsQuery : findEventsQueryMessageDataContainer.getFindEventsQueryList()) {
        log.info("findEventsQuery.eventLogCategory: {}, findEventsQuery.from: {}, findEventsQuery.until: {}", findEventsQuery.getEventLogCategory().toString(), findEventsQuery.getFrom(), findEventsQuery.getUntil());
        events.addAll(this.findEventsCommandExecutor.execute(conn, device, findEventsQuery, messageMetadata));
    }
    return new EventMessageDataResponseDto(events);
}
Also used : FindEventsRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto) EventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto) ArrayList(java.util.ArrayList) EventMessageDataResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)

Example 2 with EventMessageDataResponseDto

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

the class EventMessageDataContainerMappingTest method testWithNullList.

// Test if mapping with a null List succeeds
@Test
public void testWithNullList() {
    // build test data
    final EventMessageDataResponseDto containerDto = new EventMessageDataResponseDto(null);
    // actual mapping
    final EventMessagesResponse container = this.managementMapper.map(containerDto, EventMessagesResponse.class);
    // test mapping
    assertThat(container).isNotNull();
    assertThat(container.getEvents()).isNull();
}
Also used : EventMessagesResponse(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventMessagesResponse) EventMessageDataResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto) Test(org.junit.jupiter.api.Test)

Example 3 with EventMessageDataResponseDto

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

the class EventServiceTest method testWrongEventCode.

@Test
void testWrongEventCode() {
    final FunctionalException functionalException = Assertions.assertThrows(FunctionalException.class, () -> {
        final ProtocolInfo protocolInfo = mock(ProtocolInfo.class);
        when(protocolInfo.getProtocol()).thenReturn("SMR");
        when(this.smartMeter.getProtocolInfo()).thenReturn(protocolInfo);
        final EventDto event = new EventDto(new DateTime(), 266, 2, "STANDARD_EVENT_LOG");
        final ArrayList<EventDto> events = new ArrayList<>();
        events.add(event);
        final EventMessageDataResponseDto responseDto = new EventMessageDataResponseDto(events);
        this.eventService.enrichEvents(this.deviceMessageMetadata, responseDto);
    });
    assertThat(functionalException.getExceptionType()).isEqualTo(FunctionalExceptionType.VALIDATION_ERROR);
}
Also used : EventDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto) ArrayList(java.util.ArrayList) ProtocolInfo(org.opensmartgridplatform.domain.core.entities.ProtocolInfo) FunctionalException(org.opensmartgridplatform.shared.exceptionhandling.FunctionalException) EventMessageDataResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto) DateTime(org.joda.time.DateTime) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with EventMessageDataResponseDto

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

the class BundleService method checkIfAdditionalActionIsNeeded.

private void checkIfAdditionalActionIsNeeded(final MessageMetadata messageMetadata, final BundleMessagesRequestDto bundleMessagesRequestDto) throws FunctionalException {
    for (final ActionResponseDto action : bundleMessagesRequestDto.getAllResponses()) {
        if (action instanceof CoupleMbusDeviceByChannelResponseDto) {
            this.mBusGatewayService.handleCoupleMbusDeviceByChannelResponse(messageMetadata, (CoupleMbusDeviceByChannelResponseDto) action);
        } else if (action instanceof DecoupleMbusDeviceResponseDto) {
            this.mBusGatewayService.handleDecoupleMbusDeviceResponse(messageMetadata, (DecoupleMbusDeviceResponseDto) action);
        } else if (action instanceof SetDeviceLifecycleStatusByChannelResponseDto) {
            this.managementService.setDeviceLifecycleStatusByChannel((SetDeviceLifecycleStatusByChannelResponseDto) action);
        } else if (action instanceof EventMessageDataResponseDto) {
            this.eventService.enrichEvents(messageMetadata, (EventMessageDataResponseDto) action);
        } else if (action instanceof FirmwareVersionResponseDto) {
            final List<FirmwareVersion> firmwareVersions = this.configurationMapper.mapAsList(((FirmwareVersionResponseDto) action).getFirmwareVersions(), FirmwareVersion.class);
            this.firmwareService.saveFirmwareVersionsReturnedFromDevice(messageMetadata.getDeviceIdentification(), firmwareVersions);
        } else if (action instanceof FirmwareVersionGasResponseDto) {
            final FirmwareVersionGasResponseDto firmwareVersionGasResponseDto = (FirmwareVersionGasResponseDto) action;
            final FirmwareVersion firmwareVersion = this.configurationMapper.map(firmwareVersionGasResponseDto.getFirmwareVersion(), FirmwareVersion.class);
            this.firmwareService.saveFirmwareVersionsReturnedFromDevice(firmwareVersionGasResponseDto.getFirmwareVersion().getMbusDeviceIdentification(), Arrays.asList(firmwareVersion));
        }
    }
}
Also used : ActionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto) SetDeviceLifecycleStatusByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseDto) DecoupleMbusDeviceResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto) FirmwareVersionResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionResponseDto) EventMessageDataResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto) CoupleMbusDeviceByChannelResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto) FirmwareVersionGasResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionGasResponseDto) FirmwareVersion(org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)

Example 5 with EventMessageDataResponseDto

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

the class FindEventsResponseMessageProcessor method handleMessage.

@Override
protected void handleMessage(final MessageMetadata deviceMessageMetadata, final ResponseMessage responseMessage, final OsgpException osgpException) throws FunctionalException {
    final EventMessageDataResponseDto eventMessageDataContainer = (EventMessageDataResponseDto) responseMessage.getDataObject();
    this.managementService.handleFindEventsResponse(deviceMessageMetadata, responseMessage.getResult(), osgpException, eventMessageDataContainer);
}
Also used : EventMessageDataResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)

Aggregations

EventMessageDataResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventMessageDataResponseDto)8 EventDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDto)5 ArrayList (java.util.ArrayList)4 Test (org.junit.jupiter.api.Test)4 DateTime (org.joda.time.DateTime)3 EventMessagesResponse (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.EventMessagesResponse)3 ProtocolInfo (org.opensmartgridplatform.domain.core.entities.ProtocolInfo)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 FirmwareVersion (org.opensmartgridplatform.domain.core.valueobjects.FirmwareVersion)1 ActionResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.ActionResponseDto)1 CoupleMbusDeviceByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CoupleMbusDeviceByChannelResponseDto)1 DecoupleMbusDeviceResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.DecoupleMbusDeviceResponseDto)1 EventDetailDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.EventDetailDto)1 FindEventsRequestDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FindEventsRequestDto)1 FirmwareVersionGasResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionGasResponseDto)1 FirmwareVersionResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.FirmwareVersionResponseDto)1 SetDeviceLifecycleStatusByChannelResponseDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.SetDeviceLifecycleStatusByChannelResponseDto)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1