Search in sources :

Example 1 with Iec61850SetGpsCoordinatesCommand

use of com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850SetGpsCoordinatesCommand in project Protocol-Adapter-IEC61850 by OSGP.

the class DeviceRegistrationService method setLocationInformation.

/**
     * Set the location information for this device. If the osgp_core database
     * contains longitude and latitude information for the given device, those
     * values must be saved to the corresponding data-attributes.
     */
protected void setLocationInformation(final DeviceConnection deviceConnection) {
    final Ssld ssld = DeviceRegistrationService.this.ssldDataRepository.findByDeviceIdentification(deviceConnection.getDeviceIdentification());
    if (ssld != null) {
        final Float longitude = ssld.getGpsLongitude();
        final Float latitude = ssld.getGpsLatitude();
        LOGGER.info("Ssld found for device: {} longitude: {}, latitude: {}", deviceConnection.getDeviceIdentification(), longitude, latitude);
        if (longitude != null && latitude != null) {
            try {
                new Iec61850SetGpsCoordinatesCommand().setGpsCoordinates(deviceConnection, longitude, latitude);
            } catch (final NodeWriteException e) {
                LOGGER.error("Unable to set location information for device: " + deviceConnection.getDeviceIdentification(), e);
            }
        }
    }
}
Also used : NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) Iec61850SetGpsCoordinatesCommand(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850SetGpsCoordinatesCommand) Ssld(com.alliander.osgp.core.db.api.iec61850.entities.Ssld)

Aggregations

NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)1 Iec61850SetGpsCoordinatesCommand (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.services.commands.Iec61850SetGpsCoordinatesCommand)1 Ssld (com.alliander.osgp.core.db.api.iec61850.entities.Ssld)1