Search in sources :

Example 1 with Device

use of com.alliander.osgp.webdevicesimulator.domain.entities.Device in project Protocol-Adapter-OSLP by OSGP.

the class AutonomousDeviceRegister method run.

@Override
public void run() {
    if (this.deviceManagementService.getDevRegistration()) {
        LOGGER.info("Registering devices");
        final List<Device> devices = this.deviceRepository.findAll();
        for (final Device device : devices) {
            LOGGER.info("Autonomous device register for : {}: {} ", device.getId(), device.getDeviceIdentification());
            this.registerDevice.sendRegisterDeviceCommand(device.getId(), false);
            LOGGER.info("Autonomous device register confirmation for : {}: {} ", device.getId(), device.getDeviceIdentification());
            this.registerDevice.sendConfirmDeviceRegistrationCommand(device.getId());
        }
    }
}
Also used : Device(com.alliander.osgp.webdevicesimulator.domain.entities.Device) RegisterDevice(com.alliander.osgp.webdevicesimulator.service.RegisterDevice)

Example 2 with Device

use of com.alliander.osgp.webdevicesimulator.domain.entities.Device in project Protocol-Adapter-OSLP by OSGP.

the class EveningMorningBurnersLightSwitchingOff method run.

@Override
public void run() {
    if (this.deviceManagementService.getLightSwitching()) {
        LOGGER.info("Publiclighting Switching off for devices with Evening/Morning Burners");
        final List<Device> devices = this.deviceRepository.findByHasEveningMorningBurner(true);
        for (final Device device : devices) {
            LOGGER.info("Light switching for : {}: {} ", device.getId(), device.getDeviceIdentification());
            // Switching off Light
            this.switchingServices.lightSwitchOff(device.getId());
            // Send EventNotifications for LightSwitching Off
            LOGGER.info("Sending LIGHT_EVENTS_LIGHT_OFF event for device : {}: {} ", device.getId(), device.getDeviceIdentification());
            // The event index for Evening/Morning Burners is 3.
            this.registerDevice.sendEventNotificationCommand(device.getId(), Oslp.Event.LIGHT_EVENTS_LIGHT_OFF_VALUE, "LIGHT_EVENTS_LIGHT_OFF event occurred on Light Switching off ", 3);
        }
    }
}
Also used : Device(com.alliander.osgp.webdevicesimulator.domain.entities.Device) RegisterDevice(com.alliander.osgp.webdevicesimulator.service.RegisterDevice)

Example 3 with Device

use of com.alliander.osgp.webdevicesimulator.domain.entities.Device in project Protocol-Adapter-OSLP by OSGP.

the class LightSwitchingOff method run.

@Override
public void run() {
    if (this.deviceManagementService.getLightSwitching()) {
        LOGGER.info("Publiclighting Switching off for devices without Evening/Morning Burners");
        final List<Device> devices = this.deviceRepository.findByHasEveningMorningBurner(false);
        for (final Device device : devices) {
            LOGGER.info("Light switching for : {}: {} ", device.getId(), device.getDeviceIdentification());
            // Switching off Light
            this.switchingServices.lightSwitchOff(device.getId());
            // Send EventNotifications for LightSwitching Off
            LOGGER.info("Sending LIGHT_EVENTS_LIGHT_OFF event for device : {}: {} ", device.getId(), device.getDeviceIdentification());
            this.registerDevice.sendEventNotificationCommand(device.getId(), Oslp.Event.LIGHT_EVENTS_LIGHT_OFF_VALUE, "LIGHT_EVENTS_LIGHT_OFF event occurred on Light Switching off ", null);
        }
    }
}
Also used : Device(com.alliander.osgp.webdevicesimulator.domain.entities.Device) RegisterDevice(com.alliander.osgp.webdevicesimulator.service.RegisterDevice)

Example 4 with Device

use of com.alliander.osgp.webdevicesimulator.domain.entities.Device in project Protocol-Adapter-OSLP by OSGP.

the class LightSwitchingOn method run.

@Override
public void run() {
    if (this.deviceManagementService.getLightSwitching()) {
        LOGGER.info("Publiclighting Switching on for devices without Evening/Morning Burners");
        final List<Device> devices = this.deviceRepository.findByHasEveningMorningBurner(false);
        for (final Device device : devices) {
            LOGGER.info("Light switching for : {}: {} ", device.getId(), device.getDeviceIdentification());
            // Switching on Light
            this.switchingServices.lightSwitchOn(device.getId());
            // Send EventNotifications for LightSwitching on
            LOGGER.info("Sending LIGHT_EVENTS_LIGHT_ON event for device : {}: {} ", device.getId(), device.getDeviceIdentification());
            this.registerDevice.sendEventNotificationCommand(device.getId(), Oslp.Event.LIGHT_EVENTS_LIGHT_ON_VALUE, "LIGHT_EVENTS_LIGHT_ON event occurred on Light Switching on ", null);
        }
    }
}
Also used : Device(com.alliander.osgp.webdevicesimulator.domain.entities.Device) RegisterDevice(com.alliander.osgp.webdevicesimulator.service.RegisterDevice)

Example 5 with Device

use of com.alliander.osgp.webdevicesimulator.domain.entities.Device in project Protocol-Adapter-OSLP by OSGP.

the class TariffSwitchingHigh method run.

@Override
public void run() {
    if (this.deviceManagementService.getTariffSwitching()) {
        LOGGER.info("TariffSwitching on for devices");
        final List<Device> devices = this.deviceRepository.findAll();
        for (final Device device : devices) {
            LOGGER.info("Tariff switching on for : {}: {} ", device.getId(), device.getDeviceIdentification());
            // Switching on Tariff
            this.switchingServices.tariffSwitchHigh(device.getId());
            // Send EventNotifications for TariffSwitching Off
            LOGGER.info("Sending TARIFF_EVENTS_TARIFF_ON event for device : {}: {} ", device.getId(), device.getDeviceIdentification());
            this.registerDevice.sendEventNotificationCommand(device.getId(), Oslp.Event.TARIFF_EVENTS_TARIFF_ON_VALUE, "TARIFF_EVENTS_TARIFF_ON event occurred on Tariff Switching high ", 1);
        }
    }
}
Also used : Device(com.alliander.osgp.webdevicesimulator.domain.entities.Device) RegisterDevice(com.alliander.osgp.webdevicesimulator.service.RegisterDevice)

Aggregations

Device (com.alliander.osgp.webdevicesimulator.domain.entities.Device)23 RegisterDevice (com.alliander.osgp.webdevicesimulator.service.RegisterDevice)15 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 DeviceSimulatorException (com.alliander.osgp.webdevicesimulator.exceptions.DeviceSimulatorException)4 OslpEnvelope (com.alliander.osgp.oslp.OslpEnvelope)3 DeviceMessageStatus (com.alliander.osgp.webdevicesimulator.domain.entities.DeviceMessageStatus)3 IOException (java.io.IOException)3 UnknownHostException (java.net.UnknownHostException)3 Oslp (com.alliander.osgp.oslp.Oslp)2 ByteString (com.google.protobuf.ByteString)2 Message (com.alliander.osgp.oslp.Oslp.Message)1 OutOfSequenceEvent (com.alliander.osgp.webdevicesimulator.service.OslpChannelHandler.OutOfSequenceEvent)1