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);
}
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations