use of org.opensmartgridplatform.dto.valueobjects.EventTypeDto 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.EventTypeDto 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.EventTypeDto 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.EventTypeDto in project open-smart-grid-platform by OSGP.
the class EventNotificationMessageServiceTest method sendsLightSensorReportsLightEventToDomainTest.
@Test
void sendsLightSensorReportsLightEventToDomainTest() throws UnknownEntityException {
final String deviceUid = "testUid";
final String deviceIdentification = "testIdentification";
final DateTime dateTime = DateTime.now();
final EventTypeDto eventTypeDto = EventTypeDto.LIGHT_SENSOR_REPORTS_LIGHT;
final String description = "Sensor reports light";
final Integer index = 0;
final EventNotificationDto eventNotificationDto = new EventNotificationDto(deviceUid, dateTime, eventTypeDto, description, index);
this.eventNotificationMessageService.handleEvent(deviceIdentification, eventNotificationDto);
final ArgumentMatcher<RequestMessage> matchesEventType = (final RequestMessage message) -> ((Event) message.getRequest()).getEventType() == EventType.LIGHT_SENSOR_REPORTS_LIGHT;
verify(this.domainRequestService).send(argThat(matchesEventType), eq(MessageType.EVENT_NOTIFICATION.name()), any());
}
Aggregations