Search in sources :

Example 6 with EventNotificationDto

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

the class Iec61850ClientSSLDEventListener method addEventNotificationForReportedData.

private void addEventNotificationForReportedData(final FcModelNode evnRpn, final DateTime timeOfEntry, final String reportDescription) {
    final EventTypeDto eventType = this.determineEventType(evnRpn, reportDescription);
    final Integer index = this.determineRelayIndex(evnRpn, reportDescription);
    final String description = this.determineDescription(evnRpn);
    final DateTime dateTime = this.determineDateTime(evnRpn, timeOfEntry);
    final EventNotificationDto eventNotification = new EventNotificationDto(this.deviceIdentification, dateTime, eventType, description, index);
    synchronized (this.eventNotifications) {
        this.eventNotifications.add(eventNotification);
    }
}
Also used : EventNotificationDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationDto) BdaVisibleString(com.beanit.openiec61850.BdaVisibleString) DateTime(org.joda.time.DateTime) EventTypeDto(org.opensmartgridplatform.dto.valueobjects.EventTypeDto)

Example 7 with EventNotificationDto

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

the class LightSensorDeviceResponseService method findEventNotification.

private Optional<EventNotificationDto> findEventNotification(final MeasurementGroupDto measurementGroup, final Iec60870Device device) {
    final String deviceUid = device.getDeviceIdentification();
    final int index = device.getInformationObjectAddress();
    final EventTypeDto eventType = this.findSensorValue(measurementGroup).map(this::determineLightSensorEventType).orElse(null);
    if (eventType == null) {
        LOGGER.warn("Unable to determine event type for event notification for device {}", device.getDeviceIdentification());
    }
    final DateTime dateTime = this.findTimeValue(measurementGroup).orElse(null);
    if (dateTime == null) {
        LOGGER.warn("Unable to determine the time for event notification for device {}", device.getDeviceIdentification());
    }
    final EventNotificationDto eventNotification;
    if (eventType == null || dateTime == null) {
        eventNotification = null;
    } else {
        eventNotification = new EventNotificationDto(deviceUid, dateTime, eventType, "Spontaneous report", index);
    }
    return Optional.ofNullable(eventNotification);
}
Also used : EventNotificationDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationDto) DateTime(org.joda.time.DateTime) EventTypeDto(org.opensmartgridplatform.dto.valueobjects.EventTypeDto)

Example 8 with EventNotificationDto

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

the class OsgpCoreRequestSteps method theProtocolAdapterShouldSendALightMeasurementEventToOsgpCore.

@Then("the protocol adapter should send a light measurement event to osgp core")
public void theProtocolAdapterShouldSendALightMeasurementEventToOsgpCore(final Map<String, String> eventData) {
    final String expectedEventType = Objects.requireNonNull(eventData.get("event_type"));
    final String expectedDeviceIdentification = Objects.requireNonNull(eventData.get("device_identification"));
    final ArgumentCaptor<RequestMessage> requestMessageCaptor = ArgumentCaptor.forClass(RequestMessage.class);
    verify(this.osgpRequestMessageSenderMock, times(1)).send(requestMessageCaptor.capture(), eq(MessageType.EVENT_NOTIFICATION.name()));
    final RequestMessage requestMessage = requestMessageCaptor.getValue();
    assertThat(requestMessage.getDeviceIdentification()).isEqualTo(expectedDeviceIdentification);
    final Serializable request = requestMessage.getRequest();
    assertThat(request).isInstanceOf(EventNotificationDto.class);
    final EventNotificationDto eventNotificationDto = (EventNotificationDto) request;
    assertThat(eventNotificationDto.getEventType().name()).isEqualTo(expectedEventType);
}
Also used : Serializable(java.io.Serializable) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) EventNotificationDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationDto) Then(io.cucumber.java.en.Then)

Example 9 with EventNotificationDto

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

the class Iec61850ClientLMDEventListener method getEventNotificationForReportedData.

private EventNotificationDto getEventNotificationForReportedData(final FcModelNode evnRpn, final DateTime timeOfEntry, final String reportDescription, final String deviceIdentification, final Integer index) {
    EventTypeDto eventType;
    final boolean lightSensorValue = this.determineLightSensorValue(evnRpn, reportDescription);
    /*
     * 0 -> false -> NIGHT_DAY --> LIGHT_SENSOR_REPORTS_LIGHT
     * 1 -> true -> DAY_NIGHT --> LIGHT_SENSOR_REPORTS_DARK
     */
    if (lightSensorValue) {
        eventType = EventTypeDto.LIGHT_SENSOR_REPORTS_DARK;
    } else {
        eventType = EventTypeDto.LIGHT_SENSOR_REPORTS_LIGHT;
    }
    return new EventNotificationDto(deviceIdentification, timeOfEntry, eventType, reportDescription, index);
}
Also used : EventNotificationDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationDto) EventTypeDto(org.opensmartgridplatform.dto.valueobjects.EventTypeDto)

Example 10 with EventNotificationDto

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

the class EventNotificationMessageProcessor method processMessage.

@Override
public void processMessage(final ObjectMessage message) throws JMSException {
    final MessageMetadata metadata = MessageMetadata.fromMessage(message);
    LOGGER.info("Received message of messageType: {} organisationIdentification: {} deviceIdentification: {}", this.messageType, metadata.getOrganisationIdentification(), metadata.getDeviceIdentification());
    final RequestMessage requestMessage = (RequestMessage) message.getObject();
    final Object dataObject = requestMessage.getRequest();
    try {
        if (dataObject instanceof EventNotificationDto) {
            final EventNotificationDto eventNotification = (EventNotificationDto) dataObject;
            this.eventNotificationMessageService.handleEvent(metadata.getDeviceIdentification(), eventNotification);
        } else if (dataObject instanceof List) {
            final List<EventNotificationDto> eventNotificationDtoList = (List<EventNotificationDto>) dataObject;
            this.eventNotificationMessageService.handleEvents(metadata.getDeviceIdentification(), eventNotificationDtoList);
        }
    } catch (final UnknownEntityException e) {
        final String errorMessage = String.format("%s occurred, reason: %s", e.getClass().getName(), e.getMessage());
        LOGGER.error(errorMessage, e);
        throw new JMSException(errorMessage);
    }
}
Also used : MessageMetadata(org.opensmartgridplatform.shared.infra.jms.MessageMetadata) RequestMessage(org.opensmartgridplatform.shared.infra.jms.RequestMessage) UnknownEntityException(org.opensmartgridplatform.domain.core.exceptions.UnknownEntityException) EventNotificationDto(org.opensmartgridplatform.dto.valueobjects.EventNotificationDto) List(java.util.List) JMSException(javax.jms.JMSException)

Aggregations

EventNotificationDto (org.opensmartgridplatform.dto.valueobjects.EventNotificationDto)11 DateTime (org.joda.time.DateTime)6 EventTypeDto (org.opensmartgridplatform.dto.valueobjects.EventTypeDto)4 RequestMessage (org.opensmartgridplatform.shared.infra.jms.RequestMessage)4 ArrayList (java.util.ArrayList)2 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)2 EventType (org.opensmartgridplatform.domain.core.valueobjects.EventType)2 BdaVisibleString (com.beanit.openiec61850.BdaVisibleString)1 FcModelNode (com.beanit.openiec61850.FcModelNode)1 Then (io.cucumber.java.en.Then)1 Serializable (java.io.Serializable)1 List (java.util.List)1 JMSException (javax.jms.JMSException)1 NotImplementedException (org.apache.commons.lang3.NotImplementedException)1 Test (org.junit.jupiter.api.Test)1 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)1 OslpDevice (org.opensmartgridplatform.adapter.protocol.oslp.elster.domain.entities.OslpDevice)1 LightMeasurementDevice (org.opensmartgridplatform.core.db.api.iec61850.entities.LightMeasurementDevice)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 Event (org.opensmartgridplatform.domain.core.entities.Event)1