Search in sources :

Example 6 with Iec61850Connection

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

the class Iec61850RtuDeviceService method getData.

@Override
public void getData(final GetDataDeviceRequest deviceRequest, final DeviceResponseHandler deviceResponseHandler) throws JMSException {
    try {
        final String serverName = this.getServerName(deviceRequest);
        final ServerModel serverModel = this.connectAndRetrieveServerModel(deviceRequest, serverName);
        final ClientAssociation clientAssociation = this.iec61850DeviceConnectionService.getClientAssociation(deviceRequest.getDeviceIdentification());
        final GetDataResponseDto getDataResponse = this.handleGetData(new DeviceConnection(new Iec61850Connection(new Iec61850ClientAssociation(clientAssociation, null), serverModel), deviceRequest.getDeviceIdentification(), deviceRequest.getOrganisationIdentification(), serverName), deviceRequest);
        final GetDataDeviceResponse deviceResponse = new GetDataDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.OK, getDataResponse);
        deviceResponseHandler.handleResponse(deviceResponse);
    } catch (final ConnectionFailureException se) {
        LOGGER.error("Could not connect to device after all retries", se);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleConnectionFailure(se, deviceResponse);
    } catch (final Exception e) {
        LOGGER.error("Unexpected exception during Get Data", e);
        final EmptyDeviceResponse deviceResponse = new EmptyDeviceResponse(deviceRequest.getOrganisationIdentification(), deviceRequest.getDeviceIdentification(), deviceRequest.getCorrelationUid(), DeviceMessageStatus.FAILURE);
        deviceResponseHandler.handleException(e, deviceResponse);
    }
}
Also used : GetDataDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse) ServerModel(org.openmuc.openiec61850.ServerModel) Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) GetDataResponseDto(com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) DeviceConnection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection) Iec61850ClientAssociation(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ClientAssociation(org.openmuc.openiec61850.ClientAssociation) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) JMSException(javax.jms.JMSException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) EmptyDeviceResponse(com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)

Example 7 with Iec61850Connection

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

the class Iec61850DeviceConnectionService method readAllValues.

public void readAllValues(final String deviceIdentification) throws NodeReadException {
    final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
    if (iec61850Connection == null) {
        return;
    }
    final ClientAssociation clientAssociation = iec61850Connection.getClientAssociation();
    this.iec61850Client.readAllDataValues(clientAssociation);
}
Also used : Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection) Iec61850ClientAssociation(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation) ClientAssociation(org.openmuc.openiec61850.ClientAssociation)

Example 8 with Iec61850Connection

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

the class Iec61850DeviceConnectionService method getModelNode.

private FcModelNode getModelNode(final String logicalDevice, final Iec61850Connection iec61850Connection, final String description) throws ProtocolAdapterException {
    final ServerModel serverModel = iec61850Connection.getServerModel();
    if (serverModel == null) {
        final String msg = String.format("ServerModel is null for logicalDevice {%s}", logicalDevice);
        throw new ProtocolAdapterException(msg);
    }
    final String objRef = description + logicalDevice + "/" + LogicalNode.LOGICAL_NODE_ZERO.getDescription() + "." + DataAttribute.NAME_PLATE.getDescription();
    final FcModelNode modelNode = (FcModelNode) serverModel.findModelNode(objRef, Fc.DC);
    if (modelNode == null) {
        final String msg = String.format("ModelNode is null for {%s}", objRef);
        throw new ProtocolAdapterException(msg);
    }
    return modelNode;
}
Also used : ServerModel(org.openmuc.openiec61850.ServerModel) FcModelNode(org.openmuc.openiec61850.FcModelNode) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Example 9 with Iec61850Connection

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

the class Iec61850DeviceConnectionService method disconnect.

/**
     * Closes the {@link ClientAssociation}, send a disconnect request and close
     * the socket.
     */
public synchronized void disconnect(final String deviceIdentification) {
    LOGGER.info("Trying to disconnect from deviceIdentification: {}", deviceIdentification);
    final Iec61850Connection iec61850Connection = this.fetchIec61850Connection(deviceIdentification);
    if (iec61850Connection != null) {
        iec61850Connection.getClientAssociation().disconnect();
        this.removeIec61850Connection(deviceIdentification);
        LOGGER.info("Disconnected from deviceIdentification: {}", deviceIdentification);
    } else {
        LOGGER.info("Unable to disconnect from deviceIdentification: {}, no cached connection was found", deviceIdentification);
    }
}
Also used : Iec61850Connection(com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)

Aggregations

Iec61850Connection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850Connection)8 Iec61850ClientAssociation (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.Iec61850ClientAssociation)6 ClientAssociation (org.openmuc.openiec61850.ClientAssociation)6 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)5 ServerModel (org.openmuc.openiec61850.ServerModel)5 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)4 DeviceConnection (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.helper.DeviceConnection)4 EmptyDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.EmptyDeviceResponse)3 JMSException (javax.jms.JMSException)3 FcModelNode (org.openmuc.openiec61850.FcModelNode)2 DaDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.da.rtu.DaDeviceResponse)1 GetDataDeviceResponse (com.alliander.osgp.adapter.protocol.iec61850.device.ssld.responses.GetDataDeviceResponse)1 Iec61850Device (com.alliander.osgp.adapter.protocol.iec61850.domain.entities.Iec61850Device)1 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)1 Iec61850ClientBaseEventListener (com.alliander.osgp.adapter.protocol.iec61850.infra.networking.reporting.Iec61850ClientBaseEventListener)1 GetDataResponseDto (com.alliander.osgp.dto.valueobjects.microgrids.GetDataResponseDto)1 Serializable (java.io.Serializable)1 InetAddress (java.net.InetAddress)1 DateTime (org.joda.time.DateTime)1