use of org.opensmartgridplatform.webdevicesimulator.domain.valueobjects.EventNotificationToBeSent in project open-smart-grid-platform by OSGP.
the class EventNotificationTransition method run.
@Override
public void run() {
if (Boolean.TRUE.equals(this.deviceManagementService.getEventNotification())) {
// The original list with listofeventtobesent
final List<EventNotificationToBeSent> listeventNotificationToBeSent = this.deviceManagementService.getEventNotificationToBeSent();
// The local list of events
final List<EventNotificationToBeSent> listOfEvents = new ArrayList<>();
// add content of the original list into the local list of events
listOfEvents.addAll(listeventNotificationToBeSent);
// run through the list of events and send each
for (final EventNotificationToBeSent event : listOfEvents) {
DeviceMessageStatus status;
if (Boolean.TRUE.equals(event.getLightOn())) {
// Send EventNotifications for Light Transition ON
LOGGER.info("Sending LIGHT_EVENTS_LIGHT_ON_VALUE event for device: {}", event.getdeviceId());
status = this.registerDevice.sendEventNotificationCommand(event.getdeviceId(), Oslp.Event.LIGHT_EVENTS_LIGHT_ON_VALUE, "LIGHT_EVENTS_LIGHT_ON_VALUE event occurred on Light Switching on ", null);
} else {
// Send EventNotifications for Light Transition OFF
LOGGER.info("Sending LIGHT_EVENTS_LIGHT_OFF_VALUE event for device: {}", event.getdeviceId());
status = this.registerDevice.sendEventNotificationCommand(event.getdeviceId(), Oslp.Event.LIGHT_EVENTS_LIGHT_OFF_VALUE, "LIGHT_EVENTS_LIGHT_OFF_VALUE event occurred on light Switching off ", null);
}
// device then this doesnt work.
if (status == DeviceMessageStatus.OK) {
listeventNotificationToBeSent.remove(event);
}
}
// The local list of events
listOfEvents.clear();
}
}
Aggregations