Search in sources :

Example 1 with ServiceError

use of org.openmuc.openiec61850.ServiceError in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850Client method readAllDataValues.

/**
     * Read the values of all data attributes of all data objects of all Logical
     * Nodes.
     *
     * @param clientAssociation
     *            An {@link ClientAssociation} instance.
     *
     * @throws NodeReadException
     *             In case the read action fails.
     */
public void readAllDataValues(final ClientAssociation clientAssociation) throws NodeReadException {
    try {
        LOGGER.debug("Start getAllDataValues from device");
        clientAssociation.getAllDataValues();
        LOGGER.debug("Completed getAllDataValues from device");
    } catch (final ServiceError e) {
        LOGGER.error("ServiceError during readAllDataValues", e);
        throw new NodeReadException(e.getMessage(), e, ConnectionState.OK);
    } catch (final IOException e) {
        LOGGER.error("IOException during readAllDataValues", e);
        throw new NodeReadException(e.getMessage(), e, ConnectionState.BROKEN);
    }
}
Also used : ServiceError(org.openmuc.openiec61850.ServiceError) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) IOException(java.io.IOException)

Example 2 with ServiceError

use of org.openmuc.openiec61850.ServiceError in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850Client method sendCommandWithRetry.

/**
     * Executes the apply method of the given {@link Function} with retries and
     * message logging.
     *
     * @return The given T.
     */
public <T> T sendCommandWithRetry(final Function<T> function, final String functionName, final String deviceIdentification) throws ProtocolAdapterException {
    T output = null;
    final DeviceMessageLog deviceMessageLog = new DeviceMessageLog(IED.FLEX_OVL, LogicalDevice.LIGHTING, functionName);
    try {
        output = function.apply(deviceMessageLog);
    } catch (final NodeWriteException | NodeReadException e) {
        if (ConnectionState.OK.equals(e.getConnectionState())) {
            // ServiceError means we have to retry.
            LOGGER.error("Caught ServiceError, retrying", e);
            this.sendCommandWithRetry(function, deviceIdentification, 1, deviceMessageLog);
        } else {
            LOGGER.error("Caught IOException, connection with device is broken.", e);
        }
    } catch (final ConnectionFailureException e) {
        throw e;
    } catch (final Exception e) {
        throw new ProtocolAdapterException(e == null ? "Could not execute command" : e.getMessage(), e);
    }
    return output;
}
Also used : DeviceMessageLog(com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) SclParseException(org.openmuc.openiec61850.SclParseException) NodeWriteException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException) NodeReadException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException) ConnectionFailureException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException) IOException(java.io.IOException) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)

Example 3 with ServiceError

use of org.openmuc.openiec61850.ServiceError in project Protocol-Adapter-IEC61850 by OSGP.

the class Iec61850Client method readServerModelFromDevice.

/**
     * Read the device model from the device.
     *
     * @param clientAssociation
     *            The {@link ClientAssociation} instance.
     *
     * @return A {@link ServerModel} instance.
     * @throws ProtocolAdapterException
     */
public ServerModel readServerModelFromDevice(final ClientAssociation clientAssociation) throws ProtocolAdapterException {
    try {
        LOGGER.debug("Start reading server model from device");
        // RetrieveModel() will call all GetDirectory and GetDefinition ACSI
        // services needed to get the complete server model.
        final ServerModel serverModel = clientAssociation.retrieveModel();
        LOGGER.debug("Completed reading server model from device");
        return serverModel;
    } catch (final ServiceError e) {
        clientAssociation.close();
        throw new ProtocolAdapterException("Service Error requesting model.", e);
    } catch (final IOException e) {
        throw new ProtocolAdapterException("Fatal IOException requesting model.", e);
    }
}
Also used : ServiceError(org.openmuc.openiec61850.ServiceError) ServerModel(org.openmuc.openiec61850.ServerModel) ProtocolAdapterException(com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)3 NodeReadException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeReadException)2 ProtocolAdapterException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ProtocolAdapterException)2 ServiceError (org.openmuc.openiec61850.ServiceError)2 DeviceMessageLog (com.alliander.osgp.adapter.protocol.iec61850.domain.valueobjects.DeviceMessageLog)1 ConnectionFailureException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.ConnectionFailureException)1 NodeWriteException (com.alliander.osgp.adapter.protocol.iec61850.exceptions.NodeWriteException)1 SclParseException (org.openmuc.openiec61850.SclParseException)1 ServerModel (org.openmuc.openiec61850.ServerModel)1